Changeset: 29dd1b27d0ac for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=29dd1b27d0ac
Modified Files:
        sql/backends/monet5/sql_scenario.c
        sql/storage/bat/bat_logger.c
Branch: Oct2014
Log Message:

catalog updates for new functions schema


Unterschiede (113 Zeilen):

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
@@ -841,9 +841,9 @@ external name sql.analyze;\n");
 }
 
 static str
-sql_update_default(Client c)
+sql_update_oct2014(Client c)
 {
-       size_t bufsize = 8192, pos = 0;
+       size_t bufsize = 8192*2, pos = 0;
        char *buf = GDKmalloc(bufsize), *err = NULL;
        mvc *sql = ((backend*) c->sqlcontext)->mvc;
        ValRecord *schvar = stack_get_var(sql, "current_schema");
@@ -864,9 +864,13 @@ sql_update_default(Client c)
        pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values( 
(select max(id)+1 from _columns), 'varres', 'boolean', 1, 0, (select id from 
_tables where name = 'functions'), NULL, true, 7, NULL);\n");
        pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values( 
(select max(id)+1 from _columns), 'vararg', 'boolean', 1, 0, (select id from 
_tables where name = 'functions'), NULL, true, 8, NULL);\n");
        pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values( 
(select max(id)+1 from _columns), 'inout', 'tinyint', 8, 0, (select id from 
_tables where name = 'args'), NULL, true, 6, NULL);\n");
+       pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values( 
(select max(id)+1 from _columns), 'language', 'int', 32, 0, (select id from 
_tables where name = 'functions'), NULL, true, 9, NULL);\n");
+       pos += snprintf(buf + pos, bufsize - pos, "delete from _columns where 
table_id in (select id from _tables where name = 'functions') and 
name='sql';\n");
+
        /* correct column numbers */
        pos += snprintf(buf + pos, bufsize - pos, "update _columns set 
number='9' where name = 'schema_id' and table_id in (select id from _tables 
where name = 'functions');\n");
        pos += snprintf(buf + pos, bufsize - pos, "update _columns set 
number='7' where name = 'number' and table_id in (select id from _tables where 
name = 'args');\n");
+       pos += snprintf(buf + pos, bufsize - pos, "update _columns set 
number='4' where name = 'language' and table_id in (select id from _tables 
where name = 'functions');\n");
 
        /* remove table return types (#..), ie tt_generated from
         * _tables/_columns */
@@ -996,7 +1000,7 @@ create aggregate json.tojsonarray( x dou
 "              I.sorted"
 "              from sys.storagemodelinput I;"
 "      end;\n");
-       pos += snprintf(buf + pos, bufsize - pos, 
+       pos += snprintf(buf + pos, bufsize - pos,
 "create view sys.tablestoragemodel"
 " as select \"schema\",\"table\",max(count) as \"count\","
 "    sum(columnsize) as columnsize,"
@@ -1231,7 +1235,7 @@ SQLinitClient(Client c)
                 * update */
                sql_find_subtype(&tp, "clob", 0, 0);
                if (!sql_bind_func(m->sa, mvc_bind_schema(m, "sys"), "md5", 
&tp, NULL, F_FUNC)) {
-                       if ((err = sql_update_default(c)) !=NULL) {
+                       if ((err = sql_update_oct2014(c)) !=NULL) {
                                fprintf(stderr, "!%s\n", err);
                                GDKfree(err);
                        }
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
@@ -81,7 +81,7 @@ bl_postversion( void *lg)
        (void)lg;
        if (catalog_version == CATALOG_FEB2013) {
                /* we need to add the new schemas.system column */
-               BAT *b, *b1, *b2;
+               BAT *b, *b1, *b2, *b3;
                BATiter bi;
                char *s = "sys", n[64];
                BUN p,q;
@@ -131,30 +131,51 @@ bl_postversion( void *lg)
                bat_destroy(b1);
 
                /* add functions.vararg/varres */
-               b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s, 
"functions_name")));
+               b = temp_descriptor(logger_find_bat(lg, N(n, NULL, s, 
"functions_sql")));
+
                if (!b)
                        return;
                bi = bat_iterator(b);
                b1 = BATnew(TYPE_void, TYPE_bit, BATcount(b), PERSISTENT);
                b2 = BATnew(TYPE_void, TYPE_bit, BATcount(b), PERSISTENT);
-               if (!b1 || !b2)
+               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 variaable arguments and results */
                for(p=BUNfirst(b), q=BUNlast(b); p<q; p++) {
                        bit v = FALSE;
+                       int type;
                        /* TODO how about import ! */
                        BUNappend(b1, &v, TRUE);
                        BUNappend(b2, &v, TRUE);
+
+                       /* this should be value of functions_sql + 1*/
+                       type = *(int*) BUNtloc(bi,p) + 1;
+                       BUNappend(b3, &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);
+
+               /* delete functions.sql */
+               logger_del_bat(lg, b->batCacheid);
+
                bat_destroy(b1);
                bat_destroy(b2);
+               bat_destroy(b3);
+
 
                /* TODO rename columns.storage_type -> storage */
        }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to