Changeset: ee4ff6023e5f for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ee4ff6023e5f Modified Files: clients/mapilib/mapi.c common/utils/conversion.c sql/backends/monet5/sql_result.c Branch: protocol Log Message:
Change time conversion and treat single element BAT differently than normal BATs for print width computation (for backwards compatibility reasons). diffs (193 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -4145,7 +4145,7 @@ static char* mapi_convert_unknown(struct static MapiMsg -read_into_cache_new(MapiHdl hdl, int lookahead, int expect_result, int *error) +read_into_cache(MapiHdl hdl, int lookahead) { char *line, *copy; Mapi mid; @@ -4163,7 +4163,6 @@ read_into_cache_new(MapiHdl hdl, int loo if (result && result->next && result->next->prot10_resultset) { // if we have a prot10 resultset we don't want to read lines, because prot10 result sets do not consist of lines hdl->active = result->next; - if (expect_result) expected_prot10_result(error); return MOK; } for (;;) { @@ -4177,7 +4176,6 @@ read_into_cache_new(MapiHdl hdl, int loo lng nr_rows; lng nr_cols; lng i; - expect_result = 0; result = new_result(hdl); result->prot10_resultset = 1; @@ -4338,7 +4336,6 @@ read_into_cache_new(MapiHdl hdl, int loo while (*line) { if (*line != *copy) /* must be EOF or PROMPT1 \001\001\n */ return mid->error; - } line++; copy++; } @@ -4349,7 +4346,6 @@ read_into_cache_new(MapiHdl hdl, int loo hdl->needmore = 1; mid->active = hdl; } - if (expect_result) expected_prot10_result(error); return mid->error; case '!': /* start a new result set if we don't have one @@ -4388,7 +4384,6 @@ read_into_cache_new(MapiHdl hdl, int loo (result->querytype == -1 /* unknown (not SQL) */ || result->querytype == Q_TABLE || result->querytype == Q_UPDATE)) { - if (expect_result) expected_prot10_result(error); return mid->error; } break; @@ -4396,12 +4391,6 @@ read_into_cache_new(MapiHdl hdl, int loo } } -static MapiMsg -read_into_cache(MapiHdl hdl, int lookahead) { - int error = 0; - return read_into_cache_new(hdl, lookahead, 0, &error); -} - MapiMsg mapi_virtual_result(MapiHdl hdl, int columns, const char **columnnames, const char **columntypes, const int *columnlengths, int tuplecount, const char ***tuples) { @@ -4634,14 +4623,8 @@ mapi_query(Mapi mid, const char *cmd) ret = mid->error; if (ret == MOK) ret = mapi_execute_internal(hdl); - if (ret == MOK) { - int error = 0; - ret = read_into_cache_new(hdl, 1, 1, &error); - if (error != 0) { - /*printf("\nProblem with query: %s\n", cmd); - printf("Expected prot10 result set but did not get it.\n\n");*/ - } - } + if (ret == MOK) + ret = read_into_cache(hdl, 1); return hdl; } diff --git a/common/utils/conversion.c b/common/utils/conversion.c --- a/common/utils/conversion.c +++ b/common/utils/conversion.c @@ -263,14 +263,20 @@ conversion_date_to_string(char *dst, int int conversion_time_to_string(char *dst, int len, const int *src, int null_value, int timezone_diff) { - int sec, min, hour; + int sec, min, hour, ms; //int ms; int time = *src; + int mtime = 24 * 60 * 60 * 1000; if (len < daytimeStrlen) return -1; if (*src == null_value) { strcpy(dst, NULL_STRING); return 3; } + // time has to be between 00:00 and 24:00 + if (time < 0) + time = mtime + time; + if (time > mtime) + time = time - mtime; // account for the timezone of the client time += timezone_diff * 1000 * 60 * 60; @@ -280,9 +286,9 @@ conversion_time_to_string(char *dst, int min = time / 60000; time -= min * 60000; sec = time / 1000; - //time -= sec * 1000; - //ms = time; - return sprintf(dst, "%02d:%02d:%02d", hour, min, sec); + time -= sec * 1000; + ms = time; + return sprintf(dst, "%02d:%02d:%02d.%03d000", hour, min, sec, ms); } static int days_between_zero_and_epoch = 719528; 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 @@ -1439,27 +1439,32 @@ get_print_width(int mtype, int eclass, i } } else if (eclass == EC_NUM || eclass == EC_POS || eclass == EC_MONTH || eclass == EC_SEC) { count = 0; + BAT *b = NULL; if (bid) { - BAT *b = BATdescriptor(bid); - + b = BATdescriptor(bid); if (b) { - 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); + if (BATcount(b) == 1) { + p = Tloc(b, 0); + } 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); + } else if (mtype == TYPE_hge) { + count = bat_max_hgelength(b); #endif - } else { - assert(0); + } else { + assert(0); + } + count += incr; + BBPunfix(b->batCacheid); + b = NULL; } - count += incr; - BBPunfix(b->batCacheid); } else { assert(b); /* [stefan.maneg...@cwi.nl]: @@ -1470,7 +1475,9 @@ get_print_width(int mtype, int eclass, i return -1|0|1 ; */ } - } else { + } + + if (!bid || b) { if (p) { #ifdef HAVE_HGE hge val = 0; @@ -1503,6 +1510,9 @@ 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; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list