Changeset: 6d0ae82d8d1a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6d0ae82d8d1a
Modified Files:
        MonetDB5/src/optimizer/opt_octopus.mx
Branch: default
Log Message:

Repetitive variable assignment is correct in exit instructions, hence octopus
should not create variable alias in this case.


diffs (122 lines):

diff -r f56ffe312851 -r 6d0ae82d8d1a MonetDB5/src/optimizer/opt_octopus.mx
--- a/MonetDB5/src/optimizer/opt_octopus.mx     Thu Jan 13 17:55:03 2011 +0100
+++ b/MonetDB5/src/optimizer/opt_octopus.mx     Thu Jan 13 18:08:17 2011 +0100
@@ -952,19 +952,17 @@
        oid l,h;
        str tnm;
        char rname[BUFSIZ];
-       MalBlkPtr *tentacle= (MalBlkPtr *) GDKmalloc(sizeof(MalBlkPtr) * 
MAXSLICES);
+       MalBlkPtr *tentacle = NULL;
 
        (void) stk;
 
-       if ( tentacle == NULL)
-               return 0;
+       /*      optDebug |= 1 << DEBUG_OPT_OCTOPUS; */
+       OPTDEBUGoctopus{
+               mnstr_printf(cntxt->fdout, "#Octopus optimizer called\n");
+               chkProgram(cntxt->nspace,mb);  
+               printFunction(cntxt->fdout, mb, 0, LIST_MAL_STMT | 
LIST_MAL_TYPE | LIST_MAPI);
+       }
 
-       /*      optDebug |= 1 << DEBUG_OPT_OCTOPUS; */
-/*     OPTDEBUGoctopus{
-               mnstr_printf(cntxt->fdout, "#Octopus optimizer called\n");
-               printFunction(cntxt->fdout, mb, 0, LIST_MAL_STMT | LIST_MAL_UDF 
| LIST_MAL_PROPS);
-       }
-*/
        (void) fixModule(cntxt->nspace,octopusRef);
        old = mb->stmt;
        limit = mb->stop;
@@ -979,10 +977,8 @@
                }
        }
        /* we do not  support yet update operations in the octopus */
-       if ( update || autocommit==0 ) {
-               GDKfree(tentacle);
+       if ( update || autocommit==0 ) 
                return 0;
-       }
 
        mb->legid = octopusSeq++;
 
@@ -1003,6 +999,11 @@
                                z = getArg(p,j);
                                getArg(p,j) = alias[z];
                        }
+               if ( p->barrier == EXITsymbol ) { /* exits use the same 
variable */
+                       if ( varadd )
+                               getArg(p,0) = alias[getArg(p,0)];
+                       continue;
+               }
                for( j = 0; j < p->retc; j++ ){
                        z = getArg(p,j);
                        if ( set[z] ){
@@ -1109,13 +1110,16 @@
        for (i = 1; i < octClCnt; i++){
                if ( octCluster[i].retcnt == 0 ){
                        mnstr_printf(cntxt->fdout, "Tentacle %d without 
result\n", i); 
-                       GDKfree(tentacle);
-                       GDKfree(malPart);
-                       return 0;
+                       goto cleanup;
                }
        }
 
        /* create tentacles */
+
+       tentacle= (MalBlkPtr *) GDKmalloc(sizeof(MalBlkPtr) * MAXSLICES);
+       if ( tentacle == NULL)
+               goto cleanup;
+
        v2 = newVariable(mb, GDKstrdup("version"), TYPE_int);
        for (i = 1; i < octClCnt; i++){
                tentacle[i] = OCTnewTentacle(cntxt, mb,i, v2, malPart);
@@ -1123,18 +1127,17 @@
                actions++;
        }
 
-       if ( actions ){
-               OCTnewBidding(cntxt, octClCnt-1);
-       }
+       if ( !actions )
+               goto cleanup;
+
+       OCTnewBidding(cntxt, octClCnt-1);
 
        /* modify plan at the head */
        sig = old[0];
 
-       if ( newMalBlkStmt(mb, mb->ssize) < 0){
-               GDKfree(tentacle);
-               GDKfree(malPart);
-               return 0;
-       }
+       if ( newMalBlkStmt(mb, mb->ssize) < 0)
+               goto cleanup;
+
        pushInstruction(mb, sig); 
 
        last = limit;
@@ -1185,14 +1188,17 @@
        }       
 
        clrDeclarations(mb);
-       chkProgram(cntxt->nspace,mb);  
        OPTDEBUGoctopus{
-               /*              printFunction(cntxt->fdout, mb, 0, 
LIST_MAL_STMT | LIST_MAPI); */
+               chkProgram(cntxt->nspace,mb); 
+               printFunction(cntxt->fdout, mb, 0,  LIST_MAL_STMT | 
LIST_MAL_TYPE | LIST_MAPI); 
        }
 
+       GDKfree(old);
+
+ cleanup:
        GDKfree(malPart);
-       GDKfree(tentacle);
-       GDKfree(old);
+       if (tentacle)
+               GDKfree(tentacle);
        return actions;
 }
 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to