Changeset: b5143f768862 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b5143f768862
Modified Files:
        clients/Tests/exports.stable.out
        monetdb5/optimizer/opt_commonTerms.c
        monetdb5/optimizer/opt_support.c
        monetdb5/optimizer/opt_support.h
Branch: subquery
Log Message:

merged with default


diffs (99 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
@@ -2264,7 +2264,7 @@ str groupbyRef;
 str groupdoneRef;
 int hasCommonResults(InstrPtr p, InstrPtr q);
 int hasSameArguments(MalBlkPtr mb, InstrPtr p, InstrPtr q);
-int hasSameSignature(MalBlkPtr mb, InstrPtr p, InstrPtr q, int stop);
+int hasSameSignature(MalBlkPtr mb, InstrPtr p, InstrPtr q);
 int hasSideEffects(MalBlkPtr mb, InstrPtr p, int strict);
 str hashRef;
 int have_hge;
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
@@ -111,7 +111,7 @@ OPTcommonTermsImplementation(Client cntx
 #ifdef DEBUG_OPT_COMMONTERMS_MORE
                                fprintf(stderr,"#CANDIDATE[%d->%d] %d %d :%d %d 
%d=%d %d %d %d ",
                                                j, list[j], 
-                                               hasSameSignature(mb, p, q, 
p->retc), 
+                                               hasSameSignature(mb, p, q), 
                                                hasSameArguments(mb, p, q),
                                                q->token != ASSIGNsymbol ,
                                                list[getArg(q,q->argc-1)],i,
@@ -127,7 +127,7 @@ OPTcommonTermsImplementation(Client cntx
                                 * be assigned their value before instruction p.
                                 */
                                if ( hasSameArguments(mb, p, q) && 
-                                        hasSameSignature(mb, p, q, p->retc) && 
+                                        hasSameSignature(mb, p, q) && 
                                         !hasCommonResults(p, q) && 
                                         !isUnsafeFunction(q) && 
                                         !isUpdateInstruction(q) &&
@@ -170,7 +170,7 @@ OPTcommonTermsImplementation(Client cntx
                                i, getArg(p,p->argc-1), HASHinstruction(p), 
hash[HASHinstruction(p)]);
                fprintInstruction(stderr, mb, 0, p, LIST_MAL_ALL);
 #endif
-               if ( !mayhaveSideEffects(cntxt, mb, p, TRUE) &&  
!isUnsafeFunction(p) && !isUpdateInstruction(p)){
+               if ( !mayhaveSideEffects(cntxt, mb, p, TRUE) && p->argc != 
p->retc &&  isLinearFlow(p) && !isUnsafeFunction(p) && !isUpdateInstruction(p)){
                        list[i] = hash[HASHinstruction(p)];
                        hash[HASHinstruction(p)] = i;
                        pushInstruction(mb,p);
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
@@ -187,20 +187,20 @@ MALoptimizer(Client c)
 }
 
 /* Only used by opt_commonTerms! */
-int hasSameSignature(MalBlkPtr mb, InstrPtr p, InstrPtr q, int stop){
+int hasSameSignature(MalBlkPtr mb, InstrPtr p, InstrPtr q){
        int i;
 
        if ( getFunctionId(q) == getFunctionId(p) &&
                 getModuleId(q) == getModuleId(p) &&
-               getFunctionId(q) != 0 &&
-               getModuleId(q) != 0) {
-               if( q->retc != p->retc || q->argc != p->argc) return FALSE;
-               assert(stop <= p->argc);
-               for( i=0; i<stop; i++)
-                       if (getArgType(mb,p,i) != getArgType(mb,q,i))
+                getFunctionId(q) != 0 &&
+                getModuleId(q) != 0) {
+                       if( q->retc != p->retc || q->argc != p->argc) 
                                return FALSE;
-               return TRUE;
-       }
+                       for( i=0; i < p->argc; i++)
+                               if (getArgType(mb,p,i) != getArgType(mb,q,i))
+                                       return FALSE;
+                       return TRUE;
+               }
        return FALSE;
 }
 
@@ -471,6 +471,11 @@ mayhaveSideEffects(Client cntxt, MalBlkP
                return TRUE;
        if (getModuleId(p) != malRef || getFunctionId(p) != multiplexRef) 
                return hasSideEffects(mb, p, strict);
+       //  a manifold instruction can also have side effects.
+       //  for this to check we need the function signature, not its function 
address.
+       //  The easy way out now is to consider all manifold instructions as 
potentially having side effects.
+       if ( getModuleId(p) == malRef && getFunctionId(p) == manifoldRef)
+               return TRUE;
        if (MANIFOLDtypecheck(cntxt,mb,p,1) == NULL)
                return TRUE;
        return FALSE;
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
@@ -28,7 +28,7 @@ mal_export int isUnsafeInstruction(Instr
 mal_export int isUnsafeFunction(InstrPtr q);
 mal_export int isSealedFunction(InstrPtr q);
 mal_export int safetyBarrier(InstrPtr p, InstrPtr q);
-mal_export int hasSameSignature(MalBlkPtr mb, InstrPtr p, InstrPtr q, int 
stop);
+mal_export int hasSameSignature(MalBlkPtr mb, InstrPtr p, InstrPtr q);
 mal_export int hasSameArguments(MalBlkPtr mb, InstrPtr p, InstrPtr q);
 mal_export int hasCommonResults(InstrPtr p, InstrPtr q);
 mal_export int isUpdateInstruction(InstrPtr p);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to