Changeset: de1cbb7275ca for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/de1cbb7275ca
Modified Files:
        monetdb5/optimizer/opt_dict.c
        monetdb5/optimizer/opt_for.c
        sql/backends/monet5/for.c
        sql/storage/store.c
Branch: default
Log Message:

fixing leaks


diffs (202 lines):

diff --git a/monetdb5/optimizer/opt_dict.c b/monetdb5/optimizer/opt_dict.c
--- a/monetdb5/optimizer/opt_dict.c
+++ b/monetdb5/optimizer/opt_dict.c
@@ -71,6 +71,7 @@ OPTdictImplementation(Client cntxt, MalB
                        varisdict[k] = getArg(p,1);
                        vardictvalue[k] = getArg(p, 2);
                        dictunique[k] = 1;
+                       freeInstruction(p);
                        continue;
                }
                int done = 0;
@@ -90,6 +91,7 @@ OPTdictImplementation(Client cntxt, MalB
                                        vardictvalue[l] = vardictvalue[k];
                                        dictunique[l] = dictunique[k];
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if (p->argc == 2 && p->retc == 1 && 
getFunctionId(p) == NULL) {
@@ -98,6 +100,7 @@ OPTdictImplementation(Client cntxt, MalB
                                        varisdict[l] = varisdict[k];
                                        vardictvalue[l] = vardictvalue[k];
                                        dictunique[l] = dictunique[k];
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if (getModuleId(p) == algebraRef && 
getFunctionId(p) == subsliceRef) {
@@ -106,6 +109,7 @@ OPTdictImplementation(Client cntxt, MalB
                                        InstrPtr r = copyInstruction(p);
                                        getArg(r, j) = varisdict[k];
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if (getModuleId(p) == batRef && 
getFunctionId(p) == mirrorRef) {
@@ -114,6 +118,7 @@ OPTdictImplementation(Client cntxt, MalB
                                        InstrPtr r = copyInstruction(p);
                                        getArg(r, j) = varisdict[k];
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if (isSelect(p)) {
@@ -173,6 +178,7 @@ OPTdictImplementation(Client cntxt, MalB
                                                t = pushNil(mb, t, TYPE_lng); 
/* estimate */
                                                pushInstruction(mb,t);
                                        }
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if (j == 2 && p->argc > j+1 && 
getModuleId(p) == algebraRef && getFunctionId(p) == joinRef
@@ -186,6 +192,7 @@ OPTdictImplementation(Client cntxt, MalB
                                        getArg(r, j+0) = varisdict[k];
                                        getArg(r, j+1) = varisdict[l];
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if (j == 2 && p->argc > j+1 && 
getModuleId(p) == algebraRef && getFunctionId(p) == joinRef
@@ -207,6 +214,7 @@ OPTdictImplementation(Client cntxt, MalB
                                        r = addArgument(mb, r, getArg(p, 6));
                                        r = addArgument(mb, r, getArg(p, 7));
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if ((isMapOp(p) || isMap2Op(p)) && 
allConstExcept(mb, p, j)) {
@@ -224,6 +232,7 @@ OPTdictImplementation(Client cntxt, MalB
                                        vardictvalue[l] = vardictvalue[m] = 
getArg(r,0);
                                        dictunique[l] = 0;
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if (getModuleId(p) == groupRef &&
@@ -256,6 +265,7 @@ OPTdictImplementation(Client cntxt, MalB
                                        InstrPtr r = copyInstruction(p);
                                        getArg(r, j) = input;
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else {
@@ -280,7 +290,7 @@ OPTdictImplementation(Client cntxt, MalB
 
        for(; i<slimit; i++)
                if (old[i])
-                       pushInstruction(mb, old[i]);
+                       freeInstruction(old[i]);
        /* Defense line against incorrect plans */
        if (actions > 0){
                msg = chkTypes(cntxt->usermodule, mb, FALSE);
diff --git a/monetdb5/optimizer/opt_for.c b/monetdb5/optimizer/opt_for.c
--- a/monetdb5/optimizer/opt_for.c
+++ b/monetdb5/optimizer/opt_for.c
@@ -69,6 +69,7 @@ OPTforImplementation(Client cntxt, MalBl
                        k =  getArg(p,0);
                        varisfor[k] = getArg(p,1);
                        varforvalue[k] = getArg(p, 2);
+                       freeInstruction(p);
                        continue;
                }
                int done = 0;
@@ -87,6 +88,7 @@ OPTforImplementation(Client cntxt, MalBl
                                        varisfor[l] = getArg(r,0);
                                        varforvalue[l] = varforvalue[k];
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if (p->argc == 2 && p->retc == 1 && 
getFunctionId(p) == NULL) {
@@ -94,6 +96,7 @@ OPTforImplementation(Client cntxt, MalBl
                                        int l = getArg(p, 0);
                                        varisfor[l] = varisfor[k];
                                        varforvalue[l] = varforvalue[k];
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if (getModuleId(p) == algebraRef && 
getFunctionId(p) == subsliceRef) {
@@ -102,6 +105,7 @@ OPTforImplementation(Client cntxt, MalBl
                                        InstrPtr r = copyInstruction(p);
                                        getArg(r, j) = varisfor[k];
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else// if (isSelect(p)) {
@@ -181,6 +185,7 @@ OPTforImplementation(Client cntxt, MalBl
                                                pushInstruction(mb,t);
                                        }
 #endif
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if ((isMapOp(p) || isMap2Op(p)) && 
(getFunctionId(p) == plusRef || getFunctionId(p) == minusRef)  && 
allConstExcept(mb, p, j)) {
@@ -200,6 +205,7 @@ OPTforImplementation(Client cntxt, MalBl
                                        varisfor[l] = varisfor[m] = varisfor[k];
                                        varforvalue[l] = varforvalue[m] = 
getArg(r,0);
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else if (getModuleId(p) == groupRef &&
@@ -211,6 +217,7 @@ OPTforImplementation(Client cntxt, MalBl
                                        InstrPtr r = copyInstruction(p);
                                        getArg(r, j) = input;
                                        pushInstruction(mb,r);
+                                       freeInstruction(p);
                                        done = 1;
                                        break;
                                } else {
@@ -223,10 +230,13 @@ OPTforImplementation(Client cntxt, MalBl
                                        pushInstruction(mb, r);
 
                                        getArg(p, j) = getArg(r, 0);
+                                       actions++;
                                }
                        }
                }
-               if (!done)
+               if (done)
+                       actions++;
+               else
                        pushInstruction(mb, p);
        }
 
diff --git a/sql/backends/monet5/for.c b/sql/backends/monet5/for.c
--- a/sql/backends/monet5/for.c
+++ b/sql/backends/monet5/for.c
@@ -112,6 +112,8 @@ FORcompress_intern(char **comp_min_val, 
        if (b->ttype == TYPE_lng) {
                lng min_val = *(lng*)mn;
                lng max_val = *(lng*)mx;
+               GDKfree(mn);
+               GDKfree(mx);
                if ((max_val-min_val) > GDK_sht_max)
                        throw(SQL, "for.compress", SQLSTATE(3F000) "for 
compress: too large value spread for 'for' compression");
                if ((max_val-min_val) < GDK_bte_max/2) {
@@ -133,8 +135,12 @@ FORcompress_intern(char **comp_min_val, 
                }
                snprintf(buf, 64, "FOR-" LLFMT, min_val);
        } else if (b->ttype == TYPE_int) {
+               GDKfree(mn);
+               GDKfree(mx);
                throw(SQL, "for.compress", SQLSTATE(3F000) "for compress: 
implement type int");
        } else {
+               GDKfree(mn);
+               GDKfree(mx);
                throw(SQL, "for.compress", SQLSTATE(3F000) "for compress: type 
not yet implemented");
        }
        if (!(*comp_min_val = GDKstrdup(buf))) {
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -215,6 +215,7 @@ column_destroy(sqlstore *store, sql_colu
        _DELETE(c->min);
        _DELETE(c->max);
        _DELETE(c->def);
+       _DELETE(c->storage_type);
        _DELETE(c->base.name);
        _DELETE(c);
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to