Changeset: 74b8e44ee5e9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=74b8e44ee5e9
Modified Files:
embedded/monetdb_embedded.c
gdk/gdk_system.c
gdk/gdk_utils.c
monetdb5/optimizer/opt_reorder.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql.h
sql/backends/monet5/sql.mal
sql/common/sql_types.c
Branch: cmake-monetdblite
Log Message:
Several MonetDBLite related fixes:
- Backported mvc_append_bats_wrap for "monetdb_append".
- Disabled opt_reorder assertions for previous operation.
- Avoid MT_kill_thread on the main thread while shutdown MonetDBLite.
diffs (143 lines):
diff --git a/embedded/monetdb_embedded.c b/embedded/monetdb_embedded.c
--- a/embedded/monetdb_embedded.c
+++ b/embedded/monetdb_embedded.c
@@ -211,7 +211,7 @@ monetdb_query_internal(monetdb_connectio
else if (m->emode & m_prepare)
res_internal->res.type = Q_PREPARE;
else
- res_internal->res.type = m->type;
+ res_internal->res.type = (m->results) ?
m->results->query_type : m->type;
res_internal->res.id = m->last_id;
*result = (monetdb_result*) res_internal;
m->reply_size = -2; /* do not clean up result tables */
@@ -530,6 +530,12 @@ monetdb_append(monetdb_connection conn,
msg = createException(MAL, "embedded.monetdb_append",
"column_count must be higher than 0");
goto cleanup;
}
+ if (!m->sa)
+ m->sa = sa_create();
+ if (!m->sa) {
+ msg = createException(SQL, "embedded.monetdb_append",
MAL_MALLOC_FAIL);
+ goto cleanup;
+ }
{
node *n;
size_t i;
@@ -543,7 +549,7 @@ monetdb_append(monetdb_connection conn,
assert(f);
if (schema) {
if (!(s = mvc_bind_schema(m, schema))) {
- msg = createException(MAL,
"embedded.monetdb_get_columns", "Schema missing %s", schema);
+ msg = createException(MAL,
"embedded.monetdb_append", "Schema missing %s", schema);
goto cleanup;
}
} else {
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -788,9 +788,11 @@ MT_join_thread(MT_Id t)
return -1;
THRDDEBUG MT_fprintf(stderr, "#join \"%s\" \"%s\"\n",
MT_thread_getname(), p->threadname);
struct posthread *self = pthread_getspecific(threadkey);
- self->joinwait = p;
+ if (self)
+ self->joinwait = p;
ret = pthread_join(p->tid, NULL);
- self->joinwait = NULL;
+ if (self)
+ self->joinwait = NULL;
if (ret != 0) {
MT_fprintf(stderr, "#MT_join_thread: joining thread failed:
%s\n",
strerror(ret));
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -764,7 +764,7 @@ GDKreset(int status)
for (Thread t = GDKthreads; t < GDKthreads + THREADS; t++) {
MT_Id victim;
if ((victim = (MT_Id) ATOMIC_GET(&t->pid)) != 0) {
- if (victim != pid) {
+ if (victim != pid && victim > 1) { /* Not the
main thread */
int e;
killed = true;
diff --git a/monetdb5/optimizer/opt_reorder.c b/monetdb5/optimizer/opt_reorder.c
--- a/monetdb5/optimizer/opt_reorder.c
+++ b/monetdb5/optimizer/opt_reorder.c
@@ -232,9 +232,11 @@ OPTpostponeAppends(Client cntxt, MalBlkP
for( i=0; i<limit; i++){
if ( getModuleId(old[i]) == sqlRef && getFunctionId(old[i]) ==
appendRef){
// only postpone under strict conditions
+#ifndef HAVE_EMBEDDED
assert( isVarConstant(mb,getArg(old[i],2)));
assert( isVarConstant(mb,getArg(old[i],3)));
assert( isVarConstant(mb,getArg(old[i],4)));
+#endif
if( actions )
pushInstruction(mb, old[i]);
else {
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
@@ -3046,6 +3046,21 @@ mvc_bin_import_table_wrap(Client cntxt,
}
str
+mvc_append_bats_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+ str msg = MAL_SUCCEED;
+ int i;
+
+ (void) cntxt;
+ (void) mb;
+ for (i = 0; i < pci->retc; i++) {
+ lng *batid = getArgReference_lng(stk, pci, pci->retc + i);
+ *getArgReference_bat(stk, pci, i) = *batid;
+ }
+ return msg;
+}
+
+str
zero_or_one_error(ptr ret, const bat *bid, const bit *err)
{
BAT *b;
diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h
--- a/sql/backends/monet5/sql.h
+++ b/sql/backends/monet5/sql.h
@@ -100,6 +100,7 @@ sql5_export str mvc_row_result_wrap(Clie
sql5_export str mvc_export_row_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
sql5_export str mvc_import_table_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr
stk, InstrPtr pci);
sql5_export str mvc_bin_import_table_wrap(Client cntxt, MalBlkPtr mb,
MalStkPtr stk, InstrPtr pci);
+sql5_export str mvc_append_bats_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr
stk, InstrPtr pci);
sql5_export str setVariable(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
sql5_export str getVariable(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
sql5_export str sql_variables(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
diff --git a/sql/backends/monet5/sql.mal b/sql/backends/monet5/sql.mal
--- a/sql/backends/monet5/sql.mal
+++ b/sql/backends/monet5/sql.mal
@@ -281,6 +281,10 @@ address mvc_import_table_wrap
comment "Import a table from bstream s with the
given tuple and seperators (sep/rsep)";
+unsafe pattern append(id:lng...) (:bat[:any]...)
+address mvc_append_bats_wrap
+comment "Generate list of bats from their batids as input";
+
#command copy_errors() (efile:bat[:str], erow:bat[:int], efld:bat[:int],
emsg:bat[:str], einp:bat[:str])
#address mvc_import_errors
#comment "Summary of the failed tuple imports";
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -2167,6 +2167,11 @@ sqltypeinit( sql_allocator *sa)
create_arg(sa, NULL, sql_create_subtype(sa, INT, 0, 0),
ARG_IN)), sres, FALSE, F_UNION, SCALE_FIX);
f->varres = 1;
+ /* MonetDBLite BAT append */
+ f = sql_create_func_(sa, "append", "sql", "append", sa_list(sa), sres,
FALSE, F_UNION, SCALE_FIX);
+ f->varres = 1;
+ f->vararg = 1;
+
/* sys_update_schemas, sys_update_tables */
f = sql_create_func_(sa, "sys_update_schemas", "sql", "update_schemas",
NULL, NULL, FALSE, F_PROC, SCALE_NONE);
f = sql_create_func_(sa, "sys_update_tables", "sql", "update_tables",
NULL, NULL, FALSE, F_PROC, SCALE_NONE);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list