Changeset: 2dd259b71063 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2dd259b71063
Modified Files:
monetdb5/mal/mal.h
monetdb5/mal/mal_instruction.c
monetdb5/optimizer/opt_support.c
monetdb5/optimizer/opt_support.h
sql/backends/monet5/sql_statement.c
Branch: default
Log Message:
disable mitosis on unsafe or 'sealed' functions.
The sealed property is new (on request), ie marks
functions which cannot be run row by row.
diffs (154 lines):
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -185,39 +185,39 @@ typedef struct {
/* the core admin */
str modname; /* module context, reference
into namespace */
str fcnname; /* function name, reference
into namespace */
- int argc, retc, maxarg; /* total and result argument count */
- int argv[FLEXIBLE_ARRAY_MEMBER]; /* at least a few entries */
+ int argc, retc, maxarg; /* total and result argument
count */
+ int argv[FLEXIBLE_ARRAY_MEMBER]; /* at least a few entries */
} *InstrPtr, InstrRecord;
typedef struct MALBLK {
- char binding[IDLENGTH]; /* related C-function */
- str help; /* supportive
commentary */
- oid tag; /* unique block tag */
+ char binding[IDLENGTH]; /* related C-function */
+ str help; /* supportive commentary */
+ oid tag; /* unique block tag */
struct MALBLK *alternative;
- int vtop; /* next free slot */
- int vsize; /* size of variable
arena */
- int vid; /* generate local
variable counter */
+ int vtop; /* next free slot */
+ int vsize; /* size of variable arena */
+ int vid; /* generate local variable
counter */
VarRecord **var; /* Variable table */
- int stop; /* next free slot */
- int ssize; /* byte size of arena */
+ int stop; /* next free slot */
+ int ssize; /* byte size of arena */
InstrPtr *stmt; /* Instruction location */
- int ptop; /* next free slot */
- int psize; /* byte size of arena */
- int inlineProp; /* inline property */
- int unsafeProp; /* unsafe property */
- int errors; /* left over errors */
+ unsigned int inlineProp:1, /* inline property */
+ unsafeProp:1, /* unsafe property */
+ sealedProp:1; /* sealed property (opertions
for sealed object should be on the full object once) */
+
+ int errors; /* left over errors */
int typefixed; /* no undetermined instruction
*/
int flowfixed; /* all flow instructions are
fixed */
- struct MALBLK *history; /* of optimizer actions */
+ struct MALBLK *history; /* of optimizer actions */
short keephistory; /* do we need the history at
all */
short dotfile; /* send dot file to
stethoscope? */
- int maxarg; /* keep track on the
maximal arguments used */
+ int maxarg; /* keep track on the maximal
arguments used */
ptr replica; /* for the replicator tests */
- sht trap; /* call debugger when
called */
+ sht trap; /* call debugger when called */
lng starttime; /* track when the query
started, for resource management */
lng runtime; /* average execution time of
block in ticks */
- int calls; /* number of calls */
+ int calls; /* number of calls */
lng optimize; /* total optimizer time */
int activeClients; /* load during mitosis
optimization */
} *MalBlkPtr, MalBlkRecord;
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -121,7 +121,7 @@ newMalBlk(int maxvars, int maxstmts)
mb->flowfixed = 0;
mb->inlineProp = 0;
mb->unsafeProp = 0;
- mb->ptop = mb->psize = 0;
+ mb->sealedProp = 0;
mb->replica = NULL;
mb->trap = 0;
mb->runtime = 0;
@@ -211,6 +211,7 @@ freeMalBlk(MalBlkPtr mb)
mb->help = 0;
mb->inlineProp = 0;
mb->unsafeProp = 0;
+ mb->sealedProp = 0;
GDKfree(mb);
}
@@ -283,6 +284,7 @@ copyMalBlk(MalBlkPtr old)
mb->maxarg = old->maxarg;
mb->inlineProp = old->inlineProp;
mb->unsafeProp = old->unsafeProp;
+ mb->sealedProp = old->sealedProp;
return mb;
}
diff --git a/monetdb5/optimizer/opt_support.c b/monetdb5/optimizer/opt_support.c
--- a/monetdb5/optimizer/opt_support.c
+++ b/monetdb5/optimizer/opt_support.c
@@ -276,6 +276,19 @@ isUnsafeFunction(InstrPtr q)
return q->blk->unsafeProp;
}
+int
+isSealedFunction(InstrPtr q)
+{
+ InstrPtr p;
+
+ if (q->fcn == 0 || getFunctionId(q) == 0 || q->blk == NULL)
+ return FALSE;
+ p= getInstrPtr(q->blk,0);
+ if( p->retc== 0)
+ return TRUE;
+ return q->blk->sealedProp;
+}
+
/*
* Instructions are unsafe if one of the arguments is also mentioned
* in the result list. Alternatively, the 'unsafe' property is set
@@ -552,6 +565,8 @@ isOrderDepenent(InstrPtr p)
}
int isMapOp(InstrPtr p){
+ if (isUnsafeFunction(p) || isSealedFunction(p))
+ return 0;
return getModuleId(p) &&
((getModuleId(p) == malRef && getFunctionId(p) == multiplexRef)
||
(getModuleId(p) == malRef && getFunctionId(p) == manifoldRef)
||
diff --git a/monetdb5/optimizer/opt_support.h b/monetdb5/optimizer/opt_support.h
--- a/monetdb5/optimizer/opt_support.h
+++ b/monetdb5/optimizer/opt_support.h
@@ -27,6 +27,7 @@ mal_export void showOptimizerHistory(voi
mal_export int optimizerIsApplied(MalBlkPtr mb, str name);
mal_export int isUnsafeInstruction(InstrPtr q);
mal_export int isUnsafeFunction(InstrPtr q);
+mal_export int isSealedFunction(InstrPtr q);
mal_export int isInvariant(MalBlkPtr mb, int pcf, int pcl, int varid);
mal_export int isDependent(InstrPtr p, InstrPtr q);
mal_export int safetyBarrier(InstrPtr p, InstrPtr q);
diff --git a/sql/backends/monet5/sql_statement.c
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -1418,7 +1418,7 @@ select2_join2(backend *be, stmt *op1, st
if (op1->nr < 0 && (sub && sub->nr < 0))
return NULL;
l = op1->nr;
- if ((op2->nrcols > 0 || op3->nrcols) && (type == st_uselect2)) {
+ if ((op2->nrcols > 0 || op3->nrcols > 0) && (type == st_uselect2)) {
int k, symmetric = cmp&CMP_SYMMETRIC;
const char *mod = calcRef;
const char *OP1 = "<", *OP2 = "<";
@@ -2629,7 +2629,7 @@ stmt_Nop(backend *be, stmt *ops, sql_sub
return NULL;
mod = sql_func_mod(f->func);
fimp = sql_func_imp(f->func);
- if (o && o->nrcols) {
+ if (o && o->nrcols > 0) {
sql_subtype *res = f->res->h->data;
fimp = convertMultiplexFcn(fimp);
q = NULL;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list