Changeset: ae0d2c80bbcf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ae0d2c80bbcf
Modified Files:
        monetdb5/mal/mal_factory.c
        monetdb5/mal/mal_module.c
        monetdb5/optimizer/opt_cquery.c
        monetdb5/optimizer/opt_pipes.c
        monetdb5/optimizer/opt_wrapper.c
        sql/backends/monet5/sql_optimizer.c
Branch: trails
Log Message:

Fixed some memory in timetrails


diffs (195 lines):

diff --git a/monetdb5/mal/mal_factory.c b/monetdb5/mal/mal_factory.c
--- a/monetdb5/mal/mal_factory.c
+++ b/monetdb5/mal/mal_factory.c
@@ -389,7 +389,7 @@ void mal_factory_reset(void)
                        /* we are inside the body of the factory and about to 
return */
                        if (pl->stk) {
                                pl->stk->keepAlive = FALSE;
-                               garbageCollector(NULL, pl->factory, pl->stk, 
TRUE);
+                               //garbageCollector(NULL, pl->factory, pl->stk, 
TRUE); /* this will be freed by the freeModule call */
                                GDKfree(pl->stk);
                        }
                        pl->factory = 0;
diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c
--- a/monetdb5/mal/mal_module.c
+++ b/monetdb5/mal/mal_module.c
@@ -257,7 +257,7 @@ void freeModule(Module m)
                }
        }
 #ifdef _DEBUG_MODULE_
