Changeset: a45918881894 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a45918881894 Added Files: sql/backends/monet5/Tests/cfunction03.stable.err sql/backends/monet5/Tests/cfunction03.stable.out Modified Files: sql/backends/monet5/Tests/cfunction01.sql sql/backends/monet5/Tests/cfunction01.stable.err sql/backends/monet5/Tests/cfunction01.stable.out sql/backends/monet5/Tests/cfunction02.sql sql/backends/monet5/Tests/cfunction03.sql sql/backends/monet5/sql_cquery.c sql/backends/monet5/sql_cquery.h sql/include/sql_catalog.h sql/server/sql_mvc.c sql/server/sql_mvc.h sql/storage/sql_catalog.c sql/storage/sql_storage.h sql/storage/store.c Branch: trails Log Message:
Create output tables in "cquery" schema and drop them when the scheduler starts. Still having race conditions dropping "cquery" tables while the server shuts down diffs (truncated from 912 to 300 lines): diff --git a/sql/backends/monet5/Tests/cfunction01.sql b/sql/backends/monet5/Tests/cfunction01.sql --- a/sql/backends/monet5/Tests/cfunction01.sql +++ b/sql/backends/monet5/Tests/cfunction01.sql @@ -14,19 +14,19 @@ begin return s; END; -select result from tmp.aggr01; #error +select result from cquery.aggr01; #error start continuous function aggr01(); call cquery.wait(1000); #wait to be started -select result from tmp.aggr01; #should be empty +select result from cquery.aggr01; #should be empty pause continuous aggr01; insert into ftmp values(1),(1); resume continuous aggr01; call cquery.wait(1000); #wait for processing -select result from tmp.aggr01; #should return 2 +select result from cquery.aggr01; #should return 2 pause continuous aggr01; insert into ftmp values(2),(2); @@ -34,10 +34,10 @@ insert into ftmp values(3),(3); resume continuous aggr01; call cquery.wait(1000); -select result from tmp.aggr01; #should return 2,4,6 +select result from cquery.aggr01; #should return 2,4,6 call cquery.wait(1000); -select result from tmp.aggr01; #should return 2,4,6 +select result from cquery.aggr01; #should return 2,4,6 stop continuous aggr01; drop function aggr01; diff --git a/sql/backends/monet5/Tests/cfunction01.stable.err b/sql/backends/monet5/Tests/cfunction01.stable.err --- a/sql/backends/monet5/Tests/cfunction01.stable.err +++ b/sql/backends/monet5/Tests/cfunction01.stable.err @@ -28,7 +28,7 @@ stderr of test 'cfunction01` in director # 16:27:02 > MAPI = (monetdb) /var/tmp/mtest-26476/.s.monetdb.32321 -QUERY = select result from tmp.aggr01; #error +QUERY = select result from cquery.aggr01; #error ERROR = !SELECT: no such table 'aggr01' CODE = 42S02 diff --git a/sql/backends/monet5/Tests/cfunction01.stable.out b/sql/backends/monet5/Tests/cfunction01.stable.out --- a/sql/backends/monet5/Tests/cfunction01.stable.out +++ b/sql/backends/monet5/Tests/cfunction01.stable.out @@ -80,8 +80,8 @@ Ready. # return s; #END; #start continuous function aggr01(); -#select result from tmp.aggr01; #should be empty -% tmp.aggr01 # table_name +#select result from cquery.aggr01; #should be empty +% cquery.aggr01 # table_name % result # name % int # type % 1 # length @@ -89,8 +89,8 @@ Ready. #insert into ftmp values(1),(1); [ 2 ] #resume continuous aggr01; -#select result from tmp.aggr01; #should return 2 -% tmp.aggr01 # table_name +#select result from cquery.aggr01; #should return 2 +% cquery.aggr01 # table_name % result # name % int # type % 1 # length @@ -101,16 +101,16 @@ Ready. #insert into ftmp values(3),(3); [ 2 ] #resume continuous aggr01; -#select result from tmp.aggr01; #should return 2,4,6 -% tmp.aggr01 # table_name +#select result from cquery.aggr01; #should return 2,4,6 +% cquery.aggr01 # table_name % result # name % int # type % 1 # length [ 2 ] [ 4 ] [ 6 ] -#select result from tmp.aggr01; #should return 2,4,6 -% tmp.aggr01 # table_name +#select result from cquery.aggr01; #should return 2,4,6 +% cquery.aggr01 # table_name % result # name % int # type % 1 # length diff --git a/sql/backends/monet5/Tests/cfunction02.sql b/sql/backends/monet5/Tests/cfunction02.sql --- a/sql/backends/monet5/Tests/cfunction02.sql +++ b/sql/backends/monet5/Tests/cfunction02.sql @@ -15,7 +15,7 @@ start continuous function cfunc2('test') pause continuous cfunc2; create procedure cproc2() begin - insert into results2 (select aa, bb from tmp.cfunc2); + insert into results2 (select aa, bb from cquery.cfunc2); end; start continuous procedure cproc2() with cycles 2; diff --git a/sql/backends/monet5/Tests/cfunction03.sql b/sql/backends/monet5/Tests/cfunction03.sql --- a/sql/backends/monet5/Tests/cfunction03.sql +++ b/sql/backends/monet5/Tests/cfunction03.sql @@ -8,7 +8,7 @@ create function cfunc3(input time) retur end while; end; -start continuous function cfunc3(time '15:00:00') with heartbeat 1000 cycles 3; +start continuous function cfunc3(time '15:00:00') with heartbeat 100 cycles 3; call cquery.wait(2000); diff --git a/sql/backends/monet5/Tests/cfunction03.stable.err b/sql/backends/monet5/Tests/cfunction03.stable.err new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/Tests/cfunction03.stable.err @@ -0,0 +1,34 @@ +stderr of test 'cfunction03` in directory 'sql/backends/monet5` itself: + + +# 11:35:56 > +# 11:35:56 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=31963" "--set" "mapi_usock=/var/tmp/mtest-28584/.s.monetdb.31963" "--set" "monet_prompt=" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-trails/BUILD/var/MonetDB/mTests_sql_backends_monet5" +# 11:35:56 > + +# builtin opt gdk_dbpath = /home/ferreira/repositories/MonetDB-trails/BUILD/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 = 31963 +# cmdline opt mapi_usock = /var/tmp/mtest-28584/.s.monetdb.31963 +# cmdline opt monet_prompt = +# cmdline opt gdk_dbpath = /home/ferreira/repositories/MonetDB-trails/BUILD/var/MonetDB/mTests_sql_backends_monet5 +# cmdline opt gdk_debug = 536870922 + +# 11:35:56 > +# 11:35:56 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-28584" "--port=31963" +# 11:35:56 > + + +# 11:35:58 > +# 11:35:58 > "Done." +# 11:35:58 > + diff --git a/sql/backends/monet5/Tests/cfunction03.stable.out b/sql/backends/monet5/Tests/cfunction03.stable.out new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/Tests/cfunction03.stable.out @@ -0,0 +1,48 @@ +stdout of test 'cfunction03` in directory 'sql/backends/monet5` itself: + + +# 11:35:56 > +# 11:35:56 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=31963" "--set" "mapi_usock=/var/tmp/mtest-28584/.s.monetdb.31963" "--set" "monet_prompt=" "--forcemito" "--dbpath=/home/ferreira/repositories/MonetDB-trails/BUILD/var/MonetDB/mTests_sql_backends_monet5" +# 11:35:56 > + +# MonetDB 5 server v11.28.0 +# This is an unreleased version +# Serving database 'mTests_sql_backends_monet5', using 8 threads +# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers +# Found 15.498 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://dhcp-170.eduroam.cwi.nl:31963/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-28584/.s.monetdb.31963 +# MonetDB/GIS module loaded +# MonetDB/SQL module loaded +# MonetDB/Timetrails module loaded + +Ready. + +# 11:35:56 > +# 11:35:56 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-28584" "--port=31963" +# 11:35:56 > + +#create table results3 (aa time); +#create function cfunc3(input time) returns table (aa time) begin +# while true do +# insert into results3 values (input); +# yield table (select input); +# end while; +#end; +#start continuous function cfunc3(time '15:00:00') with heartbeat 100 cycles 3; +#select count(*) from results3; +% sys.L4 # table_name +% L3 # name +% bigint # type +% 1 # length +[ 3 ] +#drop function cfunc3; +#drop table results3; + +# 11:35:58 > +# 11:35:58 > "Done." +# 11:35:58 > + diff --git a/sql/backends/monet5/sql_cquery.c b/sql/backends/monet5/sql_cquery.c --- a/sql/backends/monet5/sql_cquery.c +++ b/sql/backends/monet5/sql_cquery.c @@ -54,7 +54,7 @@ #include "mtime.h" #include "../../../monetdb5/mal/mal_client.h" -static const str statusname[8] = {"init", "paused", "running", "pausing", "error", "stopping", "stopping", "stopping"}; +static const str statusname[8] = {"starting", "paused", "running", "pausing", "error", "stopping", "stopping", "stopping"}; static str CQstartScheduler(void); static int pnstatus = CQINIT; @@ -113,15 +113,19 @@ CQfree(Client cntxt, int idx) //Always c { int i; InstrPtr p; + sql_schema *s = NULL; + sql_table *t = NULL; //clean the baskets if so cleanBaskets(idx); if(cntxt && pnet[idx].func->res) { backend* be = (backend*) cntxt->sqlcontext; mvc *m = be->mvc; - sql_schema *s = mvc_bind_schema(m, "tmp"); - sql_table *t = mvc_bind_table(m, s, pnet[idx].alias); - mvc_drop_table(m, s, t, 0); + s = mvc_bind_schema(m, "cquery"); + if(s) + t = mvc_bind_table(m, s, pnet[idx].alias); + if(s && t) + mvc_drop_table(m, s, t, 0); } if( pnet[idx].mb) { p = getInstrPtr(pnet[idx].mb, 0); @@ -341,7 +345,7 @@ finish: /* Make sure we do not re-use the same source more than once */ /* Avoid any concurrency conflict */ static str -CQanalysis(Client cntxt, MalBlkPtr mb, int idx, sql_func* func, str alias) +CQanalysis(Client cntxt, MalBlkPtr mb, int idx) { int i, j, bskt, binout; InstrPtr p; @@ -378,15 +382,6 @@ CQanalysis(Client cntxt, MalBlkPtr mb, i pnet[idx].inout[j] = binout == 0 ? STREAM_IN : STREAM_OUT; } } - if(func->res && msg == MAL_SUCCEED) { //register the output stream into the baskets - for( j=0; j< MAXSTREAMS && pnet[idx].baskets[j]; j++); - if ( j == MAXSTREAMS){ - msg = createException(MAL,"cquery.analysis",SQLSTATE(3F000) "Too many stream table columns\n"); - } else if((msg = BSKTregisterInternal(cntxt,mb,"tmp",alias,&bskt)) == MAL_SUCCEED) { - pnet[idx].baskets[j] = bskt; - pnet[idx].inout[j] = CQ_OUT; - } - } return msg; } @@ -417,8 +412,7 @@ CQregister(Client cntxt, str sname, str int i, idx, varid, freeMB = 0, mvc_var = 0; backend* be = (backend*) cntxt->sqlcontext; mvc *m = be->mvc; - sql_schema *s = NULL, *tmp_schema = NULL; - sql_table *t = NULL; + sql_schema *s = NULL; sql_subfunc *f = NULL; sql_func* found = NULL; list *l; @@ -466,6 +460,7 @@ CQregister(Client cntxt, str sname, str msg = createException(SQL,"cquery.register",SQLSTATE(3F000) "Failed to bind %s %s.%s\n", err_message, rschema, fname); FREE_CQ_MB(finish) } + found = f->func; if((l = list_create(NULL)) == NULL) { CQ_MALLOC_FAIL(finish) } @@ -496,40 +491,13 @@ CQregister(Client cntxt, str sname, str if(!ralias) { CQ_MALLOC_FAIL(finish) } - - found = f->func; - if(found->res) { //for functions we have to store the results in an output result table - if((tmp_schema = mvc_bind_schema(m, "tmp")) == NULL) { - msg = createException(SQL,"cquery.register",SQLSTATE(3F000) "Failed to bind tmp schema\n"); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list