Changeset: b31eb0a73b77 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b31eb0a73b77
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_bat.c
gdk/gdk_bbp.c
gdk/gdk_logger.c
gdk/gdk_private.h
gdk/gdk_tm.c
gdk/gdk_utils.c
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_profiler.c
monetdb5/modules/atoms/mtime.c
monetdb5/modules/atoms/str.c
monetdb5/modules/kernel/bat5.c
monetdb5/modules/mal/bbp.c
monetdb5/modules/mal/clients.c
monetdb5/modules/mal/inspect.c
monetdb5/modules/mal/mdb.c
monetdb5/modules/mal/querylog.c
monetdb5/optimizer/opt_statistics.c
Branch: default
Log Message:
Cleanup: we don't need three versions of the same function to rename a BAT.
diffs (truncated from 448 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -152,7 +152,6 @@ BAT *BATmergecand(BAT *a, BAT *b);
void *BATmin(BAT *b, void *aggr);
gdk_return BATmode(BAT *b, int onoff);
void BATmsync(BAT *b);
-int BATname(BAT *b, const char *nme);
int BATordered(BAT *b);
int BATordered_rev(BAT *b);
gdk_return BATorderidx(BAT *b, int stable);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1344,8 +1344,6 @@ bat_iterator(BAT *b)
* @tab BATsetcapacity (BAT *b, BUN cnt)
* @item void
* @tab BATsetcount (BAT *b, BUN cnt)
- * @item BUN
- * @tab BATrename (BAT *b, str nme)
* @item BAT *
* @tab BATkey (BAT *b, int onoff)
* @item BAT *
@@ -1361,7 +1359,7 @@ bat_iterator(BAT *b)
* The function BATcount returns the number of associations stored in
* the BAT.
*
- * The BAT is given a new logical name using BATrename.
+ * The BAT is given a new logical name using BBPrename.
*
* The integrity properties to be maintained for the BAT are
* controlled separately. A key property indicates that duplicates in
@@ -1392,7 +1390,6 @@ gdk_export BUN BATgrows(BAT *b);
gdk_export gdk_return BATkey(BAT *b, int onoff);
gdk_export gdk_return BATmode(BAT *b, int onoff);
gdk_export void BATroles(BAT *b, const char *tnme);
-gdk_export int BATname(BAT *b, const char *nme);
gdk_export void BAThseqbase(BAT *b, oid o);
gdk_export void BATtseqbase(BAT *b, oid o);
gdk_export gdk_return BATsetaccess(BAT *b, int mode);
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1529,41 +1529,6 @@ BATtseqbase(BAT *b, oid o)
}
}
-/*
- * BATs have a logical name that is independent of their location in
- * the file system (this depends on batCacheid). The dimensions of
- * the BAT can be given a separate name. It helps front-ends in
- * identifying the column of interest. The new name should be
- * recognizable as an identifier. Otherwise interaction through the
- * front-ends becomes complicated.
- */
-int
-BATname(BAT *b, const char *nme)
-{
- BATcheck(b, "BATname", 0);
- return BBPrename(b->batCacheid, nme);
-}
-
-str
-BATrename(BAT *b, const char *nme)
-{
- int ret;
-
- BATcheck(b, "BATrename", NULL);
- ret = BATname(b, nme);
- if (ret == 1) {
- GDKerror("BATrename: identifier expected: %s\n", nme);
- } else if (ret == BBPRENAME_ALREADY) {
- GDKerror("BATrename: name is in use: '%s'.\n", nme);
- } else if (ret == BBPRENAME_ILLEGAL) {
- GDKerror("BATrename: illegal temporary name: '%s'\n", nme);
- } else if (ret == BBPRENAME_LONG) {
- GDKerror("BATrename: name too long: '%s'\n", nme);
- }
- return BBPname(b->batCacheid);
-}
-
-
void
BATroles(BAT *b, const char *tnme)
{
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2259,9 +2259,11 @@ BBPrename(bat bid, const char *nme)
BBPgetsubdir(dirname, bid);
if ((tmpid = BBPnamecheck(nme)) && tmpid != bid) {
+ GDKerror("BBPrename: illegal temporary name: '%s'\n", nme);
return BBPRENAME_ILLEGAL;
}
if (strlen(dirname) + strLen(nme) + 1 >= IDLENGTH) {
+ GDKerror("BBPrename: illegal temporary name: '%s'\n", nme);
return BBPRENAME_LONG;
}
idx = threadmask(MT_getpid());
@@ -2271,6 +2273,7 @@ BBPrename(bat bid, const char *nme)
if (i != 0) {
MT_lock_unset(&GDKnameLock);
MT_lock_unset(&GDKtrimLock(idx));
+ GDKerror("BBPrename: name is in use: '%s'.\n", nme);
return BBPRENAME_ALREADY;
}
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1199,12 +1199,10 @@ logger_switch_bat(BAT *old, BAT *new, co
}
snprintf(bak, sizeof(bak), "tmp_%o", old->batCacheid);
if (BBPrename(old->batCacheid, bak) != 0) {
- GDKerror("Logger_new: cannot rename old %s", name);
return GDK_FAIL;
}
snprintf(bak, sizeof(bak), "%s_%s", fn, name);
if (BBPrename(new->batCacheid, bak) != 0) {
- GDKerror("Logger_new: cannot rename new %s", name);
return GDK_FAIL;
}
return GDK_SUCCEED;
@@ -1440,19 +1438,16 @@ logger_load(int debug, const char *fn, c
* next time */
snprintf(bak, sizeof(bak), "%s_catalog_bid", fn);
if (BBPrename(lg->catalog_bid->batCacheid, bak) < 0) {
- GDKerror("logger_load: BBPrename to %s failed", bak);
goto error;
}
snprintf(bak, sizeof(bak), "%s_catalog_nme", fn);
if (BBPrename(lg->catalog_nme->batCacheid, bak) < 0) {
- GDKerror("logger_load: BBPrename to %s failed", bak);
goto error;
}
snprintf(bak, sizeof(bak), "%s_dcatalog", fn);
if (BBPrename(lg->dcatalog->batCacheid, bak) < 0) {
- GDKerror("logger_load: BBPrename to %s failed", bak);
goto error;
}
@@ -1538,7 +1533,6 @@ logger_load(int debug, const char *fn, c
goto error;
}
if (BBPrename(d->batCacheid, bak) < 0) {
- GDKerror("logger_load: BBPrename to %s failed",
bak);
BBPunfix(b->batCacheid);
BBPunfix(n->batCacheid);
goto error;
@@ -1582,7 +1576,6 @@ logger_load(int debug, const char *fn, c
snprintf(bak, sizeof(bak), "%s_freed", fn);
/* do not rename it if this is a shared logger */
if (!lg->shared && BBPrename(lg->freed->batCacheid, bak) < 0) {
- GDKerror("logger_load: BBPrename to %s failed", bak);
goto error;
}
snapshots_bid = logger_find_bat(lg, "snapshots_bid");
@@ -1618,7 +1611,6 @@ logger_load(int debug, const char *fn, c
snprintf(bak, sizeof(bak), "%s_snapshots_bid", fn);
if (BBPrename(lg->snapshots_bid->batCacheid, bak) < 0) {
- GDKerror("logger_load: BBPrename to %s failed", bak);
goto error;
}
if (logger_add_bat(lg, lg->snapshots_bid, "snapshots_bid") !=
GDK_SUCCEED) {
@@ -1629,7 +1621,6 @@ logger_load(int debug, const char *fn, c
snprintf(bak, sizeof(bak), "%s_snapshots_tid", fn);
if (BBPrename(lg->snapshots_tid->batCacheid, bak) < 0) {
- GDKerror("logger_load: BBPrename to %s failed", bak);
goto error;
}
if (logger_add_bat(lg, lg->snapshots_tid, "snapshots_tid") !=
GDK_SUCCEED) {
@@ -1640,7 +1631,6 @@ logger_load(int debug, const char *fn, c
snprintf(bak, sizeof(bak), "%s_dsnapshots", fn);
if (BBPrename(lg->dsnapshots->batCacheid, bak) < 0) {
- GDKerror("Logger_new: BBPrename to %s failed", bak);
goto error;
}
if (logger_add_bat(lg, lg->dsnapshots, "dsnapshots") !=
GDK_SUCCEED) {
@@ -1723,7 +1713,6 @@ logger_load(int debug, const char *fn, c
}
snprintf(bak, sizeof(bak), "%s_dsnapshots", fn);
if (BBPrename(lg->dsnapshots->batCacheid, bak) < 0) {
- GDKerror("Logger_new: BBPrename to %s failed",
bak);
goto error;
}
if (logger_add_bat(lg, lg->dsnapshots, "dsnapshots") !=
GDK_SUCCEED) {
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -67,8 +67,6 @@ enum heaptype {
__hidden gdk_return BATmaterialize(BAT *b)
__attribute__ ((__warn_unused_result__))
__attribute__((__visibility__("hidden")));
-__hidden str BATrename(BAT *b, const char *nme)
- __attribute__((__visibility__("hidden")));
__hidden gdk_return BATsave(BAT *b)
__attribute__ ((__warn_unused_result__))
__attribute__((__visibility__("hidden")));
diff --git a/gdk/gdk_tm.c b/gdk/gdk_tm.c
--- a/gdk/gdk_tm.c
+++ b/gdk/gdk_tm.c
@@ -13,7 +13,7 @@
* The Transaction Manager maintains the buffer of (permanent) BATS
* held resident. Entries from the BAT buffer are always accessed by
* BAT id. A BAT becomes permanent by assigning a name with
- * @%BATrename@. Access to the transaction table is regulated by a
+ * @%BBPrename@. Access to the transaction table is regulated by a
* semaphore.
*/
#include "monetdb_config.h"
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -582,8 +582,9 @@ GDKinit(opt *set, int setlen)
/* no cleanup necessary before GDKfatal */
GDKfatal("GDKinit: Could not create environment BAT");
}
- BATrename(GDKkey, "environment_key");
- BATrename(GDKval, "environment_val");
+ if (BBPrename(GDKkey->batCacheid, "environment_key") != 0 ||
+ BBPrename(GDKval->batCacheid, "environment_val") != 0)
+ GDKfatal("GDKinit: BBPrename failed");
/* store options into environment BATs */
for (i = 0; i < nlen; i++)
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -174,9 +174,11 @@ AUTHinitTables(const char *passwd) {
if (user == NULL)
throw(MAL, "initTables.user", MAL_MALLOC_FAIL " user
table");
- BATkey(user, TRUE);
- BBPrename(BBPcacheid(user), "M5system_auth_user");
- BATmode(user, PERSISTENT);
+ if (BATkey(user, TRUE) != GDK_SUCCEED ||
+ BBPrename(BBPcacheid(user), "M5system_auth_user") != 0
||
+ BATmode(user, PERSISTENT) != GDK_SUCCEED) {
+ throw(MAL, "initTables.user", GDK_EXCEPTION);
+ }
} else {
int dbg = GDKdebug;
/* don't check this bat since we'll fix it below */
@@ -194,8 +196,10 @@ AUTHinitTables(const char *passwd) {
if (pass == NULL)
throw(MAL, "initTables.passwd", MAL_MALLOC_FAIL "
password table");
- BBPrename(BBPcacheid(pass), "M5system_auth_passwd_v2");
- BATmode(pass, PERSISTENT);
+ if (BBPrename(BBPcacheid(pass), "M5system_auth_passwd_v2") != 0
||
+ BATmode(pass, PERSISTENT) != GDK_SUCCEED) {
+ throw(MAL, "initTables.user", GDK_EXCEPTION);
+ }
} else {
int dbg = GDKdebug;
/* don't check this bat since we'll fix it below */
@@ -213,8 +217,10 @@ AUTHinitTables(const char *passwd) {
if (duser == NULL)
throw(MAL, "initTables.duser", MAL_MALLOC_FAIL "
deleted user table");
- BBPrename(BBPcacheid(duser), "M5system_auth_deleted");
- BATmode(duser, PERSISTENT);
+ if (BBPrename(BBPcacheid(duser), "M5system_auth_deleted") != 0
||
+ BATmode(duser, PERSISTENT) != GDK_SUCCEED) {
+ throw(MAL, "initTables.user", GDK_EXCEPTION);
+ }
if (!isNew)
AUTHcommit();
} else {
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -695,7 +695,10 @@ TRACEcreate(const char *hnme, const char
b = COLnew(0, tt, 1 << 16, TRANSIENT);
if (b == NULL)
return NULL;
- BBPrename(b->batCacheid, buf);
+ if (BBPrename(b->batCacheid, buf) != 0) {
+ BBPreclaim(b);
+ return NULL;
+ }
return b;
}
diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -1375,8 +1375,9 @@ MTIMEprelude(void *ret)
BBPreclaim(tzbatdef);
throw(MAL, "time.prelude", MAL_MALLOC_FAIL);
}
- BBPrename(tzbatnme->batCacheid, "timezone_name");
- BBPrename(tzbatdef->batCacheid, "timezone_def");
+ if (BBPrename(tzbatnme->batCacheid, "timezone_name") != 0 ||
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list