Changeset: eaebffc6bfd4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/eaebffc6bfd4
Modified Files:
        sql/backends/monet5/sql_upgrades.c
        
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-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/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: default
Log Message:

Add upgrade code to fix a dependency.
The dependency of function get_merge_table_partition_expressions for
column id in sys.table_partitions was never there, but older versions
recorded it in the sys.dependencies table anyway.


diffs (292 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
@@ -5245,6 +5245,36 @@ sql_update_dec2025(Client c, mvc *sql, s
        return err;
 }
 
+static str
+sql_update_default(Client c, mvc *sql, sql_schema *s)
+{
+       char *err;
+       res_table *output;
+       BAT *b;
+
+       (void) sql;
+       (void) s;
+
+       /* 2048 is id of column sys.table_partitions.id */
+       err = SQLstatementIntern(c, "select * from sys.dependencies where id = 
2048 and depend_id = (select f.id from sys.functions f where name = 
'get_merge_table_partition_expressions');\n", "update", true, false, &output);
+       if (err)
+               return err;
+       b = BATdescriptor(output->cols[0].b);
+       if (b != NULL) {
+               if (BATcount(b) != 0) {
+                       const char query[] =
+                               "delete from sys.dependencies where id = 2048 
and depend_id = (select f.id from sys.functions f where name = 
'get_merge_table_partition_expressions');\n";
+                       printf("Running database upgrade commands:\n%s\n", 
query);
+                       fflush(stdout);
+                       err = SQLstatementIntern(c, query, "update", true, 
false, NULL);
+               }
+               BBPreclaim(b);
+       }
+       res_table_destroy(output);
+
+       return err;
+}
+
 int
 SQLupgrades(Client c, mvc *m)
 {
@@ -5328,6 +5358,11 @@ SQLupgrades(Client c, mvc *m)
                goto handle_error;
        }
 
+       if ((err = sql_update_default(c, m, s)) != NULL) {
+               TRC_CRITICAL(SQL_PARSER, "%s\n", err);
+               goto handle_error;
+       }
+
        return 0;
 
 handle_error:
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
@@ -628,3 +628,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -628,3 +628,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -711,3 +711,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -628,3 +628,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -628,3 +628,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -711,3 +711,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -253,3 +253,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -253,3 +253,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -338,3 +338,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -253,3 +253,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -253,3 +253,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -338,3 +338,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -628,3 +628,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -628,3 +628,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -711,3 +711,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -628,3 +628,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
@@ -628,3 +628,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
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
+++ b/sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
@@ -711,3 +711,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
diff --git a/sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -253,3 +253,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
diff --git a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
@@ -253,3 +253,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
diff --git a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128 
b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
--- a/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
+++ b/sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
@@ -338,3 +338,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
diff --git a/sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128 
b/sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
@@ -253,3 +253,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
diff --git a/sql/test/testdb-upgrade/Tests/upgrade.stable.out 
b/sql/test/testdb-upgrade/Tests/upgrade.stable.out
--- a/sql/test/testdb-upgrade/Tests/upgrade.stable.out
+++ b/sql/test/testdb-upgrade/Tests/upgrade.stable.out
@@ -253,3 +253,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
diff --git a/sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128 
b/sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
--- a/sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
+++ b/sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
@@ -338,3 +338,6 @@ returns text external name "calc"."to_he
 grant execute on function to_hex(bigint) to public;
 update sys.functions set system = true where not system and schema_id = 2000 
and name = 'to_hex' and type = 1;
 
+Running database upgrade commands:
+delete from sys.dependencies where id = 2048 and depend_id = (select f.id from 
sys.functions f where name = 'get_merge_table_partition_expressions');
+
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to