Changeset: 23bf643b6a72 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/23bf643b6a72
Modified Files:
        gdk/gdk.h
        gdk/gdk_bbp.c
        sql/backends/monet5/rel_bin.c
        sql/storage/store.c
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (truncated from 514 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -744,7 +744,6 @@ typedef struct {
 /* assert that atom width is power of 2, i.e., width == 1<<shift */
 #define assert_shift_width(shift,width) assert(((shift) == 0 && (width) == 0) 
|| ((unsigned)1<<(shift)) == (unsigned)(width))
 
-#define GDKLIBRARY_TAILN       061043U /* first in Jul2021: str offset heaps 
names don't take width into account */
 #define GDKLIBRARY_HASHASH     061044U /* first in Jul2021: hashash bit in 
string heaps */
 #define GDKLIBRARY_HSIZE       061045U /* first in Jan2022: heap "size" values 
*/
 #define GDKLIBRARY_JSON        061046U /* first in Sep2022: json storage 
changes*/
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -906,26 +906,10 @@ BBPcheckbats(unsigned bbpversion)
                        /* first check string offset heap with width,
                         * then without */
                        if (MT_stat(path, &statb) < 0) {
-#ifdef GDKLIBRARY_TAILN
-                               if (b->ttype == TYPE_str &&
-                                   b->twidth < SIZEOF_VAR_T) {
-                                       size_t taillen = strlen(path) - 1;
-                                       char tailsave = path[taillen];
-                                       path[taillen] = 0;
-                                       if (MT_stat(path, &statb) < 0) {
-                                               GDKsyserror("cannot stat file 
%s%c or %s (expected size %zu)\n",
-                                                           path, tailsave, 
path, b->theap->free);
-                                               GDKfree(path);
-                                               return GDK_FAIL;
-                                       }
-                               } else
-#endif
-                               {
-                                       GDKsyserror("cannot stat file %s 
(expected size %zu)\n",
-                                                   path, b->theap->free);
-                                       GDKfree(path);
-                                       return GDK_FAIL;
-                               }
+                               GDKsyserror("cannot stat file %s (expected size 
%zu)\n",
+                                           path, b->theap->free);
+                               GDKfree(path);
+                               return GDK_FAIL;
                        }
                        if ((size_t) statb.st_size < b->theap->free) {
                                GDKerror("file %s too small (expected %zu, 
actual %zu)\n", path, b->theap->free, (size_t) statb.st_size);
@@ -1007,8 +991,7 @@ BBPheader(FILE *fp, int *lineno, bat *bb
            bbpversion != GDKLIBRARY_STATUS &&
            bbpversion != GDKLIBRARY_JSON &&
            bbpversion != GDKLIBRARY_HSIZE &&
-           bbpversion != GDKLIBRARY_HASHASH &&
-           bbpversion != GDKLIBRARY_TAILN) {
+           bbpversion != GDKLIBRARY_HASHASH) {
                TRC_CRITICAL(GDK, "incompatible BBP version: expected 0%o, got 
0%o. "
                             "This database was probably created by a %s 
version of MonetDB.",
                             GDKLIBRARY, bbpversion,
@@ -1424,56 +1407,6 @@ fixhashash(bat *hashbats, bat nhashbats)
 }
 #endif
 
-#ifdef GDKLIBRARY_TAILN
-static gdk_return
-movestrbats(void)
-{
-       for (bat bid = 1, nbat = (bat) ATOMIC_GET(&BBPsize); bid < nbat; bid++) 
{
-               BAT *b = BBP_desc(bid);
-               if (b->batCacheid == 0) {
-                       /* not a valid BAT */
-                       continue;
-               }
-               if (b->ttype != TYPE_str || b->twidth == SIZEOF_VAR_T || 
b->batCount == 0)
-                       continue;
-               char *oldpath = GDKfilepath(0, BATDIR, 
BBP_physical(b->batCacheid), "tail");
-               char *newpath = GDKfilepath(0, BATDIR, b->theap->filename, 
NULL);
-               int ret = -1;
-               if (oldpath != NULL && newpath != NULL) {
-                       struct stat oldst, newst;
-                       bool oldexist = MT_stat(oldpath, &oldst) == 0;
-                       bool newexist = MT_stat(newpath, &newst) == 0;
-                       if (newexist) {
-                               if (oldexist) {
-                                       if (oldst.st_mtime > newst.st_mtime) {
-                                               GDKerror("both %s and %s exist 
with %s unexpectedly newer: manual intervention required\n", oldpath, newpath, 
oldpath);
-                                               ret = -1;
-                                       } else {
-                                               GDKwarning("both %s and %s 
exist, removing %s\n", oldpath, newpath, oldpath);
-                                               ret = MT_remove(oldpath);
-                                       }
-                               } else {
-                                       /* already good */
-                                       ret = 0;
-                               }
-                       } else if (oldexist) {
-                               TRC_DEBUG(IO_, "rename %s to %s\n", oldpath, 
newpath);
-                               ret = MT_rename(oldpath, newpath);
-                       } else {
-                               /* neither file exists: may be ok, but
-                                * will be checked later */
-                               ret = 0;
-                       }
-               }
-               GDKfree(oldpath);
-               GDKfree(newpath);
-               if (ret == -1)
-                       return GDK_FAIL;
-       }
-       return GDK_SUCCEED;
-}
-#endif
-
 #ifdef GDKLIBRARY_JSON
 static gdk_return
 jsonupgradebat(BAT *b, json_storage_conversion fixJSONStorage)
@@ -2013,56 +1946,6 @@ BBPinit(bool allow_hge_upgrade)
                return GDK_FAIL;
        }
 
-#ifdef GDKLIBRARY_TAILN
-       char *needstrbatmove;
-       if (GDKinmemory(0)) {
-               needstrbatmove = NULL;
-       } else {
-               if ((needstrbatmove = GDKfilepath(0, BATDIR, "needstrbatmove", 
NULL)) == NULL) {
-#ifdef GDKLIBRARY_HASHASH
-                       GDKfree(hashbats);
-#endif
-                       ATOMIC_SET(&GDKdebug, dbg);
-                       return GDK_FAIL;
-               }
-               if (bbpversion <= GDKLIBRARY_TAILN) {
-                       /* create signal file that we need to rename string
-                        * offset heaps */
-                       int fd = MT_open(needstrbatmove, O_WRONLY | O_CREAT);
-                       if (fd < 0) {
-                               TRC_CRITICAL(GDK, "cannot create signal file 
needstrbatmove.\n");
-                               GDKfree(needstrbatmove);
-#ifdef GDKLIBRARY_HASHASH
-                               GDKfree(hashbats);
-#endif
-                               ATOMIC_SET(&GDKdebug, dbg);
-                               return GDK_FAIL;
-                       }
-                       close(fd);
-               } else {
-                       /* check signal file whether we need to rename string
-                        * offset heaps */
-                       int fd = MT_open(needstrbatmove, O_RDONLY);
-                       if (fd >= 0) {
-                               /* yes, we do */
-                               close(fd);
-                       } else if (errno == ENOENT) {
-                               /* no, we don't: set var to NULL */
-                               GDKfree(needstrbatmove);
-                               needstrbatmove = NULL;
-                       } else {
-                               GDKsyserror("unexpected error opening %s\n", 
needstrbatmove);
-                               GDKfree(needstrbatmove);
-#ifdef GDKLIBRARY_HASHASH
-                               GDKfree(hashbats);
-#endif
-                               ATOMIC_SET(&GDKdebug, dbg);
-                               return GDK_FAIL;
-                       }
-               }
-       }
-#endif
-
 #ifdef GDKLIBRARY_HASHASH
        if (nhashbats > 0)
                res = fixhashash(hashbats, nhashbats);
@@ -2108,25 +1991,6 @@ BBPinit(bool allow_hge_upgrade)
                return GDK_FAIL;
        }
 
-#ifdef GDKLIBRARY_TAILN
-       /* we rename the offset heaps after the above commit: in this
-        * version we accept both the old and new names, but we want to
-        * convert so that future versions only have the new name */
-       if (needstrbatmove) {
-               /* note, if renaming fails, nothing is lost: a next
-                * invocation will just try again; an older version of
-                * mserver will not work because of the TMcommit
-                * above */
-               if (movestrbats() != GDK_SUCCEED) {
-                       GDKfree(needstrbatmove);
-                       ATOMIC_SET(&GDKdebug, dbg);
-                       return GDK_FAIL;
-               }
-               MT_remove(needstrbatmove);
-               GDKfree(needstrbatmove);
-               needstrbatmove = NULL;
-       }
-#endif
        ATOMIC_SET(&GDKdebug, dbg);
 
        /* cleanup any leftovers (must be done after BBPrecover) */
diff --git a/misc/selinux/monetdb.fc.in b/misc/selinux/monetdb.fc.in
--- a/misc/selinux/monetdb.fc.in
+++ b/misc/selinux/monetdb.fc.in
@@ -8,17 +8,25 @@
 # Copyright August 2008 - 2023 MonetDB B.V.;
 # Copyright 1997 - July 2008 CWI.
 
-@CMAKE_INSTALL_FULL_BINDIR@/monetdbd*                          --      
gen_context(system_u:object_r:monetdbd_exec_t,s0)
-@CMAKE_INSTALL_FULL_BINDIR@/mserver5*                          --      
gen_context(system_u:object_r:mserver5_exec_t,s0)
-@CMAKE_INSTALL_FULL_LIBDIR@/systemd/system/monetdbd.*                  
gen_context(system_u:object_r:monetdbd_unit_file_t,s0)
+# blank: any type file
+# -b: block device
+# -c: character device
+# -d: directory
+# -p: named pipe
+# -l: symbolic link
+# -s: socket file
+# --: regular file
+@CMAKE_INSTALL_FULL_BINDIR@/monetdbd(-.*)?                                     
        gen_context(system_u:object_r:monetdbd_exec_t,s0)
+@CMAKE_INSTALL_FULL_BINDIR@/mserver5(-.*)?                                     
        gen_context(system_u:object_r:mserver5_exec_t,s0)
+@CMAKE_INSTALL_PREFIX@/lib/systemd/system/monetdbd\.service                    
--      gen_context(system_u:object_r:monetdbd_unit_file_t,s0)
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/monetdb(/.*)?                           
        gen_context(system_u:object_r:monetdbd_log_t,s0)
-@CMAKE_INSTALL_FULL_RUNSTATEDIR@/monetdb(/.*)?                                 
gen_context(system_u:object_r:monetdbd_var_run_t,s0)
+@CMAKE_INSTALL_FULL_RUNSTATEDIR@/monetdb(/.*)?                                 
        gen_context(system_u:object_r:monetdbd_var_run_t,s0)
 # database "farm"
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/monetdb5/dbfarm(/.*)?                       
        gen_context(system_u:object_r:mserver5_db_t,s0)
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/monetdb5/dbfarm/\.merovingian_properties    
--      gen_context(system_u:object_r:monetdbd_etc_t,s0)
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/monetdb5/dbfarm/\.merovingian_lock          
--      gen_context(system_u:object_r:monetdbd_lock_t,s0)
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/monetdb5/dbfarm/.*/\.gdk_lock               
--      gen_context(system_u:object_r:mserver5_lock_t,s0)
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/lib/monetdb(/.*)?                           
        gen_context(system_u:object_r:mserver5_db_t,s0)
-@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/lib/monetdb/\.merovingian_properties        
--      gen_context(system_u:object_r:monetdbd_etc_t,s0)
+@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/lib/monetdb/\.merovingian_properties        
        --      gen_context(system_u:object_r:monetdbd_etc_t,s0)
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/lib/monetdb/\.merovingian_lock              
--      gen_context(system_u:object_r:monetdbd_lock_t,s0)
 @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/lib/monetdb/.*/\.gdk_lock                   
--      gen_context(system_u:object_r:mserver5_lock_t,s0)
diff --git a/misc/selinux/monetdb.te b/misc/selinux/monetdb.te
--- a/misc/selinux/monetdb.te
+++ b/misc/selinux/monetdb.te
@@ -8,7 +8,7 @@
 # Copyright August 2008 - 2023 MonetDB B.V.;
 # Copyright 1997 - July 2008 CWI.
 
-policy_module(monetdb, 1.3)
+policy_module(monetdb, 1.4)
 # The above line declares that this file is a SELinux policy file. Its
 # name is monetdb, so the file should be saved as monetdb.te
 
@@ -32,7 +32,7 @@ require {
        class tcp_socket create_stream_socket_perms;
        class udp_socket create_stream_socket_perms;
        class unix_dgram_socket create_socket_perms;
-       class unix_stream_socket { connectto create_stream_socket_perms getopt 
read shutdown write };
+       class unix_stream_socket { connectto create_stream_socket_perms getattr 
getopt read shutdown write setopt };
 }
 
 # First, we declare the monetdbd_t domain, used for the "monetdbd"
@@ -141,7 +141,7 @@ manage_sock_files_pattern(mserver5_t, tm
 allow mserver5_t tmp_t:file create;
 manage_sock_files_pattern(mserver5_t, mserver5_db_t, mserver5_db_t)
 allow mserver5_t monetdbd_t:fifo_file { read write getattr ioctl };
-allow mserver5_t monetdbd_t:unix_stream_socket { read write getopt shutdown };
+allow mserver5_t monetdbd_t:unix_stream_socket { read write getattr getopt 
setopt shutdown };
 allow mserver5_t var_t:dir { read };
 allow mserver5_t var_lib_t:dir { read };
 # we want to be able to read some cgroup files
diff --git a/sql/ChangeLog.Aug2024 b/sql/ChangeLog.Aug2024
--- a/sql/ChangeLog.Aug2024
+++ b/sql/ChangeLog.Aug2024
@@ -1,6 +1,10 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Thu Sep 26 2024 Martin van Dinther <[email protected]>
+- Improved the violation message of CHECK constraints when violated. It
+  now includes the schema name of the constraint and the check clause.
+
 * Fri Aug 23 2024 Joeri van Ruth <[email protected]>
 - Increase the buffer size used by hot snapshot from 64kiB to 1MiB,
   and make it configurable through setting 'hot_snapshot_buffer_size'.
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -5189,7 +5189,7 @@ sql_insert_check(backend *be, sql_key *k
        sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
        s = stmt_uselect(be, column(be, s), stmt_bool(be, 0), cmp_equal, NULL, 
0, 1);
        s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
-       char *msg = sa_message(sql->sa, SQLSTATE(40002) "INSERT INTO: CHECK 
constraint violated: %s", key->base.name);
+       char *msg = sa_message(sql->sa, SQLSTATE(40002) "INSERT INTO: violated 
constraint '%s.%s' CHECK(%s)", key->t->s->base.name, key->base.name, 
exp->comment);
        (void)stmt_exception(be, s, msg, 00001);
 }
 
@@ -6209,7 +6209,7 @@ sql_update_check(backend *be, stmt **upd
        sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR, true, true);
        s = stmt_uselect(be, column(be, s), stmt_bool(be, 0), cmp_equal, NULL, 
0, 1);
        s = stmt_aggr(be, s, NULL, NULL, cnt, 1, 0, 1);
-       char *msg = sa_message(sql->sa, SQLSTATE(40002) "UPDATE: CHECK 
constraint violated: %s", key->base.name);
+       char *msg = sa_message(sql->sa, SQLSTATE(40002) "UPDATE: violated 
constraint '%s.%s' CHECK(%s)", key->t->s->base.name, key->base.name, 
exp->comment);
        (void)stmt_exception(be, s, msg, 00001);
 }
 
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1376,7 +1376,7 @@ load_trans(sql_trans* tr)
                        NULL, NULL,
                        find_sql_column(systables, "schema_id"), /* order also 
on schema_id */
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to