Changeset: 900ea35c5fd5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=900ea35c5fd5
Added Files:
        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
Modified Files:
        sql/server/rel_optimizer.c
        sql/test/BugTracker-2017/Tests/All
Branch: Jul2017
Log Message:

fixed bug 6477, no need to rename expressions from other subqueries


diffs (156 lines):

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/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
@@ -95,4 +95,5 @@ 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.sql
+update_on_procedure.Bug-6479
+sqlsmith.Bug-6477
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 @@
+stdout 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 >  
+
+# 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:39335/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-23479/.s.monetdb.39335
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 14:26:12 >  
+# 14:26:12 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-23479" "--port=39335"
+# 14:26:12 >  
+
+
+# 14:26:12 >  
+# 14:26:12 >  "Done."
+# 14:26:12 >  
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to