Changeset: 95b0717acf94 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=95b0717acf94
Branch: default
Log Message:
Merge with hammertime.
diffs (truncated from 453 to 300 lines):
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -246,7 +246,7 @@ const char *
MT_thread_getname(void)
{
struct winthread *w = TlsGetValue(threadslot);
- return w ? w->threadname : "unknown thread";
+ return w ? w->threadname : UNKNOWN_THREAD;
}
void
@@ -579,7 +579,7 @@ MT_thread_getname(void)
struct posthread *p;
p = pthread_getspecific(threadkey);
- return p ? p->threadname : "unknown thread";
+ return p ? p->threadname : UNKNOWN_THREAD;
}
void
@@ -694,9 +694,9 @@ join_threads(void)
p->waiting = true;
pthread_mutex_unlock(&posthread_lock);
TRC_DEBUG(THRD, "Join thread \"%s\"\n",
p->threadname);
- self->joinwait = p;
+ if (self) self->joinwait = p;
pthread_join(p->tid, NULL);
- self->joinwait = NULL;
+ if (self) self->joinwait = NULL;
rm_posthread(p);
waited = true;
pthread_mutex_lock(&posthread_lock);
@@ -721,9 +721,9 @@ join_detached_threads(void)
p->waiting = true;
pthread_mutex_unlock(&posthread_lock);
TRC_DEBUG(THRD, "Join thread \"%s\"\n",
p->threadname);
- self->joinwait = p;
+ if (self) self->joinwait = p;
pthread_join(p->tid, NULL);
- self->joinwait = NULL;
+ if (self) self->joinwait = NULL;
rm_posthread(p);
waited = true;
pthread_mutex_lock(&posthread_lock);
@@ -836,9 +836,9 @@ MT_join_thread(MT_Id t)
return -1;
TRC_DEBUG(THRD, "Join thread \"%s\"\n", 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) {
GDKsyserr(ret, "Joining thread failed");
return -1;
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -140,6 +140,8 @@ typedef size_t MT_Id; /* thread number.
enum MT_thr_detach { MT_THR_JOINABLE, MT_THR_DETACHED };
#define MT_NAME_LEN 32 /* length of thread/semaphore/etc. names */
+#define UNKNOWN_THREAD "unknown thread"
+
gdk_export bool MT_thread_init(void);
gdk_export int MT_create_thread(MT_Id *t, void (*function) (void *),
void *arg, enum MT_thr_detach d,
diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -240,7 +240,6 @@ typedef struct sql_trans {
char *name;
int stime; /* start of transaction */
int wstime; /* first write transaction time stamp */
- int rtime; /* timestamp of latest read performed in
transaction*/
int wtime; /* timestamp of latest write performed in
transaction*/
int schema_number; /* schema timestamp */
int schema_updates; /* set on schema changes */
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
@@ -132,7 +132,7 @@ bind_uidx(sql_trans *tr, sql_idx * i, in
i->t->data = timestamp_dbat(ot->data, i->t->base.stime);
}
assert(tr != gtrans);
- i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = tr->rtime =
tr->stime;
+ i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = tr->stime;
u = delta_bind_ubat(i->data, access,
(oid_index(i->type))?TYPE_oid:TYPE_lng);
return u;
}
@@ -220,7 +220,7 @@ bind_col(sql_trans *tr, sql_column *c, i
return bind_ucol(tr, c, access);
assert(access == QUICK || tr != gtrans);
if (tr && access != QUICK)
- c->base.rtime = c->t->base.rtime = c->t->s->base.rtime =
tr->rtime = tr->stime;
+ c->base.rtime = c->t->base.rtime = c->t->s->base.rtime =
tr->stime;
return delta_bind_bat( c->data, access, isTemp(c));
}
@@ -238,7 +238,7 @@ bind_idx(sql_trans *tr, sql_idx * i, int
return bind_uidx(tr, i, access);
assert(access == QUICK || tr != gtrans);
if (tr && access != QUICK)
- i->base.rtime = i->t->base.rtime = i->t->s->base.rtime =
tr->rtime = tr->stime;
+ i->base.rtime = i->t->base.rtime = i->t->s->base.rtime =
tr->stime;
return delta_bind_bat( i->data, access, isTemp(i));
}
@@ -623,7 +623,7 @@ update_col(sql_trans *tr, sql_column *c,
bat = c->data;
bat->wtime = c->base.wtime = c->t->base.wtime = c->t->s->base.wtime =
tr->wtime = tr->wstime;
assert(tr != gtrans);
- c->base.rtime = c->t->base.rtime = c->t->s->base.rtime = tr->rtime =
tr->stime;
+ c->base.rtime = c->t->base.rtime = c->t->s->base.rtime = tr->stime;
if (tpe == TYPE_bat)
return delta_update_bat(bat, tids, upd, isNew(c));
else
@@ -663,7 +663,7 @@ update_idx(sql_trans *tr, sql_idx * i, v
bat = i->data;
bat->wtime = i->base.wtime = i->t->base.wtime = i->t->s->base.wtime =
tr->wtime = tr->wstime;
assert(tr != gtrans);
- i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = tr->rtime =
tr->stime;
+ i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = tr->stime;
if (tpe == TYPE_bat)
return delta_update_bat(bat, tids, upd, isNew(i));
else
diff --git a/sql/storage/sql_catalog.c b/sql/storage/sql_catalog.c
--- a/sql/storage/sql_catalog.c
+++ b/sql/storage/sql_catalog.c
@@ -113,17 +113,6 @@ cs_find_id(changeset * cs, sqlid id)
return n;
}
}
- if (cs->dset) {
- l = cs->dset;
- for (n = l->h; n; n = n->next) {
- sql_base *b = n->data;
-
- /* check if names match */
- if (b->id == id) {
- return n;
- }
- }
- }
return NULL;
}
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1366,7 +1366,7 @@ create_trans(sql_allocator *sa)
t->sa = sa;
t->name = NULL;
- t->wtime = t->rtime = 0;
+ t->wtime = 0;
t->stime = 0;
t->wstime = timestamp();
t->schema_updates = 0;
@@ -3757,7 +3757,7 @@ schema_dup(sql_trans *tr, int flags, sql
static void
_trans_init(sql_trans *tr, sql_trans *otr)
{
- tr->wtime = tr->rtime = 0;
+ tr->wtime = 0;
tr->stime = otr->wtime;
tr->wstime = timestamp();
tr->schema_updates = 0;
@@ -4611,14 +4611,12 @@ validate_tables(sql_schema *s, sql_schem
if (cs_size(&s->tables))
for (n = s->tables.set->h; n; n = n->next) {
sql_table *t = n->data;
- sql_table *ot = NULL;
if (!t->base.wtime && !t->base.rtime)
continue;
- o = list_find_base_id(os->tables.set, t->base.id);
- if (o)
- ot = o->data;
+ sql_table *ot = find_sql_table_id(os, t->base.id);
+
if (!ot && os->tables.dset &&
list_find_base_id(os->tables.dset, t->base.id) != NULL) {
/* dropped table */
return 0;
@@ -4881,6 +4879,7 @@ reset_table(sql_trans *tr, sql_table *ft
ft->access = pft->access;
if (pft->p) {
ft->p = find_sql_table(ft->s, pft->p->base.name);
+ //Check if this assert can be removed definitely.
//the parent (merge or replica table) maybe created
later!
//assert(isMergeTable(ft->p) || isReplicaTable(ft->p));
} else
diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c
--- a/tools/monetdbe/monetdbe.c
+++ b/tools/monetdbe/monetdbe.c
@@ -360,7 +360,10 @@ cleanup:
bstream_destroy(c->fdin);
c->fdin = old_bstream;
}
- return commit_action(m, mdbe, result, res_internal);
+
+ char* msg = commit_action(m, mdbe, result, res_internal);
+
+ return msg;
}
static int
@@ -427,7 +430,7 @@ cleanup:
static void
monetdbe_shutdown_internal(void) // Call this function always inside the
embedded_lock
{
- if (monetdbe_embedded_initialized) {
+ if (monetdbe_embedded_initialized && (open_dbs == 0)) {
malEmbeddedReset();
monetdbe_embedded_initialized = false;
if (monetdbe_embedded_url)
@@ -628,12 +631,12 @@ monetdbe_dump_database(monetdbe_database
return NULL;
monetdbe_database_internal *mdbe = (monetdbe_database_internal*)dbhdl;
- MT_lock_set(&embedded_lock);
+
if ((mdbe->msg = validate_database_handle(mdbe,
"embedded.monetdbe_dump_database")) != MAL_SUCCEED) {
- MT_lock_unset(&embedded_lock);
+
return mdbe->msg;
}
- MT_lock_unset(&embedded_lock);
+
struct MapiStruct mid = { .mdbe = mdbe };
/* open file stream */
@@ -657,12 +660,12 @@ monetdbe_dump_table(monetdbe_database db
return NULL;
monetdbe_database_internal *mdbe = (monetdbe_database_internal*)dbhdl;
- MT_lock_set(&embedded_lock);
+
if ((mdbe->msg = validate_database_handle(mdbe,
"embedded.monetdbe_dump_table")) != MAL_SUCCEED) {
- MT_lock_unset(&embedded_lock);
+
return mdbe->msg;
}
- MT_lock_unset(&embedded_lock);
+
struct MapiStruct mid = { .mdbe = mdbe };
/* open file stream */
@@ -686,9 +689,9 @@ monetdbe_get_autocommit(monetdbe_databas
return NULL;
monetdbe_database_internal *mdbe = (monetdbe_database_internal*)dbhdl;
- MT_lock_set(&embedded_lock);
+
if ((mdbe->msg = validate_database_handle(mdbe,
"monetdbe.monetdbe_get_autocommit")) != MAL_SUCCEED) {
- MT_lock_unset(&embedded_lock);
+
return mdbe->msg;
}
@@ -698,7 +701,7 @@ monetdbe_get_autocommit(monetdbe_databas
mvc *m = ((backend *) mdbe->c->sqlcontext)->mvc;
*result = m->session->auto_commit;
}
- MT_lock_unset(&embedded_lock);
+
return mdbe->msg;
}
@@ -709,9 +712,9 @@ monetdbe_set_autocommit(monetdbe_databas
return NULL;
monetdbe_database_internal *mdbe = (monetdbe_database_internal*)dbhdl;
- MT_lock_set(&embedded_lock);
+
if (!validate_database_handle_noerror(mdbe)) {
- MT_lock_unset(&embedded_lock);
+
return 0;
}
@@ -727,7 +730,7 @@ monetdbe_set_autocommit(monetdbe_databas
mdbe->msg = mvc_rollback(m, 0, NULL, true);
}
}
- MT_lock_unset(&embedded_lock);
+
return mdbe->msg;
}
@@ -737,9 +740,9 @@ monetdbe_in_transaction(monetdbe_databas
if (!dbhdl)
return 0;
monetdbe_database_internal *mdbe = (monetdbe_database_internal*)dbhdl;
- MT_lock_set(&embedded_lock);
+
if (!validate_database_handle_noerror(mdbe)) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list