Changeset: 80b87492af25 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/80b87492af25 Modified Files: clients/Tests/MAL-signatures-hge.test clients/Tests/MAL-signatures.test clients/Tests/exports.stable.out monetdb5/modules/kernel/algebra.c sql/backends/monet5/sql.c sql/storage/store.c testing/Mtest.py.in Branch: default Log Message:
Merge with Aug2024 branch. diffs (truncated from 2861 to 300 lines): diff --git a/clients/Tests/MAL-signatures-hge.test b/clients/Tests/MAL-signatures-hge.test --- a/clients/Tests/MAL-signatures-hge.test +++ b/clients/Tests/MAL-signatures-hge.test @@ -46584,11 +46584,6 @@ pattern io.printf(X_0:streams, X_1:str, IOprintfStream; Select default format io -setmallocsuccesscount -command io.setmallocsuccesscount(X_0:lng):void -IOsetmallocsuccesscount; -Set number of mallocs that are allowed to succeed. -io stdin pattern io.stdin():bstream io_stdin; diff --git a/clients/Tests/MAL-signatures.test b/clients/Tests/MAL-signatures.test --- a/clients/Tests/MAL-signatures.test +++ b/clients/Tests/MAL-signatures.test @@ -35074,11 +35074,6 @@ pattern io.printf(X_0:streams, X_1:str, IOprintfStream; Select default format io -setmallocsuccesscount -command io.setmallocsuccesscount(X_0:lng):void -IOsetmallocsuccesscount; -Set number of mallocs that are allowed to succeed. -io stdin pattern io.stdin():bstream io_stdin; diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -319,7 +319,6 @@ void GDKreset(int status); void GDKsetbuf(char *); void GDKsetdebug(unsigned debug); gdk_return GDKsetenv(const char *name, const char *value); -void GDKsetmallocsuccesscount(lng count); stream *GDKstdin; stream *GDKstdout; ssize_t GDKstrFromStr(unsigned char *restrict dst, const unsigned char *restrict src, ssize_t len, char quote); diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -1286,6 +1286,8 @@ describe_table(Mapi mid, const char *sch s = sescape(schema); t = sescape(tname); + if (s == NULL || t == NULL) + goto bailout; maxquerylen = 5120 + strlen(t) + strlen(s); query = malloc(maxquerylen); if (query == NULL) @@ -2249,7 +2251,11 @@ dump_table(Mapi mid, const char *schema, goto doreturn; } for (int64_t i = 0; i < rows; i++) { - mapi_fetch_row(hdl); + if (mapi_fetch_row(hdl) == 0) { + mapi_close_handle(hdl); + fprintf(stderr, "unexepcted error\n"); + goto doreturn; + } tables[i].schema = strdup(mapi_fetch_field(hdl, 0)); tables[i].table = strdup(mapi_fetch_field(hdl, 1)); if (tables[i].schema == NULL || tables[i].table == NULL) { @@ -3365,7 +3371,6 @@ dump_database(Mapi mid, stream *sqlf, co mnstr_printf(sqlf, " %sCYCLE;\n", strcmp(cycle, "true") == 0 ? "" : "NO "); if (mnstr_errnr(sqlf) != MNSTR_NO__ERROR) { mapi_close_handle(hdl); - hdl = NULL; goto bailout2; } } diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -3223,7 +3223,8 @@ putfile(void *data, const char *filename close_stream(priv->f); priv->f = NULL; if (fname) { - MT_remove(fname); + if (MT_remove(fname) < 0) + perror(fname); free(fname); } if (filename == NULL) diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c --- a/clients/mapilib/connect.c +++ b/clients/mapilib/connect.c @@ -430,7 +430,7 @@ send_all_clientinfo(Mapi mid) if (hostname[0]) reallocprintf(&buf, &pos, &cap, "ClientHostname=%s\n", hostname); - if (application_name[0]) + if (application_name && application_name[0]) reallocprintf(&buf, &pos, &cap, "ApplicationName=%s\n", application_name); reallocprintf(&buf, &pos, &cap, "ClientLibrary="); if (mid->clientprefix) @@ -466,7 +466,7 @@ mapi_handshake(Mapi mid) /* consume server challenge */ len = mnstr_read_block(mid->from, buf, 1, sizeof(buf)); - check_stream(mid, mid->from, "Connection terminated while starting handshake", (mid->blk.eos = true, mid->error)); + check_stream(mid, mid->from, len, "Connection terminated while starting handshake", (mid->blk.eos = true, mid->error)); mapi_log_data(mid, "RECV HANDSHAKE", buf, len); @@ -576,7 +576,7 @@ mapi_handshake(Mapi mid) char *clientinfo = strtok_r(NULL, ":", &strtok_state); if (clientinfo) { - if (strcmp(oobintr, "OOBINTR=1") == 0) { + if (strcmp(clientinfo, "CLIENTINFO") == 0) { mid->clientinfo_supported = true; } } @@ -603,7 +603,6 @@ mapi_handshake(Mapi mid) pwdhash = mcrypt_SHA1Sum(password, strlen(password)); } else { - (void)pwdhash; snprintf(buf, sizeof(buf), "server requires unknown hash '%.100s'", serverhash); close_connection(mid); @@ -619,6 +618,7 @@ mapi_handshake(Mapi mid) char *replacement_password = malloc(1 + strlen(pwdhash) + 1); if (replacement_password == NULL) { + free(pwdhash); close_connection(mid); return mapi_setError(mid, "malloc failed", __func__, MERROR); } @@ -722,10 +722,10 @@ mapi_handshake(Mapi mid) len = strlen(buf); mapi_log_data(mid, "HANDSHAKE SEND", buf, len); - mnstr_write(mid->to, buf, 1, len); - check_stream(mid, mid->to, "Could not send initial byte sequence", mid->error); - mnstr_flush(mid->to, MNSTR_FLUSH_DATA); - check_stream(mid, mid->to, "Could not send initial byte sequence", mid->error); + len = mnstr_write(mid->to, buf, 1, len); + check_stream(mid, mid->to, len, "Could not send initial byte sequence", mid->error); + len = mnstr_flush(mid->to, MNSTR_FLUSH_DATA); + check_stream(mid, mid->to, len, "Could not send initial byte sequence", mid->error); // Clear the redirects before we receive new ones for (char **r = mid->redirects; *r != NULL; r++) { diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1682,8 +1682,8 @@ finish_handle(MapiHdl hdl) assert(mid->active == NULL || mid->active == hdl); hdl->needmore = false; mid->active = hdl; - mnstr_flush(mid->to, MNSTR_FLUSH_DATA); - check_stream(mid, mid->to, "write error on stream", mid->error); + int f = mnstr_flush(mid->to, MNSTR_FLUSH_DATA); + check_stream(mid, mid->to, f, "write error on stream", mid->error); read_into_cache(hdl, 0); } for (i = 0; i < hdl->npending_close; i++) { @@ -1712,8 +1712,8 @@ finish_handle(MapiHdl hdl) assert(mid->active == NULL || mid->active == hdl); hdl->needmore = false; mid->active = hdl; - mnstr_flush(mid->to, MNSTR_FLUSH_DATA); - check_stream(mid, mid->to, "write error on stream", mid->error); + int f = mnstr_flush(mid->to, MNSTR_FLUSH_DATA); + check_stream(mid, mid->to, f, "write error on stream", mid->error); read_into_cache(hdl, 0); } } @@ -1795,12 +1795,12 @@ mapi_new(msettings *settings) /* then fill in some details */ *mid = MapiStructDefaults; - mid->settings = settings; mid->index = (uint32_t) ATOMIC_ADD(&index, 1); /* for distinctions in log records */ if ((mid->blk.buf = malloc(mid->blk.lim + 1)) == NULL) { mapi_destroy(mid); return NULL; } + mid->settings = settings; mid->blk.buf[0] = 0; mid->blk.buf[mid->blk.lim] = 0; @@ -2725,7 +2725,7 @@ read_line(Mapi mid) } else break; } - check_stream(mid, mid->from, "Connection terminated during read line", (mid->blk.eos = true, (char *) 0)); + check_stream(mid, mid->from, len, "Connection terminated during read line", (mid->blk.eos = true, (char *) 0)); mapi_log_data(mid, "RECV", mid->blk.buf + mid->blk.end, len); mid->blk.buf[mid->blk.end + len] = 0; if (mid->trace) { @@ -3429,8 +3429,8 @@ read_into_cache(MapiHdl hdl, int lookahe assert(mid->active == hdl); if (hdl->needmore) { hdl->needmore = false; - mnstr_flush(mid->to, MNSTR_FLUSH_DATA); - check_stream(mid, mid->to, "write error on stream", mid->error); + int f = mnstr_flush(mid->to, MNSTR_FLUSH_DATA); + check_stream(mid, mid->to, f, "write error on stream", mid->error); } if ((result = hdl->active) == NULL) result = hdl->result; /* may also be NULL */ @@ -3565,21 +3565,21 @@ mapi_execute_internal(MapiHdl hdl) if (is_sql) { /* indicate to server this is a SQL command */ - mnstr_write(mid->to, "s", 1, 1); - check_stream(mid, mid->to, "write error on stream", mid->error); + ssize_t w = mnstr_write(mid->to, "s", 1, 1); + check_stream(mid, mid->to, w, "write error on stream", mid->error); } - mnstr_write(mid->to, cmd, 1, size); - check_stream(mid, mid->to, "write error on stream", mid->error); + ssize_t w = mnstr_write(mid->to, cmd, 1, size); + check_stream(mid, mid->to, w, "write error on stream", mid->error); /* all SQL statements should end with a semicolon */ /* for the other languages it is assumed that the statements are correct */ if (is_sql) { - mnstr_write(mid->to, "\n;", 2, 1); - check_stream(mid, mid->to, "write error on stream", mid->error); + w = mnstr_write(mid->to, "\n;", 2, 1); + check_stream(mid, mid->to, w, "write error on stream", mid->error); } - mnstr_write(mid->to, "\n", 1, 1); - check_stream(mid, mid->to, "write error on stream", mid->error); - mnstr_flush(mid->to, MNSTR_FLUSH_DATA); - check_stream(mid, mid->to, "write error on stream", mid->error); + w = mnstr_write(mid->to, "\n", 1, 1); + check_stream(mid, mid->to, w, "write error on stream", mid->error); + w = mnstr_flush(mid->to, MNSTR_FLUSH_DATA); + check_stream(mid, mid->to, w, "write error on stream", mid->error); mid->active = hdl; return MOK; @@ -3703,12 +3703,12 @@ mapi_query_part(MapiHdl hdl, const char printf("mapi_query_part:%zu:%.*s\n", size, (int) size, query); } hdl->needmore = false; - mnstr_write(mid->to, query, 1, size); + size = mnstr_write(mid->to, query, 1, size); if (mid->tracelog) { mnstr_write(mid->tracelog, query, 1, size); mnstr_flush(mid->tracelog, MNSTR_FLUSH_DATA); } - check_stream(mid, mid->to, "write error on stream", mid->error); + check_stream(mid, mid->to, size, "write error on stream", mid->error); return mid->error; } @@ -3723,8 +3723,8 @@ mapi_query_done(MapiHdl hdl) assert(mid->active == NULL || mid->active == hdl); mid->active = hdl; hdl->needmore = false; - mnstr_flush(mid->to, MNSTR_FLUSH_DATA); - check_stream(mid, mid->to, "write error on stream", mid->error); + int f = mnstr_flush(mid->to, MNSTR_FLUSH_DATA); + check_stream(mid, mid->to, f, "write error on stream", mid->error); ret = mid->error; if (ret == MOK) ret = read_into_cache(hdl, 1); @@ -3911,11 +3911,12 @@ mapi_fetch_line(MapiHdl hdl) mapi_log_record(hdl->mid, "W", "X" "export %d %" PRId64 "\n", result->tableid, result->cache.first + result->cache.tuplecount); - if (mnstr_printf(hdl->mid->to, "X" "export %d %" PRId64 "\n", + int e; + if ((e = mnstr_printf(hdl->mid->to, "X" "export %d %" PRId64 "\n", result->tableid, - result->cache.first + result->cache.tuplecount) < 0 || - mnstr_flush(hdl->mid->to, MNSTR_FLUSH_DATA)) - check_stream(hdl->mid, hdl->mid->to, "sending export command", NULL); + result->cache.first + result->cache.tuplecount)) < 0 || + (e = mnstr_flush(hdl->mid->to, MNSTR_FLUSH_DATA)) < 0) + check_stream(hdl->mid, hdl->mid->to, e, "sending export command", NULL); reply = mapi_fetch_line_internal(hdl); } return reply; @@ -4433,10 +4434,11 @@ mapi_fetch_all_rows(MapiHdl hdl) hdl->active = result; mapi_log_record(mid, "SEND", "X" "export %d %" PRId64 "\n", result->tableid, result->cache.first + result->cache.tuplecount); - if (mnstr_printf(mid->to, "X" "export %d %" PRId64 "\n", - result->tableid, result->cache.first + result->cache.tuplecount) < 0 || - mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) - check_stream(mid, mid->to, "sending export command", 0); + int e; + if ((e = mnstr_printf(mid->to, "X" "export %d %" PRId64 "\n", + result->tableid, result->cache.first + result->cache.tuplecount)) < 0 || + (e = mnstr_flush(mid->to, MNSTR_FLUSH_DATA)) < 0) + check_stream(mid, mid->to, e, "sending export command", 0); } if (mid->active) read_into_cache(mid->active, 0); diff --git a/clients/mapilib/mapi_intern.h b/clients/mapilib/mapi_intern.h --- a/clients/mapilib/mapi_intern.h _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org