Changeset: eb0390531aa2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=eb0390531aa2
Modified Files:
gdk/gdk.h
sql/backends/monet5/sql_upgrades.c
sql/storage/bat/bat_logger.c
sql/storage/store.c
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
Branch: system-functions
Log Message:
Implemented upgrade for sys.functions.system column.
diffs (140 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2681,7 +2681,7 @@ gdk_export void VIEWbounds(BAT *b, BAT *
for (hb = HASHget(h, hash_##TYPE(h, v)); \
hb != HASHnil(h); \
hb = HASHgetlink(h,hb)) \
- if (* (const TYPE *) v == * (const TYPE *) BUNtloc(bi, hb))
+ if (* (const TYPE *) (v) == * (const TYPE *) BUNtloc(bi, hb))
#define HASHloop_bte(bi, h, hb, v) HASHloop_TYPE(bi, h, hb, v, bte)
#define HASHloop_sht(bi, h, hb, v) HASHloop_TYPE(bi, h, hb, v, sht)
diff --git a/sql/backends/monet5/sql_upgrades.c
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -1516,9 +1516,9 @@ sql_update_default(Client c, mvc *sql)
pos += snprintf(buf + pos, bufsize - pos, "set schema sys;\n");
pos += snprintf(buf + pos, bufsize - pos,
- "create aggregate sys.group_concat(str string) returns
string external name \"aggr\".\"str_group_concat\";\n"
+ "create system aggregate sys.group_concat(str string)
returns string external name \"aggr\".\"str_group_concat\";\n"
"grant execute on aggregate sys.group_concat(string) to
public;\n"
- "create aggregate sys.group_concat(str string, sep
string) returns string external name \"aggr\".\"str_group_concat\";\n"
+ "create system aggregate sys.group_concat(str string,
sep string) returns string external name \"aggr\".\"str_group_concat\";\n"
"grant execute on aggregate sys.group_concat(string,
string) to public;\n"
"insert into sys.systemfunctions (select id from
sys.functions where name in ('group_concat') and schema_id = (select id from
sys.schemas where name = 'sys') and id not in (select function_id from
sys.systemfunctions));\n");
diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -20,6 +20,7 @@ static gdk_return
bl_preversion(int oldversion, int newversion)
{
#define CATALOG_JUL2015 52200
+#define CATALOG_MAR2018 52201
(void)newversion;
if (oldversion == CATALOG_JUL2015) {
@@ -29,11 +30,17 @@ bl_preversion(int oldversion, int newver
return GDK_SUCCEED;
}
+ if (oldversion == CATALOG_MAR2018) {
+ /* upgrade to default releases */
+ catalog_version = oldversion;
+ return GDK_SUCCEED;
+ }
+
return GDK_FAIL;
}
static char *
-N( char *buf, char *pre, char *schema, char *post)
+N(char *buf, const char *pre, const char *schema, const char *post)
{
if (pre)
snprintf(buf, 64, "%s_%s_%s", pre, schema, post);
@@ -189,6 +196,55 @@ bl_postversion( void *lg)
* nothing */
}
}
+
+ if (catalog_version <= CATALOG_MAR2018) {
+ const char *s = "sys";
+ char n[64];
+ BAT *fid = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"functions_id")));
+ BAT *sf = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"systemfunctions_function_id")));
+ if (fid == NULL || sf == NULL) {
+ bat_destroy(fid);
+ bat_destroy(sf);
+ return GDK_FAIL;
+ }
+ BAT *b = COLnew(fid->hseqbase, TYPE_bit, BATcount(fid),
PERSISTENT);
+ if (b == NULL) {
+ bat_destroy(fid);
+ bat_destroy(sf);
+ return GDK_FAIL;
+ }
+ const int *fids = (const int *) Tloc(fid, 0);
+ bit *fsys = (bit *) Tloc(b, 0);
+ BATiter sfi = bat_iterator(sf);
+ if (BAThash(sf, 0) != GDK_SUCCEED) {
+ BBPreclaim(b);
+ bat_destroy(fid);
+ bat_destroy(sf);
+ return GDK_FAIL;
+ }
+ for (BUN p = 0, q = BATcount(fid); p < q; p++) {
+ BUN i;
+ fsys[p] = 0;
+ HASHloop_int(sfi, sf->thash, i, fids + p) {
+ fsys[p] = 1;
+ break;
+ }
+ }
+ b->tkey = false;
+ b->tsorted = b->trevsorted = false;
+ b->tnonil = true;
+ b->tnil = false;
+ BATsetcount(b, BATcount(fid));
+ bat_destroy(fid);
+ bat_destroy(sf);
+ if (BATsetaccess(b, BAT_READ) != GDK_SUCCEED ||
+ logger_add_bat(lg, b, N(n, NULL, s, "functions_system")) !=
GDK_SUCCEED) {
+ BBPreclaim(b);
+ return GDK_FAIL;
+ }
+ bat_destroy(b);
+ }
+
return GDK_SUCCEED;
}
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -18,7 +18,7 @@
#include "bat/bat_logger.h"
/* version 05.21.00 of catalog */
-#define CATALOG_VERSION 52201
+#define CATALOG_VERSION 52202
int catalog_version = 0;
static MT_Lock bs_lock MT_LOCK_INITIALIZER("bs_lock");
diff --git a/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
b/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
@@ -26,9 +26,9 @@ stdout of test 'upgrade` in directory 's
Ready.
Running database upgrade commands:
set schema sys;
-create aggregate sys.group_concat(str string) returns string external name
"aggr"."str_group_concat";
+create system aggregate sys.group_concat(str string) returns string external
name "aggr"."str_group_concat";
grant execute on aggregate sys.group_concat(string) to public;
-create aggregate sys.group_concat(str string, sep string) returns string
external name "aggr"."str_group_concat";
+create system aggregate sys.group_concat(str string, sep string) returns
string external name "aggr"."str_group_concat";
grant execute on aggregate sys.group_concat(string, string) to public;
insert into sys.systemfunctions (select id from sys.functions where name in
('group_concat') and schema_id = (select id from sys.schemas where name =
'sys') and id not in (select function_id from sys.systemfunctions));
set schema "sys";
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list