Changeset: 5d01b8c0cd97 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5d01b8c0cd97
Added Files:
        sql/test/BugTracker-2018/Tests/aggr-in-case.Bug-6526.stable.err
        sql/test/BugTracker-2018/Tests/aggr-in-case.Bug-6526.stable.out
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-in-cast-null.Bug-6529.stable.err
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-in-cast-null.Bug-6529.stable.out
        sql/test/BugTracker-2018/Tests/sqlitelogictest-in-query.Bug-6545.sql
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-in-with-division.Bug-6546.sql
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-not-in-wrong-results.Bug-6530.stable.err
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-not-in-wrong-results.Bug-6530.stable.out
Modified Files:
        gdk/gdk_atomic.h
        monetdb5/modules/mal/mkey.c
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_optimizer.c
        sql/backends/monet5/sql_optimizer.h
        sql/backends/monet5/sql_upgrades.c
        sql/scripts/97_comments.sql
        sql/server/rel_optimizer.c
        sql/server/rel_select.c
        sql/test/BugTracker-2018/Tests/All
        
sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.stable.out
        sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64
        sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade/Tests/upgrade.stable.out
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Merge with Mar2018 branch.


diffs (truncated from 1207 to 300 lines):

diff --git a/gdk/gdk_atomic.h b/gdk/gdk_atomic.h
--- a/gdk/gdk_atomic.h
+++ b/gdk/gdk_atomic.h
@@ -24,7 +24,7 @@
  * ATOMIC_INC -- increment a variable's value, return new value;
  * ATOMIC_DEC -- decrement a variable's value, return new value;
  * These interfaces work on variables of type ATOMIC_TYPE
- * (int or lng depending on architecture).
+ * (int or int64_t depending on architecture).
  *
  * In addition, the following operations are defined:
  * ATOMIC_TAS -- test-and-set: set variable to "true" and return old value
@@ -67,9 +67,9 @@
 
 #include <intrin.h>
 
-#if SIZEOF_SSIZE_T == SIZEOF_LNG
+#if SIZEOF_SSIZE_T == 8
 
-#define ATOMIC_TYPE                    lng
+#define ATOMIC_TYPE                    int64_t
 
 #define ATOMIC_GET(var, lck)           var
 #define ATOMIC_SET(var, val, lck)      _InterlockedExchange64(&var, (val))
@@ -110,10 +110,10 @@
 #define ATOMIC_TAS(var, lck)           _InterlockedCompareExchange(&var, 1, 0)
 #pragma intrinsic(_InterlockedCompareExchange)
 
-#elif (defined(__GNUC__) || defined(__INTEL_COMPILER)) && !(defined(__sun__) 
&& SIZEOF_SIZE_T == SIZEOF_LNG) && !defined(_MSC_VER) && 
!defined(NO_ATOMIC_INSTRUCTIONS)
+#elif (defined(__GNUC__) || defined(__INTEL_COMPILER)) && !(defined(__sun__) 
&& SIZEOF_SIZE_T == 8) && !defined(_MSC_VER) && !defined(NO_ATOMIC_INSTRUCTIONS)
 
-#if SIZEOF_SSIZE_T == SIZEOF_LNG
-#define ATOMIC_TYPE                    lng
+#if SIZEOF_SSIZE_T == 8
+#define ATOMIC_TYPE                    int64_t
 #else
 #define ATOMIC_TYPE                    int
 #endif
@@ -154,8 +154,8 @@
 
 #else
 
-#if SIZEOF_SSIZE_T == SIZEOF_LNG
-#define ATOMIC_TYPE                    lng
+#if SIZEOF_SSIZE_T == 8
+#define ATOMIC_TYPE                    int64_t
 #else
 #define ATOMIC_TYPE                    int
 #endif
diff --git a/monetdb5/modules/mal/mkey.c b/monetdb5/modules/mal/mkey.c
--- a/monetdb5/modules/mal/mkey.c
+++ b/monetdb5/modules/mal/mkey.c
@@ -357,7 +357,7 @@ MKEYbulk_rotate_xor_hash(bat *res, const
                BATkey(bn, 0);
                bn->tsorted = bn->trevsorted = 0;
        }
