Changeset: c8f0f97a3a0b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c8f0f97a3a0b
Branch: default
Log Message:
Merge with Jan2022 branch.
diffs (truncated from 970 to 300 lines):
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -1942,6 +1942,7 @@ dump_table_alters(Mapi mid, const char *
}
rc = 0; /* success */
bailout:
+ free(query);
free(s);
free(t);
mapi_close_handle(hdl); /* may be NULL */
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3824,7 +3824,21 @@ BATmin_skipnil(BAT *b, void *aggr, bit s
if (is_oid_nil(pos)) {
res = ATOMnilptr(b->ttype);
} else {
- res = BUNtail(bi, pos - b->hseqbase);
+ bi.minpos = pos - b->hseqbase;
+ res = BUNtail(bi, bi.minpos);
+ MT_lock_set(&b->theaplock);
+ if (bi.count == BATcount(b) && bi.h == b->theap)
+ b->tminpos = bi.minpos;
+ MT_lock_unset(&b->theaplock);
+ bat pbid = VIEWtparent(b);
+ if (pbid) {
+ BAT *pb = BBP_cache(pbid);
+ MT_lock_set(&pb->theaplock);
+ if (bi.count == BATcount(pb) &&
+ bi.h == pb->theap)
+ pb->tminpos = bi.minpos;
+ MT_lock_unset(&pb->theaplock);
+ }
}
}
if (aggr == NULL) {
@@ -3964,7 +3978,21 @@ BATmax_skipnil(BAT *b, void *aggr, bit s
if (is_oid_nil(pos)) {
res = ATOMnilptr(b->ttype);
} else {
- res = BUNtail(bi, pos - b->hseqbase);
+ bi.maxpos = pos - b->hseqbase;
+ res = BUNtail(bi, bi.maxpos);
+ MT_lock_set(&b->theaplock);
+ if (bi.count == BATcount(b) && bi.h == b->theap)
+ b->tmaxpos = bi.maxpos;
+ MT_lock_unset(&b->theaplock);
+ bat pbid = VIEWtparent(b);
+ if (pbid) {
+ BAT *pb = BBP_cache(pbid);
+ MT_lock_set(&pb->theaplock);
+ if (bi.count == BATcount(pb) &&
+ bi.h == pb->theap)
+ pb->tmaxpos = bi.maxpos;
+ MT_lock_unset(&pb->theaplock);
+ }
}
}
if (aggr == NULL) {
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2924,11 +2924,30 @@ BATcount_no_nil(BAT *b, BAT *s)
}
break;
}
- if (cnt == BATcount(b)) {
- /* we learned something */
- b->tnonil = true;
- assert(!b->tnil);
- b->tnil = false;
+ if (cnt == bi.count) {
+ MT_lock_set(&b->theaplock);
+ if (cnt == BATcount(b) && bi.h == b->theap) {
+ /* we learned something */
+ b->batDirtydesc = true;
+ b->tnonil = true;
+ assert(!b->tnil);
+ b->tnil = false;
+ }
+ MT_lock_unset(&b->theaplock);
+ bat pbid = VIEWtparent(b);
+ if (pbid) {
+ BAT *pb = BBP_cache(pbid);
+ MT_lock_set(&pb->theaplock);
+ if (cnt == BATcount(pb) &&
+ bi.h == pb->theap &&
+ !pb->tnonil) {
+ pb->batDirtydesc = true;
+ pb->tnonil = true;
+ assert(!pb->tnil);
+ pb->tnil = false;
+ }
+ MT_lock_unset(&pb->theaplock);
+ }
}
bat_iterator_end(&bi);
return cnt;
diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -797,7 +797,7 @@ STRMPappendBitstring(BAT *b, const str s
size_t sizes_offset = (char *)strmp->sizes_base -
strmp->strimps.base;
size_t pairs_offset = (char *)strmp->pairs_base -
strmp->strimps.base;
size_t bitstrings_offset = (char *)strmp->bitstrings_base -
strmp->strimps.base;
- if (HEAPextend(&(strmp->strimps),
(size_t)(extend_factor*BATcount(pb)*sizeof(uint64_t)), false) == GDK_FAIL) {
+ if (HEAPextend(&(strmp->strimps),
(size_t)(extend_factor*BATcount(pb)*sizeof(uint64_t)), false) != GDK_SUCCEED) {
MT_lock_unset(&pb->batIdxLock);
GDKerror("Cannot extend heap\n");
return GDK_FAIL;
diff --git a/gdk/gdk_unique.c b/gdk/gdk_unique.c
--- a/gdk/gdk_unique.c
+++ b/gdk/gdk_unique.c
@@ -273,6 +273,21 @@ BATunique(BAT *b, BAT *s)
TIMEOUT_CHECK(timeoffset,
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed));
}
+ if (BATcount(bn) == bi.count) {
+ /* it turns out all values are distinct */
+ MT_lock_set(&b->theaplock);
+ if (BATcount(b) == bi.count) {
+ /* and the input hasn't changed in the mean
+ * time--the only allowed change being appends;
+ * updates not allowed since the candidate list
+ * covers the complete bat */
+ assert(b->tnokey[0] == 0);
+ assert(b->tnokey[1] == 0);
+ b->tkey = true;
+ b->batDirtydesc = true;
+ }
+ MT_lock_unset(&b->theaplock);
+ }
bat_iterator_end(&bi);
bn->theap->dirty = true;
@@ -281,13 +296,6 @@ BATunique(BAT *b, BAT *s)
bn->tkey = true;
bn->tnil = false;
bn->tnonil = true;
- if (BATcount(bn) == bi.count) {
- /* it turns out all values are distinct */
- assert(b->tnokey[0] == 0);
- assert(b->tnokey[1] == 0);
- b->tkey = true;
- b->batDirtydesc = true;
- }
bn = virtualize(bn);
MT_thread_setalgorithm(algomsg);
TRC_DEBUG(ALGO, "b=" ALGOBATFMT
diff --git a/sql/ChangeLog.Jan2022 b/sql/ChangeLog.Jan2022
--- a/sql/ChangeLog.Jan2022
+++ b/sql/ChangeLog.Jan2022
@@ -1,9 +1,14 @@
# ChangeLog file for sql
# This file is updated with Maddlog
+* Mon Dec 6 2021 Sjoerd Mullender <[email protected]>
+- In previous versions there was no check that the INCREMENT BY value of
+ a SEQUENCE was not zero. During the automatic upgrade of a database,
+ INCREMENT BY values that are zero are set to one.
+
* Tue Nov 9 2021 Pedro Ferreira <[email protected]>
- The method to compute the 'side_effect' effect property was changed
- for SQL functions defined in the backend engine (eg. ``CREATE FUNCTION
+ for SQL functions defined in the backend engine (eg. ``CREATE FUNCTION
... EXTERNAL NAME "module"."function"''). It was changed from being
computed by the SQL layer to the backend engine itself. As a consequence,
the computed 'side_effect' value may be different, thus bringing
diff --git a/sql/backends/monet5/dict.c b/sql/backends/monet5/dict.c
--- a/sql/backends/monet5/dict.c
+++ b/sql/backends/monet5/dict.c
@@ -395,7 +395,7 @@ DICTdecompress(Client cntxt, MalBlkPtr m
bat_destroy(o);
bat_destroy(u);
if (!b)
- throw(SQL, "dict.decompress", SQLSTATE(HY013) "unknown offset
type");
+ throw(SQL, "dict.decompress", GDK_EXCEPTION);
BBPkeepref(*r = b->batCacheid);
return MAL_SUCCEED;
}
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
@@ -1122,7 +1122,7 @@ mvc_restart_seq(Client cntxt, MalBlkPtr
if (is_lng_nil(start))
throw(SQL, "sql.restart", SQLSTATE(HY050) "Cannot (re)start
sequence %s.%s with NULL", sname, seqname);
if (start < seq->minvalue)
- throw(SQL, "sql.restart", SQLSTATE(HY050) "Cannot set sequence
%s.%s start to a value lesser than the minimum ("LLFMT" < "LLFMT")", sname,
seqname, start, seq->minvalue);
+ throw(SQL, "sql.restart", SQLSTATE(HY050) "Cannot set sequence
%s.%s start to a value less than the minimum ("LLFMT" < "LLFMT")", sname,
seqname, start, seq->minvalue);
if (start > seq->maxvalue)
throw(SQL, "sql.restart", SQLSTATE(HY050) "Cannot set sequence
%s.%s start to a value higher than the maximum ("LLFMT" > "LLFMT")", sname,
seqname, start, seq->maxvalue);
switch (sql_trans_sequence_restart(m->session->tr, seq, start)) {
@@ -3770,11 +3770,8 @@ SQLdrop_hash(Client cntxt, MalBlkPtr mb,
const char *tbl = *getArgReference_str(stk, pci, 2);
sql_schema *s;
sql_table *t;
- sql_column *c;
mvc *m = NULL;
str msg;
- BAT *b;
- node *o;
if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL)
return msg;
@@ -3793,11 +3790,17 @@ SQLdrop_hash(Client cntxt, MalBlkPtr mb,
TABLE_TYPE_DESCRIPTION(t->type, t->properties),
t->base.name);
sqlstore *store = m->session->tr->store;
- for (o = ol_first_node(t->columns); o; o = o->next) {
- c = o->data;
- b = store->storage_api.bind_col(m->session->tr, c, RDONLY);
- if (b == NULL)
+ for (node *n = ol_first_node(t->columns); n; n = n->next) {
+ sql_column *c = n->data;
+ BAT *b = NULL, *nb = NULL;
+
+ if (!(b = store->storage_api.bind_col(m->session->tr, c,
RDONLY)))
throw(SQL, "sql.drop_hash", SQLSTATE(HY005) "Cannot
access column descriptor");
+ if (VIEWtparent(b) && (nb = BBP_cache(VIEWtparent(b)))) {
+ BBPunfix(b->batCacheid);
+ if (!(b = BATdescriptor(nb->batCacheid)))
+ throw(SQL, "sql.drop_hash", SQLSTATE(HY005)
"Cannot access column descriptor");
+ }
HASHdestroy(b);
BBPunfix(b->batCacheid);
}
diff --git a/sql/backends/monet5/sql_cast.c b/sql/backends/monet5/sql_cast.c
--- a/sql/backends/monet5/sql_cast.c
+++ b/sql/backends/monet5/sql_cast.c
@@ -198,7 +198,7 @@ SQLstr_cast(Client cntxt, MalBlkPtr mb,
}
#define SQLstr_cast_str(v, digits) \
- if (digits > 0 && UTF8_strlen(v) > digits) { \
+ if (UTF8_strlen(v) > digits) { \
msg = createException(SQL, "batcalc.str_cast", SQLSTATE(22001)
"value too long for type (var)char(%d)", digits); \
goto bailout1; \
}
@@ -220,7 +220,7 @@ SQLbatstr_cast(Client cntxt, MalBlkPtr m
BUN q;
oid off;
bool nils = false, from_str = EC_VARCHAR(eclass) || tpe == TYPE_str;
- size_t rlen = MAX(str_buf_initial_capacity(eclass, digits),
strlen(str_nil) + 1); /* don't reallocate on str_nil */
+ size_t rlen = 0;
if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL)
return msg;
@@ -234,17 +234,36 @@ SQLbatstr_cast(Client cntxt, MalBlkPtr m
msg = createException(SQL, "batcalc.str", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
goto bailout;
}
+
+ assert(digits >= 0);
+ if (from_str && digits == 0) {
+ if (s) {
+ if (!(dst = BATproject(s, b))) {
+ msg = createException(SQL, "batcalc.str",
GDK_EXCEPTION);
+ goto bailout;
+ }
+ BBPunfix(s->batCacheid);
+ BBPunfix(b->batCacheid);
+ BBPkeepref(*res = dst->batCacheid);
+ } else {
+ BBPkeepref(*res = b->batCacheid);
+ }
+ return MAL_SUCCEED;
+ }
off = b->hseqbase;
q = canditer_init(&ci, b, s);
bi = bat_iterator(b);
- if (from_str && (!sid || is_bat_nil(*sid))) { /* from string case, just
do validation, if right, return */
+ if (from_str && ci.tpe == cand_dense && q == BATcount(b)) { /* from
string case, just do validation, if right, return */
for (BUN i = 0; i < q; i++) {
- str v = (str) BUNtvar(bi, i);
+ oid p = (canditer_next_dense(&ci) - off);
+ str v = (str) BUNtvar(bi, p);
if (!strNil(v))
SQLstr_cast_str(v, digits);
}
+ if (s)
+ BBPunfix(s->batCacheid);
bat_iterator_end(&bi);
BBPkeepref(*res = b->batCacheid);
return MAL_SUCCEED;
@@ -255,6 +274,7 @@ SQLbatstr_cast(Client cntxt, MalBlkPtr m
goto bailout1;
}
+ rlen = MAX(str_buf_initial_capacity(eclass, digits), strlen(str_nil) +
1); /* don't reallocate on str_nil */
assert(rlen > 0);
if (!from_str && !(r = GDKmalloc(rlen))) {
msg = createException(SQL, "batcalc.str_cast", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c
--- a/sql/backends/monet5/sql_cat.c
+++ b/sql/backends/monet5/sql_cat.c
@@ -737,10 +737,28 @@ drop_key(mvc *sql, char *sname, char *tn
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list