Changeset: cfdd19ccca56 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cfdd19ccca56
Modified Files:
        common/utils/mstring.h
        gdk/gdk.h
        gdk/gdk_utils.c
        geom/lib/libgeom.c
        geom/monetdb5/geom.c
        sql/server/rel_select.c
        sql/storage/store.c
        sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err
        sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.out
        sql/test/subquery/Tests/subquery5.sql
        sql/test/subquery/Tests/subquery5.stable.err
        testing/difflib.c
Branch: default
Log Message:

Merged with Jun2020


diffs (truncated from 370 to 300 lines):

diff --git a/common/utils/mstring.h b/common/utils/mstring.h
--- a/common/utils/mstring.h
+++ b/common/utils/mstring.h
@@ -12,6 +12,12 @@
 #include <stdarg.h>            /* va_list etc. */
 #include <string.h>            /* strlen */
 
+#ifdef __GNUC__
+#define GCC_Pragma(pragma)     _Pragma(pragma)
+#else
+#define GCC_Pragma(pragma)
+#endif
+
 /* copy at most (n-1) bytes from src to dst and add a terminating NULL
  * byte; return length of src (i.e. can be more than what is copied) */
 static inline size_t
@@ -23,6 +29,20 @@ strcpy_len(char *restrict dst, const cha
                                return i;
                }
                dst[n - 1] = 0;
+/* This code is correct, but GCC gives a warning in certain
+ * conditions, so we disable the warning temporarily.
+ * The warning happens e.g. in
+ *   strcpy_len(buf, "fixed string", sizeof(buf))
+ * where buf is larger than the string. In that case we never get here
+ * since return is executed in the loop above, but the compiler
+ * complains anyway about reading out-of-bounds.
+ * For GCC we use _Pragma to disable the warning (and hence error).
+ * Since other compilers may warn (and hence error out) on
+ * unrecognized pragmas, we use some preprocessor trickery. */
+GCC_Pragma("GCC diagnostic push")
+GCC_Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
+               return n + strlen(src + n);
+GCC_Pragma("GCC diagnostic pop")
        }
        return strlen(src);
 }
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1709,10 +1709,10 @@ typedef struct threadStruct {
                                 * into this array + 1 (0 is
                                 * invalid) */
        ATOMIC_TYPE pid;        /* thread id, 0 = unallocated */
-       str name;
+       char name[16];
        void *data[THREADDATA];
        uintptr_t sp;
-} ThreadRec, *Thread;
+} *Thread;
 
 
 gdk_export int THRgettid(void);
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -931,7 +931,7 @@ GDKinit(opt *set, int setlen)
 
 int GDKnr_threads = 0;
 static ATOMIC_TYPE GDKnrofthreads = ATOMIC_VAR_INIT(0);
-static ThreadRec GDKthreads[THREADS];
+static struct threadStruct GDKthreads[THREADS];
 
 bool
 GDKexiting(void)
@@ -983,8 +983,6 @@ GDKreset(int status)
                                        TRC_INFO(GDK, "Killing thread: %d\n", 
e);
                                        (void) ATOMIC_DEC(&GDKnrofthreads);
                                }
-                               GDKfree(t->name);
-                               t->name = NULL;
                                ATOMIC_SET(&t->pid, 0);
                        }
                }
