fixed limit doesn't work for queries w/o postproc.

dev
Bill 2 years ago
parent 7478bdf42c
commit 1673726a2d

@ -333,7 +333,7 @@ SELECT * FROM my_table WHERE c1 > 10
License (BSD 3-Clause License): https://github.com/ben-strasser/fast-cpp-csv-parser/blob/master/LICENSE
- [Dragonbox](https://github.com/jk-jeon/dragonbox)<br>
Author: Junekey Jeon
Author: Junekey Jeon<br>
License (Boost, Apache2-LLVM): <br>https://github.com/jk-jeon/dragonbox/blob/master/LICENSE-Boost <br>
https://github.com/jk-jeon/dragonbox/blob/master/LICENSE-Apache2-LLVM

@ -550,7 +550,8 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None):
continue
elif q == 'r': # build and run
if state.server_mode == RunType.Threaded:
qs = [ctypes.c_char_p(bytes(q, 'utf-8')) for q in cxt.queries if len(q)]
enc = lambda q: 'latin-1' if q.startswith('O') else 'utf-8'
qs = [ctypes.c_char_p(bytes(q, enc(q))) for q in cxt.queries if len(q)]
sz = len(qs)
payload = (ctypes.c_char_p*sz)(*qs)
state.payload = payload

@ -424,7 +424,7 @@ class projection(ast_node):
else:
self.context.ccode = ''
if self.limit != 0 and not self.outfile:
self.context.direct_output()
self.context.direct_output(self.limit)
class select_distinct(projection):
first_order = 'select_distinct'
@ -1554,8 +1554,7 @@ class passthru_sql(ast_node):
context.queries.append('Q' + sql.strip('\r\n\t ;') + ';')
lq = sq.lower()
if lq.startswith('select'):
context.queries.append('O')
context.direct_output()
class user_module_function(OperatorBase):
def __init__(self, name, nargs, ret_type, context : Context):

@ -250,8 +250,12 @@ class Context:
self.ccode = ''
self.finalize_query()
def direct_output(self):
self.queries.append('O')
def direct_output(self, limit = -1, sep = ' ', end = '\n'):
if type(limit) is not int or limit > 2**32 - 1 or limit < 0:
limit = 2**32 - 1
limit = limit.to_bytes(4, 'little').decode('latin-1')
self.queries.append(
'O' + limit + sep + end)
def abandon_postproc(self):
self.ccode = ''

@ -200,7 +200,7 @@ void print_monetdb_results(Server* srv, const char* sep = " ", const char* end =
if (!srv->haserror() && srv->cnt && limit){
char buffer[output_buffer_size];
auto _res = static_cast<monetdbe_result*> (srv->res);
const auto& ncols = _res->ncols;
const auto ncols = _res->ncols;
monetdbe_column** cols = static_cast<monetdbe_column**>(malloc(sizeof(monetdbe_column*) * ncols));
prt_fn_t *prtfns = (prt_fn_t*) alloca(sizeof(prt_fn_t) * ncols);
char** col_data = static_cast<char**> (alloca(sizeof(char*) * ncols));
@ -210,6 +210,7 @@ void print_monetdb_results(Server* srv, const char* sep = " ", const char* end =
const size_t l_sep = strlen(sep);
const size_t l_end = strlen(end);
char* _buffer = buffer;
const auto cnt = srv->cnt < limit? srv->cnt : limit;
for(uint32_t i = 0; i < ncols; ++i){
err_msg = monetdbe_result_fetch(_res, &cols[i], i);
@ -228,7 +229,7 @@ void print_monetdb_results(Server* srv, const char* sep = " ", const char* end =
header_string.resize(header_string.size() - l_sep - 1);
header_string += end + std::string(header_string.size(), '=') + end;
fputs(header_string.c_str(), stdout);
for(uint64_t i = 0; i < srv->cnt; ++i){
for(uint64_t i = 0; i < cnt; ++i){
for(uint32_t j = 0; j < ncols; ++j){
//copy the field to buf
_buffer = prtfns[j](col_data[j], _buffer);
@ -357,8 +358,13 @@ int dll_main(int argc, char** argv, Context* cxt){
case 'O':
{
if(!server->haserror()){
uint32_t limit;
memcpy(&limit, n_recvd[i] + 1, sizeof(uint32_t));
printf("Limit: %x\n", limit);
if (limit == 0)
continue;
timer.reset();
print_monetdb_results(server);
print_monetdb_results(server, " ", "\n", limit);
cfg->stats.postproc_time += timer.elapsed();
}
}

Loading…
Cancel
Save