Changeset: 5545c3e41089 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5545c3e41089
Added Files:
        sql/backends/monet5/Tests/cquery06.sql
        sql/backends/monet5/Tests/cquery07.sql
        sql/backends/monet5/Tests/cquery08.sql
Modified Files:
        sql/backends/monet5/Tests/All
        sql/backends/monet5/Tests/cqstream00.sql
        sql/backends/monet5/Tests/cqstream01.sql
        sql/backends/monet5/Tests/cqstream02.sql
        sql/backends/monet5/Tests/cqstream03.sql
        sql/backends/monet5/Tests/cquery00.stable.err
        sql/backends/monet5/Tests/cquery05.sql
        sql/backends/monet5/Tests/cquery10.sql
        sql/backends/monet5/sql_cquery.c
        sql/scripts/50_cquery.sql
        sql/server/rel_schema.c
        sql/server/sql_parser.y
        sql/server/sql_scan.c
Branch: trails
Log Message:

Added new tests plus fixed grammar for the server startup


diffs (truncated from 442 to 300 lines):

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
@@ -82,8 +82,13 @@ basket00
 epoch
 
 # use the continuous primitives
+cqcreate
+
 cquery00
 cquery05
+cquery06
+cquery07
+cquery08
 cquery10
 cquery20
 
diff --git a/sql/backends/monet5/Tests/cqstream00.sql 
b/sql/backends/monet5/Tests/cqstream00.sql
--- a/sql/backends/monet5/Tests/cqstream00.sql
+++ b/sql/backends/monet5/Tests/cqstream00.sql
@@ -1,7 +1,7 @@
 -- Example of a stream splitter
 create stream table stmp2 (t timestamp, sensor integer, val decimal(8,2)) ;
 -- SET WINDOW 2 STRIDE 1
-call cquery.window('sys','stmp2',1); -- consume 1 tuple and tumble 1 from this 
stream
+call cquery."window"('sys','stmp2',1); -- consume 1 tuple and tumble 1 from 
this stream
 --select * from cquery.streams();
 
 insert into stmp2 values('2005-09-23 12:34:26.000',1,11.0);
diff --git a/sql/backends/monet5/Tests/cqstream01.sql 
b/sql/backends/monet5/Tests/cqstream01.sql
--- a/sql/backends/monet5/Tests/cqstream01.sql
+++ b/sql/backends/monet5/Tests/cqstream01.sql
@@ -12,7 +12,7 @@ create procedure cq_window()
 begin
        -- The window ensures a maximal number of tuples to consider
        -- Could be considered a property of the stream table
-    call cquery.window('sys','stmp2',2);
+    call cquery."window"('sys','stmp2',2);
     insert into result2 select * from stmp2 where val >12;
 end;
 
