Changeset: 8a610fb9d7ae for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8a610fb9d7ae
Modified Files:
sql/backends/monet5/sql.c
sql/backends/monet5/sql_rank.c
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
Branch: default
Log Message:
Merged with Jul2021
diffs (truncated from 5837 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
@@ -1263,7 +1263,7 @@ describe_table(Mapi mid, const char *sch
/* the table is a real table */
mnstr_printf(toConsole, "CREATE %sTABLE ",
type == 3 ? "MERGE " :
- /*type == 4 ? "STREAM " : */
+ type == 4 ? "STREAM " :
type == 5 ? "REMOTE " :
type == 6 ? "REPLICA " :
"");
diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c
--- a/gdk/gdk_tracer.c
+++ b/gdk/gdk_tracer.c
@@ -525,7 +525,7 @@ GDKtracer_log(const char *file, const ch
fprintf(stderr, "#%s%s%s: %s: %s%s%s%s\n",
add_ts ? ts : "",
add_ts ? ": " : "",
- MT_thread_getname(), func, GDKERROR,
+ MT_thread_getname(), func, level == M_WARNING ?
GDKWARNING : GDKERROR,
msg, syserr ? ": " : "",
syserr ? syserr : "");
if (active_tracer == NULL || active_tracer == stderr)
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
@@ -5648,7 +5648,7 @@ check_for_foreign_key_references(mvc *sq
continue;
k = fk;
/* make sure it is not a self
referencing key */
- if (k->t != t && !cascade) {
+ if (k->t != t && !cascade &&
isTable(t)) {
node *n =
ol_first_node(t->columns);
sql_column *c = n->data;
size_t n_rows =
store->storage_api.count_col(sql->session->tr, c, 10);
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
@@ -1309,8 +1309,12 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb
return msg;
if ((msg = checkSQLContext(cntxt)) != NULL)
return msg;
+ sqlstore *store = m->store;
sql_schema *s = mvc_bind_schema(m, sname);
sql_table *t = mvc_bind_table(m, s, tname);
+ if (t && !isTable(t))
+ throw(SQL, "sql.bind", SQLSTATE(42000) "%s '%s' is not
persistent",
+ TABLE_TYPE_DESCRIPTION(t->type, t->properties),
t->base.name);
sql_column *c = mvc_bind_column(m, t, cname);
b = mvc_bind(m, sname, tname, cname, access);
if (b && b->ttype && b->ttype != coltype) {
@@ -1319,7 +1323,6 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb
}
if (b) {
if (pci->argc == (8 + upd) && getArgType(mb, pci, 6 + upd) ==
TYPE_int) {
- sqlstore *store = m->session->tr->store;
BUN cnt = store->storage_api.count_col(m->session->tr,
c, 0), psz;
/* partitioned access */
int part_nr = *getArgReference_int(stk, pci, 6 + upd);
@@ -1407,10 +1410,6 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb
BBPkeepref(*bid = id->batCacheid);
BBPkeepref(*uvl = vl->batCacheid);
} else {
- sql_schema *s = mvc_bind_schema(m, sname);
- sql_table *t = mvc_bind_table(m, s, tname);
- sql_column *c = mvc_bind_column(m, t, cname);
-
*bid = e_bat(TYPE_oid);
*uvl = e_bat(c->type.type->localtype);
if (*bid == BID_NIL || *uvl == BID_NIL) {
@@ -1520,7 +1519,7 @@ mvc_delta_values(Client cntxt, MalBlkPtr
if (!(t = mvc_bind_table(m, s, tname)))
throw(SQL, "sql.delta", SQLSTATE(3F000) "No such table
'%s' in schema '%s'", tname, s->base.name);
if (!isTable(t))
- throw(SQL, "sql.delta", SQLSTATE(42000) "%s don't have
delta values", TABLE_TYPE_DESCRIPTION(t->type, t->properties));
+ throw(SQL, "sql.delta", SQLSTATE(42000) "%s doesn't
have delta values", TABLE_TYPE_DESCRIPTION(t->type, t->properties));
if (cname) {
if (!(c = mvc_bind_column(m, t, cname)))
throw(SQL, "sql.delta", SQLSTATE(3F000) "No
such column '%s' in table '%s'", cname, t->base.name);
@@ -1650,6 +1649,10 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl
return msg;
sqlstore *store = m->store;
sql_schema *s = mvc_bind_schema(m, sname);
+ sql_table *t = mvc_bind_table(m, s, tname);
+ if (t && !isTable(t))
+ throw(SQL, "sql.tid", SQLSTATE(42000) "%s '%s' is not
persistent",
+ TABLE_TYPE_DESCRIPTION(t->type, t->properties),
t->base.name);
sql_idx *i = mvc_bind_idx(m, s, iname);
b = mvc_bind_idxbat(m, sname, tname, iname, access);
if (b && b->ttype && b->ttype != coltype) {
@@ -1658,8 +1661,7 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl
}
if (b) {
if (pci->argc == (8 + upd) && getArgType(mb, pci, 6 + upd) ==
TYPE_int) {
- BUN cnt = BATcount(b), psz;
- cnt = store->storage_api.count_idx(m->session->tr, i,
0);
+ BUN cnt = store->storage_api.count_idx(m->session->tr,
i, 0), psz;
/* partitioned access */
int part_nr = *getArgReference_int(stk, pci, 6 + upd);
int nr_parts = *getArgReference_int(stk, pci, 7 + upd);
@@ -1682,12 +1684,6 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl
} else {
/* BAT b holds the UPD_ID bat */
oid l, h;
- BAT *s = mvc_bind_idxbat(m, sname, tname,
iname, 0);
- if ( s == NULL) {
- BBPunfix(b->batCacheid);
- throw(SQL,"sql.bindidx",SQLSTATE(42000)
"Cannot access index column %s.%s.%s",sname,tname,iname);
- }
- cnt = BATcount(s);
cnt =
store->storage_api.count_idx(m->session->tr, i, 0);
psz = cnt ? (cnt / nr_parts) : 0;
l = part_nr * psz;
@@ -1698,7 +1694,6 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl
h = cnt;
h--;
bn = BATselect(b, NULL, &l, &h, true, true,
false);
- BBPunfix(s->batCacheid);
if(bn == NULL) {
BBPunfix(b->batCacheid);
throw(SQL, "sql.bindidx",
GDK_EXCEPTION);
@@ -1738,15 +1733,17 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl
bat_destroy(id);
bat_destroy(vl);
BBPunfix(b->batCacheid);
- throw(SQL, "sql.idxbind",
GDK_EXCEPTION);
+ throw(SQL, "sql.bindidx",
GDK_EXCEPTION);
}
- assert(BATcount(id) == BATcount(vl));
+ if ( BATcount(id) != BATcount(vl)){
+ BBPunfix(b->batCacheid);
+ bat_destroy(id);
+ bat_destroy(vl);
+ throw(SQL, "sql.bindidx",
SQLSTATE(0000) "Inconsistent BAT count");
+ }
BBPkeepref(*bid = id->batCacheid);
BBPkeepref(*uvl = vl->batCacheid);
} else {
- sql_schema *s = mvc_bind_schema(m, sname);
- sql_idx *i = mvc_bind_idx(m, s, iname);
-
*bid = e_bat(TYPE_oid);
*uvl =
e_bat((i->type==join_idx)?TYPE_oid:TYPE_lng);
if (*bid == BID_NIL || *uvl == BID_NIL) {
@@ -1755,7 +1752,7 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl
if (*uvl)
BBPunfix(*uvl);
BBPunfix(b->batCacheid);
- throw(SQL, "sql.idxbind",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ throw(SQL, "sql.bindidx",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
}
BBPunfix(b->batCacheid);
@@ -1765,8 +1762,8 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl
return MAL_SUCCEED;
}
if (sname)
- throw(SQL, "sql.idxbind", SQLSTATE(HY005) "Cannot access column
descriptor %s for %s.%s", iname, sname, tname);
- throw(SQL, "sql.idxbind", SQLSTATE(HY005) "Cannot access column
descriptor %s for %s", iname, tname);
+ throw(SQL, "sql.bindidx", SQLSTATE(HY005) "Cannot access column
descriptor %s for %s.%s", iname, sname, tname);
+ throw(SQL, "sql.bindidx", SQLSTATE(HY005) "Cannot access column
descriptor %s for %s", iname, tname);
}
str
@@ -2371,6 +2368,9 @@ SQLtid(Client cntxt, MalBlkPtr mb, MalSt
t = mvc_bind_table(m, s, tname);
if (t == NULL)
throw(SQL, "sql.tid", SQLSTATE(42S02) "Table missing
%s.%s",sname,tname);
+ if (!isTable(t))
+ throw(SQL, "sql.tid", SQLSTATE(42000) "%s '%s' is not
persistent",
+ TABLE_TYPE_DESCRIPTION(t->type, t->properties),
t->base.name);
sqlstore *store = m->store;
/* we have full table count, nr of deleted (unused rows) */
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
@@ -475,8 +475,8 @@ alter_table_set_access(mvc *sql, char *s
throw(SQL,"sql.alter_table_set_access",SQLSTATE(42000) "ALTER
TABLE: access denied for %s to schema '%s'", get_string_global_var(sql,
"current_user"), s->base.name);
if (!(t = mvc_bind_table(sql, s, tname)))
throw(SQL,"sql.alter_table_set_access",SQLSTATE(42S02) "ALTER
TABLE: no such table '%s' in schema '%s'", tname, s->base.name);
- if (isMergeTable(t))
- throw(SQL,"sql.alter_table_set_access",SQLSTATE(42S02) "ALTER
TABLE: read only MERGE TABLES are not supported");
+ if (!isTable(t))
+ throw(SQL,"sql.alter_table_set_access",SQLSTATE(42000) "ALTER
TABLE: access changes on %sS not supported", TABLE_TYPE_DESCRIPTION(t->type,
t->properties));
if (t->access != access) {
if (access && table_has_updates(sql->session->tr, t))
throw(SQL,"sql.alter_table_set_access",SQLSTATE(40000)
"ALTER TABLE: set READ or INSERT ONLY not possible with outstanding updates
(wait until updates are flushed)\n");
diff --git a/sql/backends/monet5/sql_optimizer.c
b/sql/backends/monet5/sql_optimizer.c
--- a/sql/backends/monet5/sql_optimizer.c
+++ b/sql/backends/monet5/sql_optimizer.c
@@ -83,7 +83,7 @@ SQLgetSpace(mvc *m, MalBlkPtr mb, int pr
continue;
/* we have to sum the cost of all three components of a
BAT */
- if (c && (!isRemote(c->t) && !isMergeTable(c->t)) &&
(lasttable == 0 || strcmp(lasttable,tname)==0)) {
+ if (c && isTable(c->t) && (lasttable == 0 ||
strcmp(lasttable,tname)==0)) {
size = SQLgetColumnSize(tr, c, access);
space += size; // accumulate once per table
//lasttable = tname; invalidate this attempt
@@ -102,7 +102,7 @@ SQLgetSpace(mvc *m, MalBlkPtr mb, int pr
if (getFunctionId(p) == bindidxRef) {
sql_idx *i = mvc_bind_idx(m, s, idxname);
- if (i && (!isRemote(i->t) &&
!isMergeTable(i->t))) {
+ if (i && isTable(i->t)) {
size = SQLgetIdxSize(tr, i, access);
if( !prepare && size == 0 && !
i->t->system){
diff --git a/sql/backends/monet5/sql_rank.c b/sql/backends/monet5/sql_rank.c
--- a/sql/backends/monet5/sql_rank.c
+++ b/sql/backends/monet5/sql_rank.c
@@ -1245,16 +1245,24 @@ SQLbasecount(Client cntxt, MalBlkPtr mb,
str tname = *getArgReference_str(stk, pci, 2);
mvc *m = NULL;
str msg;
+ sql_schema *s = NULL;
+ sql_table *t = NULL;
+ sql_column *c = NULL;
if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL)
return msg;
if ((msg = checkSQLContext(cntxt)) != NULL)
return msg;
- sql_schema *s = mvc_bind_schema(m, sname);
- sql_table *t = s?mvc_bind_table(m, s, tname):NULL;
- if (!t || !isTable(t) || isMergeTable(t) || isReplicaTable(t))
- return createException(SQL, "sql.count", SQLSTATE(HY005)
"Cannot find table %s.%s", sname, tname);
- sql_column *c = ol_first_node(t->columns)->data;
+ if (!(s = mvc_bind_schema(m, sname)))
+ throw(SQL, "sql.count", SQLSTATE(3F000) "Schema missing %s",
sname);
+ if (!(t = mvc_bind_table(m, s, tname)))
+ throw(SQL, "sql.count", SQLSTATE(42S02) "Table missing
%s.%s",sname,tname);
+ if (!isTable(t))
+ throw(SQL, "sql.count", SQLSTATE(42000) "%s '%s' is not
persistent",
+ TABLE_TYPE_DESCRIPTION(t->type, t->properties),
t->base.name);
+ if (!ol_first_node(t->columns))
+ throw(SQL, "sql.count", SQLSTATE(42S22) "Column missing
%s.%s",sname,tname);
+ c = ol_first_node(t->columns)->data;
sqlstore *store = m->session->tr->store;
*res = store->storage_api.count_col(m->session->tr, c, 10);
@@ -1266,7 +1274,7 @@ SQLcount(Client cntxt, MalBlkPtr mb, Mal
{
BAT *r = NULL, *b = NULL, *p = NULL, *o = NULL, *s = NULL, *e = NULL;
int tpe, frame_type;
- bit ignore_nils;
+ bit ignore_nils, heap_loaded = false;
bat *res = NULL;
str msg = MAL_SUCCEED;
@@ -1280,9 +1288,18 @@ SQLcount(Client cntxt, MalBlkPtr mb, Mal
if (isaBatType(tpe))
tpe = getBatType(tpe);
- if (isaBatType(getArgType(mb, pci, 1)) && (!(b =
BATdescriptor(*getArgReference_bat(stk, pci, 1))))) {
- msg = createException(SQL, "sql.count", SQLSTATE(HY005) "Cannot
access column descriptor");
- goto bailout;
+ if (isaBatType(getArgType(mb, pci, 1))) {
+ if (!(b = BBPquickdesc(*getArgReference_bat(stk, pci, 1)))) {
+ msg = createException(SQL, "sql.count", SQLSTATE(HY005)
"Cannot access column descriptor");
+ goto bailout;
+ }
+ if (ignore_nils && !b->tnonil) {
+ if (!(b = BATdescriptor(*getArgReference_bat(stk, pci,
1)))) {
+ msg = createException(SQL, "sql.count",
SQLSTATE(HY005) "Cannot access column descriptor");
+ goto bailout;
+ }
+ heap_loaded = true;
+ }
}
if (b && !(r = COLnew(b->hseqbase, TYPE_lng, BATcount(b), TRANSIENT))) {
msg = createException(SQL, "sql.count", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
@@ -1326,7 +1343,9 @@ SQLcount(Client cntxt, MalBlkPtr mb, Mal
}
bailout:
- unfix_inputs(5, b, p, o, s, e);
+ if (b && heap_loaded)
+ BBPunfix(b->batCacheid);
+ unfix_inputs(4, p, o, s, e);
finalize_output(res, r, msg);
return msg;
}
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
@@ -530,7 +530,7 @@ stmt_tid(backend *be, sql_table *t, int
q = pushStr(mb, q, t->base.name);
if (q == NULL)
return NULL;
- if (t && (!isRemote(t) && !isMergeTable(t)) && partition) {
+ if (t && isTable(t) && partition) {
sql_trans *tr = be->mvc->session->tr;
sqlstore *store = tr->store;
BUN rows = (BUN) store->storage_api.count_col(tr,
ol_first_node(t->columns)->data, QUICK);
@@ -599,7 +599,7 @@ stmt_bat(backend *be, sql_column *c, int
sql_trans *tr = be->mvc->session->tr;
sqlstore *store = tr->store;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list