Changeset: 6c1792321ecb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6c1792321ecb
Modified Files:
        clients/Tests/exports.stable.out
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_statement.c
        sql/server/sql_parser.y
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
        tools/mserver/mserver5.c
Branch: nested
Log Message:

merged with default


diffs (truncated from 2220 to 300 lines):

diff --git a/clients/ChangeLog.Mar2025 b/clients/ChangeLog.Mar2025
--- a/clients/ChangeLog.Mar2025
+++ b/clients/ChangeLog.Mar2025
@@ -1,6 +1,21 @@
 # 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.  This is
+  actually a change in the "mapi" library, so any program using the
+  library gets the new behavior.
+- 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/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -569,6 +569,7 @@ const ptr ptr_nil;
 void *sa_alloc(allocator *sa, size_t sz);
 allocator *sa_create(allocator *pa);
 void sa_destroy(allocator *sa);
+exception_buffer *sa_get_eb(allocator *sa) __attribute__((__pure__));
 void *sa_realloc(allocator *sa, void *ptr, size_t sz, size_t osz);
 allocator *sa_reset(allocator *sa);
 size_t sa_size(allocator *sa);
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
@@ -2017,10 +2017,10 @@ Tpos(BATiter *bi, BUN p)
 
 __attribute__((__pure__))
 static inline bool
-Tmskval(BATiter *bi, BUN p)
+Tmskval(const BATiter *bi, BUN p)
 {
        assert(ATOMstorage(bi->type) == TYPE_msk);
-       return ((uint32_t *) bi->base)[p / 32] & (1U << (p % 32));
+       return ((const uint32_t *) bi->base)[p / 32] & (1U << (p % 32));
 }
 
 static inline void *
@@ -2525,29 +2525,20 @@ gdk_export exception_buffer *eb_init(exc
 #endif
 gdk_export _Noreturn void eb_error(exception_buffer *eb, const char *msg, int 
val);
 
-typedef struct allocator {
-       struct allocator *pa;
-       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;
-} allocator;
+typedef struct allocator allocator;
 
-gdk_export allocator *sa_create( allocator *pa );
-gdk_export allocator *sa_reset( allocator *sa );
-gdk_export void *sa_alloc( allocator *sa,  size_t sz );
-gdk_export void *sa_zalloc( allocator *sa,  size_t sz );
-gdk_export void *sa_realloc( allocator *sa,  void *ptr, size_t sz, size_t osz 
);
-gdk_export void sa_destroy( allocator *sa );
-gdk_export char *sa_strndup( allocator *sa, const char *s, size_t l);
-gdk_export char *sa_strdup( allocator *sa, const char *s);
-gdk_export char *sa_strconcat( allocator *sa, const char *s1, const char *s2);
-gdk_export size_t sa_size( allocator *sa );
+gdk_export allocator *sa_create(allocator *pa );
+gdk_export allocator *sa_reset(allocator *sa );
+gdk_export void *sa_alloc(allocator *sa,  size_t sz );
+gdk_export void *sa_zalloc(allocator *sa,  size_t sz );
+gdk_export void *sa_realloc(allocator *sa,  void *ptr, size_t sz, size_t osz );
+gdk_export void sa_destroy(allocator *sa );
+gdk_export char *sa_strndup(allocator *sa, const char *s, size_t l);
+gdk_export char *sa_strdup(allocator *sa, const char *s);
+gdk_export char *sa_strconcat(allocator *sa, const char *s1, const char *s2);
+gdk_export size_t sa_size(allocator *sa );
+gdk_export exception_buffer *sa_get_eb(allocator *sa)
+       __attribute__((__pure__));
 
 #if !defined(NDEBUG) && !defined(__COVERITY__) && defined(__GNUC__)
 #define sa_alloc(sa, sz)                                       \
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;
@@ -708,16 +708,12 @@ MT_getrss(void)
        return 0;
 }
 
