Changeset: 726203c34c74 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/726203c34c74 Modified Files: gdk/gdk.h gdk/gdk_bat.c sql/server/sql_var.c Branch: resource_management Log Message:
merge with default diffs (truncated from 31463 to 300 lines): diff --git a/clients/mapiclient/mhelp.c b/clients/mapiclient/mhelp.c --- a/clients/mapiclient/mhelp.c +++ b/clients/mapiclient/mhelp.c @@ -68,7 +68,7 @@ SQLhelp sqlhelp1[] = { {"ALTER TABLE", "", "ALTER TABLE [ IF EXISTS ] qname ADD [ COLUMN ] column_def\n" - "ALTER TABLE [ IF EXISTS ] qname ADD table_constraint\n" + "ALTER TABLE [ IF EXISTS ] qname ADD [ CONSTRAINT ident ] table_constraint\n" "ALTER TABLE [ IF EXISTS ] qname ALTER [ COLUMN ] ident SET DEFAULT value\n" "ALTER TABLE [ IF EXISTS ] qname ALTER [ COLUMN ] ident SET [NOT] NULL\n" "ALTER TABLE [ IF EXISTS ] qname ALTER [ COLUMN ] ident DROP DEFAULT\n" @@ -910,9 +910,10 @@ SQLhelp sqlhelp2[] = { NULL,}, {"table_constraint", NULL, - "[ CONSTRAINT ident ] { PRIMARY KEY column_list | UNIQUE column_list |\n" + "[ CONSTRAINT ident ] { CHECK '(' search_condition ')' |\n" + " PRIMARY KEY column_list | UNIQUE column_list |\n" " FOREIGN KEY column_list REFERENCES qname [ column_list ] [ match_options ] [ reference_action ] }", - "column_list,match_options,reference_action", + "column_list,search_condition,match_options,reference_action", "See also https://www.monetdb.org/documentation/user-guide/sql-manual/data-definition/table-elements/"}, {"table_element", NULL, diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1217,7 +1217,7 @@ mapi_log_header(Mapi mid, const char *fu if (firstcall == 0) firstcall = now; double seconds = (double)(now - firstcall) / 1e6; - mnstr_printf(mid->tracelog, "\342\226\266 [%u] t=%.3fs %s%s %s(), line %ld\n", mid->index, seconds, mark1, mark2, funcname, line); /* U+25B6: right-pointing triangle */ + mnstr_printf(mid->tracelog, "\n** [%u] t=%.3fs %s%s %s(), line %ld\n", mid->index, seconds, mark1, mark2, funcname, line); } void diff --git a/clients/mapilib/msettings.c b/clients/mapilib/msettings.c --- a/clients/mapilib/msettings.c +++ b/clients/mapilib/msettings.c @@ -477,7 +477,6 @@ msetting_set_string(msettings *mp, mparm mp->lang_is_mal = true; else if (strstr(value, "sql") == value) mp->lang_is_sql = true; - else if (strcmp(value, "`")) break; default: break; diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -931,6 +931,7 @@ typedef struct BAT { MT_Lock theaplock; /* lock protecting heap reference changes */ MT_RWLock thashlock; /* lock specifically for hash management */ MT_Lock batIdxLock; /* lock to manipulate other indexes/properties */ + MT_Sema imprsema; /* semaphore to synchronize imprints creation */ Heap *oldtail; /* old tail heap, to be destroyed after commit */ } BAT; diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c --- a/gdk/gdk_align.c +++ b/gdk/gdk_align.c @@ -209,6 +209,7 @@ VIEWcreate(oid seq, BAT *b, BUN l, BUN h MT_lock_destroy(&bn->theaplock); MT_lock_destroy(&bn->batIdxLock); MT_rwlock_destroy(&bn->thashlock); + MT_sema_destroy(&bn->imprsema); GDKfree(bn); return NULL; } diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -144,6 +144,8 @@ BATcreatedesc(oid hseq, int tt, bool hea MT_lock_init(&bn->batIdxLock, name); snprintf(name, sizeof(name), "hashlock%d", bn->batCacheid); /* fits */ MT_rwlock_init(&bn->thashlock, name); + snprintf(name, sizeof(name), "imprsema%d", bn->batCacheid); /* fits */ + MT_sema_init(&bn->imprsema, 1, name); return bn; } @@ -715,6 +717,7 @@ BATdestroy(BAT *b) MT_lock_destroy(&b->theaplock); MT_lock_destroy(&b->batIdxLock); MT_rwlock_destroy(&b->thashlock); + MT_sema_destroy(&b->imprsema); if (b->theap) { GDKfree(b->theap); } @@ -1200,6 +1203,9 @@ BUNappendmulti(BAT *b, const void *value maxvalp = t; } } + } else { + b->tnil = true; + b->tnonil = false; } p++; } @@ -1219,6 +1225,8 @@ BUNappendmulti(BAT *b, const void *value } else if (ATOMstorage(b->ttype) == TYPE_msk) { bi.minpos = bi.maxpos = BUN_NONE; minvalp = maxvalp = NULL; + b->tnil = false; + b->tnonil = true; for (BUN i = 0; i < count; i++) { t = (void *) ((char *) values + (i << b->tshift)); mskSetVal(b, p, *(msk *) t); @@ -1255,12 +1263,16 @@ BUNappendmulti(BAT *b, const void *value maxvalp = t; } } + } else { + b->tnil = true; + b->tnonil = false; } p++; } nunique = b->thash ? b->thash->nunique : 0; } } else { + /* inserting nils, unless it's msk */ for (BUN i = 0; i < count; i++) { gdk_return rc = tfastins_nocheck(b, p, t); if (rc != GDK_SUCCEED) { @@ -1273,6 +1285,8 @@ BUNappendmulti(BAT *b, const void *value p++; } nunique = b->thash ? b->thash->nunique : 0; + b->tnil = b->ttype != TYPE_msk; + b->tnonil = false; } MT_lock_set(&b->theaplock); b->tminpos = bi.minpos; @@ -1283,8 +1297,6 @@ BUNappendmulti(BAT *b, const void *value if (b->ttype == TYPE_oid) { /* spend extra effort on oid (possible candidate list) */ if (values == NULL || is_oid_nil(((oid *) values)[0])) { - b->tnil = true; - b->tnonil = false; b->tsorted = false; b->trevsorted = false; b->tkey = false; @@ -1295,8 +1307,6 @@ BUNappendmulti(BAT *b, const void *value b->trevsorted = true; b->tkey = true; b->tseqbase = count == 1 ? ((oid *) values)[0] : oid_nil; - b->tnil = false; - b->tnonil = true; } else { if (!is_oid_nil(b->tseqbase) && (count > 1 || @@ -1325,8 +1335,6 @@ BUNappendmulti(BAT *b, const void *value } for (BUN i = 1; i < count; i++) { if (is_oid_nil(((oid *) values)[i])) { - b->tnil = true; - b->tnonil = false; b->tsorted = false; b->trevsorted = false; b->tkey = false; @@ -1357,18 +1365,14 @@ BUNappendmulti(BAT *b, const void *value } } } else if (!ATOMlinear(b->ttype)) { - b->tnil = b->tnonil = false; b->tsorted = b->trevsorted = b->tkey = false; } else if (b->batCount == 0) { if (values == NULL) { b->tsorted = b->trevsorted = true; b->tkey = count == 1; - b->tnil = true; - b->tnonil = false; b->tunique_est = 1; } else { int c; - b->tnil = b->tnonil = false; switch (count) { case 1: b->tsorted = b->trevsorted = b->tkey = true; @@ -1415,11 +1419,7 @@ BUNappendmulti(BAT *b, const void *value b->tnokey[0] = 0; b->tnokey[1] = !b->tkey; b->tunique_est = (double) (1 + b->tkey); - b->tnil |= values == NULL; - b->tnonil = false; } else { - b->tnil |= values == NULL; - b->tnonil = false; b->tsorted = b->trevsorted = b->tkey = false; } BATsetcount(b, p); diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -831,6 +831,8 @@ BBPreadEntries(FILE *fp, unsigned bbpver MT_lock_init(&bn->batIdxLock, name); snprintf(name, sizeof(name), "hashlock%d", bn->batCacheid); /* fits */ MT_rwlock_init(&bn->thashlock, name); + snprintf(name, sizeof(name), "imprsema%d", bn->batCacheid); /* fits */ + MT_sema_init(&bn->imprsema, 1, name); ATOMIC_INIT(&bn->theap->refs, 1); if (snprintf(BBP_bak(b.batCacheid), sizeof(BBP_bak(b.batCacheid)), "tmp_%o", (unsigned) b.batCacheid) >= (int) sizeof(BBP_bak(b.batCacheid))) { diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c --- a/gdk/gdk_imprints.c +++ b/gdk/gdk_imprints.c @@ -492,6 +492,23 @@ BATimprints(BAT *b) size_t pages; MT_lock_unset(&b->batIdxLock); + /* in case there are multiple threads that all want to + * create imprints on slices of the same bat, we use a + * semaphore so that one thread can pass and do the work + * while the other threads wait until the first one is + * done; so when a subsequent thread passes, first check + * whether the work has already been done */ + MT_sema_down(&b->imprsema); + MT_lock_set(&b->batIdxLock); + if (b->timprints != NULL) { + bat_iterator_end(&bi); + if (unfix) + BBPunfix(unfix); + MT_sema_up(&b->imprsema); + MT_lock_unset(&b->batIdxLock); + return GDK_SUCCEED; + } + MT_lock_unset(&b->batIdxLock); MT_thread_setalgorithm("create imprints"); if (s2) @@ -511,6 +528,7 @@ BATimprints(BAT *b) bat_iterator_end(&bi); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } strconcat_len(imprints->imprints.filename, @@ -528,6 +546,7 @@ BATimprints(BAT *b) bat_iterator_end(&bi); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } s2 = BATunique(b, s1); @@ -537,6 +556,7 @@ BATimprints(BAT *b) bat_iterator_end(&bi); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } s3 = BATproject(s2, b); @@ -547,6 +567,7 @@ BATimprints(BAT *b) bat_iterator_end(&bi); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } s3->tkey = true; /* we know is unique on tail now */ @@ -558,6 +579,7 @@ BATimprints(BAT *b) bat_iterator_end(&bi); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } /* s4 now is ordered and unique on tail */ @@ -598,12 +620,15 @@ BATimprints(BAT *b) BBPunfix(s3->batCacheid); BBPunfix(s4->batCacheid); if (b->timprints != NULL) { + assert(0); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_SUCCEED; /* we were beaten to it */ } if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } imprints->bins = imprints->imprints.base + IMPRINTS_HEADER_SIZE * SIZEOF_SIZE_T; @@ -676,6 +701,7 @@ BATimprints(BAT *b) TRC_DEBUG(ACCELERATOR, "failed imprints construction: bat %s changed, " LLFMT " usec\n", BATgetId(b), GDKusec() - t0); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } ATOMIC_INIT(&imprints->imprints.refs, 1); @@ -693,6 +719,7 @@ BATimprints(BAT *b) MT_THR_DETACHED, name) < 0) BBPunfix(b->batCacheid); } _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org