Changeset: 43db089e0431 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=43db089e0431
Modified Files:
        sql/backends/monet5/datacell/datacell.mx
        sql/backends/monet5/datacell/petrinet.mx
Branch: default
Log Message:

Adding the analysis wrappers
When a query is entered we should derive its input/output baskets.


diffs (118 lines):

diff --git a/sql/backends/monet5/datacell/datacell.mx 
b/sql/backends/monet5/datacell/datacell.mx
--- a/sql/backends/monet5/datacell/datacell.mx
+++ b/sql/backends/monet5/datacell/datacell.mx
@@ -192,20 +192,28 @@
 DCquery(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        str nme = *(str*) getArgReference(stk,pci,1);
-       str def = (str*) getArgReference(stk,pci,2);
+       str *def = (str*) getArgReference(stk,pci,2);
        Symbol s;
        str msg;
+       InstrPtr p;
+       Module scope;
 
        (void) mb;
        msg = SQLstatementIntern(cntxt, def, nme, 0, 0);
-       if ( msg )
-               return msg;
+       /* if ( msg )
+               return msg; */
+       scope = findModule(cntxt->nspace,putName("datacell",8));
        s = newFunction(putName("datacell",8), putName(nme, 
strlen(nme)),FUNCTIONsymbol);
+       if ( s == NULL) 
+               throw(SQL,"datacell.query","Procedure code does not exist");
     freeMalBlk(s->def);
     s->def = copyMalBlk(cntxt->curprg->def);
-       if ( s == NULL) 
-               throw(SQL,"datacell.query","Procedure code does not exist");
-       return MAL_SUCCEED;
+       p= getInstrPtr(s->def,0);
+       setModuleId(p, putName("datacell",8));
+       setFunctionId(p, putName(nme,strlen(nme)));
+    insertSymbol(scope,s);
+       PNanalysis(cntxt,s->def);
+       return msg;
 }
 
 /*
diff --git a/sql/backends/monet5/datacell/petrinet.mx 
b/sql/backends/monet5/datacell/petrinet.mx
--- a/sql/backends/monet5/datacell/petrinet.mx
+++ b/sql/backends/monet5/datacell/petrinet.mx
@@ -54,6 +54,9 @@
 address PNstopScheduler
 comment "Stop the Petri net controller";
 
+pattern analyse(mod:str, fcn:str)
+address PNanalyseWrapper
+comment "Check the input/output relationship";
 command dump()
 address PNdump
 comment "Show the status of the Petri net";
@@ -89,6 +92,8 @@
 datacell_export str PNdump(int *ret);
 datacell_export str PNsource(int *ret, str *mod, str *fcn, str *schema, str 
*tbl);
 datacell_export str PNtarget(int *ret, str *mod, str *fcn, str *schema, str 
*tbl);
+datacell_export void PNanalysis(Client cntxt, MalBlkPtr mb);
+datacell_export str PNanalyseWrapper(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
 #endif
 
 @c
@@ -137,6 +142,49 @@
 static int status = 0;
 static int cycleDelay = 1000; /* be careful, it affects response/throughput 
timings */
 
+/* check the routine for input/output relationships */
+void
+PNanalysis(Client cntxt, MalBlkPtr mb)
+{
+       int i, bskt;
+       InstrPtr p;
+       str schema, tbl;
+
+       for( i = 0; i < mb->stop; i++){
+               p= getInstrPtr(mb,i);
+               if ( getModuleId(p) == sqlRef){
+                       if ( getFunctionId(p) == bindRef && getVarConstant(mb, 
getArg(p, p->argc-1)).val.ival == 0){
+                               bskt = BSKTlocate( schema = 
getVarConstant(mb,getArg(p,2)).val.sval, tbl = 
getVarConstant(mb,getArg(p,3)).val.sval);
+                               if ( bskt == 0 )
+                                       mnstr_printf(cntxt->fdout,"#input 
basket %s.%s missing\n", schema,tbl);
+                       }
+                       if ( getFunctionId(p) == appendRef){
+                               bskt = BSKTlocate( schema = 
getVarConstant(mb,getArg(p,2)).val.sval, tbl = 
getVarConstant(mb,getArg(p,3)).val.sval);
+                               if ( bskt == 0 )
+                                       mnstr_printf(cntxt->fdout,"#output 
basket %s.%s missing\n", schema,tbl);
+                       }
+               }
+       }
+}
+str PNanalyseWrapper(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       Module scope;
+       Symbol s = 0;
+       str *modnme = (str *)getArgReference(stk, pci, 1);
+       str *fcnnme = (str *)getArgReference(stk, pci, 2);
+
+       (void) mb;
+       scope = findModule(cntxt->nspace, putName(*modnme, 
(int)strlen(*modnme)));
+       if (scope)
+               s = findSymbolInModule(scope, putName(*fcnnme, 
(int)strlen(*fcnnme)));
+       if (s == NULL)
+               throw(MAL, "petrinet.analysis", "Could not find function");
+
+       PNanalysis(cntxt,s->def);
+
+       return MAL_SUCCEED;
+}
+
 str PNregistration(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        Module scope;
@@ -148,7 +196,6 @@
        (void)mb;
 
        scope = findModule(cntxt->nspace, putName(*modnme, 
(int)strlen(*modnme)));
-
        if (scope)
                s = findSymbolInModule(scope, putName(*fcnnme, 
(int)strlen(*fcnnme)));
 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to