Changeset: cecb54de54c5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cecb54de54c5
Added Files:
sql/test/BugTracker-2013/PSMcreate_user.sql
sql/test/BugTracker-2013/PSMdrop_user.sql
sql/test/BugTracker-2013/PSMexplain_function.sql
sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.SQL.py
sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.err
sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.out
Modified Files:
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_scenario.c
sql/test/BugTracker-2013/Tests/All
Branch: Feb2013
Log Message:
fixed bug 3300. The nested functions error handling was improved.
diffs (284 lines):
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
@@ -2526,6 +2526,7 @@ backend_create_func(backend *be, sql_fun
}
if (!s) {
+ f->sql--;
sa_destroy(sa);
return -1;
}
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -1759,28 +1759,30 @@ SQLparser(Client c)
m->emode = m_inplace;
}
}
- if (be->q) {
- if (m->emode == m_prepare)
- err = mvc_export_prepare(m, c->fdout, be->q, "");
- else if (m->emode == m_inplace) {
- /* everything ready for a fast call */
- } else { /* call procedure generation (only in cache mode) */
- backend_call(be, c, be->q);
+ if (err)
+ m->session->status = -10;
+ if (err == 0) {
+ if (be->q) {
+ if (m->emode == m_prepare)
+ err = mvc_export_prepare(m, c->fdout, be->q,
"");
+ else if (m->emode == m_inplace) {
+ /* everything ready for a fast call */
+ } else { /* call procedure generation (only in cache
mode) */
+ backend_call(be, c, be->q);
+ }
}
- }
+
+ /* In the final phase we add any debugging control */
+ if (m->emod & mod_trace)
+ SQLsetTrace(be, c, FALSE);
+ if (m->emod & mod_debug)
+ SQLsetDebugger(c, m, FALSE);
- /* In the final phase we add any debugging control */
- if (m->emod & mod_trace)
- SQLsetTrace(be, c, FALSE);
- if (m->emod & mod_debug)
- SQLsetDebugger(c, m, FALSE);
-
- /*
- * During the execution of the query exceptions can be raised.
- * The default action is to print them out at the end of the
- * query block.
- */
- if (err == 0) {
+ /*
+ * During the execution of the query exceptions can be raised.
+ * The default action is to print them out at the end of the
+ * query block.
+ */
if (be->q)
pushEndInstruction(c->curprg->def);
@@ -1910,28 +1912,24 @@ SQLengineIntern(Client c, backend *be)
}
if (m->emod & mod_explain) {
- if (be->q && be->q->code)
+ if (be->q && be->q->code)
printFunction(c->fdout, ((Symbol) (be->q->code))->def,
0, LIST_MAL_STMT | LIST_MAL_UDF | LIST_MAPI);
- else if (c->curprg && c->curprg->def)
+ else if (be->q)
+ msg = createException(PARSE, "SQLparser", "%s",
(*m->errstr)?m->errstr:"39000!program contains errors");
+ else if (c->curprg && c->curprg->def)
printFunction(c->fdout, c->curprg->def, 0,
LIST_MAL_STMT | LIST_MAL_UDF | LIST_MAPI);
+ goto cleanup_engine;
}
if (m->emod & mod_dot) {
- if (be->q && be->q->code)
+ if (be->q && be->q->code)
showFlowGraph(((Symbol) (be->q->code))->def, 0,
"stdout-mapi");
+ else if (be->q)
+ msg = createException(PARSE, "SQLparser", "%s",
(*m->errstr)?m->errstr:"39000!program contains errors");
else if (c->curprg && c->curprg->def)
showFlowGraph(c->curprg->def, 0, "stdout-mapi");
- }
- if (m->emod & (mod_explain | mod_dot)) {
- sqlcleanup(be->mvc, 0);
goto cleanup_engine;
}
- if (c->curprg->def->errors){
- assert(0);
- sqlcleanup(be->mvc, 0);
- throw(SQL, "SQLengine", "39000!program contains errors");
- }
-
#ifdef SQL_SCENARIO_DEBUG
mnstr_printf(GDKout, "#Ready to execute SQL statement\n");
#endif
@@ -1991,7 +1989,9 @@ cleanup_engine:
}
mb= c->curprg->def;
- if (be->q && mb &&
+ if (be->q && msg) {
+ qc_delete(m->qc, be->q);
+ } else if (be->q && mb &&
varGetProp(mb, getArg(p = getInstrPtr(mb,0), 0), runonceProp)){
SQLCacheRemove(c, getFunctionId(p));
/* this should invalidate any match */
diff --git a/sql/test/BugTracker-2013/PSMcreate_user.sql
b/sql/test/BugTracker-2013/PSMcreate_user.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2013/PSMcreate_user.sql
@@ -0,0 +1,1 @@
+CREATE USER "psm" WITH PASSWORD 'psm' NAME 'PSM' SCHEMA "sys";
diff --git a/sql/test/BugTracker-2013/PSMdrop_user.sql
b/sql/test/BugTracker-2013/PSMdrop_user.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2013/PSMdrop_user.sql
@@ -0,0 +1,1 @@
+DROP USER "psm";
diff --git a/sql/test/BugTracker-2013/PSMexplain_function.sql
b/sql/test/BugTracker-2013/PSMexplain_function.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2013/PSMexplain_function.sql
@@ -0,0 +1,3 @@
+explain select * from storagemodel();
+select * from storagemodel();
+select * from storagemodel();
diff --git a/sql/test/BugTracker-2013/Tests/All
b/sql/test/BugTracker-2013/Tests/All
--- a/sql/test/BugTracker-2013/Tests/All
+++ b/sql/test/BugTracker-2013/Tests/All
@@ -20,3 +20,4 @@ db_users.Bug-3287
create_table_with_func.Bug-3286
add_boolean.Bug-3289
prepare-smallint.Bug-3297
+psm_functions_and_accessrights.Bug-3300
diff --git
a/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.SQL.py
b/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.SQL.py
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.SQL.py
@@ -0,0 +1,20 @@
+import os, sys
+try:
+ from MonetDBtesting import process
+except ImportError:
+ import process
+
+d = os.environ['RELSRCDIR']
+
+def client(file, user, passwd):
+ sys.stdout.flush()
+ sys.stderr.flush()
+ c = process.client(lang = 'sql',
+ user = user, passwd = passwd,
+ args = [os.path.join(d, os.pardir, file)],
+ log = True)
+ c.communicate()
+
+client('PSMcreate_user.sql', 'monetdb', 'monetdb')
+client('PSMexplain_function.sql', 'psm', 'psm')
+client('PSMdrop_user.sql', 'monetdb', 'monetdb')
diff --git
a/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.err
b/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.err
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.err
@@ -0,0 +1,59 @@
+stderr of test 'psm_functions_and_accessrights.Bug-3300` in directory
'sql/test/BugTracker-2013` itself:
+
+
+# 18:51:03 >
+# 18:51:03 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=37031" "--set"
"mapi_usock=/var/tmp/mtest-6005/.s.monetdb.37031" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2013"
"--set" "mal_listing=0"
+# 18:51:03 >
+
+# 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 = 37031
+# cmdline opt mapi_usock = /var/tmp/mtest-6005/.s.monetdb.37031
+# 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_BugTracker-2013
+# cmdline opt mal_listing = 0
+
+# 18:51:03 >
+# 18:51:03 > "/usr/bin/python2"
"psm_functions_and_accessrights.Bug-3300.SQL.py"
"psm_functions_and_accessrights.Bug-3300"
+# 18:51:03 >
+
+
+# 18:51:03 >
+# 18:51:03 > Mtimeout -timeout 60 mclient -lsql -ftest -Eutf-8 -e
--host=/var/tmp/mtest-6005 --port=37031
--database=mTests_sql_test_BugTracker-2013
../../../../../../../data/rc/clean/sql/test/BugTracker-2013/Tests/../PSMcreate_user.sql
+# 18:51:03 >
+
+
+# 18:51:04 >
+# 18:51:04 > Mtimeout -timeout 60 mclient -lsql -ftest -Eutf-8 -e
--host=/var/tmp/mtest-6005 --port=37031
--database=mTests_sql_test_BugTracker-2013
../../../../../../../data/rc/clean/sql/test/BugTracker-2013/Tests/../PSMexplain_function.sql
+# 18:51:04 >
+
+MAPI = (psm) /var/tmp/mtest-6005/.s.monetdb.37031
+QUERY = explain select * from storagemodel();
+ERROR = !SELECT: access denied for psm to table 'sys.storagemodelinput'
+MAPI = (psm) /var/tmp/mtest-6005/.s.monetdb.37031
+QUERY = select * from storagemodel();
+ERROR = !SELECT: access denied for psm to table 'sys.storagemodelinput'
+MAPI = (psm) /var/tmp/mtest-6005/.s.monetdb.37031
+QUERY = select * from storagemodel();
+ERROR = !SELECT: access denied for psm to table 'sys.storagemodelinput'
+
+# 18:51:04 >
+# 18:51:04 > Mtimeout -timeout 60 mclient -lsql -ftest -Eutf-8 -e
--host=/var/tmp/mtest-6005 --port=37031
--database=mTests_sql_test_BugTracker-2013
../../../../../../../data/rc/clean/sql/test/BugTracker-2013/Tests/../PSMdrop_user.sql
+# 18:51:04 >
+
+
+# 18:51:04 >
+# 18:51:04 > "Done."
+# 18:51:04 >
+
diff --git
a/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.out
b/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.out
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2013/Tests/psm_functions_and_accessrights.Bug-3300.stable.out
@@ -0,0 +1,49 @@
+stdout of test 'psm_functions_and_accessrights.Bug-3300` in directory
'sql/test/BugTracker-2013` itself:
+
+
+# 18:51:03 >
+# 18:51:03 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=37031" "--set"
"mapi_usock=/var/tmp/mtest-6005/.s.monetdb.37031" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2013"
"--set" "mal_listing=0"
+# 18:51:03 >
+
+# MonetDB 5 server v11.15.4
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2013', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically
linked
+# Found 3.777 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:37031/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-6005/.s.monetdb.37031
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 18:51:03 >
+# 18:51:03 > "/usr/bin/python2"
"psm_functions_and_accessrights.Bug-3300.SQL.py"
"psm_functions_and_accessrights.Bug-3300"
+# 18:51:03 >
+
+
+# 18:51:03 >
+# 18:51:03 > Mtimeout -timeout 60 mclient -lsql -ftest -Eutf-8 -e
--host=/var/tmp/mtest-6005 --port=37031
--database=mTests_sql_test_BugTracker-2013
../../../../../../../data/rc/clean/sql/test/BugTracker-2013/Tests/../PSMcreate_user.sql
+# 18:51:03 >
+
+#CREATE USER "psm" WITH PASSWORD 'psm' NAME 'PSM' SCHEMA "sys";
+
+# 18:51:04 >
+# 18:51:04 > Mtimeout -timeout 60 mclient -lsql -ftest -Eutf-8 -e
--host=/var/tmp/mtest-6005 --port=37031
--database=mTests_sql_test_BugTracker-2013
../../../../../../../data/rc/clean/sql/test/BugTracker-2013/Tests/../PSMexplain_function.sql
+# 18:51:04 >
+
+
+# 18:51:04 >
+# 18:51:04 > Mtimeout -timeout 60 mclient -lsql -ftest -Eutf-8 -e
--host=/var/tmp/mtest-6005 --port=37031
--database=mTests_sql_test_BugTracker-2013
../../../../../../../data/rc/clean/sql/test/BugTracker-2013/Tests/../PSMdrop_user.sql
+# 18:51:04 >
+
+#DROP USER "psm";
+
+# 18:51:04 >
+# 18:51:04 > "Done."
+# 18:51:04 >
+
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list