Changeset: f4c6e22445b6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f4c6e22445b6
Added Files:
sql/test/bugs/Tests/emili.sql
sql/test/bugs/Tests/emili.stable.err
sql/test/bugs/Tests/emili.stable.out
sql/test/bugs/Tests/polymorphism.sql
sql/test/bugs/Tests/polymorphism.stable.err
sql/test/bugs/Tests/polymorphism.stable.out
Modified Files:
sql/common/sql_types.c
sql/scripts/15_history.sql
sql/storage/store.c
sql/test/bugs/Tests/All
Branch: default
Log Message:
merging
diffs (truncated from 435 to 300 lines):
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -691,6 +691,8 @@ sql_bind_member(sql_allocator *sa, sql_s
if (tp && f->fix_scale == INOUT)
digits = tp->digits;
sql_init_subtype(&fres->res, f->res.type,
digits, scale);
+ if (f->res.comp_type)
+ fres->res.comp_type = f->res.comp_type;
return fres;
}
}
@@ -712,6 +714,37 @@ sql_bind_member(sql_allocator *sa, sql_s
fres->func = f;
digits = f->res.digits;
sql_init_subtype(&fres->res,
f->res.type, digits, scale);
+ if (f->res.comp_type)
+ fres->res.comp_type =
f->res.comp_type;
+ return fres;
+ }
+ }
+ }
+ }
+ if (s) {
+ node *n;
+
+ if (s->funcs.set) for (n=s->funcs.set->h; n; n = n->next) {
+ sql_func *f = n->data;
+
+ if (!f->res.type)
+ continue;
+ if (strcmp(f->base.name, sqlfname) == 0) {
+ if (list_length(f->ops) == nrargs &&
is_subtype(tp, &((sql_arg *) f->ops->h->data)->type)) {
+
+ unsigned int scale = 0, digits;
+ sql_subfunc *fres = SA_ZNEW(sa,
sql_subfunc);
+
+ fres->func = f;
+ /* same scale as the input */
+ if (tp && tp->scale > scale)
+ scale = tp->scale;
+ digits = f->res.digits;
+ if (tp && f->fix_scale == INOUT)
+ digits = tp->digits;
+ sql_init_subtype(&fres->res,
f->res.type, digits, scale);
+ if (f->res.comp_type)
+ fres->res.comp_type =
f->res.comp_type;
return fres;
}
}
diff --git a/sql/scripts/15_history.sql b/sql/scripts/15_history.sql
--- a/sql/scripts/15_history.sql
+++ b/sql/scripts/15_history.sql
@@ -18,12 +18,12 @@
-- The query history mechanism of MonetDB/SQL relies on a few hooks
-- inside the kernel. The most important one is the SQL global
-- variable 'history', which is used by all sessions.
--- It is set automatically at the end of this script.
+-- It is initialized automatically at the end of this script.
-- Whenever a query is compiled and added to the cache, it is also entered
-- into the 'queryHistory' table using a hardwired call to 'keepQuery'.
-create table queryHistory(
+create table sys.queryHistory(
id wrd primary key,
defined timestamp, -- when entered into the cache
name string, -- database user name
@@ -49,7 +49,7 @@ update _tables
-- The 'inblock' and 'oublock' indicate the physical IOs during.
-- All timing in usec and all storage in bytes.
-create table callHistory(
+create table sys.callHistory(
id wrd references queryHistory(id), -- references query plan
ctime timestamp, -- time the first statement was executed
arguments string,
@@ -66,7 +66,7 @@ update _tables
where name = 'callhistory'
and schema_id = (select id from schemas where name = 'sys');
-create view queryLog as
+create view sys.queryLog as
select qd.*, ql.ctime, ql.arguments, ql.exec, ql.result, ql.foot, ql.memory,
ql.tuples, ql.inblock, ql.oublock from queryHistory qd, callHistory ql
where qd.id = ql.id;
update _tables
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -2467,12 +2467,13 @@ rollforward_add_table(sql_trans *tr, sql
return t;
}
-static sql_table *
+static int
rollforward_del_table(sql_trans *tr, sql_table *t, int mode)
{
(void) tr;
+ (void) t;
(void) mode;
- return t;
+ return LOG_OK;
}
static sql_table *
diff --git a/sql/test/bugs/Tests/All b/sql/test/bugs/Tests/All
--- a/sql/test/bugs/Tests/All
+++ b/sql/test/bugs/Tests/All
@@ -102,3 +102,5 @@ in_or_bug
create_insert_select_aggr-bug-00001
procedure_resolution_bug
correlated_update_bug
+polymorphism
+emili
diff --git a/sql/test/bugs/Tests/emili.sql b/sql/test/bugs/Tests/emili.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/bugs/Tests/emili.sql
@@ -0,0 +1,53 @@
+start transaction;
+--This one compiles
+
+create table istream(
+ ip int,
+ location varchar(16),
+ kind int,
+ value int);
+create table sensors(
+ ip int,
+ location varchar(16),
+ kind int,
+ value int);
+create table area(
+ ip int,
+ location varchar(16) );
+
+CREATE PROCEDURE enrich1()
+BEGIN
+ INSERT INTO sensors(ip, location, kind,value)
+ SELECT ip, substring(location,0,3), kind, value FROM istream;
+ IF TRUE
+ THEN
+ INSERT INTO area SELECT ip, substring(location,0,3) FROM istream;
+ END IF;
+END;
+
+--This one does not, see IF-expression, and does not produce an error message.
+
+CREATE PROCEDURE enrich2()
+BEGIN
+ INSERT INTO sensors(ip, location, kind,value)
+ SELECT ip, substring(location,0,3), kind, value FROM istream;
+ IF (SELECT count(*) FROM area ) = 0
+ THEN
+ INSERT INTO area SELECT ip, substring(location,0,3) FROM istream;
+ END IF;
+END;
+
+--And this one works again:
+CREATE PROCEDURE enrich3()
+BEGIN
+ DECLARE cnt INTEGER;
+ SET cnt = (SELECT count(*) FROM area ) ;
+ INSERT INTO sensors(ip, location, kind,value)
+ SELECT ip, substring(location,0,3), kind, value FROM istream;
+ IF cnt = 0
+ THEN
+ INSERT INTO area SELECT ip, substring(location,0,3) FROM istream;
+ END IF;
+END;
+
+rollback;
diff --git a/sql/test/bugs/Tests/emili.stable.err
b/sql/test/bugs/Tests/emili.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/bugs/Tests/emili.stable.err
@@ -0,0 +1,59 @@
+stderr of test 'emili` in directory 'sql/test/bugs` itself:
+
+
+# 19:14:59 >
+# 19:14:59 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=32975" "--set"
"mapi_usock=/var/tmp/mtest-15106/.s.monetdb.32975" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_bugs"
"--set" "mal_listing=0"
+# 19:14:59 >
+
+# builtin opt gdk_dbpath =
/home/niels/scratch/rc-clean/Linux-x86_64/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = yes
+# 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 = 32975
+# cmdline opt mapi_usock = /var/tmp/mtest-15106/.s.monetdb.32975
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbpath =
/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_bugs
+# cmdline opt mal_listing = 0
+
+# 19:14:59 >
+# 19:14:59 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-15106" "--port=32975"
+# 19:14:59 >
+
+MAPI = (monetdb) /var/tmp/mtest-15106/.s.monetdb.32975
+QUERY = CREATE PROCEDURE enrich2()
+ BEGIN
+ INSERT INTO sensors(ip, location, kind,value)
+ SELECT ip, substring(location,0,3), kind, value FROM istream;
+ IF (SELECT count(*) FROM area ) = 0
+ THEN
+ INSERT INTO area SELECT ip, substring(location,0,3) FROM
istream;
+ END IF;
+ END;
+ERROR = !IF THEN ELSE: No SELECT statements allowed within the IF condition
+MAPI = (monetdb) /var/tmp/mtest-15106/.s.monetdb.32975
+QUERY = CREATE PROCEDURE enrich3()
+ BEGIN
+ DECLARE cnt INTEGER;
+ SET cnt = (SELECT count(*) FROM area ) ;
+ INSERT INTO sensors(ip, location, kind,value)
+ SELECT ip, substring(location,0,3), kind, value FROM istream;
+ IF cnt = 0
+ THEN
+ INSERT INTO area SELECT ip, substring(location,0,3) FROM
istream;
+ END IF;
+ END;
+ERROR = !current transaction is aborted (please ROLLBACK)
+
+# 19:14:59 >
+# 19:14:59 > "Done."
+# 19:14:59 >
+
diff --git a/sql/test/bugs/Tests/emili.stable.out
b/sql/test/bugs/Tests/emili.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/bugs/Tests/emili.stable.out
@@ -0,0 +1,56 @@
+stdout of test 'emili` in directory 'sql/test/bugs` itself:
+
+
+# 19:14:59 >
+# 19:14:59 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=32975" "--set"
"mapi_usock=/var/tmp/mtest-15106/.s.monetdb.32975" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_bugs"
"--set" "mal_listing=0"
+# 19:14:59 >
+
+# MonetDB 5 server v11.15.4
+# This is an unreleased version
+# Serving database 'mTests_sql_test_bugs', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically
linked
+# Found 3.778 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2013 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on
mapi:monetdb://niels.nesco.mine.nu:32975/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-15106/.s.monetdb.32975
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 19:14:59 >
+# 19:14:59 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-15106" "--port=32975"
+# 19:14:59 >
+
+#start transaction;
+#create table istream(
+# ip int,
+# location varchar(16),
+# kind int,
+# value int);
+#create table sensors(
+# ip int,
+# location varchar(16),
+# kind int,
+# value int);
+#create table area(
+# ip int,
+# location varchar(16) );
+#CREATE PROCEDURE enrich1()
+#BEGIN
+# INSERT INTO sensors(ip, location, kind,value)
+# SELECT ip, substring(location,0,3), kind, value FROM istream;
+# IF TRUE
+# THEN
+# INSERT INTO area SELECT ip, substring(location,0,3) FROM istream;
+# END IF;
+#END;
+#rollback;
+
+# 19:14:59 >
+# 19:14:59 > "Done."
+# 19:14:59 >
+
diff --git a/sql/test/bugs/Tests/polymorphism.sql
b/sql/test/bugs/Tests/polymorphism.sql
new file mode 100644
--- /dev/null
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list