Changeset: dc2b49e4f2a5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dc2b49e4f2a5
Modified Files:
clients/Tests/exports.stable.out
monetdb5/extras/mal_optimizer_template/opt_sql_append.c
monetdb5/mal/mal_interpreter.c
monetdb5/optimizer/opt_aliases.c
monetdb5/optimizer/opt_aliases.h
monetdb5/optimizer/opt_candidates.c
monetdb5/optimizer/opt_candidates.h
monetdb5/optimizer/opt_coercion.c
monetdb5/optimizer/opt_coercion.h
monetdb5/optimizer/opt_commonTerms.c
monetdb5/optimizer/opt_commonTerms.h
monetdb5/optimizer/opt_constants.c
monetdb5/optimizer/opt_constants.h
monetdb5/optimizer/opt_costModel.c
monetdb5/optimizer/opt_costModel.h
monetdb5/optimizer/opt_dataflow.c
monetdb5/optimizer/opt_dataflow.h
monetdb5/optimizer/opt_deadcode.c
monetdb5/optimizer/opt_deadcode.h
monetdb5/optimizer/opt_emptybind.c
monetdb5/optimizer/opt_emptybind.h
monetdb5/optimizer/opt_evaluate.c
monetdb5/optimizer/opt_evaluate.h
monetdb5/optimizer/opt_garbageCollector.c
monetdb5/optimizer/opt_garbageCollector.h
monetdb5/optimizer/opt_generator.c
monetdb5/optimizer/opt_generator.h
monetdb5/optimizer/opt_inline.c
monetdb5/optimizer/opt_inline.h
monetdb5/optimizer/opt_jit.c
monetdb5/optimizer/opt_jit.h
monetdb5/optimizer/opt_json.c
monetdb5/optimizer/opt_json.h
monetdb5/optimizer/opt_macro.c
monetdb5/optimizer/opt_macro.h
monetdb5/optimizer/opt_matpack.c
monetdb5/optimizer/opt_matpack.h
monetdb5/optimizer/opt_mergetable.c
monetdb5/optimizer/opt_mergetable.h
monetdb5/optimizer/opt_mitosis.c
monetdb5/optimizer/opt_mitosis.h
monetdb5/optimizer/opt_multiplex.c
monetdb5/optimizer/opt_multiplex.h
monetdb5/optimizer/opt_oltp.c
monetdb5/optimizer/opt_oltp.h
monetdb5/optimizer/opt_profiler.c
monetdb5/optimizer/opt_profiler.h
monetdb5/optimizer/opt_projectionpath.c
monetdb5/optimizer/opt_projectionpath.h
monetdb5/optimizer/opt_pushselect.c
monetdb5/optimizer/opt_pushselect.h
monetdb5/optimizer/opt_querylog.c
monetdb5/optimizer/opt_querylog.h
monetdb5/optimizer/opt_reduce.c
monetdb5/optimizer/opt_reduce.h
monetdb5/optimizer/opt_remap.c
monetdb5/optimizer/opt_remap.h
monetdb5/optimizer/opt_remoteQueries.c
monetdb5/optimizer/opt_remoteQueries.h
monetdb5/optimizer/opt_reorder.c
monetdb5/optimizer/opt_reorder.h
monetdb5/optimizer/opt_support.c
monetdb5/optimizer/opt_support.h
monetdb5/optimizer/opt_volcano.c
monetdb5/optimizer/opt_volcano.h
monetdb5/optimizer/opt_wrapper.c
sql/test/leaks/Tests/check0.stable.out
sql/test/leaks/Tests/check0.stable.out.int128
sql/test/leaks/Tests/check1.stable.out
sql/test/leaks/Tests/check1.stable.out.int128
sql/test/leaks/Tests/check2.stable.out
sql/test/leaks/Tests/check2.stable.out.int128
sql/test/leaks/Tests/check3.stable.out
sql/test/leaks/Tests/check3.stable.out.int128
sql/test/leaks/Tests/check4.stable.out
sql/test/leaks/Tests/check4.stable.out.int128
sql/test/leaks/Tests/check5.stable.out
sql/test/leaks/Tests/check5.stable.out.int128
sql/test/leaks/Tests/select1.stable.out.int128
sql/test/leaks/Tests/select2.stable.out.int128
sql/test/leaks/Tests/temp1.stable.out
sql/test/leaks/Tests/temp1.stable.out.int128
sql/test/leaks/Tests/temp2.stable.out
sql/test/leaks/Tests/temp2.stable.out.int128
sql/test/leaks/Tests/temp3.stable.out
sql/test/leaks/Tests/temp3.stable.out.int128
Branch: default
Log Message:
Cleanup optimizer interfaces
All optimizers new return a proper exception upon errors.
A preparation for further cleanup of error detection and handling.
diffs (truncated from 2578 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1539,41 +1539,41 @@ str OLTPrelease(Client cntxt, MalBlkPtr
str OLTPreset(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str OLTPtable(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
void OPTaliasRemap(InstrPtr p, int *alias);
-int OPTaliasesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTcandidatesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTcoercionImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-int OPTcommonTermsImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-int OPTconstantsImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTcostModelImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-int OPTdataflowImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTdeadcodeImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-int OPTemptybindImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTevaluateImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-int OPTgarbageCollectorImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr
stk, InstrPtr pci);
-int OPTgeneratorImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-int OPTinlineImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTaliasesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTcandidatesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTcoercionImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTcommonTermsImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTconstantsImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTcostModelImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTdataflowImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTdeadcodeImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTemptybindImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTevaluateImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTgarbageCollectorImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr
stk, InstrPtr pci);
+str OPTgeneratorImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTinlineImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
int OPTisAlias(InstrPtr p);
-int OPTjitImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
p);
-int OPTjsonImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
+str OPTjitImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
p);
+str OPTjsonImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
str OPTmacro(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
-int OPTmacroImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
p);
-int OPTmatpackImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-int OPTmergetableImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTmitosisImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTmultiplexImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTmacroImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
p);
+str OPTmatpackImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTmergetableImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTmitosisImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTmultiplexImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
str OPTmultiplexSimple(Client cntxt, MalBlkPtr mb);
-int OPToltpImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
+str OPToltpImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
str OPTorcam(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
-int OPTorcamImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
p);
-int OPTprofilerImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTprojectionpathImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTpushselectImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-int OPTquerylogImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-int OPTreduceImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTremapImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
-int OPTremoteQueriesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-int OPTreorderImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
-int OPTvolcanoImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTorcamImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
p);
+str OPTprofilerImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTprojectionpathImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTpushselectImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTquerylogImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTreduceImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTremapImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
+str OPTremoteQueriesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+str OPTreorderImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
+str OPTvolcanoImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr p);
str OPTwrapper(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
str PCREilike2(bit *ret, const str *s, const str *pat);
str PCREilike3(bit *ret, const str *s, const str *pat, const str *esc);
@@ -2342,7 +2342,6 @@ int open_block_stream(Stream *S, Stream
str open_block_streamwrap(Stream *S, Stream *is);
str operatorName(int i);
str optimizeMALBlock(Client cntxt, MalBlkPtr mb);
-str optimizerCheck(Client cntxt, MalBlkPtr mb, str name, int actions, lng
usec);
int optimizerIsApplied(MalBlkPtr mb, str name);
str optimizerRef;
str optimizer_prelude(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
diff --git a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
--- a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
+++ b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
@@ -252,7 +252,8 @@ str OPTsql_append(Client cntxt, MalBlkPt
str fcnnme;
str msg= MAL_SUCCEED;
Symbol s= NULL;
- lng t,clk= GDKusec();
+ char buf[256];
+ lng clk= GDKusec();
int actions = 0;
(void) cntxt;
@@ -292,13 +293,20 @@ str OPTsql_append(Client cntxt, MalBlkPt
return MAL_SUCCEED;
}
actions= OPTsql_appendImplementation(cntxt, mb,stk,p);
- msg= optimizerCheck(cntxt, mb, "optimizer.sql_append", actions,
t=(GDKusec() - clk));
+
+ /* Defense line against incorrect plans */
+ chkTypes(cntxt->fdout, cntxt->nspace, mb, FALSE);
+ chkFlow(cntxt->fdout, mb);
+ chkDeclarations(cntxt->fdout, mb);
#ifdef DEBUG_OPT_OPTIMIZERS
mnstr_printf(cntxt->fdout,"=FINISHED sql_append %d\n",actions);
printFunction(cntxt->fdout,mb,0,LIST_MAL_ALL );
mnstr_printf(cntxt->fdout,"#opt_reduce: " LLFMT " ms\n",t);
#endif
- QOTupdateStatistics("sql_append",actions,t);
+ clk = GDKusec()- clk;
+ snprintf(buf,256,"%-20s actions=%2d time=" LLFMT "
usec","optimizer.sql_append",actions, clk);
+ newComment(mb,buf);
+ QOTupdateStatistics("optimizer.sql_append",actions,clk);
addtoMalBlkHistory(mb);
return msg;
}
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -283,7 +283,6 @@ prepareMALstack(MalBlkPtr mb, int size)
int i;
ValPtr lhs, rhs;
- assert(size >= mb->vsize);
stk = newGlobalStack(size);
if (!stk) {
return NULL;
diff --git a/monetdb5/optimizer/opt_aliases.c b/monetdb5/optimizer/opt_aliases.c
--- a/monetdb5/optimizer/opt_aliases.c
+++ b/monetdb5/optimizer/opt_aliases.c
@@ -21,7 +21,7 @@ OPTaliasRemap(InstrPtr p, int *alias){
getArg(p,i) = alias[getArg(p,i)];
}
-int
+str
OPTaliasesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
int i,j,k=1, limit, actions=0;
@@ -43,7 +43,7 @@ OPTaliasesImplementation(Client cntxt, M
if( i < limit){
alias= (int*) GDKzalloc(sizeof(int)* mb->vtop);
if (alias == NULL)
- return 0;
+ throw(MAL,"optimizer.aliases",MAL_MALLOC_FAIL);
setVariableScope(mb);
for(j=1; j<mb->vtop; j++) alias[j]=j;
}
@@ -83,9 +83,8 @@ OPTaliasesImplementation(Client cntxt, M
usec= GDKusec() - usec;
snprintf(buf,256,"%-20s actions=%2d time=" LLFMT "
usec","aliases",actions,usec);
newComment(mb,buf);
- QOTupdateStatistics("aliases",actions,usec);
if( actions >= 0)
addtoMalBlkHistory(mb);
- return actions;
+ return MAL_SUCCEED;
}
diff --git a/monetdb5/optimizer/opt_aliases.h b/monetdb5/optimizer/opt_aliases.h
--- a/monetdb5/optimizer/opt_aliases.h
+++ b/monetdb5/optimizer/opt_aliases.h
@@ -14,6 +14,6 @@
mal_export int OPTisAlias(InstrPtr p);
mal_export void OPTaliasRemap(InstrPtr p, int *alias);
-mal_export int OPTaliasesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr
stk, InstrPtr p);
+mal_export str OPTaliasesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr
stk, InstrPtr p);
#endif
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
@@ -15,7 +15,7 @@
#include "opt_candidates.h"
#include "opt_statistics.h"
-int
+str
OPTcandidatesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci)
{
int i;
@@ -84,8 +84,7 @@ OPTcandidatesImplementation(Client cntxt
usec = GDKusec()- usec;
snprintf(buf,256,"%-20s actions=1 time=" LLFMT " usec","candidates",usec);
newComment(mb,buf);
- QOTupdateStatistics("candidates",1,usec);
addtoMalBlkHistory(mb);
- return 1;
+ return MAL_SUCCEED;
}
diff --git a/monetdb5/optimizer/opt_candidates.h
b/monetdb5/optimizer/opt_candidates.h
--- a/monetdb5/optimizer/opt_candidates.h
+++ b/monetdb5/optimizer/opt_candidates.h
@@ -12,6 +12,6 @@
#include "opt_support.h"
#include "mal_exception.h"
-mal_export int OPTcandidatesImplementation(Client cntxt, MalBlkPtr mb,
MalStkPtr stk, InstrPtr p);
+mal_export str OPTcandidatesImplementation(Client cntxt, MalBlkPtr mb,
MalStkPtr stk, InstrPtr p);
#endif
diff --git a/monetdb5/optimizer/opt_coercion.c
b/monetdb5/optimizer/opt_coercion.c
--- a/monetdb5/optimizer/opt_coercion.c
+++ b/monetdb5/optimizer/opt_coercion.c
@@ -118,7 +118,7 @@ coercionOptimizerAggrStep(Client cntxt,
return;
}
-int
+str
OPTcoercionImplementation(Client cntxt,MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci)
{
int i, k;
@@ -130,7 +130,7 @@ OPTcoercionImplementation(Client cntxt,M
lng usec = GDKusec();
if( coerce == NULL)
- return 0;
+ throw(MAL,"optimizer.coercion",MAL_MALLOC_FAIL);
(void) cntxt;
(void) pci;
(void) stk; /* to fool compilers */
@@ -200,9 +200,8 @@ OPTcoercionImplementation(Client cntxt,M
usec = GDKusec()- usec;
snprintf(buf,256,"%-20s actions=%2d time=" LLFMT "
usec","coercion",actions, usec);
newComment(mb,buf);
- QOTupdateStatistics("coercion",actions,usec);
if( actions >= 0)
addtoMalBlkHistory(mb);
- return actions;
+ return MAL_SUCCEED;
}
diff --git a/monetdb5/optimizer/opt_coercion.h
b/monetdb5/optimizer/opt_coercion.h
--- a/monetdb5/optimizer/opt_coercion.h
+++ b/monetdb5/optimizer/opt_coercion.h
@@ -12,6 +12,6 @@
#include "mal_interpreter.h"
#include "opt_support.h"
-mal_export int OPTcoercionImplementation(Client cntxt,MalBlkPtr mb, MalStkPtr
stk, InstrPtr pci);
+mal_export str OPTcoercionImplementation(Client cntxt,MalBlkPtr mb, MalStkPtr
stk, InstrPtr pci);
#endif
diff --git a/monetdb5/optimizer/opt_commonTerms.c
b/monetdb5/optimizer/opt_commonTerms.c
--- a/monetdb5/optimizer/opt_commonTerms.c
+++ b/monetdb5/optimizer/opt_commonTerms.c
@@ -16,7 +16,7 @@
* are introduced too far apart in the MAL program.
* It requires the constant optimizer to be ran first.
*/
-int
+str
OPTcommonTermsImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci)
{
int i, j, k, prop, barrier= 0, cnt;
@@ -31,6 +31,7 @@ OPTcommonTermsImplementation(Client cntx
int *vars;
char buf[256];
lng usec = GDKusec();
+ str msg = MAL_SUCCEED;
(void) cntxt;
(void) stk;
@@ -38,13 +39,16 @@ OPTcommonTermsImplementation(Client cntx
alias = (int*) GDKzalloc(sizeof(int) * mb->vtop);
list = (int*) GDKzalloc(sizeof(int) * mb->stop);
vars = (int*) GDKzalloc(sizeof(int) * mb->vtop);
- if ( alias == NULL || list == NULL || vars == NULL)
+ if ( alias == NULL || list == NULL || vars == NULL){
+ msg =
createException(MAL,"optimizer.commonTerms",MAL_MALLOC_FAIL);
goto wrapup;
+ }
old = mb->stmt;
limit = mb->stop;
slimit = mb->ssize;
if ( newMalBlkStmt(mb, mb->ssize) < 0) {
+ msg =
createException(MAL,"optimizer.commonTerms",MAL_MALLOC_FAIL);
old = NULL;
goto wrapup;
}
@@ -183,7 +187,6 @@ OPTcommonTermsImplementation(Client cntx
usec = GDKusec()- usec;
snprintf(buf,256,"%-20s actions=%2d time=" LLFMT "
usec","commonTerms",actions,usec);
newComment(mb,buf);
- QOTupdateStatistics("commonTerms",actions,usec);
if( actions >= 0)
addtoMalBlkHistory(mb);
@@ -192,5 +195,5 @@ wrapup:
if(list) GDKfree(list);
if(vars) GDKfree(vars);
if(old) GDKfree(old);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list