Changeset: a36fcbe68523 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a36fcbe68523 Modified Files: sql/server/sql_mvc.c Branch: Jun2016 Log Message:
When recreating tables and columns views, also update dependencies table. diffs (61 lines): 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 @@ -64,6 +64,7 @@ mvc_init(int debug, store_type store, in if (first || catalog_version) { sql_schema *s; sql_table *t; + sqlid tid = 0, ntid, cid = 0, ncid; mvc *m = mvc_create(0, stk, 0, NULL, NULL); m->sa = sa_create(); @@ -80,12 +81,15 @@ mvc_init(int debug, store_type store, in if (!first) { t = mvc_bind_table(m, s, "tables"); + tid = t->base.id; mvc_drop_table(m, s, t, 0); t = mvc_bind_table(m, s, "columns"); + cid = t->base.id; mvc_drop_table(m, s, t, 0); } t = mvc_create_view(m, s, "tables", SQL_PERSIST, "SELECT \"id\", \"name\", \"schema_id\", \"query\", CAST(CASE WHEN \"system\" THEN \"type\" + 10 /* system table/view */ ELSE (CASE WHEN \"commit_action\" = 0 THEN \"type\" /* table/view */ ELSE \"type\" + 20 /* global temp table */ END) END AS SMALLINT) AS \"type\", \"system\", \"commit_action\", \"access\", CASE WHEN (NOT \"system\" AND \"commit_action\" > 0) THEN 1 ELSE 0 END AS \"temporary\" FROM \"sys\".\"_tables\" WHERE \"type\" <> 2 UNION ALL SELECT \"id\", \"name\", \"schema_id\", \"query\", CAST(\"type\" + 30 /* local temp table */ AS SMALLINT) AS \"type\", \"system\", \"commit_action\", \"access\", 1 AS \"temporary\" FROM \"tmp\".\"_tables\";", 1); + ntid = t->base.id; mvc_create_column_(m, t, "id", "int", 32); mvc_create_column_(m, t, "name", "varchar", 1024); mvc_create_column_(m, t, "schema_id", "int", 32); @@ -101,10 +105,18 @@ mvc_init(int debug, store_type store, in int p = PRIV_SELECT; int zero = 0; sql_table *privs = find_sql_table(s, "privileges"); + sql_table *deps = find_sql_table(s, "dependencies"); + sql_column *depids = find_sql_column(deps, "id"); + oid rid; + table_funcs.table_insert(m->session->tr, privs, &t->base.id, &pub, &p, &zero, &zero); + while ((rid = table_funcs.column_find_row(m->session->tr, depids, &tid, NULL)) != oid_nil) { + table_funcs.column_update_value(m->session->tr, depids, rid, &ntid); + } } t = mvc_create_view(m, s, "columns", SQL_PERSIST, "SELECT * FROM (SELECT p.* FROM \"sys\".\"_columns\" AS p UNION ALL SELECT t.* FROM \"tmp\".\"_columns\" AS t) AS columns;", 1); + ncid = t->base.id; mvc_create_column_(m, t, "id", "int", 32); mvc_create_column_(m, t, "name", "varchar", 1024); mvc_create_column_(m, t, "type", "varchar", 1024); @@ -121,7 +133,14 @@ mvc_init(int debug, store_type store, in int p = PRIV_SELECT; int zero = 0; sql_table *privs = find_sql_table(s, "privileges"); + sql_table *deps = find_sql_table(s, "dependencies"); + sql_column *depids = find_sql_column(deps, "id"); + oid rid; + table_funcs.table_insert(m->session->tr, privs, &t->base.id, &pub, &p, &zero, &zero); + while ((rid = table_funcs.column_find_row(m->session->tr, depids, &cid, NULL)) != oid_nil) { + table_funcs.column_update_value(m->session->tr, depids, rid, &ncid); + } } else { sql_create_env(m, s); sql_create_privileges(m, s); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list