Changeset: 55bfaf969866 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=55bfaf969866 Modified Files: sql/backends/monet5/sql.c sql/backends/monet5/sql_result.c sql/backends/monet5/sql_result.h Branch: protocol Log Message:
Correct print type widths when mvc_scalar_value_wrap is called. diffs (149 lines): diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c --- a/sql/backends/monet5/sql.c +++ b/sql/backends/monet5/sql.c @@ -3430,12 +3430,19 @@ mvc_scalar_value_wrap(Client cntxt, MalB return MAL_SUCCEED; } - // scalar values are single-column result sets - res_id = mvc_result_table(b->mvc, 1, 1, NULL); - mvc_result_value(b->mvc, *tn, *cn, *type, *digits, *scale, p, mtype); if (b->client->protocol == prot10 || b->client->protocol == prot10compressed) { - if (mvc_export_result(b, cntxt->fdout, res_id)) - throw(SQL, "sql.exportResult", "failed"); + // scalar values are single-column result sets + // create the empty result table + mvc *m = b->mvc; + int res_id = mvc_result_table(m, 1, 1, NULL); + res_table *t; + // fill it with the single-column value + mvc_result_value(m, *tn, *cn, *type, *digits, *scale, p, mtype); + t = res_tables_find(m->results, res_id); + // export the value to the client + if (mvc_export_resultset_prot10(m, t, cntxt->fdout, b->client->fdin->s, b->client->blocksize, b->client->compute_column_widths, p) < 0) { + throw(SQL, "sql.exportValue", "failed"); + } return MAL_SUCCEED; } if (b->out == NULL || mvc_export_value(b, b->out, 1, *tn, *cn, *type, *digits, *scale, *eclass, p, mtype, "", "NULL") != SQL_OK) diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c --- a/sql/backends/monet5/sql_result.c +++ b/sql/backends/monet5/sql_result.c @@ -1235,7 +1235,6 @@ mvc_export_row(backend *b, stream *s, re int i, ok = 1; int csv = (b->output_format == OFMT_CSV); int json = (b->output_format == OFMT_JSON); - if (!s) return 0; @@ -1438,33 +1437,28 @@ get_print_width(int mtype, int eclass, i return l; } } else if (eclass == EC_NUM || eclass == EC_POS || eclass == EC_MONTH || eclass == EC_SEC) { - BAT *b = NULL; count = 0; if (bid) { - b = BATdescriptor(bid); + BAT *b = BATdescriptor(bid); + if (b) { - if (BATcount(b) == 1) { - p = Tloc(b, 0); + if (mtype == TYPE_bte) { + count = bat_max_btelength(b); + } else if (mtype == TYPE_sht) { + count = bat_max_shtlength(b); + } else if (mtype == TYPE_int) { + count = bat_max_intlength(b); + } else if (mtype == TYPE_lng) { + count = bat_max_lnglength(b); +#ifdef HAVE_HGE + } else if (mtype == TYPE_hge) { + count = bat_max_hgelength(b); +#endif } else { - if (mtype == TYPE_bte) { - count = bat_max_btelength(b); - } else if (mtype == TYPE_sht) { - count = bat_max_shtlength(b); - } else if (mtype == TYPE_int) { - count = bat_max_intlength(b); - } else if (mtype == TYPE_lng) { - count = bat_max_lnglength(b); -#ifdef HAVE_HGE - } else if (mtype == TYPE_hge) { - count = bat_max_hgelength(b); -#endif - } else { - assert(0); - } - count += incr; - BBPunfix(b->batCacheid); - b = NULL; + assert(0); } + count += incr; + BBPunfix(b->batCacheid); } else { assert(b); /* [stefan.maneg...@cwi.nl]: @@ -1475,9 +1469,7 @@ get_print_width(int mtype, int eclass, i return -1|0|1 ; */ } - } - - if (!bid || b) { + } else { if (p) { #ifdef HAVE_HGE hge val = 0; @@ -1510,9 +1502,6 @@ get_print_width(int mtype, int eclass, i count = 0; } } - if (b) { - BBPunfix(b->batCacheid); - } if (eclass == EC_SEC && count < 5) count = 5; return count; @@ -1852,7 +1841,7 @@ static size_t max(size_t a, size_t b) { return a > b ? a : b; } -static int mvc_export_resultset_prot10(mvc *m, res_table* t, stream* s, stream *c, size_t bsize, int compute_lengths) { +int mvc_export_resultset_prot10(mvc *m, res_table* t, stream* s, stream *c, size_t bsize, int compute_lengths, ptr p) { BAT *order; lng count; size_t i; @@ -2011,7 +2000,7 @@ static int mvc_export_resultset_prot10(m } if (compute_lengths) { - if (!mnstr_writeLng(s, get_print_width(mtype, type->eclass, c->type.digits, c->type.scale, type_has_tz(&c->type), iterators[i].b->batCacheid, c->p))) { + if (!mnstr_writeLng(s, get_print_width(mtype, type->eclass, c->type.digits, c->type.scale, type_has_tz(&c->type), p ? 0 : iterators[i].b->batCacheid, p ? p : c->p))) { fres = -1; goto cleanup; } @@ -2204,7 +2193,7 @@ mvc_export_result(backend *b, stream *s, return mvc_export_file(b, s, t); if (b->client->protocol == prot10 || b->client->protocol == prot10compressed) { - return mvc_export_resultset_prot10(m, t, s, b->client->fdin->s, b->client->blocksize, b->client->compute_column_widths); + return mvc_export_resultset_prot10(m, t, s, b->client->fdin->s, b->client->blocksize, b->client->compute_column_widths, NULL); } if (!json) { diff --git a/sql/backends/monet5/sql_result.h b/sql/backends/monet5/sql_result.h --- a/sql/backends/monet5/sql_result.h +++ b/sql/backends/monet5/sql_result.h @@ -23,6 +23,7 @@ extern int mvc_export_value(backend *b, extern int mvc_export_result(backend *b, stream *s, int res_id); extern int mvc_export_head(backend *b, stream *s, int res_id, int only_header, int compute_lengths); extern int mvc_export_chunk(backend *b, stream *s, int res_id, BUN offset, BUN nr); +extern int mvc_export_resultset_prot10(mvc *m, res_table* t, stream* s, stream *c, size_t bsize, int compute_lengths, ptr p); extern int mvc_export_prepare(mvc *c, stream *s, cq *q, str w); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list