Changeset: 71c9c7728593 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=71c9c7728593
Branch: default
Log Message:

Merge with Oct2020 branch.


diffs (truncated from 670 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -647,8 +647,8 @@ stdout of test 'MAL-signatures` in direc
 [ "algebra",   "outerjoin",    "command algebra.outerjoin(X_1:bat[:any_1], 
X_2:bat[:any_1], X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:lng):bat[:oid] ",   
    "ALGouterjoin1;",       ""      ]
 [ "algebra",   "outerjoin",    "command algebra.outerjoin(X_2:bat[:any_1], 
X_3:bat[:any_1], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",  "ALGouterjoin;",        ""      ]
 [ "algebra",   "project",      "pattern algebra.project(X_1:bat[:any_1], 
X_2:any_3):bat[:any_3] ",     "ALGprojecttail;",      ""      ]
+[ "algebra",   "projection",   "command algebra.projection(X_1:bat[:oid], 
X_2:bat[:any_3], X_3:bat[:any_3]):bat[:any_3] ",     "ALGprojection2;",      "" 
     ]
 [ "algebra",   "projection",   "command algebra.projection(X_1:bat[:oid], 
X_2:bat[:any_3]):bat[:any_3] ",      "ALGprojection;",       ""      ]
-[ "algebra",   "projection2",  "command algebra.projection2(X_1:bat[:oid], 
X_2:bat[:any_3], X_3:bat[:any_3]):bat[:any_3] ",    "ALGprojection2;",      ""  
    ]
 [ "algebra",   "projectionpath",       "pattern 
algebra.projectionpath(X_1:bat[:any]...):bat[:any] ",  "ALGprojectionpath;",   
""      ]
 [ "algebra",   "rangejoin",    "command algebra.rangejoin(X_1:bat[:any_1], 
X_2:bat[:any_1], X_3:bat[:any_1], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, 
X_7:bit, X_8:bit, X_9:bit, X_10:lng):bat[:oid] ",  "ALGrangejoin1;",       ""   
   ]
 [ "algebra",   "rangejoin",    "command algebra.rangejoin(X_2:bat[:any_1], 
X_3:bat[:any_1], X_4:bat[:any_1], X_5:bat[:oid], X_6:bat[:oid], X_7:bit, 
X_8:bit, X_9:bit, X_10:bit, X_11:lng) (X_0:bat[:oid], X_1:bat[:oid]) ",    
"ALGrangejoin;",        ""      ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -760,8 +760,8 @@ stdout of test 'MAL-signatures` in direc
 [ "algebra",   "outerjoin",    "command algebra.outerjoin(X_1:bat[:any_1], 
X_2:bat[:any_1], X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:lng):bat[:oid] ",   
    "ALGouterjoin1;",       ""      ]
 [ "algebra",   "outerjoin",    "command algebra.outerjoin(X_2:bat[:any_1], 
X_3:bat[:any_1], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",  "ALGouterjoin;",        ""      ]
 [ "algebra",   "project",      "pattern algebra.project(X_1:bat[:any_1], 
X_2:any_3):bat[:any_3] ",     "ALGprojecttail;",      ""      ]
+[ "algebra",   "projection",   "command algebra.projection(X_1:bat[:oid], 
X_2:bat[:any_3], X_3:bat[:any_3]):bat[:any_3] ",     "ALGprojection2;",      "" 
     ]
 [ "algebra",   "projection",   "command algebra.projection(X_1:bat[:oid], 
X_2:bat[:any_3]):bat[:any_3] ",      "ALGprojection;",       ""      ]
-[ "algebra",   "projection2",  "command algebra.projection2(X_1:bat[:oid], 
X_2:bat[:any_3], X_3:bat[:any_3]):bat[:any_3] ",    "ALGprojection2;",      ""  
    ]
 [ "algebra",   "projectionpath",       "pattern 
algebra.projectionpath(X_1:bat[:any]...):bat[:any] ",  "ALGprojectionpath;",   
""      ]
 [ "algebra",   "rangejoin",    "command algebra.rangejoin(X_1:bat[:any_1], 
X_2:bat[:any_1], X_3:bat[:any_1], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, 
X_7:bit, X_8:bit, X_9:bit, X_10:lng):bat[:oid] ",  "ALGrangejoin1;",       ""   
   ]
 [ "algebra",   "rangejoin",    "command algebra.rangejoin(X_2:bat[:any_1], 
X_3:bat[:any_1], X_4:bat[:any_1], X_5:bat[:oid], X_6:bat[:oid], X_7:bit, 
X_8:bit, X_9:bit, X_10:bit, X_11:lng) (X_0:bat[:oid], X_1:bat[:oid]) ",    
"ALGrangejoin;",        ""      ]
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -373,18 +373,19 @@ ALGselectNotNil(bat *result, const bat *
                throw(MAL, "algebra.selectNotNil", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
 
        if (!b->tnonil) {
-               BAT *bn, *s;
+               BAT *s;
                s = BATselect(b, NULL, ATOMnilptr(b->ttype), NULL, true, true, 
true);
                if (s) {
-                       bn = BATproject(s, b);
+                       BAT *bn = BATproject(s, b);
                        BBPunfix(s->batCacheid);
+                       if (bn) {
+                               BBPunfix(b->batCacheid);
+                               *result = bn->batCacheid;
+                               BBPkeepref(*result);
+                               return MAL_SUCCEED;
+                       }
                }
                BBPunfix(b->batCacheid);
-               if (bn) {
-                       *result = bn->batCacheid;
-                       BBPkeepref(*result);
-                       return MAL_SUCCEED;
-               }
                throw(MAL, "algebra.selectNotNil", GDK_EXCEPTION);
        }
        /* just pass on the result */
@@ -820,21 +821,28 @@ ALGcrossproduct2(bat *l, bat *r, const b
        return ALGcrossproduct(l, r, left, right, max_one);
 }
 
-str
-ALGprojection(bat *result, const bat *lid, const bat *rid)
+static str
+ALGprojection2(bat *result, const bat *lid, const bat *r1id, const bat *r2id)
 {
-       BAT *left, *right,*bn= NULL;
+       BAT *l, *r1, *r2 = NULL, *bn;
 
-       if ((left = BATdescriptor(*lid)) == NULL) {
+       if ((l = BATdescriptor(*lid)) == NULL) {
                throw(MAL, "algebra.projection", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
        }
-       if ((right = BATdescriptor(*rid)) == NULL) {
-               BBPunfix(left->batCacheid);
+       if ((r1 = BATdescriptor(*r1id)) == NULL) {
+               BBPunfix(l->batCacheid);
                throw(MAL, "algebra.projection", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
        }
-       bn = BATproject(left, right);
-       BBPunfix(left->batCacheid);
-       BBPunfix(right->batCacheid);
+       if (r2id && !is_bat_nil(*r2id) && (r2 = BATdescriptor(*r2id)) == NULL) {
+               BBPunfix(l->batCacheid);
+               BBPunfix(r1->batCacheid);
+               throw(MAL, "algebra.projection", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
+       }
+       bn = BATproject2(l, r1, r2);
+       BBPunfix(l->batCacheid);
+       BBPunfix(r1->batCacheid);
+       if (r2)
+               BBPunfix(r2->batCacheid);
        if (bn == NULL)
                throw(MAL, "algebra.projection", GDK_EXCEPTION);
        *result = bn->batCacheid;
@@ -842,33 +850,10 @@ ALGprojection(bat *result, const bat *li
        return MAL_SUCCEED;
 }
 
-static str
-ALGprojection2(bat *result, const bat *lid, const bat *r1id, const bat *r2id)
+str
+ALGprojection(bat *result, const bat *lid, const bat *rid)
 {
-       BAT *l, *r1, *r2 = NULL, *bn;
-
-       if ((l = BATdescriptor(*lid)) == NULL) {
-               throw(MAL, "algebra.projection2", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       }
-       if ((r1 = BATdescriptor(*r1id)) == NULL) {
-               BBPunfix(l->batCacheid);
-               throw(MAL, "algebra.projection2", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       }
-       if (r2id && !is_bat_nil(*r2id) && (r2 = BATdescriptor(*r2id)) == NULL) {
-               BBPunfix(l->batCacheid);
-               BBPunfix(r1->batCacheid);
-               throw(MAL, "algebra.projection2", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       }
-       bn = BATproject2(l, r1, r2);
-       BBPunfix(l->batCacheid);
-       BBPunfix(r1->batCacheid);
-       if (r2)
-               BBPunfix(r2->batCacheid);
-       if (bn == NULL)
-               throw(MAL, "algegra.projection2", GDK_EXCEPTION);
-       *result = bn->batCacheid;
-       BBPkeepref(*result);
-       return MAL_SUCCEED;
+       return ALGprojection2(result, lid, rid, NULL);
 }
 
 static str
@@ -963,14 +948,25 @@ ALGsort11(bat *result, const bat *bid, c
 }
 
 static str
-ALGcount_bat(lng *result, const bat *bid)
+ALGcountCND_nil(lng *result, const bat *bid, const bat *cnd, const bit 
*ignore_nils)
 {
-       BAT *b;
+       BAT *b, *s = NULL;
 
        if ((b = BATdescriptor(*bid)) == NULL) {
                throw(MAL, "aggr.count", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
        }
-       *result = (lng) BATcount(b);
+       if (cnd && !is_bat_nil(*cnd) && (s = BATdescriptor(*cnd)) == NULL) {
+               BBPunfix(b->batCacheid);
+               throw(MAL, "aggr.count", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
+       }
+       if (*ignore_nils) {
+               *result = (lng) BATcount_no_nil(b, s);
+       } else {
+               struct canditer ci;
+               *result = (lng) canditer_init(&ci, b, s);
+       }
+       if (s)
+               BBPunfix(s->batCacheid);
        BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
@@ -978,72 +974,19 @@ ALGcount_bat(lng *result, const bat *bid
 static str
 ALGcount_nil(lng *result, const bat *bid, const bit *ignore_nils)
 {
-       BAT *b;
-       BUN cnt;
-
-       if ((b = BATdescriptor(*bid)) == NULL) {
-               throw(MAL, "aggr.count", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       }
-       if (*ignore_nils)
-               cnt = BATcount_no_nil(b, NULL);
-       else
-               cnt = BATcount(b);
-       *result = (lng) cnt;
-       BBPunfix(b->batCacheid);
-       return MAL_SUCCEED;
-}
-
-static str
-ALGcount_no_nil(lng *result, const bat *bid)
-{
-       bit ignore_nils = 1;
-
-       return ALGcount_nil(result, bid, &ignore_nils);
+       return ALGcountCND_nil(result, bid, NULL, ignore_nils);
 }
 
 static str
 ALGcountCND_bat(lng *result, const bat *bid, const bat *cnd)
 {
-       BAT *b;
-
-       if ((b = BATdescriptor(*bid)) == NULL) {
-               throw(MAL, "aggr.count", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       }
-       if (*cnd) {
-               struct canditer ci;
-               BAT *s;
-               if ((s = BATdescriptor(*cnd)) == NULL) {
-                       BBPunfix(b->batCacheid);
-                       throw(MAL, "aggr.count", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-               }
-               *result = (lng) canditer_init(&ci, b, s);
-               BBPunfix(s->batCacheid);
-       } else
-               *result = (lng) BATcount(b);
-       BBPunfix(b->batCacheid);
-       return MAL_SUCCEED;
+       return ALGcountCND_nil(result, bid, cnd, &(bit){0});
 }
 
 static str
-ALGcountCND_nil(lng *result, const bat *bid, const bat *cnd, const bit 
*ignore_nils)
+ALGcount_bat(lng *result, const bat *bid)
 {
-       BAT *b, *s = NULL;
-
-       if (!*ignore_nils)
-               return ALGcountCND_bat(result, bid, cnd);
-       if (*cnd && (s = BATdescriptor(*cnd)) == NULL) {
-               throw(MAL, "aggr.count", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       }
-       if ((b = BATdescriptor(*bid)) == NULL) {
-               if (s)
-                       BBPunfix(s->batCacheid);
-               throw(MAL, "aggr.count", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       }
-       *result = (lng) BATcount_no_nil(b, s);
-       BBPunfix(b->batCacheid);
-       if (s)
-               BBPunfix(s->batCacheid);
-       return MAL_SUCCEED;
+       return ALGcountCND_nil(result, bid, NULL, &(bit){0});
 }
 
 static str
@@ -1053,6 +996,12 @@ ALGcountCND_no_nil(lng *result, const ba
 }
 
 static str
+ALGcount_no_nil(lng *result, const bat *bid)
+{
+       return ALGcountCND_nil(result, bid, NULL, &(bit){1});
+}
+
+static str
 ALGslice(bat *ret, const bat *bid, const lng *start, const lng *end)
 {
        BAT *b, *bn = NULL;
@@ -1449,7 +1398,7 @@ mel_func algebra_init_funcs[] = {
  command("algebra", "fetch", ALGfetchoid, false, "Returns the value of the BUN 
at x-th position with 0 <= x < b.count", args(1,3, 
argany("",1),batargany("b",1),arg("x",oid))),
  pattern("algebra", "project", ALGprojecttail, false, "Fill the tail with a 
constant", args(1,3, batargany("",3),batargany("b",1),argany("v",3))),
  command("algebra", "projection", ALGprojection, false, "Project left input 
onto right input.", args(1,3, 
batargany("",3),batarg("left",oid),batargany("right",3))),
- command("algebra", "projection2", ALGprojection2, false, "Project left input 
onto right inputs which should be consecutive.", args(1,4, 
batargany("",3),batarg("left",oid),batargany("right1",3),batargany("right2",3))),
+ command("algebra", "projection", ALGprojection2, false, "Project left input 
onto right inputs which should be consecutive.", args(1,4, 
batargany("",3),batarg("left",oid),batargany("right1",3),batargany("right2",3))),
  command("algebra", "copy", ALGcopy, false, "Returns physical copy of a BAT.", 
args(1,2, batargany("",1),batargany("b",1))),
  command("algebra", "exist", ALGexist, false, "Returns whether 'val' occurs in 
b.", args(1,3, arg("",bit),batargany("b",1),argany("val",1))),
  command("algebra", "select", ALGselect1, false, "Select all head values for 
which the tail value is in range.\nInput is a dense-headed BAT, output is a 
dense-headed BAT with in\nthe tail the head value of the input BAT for which 
the tail value\nis between the values low and high (inclusive if li 
respectively\nhi is set).  The output BAT is sorted on the tail value.  If 
low\nor high is nil, the boundary is not considered (effectively - and\n+ 
infinity).  If anti is set, the result is the complement.  Nil\nvalues in the 
tail are never matched, unless low=nil, high=nil,\nli=1, hi=1, anti=0.  All 
non-nil values are returned if low=nil,\nhigh=nil, and li, hi are not both 1, 
or anti=1.\nNote that the output is suitable as second input for the 
other\nversion of this function.", args(1,7, 
batarg("",oid),batargany("b",1),argany("low",1),argany("high",1),arg("li",bit),arg("hi",bit),arg("anti",bit))),
diff --git a/monetdb5/modules/kernel/algebra.mal 
b/monetdb5/modules/kernel/algebra.mal
--- a/monetdb5/modules/kernel/algebra.mal
+++ b/monetdb5/modules/kernel/algebra.mal
@@ -27,7 +27,7 @@ command projection( left:bat[:oid], righ
 address ALGprojection
 comment "Project left input onto right input.";
 
-command projection2( left:bat[:oid], right1:bat[:any_3], right2:bat[:any_3] ) 
:bat[:any_3]
+command projection( left:bat[:oid], right1:bat[:any_3], right2:bat[:any_3] ) 
:bat[:any_3]
 address ALGprojection2
 comment "Project left input onto right inputs which should be consecutive.";
 
diff --git a/sql/backends/monet5/sql_time.c b/sql/backends/monet5/sql_time.c
--- a/sql/backends/monet5/sql_time.c
+++ b/sql/backends/monet5/sql_time.c
@@ -117,7 +117,10 @@ hge shift, hge divider, hge multiplier
 lng shift, lng divider, lng multiplier
 #endif
 ) {
-       daytime d = daytime_add_usec(daytime_create(0, 0, 0, 0), (next % 
(24*60*60*1000)) * 1000);
+       lng usec = (next % (24*60*60*1000)) * 1000;
+       if (usec < 0) /* for negative intervals add the complement */
+               usec = DAY_USEC - (-usec);
+       daytime d = daytime_add_usec(daytime_create(0, 0, 0, 0), usec);
        assert(!is_daytime_nil(d));
        return daytime_2time_daytime_imp(d, shift, divider, multiplier);
 }
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -919,11 +919,6 @@ order_joins(visitor *v, list *rels, list
                        ln = list_find(n_rels, cje->l, (fcmp)&rel_has_exp);
                        rn = list_find(n_rels, cje->r, (fcmp)&rel_has_exp);
 
-                       if (ln || rn) {
-                               /* remove the expression from the lists */
-                               list_remove_data(sdje, cje);
-                               list_remove_data(exps, cje);
-                       }
                        if (ln && rn) {
                                assert(0);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to