Changeset: f713c5f43963 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f713c5f43963
Modified Files:
gdk/gdk_bbp.c
sql/backends/monet5/sql_upgrades.c
sql/storage/bat/bat_logger.c
Branch: default
Log Message:
Remove old upgrade code (pre 2016).
diffs (truncated from 1169 to 300 lines):
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1042,13 +1042,12 @@ vheapinit(BAT *b, const char *buf, int h
return n;
}
-static int
+static void
BBPreadEntries(FILE *fp, int oidsize, int bbpversion)
{
bat bid = 0;
char buf[4096];
BAT *bn;
- int needcommit = 0;
/* read the BBP.dir and insert the BATs into the BBP */
while (fgets(buf, sizeof(buf), fp) != NULL) {
@@ -1153,21 +1152,11 @@ BBPreadEntries(FILE *fp, int oidsize, in
nread += heapinit(bn, buf + nread, &Thashash, "T", oidsize,
bbpversion, bid);
nread += vheapinit(bn, buf + nread, Thashash, bid);
- if (bn->batCount > 1) {
- /* fix result of bug in BATappend not clearing
- * revsorted property */
- if (bn->ttype == TYPE_void && bn->tseqbase != oid_nil
&& bn->trevsorted != (bn->batCount <= 1)) {
- bn->trevsorted = bn->batCount <= 1;
- bn->batDirtydesc = 1;
- needcommit = 1;
- }
- }
if (bbpversion <= GDKLIBRARY_NOKEY &&
(bn->tnokey[0] != 0 || bn->tnokey[1] != 0)) {
/* we don't trust the nokey values */
bn->tnokey[0] = bn->tnokey[1] = 0;
bn->batDirtydesc = 1;
- needcommit = 1;
}
if (buf[nread] != '\n' && buf[nread] != ' ')
@@ -1194,7 +1183,6 @@ BBPreadEntries(FILE *fp, int oidsize, in
BBP_refs(bid) = 0;
BBP_lrefs(bid) = 1; /* any BAT we encounter here is
persistent, so has a logical reference */
}
- return needcommit;
}
#ifdef HAVE_HGE
@@ -1321,7 +1309,6 @@ BBPinit(void)
int oidsize;
str bbpdirstr = GDKfilepath(0, BATDIR, "BBP", "dir");
str backupbbpdirstr = GDKfilepath(0, BAKDIR, "BBP", "dir");
- int needcommit;
#ifdef NEED_MT_LOCK_INIT
MT_lock_init(&GDKunloadLock, "GDKunloadLock");
@@ -1374,7 +1361,7 @@ BBPinit(void)
BBPextend(0, FALSE); /* allocate BBP records */
ATOMIC_SET(BBPsize, 1, BBPsizeLock);
- needcommit = BBPreadEntries(fp, oidsize, bbpversion);
+ BBPreadEntries(fp, oidsize, bbpversion);
fclose(fp);
BBPinithash(0);
@@ -1404,7 +1391,7 @@ BBPinit(void)
if (bbpversion <= GDKLIBRARY_OLDWKB)
fixwkbheap();
#endif
- if (bbpversion < GDKLIBRARY || needcommit)
+ if (bbpversion < GDKLIBRARY)
TMcommit();
GDKfree(bbpdirstr);
GDKfree(backupbbpdirstr);
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
@@ -22,589 +22,6 @@
#define printf(fmt,...) ((void) 0)
#endif
-/* Because of a difference of computing hash values for single vs bulk
operators we need to drop and recreate all constraints/indices */
-static str
-sql_update_oct2014_2(Client c, mvc *sql)
-{
- size_t bufsize = 8192*2, pos = 0, recreate = 0;
- char *buf = GDKmalloc(bufsize), *err = NULL;
- res_table *fresult = NULL, *presult = NULL, *iresult = NULL;
-
- /* get list of all foreign keys */
- pos += snprintf(buf + pos, bufsize - pos,
- "SELECT fs.name, ft.name, fk.name, fk.\"action\",
ps.name, pt.name FROM sys.keys fk, sys.tables ft, sys.schemas fs, sys.keys pk,
sys.tables pt, sys.schemas ps WHERE fk.type = 2 AND (SELECT count(*) FROM
sys.objects o WHERE o.id = fk.id) > 1 AND ft.id = fk.table_id AND ft.schema_id
= fs.id AND fk.rkey = pk.id AND pk.table_id = pt.id AND pt.schema_id =
ps.id;\n");
- err = SQLstatementIntern(c, &buf, "update", 1, 0, &fresult);
-
- /* get all primary/unique keys */
- pos = 0;
- pos += snprintf(buf + pos, bufsize - pos,
- "SELECT s.name, t.name, k.name, k.type FROM sys.keys k,
sys.tables t, sys.schemas s WHERE k.type < 2 AND (SELECT count(*) FROM
sys.objects o WHERE o.id = k.id) > 1 AND t.id = k.table_id AND t.schema_id =
s.id;\n");
- err = SQLstatementIntern(c, &buf, "update", 1, 0, &presult);
-
- /* get indices */
- pos = 0;
- pos += snprintf(buf + pos, bufsize - pos,
- "SELECT s.name, t.name, i.name FROM sys.idxs i,
sys.schemas s, sys.tables t WHERE i.table_id = t.id AND t.schema_id = s.id AND
t.system = FALSE AND (SELECT count(*) FROM sys.objects o WHERE o.id = i.id) >
1;\n");
- err = SQLstatementIntern(c, &buf, "update", 1, 0, &iresult);
-
- if (fresult) {
- BATiter fs_name =
bat_iterator(BATdescriptor(fresult->cols[0].b));
- BATiter ft_name =
bat_iterator(BATdescriptor(fresult->cols[1].b));
- BATiter fk_name =
bat_iterator(BATdescriptor(fresult->cols[2].b));
- BATiter fk_action =
bat_iterator(BATdescriptor(fresult->cols[3].b));
- BATiter ps_name =
bat_iterator(BATdescriptor(fresult->cols[4].b));
- BATiter pt_name =
bat_iterator(BATdescriptor(fresult->cols[5].b));
- oid id = 0, cnt = BATcount(fs_name.b);
-
- pos = 0;
- /* get list of all foreign key objects */
- for(id = 0; id<cnt; id++) {
- char *fsname = (str)BUNtail(fs_name, id);
- char *ftname = (str)BUNtail(ft_name, id);
- char *fkname = (str)BUNtail(fk_name, id);
- int *fkaction = (int*)BUNtail(fk_action, id);
- int on_delete = ((*fkaction) & 0xFF);
- int on_update = (((*fkaction)>>8) & 0xFF);
- char *psname = (str)BUNtail(ps_name, id);
- char *ptname = (str)BUNtail(pt_name, id);
- sql_schema *s = mvc_bind_schema(sql, fsname);
- sql_key *k = mvc_bind_key(sql, s, fkname);
- sql_ukey *r = ((sql_fkey*)k)->rkey;
- char *sep = "";
- node *n;
-
- /* create recreate calls */
- pos += snprintf(buf + pos, bufsize - pos, "ALTER table
\"%s\".\"%s\" ADD CONSTRAINT \"%s\" FOREIGN KEY (", fsname, ftname, fkname);
- for (n = k->columns->h; n; n = n->next) {
- sql_kc *kc = n->data;
-
- pos += snprintf(buf + pos, bufsize - pos,
"%s\"%s\"", sep, kc->c->base.name);
- sep = ", ";
- }
- pos += snprintf(buf + pos, bufsize - pos, ") REFERENCES
\"%s\".\"%s\" (", psname, ptname );
- sep = "";
- for (n = r->k.columns->h; n; n = n->next) {
- sql_kc *kc = n->data;
-
- pos += snprintf(buf + pos, bufsize - pos,
"%s\"%s\"", sep, kc->c->base.name);
- sep = ", ";
- }
- pos += snprintf(buf + pos, bufsize - pos, ") ");
- if (on_delete != 2)
- pos += snprintf(buf + pos, bufsize - pos, "%s",
(on_delete==0?"NO ACTION":on_delete==1?"CASCADE":on_delete==3?"SET NULL":"SET
DEFAULT"));
-
- if (on_update != 2)
- pos += snprintf(buf + pos, bufsize - pos, "%s",
(on_update==0?"NO ACTION":on_update==1?"CASCADE":on_update==3?"SET NULL":"SET
DEFAULT"));
- pos += snprintf(buf + pos, bufsize - pos, ";\n");
- assert(pos < bufsize);
-
- /* drop foreign key */
- mvc_drop_key(sql, s, k, 0 /* drop_action?? */);
- }
- if (pos) {
- SQLautocommit(c, sql);
- SQLtrans(sql);
- recreate = pos;
- }
- }
-
- if (presult) {
- BATiter s_name =
bat_iterator(BATdescriptor(presult->cols[0].b));
- BATiter t_name =
bat_iterator(BATdescriptor(presult->cols[1].b));
- BATiter k_name =
bat_iterator(BATdescriptor(presult->cols[2].b));
- BATiter k_type =
bat_iterator(BATdescriptor(presult->cols[3].b));
- oid id = 0, cnt = BATcount(s_name.b);
- char *buf = GDKmalloc(bufsize);
-
- pos = 0;
- for(id = 0; id<cnt; id++) {
- char *sname = (str)BUNtail(s_name, id);
- char *tname = (str)BUNtail(t_name, id);
- char *kname = (str)BUNtail(k_name, id);
- int *ktype = (int*)BUNtail(k_type, id);
- sql_schema *s = mvc_bind_schema(sql, sname);
- sql_key *k = mvc_bind_key(sql, s, kname);
- node *n;
- char *sep = "";
-
- /* create recreate calls */
- pos += snprintf(buf + pos, bufsize - pos, "ALTER table
\"%s\".\"%s\" ADD CONSTRAINT \"%s\" %s (", sname, tname, kname, *ktype ==
0?"PRIMARY KEY":"UNIQUE");
- for (n = k->columns->h; n; n = n->next) {
- sql_kc *kc = n->data;
-
- pos += snprintf(buf + pos, bufsize - pos,
"%s\"%s\"", sep, kc->c->base.name);
- sep = ", ";
- }
- pos += snprintf(buf + pos, bufsize - pos, ");\n" );
- assert(pos < bufsize);
-
- /* drop primary/unique key */
- mvc_drop_key(sql, s, k, 0 /* drop_action?? */);
- }
- if (pos) {
- SQLautocommit(c, sql);
- SQLtrans(sql);
-
- /* recreate primary and unique keys */
- printf("Running database upgrade commands:\n%s\n", buf);
- err = SQLstatementIntern(c, &buf, "update", 1, 0, NULL);
- if (!err)
- SQLautocommit(c, sql);
- SQLtrans(sql);
- }
- GDKfree(buf);
- }
-
- if (iresult) {
- BATiter s_name =
bat_iterator(BATdescriptor(iresult->cols[0].b));
- BATiter t_name =
bat_iterator(BATdescriptor(iresult->cols[1].b));
- BATiter i_name =
bat_iterator(BATdescriptor(iresult->cols[2].b));
- oid id = 0, cnt = BATcount(s_name.b);
- char *buf = GDKmalloc(bufsize);
-
- pos = 0;
- for(id = 0; id<cnt; id++) {
- char *sname = (str)BUNtail(s_name, id);
- char *tname = (str)BUNtail(t_name, id);
- char *iname = (str)BUNtail(i_name, id);
- sql_schema *s = mvc_bind_schema(sql, sname);
- sql_idx *k = mvc_bind_idx(sql, s, iname);
- node *n;
- char *sep = "";
-
- if (!k || k->key)
- continue;
- /* create recreate calls */
- pos += snprintf(buf + pos, bufsize - pos, "CREATE INDEX
\"%s\" ON \"%s\".\"%s\" (", iname, sname, tname);
- for (n = k->columns->h; n; n = n->next) {
- sql_kc *kc = n->data;
-
- pos += snprintf(buf + pos, bufsize - pos,
"%s\"%s\"", sep, kc->c->base.name);
- sep = ", ";
- }
- pos += snprintf(buf + pos, bufsize - pos, ");\n" );
- assert(pos < bufsize);
-
- /* drop index */
- mvc_drop_idx(sql, s, k);
- }
- if (pos) {
- SQLautocommit(c, sql);
- SQLtrans(sql);
-
- /* recreate indices */
- printf("Running database upgrade commands:\n%s\n", buf);
- err = SQLstatementIntern(c, &buf, "update", 1, 0, NULL);
- if (!err)
- SQLautocommit(c, sql);
- SQLtrans(sql);
- }
- GDKfree(buf);
- }
-
-
- /* recreate foreign keys */
- if (recreate) {
- printf("Running database upgrade commands:\n%s\n", buf);
- err = SQLstatementIntern(c, &buf, "update", 1, 0, NULL);
- if (!err)
- SQLautocommit(c, sql);
- SQLtrans(sql);
- }
- return err;
-}
-
-static str
-sql_update_oct2014(Client c, mvc *sql)
-{
- size_t bufsize = 8192*2, pos = 0;
- char *buf = GDKmalloc(bufsize), *err = NULL;
- char *schema = stack_get_string(sql, "current_schema");
- sql_table *t;
- sql_schema *s;
-
- pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
-
- /* cleanup columns of dropped views */
- pos += snprintf(buf + pos, bufsize - pos,
- "delete from _columns where table_id not in (select id
from _tables);\n");
-
- /* add new columns */
- store_next_oid(); /* reserve id for max(id)+1 */
- pos += snprintf(buf + pos, bufsize - pos,
- "insert into _columns values( (select max(id)+1 from
_columns), 'system', 'boolean', 1, 0, (select _tables.id from _tables join
schemas on _tables.schema_id=schemas.id where schemas.name='sys' and
_tables.name='schemas'), NULL, true, 4, NULL);\n");
- store_next_oid();
- pos += snprintf(buf + pos, bufsize - pos,
- "insert into _columns values( (select max(id)+1 from
_columns), 'varres', 'boolean', 1, 0, (select _tables.id from _tables join
schemas on _tables.schema_id=schemas.id where schemas.name='sys' and
_tables.name='functions'), NULL, true, 7, NULL);\n");
- store_next_oid();
- pos += snprintf(buf + pos, bufsize - pos,
- "insert into _columns values( (select max(id)+1 from
_columns), 'vararg', 'boolean', 1, 0, (select _tables.id from _tables join
schemas on _tables.schema_id=schemas.id where schemas.name='sys' and
_tables.name='functions'), NULL, true, 8, NULL);\n");
- store_next_oid();
- pos += snprintf(buf + pos, bufsize - pos,
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list