Changeset: c4d997547bd4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c4d997547bd4
Modified Files:
        sql/server/sql_partition.c
        sql/test/merge-partitions/Tests/mergepart21.stable.err
        sql/test/merge-partitions/Tests/mergepart23.stable.err
Branch: Oct2020
Log Message:

Don't add table's columns in the list of dependencies, because it's already 
checked in the 'cols' list. Also propagate dependent columns to outer 
transaction


diffs (81 lines):

diff --git a/sql/server/sql_partition.c b/sql/server/sql_partition.c
--- a/sql/server/sql_partition.c
+++ b/sql/server/sql_partition.c
@@ -274,21 +274,16 @@ bootstrap_partition_expression(mvc *sql,
 
        if (instantiate) {
                r = rel_project(sql->sa, r, NULL);
-               exp = rel_project_add_exp(sql, r, exp);
+               sql_rel *base = r->l, *nr = r;
+               r->l = NULL; /* omit table from list of dependencies */
+               (void) rel_project_add_exp(sql, r, exp);
 
-               if (r)
-                       r = sql_processrelation(sql, r, 0, 0);
-               if (r) {
-                       list *id_l = rel_dependencies(sql, r);
-                       /* remove the table itself from the list of 
dependencies */
-                       for (node *n = id_l->h ; n ; ) {
-                               node *m = n->next;
-                               if (*(sqlid *) n->data == mt->base.id)
-                                       list_remove_node(id_l, n);
-                               n = m;
-                       }
+               nr = sql_processrelation(sql, nr, 0, 0);
+               if (nr) {
+                       list *id_l = rel_dependencies(sql, nr);
                        mvc_create_dependencies(sql, id_l, mt->base.id, 
FUNC_DEPENDENCY);
                }
+               r->l = base;
        }
 
        return msg;
@@ -319,8 +314,15 @@ initialize_sql_parts(mvc *sql, sql_table
 
        find_partition_type(&found, mt);
        localtype = found.type->localtype;
-       if (isPartitionedByExpressionTable(mt)) /* Propagate type to outer 
transaction table */
+       if (isPartitionedByExpressionTable(mt)) { /* Propagate type and columns 
to outer transaction table */
                mt->po->part.pexp->type = mt->part.pexp->type;
+               assert(list_empty(mt->po->part.pexp->cols));
+               for (node *n = mt->part.pexp->cols->h ; n ; n = n->next) {
+                       int *cnr = sa_alloc(mt->po->part.pexp->cols->sa, 
sizeof(int));
+                       *cnr = *(int*)n->data;
+                       list_append(mt->po->part.pexp->cols, cnr);
+               }
+       }
 
        if (localtype != TYPE_str && mt->members && list_length(mt->members)) {
                list *new = sa_list(tr->sa), *old = sa_list(tr->sa);
diff --git a/sql/test/merge-partitions/Tests/mergepart21.stable.err 
b/sql/test/merge-partitions/Tests/mergepart21.stable.err
--- a/sql/test/merge-partitions/Tests/mergepart21.stable.err
+++ b/sql/test/merge-partitions/Tests/mergepart21.stable.err
@@ -58,9 +58,9 @@ ERROR = !ALTER TABLE: cannot add column 
 CODE  = 42000
 MAPI  = (monetdb) /var/tmp/mtest-9071/.s.monetdb.34262
 QUERY = ALTER TABLE nexttest DROP COLUMN a; --error
-ERROR = !ALTER TABLE: cannot drop column 'a': there are database objects which 
depend on it
-CODE  = 2BM37
-MAPI  = (monetdb) /var/tmp/mtest-28885/.s.monetdb.37051
+ERROR = !ALTER TABLE: cannot drop column 'a': the expression used in 
'nexttest' depends on it
+CODE  = 42000
+MAPI  = (monetdb) /var/tmp/mtest-177018/.s.monetdb.32503
 QUERY = CREATE MERGE TABLE nexttest (a int, dd real) PARTITION BY VALUES USING 
(dosomethingelse(a)); --error
 ERROR = !SELECT: no such unary operator 'dosomethingelse(int)'
 CODE  = 42000
diff --git a/sql/test/merge-partitions/Tests/mergepart23.stable.err 
b/sql/test/merge-partitions/Tests/mergepart23.stable.err
--- a/sql/test/merge-partitions/Tests/mergepart23.stable.err
+++ b/sql/test/merge-partitions/Tests/mergepart23.stable.err
@@ -49,9 +49,9 @@ ERROR = !ALTER TABLE: cannot drop column
 CODE  = 42000
 MAPI  = (monetdb) /var/tmp/mtest-12650/.s.monetdb.50085
 QUERY = ALTER TABLE anothertest DROP COLUMN "a"; --error, a is used on 
partition expression
-ERROR = !ALTER TABLE: cannot drop column 'a': there are database objects which 
depend on it
-CODE  = 2BM37
-# builtin opt  gdk_dbpath = 
/home/ferreira/repositories/MonetDB-Jun2020/BUILD/var/monetdb5/dbfarm/demo
+ERROR = !ALTER TABLE: cannot drop column 'a': the expression used in 
'anothertest' depends on it
+CODE  = 42000
+# builtin opt  gdk_dbpath = 
/home/ferreira/repositories/MonetDB-Oct2020/BUILD/var/monetdb5/dbfarm/demo
 # builtin opt  mapi_port = 50000
 # builtin opt  mapi_open = false
 # builtin opt  mapi_ipv6 = false
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to