Changeset: 42b7d8db8df1 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=42b7d8db8df1
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_heap.c
gdk/gdk_tm.c
sql/storage/bat/bat_utils.c
sql/storage/store.c
Branch: Jun2016
Log Message:
Merge with Jul2015 branch.
diffs (215 lines):
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -113,6 +113,12 @@ static BAT *getBBPdescriptor(bat i, int
static gdk_return BBPbackup(BAT *b, bit subcommit);
static gdk_return BBPdir(int cnt, bat *subcommit);
+#ifdef HAVE_HGE
+/* start out by saying we have no hge, but as soon as we've seen one,
+ * we'll always say we do have it */
+static int havehge = 0;
+#endif
+
#define BBPnamecheck(s) (BBPtmpcheck(s) ? ((s)[3] == '_' ? strtol((s) + 4,
NULL, 8) : -strtol((s) + 5, NULL, 8)) : 0)
#ifdef ATOMIC_LOCK
@@ -944,6 +950,10 @@ heapinit(COLrec *col, const char *buf, i
/* silently convert chr columns to bte */
if (strcmp(type, "chr") == 0)
strcpy(type, "bte");
+#ifdef HAVE_HGE
+ else if (strcmp(type, "hge") == 0)
+ havehge = 1;
+#endif
if ((t = ATOMindex(type)) < 0)
t = ATOMunknown_find(type);
else if (var != (t == TYPE_void || BATatoms[t].atomPut != NULL))
@@ -1588,7 +1598,11 @@ static gdk_return
BBPdir_header(FILE *f, int n)
{
if (fprintf(f, "BBP.dir, GDKversion %d\n%d %d %d\n",
- GDKLIBRARY, SIZEOF_SIZE_T, SIZEOF_OID, SIZEOF_MAX_INT) < 0
||
+ GDKLIBRARY, SIZEOF_SIZE_T, SIZEOF_OID,
+#ifdef HAVE_HGE
+ havehge ? SIZEOF_HGE :
+#endif
+ SIZEOF_LNG) < 0 ||
OIDwrite(f) < 0 ||
fprintf(f, " BBPsize=%d\n", n) < 0 ||
ferror(f)) {
@@ -2124,6 +2138,11 @@ BBPinsert(BATstore *bs)
BBP_refs(i) = 1; /* new bats have 1 pin */
BBP_lrefs(i) = 0; /* ie. no logical refs */
+#ifdef HAVE_HGE
+ if (bs->T.type == TYPE_hge)
+ havehge = 1;
+#endif
+
if (BBP_bak(i) == NULL) {
s = BBPtmpname(dirname, 64, i);
BBP_logical(i) = GDKstrdup(s);
@@ -3605,8 +3624,8 @@ BBPprepare(bit subcommit)
}
static gdk_return
-do_backup(const char *srcdir, const char *nme, const char *extbase,
- Heap *h, int tp, int dirty, bit subcommit)
+do_backup(const char *srcdir, const char *nme, const char *ext,
+ Heap *h, int dirty, bit subcommit)
{
gdk_return ret = GDK_SUCCEED;
@@ -3614,10 +3633,11 @@ do_backup(const char *srcdir, const char
* protection); however, if we're backing up for subcommit
* and a backup already exists in the main backup directory
* (see GDKupgradevarheap), move the file */
- if (subcommit && file_exists(h->farmid, BAKDIR, nme, extbase)) {
- if (file_move(h->farmid, BAKDIR, SUBDIR, nme, extbase) !=
GDK_SUCCEED)
+ if (subcommit && file_exists(h->farmid, BAKDIR, nme, ext)) {
+ if (file_move(h->farmid, BAKDIR, SUBDIR, nme, ext) !=
GDK_SUCCEED)
return GDK_FAIL;
- } else if (h->storage != STORE_MMAP) {
+ }
+ if (h->storage != STORE_MMAP) {
/* STORE_PRIV saves into X.new files. Two cases could
* happen. The first is when a valid X.new exists
* because of an access change or a previous
@@ -3627,23 +3647,34 @@ do_backup(const char *srcdir, const char
* X.new files (after a crash). To protect against
* these we write X.new.kill files in the backup
* directory (see heap_move). */
- char ext[16];
+ char extnew[16];
gdk_return mvret = GDK_SUCCEED;
- if (h->filename && h->newstorage == STORE_PRIV)
- snprintf(ext, sizeof(ext), "%s.new", extbase);
- else
- snprintf(ext, sizeof(ext), "%s", extbase);
- if (tp && dirty && !file_exists(h->farmid, BAKDIR, nme, ext)) {
- /* file will be saved (is dirty), move the old
- * image into backup */
- mvret = heap_move(h, srcdir, subcommit ? SUBDIR :
BAKDIR, nme, ext);
- } else if (subcommit && tp &&
- (dirty || file_exists(h->farmid, BAKDIR, nme, ext)))
{
- /* file is clean. move the backup into the
- * subcommit dir (commit should eliminate
- * backup) */
- mvret = file_move(h->farmid, BAKDIR, SUBDIR, nme, ext);
+ snprintf(extnew, sizeof(extnew), "%s.new", ext);
+ if (dirty &&
+ !file_exists(h->farmid, BAKDIR, nme, extnew) &&
+ !file_exists(h->farmid, BAKDIR, nme, ext)) {
+ /* if the heap is dirty and there is no heap
+ * file (with or without .new extension) in
+ * the BAKDIR, move the heap (preferably with
+ * .new extension) to the correct backup
+ * directory */
+ if (file_exists(h->farmid, srcdir, nme, extnew))
+ mvret = heap_move(h, srcdir,
+ subcommit ? SUBDIR : BAKDIR,
+ nme, extnew);
+ else
+ mvret = heap_move(h, srcdir,
+ subcommit ? SUBDIR : BAKDIR,
+ nme, ext);
+ } else if (subcommit) {
+ /* if subcommit, wqe may need to move an
+ * already made backup from BAKDIR to
+ * SUBSIR */
+ if (file_exists(h->farmid, BAKDIR, nme, extnew))
+ mvret = file_move(h->farmid, BAKDIR, SUBDIR,
nme, extnew);
+ else if (file_exists(h->farmid, BAKDIR, nme, ext))
+ mvret = file_move(h->farmid, BAKDIR, SUBDIR,
nme, ext);
}
/* there is a situation where the move may fail,
* namely if this heap was not supposed to be existing
@@ -3690,20 +3721,20 @@ BBPbackup(BAT *b, bit subcommit)
nme[sizeof(nme) - 1] = 0;
srcdir[s - srcdir] = 0;
- if (do_backup(srcdir, nme, "head", &b->H->heap, b->htype,
+ if (b->htype != TYPE_void &&
+ do_backup(srcdir, nme, "head", &b->H->heap,
b->batDirty || b->H->heap.dirty, subcommit) !=
GDK_SUCCEED)
goto fail;
- if (do_backup(srcdir, nme, "tail", &b->T->heap, b->ttype,
+ if (b->ttype != TYPE_void &&
+ do_backup(srcdir, nme, "tail", &b->T->heap,
b->batDirty || b->T->heap.dirty, subcommit) !=
GDK_SUCCEED)
goto fail;
if (b->H->vheap &&
do_backup(srcdir, nme, "hheap", b->H->vheap,
- b->htype && b->hvarsized,
b->batDirty || b->H->vheap->dirty, subcommit) !=
GDK_SUCCEED)
goto fail;
if (b->T->vheap &&
do_backup(srcdir, nme, "theap", b->T->vheap,
- b->ttype && b->tvarsized,
b->batDirty || b->T->vheap->dirty, subcommit) !=
GDK_SUCCEED)
goto fail;
GDKfree(srcdir);
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -582,6 +582,10 @@ HEAPfree(Heap *h, int remove)
if (path && unlink(path) < 0 && errno != ENOENT)
perror(path);
GDKfree(path);
+ path = GDKfilepath(h->farmid, BATDIR, h->filename,
"new");
+ if (path && unlink(path) < 0 && errno != ENOENT)
+ perror(path);
+ GDKfree(path);
}
GDKfree(h->filename);
h->filename = NULL;
diff --git a/gdk/gdk_tm.c b/gdk/gdk_tm.c
--- a/gdk/gdk_tm.c
+++ b/gdk/gdk_tm.c
@@ -148,7 +148,7 @@ TMcommit(void)
* @- TMsubcommit
*
* Create a new checkpoint that is equal to the previous, with the
- * expection that for the passed list of batnames, the current state
+ * exception that for the passed list of batnames, the current state
* will be reflected in the new checkpoint.
*
* On the bats in this list we assume exclusive access during the
diff --git a/sql/storage/bat/bat_utils.c b/sql/storage/bat/bat_utils.c
--- a/sql/storage/bat/bat_utils.c
+++ b/sql/storage/bat/bat_utils.c
@@ -8,6 +8,7 @@
#include "monetdb_config.h"
#include "bat_utils.h"
+#include "mal.h" /* for have_hge */
void
bat_destroy(BAT *b)
@@ -175,7 +176,11 @@ bat_utils_init(void)
int t;
for (t=1; t<GDKatomcnt; t++) {
- if (t != TYPE_bat && BATatoms[t].name[0]) {
+ if (t != TYPE_bat && BATatoms[t].name[0]
+#ifdef HAVE_HGE
+ && (have_hge || t != TYPE_hge)
+#endif
+ ) {
ebats[t] = bat_new(TYPE_void, t, 0, TRANSIENT);
bat_set_access(ebats[t], BAT_READ);
}
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1085,7 +1085,7 @@ insert_functions(sql_trans *tr, sql_tabl
char arg_nme[] = "arg_0";
if (f->s)
- table_funcs.table_insert(tr, sysfunc, &f->base.id,
f->base.name, f->imp, f->mod, &lang, &f->type, &se,&f->varres, &f->vararg,
&f->s->base.id);
+ table_funcs.table_insert(tr, sysfunc, &f->base.id,
f->base.name, f->imp, f->mod, &lang, &f->type, &se, &f->varres, &f->vararg,
&f->s->base.id);
else
table_funcs.table_insert(tr, sysfunc, &f->base.id,
f->base.name, f->imp, f->mod, &lang, &f->type, &se, &f->varres, &f->vararg,
&zero);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list