Changeset: 5732e19a89f5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5732e19a89f5
Modified Files:
        clients/Tests/MAL-signatures-hge.test
        clients/Tests/MAL-signatures.test
        monetdb5/mal/Tests/tst191.maltest
        monetdb5/mal/mal.h
        monetdb5/mal/mal_instruction.c
        monetdb5/mal/mal_parser.c
        monetdb5/mal/mal_prelude.c
        monetdb5/mal/mal_resolve.c
        monetdb5/mal/mal_resolve.h
        monetdb5/mal/mal_type.h
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/mal/batcalc.c
        monetdb5/optimizer/Tests/tst4630.maltest
        sql/backends/monet5/sql.c
Branch: no_type_bat
Log Message:

only 1-3 any_index numbers for now (seems 1-2, could/should be enough).
improved parser, give errors on overflow of the index numbers


diffs (truncated from 430 to 300 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -215,12 +215,12 @@ CMDBATavg3comb;
 Average aggregation combiner.
 aggr
 avg
-pattern aggr.avg(X_0:bat[:any_2]):dbl 
+pattern aggr.avg(X_0:bat[:any_1]):dbl 
 CMDcalcavg;
 Gives the avg of all tail values
 aggr
 avg
-pattern aggr.avg(X_0:bat[:any_2], X_1:int):dbl 
+pattern aggr.avg(X_0:bat[:any_1], X_1:int):dbl 
 CMDcalcavg;
 Gives the avg of all tail values
 aggr
@@ -3545,17 +3545,17 @@ ALGouterselect;
 Per input lid return atleast one row, if none of the predicates (p) hold, 
return a nil, else 'all' true cases.
 algebra
 project
-pattern algebra.project(X_0:bat[:any_1], X_1:any_3):bat[:any_3] 
+pattern algebra.project(X_0:bat[:any_1], X_1:any_2):bat[:any_2] 
 ALGprojecttail;
 Fill the tail with a constant
 algebra
 projection
-command algebra.projection(X_0:bat[:oid], X_1:bat[:any_3], 
X_2:bat[:any_3]):bat[:any_3] 
+command algebra.projection(X_0:bat[:oid], X_1:bat[:any_1], 
X_2:bat[:any_1]):bat[:any_1] 
 ALGprojection2;
 Project left input onto right inputs which should be consecutive.
 algebra
 projection
-command algebra.projection(X_0:bat[:oid], X_1:bat[:any_3]):bat[:any_3] 
+command algebra.projection(X_0:bat[:oid], X_1:bat[:any_1]):bat[:any_1] 
 ALGprojection;
 Project left input onto right input.
 algebra
@@ -49440,7 +49440,7 @@ mvc_delete_wrap;
 Delete a row from a table. Returns sequence number for order dependence.
 sql
 delta
-command sql.delta(X_0:bat[:any_3], X_1:bat[:oid], X_2:bat[:any_3]):bat[:any_3] 
+command sql.delta(X_0:bat[:any_1], X_1:bat[:oid], X_2:bat[:any_1]):bat[:any_1] 
 DELTAbat;
 Return column bat with delta's applied.
 sql
@@ -49860,7 +49860,7 @@ BATleftproject;
 Last step of a left outer join, ie project the inner join (l,r) over the left 
input side (col)
 sql
 projectdelta
-command sql.projectdelta(X_0:bat[:oid], X_1:bat[:any_3], X_2:bat[:oid], 
X_3:bat[:any_3]):bat[:any_3] 
+command sql.projectdelta(X_0:bat[:oid], X_1:bat[:any_1], X_2:bat[:oid], 
X_3:bat[:any_1]):bat[:any_1] 
 DELTAproject;
 Return column bat with delta's applied.
 sql
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -195,12 +195,12 @@ CMDBATavg3comb;
 Average aggregation combiner.
 aggr
 avg
-pattern aggr.avg(X_0:bat[:any_2]):dbl 
+pattern aggr.avg(X_0:bat[:any_1]):dbl 
 CMDcalcavg;
 Gives the avg of all tail values
 aggr
 avg
-pattern aggr.avg(X_0:bat[:any_2], X_1:int):dbl 
+pattern aggr.avg(X_0:bat[:any_1], X_1:int):dbl 
 CMDcalcavg;
 Gives the avg of all tail values
 aggr
@@ -2980,17 +2980,17 @@ ALGouterselect;
 Per input lid return atleast one row, if none of the predicates (p) hold, 
return a nil, else 'all' true cases.
 algebra
 project
-pattern algebra.project(X_0:bat[:any_1], X_1:any_3):bat[:any_3] 
+pattern algebra.project(X_0:bat[:any_1], X_1:any_2):bat[:any_2] 
 ALGprojecttail;
 Fill the tail with a constant
 algebra
 projection
-command algebra.projection(X_0:bat[:oid], X_1:bat[:any_3], 
X_2:bat[:any_3]):bat[:any_3] 
+command algebra.projection(X_0:bat[:oid], X_1:bat[:any_1], 
X_2:bat[:any_1]):bat[:any_1] 
 ALGprojection2;
 Project left input onto right inputs which should be consecutive.
 algebra
 projection
-command algebra.projection(X_0:bat[:oid], X_1:bat[:any_3]):bat[:any_3] 
+command algebra.projection(X_0:bat[:oid], X_1:bat[:any_1]):bat[:any_1] 
 ALGprojection;
 Project left input onto right input.
 algebra
@@ -37845,7 +37845,7 @@ mvc_delete_wrap;
 Delete a row from a table. Returns sequence number for order dependence.
 sql
 delta
-command sql.delta(X_0:bat[:any_3], X_1:bat[:oid], X_2:bat[:any_3]):bat[:any_3] 
+command sql.delta(X_0:bat[:any_1], X_1:bat[:oid], X_2:bat[:any_1]):bat[:any_1] 
 DELTAbat;
 Return column bat with delta's applied.
 sql
@@ -38240,7 +38240,7 @@ BATleftproject;
 Last step of a left outer join, ie project the inner join (l,r) over the left 
input side (col)
 sql
 projectdelta
-command sql.projectdelta(X_0:bat[:oid], X_1:bat[:any_3], X_2:bat[:oid], 
X_3:bat[:any_3]):bat[:any_3] 
+command sql.projectdelta(X_0:bat[:oid], X_1:bat[:any_1], X_2:bat[:oid], 
X_3:bat[:any_1]):bat[:any_1] 
 DELTAproject;
 Return column bat with delta's applied.
 sql
diff --git a/monetdb5/mal/Tests/tst191.maltest 
b/monetdb5/mal/Tests/tst191.maltest
--- a/monetdb5/mal/Tests/tst191.maltest
+++ b/monetdb5/mal/Tests/tst191.maltest
@@ -5,11 +5,11 @@ function welcome0(lim:int):str;
     return (w,i);
 end welcome0
 
-statement ok
+statement error
 y:= user.welcome0(1)
 
 query T rowsort
 io.print(y)
 ----
-"hello"
+NULL
 
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -183,7 +183,6 @@ typedef struct MALBLK {
        struct MALBLK *history;         /* of optimizer actions */
        short keephistory;                      /* do we need the history at 
all */
        int maxarg;                                     /* keep track on the 
maximal arguments used */
-       ptr replica;                            /* for the replicator tests */
 
        /* During the run we keep track on the maximum number of concurrent 
threads and memory claim */
        ATOMIC_TYPE workers;
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
@@ -342,7 +342,6 @@ copyMalBlk(MalBlkPtr old)
        mb->runtime = old->runtime;
        mb->calls = old->calls;
        mb->optimize = old->optimize;
-       mb->replica = old->replica;
        mb->maxarg = old->maxarg;
        mb->inlineProp = old->inlineProp;
        mb->unsafeProp = old->unsafeProp;
@@ -1234,18 +1233,15 @@ destinationType(MalBlkPtr mb, InstrPtr p
 inline void
 setPolymorphic(InstrPtr p, int tpe, int force)
 {
-       int c1 = 0, c2 = 0;
        if (force == FALSE && tpe == TYPE_any)
                return;
-       if (isaBatType(tpe))
-               c1 = TYPE_oid;
+       int any = isAnyExpression(tpe) || TYPE_any, index = 0;
+       assert(any);
        if (getTypeIndex(tpe) > 0)
-               c2 = getTypeIndex(tpe);
-       else if (getBatType(tpe) == TYPE_any)
-               c2 = 1;
-       c1 = c1 > c2 ? c1 : c2;
-       if (c1 > 0 && c1 >= p->polymorphic)
-               p->polymorphic = c1 + 1;
+               index = getTypeIndex(tpe);
+       if (any && (index + 1) >= p->polymorphic)
+               p->polymorphic = index + 1;
+       assert(p->polymorphic);
 }
 
 /* Instructions are simply appended to a MAL block. It should always succeed.
diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c
--- a/monetdb5/mal/mal_parser.c
+++ b/monetdb5/mal/mal_parser.c
@@ -764,14 +764,12 @@ cstToken(Client cntxt, ValPtr cst)
  *
  * The type ANY matches any type specifier.
  * Appending it with an alias turns it into a type variable.
- * The type alias is \$DIGIT (1-9) and can be used to relate types
+ * The type alias is \$DIGIT (1-3) and can be used to relate types
  * by type equality.
  * The type variable are defined within the context of a function
  * scope.
  * Additional information, such as a repetition factor,
  * encoding tables, or type dependency should be modeled as properties.
- *
- * It would make more sense for tpe parameter to be an int, but simpleTypeId 
returns a size_t
  */
 static int
 typeAlias(Client cntxt, int tpe)
@@ -779,17 +777,18 @@ typeAlias(Client cntxt, int tpe)
        int t;
 
        if (tpe != TYPE_any)
-               return -1;
+               return 0;
        if (currChar(cntxt) == TMPMARKER) {
                nextChar(cntxt);
                t = currChar(cntxt) - '0';
-               if (t <= 0 || t > 9)
-                       parseError(cntxt, "[1-9] expected\n");
-               else
+               if (t <= 0 || t > 3) {
+                       parseError(cntxt, "[1-3] expected\n");
+                       return -1;
+               } else
                        nextChar(cntxt);
                return t;
        }
-       return -1;
+       return 0;
 }
 
 /*
@@ -835,6 +834,8 @@ parseTypeId(Client cntxt)
                if (currChar(cntxt) == ':') {
                        tt = simpleTypeId(cntxt);
                        kt = typeAlias(cntxt, tt);
+                       if (kt < 0)
+                               return kt;
                } else {
                        parseError(cntxt, "':bat[:any]' expected\n");
                        return -1;
@@ -853,6 +854,8 @@ parseTypeId(Client cntxt)
        if (currChar(cntxt) == ':') {
                tt = simpleTypeId(cntxt);
                kt = typeAlias(cntxt, tt);
+               if (kt < 0)
+                       return kt;
                if (kt > 0)
                        setTypeIndex(tt, kt);
                return tt;
@@ -952,6 +955,8 @@ binding(Client cntxt, MalBlkPtr curBlk, 
                        if (varid < 0)
                                return curInstr;
                        type = typeElm(cntxt, TYPE_any);
+                       if (type < 0)
+                               return curInstr;
                        if (isPolymorphic(type))
                                setPolymorphic(curInstr, type, TRUE);
                        setVarType(curBlk, varid, type);
diff --git a/monetdb5/mal/mal_prelude.c b/monetdb5/mal/mal_prelude.c
--- a/monetdb5/mal/mal_prelude.c
+++ b/monetdb5/mal/mal_prelude.c
@@ -224,6 +224,7 @@ makeArgument(MalBlkPtr mb, const mel_arg
        return MAL_SUCCEED;
 }
 
+//static int max_index = 0;
 static str
 addFunctions(mel_func *fcn)
 {
@@ -292,10 +293,14 @@ addFunctions(mel_func *fcn)
                                return msg;
                        }
                        sig = pushReturn(mb, sig, idx);
-                       int tpe = TYPE_any;
+                       int tpe = getVarType(mb, idx);
                        if (a->nr > 0) {
-                               if (a->isbat)
-                                       tpe = newBatType(tpe);
+                               /*
+                               if (a->nr > max_index) {
+                                       max_index=a->nr;
+                                       printf("%s %d \n", fcn->fcn, a->nr);
+                               }
+                               */
                                setPolymorphic(sig, tpe, TRUE);
                        }
                        if (a->vargs) {
@@ -313,10 +318,14 @@ addFunctions(mel_func *fcn)
                                return msg;
                        }
                        sig = pushArgument(mb, sig, idx);
-                       int tpe = TYPE_any;
+                       int tpe = getVarType(mb, idx);
                        if (a->nr > 0) {
-                               if (a->isbat)
-                                       tpe = newBatType(tpe);
+                               /*
+                               if (a->nr > max_index) {
+                                       max_index=a->nr;
+                                       printf("%s %d \n", fcn->fcn, a->nr);
+                               }
+                               */
                                setPolymorphic(sig, tpe, TRUE);
                        }
                        if (a->vargs) {
@@ -425,10 +434,14 @@ melFunction(bool command, const char *mo
                        return MEL_ERR;
                }
                sig = pushReturn(mb, sig, idx);
-               int tpe = TYPE_any;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to