Changeset: 604ae9397192 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=604ae9397192
Modified Files:
        sql/backends/monet5/sql_upgrades.c
        sql/scripts/99_system.sql
Branch: default
Log Message:

Updating invalid schema_id references (value is 0) in sys.types.schema_id and 
sys.functions.schema_id.
This prevents missing records when joining (inner) the data with sys.schemas.id.


diffs (28 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -1202,6 +1202,11 @@ sql_update_jun2016(Client c)
        pos += snprintf(buf + pos, bufsize - pos,
                        "insert into sys.systemfunctions (select id from 
sys.functions where name = 'storage' and schema_id = (select id from 
sys.schemas where name = 'sys') and id not in (select function_id from 
sys.systemfunctions));\n");
 
+       /* change to 99_system.sql: correct invalid FK schema ids, set them to 
schema id 2000 (the "sys" schema) */
+       pos += snprintf(buf + pos, bufsize - pos,
+                       "UPDATE sys.types     SET schema_id = 2000 WHERE 
schema_id = 0 AND schema_id NOT IN (SELECT id from sys.schemas);\n"
+                       "UPDATE sys.functions SET schema_id = 2000 WHERE 
schema_id = 0 AND schema_id NOT IN (SELECT id from sys.schemas);\n");
+
        if (schema) {
                pos += snprintf(buf + pos, bufsize - pos, "set schema 
\"%s\";\n", schema);
                free(schema);
diff --git a/sql/scripts/99_system.sql b/sql/scripts/99_system.sql
--- a/sql/scripts/99_system.sql
+++ b/sql/scripts/99_system.sql
@@ -15,5 +15,9 @@ update _tables set system = true;
 -- only system schemas until now
 update schemas set system = true;
 
+-- correct invalid FK schema ids, set them to schema id 2000 (the "sys" schema)
+UPDATE sys.types     SET schema_id = 2000 WHERE schema_id = 0 AND schema_id 
NOT IN (SELECT id from sys.schemas);
+UPDATE sys.functions SET schema_id = 2000 WHERE schema_id = 0 AND schema_id 
NOT IN (SELECT id from sys.schemas);
+
 -- make sure all gets commited
 COMMIT;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to