Changeset: 0f8372f1920c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0f8372f1920c
Modified Files:
        monetdb5/optimizer/opt_candidates.c
        sql/backends/monet5/sql_statistics.c
        
sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-1join-query.stable.out
        
sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-1join-view.stable.out
        
sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-query.stable.out
        
sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-view.stable.out
Branch: default
Log Message:

Merge with Mar2018 branch.


diffs (211 lines):

diff --git a/monetdb5/optimizer/opt_candidates.c 
b/monetdb5/optimizer/opt_candidates.c
--- a/monetdb5/optimizer/opt_candidates.c
+++ b/monetdb5/optimizer/opt_candidates.c
@@ -44,7 +44,7 @@ OPTcandidatesImplementation(Client cntxt
                                setVarCList(mb,getArg(p,0));
                        else if(getFunctionId(p) == likeselectRef || 
getFunctionId(p) == likethetaselectRef)
                                setVarCList(mb,getArg(p,0));
-                       else if(getFunctionId(p) == intersectRef )
+                       else if(getFunctionId(p) == intersectRef || 
getFunctionId(p) == differenceRef )
                                setVarCList(mb,getArg(p,0));
                        else if(getFunctionId(p) == uniqueRef )
                                setVarCList(mb,getArg(p,0));
@@ -52,6 +52,10 @@ OPTcandidatesImplementation(Client cntxt
                                setVarCList(mb,getArg(p,0));
                        else if(getFunctionId(p) == subsliceRef )
                                setVarCList(mb,getArg(p,0));
+                       else if (getFunctionId(p) == projectionRef &&
+                                        isVarCList(mb,getArg(p,p->retc + 0)) &&
+                                        isVarCList(mb,getArg(p,p->retc + 1)))
+                               setVarCList(mb,getArg(p,0));
                }
                else if( getModuleId(p) == generatorRef){
                        if(getFunctionId(p) == selectRef || getFunctionId(p) == 
thetaselectRef)
diff --git a/sql/backends/monet5/sql_statistics.c 
b/sql/backends/monet5/sql_statistics.c
--- a/sql/backends/monet5/sql_statistics.c
+++ b/sql/backends/monet5/sql_statistics.c
@@ -59,8 +59,8 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
        str msg = getSQLContext(cntxt, mb, &m, NULL);
        sql_trans *tr = m->session->tr;
        node *nsch, *ntab, *ncol;
-       char *query, *dquery;
-       size_t querylen;
+       char *query = NULL, *dquery;
+       size_t querylen = 0;
        char *maxval = NULL, *minval = NULL;
        size_t minlen = 0, maxlen = 0;
        str sch = 0, tbl = 0, col = 0;
@@ -76,9 +76,7 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
        if (msg != MAL_SUCCEED || (msg = checkSQLContext(cntxt)) != NULL)
                return msg;
 
-       querylen = 0;
-       query = NULL;
-       dquery = (char *) GDKzalloc(8192);
+       dquery = (char *) GDKzalloc(96);
        if (dquery == NULL) {
                throw(SQL, "analyze", SQLSTATE(HY001) MAL_MALLOC_FAIL);
        }
@@ -112,8 +110,13 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
 
                                if (tbl && strcmp(bt->name, tbl))
                                        continue;
-                               if (t->persistence != SQL_PERSIST)
+                               if (t->persistence != SQL_PERSIST) {
+                                       GDKfree(dquery);
+                                       GDKfree(query);
+                                       GDKfree(maxval);
+                                       GDKfree(minval);
                                        throw(SQL, "analyze", SQLSTATE(42S02) 
"Table '%s' is not persistent", bt->name);
+                               }
                                tfnd = 1;
                                if (isTable(t) && t->columns.set)
                                        for (ncol = (t)->columns.set->h; ncol; 
ncol = ncol->next) {
@@ -144,7 +147,7 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
                                                if (tostr == 
BATatoms[TYPE_str].atomToStr)
                                                        tostr = strToStrSQuote;
 
-                                               snprintf(dquery, 8192, "delete 
from sys.statistics where \"column_id\" = %d;", c->base.id);
+                                               snprintf(dquery, 96, "delete 
from sys.statistics where \"column_id\" = %d;", c->base.id);
                                                cfnd = 1;
                                                if (samplesize > 0) {
                                                        bsample = BATsample(bn, 
(BUN) samplesize);
@@ -174,7 +177,7 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
                                                        if (bsample && br)
                                                                
BBPunfix(br->batCacheid);
                                                }
-                                               if( bsample)
+                                               if (bsample)
                                                        
BBPunfix(bsample->batCacheid);
                                                /* use BATordered(_rev)
                                                 * and not
@@ -190,10 +193,9 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
                                                if (maxlen < 4) {
                                                        GDKfree(maxval);
                                                        maxval = GDKmalloc(4);
-                                                       if( maxval== NULL) {
+                                                       if (maxval == NULL) {
                                                                GDKfree(dquery);
                                                                GDKfree(minval);
-                                                               GDKfree(maxval);
                                                                throw(SQL, 
"analyze", SQLSTATE(HY001) MAL_MALLOC_FAIL);
                                                        }
                                                        maxlen = 4;
@@ -201,9 +203,8 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
                                                if (minlen < 4) {
                                                        GDKfree(minval);
                                                        minval = GDKmalloc(4);
-                                                       if( minval== NULL){
+                                                       if (minval == NULL){
                                                                GDKfree(dquery);
-                                                               GDKfree(minval);
                                                                GDKfree(maxval);
                                                                throw(SQL, 
"analyze", SQLSTATE(HY001) MAL_MALLOC_FAIL);
                                                        }
diff --git 
a/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-1join-query.stable.out
 
b/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-1join-query.stable.out
--- 
a/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-1join-query.stable.out
+++ 
b/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-1join-query.stable.out
@@ -216,15 +216,15 @@ function user.s10_1():void;
     X_17:bat[:int] := algebra.projection(C_5:bat[:oid], X_8:bat[:int]);
     X_42:bat[:int] := algebra.projection(X_34:bat[:oid], X_17:bat[:int]);
     X_40:bat[:oid] := bat.mirror(X_17:bat[:int]);
-    X_41:bat[:oid] := algebra.difference(X_40:bat[:oid], X_34:bat[:oid], 
nil:BAT, nil:BAT, false:bit, nil:lng);
+    C_41:bat[:oid] := algebra.difference(X_40:bat[:oid], X_34:bat[:oid], 
nil:BAT, nil:BAT, false:bit, nil:lng);
     X_27:bat[:int] := sql.bind(X_4:int, "sys":str, "pk2":str, "v2":str, 0:int);
     X_45:bat[:int] := bat.append(X_43:bat[:int], X_42:bat[:int], true:bit);
-    X_47:bat[:int] := algebra.projection(X_41:bat[:oid], X_17:bat[:int]);
+    X_47:bat[:int] := algebra.projection(C_41:bat[:oid], X_17:bat[:int]);
     X_48:bat[:int] := bat.append(X_45:bat[:int], X_47:bat[:int], true:bit);
     X_56:bat[:int] := bat.new(nil:int);
     X_55:bat[:int] := algebra.projectionpath(X_35:bat[:oid], C_25:bat[:oid], 
X_27:bat[:int]);
     X_57:bat[:int] := bat.append(X_56:bat[:int], X_55:bat[:int], true:bit);
-    X_59:bat[:int] := algebra.project(X_41:bat[:oid], nil:int);
+    X_59:bat[:int] := algebra.project(C_41:bat[:oid], nil:int);
     X_60:bat[:int] := bat.append(X_57:bat[:int], X_59:bat[:int], true:bit);
     X_73:bat[:str] := bat.new(nil:str);
     X_79:bat[:int] := bat.new(nil:int);
diff --git 
a/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-1join-view.stable.out
 
b/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-1join-view.stable.out
--- 
a/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-1join-view.stable.out
+++ 
b/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-1join-view.stable.out
@@ -139,15 +139,15 @@ function user.s8_1():void;
     X_17:bat[:int] := algebra.projection(C_5:bat[:oid], X_8:bat[:int]);
     X_42:bat[:int] := algebra.projection(X_34:bat[:oid], X_17:bat[:int]);
     X_40:bat[:oid] := bat.mirror(X_17:bat[:int]);
-    X_41:bat[:oid] := algebra.difference(X_40:bat[:oid], X_34:bat[:oid], 
nil:BAT, nil:BAT, false:bit, nil:lng);
+    C_41:bat[:oid] := algebra.difference(X_40:bat[:oid], X_34:bat[:oid], 
nil:BAT, nil:BAT, false:bit, nil:lng);
     X_27:bat[:int] := sql.bind(X_4:int, "sys":str, "pk1":str, "v1":str, 0:int);
     X_45:bat[:int] := bat.append(X_43:bat[:int], X_42:bat[:int], true:bit);
-    X_47:bat[:int] := algebra.projection(X_41:bat[:oid], X_17:bat[:int]);
+    X_47:bat[:int] := algebra.projection(C_41:bat[:oid], X_17:bat[:int]);
     X_48:bat[:int] := bat.append(X_45:bat[:int], X_47:bat[:int], true:bit);
     X_56:bat[:int] := bat.new(nil:int);
     X_55:bat[:int] := algebra.projectionpath(X_35:bat[:oid], C_25:bat[:oid], 
X_27:bat[:int]);
     X_57:bat[:int] := bat.append(X_56:bat[:int], X_55:bat[:int], true:bit);
-    X_59:bat[:int] := algebra.project(X_41:bat[:oid], nil:int);
+    X_59:bat[:int] := algebra.project(C_41:bat[:oid], nil:int);
     X_60:bat[:int] := bat.append(X_57:bat[:int], X_59:bat[:int], true:bit);
     X_73:bat[:str] := bat.new(nil:str);
     X_79:bat[:int] := bat.new(nil:int);
diff --git 
a/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-query.stable.out
 
b/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-query.stable.out
--- 
a/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-query.stable.out
+++ 
b/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-query.stable.out
@@ -139,15 +139,15 @@ function user.s8_1():void;
     X_17:bat[:int] := algebra.projection(C_5:bat[:oid], X_8:bat[:int]);
     X_42:bat[:int] := algebra.projection(X_34:bat[:oid], X_17:bat[:int]);
     X_40:bat[:oid] := bat.mirror(X_17:bat[:int]);
-    X_41:bat[:oid] := algebra.difference(X_40:bat[:oid], X_34:bat[:oid], 
nil:BAT, nil:BAT, false:bit, nil:lng);
+    C_41:bat[:oid] := algebra.difference(X_40:bat[:oid], X_34:bat[:oid], 
nil:BAT, nil:BAT, false:bit, nil:lng);
     X_27:bat[:int] := sql.bind(X_4:int, "sys":str, "pk1":str, "v1":str, 0:int);
     X_45:bat[:int] := bat.append(X_43:bat[:int], X_42:bat[:int], true:bit);
-    X_47:bat[:int] := algebra.projection(X_41:bat[:oid], X_17:bat[:int]);
+    X_47:bat[:int] := algebra.projection(C_41:bat[:oid], X_17:bat[:int]);
     X_48:bat[:int] := bat.append(X_45:bat[:int], X_47:bat[:int], true:bit);
     X_56:bat[:int] := bat.new(nil:int);
     X_55:bat[:int] := algebra.projectionpath(X_35:bat[:oid], C_25:bat[:oid], 
X_27:bat[:int]);
     X_57:bat[:int] := bat.append(X_56:bat[:int], X_55:bat[:int], true:bit);
-    X_59:bat[:int] := algebra.project(X_41:bat[:oid], nil:int);
+    X_59:bat[:int] := algebra.project(C_41:bat[:oid], nil:int);
     X_60:bat[:int] := bat.append(X_57:bat[:int], X_59:bat[:int], true:bit);
     X_73:bat[:str] := bat.new(nil:str);
     X_79:bat[:int] := bat.new(nil:int);
@@ -216,15 +216,15 @@ function user.s10_1():void;
     X_17:bat[:int] := algebra.projection(C_5:bat[:oid], X_8:bat[:int]);
     X_42:bat[:int] := algebra.projection(X_34:bat[:oid], X_17:bat[:int]);
     X_40:bat[:oid] := bat.mirror(X_17:bat[:int]);
-    X_41:bat[:oid] := algebra.difference(X_40:bat[:oid], X_34:bat[:oid], 
nil:BAT, nil:BAT, false:bit, nil:lng);
+    C_41:bat[:oid] := algebra.difference(X_40:bat[:oid], X_34:bat[:oid], 
nil:BAT, nil:BAT, false:bit, nil:lng);
     X_27:bat[:int] := sql.bind(X_4:int, "sys":str, "pk2":str, "v2":str, 0:int);
     X_45:bat[:int] := bat.append(X_43:bat[:int], X_42:bat[:int], true:bit);
-    X_47:bat[:int] := algebra.projection(X_41:bat[:oid], X_17:bat[:int]);
+    X_47:bat[:int] := algebra.projection(C_41:bat[:oid], X_17:bat[:int]);
     X_48:bat[:int] := bat.append(X_45:bat[:int], X_47:bat[:int], true:bit);
     X_56:bat[:int] := bat.new(nil:int);
     X_55:bat[:int] := algebra.projectionpath(X_35:bat[:oid], C_25:bat[:oid], 
X_27:bat[:int]);
     X_57:bat[:int] := bat.append(X_56:bat[:int], X_55:bat[:int], true:bit);
-    X_59:bat[:int] := algebra.project(X_41:bat[:oid], nil:int);
+    X_59:bat[:int] := algebra.project(C_41:bat[:oid], nil:int);
     X_60:bat[:int] := bat.append(X_57:bat[:int], X_59:bat[:int], true:bit);
     X_73:bat[:str] := bat.new(nil:str);
     X_79:bat[:int] := bat.new(nil:int);
diff --git 
a/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-view.stable.out
 
b/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-view.stable.out
--- 
a/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-view.stable.out
+++ 
b/sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-view.stable.out
@@ -139,15 +139,15 @@ function user.s8_1():void;
     X_17:bat[:int] := algebra.projection(C_5:bat[:oid], X_8:bat[:int]);
     X_42:bat[:int] := algebra.projection(X_34:bat[:oid], X_17:bat[:int]);
     X_40:bat[:oid] := bat.mirror(X_17:bat[:int]);
-    X_41:bat[:oid] := algebra.difference(X_40:bat[:oid], X_34:bat[:oid], 
nil:BAT, nil:BAT, false:bit, nil:lng);
+    C_41:bat[:oid] := algebra.difference(X_40:bat[:oid], X_34:bat[:oid], 
nil:BAT, nil:BAT, false:bit, nil:lng);
     X_27:bat[:int] := sql.bind(X_4:int, "sys":str, "pk1":str, "v2":str, 0:int);
     X_45:bat[:int] := bat.append(X_43:bat[:int], X_42:bat[:int], true:bit);
-    X_47:bat[:int] := algebra.projection(X_41:bat[:oid], X_17:bat[:int]);
+    X_47:bat[:int] := algebra.projection(C_41:bat[:oid], X_17:bat[:int]);
     X_48:bat[:int] := bat.append(X_45:bat[:int], X_47:bat[:int], true:bit);
     X_56:bat[:int] := bat.new(nil:int);
     X_55:bat[:int] := algebra.projectionpath(X_35:bat[:oid], C_25:bat[:oid], 
X_27:bat[:int]);
     X_57:bat[:int] := bat.append(X_56:bat[:int], X_55:bat[:int], true:bit);
-    X_59:bat[:int] := algebra.project(X_41:bat[:oid], nil:int);
+    X_59:bat[:int] := algebra.project(C_41:bat[:oid], nil:int);
     X_60:bat[:int] := bat.append(X_57:bat[:int], X_59:bat[:int], true:bit);
     X_73:bat[:str] := bat.new(nil:str);
     X_79:bat[:int] := bat.new(nil:int);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to