Changeset: be6b999e0918 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=be6b999e0918 Added Files: sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64 Modified Files: clients/mapiclient/dump.c clients/mapiclient/eventparser.c clients/mapiclient/stethoscope.c clients/odbc/driver/ODBCConvert.c common/utils/msabaoth.c gdk/gdk_bbp.c gdk/gdk_heap.c gdk/gdk_system.c gdk/gdk_utils.c monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows monetdb5/mal/mal_debugger.c monetdb5/mal/mal_import.c monetdb5/mal/mal_instruction.c monetdb5/mal/mal_listing.c monetdb5/modules/mal/wlc.c sql/backends/monet5/sql.c sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_result.c sql/backends/monet5/sql_upgrades.c sql/storage/bat/bat_storage.c sql/storage/bat/bat_table.c sql/storage/bat/bat_utils.c sql/storage/bat/bat_utils.h sql/storage/store.c sql/test/BugTracker-2009/Tests/overflow.SF-2853458.stable.err.powerpc64 sql/test/BugTracker-2016/Tests/storagemodel.stable.out.Darwin sql/test/BugTracker-2016/Tests/storagemodel.stable.out.FreeBSD sql/test/BugTracker-2016/Tests/storagemodel.stable.out.Windows sql/test/BugTracker-2017/Tests/All sql/test/BugTracker-2017/Tests/case.Bug-6386.stable.out sql/test/BugTracker-2017/Tests/statistics_nils_not_eq_zero.Bug-6331.sql sql/test/BugTracker-2017/Tests/statistics_nils_not_eq_zero.Bug-6331.stable.out sql/test/BugTracker/Tests/explain.SF-1739353.stable.out sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64 sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/emptydb-upgrade/Tests/upgrade.stable.out sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128 sql/test/emptydb/Tests/check.SQL.py sql/test/emptydb/Tests/check.stable.out sql/test/emptydb/Tests/check.stable.out.32bit sql/test/emptydb/Tests/check.stable.out.int128 sql/test/remote/Tests/partition_elim.stable.out sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128 sql/test/testdb-upgrade/Tests/upgrade.stable.out sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128 Branch: default Log Message:
Merge with Mar2018 branch. diffs (truncated from 27114 to 300 lines): diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -1550,8 +1550,11 @@ dump_functions(Mapi mid, stream *toConso len = 500 + (sname ? strlen(sname) : 0) + (fname ? strlen(fname) : 0); query = malloc(len); - if (!query) + if (query == NULL) { + if (to_free) + free(to_free); return 1; + } q = query; end_q = q + len; diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c --- a/clients/mapiclient/eventparser.c +++ b/clients/mapiclient/eventparser.c @@ -333,7 +333,6 @@ eventdump(void) int lineparser(char *row, EventRecord *ev) { -#ifdef HAVE_STRPTIME char *c, *cc, *v =0; struct tm stm; @@ -342,7 +341,7 @@ lineparser(char *row, EventRecord *ev) memset(malvariables, 0, sizeof(malvariables)); /* check basic validaty first */ if (row[0] =='#'){ - return 0; + return 1; /* ok, but nothing filled in */ } if (row[0] != '[') return -1; @@ -351,34 +350,40 @@ lineparser(char *row, EventRecord *ev) /* scan event record number */ c = row+1; - if (c == 0) - return -2; ev->eventnr = atoi(c + 1); /* scan event time" */ c = strchr(c + 1, '"'); - if (c) { - /* convert time to epoch in seconds*/ - cc =c; - memset(&stm, 0, sizeof(struct tm)); - c = strptime(c + 1, "%H:%M:%S", &stm); - ev->clkticks = (((lng) stm.tm_hour * 60 + stm.tm_min) * 60 + stm.tm_sec) * 1000000; - if (c == 0) - return -3; - if (*c == '.') { - lng usec; - /* microseconds */ - usec = strtoll(c + 1, NULL, 10); - assert(usec >= 0 && usec < 1000000); - ev->clkticks += usec; - } - c = strchr(c + 1, '"'); - if (ev->clkticks < 0) { - fprintf(stderr, "parser: read negative value "LLFMT" from\n'%s'\n", ev->clkticks, cc); - } - c++; - } else + if (c == NULL) + return -3; + /* convert time to epoch in seconds*/ + cc =c; + memset(&stm, 0, sizeof(struct tm)); +#ifdef HAVE_STRPTIME + c = strptime(c + 1, "%H:%M:%S", &stm); + ev->clkticks = (((lng) stm.tm_hour * 60 + stm.tm_min) * 60 + stm.tm_sec) * 1000000; + if (c == NULL) + return -3; +#else + int pos; + if (sscanf(c + 1, "%d:%d:%d%n", &stm.tm_hour, &stm.tm_min, &stm.tm_sec, &pos) < 3) return -3; + c += pos + 1; +#endif + if (*c == '.') { + lng usec; + /* microseconds */ + usec = strtoll(c + 1, NULL, 10); + assert(usec >= 0 && usec < 1000000); + ev->clkticks += usec; + } + c = strchr(c + 1, '"'); + if (c == NULL) + return -3; + if (ev->clkticks < 0) { + fprintf(stderr, "parser: read negative value "LLFMT" from\n'%s'\n", ev->clkticks, cc); + } + c++; /* skip pc tag */ { // decode qry[pc]tag @@ -531,9 +536,6 @@ lineparser(char *row, EventRecord *ev) } if (ev->stmt && (v=strstr(ev->stmt, ";\",\t"))) *v = 0; -#else - (void) row; -#endif return 0; } diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c --- a/clients/mapiclient/stethoscope.c +++ b/clients/mapiclient/stethoscope.c @@ -136,55 +136,86 @@ static void convertOldFormat(char *inputfile) { FILE *fdin; char basefile[BUFSIZ]; - char buf[BUFSIZ]={0}, *response = buf, *e; - int first = 0, i = 0; - size_t n; + char *buf, *e; + int notfirst = 0, i; + size_t bufsize; size_t len; EventRecord event; + buf = malloc(BUFSIZ); + if (buf == NULL) { + fprintf(stderr, "Could not allocate memory\n"); + return; + } + bufsize = BUFSIZ; fprintf(stderr, "Converting a file to JSON\n"); fdin = fopen(inputfile,"r"); if( fdin == NULL){ fprintf(stderr,"Could not open the input file %s\n", inputfile); + free(buf); return; } - if( strstr(inputfile,".trace")) - *strstr(inputfile,".trace") = 0; - snprintf(basefile,BUFSIZ,"%s.json",inputfile); - trace = fopen(basefile,"w"); + /* find file name extension */ + e = strrchr(inputfile, '.'); + if (e != NULL) { + char *s; + /* if last dot before last /, ignore the dot */ + if ((s = strrchr(inputfile, '/')) != NULL && s > e) + e = NULL; +#if DIR_SEP != '/' + /* on Windows, look at both directory separators */ + else if ((s = strrchr(inputfile, DIR_SEP)) != NULL && s > e) + e = NULL; +#endif + } + if (e == NULL) + i = (int) strlen(inputfile); + else + i = (int) (e - inputfile); + snprintf(basefile, BUFSIZ, "%.*s.json", i, inputfile); + trace = fopen(basefile, "w"); if( trace == NULL){ fprintf(stderr,"Could not create the output file %s\n", basefile); + free(buf); + fclose(fdin); return; } - fprintf(trace?trace:stdout,"[\n{"); + fprintf(trace,"[\n{"); len = 0; - while ((n = fread(buf + len, 1, BUFSIZ - len, fdin)) > 0) { - buf[len + n] = 0; - response = buf; - while ((e = strchr(response, '\n')) != NULL) { - *e = 0; - i = lineparser(response, &event); - if (debug ) - fprintf(stderr, "PARSE %d:%s\n", i, response); - renderJSONevent((trace?trace:stdout), &event, first); - first++; - response = e + 1; + memset(&event, 0, sizeof(event)); + while (fgets(buf + len, bufsize - len, fdin) != NULL) { + while ((e = strchr(buf + len, '\n')) == NULL) { + /* rediculously long line */ + len += strlen(buf + len); /* i.e. len = strlen(buf) */ + bufsize += BUFSIZ; + if ((e = realloc(buf, bufsize)) == NULL) { + free(buf); + fclose(fdin); + fclose(trace); + fprintf(stderr, "Could not allocate memory\n"); + return; + } + buf = e; + if (fgets(buf + len, bufsize - len, fdin) == NULL) { + /* incomplete line */ + e = NULL; /* no newline to zap */ + break; + } } - if( i){ - renderJSONevent((trace?trace:stdout),&event,first); + if (e) + *e = 0; /* zap newline */ + i = lineparser(buf, &event); + if (i == 0) { + renderJSONevent(trace, &event, notfirst); resetEventRecord(&event); + notfirst = 1; } - /* handle last line in buffer */ - if (*response) { - if (debug) - fprintf(stderr,"LASTLINE:%s", response); - len = strlen(response); - strncpy(buf, response, len + 1); - } else - len = 0; } - fprintf(trace?trace:stdout,"}]\n"); + fprintf(trace,"}]\n"); + free(buf); + fclose(fdin); + fclose(trace); return; } @@ -239,7 +270,7 @@ main(int argc, char **argv) char *password = NULL; char buf[BUFSIZ], *buffer, *e, *response; int done = 0; - EventRecord *ev = malloc(sizeof(EventRecord)); + EventRecord *ev = calloc(1, sizeof(EventRecord)); static struct option long_options[13] = { { "dbname", 1, 0, 'd' }, @@ -257,8 +288,7 @@ main(int argc, char **argv) { 0, 0, 0, 0 } }; - if( ev) memset((char*)ev,0, sizeof(EventRecord)); - else { + if( ev == NULL) { fprintf(stderr,"could not allocate space\n"); exit(-1); } diff --git a/clients/odbc/driver/ODBCConvert.c b/clients/odbc/driver/ODBCConvert.c --- a/clients/odbc/driver/ODBCConvert.c +++ b/clients/odbc/driver/ODBCConvert.c @@ -587,9 +587,6 @@ parsemonthintervalstring(char **svalp, slen--; sval++; } - ival->interval_type = SQL_IS_YEAR_TO_MONTH; - ival->intval.year_month.year = val1; - ival->intval.year_month.month = val2; if (val2 >= 12) return SQL_ERROR; } @@ -612,10 +609,13 @@ parsemonthintervalstring(char **svalp, return SQL_ERROR; if (leadingprecision > p) return SQL_ERROR; + ival->intval.year_month.year = val1; if (val2 == -1) { ival->interval_type = SQL_IS_YEAR; - ival->intval.year_month.year = val1; ival->intval.year_month.month = 0; + } else { + ival->interval_type = SQL_IS_YEAR_TO_MONTH; + ival->intval.year_month.month = val2; } if (slen > 0 && isspace((unsigned char) *sval)) { while (slen > 0 && isspace((unsigned char) *sval)) { @@ -3560,6 +3560,7 @@ ODBCStore(ODBCStmt *stmt, snprintf(data, sizeof(data), "INTERVAL %s'%u-%u' YEAR TO MONTH", ival.interval_sign ? "" : "- ", (unsigned int) ival.intval.year_month.year, (unsigned int) ival.intval.year_month.month); break; default: + /* cannot happen */ break; } assigns(buf, bufpos, buflen, data, stmt); diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c --- a/common/utils/msabaoth.c +++ b/common/utils/msabaoth.c @@ -186,7 +186,7 @@ msab_init(const char *dbfarm, const char /* remove in a separate loop after reading the directory, * so as to not have any interference */ while (dbe != NULL) { - remove(dbe->path); + (void) remove(dbe->path); db = dbe; dbe = dbe->next; free(db); @@ -334,11 +334,10 @@ msab_retreatScenario(const char *lang) fflush(f); fclose(f); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list