@@ -1349,13 +1347,6 @@ GDK_find_self(void)
 static Thread
 THRnew(const char *name, MT_Id pid)
 {
-       char *nme = GDKstrdup(name);
-
-       if (nme == NULL) {
-               TRC_DEBUG(IO_, "Malloc failure\n");
-               GDKerror("malloc failure\n");
-               return NULL;
-       }
        for (Thread s = GDKthreads; s < GDKthreads + THREADS; s++) {
                ATOMIC_BASE_TYPE npid = 0;
                if (ATOMIC_CAS(&s->pid, &npid, pid)) {
@@ -1363,7 +1354,7 @@ THRnew(const char *name, MT_Id pid)
                        s->data[0] = THRdata[0];
                        s->data[1] = THRdata[1];
                        s->sp = THRsp();
-                       s->name = nme;
+                       strcpy_len(s->name, name, sizeof(s->name));
                        TRC_DEBUG(PAR, "%x %zu sp = %zu\n",
                                  (unsigned) s->tid,
                                  (size_t) ATOMIC_GET(&s->pid),
@@ -1373,7 +1364,6 @@ THRnew(const char *name, MT_Id pid)
                        return s;
                }
        }
-       GDKfree(nme);
        TRC_DEBUG(IO_, "Too many threads\n");
        GDKerror("too many threads\n");
        return NULL;
@@ -1428,8 +1418,6 @@ THRcreate(void (*f) (void *), void *arg,
                TRC_DEBUG(IO_, "Semaphore name is too large\n");
                GDKerror("semaphore name is too large\n");
                GDKfree(t);
-               GDKfree(s->name);
-               s->name = NULL;
                ATOMIC_SET(&s->pid, 0); /* deallocate */
                return 0;
        }
@@ -1438,8 +1426,6 @@ THRcreate(void (*f) (void *), void *arg,
                GDKerror("could not start thread\n");
                MT_sema_destroy(&t->sem);
                GDKfree(t);
-               GDKfree(s->name);
-               s->name = NULL;
                ATOMIC_SET(&s->pid, 0); /* deallocate */
                return 0;
        }
@@ -1460,8 +1446,7 @@ THRdel(Thread t)
                  (size_t) ATOMIC_GET(&t->pid),
                  (int) ATOMIC_GET(&GDKnrofthreads));
 
-       GDKfree(t->name);
-       t->name = NULL;
+       t->name[0] = 0;
        for (int i = 0; i < THREADDATA; i++)
                t->data[i] = NULL;
        t->sp = 0;
diff --git a/geom/lib/libgeom.c b/geom/lib/libgeom.c
--- a/geom/lib/libgeom.c
+++ b/geom/lib/libgeom.c
@@ -27,6 +27,7 @@ geomerror(_In_z_ _Printf_format_string_ 
        vsnprintf(err, sizeof(err), fmt, va);
        GDKtracer_log(__FILE__, __func__, __LINE__, M_CRITICAL,
                      GDK, NULL, "%s", err);
+       va_end(va);
 }
 
 void
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -1594,7 +1594,11 @@ dumpGeometriesSingle(BAT *idBAT, BAT *ge
                snprintf(newPath, lvlDigitsNum + 1, "%u", *lvl);
        } else {
                //remove the comma at the end of the path
-               newPath = GDKmalloc(pathLength);
+               newPath = GDKmalloc(pathLength
+#ifdef STATIC_CODE_ANALYSIS
+                                   + 1
+#endif
+                       );
                if (newPath == NULL) {
                        GDKfree(singleWKB);
                        throw(MAL, "geom.Dump", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -1170,19 +1170,22 @@ rel_column_ref(sql_query *query, sql_rel
                int var = stack_find_var(sql, name);
 
                if (!exp && inner)
-                       exp = rel_bind_column(sql, inner, name, f, 0);
+                       if (!(exp = rel_bind_column(sql, inner, name, f, 0)) && 
sql->session->status == -ERR_AMBIGUOUS)
+                               return NULL;
                if (!exp && inner && is_sql_having(f) && inner->op == op_select)
                        inner = inner->l;
                if (!exp && inner && (is_sql_having(f) || is_sql_aggr(f)) && 
is_groupby(inner->op))
-                       exp = rel_bind_column(sql, inner->l, name, f, 0);
+                       if (!(exp = rel_bind_column(sql, inner->l, name, f, 0)) 
&& sql->session->status == -ERR_AMBIGUOUS)
+                               return NULL;
                if (!exp && query && query_has_outer(query)) {
                        int i;
                        sql_rel *outer;
 
                        for (i=query_has_outer(query)-1; i>= 0 && !exp && 
(outer = query_fetch_outer(query,i)); i--) {
-                               exp = rel_bind_column(sql, outer, name, f, 0);
-                               if (!exp && is_groupby(outer->op))
-                                       exp = rel_bind_column(sql, outer->l, 
name, f, 0);
+                               if (!(exp = rel_bind_column(sql, outer, name, 
f, 0)) && sql->session->status == -ERR_AMBIGUOUS)
+                                       return NULL;
+                               if (!exp && is_groupby(outer->op) && !(exp = 
rel_bind_column(sql, outer->l, name, f, 0)) && sql->session->status == 
-ERR_AMBIGUOUS)
+                                       return NULL;
                                if (exp && is_simple_project(outer->op) && 
!rel_find_exp(outer, exp))
                                        exp = rel_project_add_exp(sql, outer, 
exp);
                                if (exp)
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -4222,7 +4222,7 @@ static int
 rollforward_drop_column(sql_trans *tr, sql_column *c, int mode)
 {
        if (isTable(c->t)) {
-               int p = (tr->parent == gtrans);
+               int p = (tr->parent == gtrans && !isTempTable(c->t));
 
                if (p && mode == R_LOG)
                        return store_funcs.log_destroy_col(tr, c);
@@ -4238,7 +4238,7 @@ rollforward_drop_idx(sql_trans *tr, sql_
        int ok = LOG_OK;
 
        if (isTable(i->t)) {
-               int p = (tr->parent == gtrans);
+               int p = (tr->parent == gtrans && !isTempTable(i->t));
 
                if (p && mode == R_LOG)
                        ok = store_funcs.log_destroy_idx(tr, i);
@@ -4328,7 +4328,7 @@ rollforward_drop_table(sql_trans *tr, sq
        int ok = LOG_OK;
 
        if (isTable(t)) {
-               int p = (tr->parent == gtrans);
+               int p = (tr->parent == gtrans && !isTempTable(t));
 
                if (p && mode == R_LOG)
                        ok = store_funcs.log_destroy_del(tr, t);
diff --git 
a/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err 
b/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err
--- a/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err
+++ b/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err
@@ -5,65 +5,11 @@ stderr of test 'assert_in_update.SF-2807
 # 10:38:04 >   mserver5 
"--config=/ufs/niels/scratch/rc/Linux-x86_64/etc/monetdb5.conf" --debug=10 
--set gdk_nr_threads=0 --set 
"monet_mod_path=/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5:/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5/lib:/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5/bin"
 --set "gdk_dbfarm=/ufs/niels/scratch/rc/Linux-x86_64/var/MonetDB5/dbfarm"    
--set mapi_open=true --set xrpc_open=true --set mapi_port=36216 --set 
xrpc_port=46629 --set monet_prompt= --trace  
"--dbname=mTests_src_test_BugTracker-2009" --set mal_listing=0 "--dbinit= 
include sql;" ; echo ; echo Over..
 # 10:38:04 >  
 
-# builtin opt  gdk_arch = 64bitx86_64-unknown-linux-gnu
-# builtin opt  gdk_version = 1.32.0
-# builtin opt  prefix = /ufs/niels/scratch/rc/Linux-x86_64
-# builtin opt  exec_prefix = ${prefix}
-# builtin opt  gdk_dbname = tst
-# builtin opt  gdk_dbfarm = ${prefix}/var/MonetDB
-# builtin opt  gdk_debug = 8
-# builtin opt  gdk_alloc_map = yes
-# builtin opt  gdk_vmtrim = yes
-# builtin opt  monet_admin = adm
-# builtin opt  monet_prompt = >
-# builtin opt  monet_welcome = yes
-# builtin opt  monet_mod_path = ${exec_prefix}/lib/MonetDB
-# builtin opt  monet_daemon = yes
-# builtin opt  host = localhost
-# builtin opt  mapi_port = 50000
-# builtin opt  mapi_noheaders = no
-# builtin opt  mapi_debug = 0
-# builtin opt  mapi_clients = 2
-# builtin opt  sql_debug = 0
-# builtin opt  sql_logdir = sql_logs
-# builtin opt  xquery_logdir = xquery_logs
-# builtin opt  standoff_ns = http://monetdb.cwi.nl/standoff
-# builtin opt  standoff_start = start
-# builtin opt  standoff_end = end
-# config opt   prefix = /ufs/niels/scratch/rc/Linux-x86_64
-# config opt   config = ${prefix}/etc/monetdb5.conf
-# config opt   prefix = /ufs/niels/scratch/rc/Linux-x86_64
-# config opt   exec_prefix = ${prefix}
-# config opt   gdk_dbfarm = ${prefix}/var/MonetDB5/dbfarm
-# config opt   gdk_dbname = demo
-# config opt   gdk_alloc_map = no
-# config opt   gdk_embedded = no
-# config opt   gdk_debug = 0
-# config opt   monet_mod_path = 
${exec_prefix}/lib/MonetDB5:${exec_prefix}/lib/MonetDB5/lib:${exec_prefix}/lib/MonetDB5/bin
-# config opt   monet_daemon = no
-# config opt   monet_welcome = yes
-# config opt   mero_msglog = ${prefix}/var/log/MonetDB/merovingian.log
-# config opt   mero_errlog = ${prefix}/var/log/MonetDB/merovingian.log
-# config opt   mero_pidfile = ${prefix}/var/run/MonetDB/merovingian.pid
-# config opt   mal_init = ${exec_prefix}/lib/MonetDB5/mal_init.mal
-# config opt   mal_listing = 2
-# config opt   mapi_port = 50000
-# config opt   mapi_autosense = false
-# config opt   mapi_open = false
-# config opt   sql_optimizer = 
inline,remap,evaluate,costModel,coercions,emptySet,cluster,aliases,mergetable,deadcode,constants,commonTerms,joinPath,deadcode,reduce,garbageCollector,dataflow,history,multiplex
-# cmdline opt  config = /ufs/niels/scratch/rc/Linux-x86_64/etc/monetdb5.conf
-# cmdline opt  gdk_nr_threads = 0
-# cmdline opt  monet_mod_path = 
/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5:/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5/lib:/ufs/niels/scratch/rc/Linux-x86_64/lib/MonetDB5/bin
-# cmdline opt  gdk_dbfarm = 
/ufs/niels/scratch/rc/Linux-x86_64/var/MonetDB5/dbfarm
-# cmdline opt  mapi_open = true
-# cmdline opt  xrpc_open = true
-# cmdline opt  mapi_port = 36216
-# cmdline opt  xrpc_port = 46629
-# cmdline opt  monet_prompt = 
-# cmdline opt  gdk_dbname = mTests_src_test_BugTracker-2009
-# cmdline opt  mal_listing = 0
-#warning: please don't forget to set your vault key!
-#(see /ufs/niels/scratch/rc/Linux-x86_64/etc/monetdb5.conf)
+MAPI  = (monetdb) /var/tmp/mtest-338701/.s.monetdb.39866
+QUERY = update anbi set kvk = (select kvk from kvk,anbi where lower(naam)
+        = lower(bedrijfsnaam) and lower(plaats) = lower(vestigingsplaats));
+ERROR = !SELECT: identifier 'kvk' ambiguous
+CODE  = 42000
 
 # 13:17:20 >  
 # 13:17:20 >  "Done."
diff --git 
a/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.out 
b/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.out
--- a/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.out
+++ b/sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.out
@@ -30,9 +30,8 @@ stdout of test 'assert_in_update.SF-2807
 #update anbi set kvk = (select kvk.kvk from kvk,anbi where lower(naam)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to