Changeset: c1d4f1698902 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c1d4f1698902 Added Files: sql/backends/monet5/Tests/cquery09.sql sql/backends/monet5/Tests/cquery09.stable.err sql/backends/monet5/Tests/cquery09.stable.out Modified Files: monetdb5/optimizer/opt_cquery.c sql/backends/monet5/Tests/All sql/backends/monet5/sql_basket.c sql/backends/monet5/sql_basket.h sql/backends/monet5/sql_cat.c sql/backends/monet5/sql_cquery.c sql/backends/monet5/sql_cquery.h sql/server/rel_schema.c Branch: trails Log Message:
Added constraints in the SQL catalog for dropping and altering stream tables. A streaming table can only be dropped when there are no continuous queries running on it. Cannot add or drop columns to a stream table because of linking issues that I am checking. diffs (truncated from 821 to 300 lines): diff --git a/monetdb5/optimizer/opt_cquery.c b/monetdb5/optimizer/opt_cquery.c --- a/monetdb5/optimizer/opt_cquery.c +++ b/monetdb5/optimizer/opt_cquery.c @@ -31,7 +31,7 @@ #include "mal_builder.h" #include "opt_dataflow.h" -#define MAXBSKT 64 +#define MAXBSKTOPT 128 #define getStreamTableInfo(S,T) \ for(fnd=0, k= 0; k< btop; k++) \ if( strcmp(schemas[k], S)== 0 && strcmp(tables[k], T)== 0 ){ \ @@ -46,10 +46,10 @@ OPTcqueryImplementation(Client cntxt, Ma int i, j, k, fnd, limit, slimit; InstrPtr r, p, *old; int *alias; - str schemas[MAXBSKT]; - str tables[MAXBSKT]; - int input[MAXBSKT]= {0}; - int output[MAXBSKT]= {0}; + str schemas[MAXBSKTOPT]; + str tables[MAXBSKTOPT]; + int input[MAXBSKTOPT]= {0}; + int output[MAXBSKTOPT]= {0}; int btop=0, lastmvc=0; int noerror=0; int mvcseen = 0; @@ -77,7 +77,7 @@ OPTcqueryImplementation(Client cntxt, Ma slimit = mb->ssize; /* first analyse the query for streaming tables */ - for (i = 1; i < limit && btop <MAXBSKT; i++){ + for (i = 1; i < limit && btop <MAXBSKTOPT; i++){ p = old[i]; if( getModuleId(p)== basketRef && (getFunctionId(p)== registerRef || getFunctionId(p)== bindRef ) ){ schemas[btop]= getVarConstant(mb, getArg(p,2)).val.sval; @@ -143,7 +143,7 @@ OPTcqueryImplementation(Client cntxt, Ma #ifdef DEBUG_OPT_CQUERY mnstr_printf(cntxt->fdout, "#cquery optimizer started with %d streams, mvc %d\n", btop,lastmvc); #endif - if( btop == MAXBSKT || btop == 0) + if( btop == MAXBSKTOPT || btop == 0) return MAL_SUCCEED; (void) stk; @@ -298,18 +298,18 @@ OPTcqueryImplementation(Client cntxt, Ma pushInstruction(mb, p); } - /* take the remainder as is */ - for (; i<limit; i++) - if (old[i]) - pushInstruction(mb,old[i]); + /* take the remainder as is */ + for (; i<limit; i++) + if (old[i]) + pushInstruction(mb,old[i]); - /* Defense line against incorrect plans */ + /* Defense line against incorrect plans */ chkTypes(cntxt->fdout, cntxt->nspace, mb, FALSE); chkFlow(cntxt->fdout, mb); chkDeclarations(cntxt->fdout, mb); - /* keep all actions taken as a post block comment */ - snprintf(buf,256,"%-20s actions=%2d time=" LLFMT " usec","cquery", btop, GDKusec() - usec); - newComment(mb,buf); + /* keep all actions taken as a post block comment */ + snprintf(buf,256,"%-20s actions=%2d time=" LLFMT " usec","cquery", btop, GDKusec() - usec); + newComment(mb,buf); #ifdef DEBUG_OPT_CQUERY mnstr_printf(cntxt->fdout, "#cquery optimizer final\n"); @@ -318,7 +318,7 @@ OPTcqueryImplementation(Client cntxt, Ma GDKfree(alias); GDKfree(old); - if( btop > 0) - return MAL_SUCCEED; + if( btop > 0) + return MAL_SUCCEED; throw (MAL,"optimizer.cquery", "The cquery optimizer failed to start! (btop = %d)", btop); } diff --git a/sql/backends/monet5/Tests/All b/sql/backends/monet5/Tests/All --- a/sql/backends/monet5/Tests/All +++ b/sql/backends/monet5/Tests/All @@ -89,9 +89,10 @@ cquery00 cquery05 cquery06 cquery07 +cquery08 +cquery09 cquery10 cquery20 -cquery08 cqstream00 cqstream01 diff --git a/sql/backends/monet5/Tests/cquery09.sql b/sql/backends/monet5/Tests/cquery09.sql new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/Tests/cquery09.sql @@ -0,0 +1,20 @@ +--cannot drop stream table while there are continuous queries referencing it +create stream table result9(i integer); + +create procedure cq_c(inputA int) +begin + insert into sys.result9 values (inputA); +end; + +start continuous sys.cq_c(1); + +call cquery.wait(4000); + +drop table result9; --error + +stop continuous sys.cq_c(2); --error + +stop continuous sys.cq_c(1); + +drop procedure cq_c; +drop table result9; --no error diff --git a/sql/backends/monet5/Tests/cquery09.stable.err b/sql/backends/monet5/Tests/cquery09.stable.err new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/Tests/cquery09.stable.err @@ -0,0 +1,40 @@ +stderr of test 'cquery09` in directory 'sql/backends/monet5` itself: + + +# 16:43:39 > +# 16:43:39 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=35695" "--set" "mapi_usock=/var/tmp/mtest-4922/.s.monetdb.35695" "--set" "monet_prompt=" "--forcemito" "--dbpath=/home/ferreira/MonetDB-trails/BUILD/var/MonetDB/mTests_sql_backends_monet5" +# 16:43:39 > + +# builtin opt gdk_dbpath = /home/ferreira/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 = 35695 +# cmdline opt mapi_usock = /var/tmp/mtest-4922/.s.monetdb.35695 +# cmdline opt monet_prompt = +# cmdline opt gdk_dbpath = /home/ferreira/MonetDB-trails/BUILD/var/MonetDB/mTests_sql_backends_monet5 +# cmdline opt gdk_debug = 536870922 + +# 16:43:39 > +# 16:43:39 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-4922" "--port=35695" +# 16:43:39 > + +MAPI = (monetdb) /var/tmp/mtest-4922/.s.monetdb.35695 +QUERY = drop table result9; --error +ERROR = !DROP TABLE: unable to drop stream table 'result9': there are pending continuous queries on it +MAPI = (monetdb) /var/tmp/mtest-4922/.s.monetdb.35695 +QUERY = stop continuous sys.cq_c(2); --error +ERROR = !The continuous procedure user.cq_c(2:int); has not yet started + +# 16:43:44 > +# 16:43:44 > "Done." +# 16:43:44 > + diff --git a/sql/backends/monet5/Tests/cquery09.stable.out b/sql/backends/monet5/Tests/cquery09.stable.out new file mode 100644 --- /dev/null +++ b/sql/backends/monet5/Tests/cquery09.stable.out @@ -0,0 +1,79 @@ +stdout of test 'cquery09` in directory 'sql/backends/monet5` itself: + + +# 16:43:39 > +# 16:43:39 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=35695" "--set" "mapi_usock=/var/tmp/mtest-4922/.s.monetdb.35695" "--set" "monet_prompt=" "--forcemito" "--dbpath=/home/ferreira/MonetDB-trails/BUILD/var/MonetDB/mTests_sql_backends_monet5" +# 16:43:39 > + +# 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.499 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-120.eduroam.cwi.nl:35695/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-4922/.s.monetdb.35695 +# MonetDB/GIS module loaded +# MonetDB/SQL module loaded +# MonetDB/Timetrails module loaded + +Ready. +# 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_functions.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: 50_cquery.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_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 + +# 16:43:39 > +# 16:43:39 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-4922" "--port=35695" +# 16:43:39 > + +#create stream table result9(i integer); +#create procedure cq_c(inputA int) +#begin +# insert into sys.result9 values (inputA); +#end; +#drop procedure cq_c; +#drop table result9; --no error + +# 16:43:44 > +# 16:43:44 > "Done." +# 16:43:44 > + diff --git a/sql/backends/monet5/sql_basket.c b/sql/backends/monet5/sql_basket.c --- a/sql/backends/monet5/sql_basket.c +++ b/sql/backends/monet5/sql_basket.c @@ -60,10 +60,10 @@ static int BSKTnewEntry(void) BasketRec *bnew; if (bsktTop + 1 == bsktLimit) { - bnew = (BasketRec *) GDKrealloc(baskets, (bsktLimit+MAXBSKT) * sizeof(BasketRec)); + bnew = (BasketRec *) GDKrealloc(baskets, (bsktLimit+INTIAL_BSKT) * sizeof(BasketRec)); if( bnew == 0) return 0; - bsktLimit += MAXBSKT; + bsktLimit += INTIAL_BSKT; baskets = bnew; } for (i = 1; i < bsktLimit; i++) { /* find an available slot */ @@ -78,11 +78,11 @@ static int BSKTnewEntry(void) } // free a basket structure -static void +void BSKTclean(int idx) { int i; - if( idx){ + if( idx && baskets[idx].table){ if(baskets[idx].error) GDKfree(baskets[idx].error); baskets[idx].table = NULL; @@ -104,7 +104,7 @@ BSKTclean(int idx) // MAL/SQL interface for registration of a single table str -BSKTregisterInternal(Client cntxt, MalBlkPtr mb, str sch, str tbl) +BSKTregisterInternal(Client cntxt, MalBlkPtr mb, str sch, str tbl, int* res) { sql_schema *s; sql_table *t; @@ -118,8 +118,11 @@ BSKTregisterInternal(Client cntxt, MalBl return msg; /* check double registration */ - if( BSKTlocate(sch, tbl) > 0) - return msg; + if( (idx = BSKTlocate(sch, tbl)) > 0) { + *res = idx; + return MAL_SUCCEED; + } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list