-/* Windows mmap keeps a global list of base addresses for complex
- * (remapped) memory maps the reason is that each remapped segment
- * needs to be unmapped separately in the end. */
-
 void *
 MT_mmap(const char *path, int mode, size_t len)
 {
        DWORD mode0 = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
        DWORD mode1 = FILE_SHARE_READ | FILE_SHARE_WRITE;
-       DWORD mode2 = mode & MMAP_ADVISE;
+       DWORD mode2;
        DWORD mode3 = PAGE_READONLY;
        int mode4 = FILE_MAP_READ;
        SECURITY_ATTRIBUTES sa;
@@ -731,16 +727,6 @@ MT_mmap(const char *path, int mode, size
        if (mode & MMAP_WRITE) {
                mode0 |= FILE_APPEND_DATA | FILE_WRITE_ATTRIBUTES | 
FILE_WRITE_DATA;
        }
-       if (mode2 == MMAP_RANDOM || mode2 == MMAP_DONTNEED) {
-               mode2 = FILE_FLAG_RANDOM_ACCESS;
-       } else if (mode2 == MMAP_SEQUENTIAL || mode2 == MMAP_WILLNEED) {
-               mode2 = FILE_FLAG_SEQUENTIAL_SCAN;
-       } else {
-               mode2 = FILE_FLAG_NO_BUFFERING;
-       }
-       if (mode & MMAP_SYNC) {
-               mode2 |= FILE_FLAG_WRITE_THROUGH;
-       }
        if (mode & MMAP_COPY) {
                mode3 = PAGE_WRITECOPY;
                mode4 = FILE_MAP_COPY;
@@ -748,7 +734,7 @@ MT_mmap(const char *path, int mode, size
                mode3 = PAGE_READWRITE;
                mode4 = FILE_MAP_WRITE;
        }
-       mode2 |= FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
+       mode2 = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
        sa.nLength = sizeof(SECURITY_ATTRIBUTES);
        sa.bInheritHandle = TRUE;
        sa.lpSecurityDescriptor = 0;
diff --git a/gdk/gdk_posix.h b/gdk/gdk_posix.h
--- a/gdk/gdk_posix.h
+++ b/gdk/gdk_posix.h
@@ -43,74 +43,9 @@
 # include <sys/mman.h>
 #endif
 
-#ifdef __linux__
-/* on Linux, posix_madvise does not seem to work, fall back to classic
- * madvise */
-#undef HAVE_POSIX_MADVISE
-#undef HAVE_POSIX_FADVISE
-#undef POSIX_MADV_NORMAL
-#undef POSIX_MADV_RANDOM
-#undef POSIX_MADV_SEQUENTIAL
-#undef POSIX_MADV_WILLNEED
-#undef POSIX_MADV_DONTNEED
-#endif
-
-#ifndef HAVE_POSIX_MADVISE
-# ifdef HAVE_MADVISE
-#  define posix_madvise madvise
-#  define HAVE_POSIX_MADVISE 1
-#  ifndef MADV_RANDOM
-#   define MADV_RANDOM 0
-#  endif
-#  ifndef POSIX_MADV_NORMAL
-#   define POSIX_MADV_NORMAL     MADV_NORMAL
-#   define POSIX_MADV_RANDOM     MADV_RANDOM
-#   define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
-#   define POSIX_MADV_WILLNEED   MADV_WILLNEED
-#   define POSIX_MADV_DONTNEED   MADV_DONTNEED
-#  endif
-# else
-#  define posix_madvise(x,y,z) 0
-#  ifndef POSIX_MADV_NORMAL
-#   define POSIX_MADV_NORMAL     0
-#   define POSIX_MADV_RANDOM     0
-#   define POSIX_MADV_SEQUENTIAL 0
-#   define POSIX_MADV_WILLNEED   0
-#   define POSIX_MADV_DONTNEED   0
-#  endif
-# endif
-#endif
-
-/* in case they are still not defined, define these values as
- * something that doesn't do anything */
-#ifndef POSIX_MADV_NORMAL
-#define POSIX_MADV_NORMAL 0
-#endif
-#ifndef POSIX_MADV_RANDOM
-#define POSIX_MADV_RANDOM 0
-#endif
-#ifndef POSIX_MADV_SEQUENTIAL
-#define POSIX_MADV_SEQUENTIAL 0
-#endif
-#ifndef POSIX_MADV_WILLNEED
-#define POSIX_MADV_WILLNEED 0
-#endif
-#ifndef POSIX_MADV_DONTNEED
-#define POSIX_MADV_DONTNEED 0
-#endif
-
-/* the new mmap modes, mimic default MADV_* madvise POSIX constants */
-#define MMAP_NORMAL    POSIX_MADV_NORMAL       /* no further special treatment 
*/
-#define MMAP_RANDOM    POSIX_MADV_RANDOM       /* expect random page 
references */
-#define MMAP_SEQUENTIAL        POSIX_MADV_SEQUENTIAL   /* expect sequential 
page references */
-#define MMAP_WILLNEED  POSIX_MADV_WILLNEED     /* will need these pages */
-#define MMAP_DONTNEED  POSIX_MADV_DONTNEED     /* don't need these pages */
-
 #define MMAP_READ              1024    /* region is readable (default if 
omitted) */
 #define MMAP_WRITE             2048    /* region may be written into */
 #define MMAP_COPY              4096    /* writable, but changes never reach 
file */
-#define MMAP_ASYNC             8192    /* asynchronous writes (default if 
omitted) */
-#define MMAP_SYNC              16384   /* writing is done synchronously */
 
 /* in order to be sure of madvise and msync modes, pass them to mmap()
  * call as well */
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -39,6 +39,19 @@ enum range_comp_t {
        range_inside,           /* search range inside bat range */
 };
 
+struct allocator {
+       struct allocator *pa;
+       size_t size;
+       size_t nr;
+       char **blks;
+       size_t used;    /* memory used in last block */
+       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  */
+};
+
 bool ATOMisdescendant(int id, int parentid)
        __attribute__((__visibility__("hidden")));
 int ATOMunknown_find(const char *nme)
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -586,12 +586,10 @@ GDKload(int farmid, const char *nme, con
                        nme = path;
                }
                if (nme != NULL && GDKextend(nme, size) == GDK_SUCCEED) {
-                       int mod = MMAP_READ | MMAP_WRITE | MMAP_SEQUENTIAL;
+                       int mod = MMAP_READ | MMAP_WRITE;
 
                        if (mode == STORE_PRIV)
                                mod |= MMAP_COPY;
-                       else
-                               mod |= MMAP_SYNC;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to