-       fprintf(stderr,"#freeModue %s \n", m->name);
+       fprintf(stderr,"#freeModule %s \n", m->name);
 #endif
        freeSubScope(m);        
        if (strcmp(m->name, "user")) {
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
@@ -43,7 +43,7 @@
 str
 OPTcqueryImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci)
 {
-       int i, j, k, fnd, limit, slimit;
+       int i, j, k, fnd, limit, slimit, extra_stmts = 0;
        InstrPtr r, p, *old;
        int *alias;
        str schemas[MAXBSKTOPT];
@@ -134,11 +134,21 @@ OPTcqueryImplementation(Client cntxt, Ma
                }
                if( getModuleId(p)== sqlRef && getFunctionId(p) == appendRef )
                        lastmvc = getArg(p,0);
-               if (!cq && getModuleId(p) == sqlRef && getFunctionId(p) == 
affectedRowsRef )
+               if( !cq && getModuleId(p) == sqlRef && getFunctionId(p) == 
affectedRowsRef )
                        lastmvc = getArg(p,0);
-               if( getModuleId(p)== cqueryRef && getFunctionId(p) == 
tumbleRef){
+               if( getModuleId(p)== cqueryRef && getFunctionId(p) == tumbleRef 
)
                        lastmvc = getArg(p,1);
+               /*if( getModuleId(p) == sqlRef && getFunctionId(p)== mvcRef ){
+                       if( mvcseen){
+                               extra_stmts++;
+                       }
+                       mvcseen=1;
+                       extra_stmts += 2;
                }
+               if( getModuleId(p)== cqueryRef && getFunctionId(p)==errorRef )
+                       noerror++;
+               if( p->token == ENDsymbol && btop > 0 && noerror==0 )
+                       extra_stmts += 2;*/
        }
 #ifdef DEBUG_OPT_CQUERY
        mnstr_printf(cntxt->fdout, "#cquery optimizer started with %d streams, 
mvc %d\n", btop,lastmvc);
@@ -152,10 +162,12 @@ OPTcqueryImplementation(Client cntxt, Ma
        if (alias == 0)
                return MAL_SUCCEED;
 
-       if (newMalBlkStmt(mb, slimit) < 0)
+       if (newMalBlkStmt(mb, slimit + extra_stmts) < 0)
                return MAL_SUCCEED;
 
        pushInstruction(mb, old[0]);
+       /*mvcseen = 0;
+       noerror = 0;*/
        for (i = 1; i < limit; i++)
                if (old[i]) {
                        p = old[i];
diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c
--- a/monetdb5/optimizer/opt_pipes.c
+++ b/monetdb5/optimizer/opt_pipes.c
@@ -228,18 +228,19 @@ static struct PIPELINES {
         "optimizer.constants();"
         "optimizer.commonTerms();"
         "optimizer.projectionpath();"
-       "optimizer.deadcode();"
-       "optimizer.reorder();"
+        "optimizer.deadcode();"
+        "optimizer.reorder();"
 //      "optimizer.reduce();" deprecated
-       "optimizer.matpack();"
-       "optimizer.dataflow();"
-       "optimizer.querylog();"
-       "optimizer.multiplex();"
-       "optimizer.generator();"
+        "optimizer.matpack();"
+        "optimizer.dataflow();"
+        "optimizer.querylog();"
+        "optimizer.multiplex();"
+        "optimizer.generator();"
         "optimizer.profiler();"
         "optimizer.candidates();"
 //      "optimizer.jit();" awaiting the new batcalc api
 //      "optimizer.oltp();"awaiting the autocommit front-end changes
+        "optimizer.wlc();"
         "optimizer.garbageCollector();",
         "stable", NULL, NULL, 1},
 
diff --git a/monetdb5/optimizer/opt_wrapper.c b/monetdb5/optimizer/opt_wrapper.c
--- a/monetdb5/optimizer/opt_wrapper.c
+++ b/monetdb5/optimizer/opt_wrapper.c
@@ -132,14 +132,19 @@ str OPTwrapper (Client cntxt, MalBlkPtr 
                        fcnnme= getArgDefault(mb,p,2);
                }
                removeInstruction(mb, p);
+               freeInstruction(p);
+               mb->stmt[mb->stop] = NULL;
                s= findSymbol(cntxt->usermodule, 
putName(modnme),putName(fcnnme));
 
                if( s == NULL) 
                        throw(MAL, optimizer, RUNTIME_OBJECT_UNDEFINED 
":%s.%s", modnme, fcnnme);
                mb = s->def;
                stk= 0;
-       } else if( p ) 
+       } else if( p ) {
                removeInstruction(mb, p);
+               freeInstruction(p);
+               mb->stmt[mb->stop] = NULL;
+       }
 
        for (i=0; codes[i].nme; i++)
                if (strcmp(codes[i].nme, optimizer) == 0){
diff --git a/sql/backends/monet5/sql_optimizer.c 
b/sql/backends/monet5/sql_optimizer.c
--- a/sql/backends/monet5/sql_optimizer.c
+++ b/sql/backends/monet5/sql_optimizer.c
@@ -80,37 +80,37 @@ SQLgetSpace(mvc *m, MalBlkPtr mb, int pr
 
        for (i = 0; i < mb->stop; i++) {
                InstrPtr p = mb->stmt[i];
-        char *f = getFunctionId(p);
+               char *f = getFunctionId(p);
 
-        if (getModuleId(p) == sqlRef && strcmp(f,"clear_table")==0){
-            char *sname = getVarConstant(mb, getArg(p, 1 )).val.sval;
-            char *tname = getVarConstant(mb, getArg(p, 2 )).val.sval;
-            sql_schema *s = mvc_bind_schema(m, sname);
-            sql_table *t;
+               if (getModuleId(p) == sqlRef && strcmp(f,"clear_table")==0){
+                       char *sname = getVarConstant(mb, getArg(p, 1 
)).val.sval;
+                       char *tname = getVarConstant(mb, getArg(p, 2 
)).val.sval;
+                       sql_schema *s = mvc_bind_schema(m, sname);
+                       sql_table *t;
 
-            if( ! s ) continue;
-            t = mvc_bind_table(m, s, tname);
-            if (t && isStream(t)) {
-                setModuleId(p, basketRef);
+                       if( ! s ) continue;
+                       t = mvc_bind_table(m, s, tname);
+                       if (t && isStream(t)) {
+                               setModuleId(p, basketRef);
                                *alterpipe= "cquery_pipe";
-                continue;
-            }
-        }
+                               continue;
+                       }
+               }
 
-        if (getModuleId(p) == sqlRef && (f == appendRef || f == updateRef || f 
== deleteRef )) {
-            char *sname = getVarConstant(mb, getArg(p, 2 )).val.sval;
-            char *tname = getVarConstant(mb, getArg(p, 3 )).val.sval;
-            sql_schema *s = mvc_bind_schema(m, sname);
-            sql_table *t;
+               if (getModuleId(p) == sqlRef && (f == appendRef || f == 
updateRef || f == deleteRef )) {
+                       char *sname = getVarConstant(mb, getArg(p, 2 
)).val.sval;
+                       char *tname = getVarConstant(mb, getArg(p, 3 
)).val.sval;
+                       sql_schema *s = mvc_bind_schema(m, sname);
+                       sql_table *t;
 
-            if( ! s ) continue;
-            t = mvc_bind_table(m, s, tname);
-            if (t && isStream(t)) {
-                setModuleId(p, basketRef);
-                *alterpipe= "cquery_pipe";
-                continue;
-            }
-        }
+                       if( ! s ) continue;
+                       t = mvc_bind_table(m, s, tname);
+                       if (t && isStream(t)) {
+                               setModuleId(p, basketRef);
+                               *alterpipe= "cquery_pipe";
+                               continue;
+                       }
+               }
 
                /* now deal with the update binds, it is only necessary to 
identify that there are updats
                 * The actual size is not that important */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to