Changeset: da446cc3cc59 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=da446cc3cc59
Modified Files:
sql/backends/monet5/sql_upgrades.c
Branch: Apr2019
Log Message:
Reorder functions.
diffs (187 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
@@ -1435,6 +1435,91 @@ sql_update_aug2018(Client c, mvc *sql)
}
static str
+sql_update_aug2018_sp2(Client c, mvc *sql)
+{
+ size_t bufsize = 1000, pos = 0;
+ char *buf, *err;
+ char *schema;
+ res_table *output;
+ BAT *b;
+
+ schema = stack_get_string(sql, "current_schema");
+ if ((buf = GDKmalloc(bufsize)) == NULL)
+ throw(SQL, "sql_update_aug2018_sp2", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
+
+ /* required update for changeset 23e1231ada99 */
+ pos += snprintf(buf + pos, bufsize - pos,
+ "select id from sys.functions where language <> 0 and
not side_effect and type <> 4 and (type = 2 or (language <> 2 and id not in
(select func_id from sys.args where inout = 1)));\n");
+ err = SQLstatementIntern(c, &buf, "update", 1, 0, &output);
+ if (err) {
+ GDKfree(buf);
+ return err;
+ }
+ b = BATdescriptor(output->cols[0].b);
+ if (b) {
+ if (BATcount(b) > 0) {
+ pos = 0;
+ pos += snprintf(buf + pos, bufsize - pos, "set schema
sys;\n");
+ pos += snprintf(buf + pos, bufsize - pos,
+ "update sys.functions set side_effect =
true where language <> 0 and not side_effect and type <> 4 and (type = 2 or
(language <> 2 and id not in (select func_id from sys.args where inout =
1)));\n");
+
+ if (schema)
+ pos += snprintf(buf + pos, bufsize - pos, "set
schema \"%s\";\n", schema);
+ pos += snprintf(buf + pos, bufsize - pos, "commit;\n");
+
+ assert(pos < bufsize);
+ printf("Running database upgrade commands:\n%s\n", buf);
+ err = SQLstatementIntern(c, &buf, "update", 1, 0,
&output);
+ }
+ BBPunfix(b->batCacheid);
+ }
+ res_table_destroy(output);
+ GDKfree(buf);
+ return err; /* usually MAL_SUCCEED */
+}
+
+static str
+sql_drop_functions_dependencies_Xs_on_Ys(Client c, mvc *sql)
+{
+ size_t bufsize = 1600, pos = 0;
+ char *schema = NULL, *err = NULL;
+ char *buf = GDKmalloc(bufsize);
+
+ if (buf == NULL)
+ throw(SQL, "sql_drop_functions_dependencies_Xs_on_Ys",
SQLSTATE(HY001) MAL_MALLOC_FAIL);
+ schema = stack_get_string(sql, "current_schema");
+ /* remove functions which were created in
sql/scripts/21_dependency_functions.sql */
+ pos += snprintf(buf + pos, bufsize - pos,
+ "set schema \"sys\";\n"
+ "DROP FUNCTION dependencies_schemas_on_users();\n"
+ "DROP FUNCTION dependencies_owners_on_schemas();\n"
+ "DROP FUNCTION dependencies_tables_on_views();\n"
+ "DROP FUNCTION dependencies_tables_on_indexes();\n"
+ "DROP FUNCTION dependencies_tables_on_triggers();\n"
+ "DROP FUNCTION dependencies_tables_on_foreignKeys();\n"
+ "DROP FUNCTION dependencies_tables_on_functions();\n"
+ "DROP FUNCTION dependencies_columns_on_views();\n"
+ "DROP FUNCTION dependencies_columns_on_keys();\n"
+ "DROP FUNCTION dependencies_columns_on_indexes();\n"
+ "DROP FUNCTION dependencies_columns_on_functions();\n"
+ "DROP FUNCTION dependencies_columns_on_triggers();\n"
+ "DROP FUNCTION dependencies_views_on_functions();\n"
+ "DROP FUNCTION dependencies_views_on_triggers();\n"
+ "DROP FUNCTION dependencies_functions_on_functions();\n"
+ "DROP FUNCTION dependencies_functions_on_triggers();\n"
+ "DROP FUNCTION dependencies_keys_on_foreignKeys();\n");
+ if (schema)
+ pos += snprintf(buf + pos, bufsize - pos, "set schema
\"%s\";\n", schema);
+ pos += snprintf(buf + pos, bufsize - pos, "commit;\n");
+ assert(pos < bufsize);
+
+ printf("Running database upgrade commands:\n%s\n", buf);
+ err = SQLstatementIntern(c, &buf, "update", 1, 0, NULL);
+ GDKfree(buf);
+ return err; /* usually MAL_SUCCEED */
+}
+
+static str
sql_update_apr2019(Client c, mvc *sql)
{
size_t bufsize = 2000, pos = 0;
@@ -1512,91 +1597,6 @@ sql_update_apr2019(Client c, mvc *sql)
}
static str
-sql_drop_functions_dependencies_Xs_on_Ys(Client c, mvc *sql)
-{
- size_t bufsize = 1600, pos = 0;
- char *schema = NULL, *err = NULL;
- char *buf = GDKmalloc(bufsize);
-
- if (buf == NULL)
- throw(SQL, "sql_drop_functions_dependencies_Xs_on_Ys",
SQLSTATE(HY001) MAL_MALLOC_FAIL);
- schema = stack_get_string(sql, "current_schema");
- /* remove functions which were created in
sql/scripts/21_dependency_functions.sql */
- pos += snprintf(buf + pos, bufsize - pos,
- "set schema \"sys\";\n"
- "DROP FUNCTION dependencies_schemas_on_users();\n"
- "DROP FUNCTION dependencies_owners_on_schemas();\n"
- "DROP FUNCTION dependencies_tables_on_views();\n"
- "DROP FUNCTION dependencies_tables_on_indexes();\n"
- "DROP FUNCTION dependencies_tables_on_triggers();\n"
- "DROP FUNCTION dependencies_tables_on_foreignKeys();\n"
- "DROP FUNCTION dependencies_tables_on_functions();\n"
- "DROP FUNCTION dependencies_columns_on_views();\n"
- "DROP FUNCTION dependencies_columns_on_keys();\n"
- "DROP FUNCTION dependencies_columns_on_indexes();\n"
- "DROP FUNCTION dependencies_columns_on_functions();\n"
- "DROP FUNCTION dependencies_columns_on_triggers();\n"
- "DROP FUNCTION dependencies_views_on_functions();\n"
- "DROP FUNCTION dependencies_views_on_triggers();\n"
- "DROP FUNCTION dependencies_functions_on_functions();\n"
- "DROP FUNCTION dependencies_functions_on_triggers();\n"
- "DROP FUNCTION dependencies_keys_on_foreignKeys();\n");
- if (schema)
- pos += snprintf(buf + pos, bufsize - pos, "set schema
\"%s\";\n", schema);
- pos += snprintf(buf + pos, bufsize - pos, "commit;\n");
- assert(pos < bufsize);
-
- printf("Running database upgrade commands:\n%s\n", buf);
- err = SQLstatementIntern(c, &buf, "update", 1, 0, NULL);
- GDKfree(buf);
- return err; /* usually MAL_SUCCEED */
-}
-
-static str
-sql_update_aug2018_sp2(Client c, mvc *sql)
-{
- size_t bufsize = 1000, pos = 0;
- char *buf, *err;
- char *schema;
- res_table *output;
- BAT *b;
-
- schema = stack_get_string(sql, "current_schema");
- if ((buf = GDKmalloc(bufsize)) == NULL)
- throw(SQL, "sql_update_aug2018_sp2", SQLSTATE(HY001)
MAL_MALLOC_FAIL);
-
- /* required update for changeset 23e1231ada99 */
- pos += snprintf(buf + pos, bufsize - pos,
- "select id from sys.functions where language <> 0 and
not side_effect and type <> 4 and (type = 2 or (language <> 2 and id not in
(select func_id from sys.args where inout = 1)));\n");
- err = SQLstatementIntern(c, &buf, "update", 1, 0, &output);
- if (err) {
- GDKfree(buf);
- return err;
- }
- b = BATdescriptor(output->cols[0].b);
- if (b) {
- if (BATcount(b) > 0) {
- pos = 0;
- pos += snprintf(buf + pos, bufsize - pos, "set schema
sys;\n");
- pos += snprintf(buf + pos, bufsize - pos,
- "update sys.functions set side_effect =
true where language <> 0 and not side_effect and type <> 4 and (type = 2 or
(language <> 2 and id not in (select func_id from sys.args where inout =
1)));\n");
-
- if (schema)
- pos += snprintf(buf + pos, bufsize - pos, "set
schema \"%s\";\n", schema);
- pos += snprintf(buf + pos, bufsize - pos, "commit;\n");
-
- assert(pos < bufsize);
- printf("Running database upgrade commands:\n%s\n", buf);
- err = SQLstatementIntern(c, &buf, "update", 1, 0,
&output);
- }
- BBPunfix(b->batCacheid);
- }
- res_table_destroy(output);
- GDKfree(buf);
- return err; /* usually MAL_SUCCEED */
-}
-
-static str
sql_update_storagemodel(Client c, mvc *sql)
{
size_t bufsize = 20000, pos = 0;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list