Changeset: 400e66d1b232 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/400e66d1b232 Modified Files: clients/mapiclient/mclient.c gdk/gdk_bbp.c Branch: default Log Message:
Merge with Jan2022 branch. diffs (121 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -768,3 +768,4 @@ 2e54857a91306cc6304825c5596f65d00595db6b 1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_13 1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_SP2_release 59de1ee118d4eccc072c0cf3938f90635a7db311 Jan2022_15 +59de1ee118d4eccc072c0cf3938f90635a7db311 Jan2022_SP3_release diff --git a/clients/ChangeLog.Jan2022 b/clients/ChangeLog.Jan2022 --- a/clients/ChangeLog.Jan2022 +++ b/clients/ChangeLog.Jan2022 @@ -1,3 +1,9 @@ # ChangeLog file for clients # This file is updated with Maddlog +* Tue May 31 2022 Sjoerd Mullender <sjo...@acm.org> +- Fixed a bug where when the semicolon at the end of a COPY INTO query + that reads from STDIN is at exactly a 10240 byte boundary in a file, + the data isn't read as input for the COPY INTO but instead as a new + SQL query. + diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -2042,6 +2042,7 @@ static bool doFileBulk(Mapi mid, stream *fp) { char *buf = NULL; + size_t semicolon1 = 0, semicolon2 = 0; ssize_t length; MapiHdl hdl = mapi_get_active(mid); MapiMsg rc = MOK; @@ -2064,18 +2065,28 @@ doFileBulk(Mapi mid, stream *fp) break; length = 0; buf[0] = 0; - } else if ((length = mnstr_read(fp, buf, 1, bufsize)) <= 0) { - /* end of file or error */ - if (hdl == NULL) + } else { + if ((length = mnstr_read(fp, buf, 1, bufsize)) < 0) { + /* error */ + errseen = true; break; /* nothing more to do */ - buf[0] = 0; - length = 0; /* handle error like EOF */ - } else { - buf[length] = 0; - if (strlen(buf) < (size_t) length) { - mnstr_printf(stderr_stream, "NULL byte in input\n"); - errseen = true; - break; + } else { + buf[length] = 0; + if (length == 0) { + /* end of file */ + if (semicolon2 == 0 && hdl == NULL) + break; /* nothing more to do */ + } else { + if (strlen(buf) < (size_t) length) { + mnstr_printf(stderr_stream, "NULL byte in input\n"); + errseen = true; + break; + } + while (length > 1 && buf[length - 1] == ';') { + semicolon1++; + buf[--length] = 0; + } + } } } timerResume(); @@ -2085,7 +2096,15 @@ doFileBulk(Mapi mid, stream *fp) } assert(hdl != NULL); - mapi_query_part(hdl, buf, (size_t) length); + while (semicolon2 > 0) { + mapi_query_part(hdl, ";", 1); + CHECK_RESULT(mid, hdl, buf, fp); + semicolon2--; + } + semicolon2 = semicolon1; + semicolon1 = 0; + if (length > 0) + mapi_query_part(hdl, buf, (size_t) length); CHECK_RESULT(mid, hdl, buf, fp); /* if not at EOF, make sure there is a newline in the diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -3899,9 +3899,10 @@ BBPsync(int cnt, bat *restrict subcommit BUN size = sizes ? sizes[idx] : BUN_NONE; BATiter bi; - /* add a fix so that BBPmanager doesn't interfere */ - BBPfix(i); if (BBP_status(i) & BBPPERSISTENT) { + /* add a fix so that BBPmanager doesn't + * interfere */ + BBPfix(i); BAT *b = dirty_bat(&i, subcommit != NULL); if (i <= 0) { decref(-i, false, false, true, locked_by == 0 || locked_by != MT_getpid(), __func__); @@ -3941,9 +3942,12 @@ BBPsync(int cnt, bat *restrict subcommit n = BBPdir_step(i, size, n, buf, sizeof(buf), &obbpf, nbbpf, subcommit != NULL, &bi); } bat_iterator_end(&bi); - /* can't use BBPunfix because of the "lock" - * argument: locked_by may be set here */ - decref(i, false, false, true, lock, __func__); + if (BBP_status(i) & BBPPERSISTENT) { + /* can't use BBPunfix because of the + * "lock" argument: locked_by may be + * set here */ + decref(i, false, false, true, lock, __func__); + } if (n == -2) break; /* we once again have a saved heap */ _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org