diff --git a/sql/backends/monet5/Tests/cqstream02.sql 
b/sql/backends/monet5/Tests/cqstream02.sql
--- a/sql/backends/monet5/Tests/cqstream02.sql
+++ b/sql/backends/monet5/Tests/cqstream02.sql
@@ -20,7 +20,7 @@ insert into stmp10 values('2005-09-23 12
 start continuous sys.cq_collector();
 
 -- Run the query a few times
-call cquery.cycles(3);
+call cquery."cycles"(3);
 
 call cquery.wait(1000);
 
diff --git a/sql/backends/monet5/Tests/cqstream03.sql 
b/sql/backends/monet5/Tests/cqstream03.sql
--- a/sql/backends/monet5/Tests/cqstream03.sql
+++ b/sql/backends/monet5/Tests/cqstream03.sql
@@ -4,7 +4,7 @@ create table agenda13(i integer, msg str
 
 -- The window determines the input size, it can not be overruled.
 -- which is overruled here by the hearbeat (order is important)
-call cquery.window('sys','tmp13',2);
+call cquery."window"('sys','tmp13',2);
 
 create procedure cq_agenda()
 begin
@@ -16,7 +16,7 @@ begin
     end if;
 end;
 start continuous sys.cq_agenda();
-call cquery.heartbeat('sys','cq_agenda',1000);
+call cquery."heartbeat"('sys','cq_agenda',1000);
 
 select * from cquery.status();
 
diff --git a/sql/backends/monet5/Tests/cquery00.stable.err 
b/sql/backends/monet5/Tests/cquery00.stable.err
--- a/sql/backends/monet5/Tests/cquery00.stable.err
+++ b/sql/backends/monet5/Tests/cquery00.stable.err
@@ -38,7 +38,7 @@ QUERY = # some simple MAL tests
         (tick:bat[:timestamp],mod:bat[:str],fcn:bat[:str], 
time:bat[:lng],error:bat[:str]) := cquery.log();
         
         io.print(tick,mod,fcn,time,error);
-ERROR = !SQLException:cquery.show:Continuous procedure unknown.query not 
accessible
+
 
 
 
diff --git a/sql/backends/monet5/Tests/cquery05.sql 
b/sql/backends/monet5/Tests/cquery05.sql
--- a/sql/backends/monet5/Tests/cquery05.sql
+++ b/sql/backends/monet5/Tests/cquery05.sql
@@ -9,7 +9,7 @@ end;
 
 start continuous sys.cq_basic();
 
-call cquery.heartbeat('sys','cq_basic',1000);
+call cquery."heartbeat"('sys','cq_basic',1000);
 
 call cquery.wait(2100);
 
diff --git a/sql/backends/monet5/Tests/cquery06.sql 
b/sql/backends/monet5/Tests/cquery06.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/cquery06.sql
@@ -0,0 +1,20 @@
+--test proper continuous query handling via the SQL parser
+create table cqresult06(i integer);
+
+create procedure cq_basic06()
+begin
+       insert into cqresult06 (select count(*) from cqresult06);
+end;
+
+pause continuous cq_basic06(); --error
+
+start continuous cq_basic06() WITH HEARTBEAT 1000; --1 second
+
+call cquery.wait(2100);
+
+pause continuous cq_basic06(); --it's ok
+
+stop continuous cq_basic06();
+
+drop procedure cq_basic06;
+drop table cqresult06;
diff --git a/sql/backends/monet5/Tests/cquery07.sql 
b/sql/backends/monet5/Tests/cquery07.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/cquery07.sql
@@ -0,0 +1,32 @@
+--test the server behavior of reproducing the same calls consecutively
+create table cqresult07(i integer);
+
+create procedure cq_basic07()
+begin
+       insert into cqresult07 (select count(*) from cqresult07);
+end;
+
+stop continuous cq_basic07(); --error
+
+start continuous cq_basic07() WITH HEARTBEAT 1000 CYCLES 300; --1 second
+
+call cquery.wait(2100);
+
+pause continuous cq_basic07(); --ok
+
+pause continuous cq_basic07(); --error
+
+resume continuous cq_basic07() WITH HEARTBEAT 2000 CYCLES 300; --ok
+
+resume continuous cq_basic07() WITH HEARTBEAT 2000 CYCLES 300; --error
+
+stop continuous cq_basic07(); --ok
+
+stop continuous cq_basic07(); --error
+
+pause continuous cq_basic07(); --error
+
+resume continuous cq_basic07() WITH HEARTBEAT 2000 CYCLES 300; --error
+
+drop procedure cq_basic07;
+drop table cqresult07;
diff --git a/sql/backends/monet5/Tests/cquery08.sql 
b/sql/backends/monet5/Tests/cquery08.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/cquery08.sql
@@ -0,0 +1,34 @@
+--only the monetdb user can invoke the all statements
+create table cqresult081(i integer);
+
+create procedure cq_basic081()
+begin
+       insert into cqresult081 VALUES (1);
+end;
+
+create table cqresult082(i integer);
+
+create procedure cq_basic082()
+begin
+       insert into cqresult082 VALUES (2);
+end;
+
+start continuous cq_basic081();
+
+start continuous cq_basic082();
+
+create user dummyme with password 'weak' name 'Just an user' schema sys;
+
+set session authorization dummyme;
+
+stop all continuous; --error
+
+reset session authorization;
+
+stop all continuous; --ok
+
+drop user dummyme;
+drop procedure cq_basic081;
+drop procedure cq_basic082;
+drop table cqresult081;
+drop table cqresult082;
diff --git a/sql/backends/monet5/Tests/cquery10.sql 
b/sql/backends/monet5/Tests/cquery10.sql
--- a/sql/backends/monet5/Tests/cquery10.sql
+++ b/sql/backends/monet5/Tests/cquery10.sql
@@ -11,10 +11,10 @@ end;
 start continuous sys.cq_cycles();
 
 -- The scheduler interval is 1 sec 
---call cquery.heartbeat('sys','cq_cycles',1000);
+--call cquery."heartbeat"('sys','cq_cycles',1000);
 
 -- The scheduler executes all CQ at most 5 rounds
-call cquery.cycles('sys','cq_cycles',3);
+call cquery."cycles"('sys','cq_cycles',3);
 
 -- reactivate all continuous queries
 
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
@@ -75,6 +75,7 @@ MT_Lock ttrLock MT_LOCK_INITIALIZER("cqu
 static void
 CQfree(int idx)
 {
+       int i;
        if( pnet[idx].mb)
                freeMalBlk(pnet[idx].mb);
        if( pnet[idx].stk)
@@ -82,10 +83,10 @@ CQfree(int idx)
        GDKfree(pnet[idx].mod);
        GDKfree(pnet[idx].fcn);
        GDKfree(pnet[idx].stmt);
-       for( ; idx<pnettop-1; idx++)
-               pnet[idx] = pnet[idx+1];
+       for(i=idx; i<pnettop-1; i++)
+               pnet[i] = pnet[i+1];
        pnettop--;
-       memset((void*) (pnet+idx), 0, sizeof(CQnode));
+       memset((void*) (pnet+pnettop), 0, sizeof(CQnode));
 }
 
 /* We need a lock table for all stream tables considered
@@ -700,15 +701,15 @@ CQresumeInternal(Client cntxt, MalBlkPtr
 {
        mvc* sqlcontext = ((backend *) cntxt->sqlcontext)->mvc;
        str msg = MAL_SUCCEED, mb2str = NULL;
-       int idx, cycles, heartbeats;
+       int idx = 0, cycles = int_nil, heartbeats = 1;
 
 #ifdef DEBUG_CQUERY
        fprintf(stderr, "#resume scheduler\n");
 #endif
 
-       if(with_alter) {
-               cycles = sqlcontext ? sqlcontext->cycles : int_nil;
-               heartbeats = sqlcontext ? sqlcontext->heartbeats : 1;
+       if(with_alter && sqlcontext) {
+               cycles = sqlcontext->cycles;
+               heartbeats = sqlcontext->heartbeats;
                if(cycles < 0 && cycles != int_nil){
                        msg = createException(SQL,"cquery.resume","The cycles 
value must be non negative\n");
                        goto finish;
@@ -828,7 +829,7 @@ CQresumeAll(Client cntxt, MalBlkPtr mb, 
 static str
 CQpauseInternal(MalBlkPtr mb)
 {
-       int idx;
+       int idx = 0;
        str msg = MAL_SUCCEED, mb2str = NULL;
 
        MT_lock_set(&ttrLock);
@@ -1017,7 +1018,7 @@ CQwait(Client cntxt, MalBlkPtr mb, MalSt
 static str
 CQderegisterInternal(MalBlkPtr mb)
 {
-       int idx;
+       int idx = 0;
        str msg = MAL_SUCCEED, mb2str = NULL;
 
        MT_lock_set(&ttrLock);
diff --git a/sql/scripts/50_cquery.sql b/sql/scripts/50_cquery.sql
--- a/sql/scripts/50_cquery.sql
+++ b/sql/scripts/50_cquery.sql
@@ -26,26 +26,26 @@ create procedure cquery.wait(ms bigint)
        external name cquery.wait;
 
 -- Limit the number of iterations of a CQ
-create procedure cquery.cycles(cycles integer)
-       external name cquery.cycles;
-create procedure cquery.cycles(sch string, cqname string, cycles integer)
-       external name cquery.cycles;
+create procedure cquery."cycles"(cqcycles integer)
+       external name cquery."cycles";
+create procedure cquery."cycles"("schema" string, cqname string, cqcycles 
integer)
+       external name cquery."cycles";
 
 -- set the scheduler heartbeat 
-create procedure cquery.heartbeat("schema" string, qryname string, msec 
integer)
-       external name cquery.heartbeat;
-create procedure cquery.heartbeat(msec integer)
-       external name cquery.heartbeat;
+create procedure cquery."heartbeat"("schema" string, cqname string, msec 
integer)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to