Changeset: 28d0d9808b1a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=28d0d9808b1a
Modified Files:
sql/backends/monet5/sql_scenario.c
sql/server/sql_mvc.c
sql/storage/store.c
Branch: default
Log Message:
upgrade path fixes, ie make sure the new columns are added to the catalog
some old need a different order number
and old view columns should be removed
diffs (78 lines):
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
@@ -856,6 +856,18 @@ sql_update_default(Client c)
pos += snprintf(buf + pos, bufsize - pos, "set schema \"sys\";\n");
+ /* cleanup columns of dropped views */
+ pos += snprintf(buf + pos, bufsize - pos, "delete from _columns where
table_id not in (select id from _tables);\n");
+
+ /* add new columns */
+ pos += snprintf(buf + pos, bufsize - pos, "insert into _columns values(
(select max(id)+1 from _columns), 'system', 'boolean', 1, 0, (select id from
_tables where name = 'schemas'), NULL, true, 4, NULL);\n");
+ 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");
+ /* 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");
+
/* remove table return types (#..), ie tt_generated from
* _tables/_columns */
pos += snprintf(buf + pos, bufsize - pos, "delete from _columns where
table_id in (select id from _tables where name like '#%%');\n");
diff --git a/sql/server/sql_mvc.c b/sql/server/sql_mvc.c
--- a/sql/server/sql_mvc.c
+++ b/sql/server/sql_mvc.c
@@ -65,7 +65,7 @@ mvc_init(int debug, store_type store, in
s = m->session->schema = mvc_bind_schema(m, "sys");
assert(m->session->schema != NULL);
- if (catalog_version) {
+ if (!first) {
t = mvc_bind_table(m, s, "tables");
mvc_drop_table(m, s, t, 0);
t = mvc_bind_table(m, s, "columns");
@@ -83,7 +83,7 @@ mvc_init(int debug, store_type store, in
mvc_create_column_(m, t, "readonly", "boolean", 1);
mvc_create_column_(m, t, "temporary", "smallint", 16);
- if (catalog_version) {
+ if (!first) {
int pub = ROLE_PUBLIC;
int p = PRIV_SELECT;
int zero = 0;
@@ -103,15 +103,13 @@ mvc_init(int debug, store_type store, in
mvc_create_column_(m, t, "number", "int", 32);
mvc_create_column_(m, t, "storage", "varchar", 2048);
- if (catalog_version) {
+ if (!first) {
int pub = ROLE_PUBLIC;
int p = PRIV_SELECT;
int zero = 0;
sql_table *privs = find_sql_table(s, "privileges");
table_funcs.table_insert(m->session->tr, privs,
&t->base.id, &pub, &p, &zero, &zero);
- }
-
- if (!catalog_version) {
+ } else {
sql_create_env(m, s);
sql_create_privileges(m, s);
}
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -871,11 +871,9 @@ load_schema(sql_trans *tr, sqlid id, oid
s = SA_ZNEW(tr->sa, sql_schema);
v = table_funcs.column_find_value(tr, find_sql_column(ss,
"name"), rid);
base_init(tr->sa, &s->base, sid, TR_OLD, v); _DELETE(v);
- v = table_funcs.column_find_value(tr,
- find_sql_column(ss, "authorization"), rid);
+ v = table_funcs.column_find_value(tr, find_sql_column(ss,
"authorization"), rid);
s->auth_id = *(sqlid *)v; _DELETE(v);
- v = table_funcs.column_find_value(tr,
- find_sql_column(tables, "system"), rid);
+ v = table_funcs.column_find_value(tr, find_sql_column(ss,
"system"), rid);
s->system = *(bit *)v; _DELETE(v);
v = table_funcs.column_find_value(tr, find_sql_column(ss,
"owner"), rid);
s->owner = *(sqlid *)v; _DELETE(v);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list