Changeset: a861b3eeaf4e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a861b3eeaf4e
Modified Files:
        sql/backends/monet5/sql_upgrades.c
        sql/scripts/25_debug.sql
        
sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
        sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
        sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
        sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
        sql/test/emptydb/Tests/check.stable.out.int128
        
sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
        sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade/Tests/upgrade.stable.out
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: escape-sequences
Log Message:

Add upgrade code, and grant execute on sys.database() to public.


diffs (truncated from 396 to 300 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
@@ -5482,6 +5482,20 @@ sql_update_default(Client c, mvc *sql, s
                output = NULL;
        }
 
+       if (!sql_bind_func(sql, "sys", "database", NULL, NULL, F_FUNC, true)) {
+               sql->session->status = 0; /* if the function was not found 
clean the error */
+               sql->errstr[0] = '\0';
+               pos = snprintf(buf, bufsize,
+                                          "create function sys.database ()\n"
+                                          "returns string\n"
+                                          "external name 
inspect.\"getDatabaseName\";\n"
+                                          "grant execute on function 
sys.database() to public;\n"
+                                          "update sys.functions set system = 
true where system <> true and name = 'database' and schema_id = 2000 and type = 
%d;\n",
+                                          (int) F_FUNC);
+               printf("Running database upgrade commands:\n%s\n", buf);
+               err = SQLstatementIntern(c, buf, "update", true, false, NULL);
+       }
+
        GDKfree(buf);
        return err;             /* usually MAL_SUCCEED */
 }
diff --git a/sql/scripts/25_debug.sql b/sql/scripts/25_debug.sql
--- a/sql/scripts/25_debug.sql
+++ b/sql/scripts/25_debug.sql
@@ -37,6 +37,7 @@ GRANT SELECT ON sys.environment TO PUBLI
 create function sys.database ()
     returns string
     external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
 
 -- The BAT buffer pool overview
 create function sys.bbp ()
diff --git 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -581,3 +581,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
@@ -581,3 +581,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git 
a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
@@ -650,3 +650,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git 
a/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
@@ -575,3 +575,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out 
b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
--- a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
@@ -575,3 +575,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
@@ -644,3 +644,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -251,3 +251,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
@@ -251,3 +251,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
@@ -320,3 +320,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git 
a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128 
b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
--- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
+++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
@@ -320,3 +320,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
@@ -251,3 +251,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/emptydb-upgrade/Tests/upgrade.stable.out 
b/sql/test/emptydb-upgrade/Tests/upgrade.stable.out
--- a/sql/test/emptydb-upgrade/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-upgrade/Tests/upgrade.stable.out
@@ -251,3 +251,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
@@ -320,3 +320,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/emptydb/Tests/check.stable.out.int128 
b/sql/test/emptydb/Tests/check.stable.out.int128
--- a/sql/test/emptydb/Tests/check.stable.out.int128
+++ b/sql/test/emptydb/Tests/check.stable.out.int128
@@ -4361,6 +4361,7 @@ select 'null in fkeys.delete_action', de
 [ "grant on function", "sys",  "covar_samp",   "public",       "EXECUTE",      
"monetdb",      0       ]
 [ "grant on function", "sys",  "covar_samp",   "public",       "EXECUTE",      
"monetdb",      0       ]
 [ "grant on function", "sys",  "current_sessionid",    "public",       
"EXECUTE",      "monetdb",      0       ]
+[ "grant on function", "sys",  "database",     "public",       "EXECUTE",      
"monetdb",      0       ]
 [ "grant on function", "sys",  "date_to_str",  "public",       "EXECUTE",      
"monetdb",      0       ]
 [ "grant on function", "sys",  "date_trunc",   "public",       "EXECUTE",      
"monetdb",      0       ]
 [ "grant on function", "sys",  "date_trunc",   "public",       "EXECUTE",      
"monetdb",      0       ]
diff --git 
a/sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -581,3 +581,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
@@ -581,3 +581,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git 
a/sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 
b/sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
--- a/sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
+++ b/sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
@@ -650,3 +650,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git 
a/sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128 
b/sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
@@ -575,3 +575,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out 
b/sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
--- a/sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
+++ b/sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
@@ -575,3 +575,10 @@ SELECT v.schema_id AS view_schema_id, v.
 GRANT SELECT ON sys.dependency_views_on_functions TO PUBLIC;
 update sys._tables set system = true where system <> true and name in 
('dependency_tables_on_functions','dependency_views_on_functions') and 
schema_id = 2000;
 
+Running database upgrade commands:
+create function sys.database ()
+returns string
+external name inspect."getDatabaseName";
+grant execute on function sys.database() to public;
+update sys.functions set system = true where system <> true and name = 
'database' and schema_id = 2000 and type = 1;
+
diff --git a/sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128 
b/sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
--- a/sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to