Changeset: f79bbb79adc0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f79bbb79adc0
Added Files:
        sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.sql
        sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.stable.err
        sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.stable.out
        sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.sql
        sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.stable.err
        sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.stable.out
        sql/test/BugTracker-2017/Tests/update_on_procedure.Bug-6479.sql
        sql/test/BugTracker-2017/Tests/update_on_procedure.Bug-6479.stable.err
        sql/test/BugTracker-2017/Tests/update_on_procedure.Bug-6479.stable.out
Modified Files:
        gdk/gdk_firstn.c
        sql/server/rel_optimizer.c
        sql/server/rel_semantic.c
        sql/test/BugTracker-2017/Tests/All
Branch: default
Log Message:

Merged with Jul2017


diffs (truncated from 440 to 300 lines):

diff --git a/gdk/gdk_firstn.c b/gdk/gdk_firstn.c
--- a/gdk/gdk_firstn.c
+++ b/gdk/gdk_firstn.c
@@ -763,7 +763,7 @@ BATfirstn_grouped_with_groups(BAT **topn
                        BBPunfix(bn1->batCacheid);
                        return  GDK_FAIL;
                }
-               bn4 = BATselect(b, bn3, BUNtail(bi, last - b->hseqbase), NULL, 
1, 0, 0);
+               bn4 = BATselect(b, bn3, BUNtail(bi, BUNlast(b) - b->hseqbase), 
NULL, 1, 0, 0);
                BBPunfix(bn3->batCacheid);
                if (bn4 == NULL) {
                        BBPunfix(bn1->batCacheid);
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
@@ -1192,8 +1192,11 @@ exp_rename(mvc *sql, sql_exp *e, sql_rel
                } else {
                        ne = exps_bind_column(f->exps, e->r, NULL);
                }
-               if (!ne) 
+               if (!ne) {
                        ne = mvc_find_subexp(sql, e->l?e->l:e->r, e->r);
+                       if (ne)
+                               return e;
+               }
                if (!ne)
                        return e;
                e = NULL;
diff --git a/sql/server/rel_semantic.c b/sql/server/rel_semantic.c
--- a/sql/server/rel_semantic.c
+++ b/sql/server/rel_semantic.c
@@ -99,11 +99,14 @@ rel_parse(mvc *m, sql_schema *s, char *q
                strcpy(m->errstr, errstr);
        } else {
                int label = m->label;
+               list *sqs = m->sqs;
+
                while (m->topvars > o.topvars) {
                        if (m->vars[--m->topvars].name)
                                c_delete(m->vars[m->topvars].name);
                }
                *m = o;
+               m->sqs = sqs;
                m->label = label;
        }
        m->session->schema = c;
diff --git a/sql/test/BugTracker-2017/Tests/All 
b/sql/test/BugTracker-2017/Tests/All
--- a/sql/test/BugTracker-2017/Tests/All
+++ b/sql/test/BugTracker-2017/Tests/All
@@ -109,3 +109,6 @@ HAVE_LIBPY?python_loader_clobbers_defaul
 skip_problem_best_effort.Bug-6442
 date_to_str.Bug-6467
 cleanup_statistics.Bug-6439
+update_on_procedure.Bug-6479
+sqlsmith.Bug-6477
+crash-in-topn.Bug-6478
diff --git a/sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.sql 
b/sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.sql
@@ -0,0 +1,26 @@
+CREATE TABLE "sys"."unitTestDontDelete" (
+       "A"                VARCHAR(255),
+       "B"                BIGINT,
+       "C"                DOUBLE,
+       "D"                TIMESTAMP,
+       "id" BIGINT        NOT NULL,
+       CONSTRAINT "\"unitTestDontDelete\"_PK" PRIMARY KEY ("id")
+);
+INSERT INTO "sys"."unitTestDontDelete" VALUES (NULL, NULL, NULL, NULL, 0);
+INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 0, 0.5, '2013-06-10 
11:10:10.000000', 1);
+INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 1, 1.5, '2013-06-11 
12:11:11.000000', 2);
+INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 2, 2.5, '2013-06-12 
13:12:12.000000', 3);
+INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 3, 3.5, '2013-06-13 
14:13:13.000000', 4);
+INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 4, 4.5, '2013-06-14 
15:14:14.000000', 5);
+INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 5, 5.5, '2013-06-15 
16:15:15.000000', 6);
+INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 6, 6.5, '2013-06-16 
17:16:16.000000', 7);
+INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 7, 7.5, '2013-06-17 
18:17:17.000000', 8);
+INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 8, 8.5, '2013-06-18 
19:18:18.000000', 9);
+
+select "A" as "cb_a", "B" as "cc_b", "C" as "cd_c", "D" as "ce_d" from (
+       select "t8"."A", "t8"."B", "t8"."C", "t8"."D", "t8"."id" from (
+               select "t7"."A", "t7"."B", "t7"."C", "t7"."D", "t7"."id" from 
"unitTestDontDelete" as "t7"
+       ) as "t8" order by "A" desc, "id" asc limit 4 offset 1
+) as "ta" order by "B" asc, "A" desc, "id" asc limit 1;
+
+drop table sys."unitTestDontDelete";
diff --git a/sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.stable.err 
b/sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'crash-in-topn.Bug-6478` in directory 
'sql/test/BugTracker-2017` itself:
+
+
+# 16:27:05 >  
+# 16:27:05 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=38375" "--set" 
"mapi_usock=/var/tmp/mtest-13869/.s.monetdb.38375" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 16:27:05 >  
+
+# 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 = 38375
+# cmdline opt  mapi_usock = /var/tmp/mtest-13869/.s.monetdb.38375
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017
+# cmdline opt  gdk_debug = 536870922
+
+# 16:27:05 >  
+# 16:27:05 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-13869" "--port=38375"
+# 16:27:05 >  
+
+
+# 16:27:05 >  
+# 16:27:05 >  "Done."
+# 16:27:05 >  
+
diff --git a/sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.stable.out 
b/sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/crash-in-topn.Bug-6478.stable.out
@@ -0,0 +1,70 @@
+stdout of test 'crash-in-topn.Bug-6478` in directory 
'sql/test/BugTracker-2017` itself:
+
+
+# 16:27:05 >  
+# 16:27:05 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=38375" "--set" 
"mapi_usock=/var/tmp/mtest-13869/.s.monetdb.38375" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 16:27:05 >  
+
+# MonetDB 5 server v11.27.6
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2017', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 128bit integers
+# Found 7.330 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2017 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://localhost.nes.nl:38375/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-13869/.s.monetdb.38375
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 16:27:05 >  
+# 16:27:05 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-13869" "--port=38375"
+# 16:27:05 >  
+
+#CREATE TABLE "sys"."unitTestDontDelete" (
+#      "A"                VARCHAR(255),
+#      "B"                BIGINT,
+#      "C"                DOUBLE,
+#      "D"                TIMESTAMP,
+#      "id" BIGINT        NOT NULL,
+#      CONSTRAINT "\"unitTestDontDelete\"_PK" PRIMARY KEY ("id")
+#);
+#INSERT INTO "sys"."unitTestDontDelete" VALUES (NULL, NULL, NULL, NULL, 0);
+[ 1    ]
+#INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 0, 0.5, '2013-06-10 
11:10:10.000000', 1);
+[ 1    ]
+#INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 1, 1.5, '2013-06-11 
12:11:11.000000', 2);
+[ 1    ]
+#INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 2, 2.5, '2013-06-12 
13:12:12.000000', 3);
+[ 1    ]
+#INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 3, 3.5, '2013-06-13 
14:13:13.000000', 4);
+[ 1    ]
+#INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 4, 4.5, '2013-06-14 
15:14:14.000000', 5);
+[ 1    ]
+#INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 5, 5.5, '2013-06-15 
16:15:15.000000', 6);
+[ 1    ]
+#INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 6, 6.5, '2013-06-16 
17:16:16.000000', 7);
+[ 1    ]
+#INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 7, 7.5, '2013-06-17 
18:17:17.000000', 8);
+[ 1    ]
+#INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 8, 8.5, '2013-06-18 
19:18:18.000000', 9);
+[ 1    ]
+#select "A" as "cb_a", "B" as "cc_b", "C" as "cd_c", "D" as "ce_d" from (
+#      select "t8"."A", "t8"."B", "t8"."C", "t8"."D", "t8"."id" from (
+#              select "t7"."A", "t7"."B", "t7"."C", "t7"."D", "t7"."id" from 
"unitTestDontDelete" as "t7"
+#      ) as "t8" order by "A" desc, "id" asc limit 4 offset 1
+#) as "ta" order by "B" asc, "A" desc, "id" asc limit 1;
+% sys.L15,     sys.L17,        sys.L21,        sys.L23 # table_name
+% cb_a,        cc_b,   cd_c,   ce_d # name
+% varchar,     bigint, double, timestamp # type
+% 4,   1,      24,     26 # length
+[ "Cat1",      0,      0.5,    2013-06-10 11:10:10.000000      ]
+#drop table sys."unitTestDontDelete";
+
+# 16:27:05 >  
+# 16:27:05 >  "Done."
+# 16:27:05 >  
+
diff --git a/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.sql 
b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.sql
@@ -0,0 +1,27 @@
+select
+  cast(coalesce(ref_0.stop,
+    ref_0.stop) as timestamp) as c0,
+  ref_0.id as c1,
+  cast(coalesce(ref_0.cpu,
+    ref_0.io) as int) as c2,
+  ref_0.run as c3,
+  ref_0.stop as c4,
+  ref_0.cpu as c5,
+  case when cast(nullif(ref_0.tuples,
+        ref_0.tuples) as bigint) is not NULL then ref_0.io else ref_0.io end
+     as c6
+from
+  sys.querylog_calls as ref_0
+where cast(coalesce(ref_0.tuples,
+    case when EXISTS (
+        select
+            ref_1.id as c0
+          from
+            sys.args as ref_1
+              left join tmp.objects as ref_2
+                right join sys.spatial_ref_sys as ref_3
+                on (true)
+              on (ref_1.type_scale = ref_2.id )
+          where true) then ref_0.run else ref_0.run end
+      ) as bigint) is not NULL
+limit 101;
diff --git a/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.stable.err 
b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.stable.err
@@ -0,0 +1,57 @@
+stderr of test 'sqlsmith.Bug-6477` in directory 'sql/test/BugTracker-2017` 
itself:
+
+
+# 14:26:12 >  
+# 14:26:12 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39335" "--set" 
"mapi_usock=/var/tmp/mtest-23479/.s.monetdb.39335" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 14:26:12 >  
+
+# 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 = 39335
+# cmdline opt  mapi_usock = /var/tmp/mtest-23479/.s.monetdb.39335
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2017
+# cmdline opt  gdk_debug = 536870922
+
+# 14:26:12 >  
+# 14:26:12 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-23479" "--port=39335"
+# 14:26:12 >  
+
+MAPI  = (monetdb) /var/tmp/mtest-23479/.s.monetdb.39335
+QUERY = select
+          cast(coalesce(ref_0.stop,
+            ref_0.stop) as timestamp) as c0,
+          ref_0.id as c1,
+          cast(coalesce(ref_0.cpu,
+            ref_0.io) as int) as c2,
+          ref_0.run as c3,
+          ref_0.stop as c4,
+          ref_0.cpu as c5,
+          case when cast(nullif(ref_0.tuples,
+                ref_0.tuples) as bigint) is not NULL then ref_0.io else 
ref_0.io end
+             as c6
+        from
+          sys.querylog_calls as ref_0
+        where cast(coalesce(ref_0.tuples,
+            case when EXISTS (
+                select
+                    ref_1.id as c0
+                  from
+                    sys.args as ref_1
+                      left join tmp.objects as ref_2
+ERROR = !cardinality violation, scalar value expected
+
+# 14:26:12 >  
+# 14:26:12 >  "Done."
+# 14:26:12 >  
+
diff --git a/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.stable.out 
b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2017/Tests/sqlsmith.Bug-6477.stable.out
@@ -0,0 +1,31 @@
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to