Changeset: 706f6a5145f4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/706f6a5145f4
Modified Files:
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_select.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_statement.c
sql/server/sql_atom.c
sql/storage/bat/bat_storage.c
Branch: nilmask
Log Message:
small improvements to the nil-mask.
diffs (227 lines):
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1224,7 +1224,7 @@ BUNappendmulti(BAT *b, const void *value
if (b->thash) {
HASHappend_locked(b, p, t);
}
- if (atomcmp(t, atomnil) != 0) {
+ if (atomnil && atomcmp(t, atomnil) != 0) {
if (p == 0) {
bi.minpos = bi.maxpos = 0;
minvalp = maxvalp = t;
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2814,7 +2814,7 @@ BATconstant(oid hseq, int tailtype, cons
lng t0 = 0;
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
- if (v == NULL)
+ if (n && v == NULL)
return NULL;
bn = COLnew(hseq, tailtype, n, role);
if (bn != NULL && n > 0) {
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1198,10 +1198,11 @@ BATrange(BATiter *bi, const void *tl, co
BAT *pb = NULL;
int c;
int (*atomcmp) (const void *, const void *) = ATOMcompare(bi->type);
+ const void *nilp = ATOMnilptr(bi->type);
- if (tl && (*atomcmp)(tl, ATOMnilptr(bi->type)) == 0)
+ if (tl && nilp && (*atomcmp)(tl, nilp) == 0)
tl = NULL;
- if (th && (*atomcmp)(th, ATOMnilptr(bi->type)) == 0)
+ if (th && nilp && (*atomcmp)(th, nilp) == 0)
th = NULL;
if (tl == NULL && th == NULL)
return range_contains; /* looking for everything */
@@ -1522,7 +1523,7 @@ BATselect(BAT *b, BAT *s, const void *tl
ti = lval;
lval = hval;
hval = ti;
- lnil = ATOMcmp(t, tl, nil) == 0;
+ lnil = nil && ATOMcmp(t, tl, nil) == 0;
anti = false;
TRC_DEBUG(ALGO, "b=" ALGOBATFMT
",s=" ALGOOPTBATFMT ",anti=%d "
@@ -1754,7 +1755,7 @@ BATselect(BAT *b, BAT *s, const void *tl
* persistent and the total size wouldn't be too large; check
* for existence of hash last since that may involve I/O */
if (equi) {
- double cost = joincost(b, 1, &ci, &havehash, &phash, NULL);
+ double cost = (b->ttype > TYPE_msk)?joincost(b, 1, &ci,
&havehash, &phash, NULL):0;
if (cost > 0 && cost < ci.ncand) {
wanthash = true;
if (havehash) {
@@ -2213,7 +2214,7 @@ BATthetaselect(BAT *b, BAT *s, const voi
BATcheck(op, NULL);
nil = ATOMnilptr(b->ttype);
- if (ATOMcmp(b->ttype, val, nil) == 0)
+ if (nil && ATOMcmp(b->ttype, val, nil) == 0)
return BATdense(0, 0, 0);
if (op[0] == '=' && ((op[1] == '=' && op[2] == 0) || op[1] == 0)) {
/* "=" or "==" */
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -2511,7 +2511,7 @@ mvc_result_set_wrap( Client cntxt, MalBl
colname = BUNtvar(iteratr,o);
tpename = BUNtvar(itertpe,o);
b = BATdescriptor(bid);
- if (b && b->ttype == TYPE_msk) {
+ if (b && (b->ttype == TYPE_msk || (b->ttype == TYPE_void &&
strcmp(tpename, "oid") != 0))) { /* expect mask before value */
bid = *getArgReference_bat(stk,pci,++i);
cand = b;
b = BATdescriptor(bid);
diff --git a/sql/backends/monet5/sql_statement.c
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -1762,21 +1762,40 @@ stmt_uselect(backend *be, stmt *op1, stm
assert(cmptype == cmp_equal || cmptype == cmp_notequal);
if (cmptype == cmp_notequal)
anti = !anti;
- q = newStmtArgs(mb, algebraRef, selectRef, 9);
- if (q == NULL)
- goto bailout;
- q = pushArgument(mb, q, l);
- if (sub && !op1->cand) {
- q = pushArgument(mb, q, sub->nr);
- } else {
- assert(!sub || op1->cand == sub);
- sub = NULL;
+ if (!op1->cand || !sub || op1->cand == sub) {
+ q = newStmtArgs(mb, algebraRef, selectRef, 9);
+ if (q == NULL)
+ goto bailout;
+ q = pushArgument(mb, q, l);
+ if (sub && !op1->cand) {
+ q = pushArgument(mb, q, sub->nr);
+ } else {
+ assert(!sub || op1->cand == sub);
+ sub = NULL;
+ }
+ q = pushArgument(mb, q, r);
+ q = pushArgument(mb, q, r);
+ q = pushBit(mb, q, TRUE);
+ q = pushBit(mb, q, TRUE);
+ q = pushBit(mb, q, anti);
+ } else { /* nonull use nil mask */
+ stmt *cands = op1->cand;
+ q = newStmtArgs(mb, algebraRef, selectRef, 9);
+ if (q == NULL)
+ goto bailout;
+ q = pushArgument(mb, q, cands->nr);
+ if (sub) {
+ q = pushArgument(mb, q, sub->nr);
+ } else {
+ sub = NULL;
+ }
+ q = pushMsk(mb, q, TRUE); /* mask true */
+ q = pushMsk(mb, q, TRUE); /* mask true */
+
+ q = pushBit(mb, q, TRUE);
+ q = pushBit(mb, q, TRUE);
+ q = pushBit(mb, q, anti);
}
- q = pushArgument(mb, q, r);
- q = pushArgument(mb, q, r);
- q = pushBit(mb, q, TRUE);
- q = pushBit(mb, q, TRUE);
- q = pushBit(mb, q, anti);
} else {
q = newStmt(mb, algebraRef, thetaselectRef);
if (q == NULL)
@@ -3307,6 +3326,8 @@ dump_header(mvc *sql, MalBlkPtr mb, list
tpePtr = pushStr(mb, tpePtr, (t->type->localtype ==
TYPE_void ? "char" : t->type->base.name));
lenPtr = pushInt(mb, lenPtr, t->digits);
scalePtr = pushInt(mb, scalePtr, t->scale);
+ if (c->cand)
+ list = pushArgument(mb,list,c->cand->nr);
list = pushArgument(mb,list,c->nr);
} else
return NULL;
diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -269,9 +269,8 @@ atom_general(allocator *sa, sql_subtype
a->data.vtype = tpe->type->localtype;
assert(a->data.vtype >= 0);
+ int type = a->data.vtype;
if (!strNil(val)) {
- int type = a->data.vtype;
-
if (type == TYPE_str) {
a->data.len = strLen(val);
a->data.val.sval = sa_alloc(sa, a->data.len);
@@ -287,9 +286,10 @@ atom_general(allocator *sa, sql_subtype
} else {
ptr p = NULL;
ssize_t res = ATOMfromstr(type, &p, &a->data.len, val,
false);
+ const void *nil = ATOMnilptr(type);
/* no result or nil means error (SQL has NULL not nil)
*/
- if (res < 0 || !p || ATOMcmp(type, p, ATOMnilptr(type))
== 0) {
+ if (res < 0 || !p || (nil && ATOMcmp(type, p, nil) ==
0)) {
GDKfree(p);
GDKclrerr();
return NULL;
@@ -312,7 +312,9 @@ atom_general(allocator *sa, sql_subtype
GDKfree(p);
}
} else {
- VALset(&a->data, a->data.vtype, (ptr)
ATOMnilptr(a->data.vtype));
+ const void *nil = ATOMnilptr(type);
+ if (nil)
+ VALset(&a->data, a->data.vtype, (ptr) nil);
a->isnull = 1;
}
return a;
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -1940,13 +1940,15 @@ dup_cs(sql_trans *tr, column_storage *oc
if (temp) {
cs->bid = temp_copy(cs->bid, true, false);
- if (cs->bid == BID_NIL)
+ if (cs->ebid)
+ cs->ebid = temp_copy(cs->ebid, true, false);
+ if (cs->bid == BID_NIL || (ocs->ebid && cs->ebid == BID_NIL))
return LOG_ERR;
} else {
temp_dup(cs->bid);
+ if (cs->ebid)
+ temp_dup(cs->ebid);
}
- if (cs->ebid)
- temp_dup(cs->ebid);
cs->ucnt = 0;
cs->uibid = e_bat(TYPE_oid);
cs->uvbid = e_bat(type);
@@ -3096,6 +3098,12 @@ log_create_delta(sql_trans *tr, sql_delt
bat_destroy(b);
if(res != LOG_OK)
return res;
+ if (bat->cs.ebid) {
+ BAT *b = temp_descriptor(bat->cs.ebid);
+ bat_set_access(b, BAT_READ);
+ ok = log_bat_persists(store->logger, b, -id);
+ bat_destroy(b);
+ }
return ok == GDK_SUCCEED ? LOG_OK : LOG_ERR;
}
@@ -3162,7 +3170,6 @@ create_col(sql_trans *tr, sql_column *c)
bat->cs.ts = tr->ts;
ok = load_cs(tr, &bat->cs, type, c->base.id);
if (nonull) {
- assert(0);
int bid = log_find_bat(store->logger, -c->base.id);
if (bid <= 0)
return LOG_ERR;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]