Changeset: 3cff5551056a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3cff5551056a
Modified Files:
clients/mapiclient/mclient.c
clients/mapilib/mapi.rc
gdk/gdk_atoms.h
sql/backends/monet5/sql_result.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_scenario.h
sql/storage/bat/bat_storage.c
sql/storage/store.c
sql/test/merge-partitions/Tests/All
Branch: default
Log Message:
Merge with Apr2019 branch.
diffs (truncated from 446 to 300 lines):
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1512,25 +1512,26 @@ SQLrenderer(MapiHdl hdl)
char *s;
len[i] = mapi_get_len(hdl, i);
- if (len[i] == 0 &&
- ((s = mapi_get_type(hdl, i)) == NULL ||
- (strcmp(s, "varchar") != 0 &&
- strcmp(s, "clob") != 0 &&
- strcmp(s, "char") != 0 &&
- strcmp(s, "str") != 0 &&
- strcmp(s, "json") != 0))) {
- /* no table width known, use maximum, rely on
- * squeezing later on to fix it to whatever is
- * available; note that for a column type of
- * varchar, 0 means the complete column is
- * NULL or empty string, so MINCOLSIZE (below)
- * will work great */
- len[i] = pagewidth <= 0 ? DEFWIDTH : pagewidth;
- } else if (len[i] == 0 &&
- strcmp(mapi_get_type(hdl, i), "uuid") == 0) {
- /* we know how large the UUID representation
- * is, even if the server doesn't */
- len[i] = 36;
+ if (len[i] == 0) {
+ if ((s = mapi_get_type(hdl, i)) == NULL ||
+ (strcmp(s, "varchar") != 0 &&
+ strcmp(s, "clob") != 0 &&
+ strcmp(s, "char") != 0 &&
+ strcmp(s, "str") != 0 &&
+ strcmp(s, "json") != 0)) {
+ /* no table width known, use maximum,
+ * rely on squeezing later on to fix
+ * it to whatever is available; note
+ * that for a column type of varchar,
+ * 0 means the complete column is NULL
+ * or empty string, so MINCOLSIZE
+ * (below) will work great */
+ len[i] = pagewidth <= 0 ? DEFWIDTH : pagewidth;
+ } else if (strcmp(s, "uuid") == 0) {
+ /* we know how large the UUID representation
+ * is, even if the server doesn't */
+ len[i] = 36;
+ }
}
if (len[i] < MINCOLSIZE)
len[i] = MINCOLSIZE;
diff --git a/clients/mapilib/mapi.rc b/clients/mapilib/mapi.rc
--- a/clients/mapilib/mapi.rc
+++ b/clients/mapilib/mapi.rc
@@ -23,7 +23,7 @@ BEGIN
// Maintained via vertoo. Please don't modify by hand!
// Contact [email protected] for details and/or
assistance.
VALUE "InternalName", "Mapi\0"
- VALUE "LegalCopyright", "Copyright © MonetDB B.V. 2008-2018\0"
+ VALUE "LegalCopyright", "Copyright © MonetDB B.V. 2008-2019\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "Mapi.dll\0"
VALUE "PrivateBuild", "\0"
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -203,7 +203,7 @@ gdk_export const ptr ptr_nil;
#define ATOMdel(t,hp,src) do if (BATatoms[t].atomDel)
BATatoms[t].atomDel(hp,src); while (0)
#define ATOMvarsized(t) (BATatoms[t].atomPut != NULL)
#define ATOMlinear(t) BATatoms[t].linear
-#define ATOMtype(t) ((t == TYPE_void)?TYPE_oid:t)
+#define ATOMtype(t) ((t) == TYPE_void ? TYPE_oid : (t))
#define ATOMfix(t,v) do if (BATatoms[t].atomFix)
BATatoms[t].atomFix(v); while (0)
#define ATOMunfix(t,v) do if (BATatoms[t].atomUnfix)
BATatoms[t].atomUnfix(v); while (0)
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -2059,6 +2059,8 @@ get_print_width(int mtype, sql_class ecl
return count;
} else if (eclass == EC_BIT) {
return 5; /* max(strlen("true"), strlen("false")) */
+ } else if (strcmp(ATOMname(mtype), "uuid") == 0) {
+ return 36; /* xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx */
} else {
return 0;
}
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -125,8 +125,8 @@ SQLprelude(Client cntxt, MalBlkPtr mb, M
.language = "msql",
.exitSystem = "SQLexit",
.exitSystemCmd = SQLexit,
- .initClient = "SQLinitClient",
- .initClientCmd = SQLinitClient,
+ .initClient = "SQLinitClientFromMAL",
+ .initClientCmd = SQLinitClientFromMAL,
.exitClient = "SQLexitClient",
.exitClientCmd = SQLexitClient,
.reader = "MALreader",
@@ -288,6 +288,12 @@ SQLprepareClient(Client c, int login)
} else {
be = c->sqlcontext;
m = be->mvc;
+ /* Only reset if there is no active transaction which
+ * can happen when we combine sql.init with msql.
+ */
+ if(m->session->tr->active) {
+ return NULL;
+ }
if(mvc_reset(m, c->fdin, c->fdout, SQLdebug, NR_GLOBAL_VARS) <
0) {
throw(SQL,"sql.initClient", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
}
@@ -694,6 +700,34 @@ SQLinitClient(Client c)
}
str
+SQLinitClientFromMAL(Client c) {
+ str msg = MAL_SUCCEED;
+
+ if ( (msg = SQLinitClient(c)) != MAL_SUCCEED) {
+ return msg;
+ }
+
+ mvc* m = ((backend*) c->sqlcontext)->mvc;
+
+ /* Crucial step:
+ * MAL scripts that interact with the sql module
+ * must have a properly initialized transaction.
+ */
+ SQLtrans(m);
+
+ if(*m->errstr) {
+ if (strlen(m->errstr) > 6 && m->errstr[5] == '!')
+ msg = createException(PARSE, "SQLinitClientFromMAL",
"%s", m->errstr);
+ else
+ msg = createException(PARSE, "SQLinitClientFromMAL",
SQLSTATE(42000) "%s", m->errstr);
+ *m->errstr=0;
+ c->mode = FINISHCLIENT;
+ }
+
+ return msg;
+}
+
+str
SQLexitClient(Client c)
{
str err;
diff --git a/sql/backends/monet5/sql_scenario.h
b/sql/backends/monet5/sql_scenario.h
--- a/sql/backends/monet5/sql_scenario.h
+++ b/sql/backends/monet5/sql_scenario.h
@@ -25,6 +25,7 @@ sql5_export str SQLexit(Client c);
sql5_export str SQLexitClient(Client c);
sql5_export str SQLresetClient(Client c);
sql5_export str SQLinitClient(Client c);
+sql5_export str SQLinitClientFromMAL(Client c);
sql5_export str SQLreader(Client c);
sql5_export str SQLparser(Client c);
sql5_export str SQLengine(Client c);
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
@@ -42,6 +42,7 @@ delta_bind_del(sql_dbat *bat, int access
assert(access != RD_UPD_ID && access != RD_UPD_VAL);
b = temp_descriptor(bat->dbid);
+ assert(BATcount(b) == bat->cnt);
return b;
}
@@ -787,6 +788,7 @@ dup_dbat( sql_trans *tr, sql_dbat *obat,
} else {
bat->dbid = ebat_copy(bat->dbid, 0, temp);
}
+ assert(BATcount(quick_descriptor(bat->dbid)) == bat->cnt);
if (bat->dbid == BID_NIL)
return LOG_ERR;
}
@@ -944,11 +946,13 @@ delta_delete_bat( sql_dbat *bat, BAT *i
return LOG_ERR;
}
assert(b->theap.storage != STORE_PRIV);
+ assert(BATcount(b) == bat->cnt);
if (BATappend(b, i, NULL, true) != GDK_SUCCEED) {
bat_destroy(b);
return LOG_ERR;
}
BATkey(b, true);
+ assert(BATcount(b) == bat->cnt+ BATcount(i));
bat_destroy(b);
bat->cnt += BATcount(i);
@@ -971,6 +975,7 @@ delta_delete_val( sql_dbat *bat, oid rid
return LOG_ERR;
}
assert(b->theap.storage != STORE_PRIV);
+ assert(BATcount(b) == bat->cnt);
if (BUNappend(b, (ptr)&rid, true) != GDK_SUCCEED) {
bat_destroy(b);
return LOG_ERR;
@@ -2258,12 +2263,15 @@ gtr_update_dbat(sql_trans *tr, sql_dbat
assert(!isEbat(cdb));
if (append_inserted(cdb, idb) == BUN_NONE)
ok = LOG_ERR;
+ else
+ BATcommit(cdb);
bat_destroy(cdb);
} else {
ok = LOG_ERR;
}
}
bat_destroy(idb);
+ assert(BATcount(quick_descriptor(d->dbid)) == d->cnt);
return ok;
}
@@ -2673,10 +2681,12 @@ tr_update_dbat(sql_trans *tr, sql_dbat *
ok = LOG_ERR;
else
BATcommit(odb);
+ assert(BATcount(odb) == fdb->cnt);
temp_destroy(fdb->dbid);
if (ok == LOG_OK) {
fdb->dbid = 0;
+ assert(BATcount(db) == fdb->cnt);
tdb->cnt = fdb->cnt;
}
bat_destroy(odb);
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -2723,6 +2723,20 @@ column_dup(sql_trans *tr, int flags, sql
base_init(sa, &c->base, oc->base.id, tr_flag(&oc->base, flags),
oc->base.name);
obj_ref(oc,c,flags);
c->type = oc->type;
+ if (c->type.type->s) { /* user type */
+ sql_schema *s = t->s;
+ sql_type *lt = NULL;
+
+ if (s->base.id == c->type.type->s->base.id) {
+ /* current column belongs to current schema. So search
there for current user type. */
+ lt = find_sql_type(s, c->type.type->base.name);
+ } else {
+ lt = sql_trans_bind_type(tr, find_sql_schema_id(tr,
c->type.type->s->base.id), c->type.type->base.name);
+ }
+ if (lt == NULL)
+ GDKfatal("SQL type %s missing",
c->type.type->base.name);
+ sql_init_subtype(&c->type, lt, c->type.digits, c->type.scale);
+ }
c->def = NULL;
if (oc->def)
c->def = sa_strdup(sa, oc->def);
@@ -3131,26 +3145,71 @@ schema_dup(sql_trans *tr, int flags, sql
}
static sql_trans *
-trans_init(sql_trans *t, backend_stack stk, sql_trans *ot)
-{
- t->wtime = t->rtime = 0;
- t->stime = ot->wtime;
- t->wstime = timestamp ();
- t->schema_updates = 0;
- t->dropped = NULL;
- t->status = 0;
- if (ot != gtrans)
- t->schema_updates = ot->schema_updates;
-
- t->schema_number = store_schema_number();
- t->parent = ot;
- t->stk = stk;
-
- t->name = NULL;
+trans_init(sql_trans *tr, backend_stack stk, sql_trans *otr)
+{
+ node *m,*n;
+
+ tr->wtime = tr->rtime = 0;
+ tr->stime = otr->wtime;
+ tr->wstime = timestamp ();
+ tr->schema_updates = 0;
+ tr->dropped = NULL;
+ tr->status = 0;
+ if (otr != gtrans)
+ tr->schema_updates = otr->schema_updates;
+
+ tr->schema_number = store_schema_number();
+ tr->parent = otr;
+ tr->stk = stk;
+
+ for (m = otr->schemas.set->h, n = tr->schemas.set->h; m && n; m =
m->next, n = n->next ) {
+ sql_schema *ps = m->data; /* parent transactions schema */
+ sql_schema *s = n->data;
+
+ if (s->base.id == ps->base.id) {
+ node *k, *l;
+
+ s->base.rtime = s->base.wtime = 0;
+ s->base.stime = ps->base.wtime;
+
+ if (ps->tables.set && s->tables.set)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list