Changeset: 031b5d6a9f2e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=031b5d6a9f2e
Modified Files:
        sql/ChangeLog
        sql/backends/monet5/sql_scenario.c
Branch: default
Log Message:

Cleanup: stop support for upgrade from ancient database.


diffs (255 lines):

diff --git a/sql/ChangeLog b/sql/ChangeLog
--- a/sql/ChangeLog
+++ b/sql/ChangeLog
@@ -1,3 +1,8 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Fri Dec 13 2013 Sjoerd Mullender <[email protected]>
+- Stop support for upgrading directly from a database created with a
+  server from the Oct2012 release or older.  You can upgrade via the
+  Feb2013 or Jan2014 release.
+
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
@@ -357,172 +357,6 @@ handle_error(mvc *m, stream *out, int ps
 }
 
 static str
-sql_update_dec2011(Client c, mvc *m)
-{
-       node *nsch, *ntab, *ncol;
-       sql_trans *tr;
-       char *buf = GDKmalloc(1024), *err = NULL;
-       size_t bufsize = 1024, pos = 0;
-
-       buf[0] = 0;
-       tr = m->session->tr;
-       for (nsch = tr->schemas.set->h; nsch; nsch = nsch->next) {
-               sql_schema *s = nsch->data;
-
-               if (isalpha((int) s->base.name[0])) {
-                       if (!s->tables.set)
-                               continue;
-                       for (ntab = (s)->tables.set->h; ntab; ntab = 
ntab->next) {
-                               sql_table *t = ntab->data;
-
-                               if (!isTable(t) || !t->columns.set)
-                                       continue;
-                               for (ncol = (t)->columns.set->h; ncol; ncol = 
ncol->next) {
-                                       sql_column *c = (sql_column *) 
ncol->data;
-
-                                       if (c->type.type->eclass == EC_INTERVAL 
&&
-                                           strcmp(c->type.type->sqlname, 
"sec_interval") == 0) {
-                                               while (bufsize < pos + 100 + 
strlen(s->base.name) + strlen(t->base.name) + 3 * strlen(c->base.name))
-                                                       buf = GDKrealloc(buf, 
bufsize += 1024);
-                                               pos += snprintf(buf + pos, 
bufsize - pos, "update \"%s\".\"%s\" set \"%s\"=1000*\"%s\" where \"%s\" is not 
null;\n",
-                                                               s->base.name, 
t->base.name, c->base.name, c->base.name, c->base.name);
-                                       }
-                               }
-                       }
-               }
-       }
-       if (bufsize < pos + 400)
-               buf = GDKrealloc(buf, bufsize += 1024);
-       pos += snprintf(buf + pos, bufsize - pos, "create filter function 
sys.\"like\"(val string, pat string, esc string) external name 
pcre.like_filter;\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create filter function 
sys.\"ilike\"(val string, pat string, esc string) external name 
pcre.ilike_filter;\n");
-       pos += snprintf(buf + pos, bufsize - pos, "insert into 
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where 
f.name in ('ilike', 'like') and f.type = %d and f.schema_id = s.id and s.name = 
'sys');\n", F_FILT);
-       printf("Running database upgrade commands:\n%s\n", buf);
-       err = SQLstatementIntern(c, &buf, "update", 1, 0);
-       GDKfree(buf);
-       return err;             /* usually MAL_SUCCEED */
-}
-
-static str
-sql_update_apr2012(Client c)
-{
-       char *buf = GDKmalloc(2048), *err = NULL;
-       size_t bufsize = 2048, pos = 0;
-
-       /* sys.median and sys.corr functions */
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate 
sys.median(val TINYINT) returns TINYINT external name \"aggr\".\"median\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate 
sys.median(val SMALLINT) returns SMALLINT external name 
\"aggr\".\"median\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate 
sys.median(val INTEGER) returns INTEGER external name \"aggr\".\"median\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate 
sys.median(val BIGINT) returns BIGINT external name \"aggr\".\"median\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate 
sys.median(val REAL) returns REAL external name \"aggr\".\"median\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate 
sys.median(val DOUBLE) returns DOUBLE external name \"aggr\".\"median\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate sys.corr(e1 
TINYINT, e2 TINYINT) returns TINYINT external name \"aggr\".\"corr\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate sys.corr(e1 
SMALLINT, e2 SMALLINT) returns SMALLINT external name \"aggr\".\"corr\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate sys.corr(e1 
INTEGER, e2 INTEGER) returns INTEGER external name \"aggr\".\"corr\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate sys.corr(e1 
BIGINT, e2 BIGINT) returns BIGINT external name \"aggr\".\"corr\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate sys.corr(e1 
REAL, e2 REAL) returns REAL external name \"aggr\".\"corr\";\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create aggregate sys.corr(e1 
DOUBLE, e2 DOUBLE) returns DOUBLE external name \"aggr\".\"corr\";\n");
-
-       pos += snprintf(buf + pos, bufsize - pos, "insert into 
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where 
f.name in ('median', 'corr') and f.type = %d and f.schema_id = s.id and s.name 
= 'sys');\n", F_AGGR);
-
-       assert(pos < 2048);
-
-       printf("Running database upgrade commands:\n%s\n", buf);
-       err = SQLstatementIntern(c, &buf, "update", 1, 0);
-       GDKfree(buf);
-       return err;             /* usually MAL_SUCCEED */
-}
-
-static str
-sql_update_apr2012_sp1(Client c)
-{
-       char *buf = GDKmalloc(2048), *err = NULL;
-       size_t bufsize = 2048, pos = 0;
-
-       /* changes in createdb/25_debug.sql */
-       pos += snprintf(buf + pos, bufsize - pos, "update sys.functions set 
type = %d, side_effect = false where type = %d and id not in (select func_id 
from sys.args where number = 0 and name = 'result');\n", F_PROC, F_FUNC);
-       pos += snprintf(buf + pos, bufsize - pos, "drop function 
sys.storage;\n");
-       pos += snprintf(buf + pos, bufsize - pos,
-                       "create function sys.storage() returns table 
(\"schema\" string, \"table\" string, \"column\" string, location string, 
\"count\" bigint, capacity bigint, width int, size bigint, hashsize bigint, 
sorted boolean) external name sql.storage;\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create function 
sys.optimizers() returns table (name string, def string, status string) 
external name sql.optimizers;\n");
-       pos += snprintf(buf + pos, bufsize - pos, "drop procedure sys.ra;\n");
-       pos += snprintf(buf + pos, bufsize - pos, "create procedure 
sys.evalAlgebra( ra_stmt string, opt bool) external name 
sql.\"evalAlgebra\";\n");
-
-       pos += snprintf(buf + pos, bufsize - pos, "insert into 
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where 
f.name in ('storage', 'optimizers') and f.type = %d and f.schema_id = s.id and 
s.name = 'sys');\n", F_FUNC);
-       pos += snprintf(buf + pos, bufsize - pos, "insert into 
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where 
f.name in ('evalalgebra') and f.type = %d and f.schema_id = s.id and s.name = 
'sys');\n", F_PROC);
-
-       assert(pos < 2048);
-
-       printf("Running database upgrade commands:\n%s\n", buf);
-       err = SQLstatementIntern(c, &buf, "update", 1, 0);
-       GDKfree(buf);
-       return err;             /* usually MAL_SUCCEED */
-}
-
-static str
-sql_update_jul2012(Client c)
-{
-       char *buf = GDKmalloc(2048), *err = NULL;
-       size_t bufsize = 2048, pos = 0;
-
-       /* new function sys.alpha */
-       pos += snprintf(buf + pos, bufsize - pos, "create function 
sys.alpha(pdec double, pradius double) returns double external name 
sql.alpha;\n");
-
-       pos += snprintf(buf + pos, bufsize - pos, "insert into 
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where 
f.name = 'alpha' and f.type = %d and f.schema_id = s.id and s.name = 
'sys');\n", F_FUNC);
-
-       assert(pos < 2048);
-
-       printf("Running database upgrade commands:\n%s\n", buf);
-       err = SQLstatementIntern(c, &buf, "update", 1, 0);
-       GDKfree(buf);
-       return err;             /* usually MAL_SUCCEED */
-}
-
-static str
-sql_update_oct2012(Client c)
-{
-       char *buf = GDKmalloc(2048), *err = NULL;
-       size_t bufsize = 2048, pos = 0;
-
-       /* new function sys.alpha */
-       pos += snprintf(buf + pos, bufsize - pos, "drop function 
sys.zorder_slice;\n");
-
-       assert(pos < 2048);
-
-       printf("Running database upgrade commands:\n%s\n", buf);
-       err = SQLstatementIntern(c, &buf, "update", 1, 0);
-       GDKfree(buf);
-       return err;             /* usually MAL_SUCCEED */
-}
-
-static str
-sql_update_oct2012_sp1(Client c)
-{
-       char *buf = GDKmalloc(2048), *err = NULL;
-       size_t bufsize = 2048, pos = 0;
-
-       /* sys.stddev functions */
-       pos += snprintf(buf + pos, bufsize - pos, "drop aggregate 
sys.stddev(TINYINT);\n");
-       pos += snprintf(buf + pos, bufsize - pos, "drop aggregate 
sys.stddev(SMALLINT);\n");
-       pos += snprintf(buf + pos, bufsize - pos, "drop aggregate 
sys.stddev(INTEGER);\n");
-       pos += snprintf(buf + pos, bufsize - pos, "drop aggregate 
sys.stddev(BIGINT);\n");
-       pos += snprintf(buf + pos, bufsize - pos, "drop aggregate 
sys.stddev(REAL);\n");
-       pos += snprintf(buf + pos, bufsize - pos, "drop aggregate 
sys.stddev(DOUBLE);\n");
-
-       pos += snprintf(buf + pos, bufsize - pos, "drop aggregate 
sys.stddev(DATE);\n");
-       pos += snprintf(buf + pos, bufsize - pos, "drop aggregate 
sys.stddev(TIME);\n");
-       pos += snprintf(buf + pos, bufsize - pos, "drop aggregate 
sys.stddev(TIMESTAMP);\n");
-
-       pos += snprintf(buf + pos, bufsize - pos, "delete from 
sys.systemfunctions where function_id in (select f.id from sys.functions f, 
sys.schemas s where f.name = 'stddev' and f.type = %d and f.schema_id = s.id 
and s.name = 'sys');\n", F_AGGR);
-
-       assert(pos < 2048);
-
-       printf("Running database upgrade commands:\n%s\n", buf);
-       err = SQLstatementIntern(c, &buf, "update", 1, 0);
-       GDKfree(buf);
-       return err;             /* usually MAL_SUCCEED */
-}
-
-static str
 sql_update_feb2013(Client c)
 {
        char *buf = GDKmalloc(4096), *err = NULL;
@@ -953,66 +787,6 @@ SQLinitClient(Client c)
 
                if (!m->sa)
                        m->sa = sa_create();
-               /* if filter function sys.like(str,str,str) does not
-                * exist, we need to update */
-               sql_find_subtype(&tp, "clob", 0, 0);
-               if (!sql_bind_func3(m->sa, mvc_bind_schema(m, "sys"), "like", 
&tp, &tp, &tp, F_FILT)) {
-                       if ((err = sql_update_dec2011(c, m)) !=NULL) {
-                               fprintf(stderr, "!%s\n", err);
-                               GDKfree(err);
-                       }
-               }
-               /* if aggregate function sys.median(int) does not
-                * exist, we need to update */
-               sql_find_subtype(&tp, "int", 0, 0);
-               if (!sql_bind_func(m->sa, mvc_bind_schema(m, "sys"), "median", 
&tp, NULL, F_AGGR)) {
-                       if ((err = sql_update_apr2012(c)) !=NULL) {
-                               fprintf(stderr, "!%s\n", err);
-                               GDKfree(err);
-                       }
-               }
-               /* if function sys.optimizers() does not exist, we
-                * need to update */
-               if (!sql_bind_func(m->sa, mvc_bind_schema(m, "sys"), 
"optimizers", NULL, NULL, F_FUNC)) {
-                       if ((err = sql_update_apr2012_sp1(c)) !=NULL) {
-                               fprintf(stderr, "!%s\n", err);
-                               GDKfree(err);
-                       }
-               }
-               /* if function sys.alpa(double) does not
-                * exist, we need to update */
-               sql_find_subtype(&tp, "double", 0, 0);
-               if (!sql_bind_func(m->sa, mvc_bind_schema(m, "sys"), "alpha", 
&tp, &tp, F_FUNC)) {
-                       if ((err = sql_update_jul2012(c)) !=NULL) {
-                               fprintf(stderr, "!%s\n", err);
-                               GDKfree(err);
-                       }
-               }
-               /* if function sys.zorder_slice() does exist, we need
-                * to update */
-               {
-                       list *l = sa_list(m->sa);
-                       sql_find_subtype(&tp, "int", 0, 0);
-                       list_append(l, &tp);
-                       list_append(l, &tp);
-                       list_append(l, &tp);
-                       list_append(l, &tp);
-                       if (sql_bind_func_(m->sa, mvc_bind_schema(m, "sys"), 
"zorder_slice", l, F_FUNC)) {
-                               if ((err = sql_update_oct2012(c)) !=NULL) {
-                                       fprintf(stderr, "!%s\n", err);
-                                       GDKfree(err);
-                               }
-                       }
-               }
-               /* if aggregate function sys.stddev(int) does
-                * exist, we need to update */
-               sql_find_subtype(&tp, "int", 0, 0);
-               if (sql_bind_func(m->sa, mvc_bind_schema(m, "sys"), "stddev", 
&tp, NULL, F_AGGR)) {
-                       if ((err = sql_update_oct2012_sp1(c)) !=NULL) {
-                               fprintf(stderr, "!%s\n", err);
-                               GDKfree(err);
-                       }
-               }
                /* if aggregate function sys.stddev_samp(int) does not
                 * exist, we need to update */
                sql_find_subtype(&tp, "int", 0, 0);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to