Changeset: 58cef22adcb3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=58cef22adcb3
Modified Files:
        gdk/gdk_logger.c
        sql/backends/monet5/sql_scenario.c
        sql/storage/bat/bat_logger.c
        sql/storage/store.c
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-upgrade/Tests/upgrade.stable.out
Branch: Oct2014
Log Message:

fixed upgrade code for change of eclass for type OID


diffs (134 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -140,22 +140,8 @@ logbat_new(int tt, BUN size, int role)
 }
 
 static int
-log_read_format_old(logger *l, logformat *data)
-{
-       int nr = 0;
-       int ok =  mnstr_read(l->log, &data->flag, 1, 1) == 1 &&
-               mnstr_readInt(l->log, &nr) == 1 &&
-               mnstr_readInt(l->log, &data->tid) == 1;
-       data->nr = nr;
-       return ok;
-}
-
-static int
 log_read_format(logger *l, logformat *data)
 {
-       if (l->postfuncp) /* we need to convert from the old logformat, 
-                                    needs to be removed once we released 
Aug2014 */
-               return log_read_format_old(l, data);
        return mnstr_read(l->log, &data->flag, 1, 1) == 1 &&
                mnstr_readLng(l->log, &data->nr) == 1 &&
                mnstr_readInt(l->log, &data->tid) == 1;
diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -1440,7 +1440,6 @@ CREATE FUNCTION \"right_shift\"(i1 inet,
 CREATE FUNCTION \"left_shift_assign\"(i1 inet, i2 inet) RETURNS boolean 
EXTERNAL NAME inet.\"<<=\";\n\
 CREATE FUNCTION \"right_shift_assign\"(i1 inet, i2 inet) RETURNS boolean 
EXTERNAL NAME inet.\">>=\";\n");
        pos += snprintf(buf + pos, bufsize - pos, "insert into 
sys.systemfunctions (select id from sys.functions where name in ('left_shift', 
'right_shift', 'left_shift_assign', 'right_shift_assign') and schema_id = 
(select id from sys.schemas where name = 'sys') and id not in (select 
function_id from sys.systemfunctions));\n");
-       pos += snprintf(buf + pos, bufsize - pos, "update sys.types set eclass 
= eclass + 1 where eclass >= %d and sqlname <> 'oid';\n", EC_POS);
 
        if (schema) {
                pos += snprintf(buf + pos, bufsize - pos, "set schema 
\"%s\";\n", schema);
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 @@
 #include "monetdb_config.h"
 #include "bat_logger.h"
 #include "bat_utils.h"
+#include "sql_types.h" /* EC_POS */
 
 logger *bat_logger = NULL;
 
@@ -32,8 +33,13 @@ bl_preversion( int oldversion, int newve
 #define CATALOG_AUG2011 51101
 #define CATALOG_DEC2011 52000
 #define CATALOG_FEB2013 52001
+#define CATALOG_OCT2014 52100
 
        (void)newversion;
+       if (oldversion == CATALOG_OCT2014) {
+               catalog_version = oldversion;
+               return 0;
+       }
        if (oldversion == CATALOG_FEB2013) {
                catalog_version = oldversion;
                return 0;
@@ -104,6 +110,37 @@ static void
 bl_postversion( void *lg) 
 {
        (void)lg;
+       if (catalog_version == CATALOG_OCT2014) {
+               BAT *te, *tn, *tne;
+               BATiter tei, tni;
+               char *s = "sys", n[64];
+               BUN p,q;
+
+               te = temp_descriptor(logger_find_bat(lg, N(n, NULL, s, 
"types_eclass")));
+               tn = temp_descriptor(logger_find_bat(lg, N(n, NULL, s, 
"types_eclass")));
+               if (!te || !tn)
+                       return;
+               tei = bat_iterator(te);
+               tni = bat_iterator(te);
+               tne = BATnew(TYPE_void, TYPE_int, BATcount(te), PERSISTENT);
+               if (!tne)
+                       return;
+               BATseqbase(tne, te->hseqbase);
+               for(p=BUNfirst(te), q=BUNlast(te); p<q; p++) {
+                       int eclass = *(int*)BUNtail(tei, p);
+                       char *name = BUNtail(tni, p);
+
+                       if (eclass >= EC_POS && strcmp(name, "oid") != 0)
+                               eclass++;
+                       else if (strcmp(name, "oid") == 0)
+                               eclass = EC_POS;
+                       BUNappend(tne, &eclass, TRUE);
+               }
+               tne = BATsetaccess(tne, BAT_READ);
+               logger_add_bat(lg, tne, N(n, NULL, s, "types_eclass"));
+               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;
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -30,7 +30,7 @@
 #include <bat/bat_logger.h>
 
 /* version 05.21.00 of catalog */
-#define CATALOG_VERSION 52100
+#define CATALOG_VERSION 52101
 int catalog_version = 0;
 
 static MT_Lock bs_lock MT_LOCK_INITIALIZER("bs_lock");
diff --git a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
@@ -26,7 +26,6 @@ CREATE FUNCTION "right_shift"(i1 inet, i
 CREATE FUNCTION "left_shift_assign"(i1 inet, i2 inet) RETURNS boolean EXTERNAL 
NAME inet."<<=";
 CREATE FUNCTION "right_shift_assign"(i1 inet, i2 inet) RETURNS boolean 
EXTERNAL NAME inet.">>=";
 insert into sys.systemfunctions (select id from sys.functions where name in 
('left_shift', 'right_shift', 'left_shift_assign', 'right_shift_assign') and 
schema_id = (select id from sys.schemas where name = 'sys') and id not in 
(select function_id from sys.systemfunctions));
-update sys.types set eclass = eclass + 1 where eclass >= 6 and sqlname <> 
'oid';
 set schema "testschema";
 
 # 09:43:35 >  
diff --git a/sql/test/testdb-upgrade/Tests/upgrade.stable.out 
b/sql/test/testdb-upgrade/Tests/upgrade.stable.out
--- a/sql/test/testdb-upgrade/Tests/upgrade.stable.out
+++ b/sql/test/testdb-upgrade/Tests/upgrade.stable.out
@@ -23,7 +23,6 @@ CREATE FUNCTION "right_shift"(i1 inet, i
 CREATE FUNCTION "left_shift_assign"(i1 inet, i2 inet) RETURNS boolean EXTERNAL 
NAME inet."<<=";
 CREATE FUNCTION "right_shift_assign"(i1 inet, i2 inet) RETURNS boolean 
EXTERNAL NAME inet.">>=";
 insert into sys.systemfunctions (select id from sys.functions where name in 
('left_shift', 'right_shift', 'left_shift_assign', 'right_shift_assign') and 
schema_id = (select id from sys.schemas where name = 'sys') and id not in 
(select function_id from sys.systemfunctions));
-update sys.types set eclass = eclass + 1 where eclass >= 6 and sqlname <> 
'oid';
 set schema "testschema";
 
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to