Changeset: 593633197125 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=593633197125
Added Files:
        sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.sql
        
sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.stable.err
        
sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.stable.out
Modified Files:
        gdk/gdk_hash.c
        gdk/gdk_heap.c
        gdk/gdk_imprints.c
        sql/test/BugTracker-2016/Tests/All
Branch: default
Log Message:

Merge with Jun2016 branch.


diffs (268 lines):

diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -495,6 +495,10 @@ BAThash(BAT *b, BUN masksize)
                        }
                        break;
                }
+#ifndef NDEBUG
+               /* clear unused part of Link array */
+               memset((char *) h->Link + q * h->width, 0, (h->lim - q) * 
h->width);
+#endif
                hp->parentid = b->batCacheid;
 #ifdef PERSISTENTHASH
                if (BBP_status(b->batCacheid) & BBPEXISTING) {
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -489,44 +489,53 @@ GDKupgradevarheap(BAT *b, var_t v, int c
 #endif
 
        /* convert from back to front so that we can do it in-place */
-       switch (b->twidth) {
-       case 1:
-               switch (width) {
-               case 2:
+       switch (width) {
+       case 2:
+#ifndef NDEBUG
+               memset(ps, 0, b->theap.base + b->theap.size - (char *) ps);
+#endif
+               switch (b->twidth) {
+               case 1:
                        for (i = 0; i < n; i++)
                                *--ps = *--pc;
                        break;
-               case 4:
+               }
+               break;
+       case 4:
+#ifndef NDEBUG
+               memset(ps, 0, b->theap.base + b->theap.size - (char *) pi);
+#endif
+               switch (b->twidth) {
+               case 1:
                        for (i = 0; i < n; i++)
                                *--pi = *--pc + GDK_VAROFFSET;
                        break;
+               case 2:
+                       for (i = 0; i < n; i++)
+                               *--pi = *--ps + GDK_VAROFFSET;
+                       break;
+               }
+               break;
 #if SIZEOF_VAR_T == 8
-               case 8:
+       case 8:
+#ifndef NDEBUG
+               memset(ps, 0, b->theap.base + b->theap.size - (char *) pv);
+#endif
+               switch (b->twidth) {
+               case 1:
                        for (i = 0; i < n; i++)
                                *--pv = *--pc + GDK_VAROFFSET;
                        break;
-#endif
-               }
-               break;
-       case 2:
-               switch (width) {
-               case 4:
-                       for (i = 0; i < n; i++)
-                               *--pi = *--ps + GDK_VAROFFSET;
-                       break;
-#if SIZEOF_VAR_T == 8
-               case 8:
+               case 2:
                        for (i = 0; i < n; i++)
                                *--pv = *--ps + GDK_VAROFFSET;
                        break;
-#endif
+               case 4:
+                       for (i = 0; i < n; i++)
+                               *--pv = *--pi;
+                       break;
                }
                break;
-#if SIZEOF_VAR_T == 8
-       case 4:
-               for (i = 0; i < n; i++)
-                       *--pv = *--pi;
-               break;
 #endif
        }
        b->theap.free <<= shift - b->tshift;
diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -117,6 +117,10 @@ imprints_create(BAT *b, void *inbins, BU
        BUN *restrict cnt_bins = max_bins + 64;
        int bin = 0;
        dcnt = icnt = 0;
+#ifndef NDEBUG
+       memset(min_bins, 0, 64 * SIZEOF_BUN);
+       memset(max_bins, 0, 64 * SIZEOF_BUN);
+#endif
        memset(cnt_bins, 0, 64 * SIZEOF_BUN);
 
        switch (ATOMbasetype(b->ttype)) {
@@ -152,6 +156,12 @@ imprints_create(BAT *b, void *inbins, BU
        *impcnt = icnt;
 }
 
+#ifdef NDEBUG
+#define CLRMEM()       ((void *) 0)
+#else
+#define CLRMEM()       while (k < 64) h[k++] = 0
+#endif
+
 #define FILL_HISTOGRAM(TYPE)                                           \
 do {                                                                   \
        BUN k;                                                          \
@@ -163,6 +173,7 @@ do {                                                        
                \
                        h[k] = s[k];                                    \
                while (k < (BUN) imprints->bits)                        \
                        h[k++] = max;                                   \
+               CLRMEM();                                               \
        } else {                                                        \
                double y, ystep = (double) cnt / (64 - 1);              \
                for (k = 0, y = 0; (BUN) y < cnt; y += ystep, k++)      \
@@ -388,13 +399,13 @@ BATimprints(BAT *b)
                 * trust the imprints when encountered on startup (including
                 * a version number -- CURRENT VERSION is 2). */
                if (HEAPalloc(imprints->imprints,
-                             64 * b->twidth +
-                             64 * 2 * SIZEOF_OID +
-                             64 * SIZEOF_BUN +
-                             pages * (imprints->bits / 8) +
-                             pages * sizeof(cchdc_t) +
-                             sizeof(uint64_t) /* padding for alignment */
-                             + IMPRINTS_HEADER_SIZE * SIZEOF_SIZE_T, /* extra 
info */
+                             IMPRINTS_HEADER_SIZE * SIZEOF_SIZE_T + /* extra 
info */
+                             64 * b->twidth + /* bins */
+                             64 * 2 * SIZEOF_OID + /* {min,max}_bins */
+                             64 * SIZEOF_BUN +     /* cnt_bins */
+                             pages * (imprints->bits / 8) + /* imps */
+                             sizeof(uint64_t) + /* padding for alignment */
+                             pages * sizeof(cchdc_t), /* dict */
                              1) != GDK_SUCCEED) {
                        GDKfree(imprints->imprints);
                        GDKfree(imprints);
@@ -450,6 +461,9 @@ BATimprints(BAT *b)
                                &imprints->dictcnt);
                assert(imprints->impcnt <= pages);
                assert(imprints->dictcnt <= pages);
+#ifndef NDEBUG
+               memset((char *) imprints->imps + imprints->impcnt * 
(imprints->bits / 8), 0, (char *) imprints->dict - ((char *) imprints->imps + 
imprints->impcnt * (imprints->bits / 8)));
+#endif
                imprints->imprints->free = (size_t) ((char *) ((cchdc_t *) 
imprints->dict + imprints->dictcnt) - imprints->imprints->base);
                /* add info to heap for when they become persistent */
                ((size_t *) imprints->imprints->base)[0] = (size_t) 
(imprints->bits);
diff --git a/sql/test/BugTracker-2016/Tests/All 
b/sql/test/BugTracker-2016/Tests/All
--- a/sql/test/BugTracker-2016/Tests/All
+++ b/sql/test/BugTracker-2016/Tests/All
@@ -51,3 +51,4 @@ concat_2_integers.Bug-4058
 column_not_found.Bug-4064
 prepare_without_querycache.Bug-4047
 outer_constant_predicate.Bug-4070
+name_conflict_in_union.Bug-6065
diff --git a/sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.sql 
b/sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.sql
@@ -0,0 +1,6 @@
+WITH t0(so) AS (
+       SELECT ROW_NUMBER() OVER (ORDER BY v0 ASC) AS so
+FROM (values (0)) as t(v0))
+SELECT 1 AS k1, a3.so AS k2 FROM t0 AS a3
+UNION ALL
+SELECT 2 AS k2, a8.so AS k2 FROM t0 AS a8;
diff --git 
a/sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.stable.err 
b/sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'name_conflict_in_union.Bug-6065` in directory 
'sql/test/BugTracker-2016` itself:
+
+
+# 12:57:07 >  
+# 12:57:07 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35574" "--set" 
"mapi_usock=/var/tmp/mtest-11796/.s.monetdb.35574" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2016"
 "--set" "embedded_r=yes"
+# 12:57:07 >  
+
+# builtin opt  gdk_dbpath = 
/home/niels/scratch/rc-monetdb/Linux-x86_64/var/monetdb5/dbfarm/demo
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_vmtrim = no
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 35574
+# cmdline opt  mapi_usock = /var/tmp/mtest-11796/.s.monetdb.35574
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2016
+# cmdline opt  embedded_r = yes
+# cmdline opt  gdk_debug = 536870922
+
+# 12:57:08 >  
+# 12:57:08 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-11796" "--port=35574"
+# 12:57:08 >  
+
+
+# 12:57:08 >  
+# 12:57:08 >  "Done."
+# 12:57:08 >  
+
diff --git 
a/sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.stable.out 
b/sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2016/Tests/name_conflict_in_union.Bug-6065.stable.out
@@ -0,0 +1,44 @@
+stdout of test 'name_conflict_in_union.Bug-6065` in directory 
'sql/test/BugTracker-2016` itself:
+
+
+# 12:57:07 >  
+# 12:57:07 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35574" "--set" 
"mapi_usock=/var/tmp/mtest-11796/.s.monetdb.35574" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2016"
 "--set" "embedded_r=yes"
+# 12:57:07 >  
+
+# MonetDB 5 server v11.23.10
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2016', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit 
integers dynamically linked
+# Found 7.332 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2016 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://localhost.nes.nl:35574/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-11796/.s.monetdb.35574
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+# MonetDB/R   module loaded
+
+Ready.
+
+# 12:57:08 >  
+# 12:57:08 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-11796" "--port=35574"
+# 12:57:08 >  
+
+#WITH t0(so) AS (
+#      SELECT ROW_NUMBER() OVER (ORDER BY v0 ASC) AS so
+#FROM (values (0)) as t(v0))
+#SELECT 1 AS k1, a3.so AS k2 FROM t0 AS a3
+#UNION ALL
+#SELECT 2 AS k2, a8.so AS k2 FROM t0 AS a8;
+% .L2, .L2 # table_name
+% k1,  k2 # name
+% tinyint,     int # type
+% 1,   1 # length
+[ 1,   1       ]
+[ 2,   1       ]
+
+# 12:57:08 >  
+# 12:57:08 >  "Done."
+# 12:57:08 >  
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to