Changeset: 07a112231d38 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=07a112231d38 Added Files: sql/jdbc/tests/Tests/Bug_PrepStmtSetString_6382.SQL.bat sql/jdbc/tests/Tests/Bug_PrepStmtSetString_6382.SQL.sh sql/jdbc/tests/Tests/Bug_PrepStmtSetString_6382.stable.err sql/jdbc/tests/Tests/Bug_PrepStmtSetString_6382.stable.out sql/test/BugTracker-2017/Tests/udf_crash_subquery_scalar_paramters.Bug-6399.sql sql/test/BugTracker-2017/Tests/udf_crash_subquery_scalar_paramters.Bug-6399.stable.err sql/test/BugTracker-2017/Tests/udf_crash_subquery_scalar_paramters.Bug-6399.stable.out Modified Files: clients/mapiclient/mclient.c clients/mapiclient/mhelp.c clients/mapilib/mapi.c common/stream/stream.c gdk/gdk_aggr.c gdk/gdk_firstn.c gdk/gdk_logger.c gdk/gdk_orderidx.c gdk/gdk_storage.c gdk/gdk_utils.c geom/monetdb5/geomBulk.c monetdb5/mal/mal_authorize.c monetdb5/mal/mal_instruction.c monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_module.c monetdb5/mal/mal_parser.c monetdb5/mal/mal_scenario.c monetdb5/mal/mal_session.c monetdb5/modules/atoms/json.c monetdb5/modules/atoms/str.c monetdb5/modules/atoms/uuid.c monetdb5/modules/mal/inspect.c monetdb5/modules/mal/mal_mapi.c monetdb5/modules/mal/mdb.c monetdb5/modules/mal/oltp.c monetdb5/optimizer/opt_evaluate.c monetdb5/optimizer/opt_json.c monetdb5/optimizer/opt_macro.c monetdb5/optimizer/opt_mergetable.c monetdb5/optimizer/opt_multiplex.c monetdb5/optimizer/opt_oltp.c monetdb5/optimizer/opt_remap.c monetdb5/optimizer/opt_remoteQueries.c monetdb5/optimizer/opt_support.c sql/backends/monet5/UDF/pyapi/emit.c sql/backends/monet5/generator/generator.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_statement.c sql/common/sql_keyword.c sql/common/sql_stack.c sql/common/sql_string.c sql/common/sql_types.c sql/include/sql_keyword.h sql/jdbc/tests/Tests/All sql/server/rel_semantic.c sql/server/rel_updates.c sql/server/sql_mvc.c sql/server/sql_scan.c sql/server/sql_scan.h sql/storage/bat/bat_table.c sql/storage/store.c sql/storage/store_dependency.c sql/storage/store_sequence.c sql/test/BugTracker-2017/Tests/All Branch: default Log Message:
Merge with Jul2017 branch. diffs (truncated from 2706 to 300 lines): diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -2282,9 +2282,10 @@ doFile(Mapi mid, stream *fp, int useinse #ifdef HAVE_LIBREADLINE struct myread_t rl; #endif + int fd; (void) save_history; /* not used if no readline */ - if (isatty(getFileNo(fp)) /* fails if not a FILE* */ + if ((fd = getFileNo(fp)) >= 0 && isatty(fd) #ifdef WIN32 /* isatty may not give expected result */ && formatter != TESTformatter #endif @@ -2333,11 +2334,8 @@ doFile(Mapi mid, stream *fp, int useinse for (;;) { ssize_t l; l = mnstr_readline(fp, buf + length, bufsiz - length); - if (l <= 0) { - if (length == 0) - length = l; + if (l <= 0) break; - } if (!seen_null_byte && strlen(buf + length) < (size_t) l) { fprintf(stderr, "NULL byte in input on line %d of input\n", lineno); seen_null_byte = 1; @@ -2356,7 +2354,7 @@ doFile(Mapi mid, stream *fp, int useinse lineno++; if (seen_null_byte) continue; - if (length <= 0) { + if (length == 0) { /* end of file */ if (hdl == NULL) { /* nothing more to do */ @@ -2365,7 +2363,6 @@ doFile(Mapi mid, stream *fp, int useinse } /* hdl != NULL, we should finish the current query */ - length = 0; } if (hdl == NULL && length > 0 && interactive) { /* test for special commands */ diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c --- a/clients/mapiclient/mhelp.c +++ b/clients/mapiclient/mhelp.c @@ -823,7 +823,7 @@ sql_word(const char *word, size_t maxlen void sql_help(char *pattern, stream *toConsole, int pagewidth) { - size_t maxlen = 0, len; + size_t maxlen = 1, len; int i, step, ncolumns, total = 0; if (*pattern == '\\') diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1896,7 +1896,7 @@ parse_uri_query(Mapi mid, char *uri) char *val; /* just don't care where it is, assume it all starts from '?' */ - if ((uri = strchr(uri, '?')) == NULL) + if (uri == NULL || (uri = strchr(uri, '?')) == NULL) return; *uri++ = '\0'; /* skip '?' */ @@ -2454,7 +2454,7 @@ mapi_reconnect(Mapi mid) if (s == INVALID_SOCKET) continue; #ifdef HAVE_FCNTL - fcntl(s, F_SETFD, FD_CLOEXEC); + (void) fcntl(s, F_SETFD, FD_CLOEXEC); #endif if (connect(s, rp->ai_addr, (socklen_t) rp->ai_addrlen) != SOCKET_ERROR) break; /* success */ @@ -3374,7 +3374,18 @@ mapi_param_store(MapiHdl hdl) buf[0] = *(char *) src; buf[1] = 0; val = mapi_quote(buf, 1); - checkSpace(strlen(val) + 3); + /* note: k==strlen(hdl->query) */ + if (k + strlen(val) + 3 >= lim) { + char *q = hdl->query; + lim = k + strlen(val) + 3 + MAPIBLKSIZE; + hdl->query = realloc(hdl->query, lim); + if (hdl->query == NULL) { + free(q); + free(val); + return; + } + hdl->query = q; + } sprintf(hdl->query + k, "'%s'", val); free(val); break; diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -3808,13 +3808,13 @@ bs2_create(stream *s, size_t bufsiz, com ns->compbufsiz = compress_bound; ns->compbuf = malloc(ns->compbufsiz); if (!ns->compbuf) { + free(ns->buf); free(ns); - free(ns->buf); return NULL; } } else if (compress_bound < 0) { + free(ns->buf); free(ns); - free(ns->buf); return NULL; } return ns; diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -2290,7 +2290,6 @@ BATminmax(BAT *b, void *aggr, oid pos; const void *res; int s; - int needdecref = 0; BATiter bi; if ((VIEWtparent(b) == 0 || @@ -2333,8 +2332,6 @@ BATminmax(BAT *b, void *aggr, } if (aggr != NULL) /* else: malloc error */ memcpy(aggr, res, s); - if (needdecref) - BBPunfix(b->batCacheid); return aggr; } diff --git a/gdk/gdk_firstn.c b/gdk/gdk_firstn.c --- a/gdk/gdk_firstn.c +++ b/gdk/gdk_firstn.c @@ -698,13 +698,10 @@ BATfirstn_grouped_with_groups(BAT **topn if (rc != GDK_SUCCEED) return GDK_FAIL; BBPunfix(bn7->batCacheid); - if (s) { - bn = BATproject(bn8, s); - BBPunfix(bn8->batCacheid); - if (bn == NULL) - return GDK_FAIL; - } else - bn = bn8; + bn = BATproject(bn8, s); + BBPunfix(bn8->batCacheid); + if (bn == NULL) + return GDK_FAIL; } else { bn = BATfirstn_unique_with_groups(b, s, g, n, asc, &last, &lastg); if (bn == NULL) diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -931,6 +931,7 @@ logger_readlog(logger *lg, char *filenam time_t t0, t1; struct stat sb; int dbg = GDKdebug; + int fd; GDKdebug &= ~(CHECKMASK|PROPMASK); @@ -947,7 +948,7 @@ logger_readlog(logger *lg, char *filenam GDKdebug = dbg; return GDK_SUCCEED; } - if (fstat(getFileNo(lg->log), &sb) < 0) { + if ((fd = getFileNo(lg->log)) < 0 || fstat(fd, &sb) < 0) { fprintf(stderr, "!ERROR: logger_readlog: fstat on opened file %s failed\n", filename); mnstr_destroy(lg->log); lg->log = NULL; diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c --- a/gdk/gdk_orderidx.c +++ b/gdk/gdk_orderidx.c @@ -62,6 +62,8 @@ BATcheckorderidx(BAT *b) int ret; lng t = 0; + if (b == NULL) + return 0; assert(b->batCacheid > 0); ALGODEBUG t = GDKusec(); MT_lock_set(&GDKhashLock(b->batCacheid)); diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c --- a/gdk/gdk_storage.c +++ b/gdk/gdk_storage.c @@ -323,6 +323,10 @@ GDKextendf(int fd, size_t size, const ch int rt = 0; int t0 = 0; +#ifdef STATIC_CODE_ANALYSIS + if (fd < 0) /* in real life, if fd < 0, fstat will fail */ + return GDK_FAIL; +#endif if (fstat(fd, &stb) < 0) { /* shouldn't happen */ GDKsyserror("GDKextendf: fstat unexpectedly failed\n"); diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c --- a/gdk/gdk_utils.c +++ b/gdk/gdk_utils.c @@ -419,9 +419,11 @@ MT_init(void) static void THRinit(void); static void GDKlockHome(int farmid); +#ifndef STATIC_CODE_ANALYSIS #ifndef NDEBUG static MT_Lock mallocsuccesslock MT_LOCK_INITIALIZER("mallocsuccesslock"); #endif +#endif int GDKinit(opt *set, int setlen) @@ -1821,8 +1823,10 @@ char * GDKstrndup(const char *s, size_t size) { char *p = malloc(size + 1); - if (p == NULL) + if (p == NULL) { GDKerror("GDKstrdup failed for %s\n", s); + return NULL; + } memcpy(p, s, size); p[size] = 0; return p; diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c --- a/geom/monetdb5/geomBulk.c +++ b/geom/monetdb5/geomBulk.c @@ -1347,7 +1347,9 @@ wkbMakeLine_bat(bat *outBAT_id, bat *aBA BUN i; //get the BATs - if ((aBAT = BATdescriptor(*aBAT_id)) == NULL || (bBAT = BATdescriptor(*bBAT_id)) == NULL) { + aBAT = BATdescriptor(*aBAT_id); + bBAT = BATdescriptor(*bBAT_id); + if (aBAT == NULL || bBAT == NULL) { if (aBAT) BBPunfix(aBAT->batCacheid); if (bBAT) @@ -1410,7 +1412,9 @@ wkbUnion_bat(bat *outBAT_id, bat *aBAT_i BUN i; //get the BATs - if ((aBAT = BATdescriptor(*aBAT_id)) == NULL || (bBAT = BATdescriptor(*bBAT_id)) == NULL) { + aBAT = BATdescriptor(*aBAT_id); + bBAT = BATdescriptor(*bBAT_id); + if (aBAT == NULL || bBAT == NULL) { if (aBAT) BBPunfix(aBAT->batCacheid); if (bBAT) diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c --- a/monetdb5/mal/mal_authorize.c +++ b/monetdb5/mal/mal_authorize.c @@ -119,13 +119,12 @@ AUTHrequireAdminOrUser(Client cntxt, con return(MAL_SUCCEED); rethrow("requireAdminOrUser", tmp, AUTHresolveUser(&user, id)); - if (username == NULL || strcmp(username, user) != 0) { - GDKfree(user); - throw(INVCRED, "requireAdminOrUser", INVCRED_ACCESS_DENIED " '%s'", user); - } + if (username == NULL || strcmp(username, user) != 0) + tmp = createException(INVCRED, "requireAdminOrUser", + INVCRED_ACCESS_DENIED " '%s'", user); + GDKfree(user); - - return(MAL_SUCCEED); + return tmp; } static void diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c --- a/monetdb5/mal/mal_instruction.c +++ b/monetdb5/mal/mal_instruction.c @@ -823,8 +823,6 @@ clearVariable(MalBlkPtr mb, int varid) VarPtr v; v = getVar(mb, varid); - if (v == 0) - return; if (isVarConstant(mb, varid) || isVarDisabled(mb, varid)) VALclear(&v->value); v->type = 0; diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c --- a/monetdb5/mal/mal_interpreter.c +++ b/monetdb5/mal/mal_interpreter.c @@ -587,9 +587,10 @@ str runMALsequence(Client cntxt, MalBlkP for (i = 0; i < pci->argc; i++) { int a = getArg(pci, i); - garbage[i] = -1; if (stk->stk[a].vtype == TYPE_bat && getEndScope(mb, a) == stkpc && isNotUsedIn(pci, i + 1, a)) garbage[i] = a; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list