Changeset: ea82b864645d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ea82b864645d
Added Files:
        sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.sql
        
sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.stable.err
        
sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.stable.out
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_gencode.c
        sql/server/rel_psm.c
        sql/server/rel_select.c
        sql/test/BugTracker-2017/Tests/prepare.Bug-6133.stable.err
        sql/test/BugTracker-2019/Tests/All
Branch: Apr2019
Log Message:

Throw a more detailed error message for bug 6706.


diffs (truncated from 334 to 300 lines):

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
@@ -320,9 +320,12 @@ value_list(backend *be, list *vals, stmt
 {
        node *n;
        stmt *s;
-
+       sql_subtype *type = exp_subtype(vals->h->data);
+
+       if (!type)
+               return sql_error(be->mvc, 02, SQLSTATE(42000) "Could not infer 
the type of a value list column");
        /* create bat append values */
-       s = stmt_temp(be, exp_subtype(vals->h->data));
+       s = stmt_temp(be, type);
        for( n = vals->h; n; n = n->next) {
                sql_exp *e = n->data;
                stmt *i = exp_bin(be, e, left, NULL, NULL, NULL, NULL, sel);
@@ -332,7 +335,6 @@ value_list(backend *be, list *vals, stmt
 
                if (list_length(vals) == 1)
                        return i;
-               
                s = stmt_append(be, s, i);
        }
        return s;
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -643,11 +643,11 @@ backend_dumpstmt(backend *be, MalBlkPtr 
                return -1;
        be->mvc_var = getDestVar(q);
        be->mb = mb;
-               s = sql_relation2stmt(be, r);
+       s = sql_relation2stmt(be, r);
        if (!s) {
                if (querylog)
                        (void) pushInt(mb, querylog, mb->stop);
-               return 0;
+               return (be->mvc->errstr[0] == '\0') ? 0 : -1;
        }
 
        be->mvc_var = old_mv;
@@ -746,8 +746,8 @@ backend_dumpproc(backend *be, Client c, 
                        sql_type *tpe = atom_type(a)->type;
                        int type, varid = 0;
 
-                       if(!tpe) {
-                               sql_error(m, 003, SQLSTATE(42000) "Could not 
determine type for argument %d\n", argc+1);
+                       if (!tpe) {
+                               sql_error(m, 003, SQLSTATE(42000) "Could not 
determine type for argument number %d\n", argc+1);
                                goto cleanup;
                        }
                        type = tpe->localtype;
@@ -767,8 +767,8 @@ backend_dumpproc(backend *be, Client c, 
                        sql_type *tpe = a->type.type;
                        int type, varid = 0;
 
-                       if(!tpe) {
-                               sql_error(m, 003, SQLSTATE(42000) "Could not 
determine type for argument %d\n", argc+1);
+                       if (!tpe) {
+                               sql_error(m, 003, SQLSTATE(42000) "Could not 
determine type for argument number %d\n", argc+1);
                                goto cleanup;
                        }
                        type = tpe->localtype;
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -845,7 +845,7 @@ rel_create_func(mvc *sql, dlist *qname, 
                                                arg_list = tpe;
                                        }
                                }
-                               (void)sql_error(sql, 02, SQLSTATE(42000) 
"CREATE %s%s: name '%s' (%s) already in use", KF, F, fname, arg_list);
+                               (void)sql_error(sql, 02, SQLSTATE(42000) 
"CREATE %s%s: name '%s' (%s) already in use", KF, F, fname, arg_list ? arg_list 
: "");
                                _DELETE(arg_list);
                                list_destroy(type_list);
                                return NULL;
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
@@ -1232,7 +1232,7 @@ exp_fix_scale(mvc *sql, sql_subtype *ct,
 static int
 rel_set_type_param(mvc *sql, sql_subtype *type, sql_exp *param, int upcast)
 {
-       if (!type || !param || param->type != e_atom)
+       if (!type || !param || (param->type != e_atom && param->type != 
e_column))
                return -1;
 
        /* use largest numeric types */
diff --git a/sql/test/BugTracker-2017/Tests/prepare.Bug-6133.stable.err 
b/sql/test/BugTracker-2017/Tests/prepare.Bug-6133.stable.err
--- a/sql/test/BugTracker-2017/Tests/prepare.Bug-6133.stable.err
+++ b/sql/test/BugTracker-2017/Tests/prepare.Bug-6133.stable.err
@@ -33,7 +33,8 @@ QUERY = PREPARE
         SELECT tnew.id, tnew.content, false, tnew.creationdate, 
tnew.locationip, tnew.browserused, NULL, tnew.length, tnew.person_id, 
tnew.place_id, parent.forum_id, tnew.comment_id, parent.post_id
         FROM ( VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ) AS tnew(id, content, 
creationdate, locationip, browserused, length, person_id, place_id, parent_id)
         JOIN messages parent ON ( parent.id = tnew.parent_id );
-ERROR = !42000!
+ERROR = !SELECT: subquery result missing
+CODE  = 42000
 
 # 20:13:43 >  
 # 20:13:43 >  "Done."
diff --git a/sql/test/BugTracker-2019/Tests/All 
b/sql/test/BugTracker-2019/Tests/All
--- a/sql/test/BugTracker-2019/Tests/All
+++ b/sql/test/BugTracker-2019/Tests/All
@@ -11,3 +11,4 @@ duplicates-not-eliminated-long-CASE-stmt
 KNOWNFAIL?subselect.Bug-6700
 alter_table_set_schema.Bug-6701
 crash-in-rel_dependencies.Bug-6703
+prepared-merge-statement.Bug-6706
diff --git 
a/sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.sql 
b/sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.sql
@@ -0,0 +1,33 @@
+create schema test;
+create table test.share_daily_history (id string, timeid int, c1 int, c2 int, 
c3 int, c4 int, volume int);
+
+prepare merge into test.share_daily_history as target
+using (select * from (values('BHP',1,1 ,1 ,1 ,1 ,1)) as 
a(id,timeid,c1,c2,c3,c4,volume)) as source
+on source.id=target.id and source.timeid=target.timeid
+when not matched then insert (id,timeid,c1,c2,c3,c4,volume) 
values(source.id,source.timeid,source.c1,source.c2,source.c3,source.c4,source.volume);
+exec **();
+exec **();
+
+prepare merge into test.share_daily_history as target
+using (select * from (values('BHP',?,?,?,?,?,?)) as 
a(id,timeid,c1,c2,c3,c4,volume)) as source
+on source.id=target.id and source.timeid=target.timeid
+when not matched then insert (id,timeid,c1,c2,c3,c4,volume) 
values(source.id,source.timeid,source.c1,source.c2,source.c3,source.c4,source.volume);
 --error
+
+prepare select * from test.share_daily_history
+inner join (values('BHP',?,?,?,?,?,?)) as source(id,timeid,c1,c2,c3,c4,volume)
+on source.id=share_daily_history.id and 
source.timeid=share_daily_history.timeid; --error
+
+prepare select * from test.share_daily_history
+inner join (values('BHP',?)) as source(id,timeid)
+on source.id=share_daily_history.id and 
source.timeid=share_daily_history.timeid; --error
+
+prepare select * from test.share_daily_history
+inner join (values('BHP')) as source(id)
+on source.id=share_daily_history.id;
+exec **();
+
+prepare select * from test.share_daily_history
+inner join (values('BHP'), (?)) as source(id)
+on source.id=share_daily_history.id; --error
+
+drop schema test cascade;
diff --git 
a/sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.stable.err 
b/sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.stable.err
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.stable.err
@@ -0,0 +1,62 @@
+stderr of test 'prepared-merge-statement.Bug-6706` in directory 
'sql/test/BugTracker-2019` itself:
+
+
+# 10:09:56 >  
+# 10:09:56 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=31509" "--set" 
"mapi_usock=/var/tmp/mtest-31613/.s.monetdb.31509" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019"
 "--set" "embedded_c=true"
+# 10:09:56 >  
+
+# builtin opt  gdk_dbpath = 
/home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/monetdb5/dbfarm/demo
+# 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 = 31509
+# cmdline opt  mapi_usock = /var/tmp/mtest-31613/.s.monetdb.31509
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019
+# cmdline opt  embedded_c = true
+#client2:!ERROR:ParseException:SQLparser:42000!Could not determine type for 
argument number 2
+#client2:!ERROR:ParseException:SQLparser:42000!Could not determine type for 
argument number 2
+#client2:!ERROR:ParseException:SQLparser:42000!Could not infer the type of a 
value list column
+#client2:!ERROR:ParseException:SQLparser:42000!Could not determine type for 
argument number 1
+#main thread:!ERROR:MALException:client.quit:Server stopped
+
+# 10:09:57 >  
+# 10:09:57 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-31613" "--port=31509"
+# 10:09:57 >  
+
+MAPI  = (monetdb) /var/tmp/mtest-31613/.s.monetdb.31509
+QUERY = prepare merge into test.share_daily_history as target
+        using (select * from (values('BHP',?,?,?,?,?,?)) as 
a(id,timeid,c1,c2,c3,c4,volume)) as source
+        on source.id=target.id and source.timeid=target.timeid
+        when not matched then insert (id,timeid,c1,c2,c3,c4,volume) 
values(source.id,source.timeid,source.c1,source.c2,source.c3,source.c4,source.volume);
 --error
+ERROR = !Could not determine type for argument number 2
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-31613/.s.monetdb.31509
+QUERY = prepare select * from test.share_daily_history
+        inner join (values('BHP',?,?,?,?,?,?)) as 
source(id,timeid,c1,c2,c3,c4,volume)
+        on source.id=share_daily_history.id and 
source.timeid=share_daily_history.timeid; --error
+ERROR = !Could not determine type for argument number 2
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-31613/.s.monetdb.31509
+QUERY = prepare select * from test.share_daily_history
+        inner join (values('BHP',?)) as source(id,timeid)
+        on source.id=share_daily_history.id and 
source.timeid=share_daily_history.timeid; --error
+ERROR = !Could not infer the type of a value list column
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-31613/.s.monetdb.31509
+QUERY = prepare select * from test.share_daily_history
+        inner join (values('BHP'), (?)) as source(id)
+        on source.id=share_daily_history.id; --error
+ERROR = !Could not determine type for argument number 1
+CODE  = 42000
+
+# 10:09:57 >  
+# 10:09:57 >  "Done."
+# 10:09:57 >  
+
diff --git 
a/sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.stable.out 
b/sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.stable.out
new file mode 100644
--- /dev/null
+++ 
b/sql/test/BugTracker-2019/Tests/prepared-merge-statement.Bug-6706.stable.out
@@ -0,0 +1,114 @@
+stdout of test 'prepared-merge-statement.Bug-6706` in directory 
'sql/test/BugTracker-2019` itself:
+
+
+# 10:09:56 >  
+# 10:09:56 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=31509" "--set" 
"mapi_usock=/var/tmp/mtest-31613/.s.monetdb.31509" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/home/ferreira/repositories/MonetDB-Apr2019/BUILD/var/MonetDB/mTests_sql_test_BugTracker-2019"
 "--set" "embedded_c=true"
+# 10:09:56 >  
+
+# MonetDB 5 server v11.33.4 (hg id: a3a2f049a9ab+)
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2019', using 8 threads
+# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers
+# Found 15.528 GiB available main-memory.
+# Copyright (c) 1993 - July 2008 CWI.
+# Copyright (c) August 2008 - 2019 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on 
mapi:monetdb://localhost.localdomain:31509/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-31613/.s.monetdb.31509
+# MonetDB/GIS module loaded
+# SQL catalog created, loading sql scripts once
+# loading sql script: 09_like.sql
+# loading sql script: 10_math.sql
+# loading sql script: 11_times.sql
+# loading sql script: 12_url.sql
+# loading sql script: 13_date.sql
+# loading sql script: 14_inet.sql
+# loading sql script: 15_querylog.sql
+# loading sql script: 16_tracelog.sql
+# loading sql script: 17_temporal.sql
+# loading sql script: 18_index.sql
+# loading sql script: 20_vacuum.sql
+# loading sql script: 21_dependency_views.sql
+# loading sql script: 22_clients.sql
+# loading sql script: 23_skyserver.sql
+# loading sql script: 25_debug.sql
+# loading sql script: 26_sysmon.sql
+# loading sql script: 27_rejects.sql
+# loading sql script: 39_analytics.sql
+# loading sql script: 39_analytics_hge.sql
+# loading sql script: 40_geom.sql
+# loading sql script: 40_json.sql
+# loading sql script: 40_json_hge.sql
+# loading sql script: 41_md5sum.sql
+# loading sql script: 45_uuid.sql
+# loading sql script: 46_profiler.sql
+# loading sql script: 51_sys_schema_extension.sql
+# loading sql script: 60_wlcr.sql
+# loading sql script: 72_fits.sql
+# loading sql script: 74_netcdf.sql
+# loading sql script: 75_lidar.sql
+# loading sql script: 75_shp.sql
+# loading sql script: 75_storagemodel.sql
+# loading sql script: 80_statistics.sql
+# loading sql script: 80_udf.sql
+# loading sql script: 80_udf_hge.sql
+# loading sql script: 85_bam.sql
+# loading sql script: 90_generator.sql
+# loading sql script: 90_generator_hge.sql
+# loading sql script: 99_system.sql
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 10:09:57 >  
+# 10:09:57 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-31613" "--port=31509"
+# 10:09:57 >  
+
+#create schema test;
+#create table test.share_daily_history (id string, timeid int, c1 int, c2 int, 
c3 int, c4 int, volume int);
+#prepare merge into test.share_daily_history as target
+#using (select * from (values('BHP',1,1 ,1 ,1 ,1 ,1)) as 
a(id,timeid,c1,c2,c3,c4,volume)) as source
+#on source.id=target.id and source.timeid=target.timeid
+#when not matched then insert (id,timeid,c1,c2,c3,c4,volume) 
values(source.id,source.timeid,source.c1,source.c2,source.c3,source.c4,source.volume);
+#prepare merge into test.share_daily_history as target
+#using (select * from (values('BHP',1,1 ,1 ,1 ,1 ,1)) as 
a(id,timeid,c1,c2,c3,c4,volume)) as source
+#on source.id=target.id and source.timeid=target.timeid
+#when not matched then insert (id,timeid,c1,c2,c3,c4,volume) 
values(source.id,source.timeid,source.c1,source.c2,source.c3,source.c4,source.volume);
+% .prepare,    .prepare,       .prepare,       .prepare,       .prepare,       
.prepare # table_name
+% type,        digits, scale,  schema, table,  column # name
+% varchar,     int,    int,    str,    str,    str # type
+% 0,   1,      1,      0,      0,      0 # length
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to