Changeset: cc7aedcd69d4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cc7aedcd69d4
Modified Files:
sql/storage/bat/bat_logger.c
Branch: Oct2014
Log Message:
It turns out that we can't upgrade from releases before Oct2014.
This is true since the hack that allowed an upgrade from an older
release was incompatible with the upgrade code for renumbering the
EC_* class values (sys.types.eclass) that was done for the Oct2014-SP3
release.
diffs (truncated from 359 to 300 lines):
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
@@ -27,12 +27,6 @@ logger *bat_logger = NULL;
static int
bl_preversion( int oldversion, int newversion)
{
-#define CATALOG_FEB2010 50000
-#define CATALOG_OCT2010 51000
-#define CATALOG_APR2011 51100
-#define CATALOG_AUG2011 51101
-#define CATALOG_DEC2011 52000
-#define CATALOG_FEB2013 52001
#define CATALOG_OCT2014 52100
(void)newversion;
@@ -40,26 +34,6 @@ bl_preversion( int oldversion, int newve
catalog_version = oldversion;
return 0;
}
- if (oldversion == CATALOG_FEB2013) {
- catalog_version = oldversion;
- return 0;
- }
- if (oldversion == CATALOG_OCT2010) {
- catalog_version = oldversion;
- return 0;
- }
- if (oldversion == CATALOG_APR2011) {
- catalog_version = oldversion;
- return 0;
- }
- if (oldversion == CATALOG_AUG2011) {
- catalog_version = oldversion;
- return 0;
- }
- if (oldversion == CATALOG_DEC2011) {
- catalog_version = oldversion;
- return 0;
- }
return -1;
}
@@ -73,14 +47,6 @@ N( char *buf, char *pre, char *schema, c
return buf;
}
-static char *
-I( char *buf, char *schema, char *table, char *iname)
-{
- snprintf(buf, 64, "%s_%s@%s", schema, table, iname);
- return buf;
-}
-
-
#ifndef HAVE_STRCASESTR
static const char *
strcasestr(const char *haystack, const char *needle)
@@ -110,7 +76,7 @@ static void
bl_postversion( void *lg)
{
(void)lg;
- if (catalog_version == CATALOG_OCT2014) {
+ if (catalog_version <= CATALOG_OCT2014) {
BAT *te, *tn, *tne;
BATiter tei, tni;
char *s = "sys", n[64];
@@ -141,291 +107,6 @@ bl_postversion( void *lg)
bat_destroy(te);
bat_destroy(tn);
}
- if (catalog_version == CATALOG_FEB2013) {
- /* we need to add the new schemas.system column */
- BAT *b, *b1, *b2, *b3, *u, *f, *l;
- BATiter bi, fi, li;
- char *s = "sys", n[64];
- BUN p,q;
-
- b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"schemas_name")));
- if (!b)
- return;
- bi = bat_iterator(b);
- b1 = BATnew(TYPE_void, TYPE_bit, BATcount(b), PERSISTENT);
- if (!b1)
- return;
- BATseqbase(b1, b->hseqbase);
- /* only sys and tmp are system schemas */
- for(p=BUNfirst(b), q=BUNlast(b); p<q; p++) {
- bit v = FALSE;
- char *name = BUNtail(bi, p);
- if (strcmp(name, "sys") == 0 || strcmp(name, "tmp") ==
0)
- v = TRUE;
- BUNappend(b1, &v, TRUE);
- }
- b1 = BATsetaccess(b1, BAT_READ);
- logger_add_bat(lg, b1, N(n, NULL, s, "schemas_system"));
- bat_destroy(b);
- bat_destroy(b1);
-
- /* add args.inout (default to ARG_IN) */
- b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"args_name")));
- if (!b)
- return;
- bi = bat_iterator(b);
- b1 = BATnew(TYPE_void, TYPE_bte, BATcount(b), PERSISTENT);
- if (!b1)
- return;
- BATseqbase(b1, b->hseqbase);
- /* default to ARG_IN, names starting with 'res' are ARG_OUT */
- bi = bat_iterator(b);
- for(p=BUNfirst(b), q=BUNlast(b); p<q; p++) {
- bte v = ARG_IN;
- char *name = BUNtail(bi, p);
- if (strncmp(name, "res", 3) == 0)
- v = ARG_OUT;
- BUNappend(b1, &v, TRUE);
- }
- b1 = BATsetaccess(b1, BAT_READ);
- logger_add_bat(lg, b1, N(n, NULL, s, "args_inout"));
- bat_destroy(b);
- bat_destroy(b1);
-
- /* add functions.vararg/varres */
- b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"functions_sql")));
- u = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"functions_type")));
- f = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"functions_func")));
- l = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"functions_name")));
- fi = bat_iterator(f);
- li = bat_iterator(l);
-
- if (!b || !u || !f || !l)
- return;
- bi = bat_iterator(b);
- b1 = BATnew(TYPE_void, TYPE_bit, BATcount(b), PERSISTENT);
- b2 = BATnew(TYPE_void, TYPE_bit, BATcount(b), PERSISTENT);
- b3 = BATnew(TYPE_void, TYPE_int, BATcount(b), PERSISTENT);
-
- if (!b1 || !b2 || !b3)
- return;
- BATseqbase(b1, b->hseqbase);
- BATseqbase(b2, b->hseqbase);
- BATseqbase(b3, b->hseqbase);
-
- /* default to no variable arguments and results */
- for(p=BUNfirst(b), q=BUNlast(b); p<q; p++) {
- bit v = FALSE, t = TRUE;
- int lang, type = F_UNION;
- char *name = BUNtail(li, p);
-
- if (strcmp(name, "copyfrom") == 0) {
- /* var in and out, and union func */
- void_inplace(u, p, &type, TRUE);
- BUNappend(b1, &t, TRUE);
- BUNappend(b2, &t, TRUE);
-
- lang = 0;
- BUNappend(b3, &lang, TRUE);
- } else {
- BUNappend(b1, &v, TRUE);
- BUNappend(b2, &v, TRUE);
-
- /* this should be value of functions_sql + 1*/
- lang = *(bit*) BUNtloc(bi,p) + 1;
- BUNappend(b3, &lang, TRUE);
- }
-
- /* beware these will all be drop and recreated in the
sql
- * upgrade code */
- name = BUNtail(fi, p);
- if (strcasestr(name, "RETURNS TABLE") != NULL)
- void_inplace(u, p, &type, TRUE);
- }
- b1 = BATsetaccess(b1, BAT_READ);
- b2 = BATsetaccess(b2, BAT_READ);
- b3 = BATsetaccess(b3, BAT_READ);
-
- logger_add_bat(lg, b1, N(n, NULL, s, "functions_vararg"));
- logger_add_bat(lg, b2, N(n, NULL, s, "functions_varres"));
- logger_add_bat(lg, b3, N(n, NULL, s, "functions_language"));
-
- bat_destroy(b);
- bat_destroy(u);
- bat_destroy(l);
-
- /* delete functions.sql */
- logger_del_bat(lg, b->batCacheid);
-
- bat_destroy(b1);
- bat_destroy(b2);
- bat_destroy(b3);
- }
- if (catalog_version == CATALOG_OCT2010) {
- BAT *b, *b1;
- char *s = "sys", n[64];
-
- fprintf(stdout, "# upgrading catalog from Oct2010\n");
- fflush(stdout);
-
- /* rename table 'keycolumns' into 'objects'
- * and remove trunc column */
- while (s) {
- b = temp_descriptor(logger_find_bat(lg, N(n, "D", s,
"keycolumns")));
- if (!b)
- return;
- b1 = BATcopy(b, b->htype, b->ttype, 1, PERSISTENT);
- if (!b1)
- return;
- b1 = BATsetaccess(b1, BAT_READ);
- logger_del_bat(lg, b->batCacheid);
- logger_add_bat(lg, b1, N(n, "D", s, "objects"));
- bat_destroy(b);
- bat_destroy(b1);
-
- b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"keycolumns_id")));
- if (!b)
- return;
- b1 = BATcopy(b, b->htype, b->ttype, 1, PERSISTENT);
- if (!b1)
- return;
- b1 = BATsetaccess(b1, BAT_READ);
- logger_del_bat(lg, b->batCacheid);
- logger_add_bat(lg, b1, N(n, NULL, s, "objects_id"));
- bat_destroy(b);
- bat_destroy(b1);
-
- b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"keycolumns_column")));
- if (!b)
- return;
- b1 = BATcopy(b, b->htype, b->ttype, 1, PERSISTENT);
- if (!b1)
- return;
- b1 = BATsetaccess(b1, BAT_READ);
- logger_del_bat(lg, b->batCacheid);
- logger_add_bat(lg, b1, N(n, NULL, s, "objects_name"));
- bat_destroy(b);
- bat_destroy(b1);
-
- b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"keycolumns_nr")));
- if (!b)
- return;
- b1 = BATcopy(b, b->htype, b->ttype, 1, PERSISTENT);
- if (!b1)
- return;
- b1 = BATsetaccess(b1, BAT_READ);
- logger_del_bat(lg, b->batCacheid);
- logger_add_bat(lg, b1, N(n, NULL, s, "objects_nr"));
- bat_destroy(b);
- bat_destroy(b1);
-
- b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s,
"keycolumns_trunc")));
- if (!b)
- return;
- logger_del_bat(lg, b->batCacheid);
- bat_destroy(b);
- if (strcmp(s, "sys") == 0)
- s = "tmp";
- else
- s = NULL;
- }
- }
- if (catalog_version == CATALOG_APR2011) {
- char n[64];
- BAT *b, *b1, *b2, *iname, *tname, *sname;
- BUN bs;
- BATiter iiname, itname, isname;
-
- /* TODO functions.aggr (boolean) -> functions.type (int) */
- fprintf(stdout, "# upgrading catalog from Apr2011\n");
- fflush(stdout);
-
- /* join sys.idxs(table_id, name),
- * sys._tables(id,schema_id, name),
- * sys.schemas(id,name) */
- iname = temp_descriptor(logger_find_bat(lg, N(n, "sys", "idxs",
"name")));
- bs = BATcount(iname);
- b = temp_descriptor(logger_find_bat(lg, N(n, "sys", "idxs",
"table_id")));
- b1 = temp_descriptor(logger_find_bat(lg, N(n, "sys", "_tables",
"id")));
- b2 = BATleftjoin( b, BATmirror(b1), bs);
- bat_destroy(b);
- bat_destroy(b1);
- b = b2;
-
- b1 = temp_descriptor(logger_find_bat(lg, N(n, "sys", "_tables",
"name")));
- b2 = temp_descriptor(logger_find_bat(lg, N(n, "sys", "_tables",
"schema_id")));
- tname = BATleftjoin( b, b1, bs );
- bat_destroy(b1);
- b1 = BATleftjoin( b, b2, bs );
- bat_destroy(b2);
- bat_destroy(b);
-
- b = temp_descriptor(logger_find_bat(lg, N(n, "sys", "schemas",
"id")));
- b2 = BATleftjoin( b1, BATmirror(b), bs);
- bat_destroy(b1);
- bat_destroy(b);
- b = temp_descriptor(logger_find_bat(lg, N(n, "sys", "schemas",
"name")));
- sname = BATleftjoin( b2, b, bs);
- bat_destroy(b2);
- bat_destroy(b);
-
- iiname = bat_iterator(iname);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list