-       bn->tnonil = 1;
+       bn->tnonil = 0;
        bn->tnil = 0;
 
        BBPkeepref(*res = bn->batCacheid);
@@ -439,7 +439,7 @@ MKEYbulkconst_rotate_xor_hash(Client cnt
                BATkey(bn, 0);
                bn->tsorted = bn->trevsorted = 0;
        }
-       bn->tnonil = 1;
+       bn->tnonil = 0;
        bn->tnil = 0;
 
        BBPkeepref(*res = bn->batCacheid);
@@ -545,7 +545,7 @@ MKEYconstbulk_rotate_xor_hash(bat *res, 
                BATkey(bn, 0);
                bn->tsorted = bn->trevsorted = 0;
        }
-       bn->tnonil = 1;
+       bn->tnonil = 0;
        bn->tnil = 0;
 
        BBPkeepref(*res = bn->batCacheid);
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
@@ -4619,7 +4619,10 @@ check_for_foreign_key_references(mvc *sq
                                                if (k->t != t && !cascade) {
                                                        node *n = 
t->columns.set->h;
                                                        sql_column *c = n->data;
-                                                       
if(SQLgetColumnSize(sql->session->tr, c, 2) > 0) {
+                                                       size_t n_rows = 
store_funcs.count_col(sql->session->tr, c, 1);
+                                                       size_t n_deletes = 
store_funcs.count_del(sql->session->tr, c->t);
+                                                       assert (n_rows >= 
n_deletes);
+                                                       if(n_rows - n_deletes > 
0) {
                                                                *error = 
sql_error(sql, 02, SQLSTATE(42000) "TRUNCATE: FOREIGN KEY %s.%s depends on %s", 
k->t->base.name, k->base.name, t->base.name);
                                                                return;
                                                        }
diff --git a/sql/backends/monet5/sql_optimizer.c 
b/sql/backends/monet5/sql_optimizer.c
--- a/sql/backends/monet5/sql_optimizer.c
+++ b/sql/backends/monet5/sql_optimizer.c
@@ -25,7 +25,7 @@
 /* calculate the footprint for optimizer pipe line choices
  * and identify empty columns upfront for just in time optimizers.
  */
-lng
+static lng
 SQLgetColumnSize(sql_trans *tr, sql_column *c, int access)
 {
        lng size = 0;
diff --git a/sql/backends/monet5/sql_optimizer.h 
b/sql/backends/monet5/sql_optimizer.h
--- a/sql/backends/monet5/sql_optimizer.h
+++ b/sql/backends/monet5/sql_optimizer.h
@@ -11,7 +11,6 @@
 #include "sql.h"
 
 //#define _SQL_OPTIMIZER_DEBUG
-sql5_export lng SQLgetColumnSize(sql_trans *tr, sql_column *c, int access);
 sql5_export str SQLoptimizeQuery(Client c, MalBlkPtr mb);
 sql5_export str SQLoptimizeFunction(Client c, MalBlkPtr mb);
 sql5_export void SQLaddQueryToCache(Client c);
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -1469,7 +1469,7 @@ sql_update_mar2018(Client c, mvc *sql)
                        "         s.name || '.' || f.name AS fullname,\n"
                        "         CAST(8 AS SMALLINT) AS ntype,\n"
                        "         (CASE WHEN sf.function_id IS NOT NULL THEN 
'SYSTEM ' ELSE '' END) || sys.function_type_keyword(f.type) AS type,\n"
-                       "         CASE WHEN sf.function_id IS NULL THEN FALSE 
ELSE TRUE END AS system,\n"
+                       "         sf.function_id IS NOT NULL AS system,\n"
                        "         c.remark AS remark\n"
                        "  FROM sys.functions f\n"
                        "  LEFT OUTER JOIN sys.comments c ON f.id = c.id\n"
@@ -1492,7 +1492,7 @@ sql_update_mar2018(Client c, mvc *sql)
                        "       s.name AS schema,\n"
                        "       f.name AS fname,\n"
                        "       sys.function_type_keyword(f.type) AS 
category,\n"
-                       "       CASE WHEN sf.function_id IS NULL THEN FALSE 
ELSE TRUE END AS system,\n"
+                       "       sf.function_id IS NOT NULL AS system,\n"
                        "       CASE RANK() OVER (PARTITION BY f.id ORDER BY 
p.number ASC) WHEN 1 THEN f.name ELSE NULL END AS name,\n"
                        "       CASE RANK() OVER (PARTITION BY f.id ORDER BY 
p.number DESC) WHEN 1 THEN c.remark ELSE NULL END AS remark,\n"
                        "       p.type, p.type_digits, p.type_scale,\n"
diff --git a/sql/scripts/97_comments.sql b/sql/scripts/97_comments.sql
--- a/sql/scripts/97_comments.sql
+++ b/sql/scripts/97_comments.sql
@@ -66,7 +66,7 @@ SELECT DISTINCT s.name AS sname,  -- DIS
          s.name || '.' || f.name AS fullname,
          CAST(8 AS SMALLINT) AS ntype,
          (CASE WHEN sf.function_id IS NOT NULL THEN 'SYSTEM ' ELSE '' END) || 
sys.function_type_keyword(f.type) AS type,
-         CASE WHEN sf.function_id IS NULL THEN FALSE ELSE TRUE END AS system,
+         sf.function_id IS NOT NULL AS system,
          c.remark AS remark
   FROM sys.functions f
   LEFT OUTER JOIN sys.comments c ON f.id = c.id
@@ -91,7 +91,7 @@ SELECT f.id AS fid,
        s.name AS schema,
        f.name AS fname,
        sys.function_type_keyword(f.type) AS category,
-       CASE WHEN sf.function_id IS NULL THEN FALSE ELSE TRUE END AS system,
+       sf.function_id IS NOT NULL AS system,
        CASE RANK() OVER (PARTITION BY f.id ORDER BY p.number ASC) WHEN 1 THEN 
f.name ELSE NULL END AS name,
        CASE RANK() OVER (PARTITION BY f.id ORDER BY p.number DESC) WHEN 1 THEN 
c.remark ELSE NULL END AS remark,
        p.type, p.type_digits, p.type_scale,
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -5811,6 +5811,18 @@ static void
 exps_mark_used(sql_allocator *sa, sql_rel *rel, sql_rel *subrel)
 {
        int nr = 0;
+
+       if (rel->r && (rel->op == op_project || rel->op  == op_groupby)) {
+               list *l = rel->r;
+               node *n;
+
+               for (n=l->h; n; n = n->next) {
+                       sql_exp *e = n->data;
+
+                       exp_mark_used(rel, e);
+               }
+       }
+
        if (rel->exps) {
                node *n;
                int len = list_length(rel->exps), i;
@@ -5847,7 +5859,7 @@ exps_mark_used(sql_allocator *sa, sql_re
                for (n=l->h; n; n = n->next) {
                        sql_exp *e = n->data;
 
-                       exp_mark_used(rel, e);
+               //      exp_mark_used(rel, e);
                        /* possibly project/groupby uses columns from the inner 
*/ 
                        exp_mark_used(subrel, e);
                }
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
@@ -3842,7 +3842,7 @@ rel_case(mvc *sql, sql_rel **rel, int to
                                        return NULL;
                                cond = rel_binop_(sql, l, r, NULL, "=", 
card_value);
                        } else {
-                               cond = rel_logical_value_exp(sql, rel, 
when->h->data.sym, sql_sel);
+                               cond = rel_logical_value_exp(sql, rel, 
when->h->data.sym, f);
                        }
                        result = rel_value_exp(sql, rel, 
when->h->next->data.sym, f, ek);
                }
@@ -3881,9 +3881,9 @@ rel_case(mvc *sql, sql_rel **rel, int to
                                        return NULL;
                                cond = rel_binop_(sql, l, r, NULL, "=", 
card_value);
                        } else {
-                               cond = rel_logical_value_exp(sql, rel, 
when->h->data.sym, sql_sel);
+                               cond = rel_logical_value_exp(sql, rel, 
when->h->data.sym, f);
                        }
-                       result = rel_value_exp(sql, rel, 
when->h->next->data.sym, sql_sel, ek);
+                       result = rel_value_exp(sql, rel, 
when->h->next->data.sym, f, ek);
                }
                if (!cond || !result) 
                        return NULL;
diff --git a/sql/test/BugTracker-2018/Tests/All 
b/sql/test/BugTracker-2018/Tests/All
--- a/sql/test/BugTracker-2018/Tests/All
+++ b/sql/test/BugTracker-2018/Tests/All
@@ -13,7 +13,7 @@ update-with-correlated-subquery.Bug-6520
 sqlitelogictest-in-single-column.Bug-6522
 sqlitelogictest-case-subquery-missing.Bug-6523
 sqlitelogictest-group-by-having-in-count.Bug-6524
-aggr-in-case.Bug-6526
+HAVE_HGE?aggr-in-case.Bug-6526
 crash-orderby-alias.Bug-6527
 sqlitelogictest-in-cast-null.Bug-6529
 sqlitelogictest-not-in-wrong-results.Bug-6530
@@ -23,4 +23,5 @@ HAVE_NETCDF?truncate_sys_netcdf_tables.B
 HAVE_SAMTOOLS?truncate_bam_tables.Bug-6543
 truncate_sys_tables.Bug-6543
 truncate_empty_table.Bug-6544
-
+sqlitelogictest-in-query.Bug-6545
+sqlitelogictest-in-with-division.Bug-6546
diff --git a/sql/test/BugTracker-2018/Tests/aggr-in-case.Bug-6526.stable.err 
b/sql/test/BugTracker-2018/Tests/aggr-in-case.Bug-6526.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2018/Tests/aggr-in-case.Bug-6526.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'aggr-in-case.Bug-6526` in directory 'sql/test/BugTracker-2018` 
itself:
+
+
+# 18:07:27 >  
+# 18:07:27 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35745" "--set" 
"mapi_usock=/var/tmp/mtest-17690/.s.monetdb.35745" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
+# 18:07:27 >  
+
+# builtin opt  gdk_dbpath = 
/home/niels/scratch/rc-old/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 = 35745
+# cmdline opt  mapi_usock = /var/tmp/mtest-17690/.s.monetdb.35745
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018
+# cmdline opt  gdk_debug = 553648138
+
+# 18:07:27 >  
+# 18:07:27 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-17690" "--port=35745"
+# 18:07:27 >  
+
+
+# 18:07:27 >  
+# 18:07:27 >  "Done."
+# 18:07:27 >  
+
diff --git a/sql/test/BugTracker-2018/Tests/aggr-in-case.Bug-6526.stable.out 
b/sql/test/BugTracker-2018/Tests/aggr-in-case.Bug-6526.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2018/Tests/aggr-in-case.Bug-6526.stable.out
@@ -0,0 +1,90 @@
+stdout of test 'aggr-in-case.Bug-6526` in directory 'sql/test/BugTracker-2018` 
itself:
+
+
+# 18:07:27 >  
+# 18:07:27 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35745" "--set" 
"mapi_usock=/var/tmp/mtest-17690/.s.monetdb.35745" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-old/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2018"
+# 18:07:27 >  
+
+# MonetDB 5 server v11.27.14
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2018', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 128bit integers
+# Found 7.324 GiB available main-memory.
+# Copyright (c) 1993 - July 2008 CWI.
+# Copyright (c) August 2008 - 2018 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://localhost.nes.nl:35745/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-17690/.s.monetdb.35745
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 18:07:27 >  
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to