Changeset: e4c0515be8c3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e4c0515be8c3
Modified Files:
        monetdb5/optimizer/Tests/remap.stable.out
        monetdb5/optimizer/opt_multiplex.c
Branch: default
Log Message:

Rearrange error checking so that it happens before any code is generated.


diffs (79 lines):

diff --git a/monetdb5/optimizer/Tests/remap.stable.out 
b/monetdb5/optimizer/Tests/remap.stable.out
--- a/monetdb5/optimizer/Tests/remap.stable.out
+++ b/monetdb5/optimizer/Tests/remap.stable.out
@@ -22,7 +22,6 @@ function user.tst():void;
 # demonstrate an error 
     y:bat[:int,:int]  := mal.multiplex("calc","+",b,1);
 end tst;
-!TypeException:user.tst[10]:'bat.new' undefined in: _20:any := bat.new()
 function user.main():void;
 # it will be ignored by the optimizer 
     mdb.List("user","tst");
@@ -36,10 +35,8 @@ function user.tst():void;               
     d := bat.new(:oid,:str);            #  6 d:bat[:oid,:str] := 
CMDBATnew(_2:oid, _13:str) {G}
     a:bat[:oid,:bit]  := batcalc.isnil(d);#  7 a:bat[:oid,:bit] := 
CMDbatISNIL(d:bat[:oid,:str]) {G}
 # demonstrate an error 
-    bat.reverse(b);                     #  9 _18:bat[:int,:oid] := 
BKCreverse(b:bat[:oid,:int]) {G}
-    bat.new();                          # 10 _20:any := bat.new() {U}
-    y:bat[:int,:int]  := mal.multiplex("calc","+",b,1);# 11 y:bat[:int,:int] 
:= OPTremapMultiplex(_6:str, _7:str, b:bat[:oid,:int], _8:int) {G}
-end tst;                                # 12  
+    y:bat[:int,:int]  := mal.multiplex("calc","+",b,1);#  9 y:bat[:int,:int] 
:= OPTremapMultiplex(_6:str, _7:str, b:bat[:oid,:int], _8:int) {G}
+end tst;                                # 10  
 
 # 22:31:17 >  
 # 22:31:17 >  Done.
diff --git a/monetdb5/optimizer/opt_multiplex.c 
b/monetdb5/optimizer/opt_multiplex.c
--- a/monetdb5/optimizer/opt_multiplex.c
+++ b/monetdb5/optimizer/opt_multiplex.c
@@ -56,9 +56,16 @@ OPTexpandMultiplex(Client cntxt, MalBlkP
 
        (void) cntxt;
        (void) stk;
-       alias= (int*) GDKmalloc(sizeof(int) * pci->maxarg);
-       if (alias == NULL)
-               return NULL;
+
+       ht = getHeadType(getArgType(mb, pci, 0));
+       if (ht != TYPE_oid)
+               return createException(MAL, "optimizer.multiplex", "Target head 
type is missing");
+       tt = getTailType(getArgType(mb, pci, 0));
+       if (tt== TYPE_any)
+               return createException(MAL, "optimizer.multiplex", "Target tail 
type is missing");
+       if (isAnyExpression(getArgType(mb, pci, 0)))
+               return createException(MAL, "optimizer.multiplex", "Target type 
is missing");
+
        mod = VALget(&getVar(mb, getArg(pci, 1))->value);
        mod = putName(mod,strlen(mod));
        fcn = VALget(&getVar(mb, getArg(pci, 2))->value);
@@ -84,9 +91,11 @@ OPTexpandMultiplex(Client cntxt, MalBlkP
         * because in the end we issue a recursive function call that should
         * find the actual arguments at the proper place of the callee.
         */
-       /* resB := new(refBat) */
-       if (isAnyExpression(getArgType(mb, pci, 0)))
-               return createException(MAL, "optimizer.multiplex", "Target type 
is missing");
+
+       alias= (int*) GDKmalloc(sizeof(int) * pci->maxarg);
+       if (alias == NULL)
+               return NULL;
+
        /* x := bat.reverse(A1); */
        x = newTmpVariable(mb, newBatType(getTailType(getVarType(mb,iter)),
                                                                          
getHeadType(getVarType(mb,iter))));
@@ -94,15 +103,10 @@ OPTexpandMultiplex(Client cntxt, MalBlkP
        getArg(q, 0) = x;
        q = pushArgument(mb, q, iter);
 
+       /* resB := new(refBat) */
        q = newFcnCall(mb, batRef, newRef);
        resB = getArg(q, 0);
 
-       ht = getHeadType(getArgType(mb, pci, 0));
-       if (ht== TYPE_any || ht != TYPE_oid)
-               return createException(MAL, "optimizer.multiplex", "Target head 
type is missing");
-       tt = getTailType(getArgType(mb, pci, 0));
-       if (tt== TYPE_any)
-               return createException(MAL, "optimizer.multiplex", "Target tail 
type is missing");
        setVarType(mb, getArg(q, 0), newBatType(ht, tt));
        q = pushType(mb, q, ht);
        q = pushType(mb, q, tt);
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to