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

Update catalog with new sys.storage and other functions after Apr2012 release.
The fix to update the catalog didn't make it in the Apr2012 release,
so we need to do it for the Apr2012-SP1 release.


diffs (47 lines):

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
@@ -427,6 +427,22 @@ sql_update_apr2012(Client c)
        pos += snprintf(buf+pos, bufsize-pos, "create aggregate corr(e1 REAL, 
e2 REAL) returns REAL external name \"aggr\".\"corr\";\n");
        pos += snprintf(buf+pos, bufsize-pos, "create aggregate 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, "drop function storage;\n");
        pos += snprintf(buf+pos, bufsize-pos, "create function 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");
@@ -434,7 +450,6 @@ sql_update_apr2012(Client c)
        pos += snprintf(buf+pos, bufsize-pos, "drop procedure ra;\n");
        pos += snprintf(buf+pos, bufsize-pos, "create procedure 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 ('median', 'corr') and f.type = %d and f.schema_id = s.id and s.name 
= 'sys');\n", F_AGGR);
        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);
 
@@ -577,6 +592,12 @@ SQLinitClient(Client c)
                        if ((err = sql_update_apr2012(c)) != NULL)
                                fprintf(stderr, "!%s\n", 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);
+               }
        }
        fflush(stdout);
        fflush(stderr);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to