Changeset: 936c4401091b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/936c4401091b
Modified Files:
        gdk/gdk.h
        sql/server/sql_parser.y
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
        tools/mserver/mserver5.c
Branch: default
Log Message:

Merge with Mar2025 branch.


diffs (139 lines):

diff --git a/clients/ChangeLog.Mar2025 b/clients/ChangeLog.Mar2025
--- a/clients/ChangeLog.Mar2025
+++ b/clients/ChangeLog.Mar2025
@@ -1,6 +1,19 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Tue Jun  3 2025 Sjoerd Mullender <[email protected]>
+- When connecting to a database, if there are multiple monetdbd servers
+  running, mclient will try them all, and also both UNIX domain sockets
+  and then TCP, in order to find a server that accepts the connection.
+  However, when a server that handles the requested database does
+  exist but refuses the connection for some other reason, mclient would
+  continue searching.  This has now been changed.  If monetdbd reports
+  an error other than database unknown, mclient will now stop looking
+  and report the error.
+- There is a new option --quiet (or just -q) in mclient.  If used, the
+  welcome message that is normally printed in an interactive invocation
+  is suppressed.
+
 * Fri May  9 2025 Sjoerd Mullender <[email protected]>
 - There is now a \dm command in the interactive mclient to show
   information about merge tables.
diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c
--- a/clients/mapilib/connect.c
+++ b/clients/mapilib/connect.c
@@ -106,6 +106,10 @@ scan_sockets(Mapi mid)
 
        if (scan_unix_sockets(mid) == MOK)
                return MOK;
+       /* if database was not unknown (no message "no such database"),
+        * skip further attempts to connect */
+       if (mid->errorstr && strstr(mid->errorstr, "no such database") == NULL)
+               return MERROR;
 
        errmsg = msetting_set_string(mid->settings, MP_HOST, "localhost");
        if (!errmsg)
diff --git a/clients/mapilib/connect_unix.c b/clients/mapilib/connect_unix.c
--- a/clients/mapilib/connect_unix.c
+++ b/clients/mapilib/connect_unix.c
@@ -106,6 +106,16 @@ scan_unix_sockets(Mapi mid)
                                msettings_destroy(original);
                                free(namebuf);
                                return MOK;
+                       } else if (msg == MSERVER && mid->errorstr &&
+                                  strstr(mid->errorstr, "no such database") == 
NULL) {
+                               /* connecting failed, but database not
+                                * unknown (no message "no such
+                                * database"), so skip further
+                                * attempts */
+                               msettings_destroy(mid->settings);
+                               mid->settings = NULL;
+                               round = 2; /* to break out of outer loop */
+                               break;
                        } else {
                                msettings_destroy(mid->settings);
                                mid->settings = NULL;
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2530,12 +2530,12 @@ typedef struct allocator {
        size_t size;
        size_t nr;
        char **blks;
-       char *first_block; /* the special block in blks that also holds our 
bookkeeping */
        size_t used;    /* memory used in last block */
-       size_t reserved;  /* space in first_block is reserved up to here  */
        size_t usedmem; /* used memory */
        void *freelist; /* list of freed blocks */
        exception_buffer eb;
+       char *first_block; /* the special block in blks that also holds our 
bookkeeping */
+       size_t reserved;  /* space in first_block is reserved up to here  */
 } allocator;
 
 gdk_export allocator *sa_create( allocator *pa );
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -326,7 +326,7 @@ MT_mmap(const char *path, int mode, size
        int fd;
        void *ret;
 
-       fd = open(path, O_CREAT | ((mode & MMAP_WRITE) ? O_RDWR : O_RDONLY) | 
O_CLOEXEC, MONETDB_MODE);
+       fd = open(path, ((mode & MMAP_WRITE) ? O_RDWR : O_RDONLY) | O_CLOEXEC, 
MONETDB_MODE);
        if (fd < 0) {
                GDKsyserror("open %s failed\n", path);
                return NULL;
diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c
--- a/tools/mserver/mserver5.c
+++ b/tools/mserver/mserver5.c
@@ -436,20 +436,41 @@ main(int argc, char **av)
                                                   || optarg[optarglen - 1] == 
'\\'))
                                        optarg[--optarglen] = '\0';
                                dbpath = absolute_path(optarg);
-                               if (dbpath == NULL)
+                               if (dbpath == NULL) {
                                        fprintf(stderr,
                                                        "#error: can not 
allocate memory for dbpath\n");
-                               else
-                                       setlen = mo_add_option(&set, setlen, 
opt_cmdline,
-                                                                               
   "gdk_dbpath", dbpath);
+                                       exit(1);
+                               }
+                               if (strlen(dbpath) >= FILENAME_MAX - 45) {
+                                       fprintf(stderr, "#error: dbpath name 
too long\n");
+                                       exit(1);
+                               }
+                               setlen = mo_add_option(&set, setlen, 
opt_cmdline,
+                                                                          
"gdk_dbpath", dbpath);
                                break;
                        }
                        if (strcmp(long_options[option_index].name, "dbextra") 
== 0) {
-                               if (dbextra)
+                               if (dbextra) {
                                        fprintf(stderr,
                                                        "#warning: ignoring 
multiple --dbextra arguments\n");
-                               else
-                                       dbextra = optarg;
+                                       break;
+                               }
+                               size_t optarglen = strlen(optarg);
+                               /* remove trailing directory separator */
+                               while (optarglen > 0
+                                          && (optarg[optarglen - 1] == '/'
+                                                  || optarg[optarglen - 1] == 
'\\'))
+                                       optarg[--optarglen] = '\0';
+                               dbextra = absolute_path(optarg);
+                               if (dbextra == NULL) {
+                                       fprintf(stderr,
+                                                       "#error: can not 
allocate memory for dbextra\n");
+                                       exit(1);
+                               }
+                               if (strlen(dbextra) >= FILENAME_MAX - 45) {
+                                       fprintf(stderr, "#error: dbextra name 
too long\n");
+                                       exit(1);
+                               }
                                break;
                        }
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to