Changeset: 286f512420a8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/286f512420a8
Modified Files:
gdk/gdk_storage.c
gdk/gdk_string.c
Branch: ustr
Log Message:
Fixes to WAL processing in connection with ustr bats.
diffs (78 lines):
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -672,19 +672,21 @@ BATsave_iter(BAT *b, BATiter *bi, BUN si
dosync = (BBP_status(b->batCacheid) & BBPPERSISTENT) != 0;
assert(!GDKinmemory(bi->h->farmid));
- /* views cannot be saved, but make an exception for
- * force-remapped views */
- if (isVIEW(b)) {
- if (locked)
- MT_rwlock_rdunlock(&b->thashlock);
- GDKerror("%s is a view on %s; cannot be saved\n", BATgetId(b),
BBP_logical(VIEWtparent(b)));
- return GDK_FAIL;
- }
if (!BATdirtybi(*bi)) {
if (locked)
MT_rwlock_rdunlock(&b->thashlock);
return GDK_SUCCEED;
}
+ /* views cannot be saved, but make an exception for
+ * force-remapped views */
+ if ((bi->h != NULL && bi->h->parentid != b->batCacheid) ||
+ (bi->vh != NULL && bi->vh->parentid != b->batCacheid &&
bi->vh->parentid != b->ustr)) {
+ if (locked)
+ MT_rwlock_rdunlock(&b->thashlock);
+ GDKerror("%s is a view on %s; cannot be saved\n", BATgetId(b),
BBP_logical(VIEWtparent(b)));
+ assert(0);
+ return GDK_FAIL;
+ }
/* start saving data */
if (bi->type != TYPE_void && bi->base == NULL) {
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -288,10 +288,37 @@ BATconvert2ustr(BAT *b, BAT *bu)
}
MT_lock_set(&bu->theaplock);
if (!bu->tvkey) {
- MT_lock_unset(&b->theaplock);
- MT_lock_unset(&bu->theaplock);
- GDKerror("USTR BAT must have tvkey property\n");
- return GDK_FAIL;
+ /* if bu was created and filled during initial WAL
+ * processing, the tvkey property may have gotten lost,
+ * so we check it: the way the bu bat is created, the
+ * offsets are strictly ascending */
+ assert(bu->twidth >= 4);
+ if (bu->twidth == 4) {
+ const uint32_t *p = (const uint32_t *) bu->theap->base;
+ uint32_t prev = 0;
+ for (BUN i = 0, n = bu->batCount; i < n; i++) {
+ if (p[i] <= prev) {
+ MT_lock_unset(&b->theaplock);
+ MT_lock_unset(&bu->theaplock);
+ GDKerror("USTR BAT must have tvkey
property\n");
+ return GDK_FAIL;
+ }
+ prev = p[i];
+ }
+ } else if (bu->twidth == 8) {
+ const uint64_t *p = (const uint64_t *) bu->theap->base;
+ uint64_t prev = 0;
+ for (BUN i = 0, n = bu->batCount; i < n; i++) {
+ if (p[i] <= prev) {
+ MT_lock_unset(&b->theaplock);
+ MT_lock_unset(&bu->theaplock);
+ GDKerror("USTR BAT must have tvkey
property\n");
+ return GDK_FAIL;
+ }
+ prev = p[i];
+ }
+ }
+ bu->tvkey = true;
}
if (bu->ustr) {
MT_lock_unset(&b->theaplock);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]