Changeset: 9d8e4b6007ac for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9d8e4b6007ac
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        gdk/gdk_analytic_func.c
        gdk/gdk_calc.c
        monetdb5/modules/mal/01_batcalc.mal
        monetdb5/modules/mal/01_batcalc.mal.sh
        monetdb5/modules/mal/batcalc.c
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_statement.c
        sql/server/rel_optimizer.c
        sql/test/SQLancer/Tests/sqlancer03.sql
        sql/test/SQLancer/Tests/sqlancer03.stable.out
Branch: default
Log Message:

merged


diffs (truncated from 570 to 300 lines):

diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c
--- a/gdk/gdk_analytic_func.c
+++ b/gdk/gdk_analytic_func.c
@@ -66,10 +66,7 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p
        BUN i, cnt = BATcount(b);
        bit *restrict rb = (bit *) Tloc(r, 0), *restrict np = p ? (bit *) 
Tloc(p, 0) : NULL;
 
-       switch (tpe) {
-       case TYPE_bit:
-               ANALYTICAL_DIFF_IMP(bit);
-               break;
+       switch (ATOMbasetype(tpe)) {
        case TYPE_bte:
                ANALYTICAL_DIFF_IMP(bte);
                break;
@@ -299,10 +296,7 @@ GDKanalyticalfirst(BAT *r, BAT *b, BAT *
        start = (lng *) Tloc(s, 0);
        end = (lng *) Tloc(e, 0);
 
-       switch (tpe) {
-       case TYPE_bit:
-               ANALYTICAL_FIRST_IMP(bit);
-               break;
+       switch (ATOMbasetype(tpe)) {
        case TYPE_bte:
                ANALYTICAL_FIRST_IMP(bte);
                break;
@@ -371,10 +365,7 @@ GDKanalyticallast(BAT *r, BAT *b, BAT *s
        start = (lng *) Tloc(s, 0);
        end = (lng *) Tloc(e, 0);
 
-       switch (tpe) {
-       case TYPE_bit:
-               ANALYTICAL_LAST_IMP(bit);
-               break;
+       switch (ATOMbasetype(tpe)) {
        case TYPE_bte:
                ANALYTICAL_LAST_IMP(bte);
                break;
@@ -543,10 +534,7 @@ GDKanalyticalnthvalue(BAT *r, BAT *b, BA
                default:
                        goto nosupport;
                }
-               switch (tp1) {
-               case TYPE_bit:
-                       ANALYTICAL_NTHVALUE_IMP_SINGLE_FIXED(bit);
-                       break;
+               switch (ATOMbasetype(tp1)) {
                case TYPE_bte:
                        ANALYTICAL_NTHVALUE_IMP_SINGLE_FIXED(bte);
                        break;
@@ -589,10 +577,7 @@ GDKanalyticalnthvalue(BAT *r, BAT *b, BA
                }
                }
        } else {
-               switch (tp1) {
-               case TYPE_bit:
-                       ANALYTICAL_NTHVALUE_CALC_FIXED(bit);
-                       break;
+               switch (ATOMbasetype(tp1)) {
                case TYPE_bte:
                        ANALYTICAL_NTHVALUE_CALC_FIXED(bte);
                        break;
@@ -721,10 +706,7 @@ GDKanalyticallag(BAT *r, BAT *b, BAT *p,
 
        assert(default_value);
 
-       switch (tpe) {
-       case TYPE_bit:
-               ANALYTICAL_LAG_IMP(bit);
-               break;
+       switch (ATOMbasetype(tpe)) {
        case TYPE_bte:
                ANALYTICAL_LAG_IMP(bte);
                break;
@@ -864,10 +846,7 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p
 
        assert(default_value);
 
-       switch (tpe) {
-       case TYPE_bit:
-               ANALYTICAL_LEAD_IMP(bit);
-               break;
+       switch (ATOMbasetype(tpe)) {
        case TYPE_bte:
                ANALYTICAL_LEAD_IMP(bte);
                break;
@@ -972,10 +951,7 @@ GDKanalytical##OP(BAT *r, BAT *b, BAT *s
        start = (lng*)Tloc(s, 0);                                       \
        end = (lng*)Tloc(e, 0);                                         \
                                                                        \
-       switch (tpe) {                                                  \
-       case TYPE_bit:                                                  \
-               ANALYTICAL_MIN_MAX_CALC(bit, IMP);                      \
-               break;                                                  \
+       switch (ATOMbasetype(tpe)) {                            \
        case TYPE_bte:                                                  \
                ANALYTICAL_MIN_MAX_CALC(bte, IMP);                      \
                break;                                                  \
@@ -1068,10 +1044,7 @@ GDKanalyticalcount(BAT *r, BAT *b, BAT *
                for (; i < cnt; i++, rb++)
                        *rb = (end[i] > start[i]) ? (end[i] - start[i]) : 0;
        } else {
-               switch (tpe) {
-               case TYPE_bit:
-                       ANALYTICAL_COUNT_NO_NIL_FIXED_SIZE_IMP(bit);
-                       break;
+               switch (ATOMbasetype(tpe)) {
                case TYPE_bte:
                        ANALYTICAL_COUNT_NO_NIL_FIXED_SIZE_IMP(bte);
                        break;
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -13207,9 +13207,6 @@ BATcalcbetweenbatcst(BAT *b, BAT *lo, co
        BATcheck(b, NULL);
        BATcheck(lo, NULL);
 
-       if (checkbats(b, lo, __func__) != GDK_SUCCEED)
-               return NULL;
-
        if (ATOMbasetype(b->ttype) != ATOMbasetype(hi->vtype)) {
                GDKerror("incompatible input types.\n");
                return NULL;
diff --git a/monetdb5/modules/mal/01_batcalc.mal 
b/monetdb5/modules/mal/01_batcalc.mal
--- a/monetdb5/modules/mal/01_batcalc.mal
+++ b/monetdb5/modules/mal/01_batcalc.mal
@@ -28674,6 +28674,30 @@ comment "B between V1 and V2 (or vice ve
 pattern 
between(b:bat[:any_1],v1:any_1,v2:any_1,s:bat[:oid],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
 address CMDbatBETWEEN
 comment "B between V1 and V2 (or vice versa) with candidate list";
+pattern 
between(b:bat[:any_1],v1:bat[:any_1],v2:bat[:any_1],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:bat[:any_1],v2:bat[:any_1],s:bat[:oid],s1:bat[:oid],s2:bat[:oid],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with candidate list and 
conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:bat[:any_1],v2:any_1,r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:bat[:any_1],v2:any_1,s:bat[:oid],s1:bat[:oid],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with candidate list and 
conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:any_1,v2:bat[:any_1],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:any_1,v2:bat[:any_1],s:bat[:oid],s2:bat[:oid],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with candidate list and 
conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:any_1,v2:any_1,r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:any_1,v2:any_1,s:bat[:oid],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with candidate list and 
conditional execution bat";
 
 
 pattern avg(b:bat[:bte]) :dbl
diff --git a/monetdb5/modules/mal/01_batcalc.mal.sh 
b/monetdb5/modules/mal/01_batcalc.mal.sh
--- a/monetdb5/modules/mal/01_batcalc.mal.sh
+++ b/monetdb5/modules/mal/01_batcalc.mal.sh
@@ -813,6 +813,30 @@ comment "B between V1 and V2 (or vice ve
 pattern 
between(b:bat[:any_1],v1:any_1,v2:any_1,s:bat[:oid],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
 address CMDbatBETWEEN
 comment "B between V1 and V2 (or vice versa) with candidate list";
+pattern 
between(b:bat[:any_1],v1:bat[:any_1],v2:bat[:any_1],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:bat[:any_1],v2:bat[:any_1],s:bat[:oid],s1:bat[:oid],s2:bat[:oid],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with candidate list and 
conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:bat[:any_1],v2:any_1,r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:bat[:any_1],v2:any_1,s:bat[:oid],s1:bat[:oid],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with candidate list and 
conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:any_1,v2:bat[:any_1],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:any_1,v2:bat[:any_1],s:bat[:oid],s2:bat[:oid],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with candidate list and 
conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:any_1,v2:any_1,r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with conditional execution bat";
+pattern 
between(b:bat[:any_1],v1:any_1,v2:any_1,s:bat[:oid],r:bat[:bit],sym:bit,linc:bit,hinc:bit,nils_false:bit,anti:bit)
 :bat[:bit]
+address CMDbatBETWEEN
+comment "B between V1 and V2 (or vice versa) with candidate list and 
conditional execution bat";
 
 EOF
 echo
diff --git a/monetdb5/modules/mal/batcalc.c b/monetdb5/modules/mal/batcalc.c
--- a/monetdb5/modules/mal/batcalc.c
+++ b/monetdb5/modules/mal/batcalc.c
@@ -1076,9 +1076,9 @@ CMDbatBETWEEN(Client cntxt, MalBlkPtr mb
 {
        bat bid;
        BAT *bn, *b = NULL, *lo = NULL, *hi = NULL, *s = NULL, *slo = NULL, 
*shi = NULL, *r = NULL;
-       int tp1, tp2, tp3;
+       int tp1, tp2, tp3, tp;
        int bc = 0;                                     /* number of extra BAT 
arguments */
-       bool symmetric, linc, hinc, nils_false, anti;
+       bool symmetric, linc, hinc, nils_false, anti, has_cand = false;
 
        (void) cntxt;
        (void) mb;
@@ -1104,42 +1104,63 @@ CMDbatBETWEEN(Client cntxt, MalBlkPtr mb
                if (hi == NULL)
                        goto bailout;
        }
-       if (isaBatType(getArgType(mb, pci, 4))) {
+       tp = getArgType(mb, pci, 4);
+       if (tp == TYPE_bat || isaBatType(tp)) {
                bid = *getArgReference_bat(stk, pci, 4);
-               s = BATdescriptor(bid);
-               if (s == NULL)
-                       goto bailout;
-               if (s->ttype == TYPE_bit) {
-                       r = s;
-                       s = NULL;
+               has_cand = true;
+               if (!is_bat_nil(bid)) {
+                       s = BATdescriptor(bid);
+                       if (s == NULL)
+                               goto bailout;
+                       if (s->ttype == TYPE_bit) {
+                               r = s;
+                               s = NULL;
+                               has_cand = false;
+                       }
                }
                bc++;
        }
-       if (s != NULL && lo) {
-               if (!isaBatType(getArgType(mb, pci, 4 + bc)))
-                       goto bailout;
-               bid = *getArgReference_bat(stk, pci, 4 + bc);
-               slo = BATdescriptor(bid);
-               if (slo == NULL)
-                       goto bailout;
-               bc++;
+       if (has_cand && lo) {
+               tp = getArgType(mb, pci, 4 + bc);
+               if (tp == TYPE_bat || isaBatType(tp)) {
+                       bid = *getArgReference_bat(stk, pci, 4 + bc);
+                       if (!is_bat_nil(bid)) {
+                               slo = BATdescriptor(bid);
+                               if (slo == NULL)
+                                       goto bailout;
+                       }
+                       bc++;
+               } else {
+                       if (s == NULL) {
+                               /* apparently the extra bat was a NIL 
conditional
+                                * execution bat */
+                               has_cand = false;
+                       } else
+                               goto bailout;
+               }
        }
-       if (s != NULL && hi) {
-               if (!isaBatType(getArgType(mb, pci, 4 + bc)))
+       if (has_cand && hi) {
+               tp = getArgType(mb, pci, 4 + bc);
+               if (tp != TYPE_bat && !isaBatType(tp))
                        goto bailout;
                bid = *getArgReference_bat(stk, pci, 4 + bc);
-               shi = BATdescriptor(bid);
-               if (shi == NULL)
-                       goto bailout;
+               if (!is_bat_nil(bid)) {
+                       shi = BATdescriptor(bid);
+                       if (shi == NULL)
+                               goto bailout;
+               }
                bc++;
        }
-       if (r == NULL && isaBatType(getArgType(mb, pci, 4 + bc))) {
+       tp = getArgType(mb, pci, 4 + bc);
+       if (r == NULL && (tp == TYPE_bat || isaBatType(tp))) {
                bid = *getArgReference_bat(stk, pci, 4 + bc);
-               r = BATdescriptor(bid);
-               if (r == NULL)
-                       goto bailout;
-               if (r->ttype != TYPE_bit)
-                       goto bailout;
+               if (!is_bat_nil(bid)) {
+                       r = BATdescriptor(bid);
+                       if (r == NULL)
+                               goto bailout;
+                       if (r->ttype != TYPE_bit)
+                               goto bailout;
+               }
                bc++;
        }
 
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to