Changeset: 1f8d65c3dd56 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1f8d65c3dd56
Branch: strimps_update
Log Message:

Merge with default


diffs (202 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/clients/odbc/ChangeLog b/clients/odbc/ChangeLog
--- a/clients/odbc/ChangeLog
+++ b/clients/odbc/ChangeLog
@@ -1,6 +1,11 @@
 # ChangeLog file for odbc
 # This file is updated with Maddlog
 
+* Thu Jun  2 2022 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
+- Fixed implementation of SQLGetInfo(hdbc, SQL_MAX_DRIVER_CONNECTIONS,
+  ...). It used to always return a value of 64. Now it returns the
+  MonetDB server value.
+
 * Thu May 19 2022 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
 - Corrected SQLSpecialColumns(..., SQL_BEST_ROWID, ...). Previously it only
   returned rows when the table had a primary key. Now it also returns
diff --git a/clients/odbc/driver/ODBCDbc.h b/clients/odbc/driver/ODBCDbc.h
--- a/clients/odbc/driver/ODBCDbc.h
+++ b/clients/odbc/driver/ODBCDbc.h
@@ -65,6 +65,7 @@ typedef struct tODBCDRIVERDBC {
        int cachelimit;         /* cache limit we requested */
        SQLULEN qtimeout;       /* current query timeout */
        short major, minor, patch; /* version of server */
+       SQLUSMALLINT maxclients;   /* mserver5 max_clients value */
        int Mdebug;
 
        /* Dbc children: list of ODBC Statement handles created within
@@ -75,7 +76,6 @@ typedef struct tODBCDRIVERDBC {
 } ODBCDbc;
 
 
-
 /*
  * Creates a new allocated ODBCDbc object and initializes it.
  *
diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -72,7 +72,7 @@ get_serverinfo(ODBCDbc *dbc)
        MapiHdl hdl;
        char *n, *v;
 
-       if ((hdl = mapi_query(dbc->mid, "select name, value from sys.env() 
where name in ('monet_version', 'gdk_dbname')")) == NULL)
+       if ((hdl = mapi_query(dbc->mid, "select name, value from sys.env() 
where name in ('monet_version', 'gdk_dbname', 'max_clients')")) == NULL)
                return;
        while (mapi_fetch_row(hdl)) {
                n = mapi_fetch_field(hdl, 0);
@@ -80,6 +80,9 @@ get_serverinfo(ODBCDbc *dbc)
                if (strcmp(n, "monet_version") == 0) {
                        sscanf(v, "%hd.%hd.%hd",
                               &dbc->major, &dbc->minor, &dbc->patch);
+               } else
+               if (strcmp(n, "max_clients") == 0) {
+                       sscanf(v, "%hu", &dbc->maxclients);
                } else {
                        assert(strcmp(n, "gdk_dbname") == 0);
                        assert(dbc->dbname == NULL ||
diff --git a/clients/odbc/driver/SQLGetInfo.c b/clients/odbc/driver/SQLGetInfo.c
--- a/clients/odbc/driver/SQLGetInfo.c
+++ b/clients/odbc/driver/SQLGetInfo.c
@@ -46,8 +46,9 @@ MNDBGetInfo(ODBCDbc *dbc,
        /* For some info types an active connection is needed */
        if (!dbc->Connected &&
            (InfoType == SQL_DATA_SOURCE_NAME ||
-            InfoType == SQL_SERVER_NAME ||
             InfoType == SQL_DATABASE_NAME ||
+            InfoType == SQL_DBMS_VER ||
+            InfoType == SQL_MAX_DRIVER_CONNECTIONS ||
             InfoType == SQL_USER_NAME ||
             InfoType == SQL_KEYWORDS)) {
                /* Connection does not exist */
@@ -694,9 +695,7 @@ MNDBGetInfo(ODBCDbc *dbc,
                len = sizeof(SQLUSMALLINT);
                break;
        case SQL_MAX_DRIVER_CONNECTIONS:
-               nValue = 64;    /* default value of mserver5 */
-               /* TODO query the server for the actual value via SQL:
-                  SELECT value FROM sys.env() WHERE name = 'max_clients'; */
+               nValue = dbc->maxclients;
                len = sizeof(SQLUSMALLINT);
                break;
        case SQL_MAX_IDENTIFIER_LEN:
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

Reply via email to