Changeset: edb78a6816c7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=edb78a6816c7
Added Files:
sql/test/merge-partitions/Tests/mergepart21.stable.err
sql/test/merge-partitions/Tests/mergepart21.stable.out
sql/test/merge-partitions/Tests/mergepart22.sql
sql/test/merge-partitions/Tests/mergepart22.stable.err
sql/test/merge-partitions/Tests/mergepart22.stable.out
Modified Files:
sql/include/sql_catalog.h
sql/server/rel_schema.c
sql/server/rel_updates.c
sql/server/sql_partition.c
sql/storage/store.c
sql/test/merge-partitions/Tests/All
sql/test/merge-partitions/Tests/mergepart11.stable.err
sql/test/merge-partitions/Tests/mergepart12.stable.err
sql/test/merge-partitions/Tests/mergepart17.stable.err
sql/test/merge-partitions/Tests/mergepart20.sql
sql/test/merge-partitions/Tests/mergepart21.sql
Branch: merge-partitions
Log Message:
Update on columns used by expressions not possible at the moment.
diffs (truncated from 613 to 300 lines):
diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -544,7 +544,7 @@ typedef struct sql_part {
typedef struct sql_expression {
sql_subtype type; /* the returning sql_subtype of the expression */
char *exp; /* the expression itself */
- list *cols; /* list of oids of the columns of the table used in
the expression */
+ list *cols; /* list of colnr of the columns of the table used in
the expression */
} sql_expression;
typedef struct sql_table {
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -892,8 +892,8 @@ table_element(mvc *sql, symbol *s, sql_s
}
if (isPartitionedByExpressionTable(t)) {
for(node *n = t->part.pexp->cols->h; n; n = n->next) {
- sqlid next = *(sqlid*) n->data;
- if(next == col->base.id) {
+ int next = *(int*) n->data;
+ if(next == col->colnr) {
sql_error(sql, 02, SQLSTATE(42000)
"ALTER TABLE: cannot drop column '%s': the expression used in '%s' depends on
it\n", cname, t->base.name);
return SQL_ERR;
}
diff --git a/sql/server/rel_updates.c b/sql/server/rel_updates.c
--- a/sql/server/rel_updates.c
+++ b/sql/server/rel_updates.c
@@ -894,24 +894,32 @@ update_table(mvc *sql, dlist *qname, dli
t = stack_find_table(sql, tname);
}
if (update_allowed(sql, t, tname, "UPDATE", "update", 0) != NULL) {
+ sql_table *mt = NULL;
sql_exp *e = NULL, **updates;
sql_rel *r = NULL;
- list *exps;
+ list *exps, *pcols = NULL;
dnode *n;
const char *rname = NULL;
sql_rel *res = NULL, *bt = rel_basetable(sql, t, t->base.name);
- int partitioned_column = -1;
- if(isPartitionedByColumnTable(t)) { //TODO for expressions
- partitioned_column = t->part.pcol->colnr;
+ if(isPartitionedByColumnTable(t) ||
isPartitionedByExpressionTable(t)) {
+ mt = t;
} else if(t->p) {
sql_part *pt = find_sql_part(t->p, t->base.name);
if(!pt) {
t->p = NULL;
- } else if(isPartitionedByColumnTable(t->p)) {
- partitioned_column = t->p->part.pcol->colnr;
+ } else if(isPartitionedByColumnTable(t->p) ||
isPartitionedByExpressionTable(t->p)) {
+ mt = t->p;
}
}
+ if(mt && isPartitionedByColumnTable(mt)) {
+ pcols = sa_list(sql->sa);
+ int *nid = sa_alloc(sql->sa, sizeof(int));
+ *nid = mt->part.pcol->colnr;
+ list_append(pcols, nid);
+ } else if(mt && isPartitionedByExpressionTable(mt)) {
+ pcols = mt->part.pexp->cols;
+ }
res = bt;
#if 0
dlist *selection = dlist_create(sql->sa);
@@ -1086,8 +1094,18 @@ update_table(mvc *sql, dlist *qname, dli
sql_column *c = mvc_bind_column(sql, t,
cname);
sql_exp *v = n->data;
- if(partitioned_column == c->colnr)
- return sql_error(sql, 02,
SQLSTATE(42000) "UPDATE: Update on the partitioned column not possible at the
moment");
+ if(mt && pcols) {
+ for(node *nn = pcols->h; nn; nn
= n->next) {
+ int next = *(int*)
nn->data;
+ if(next == c->colnr) {
+
if(isPartitionedByColumnTable(mt)) {
+ return
sql_error(sql, 02, SQLSTATE(42000) "UPDATE: Update on the partitioned column is
not possible at the moment");
+ } else
if(isPartitionedByExpressionTable(mt)) {
+ return
sql_error(sql, 02, SQLSTATE(42000) "UPDATE: Update a column used by the
partition's expression is not possible at the moment");
+ }
+ }
+ }
+ }
if (!exp_name(v))
exp_label(sql->sa, v,
++sql->label);
v = exp_column(sql->sa, exp_relname(v),
exp_name(v), exp_subtype(v), v->card, has_nil(v), is_intern(v));
@@ -1105,8 +1123,18 @@ update_table(mvc *sql, dlist *qname, dli
char *cname = assignment->h->next->data.sval;
sql_column *c = mvc_bind_column(sql, t, cname);
- if(partitioned_column == c->colnr)
- return sql_error(sql, 02,
SQLSTATE(42000) "UPDATE: Update on the partitioned column not possible at the
moment");
+ if(mt && pcols) {
+ for(node *nn = pcols->h; nn; nn =
nn->next) {
+ int next = *(int*) nn->data;
+ if(next == c->colnr) {
+
if(isPartitionedByColumnTable(mt)) {
+ return
sql_error(sql, 02, SQLSTATE(42000) "UPDATE: Update on the partitioned column is
not possible at the moment");
+ } else
if(isPartitionedByExpressionTable(mt)) {
+ return
sql_error(sql, 02, SQLSTATE(42000) "UPDATE: Update a column used by the
partition's expression is not possible at the moment");
+ }
+ }
+ }
+ }
if (!v) {
v = exp_atom(sql->sa,
atom_general(sql->sa, &c->type, NULL));
} else if ((v = update_check_column(sql, t, c,
v, r, cname)) == NULL) {
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
@@ -82,9 +82,9 @@ exp_find_table_columns(mvc *sql, sql_exp
if(!strcmp(e->l, t->base.name)) {
sql_column *col = find_sql_column(t, e->r);
if(col) {
- sqlid *nid = sa_alloc(cols->sa,
sizeof(sqlid));
- *nid = col->base.id;
- list_append(cols, nid);
+ int *cnr = sa_alloc(cols->sa,
sizeof(int));
+ *cnr = col->colnr;
+ list_append(cols, cnr);
}
}
} break;
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1539,8 +1539,8 @@ dup_sql_table(sql_allocator *sa, sql_tab
nt->part.pexp->type = t->part.pexp->type;
nt->part.pexp->cols = sa_list(sa);
for(node *n = t->part.pexp->cols->h; n; n = n->next) {
- sqlid *nid = sa_alloc(sa, sizeof(sqlid));
- *nid = *(sqlid *) n->data;
+ int *nid = sa_alloc(sa, sizeof(int));
+ *nid = *(int *) n->data;
list_append(nt->part.pexp->cols, nid);
}
}
@@ -2680,8 +2680,8 @@ table_dup(sql_trans *tr, int flag, sql_t
t->part.pexp->type = *empty;
t->part.pexp->cols = sa_list(sa);
for(node *n = ot->part.pexp->cols->h; n; n = n->next) {
- sqlid *nid = sa_alloc(sa, sizeof(sqlid));
- *nid = *(sqlid *) n->data;
+ int *nid = sa_alloc(sa, sizeof(int));
+ *nid = *(int *) n->data;
list_append(t->part.pexp->cols, nid);
}
}
diff --git a/sql/test/merge-partitions/Tests/All
b/sql/test/merge-partitions/Tests/All
--- a/sql/test/merge-partitions/Tests/All
+++ b/sql/test/merge-partitions/Tests/All
@@ -20,3 +20,4 @@ mergepart18
mergepart19
mergepart20
mergepart21
+mergepart22
diff --git a/sql/test/merge-partitions/Tests/mergepart11.stable.err
b/sql/test/merge-partitions/Tests/mergepart11.stable.err
--- a/sql/test/merge-partitions/Tests/mergepart11.stable.err
+++ b/sql/test/merge-partitions/Tests/mergepart11.stable.err
@@ -30,19 +30,19 @@ stderr of test 'mergepart11` in director
MAPI = (monetdb) /var/tmp/mtest-21121/.s.monetdb.39288
QUERY = UPDATE moveaccrosspartitions SET a = a + 1 WHERE a % 50 = 0;
-ERROR = !UPDATE: Update on the partitioned column not possible at the moment
+ERROR = !UPDATE: Update on the partitioned column is not possible at the moment
CODE = 42000
MAPI = (monetdb) /var/tmp/mtest-21121/.s.monetdb.39288
QUERY = UPDATE moveaccrosspartitions SET a = a - 50, b = 'p' || b || 's' WHERE
a % 60 = 0;
-ERROR = !UPDATE: Update on the partitioned column not possible at the moment
+ERROR = !UPDATE: Update on the partitioned column is not possible at the moment
CODE = 42000
MAPI = (monetdb) /var/tmp/mtest-21121/.s.monetdb.39288
QUERY = UPDATE moveaccrosspartitions SET a = a - 60 WHERE a % 10 = 0; --error
-ERROR = !UPDATE: Update on the partitioned column not possible at the moment
+ERROR = !UPDATE: Update on the partitioned column is not possible at the moment
CODE = 42000
MAPI = (monetdb) /var/tmp/mtest-21121/.s.monetdb.39288
QUERY = UPDATE moveaccrosspartitions SET a = a + 100, b = 'moved' WHERE a % 10
= 0 AND a < 100;
-ERROR = !UPDATE: Update on the partitioned column not possible at the moment
+ERROR = !UPDATE: Update on the partitioned column is not possible at the moment
CODE = 42000
# 09:47:13 >
diff --git a/sql/test/merge-partitions/Tests/mergepart12.stable.err
b/sql/test/merge-partitions/Tests/mergepart12.stable.err
--- a/sql/test/merge-partitions/Tests/mergepart12.stable.err
+++ b/sql/test/merge-partitions/Tests/mergepart12.stable.err
@@ -30,15 +30,15 @@ stderr of test 'mergepart12` in director
MAPI = (monetdb) /var/tmp/mtest-27133/.s.monetdb.35212
QUERY = UPDATE testme SET a = a + 1;
-ERROR = !UPDATE: Update on the partitioned column not possible at the moment
+ERROR = !UPDATE: Update on the partitioned column is not possible at the moment
CODE = 42000
MAPI = (monetdb) /var/tmp/mtest-27133/.s.monetdb.35212
QUERY = UPDATE sublimits1 SET a = a * 3;
-ERROR = !UPDATE: Update on the partitioned column not possible at the moment
+ERROR = !UPDATE: Update on the partitioned column is not possible at the moment
CODE = 42000
MAPI = (monetdb) /var/tmp/mtest-27133/.s.monetdb.35212
QUERY = UPDATE sublimits2 SET a = a * 3;
-ERROR = !UPDATE: Update on the partitioned column not possible at the moment
+ERROR = !UPDATE: Update on the partitioned column is not possible at the moment
CODE = 42000
# 10:52:09 >
diff --git a/sql/test/merge-partitions/Tests/mergepart17.stable.err
b/sql/test/merge-partitions/Tests/mergepart17.stable.err
--- a/sql/test/merge-partitions/Tests/mergepart17.stable.err
+++ b/sql/test/merge-partitions/Tests/mergepart17.stable.err
@@ -36,7 +36,7 @@ ERROR = !ALTER TABLE: there are values i
CODE = M0M29
MAPI = (monetdb) /var/tmp/mtest-9208/.s.monetdb.33193
QUERY = UPDATE sublimits1 SET a = a + 1; --error
-ERROR = !UPDATE: Update on the partitioned column not possible at the moment
+ERROR = !UPDATE: Update on the partitioned column is not possible at the moment
CODE = 42000
MAPI = (monetdb) /var/tmp/mtest-9208/.s.monetdb.33193
QUERY = ALTER TABLE testupdates ADD TABLE sublimits1 AS PARTITION BETWEEN 1
AND 100; --error
diff --git a/sql/test/merge-partitions/Tests/mergepart20.sql
b/sql/test/merge-partitions/Tests/mergepart20.sql
--- a/sql/test/merge-partitions/Tests/mergepart20.sql
+++ b/sql/test/merge-partitions/Tests/mergepart20.sql
@@ -49,5 +49,6 @@ ALTER TABLE testme DROP TABLE subtable2;
DROP TABLE subtable1;
DROP TABLE subtable2;
+DROP TABLE subtable3;
DROP TABLE testme;
DROP FUNCTION iamdummy;
diff --git a/sql/test/merge-partitions/Tests/mergepart21.sql
b/sql/test/merge-partitions/Tests/mergepart21.sql
--- a/sql/test/merge-partitions/Tests/mergepart21.sql
+++ b/sql/test/merge-partitions/Tests/mergepart21.sql
@@ -39,12 +39,12 @@ DROP FUNCTION dosomething;
CREATE FUNCTION dosomethingelse(i int) RETURNS TABLE (j int) BEGIN RETURN
TABLE(SELECT i); END;
-CREATE MERGE TABLE nexttest (a int, dd real) PARTITION BY VALUES USING
(dosomethingelse(a));
+CREATE MERGE TABLE nexttest (a int, dd real) PARTITION BY VALUES USING
(dosomethingelse(a)); --error
CREATE TABLE subtable3 (a int, dd real);
INSERT INTO subtable3 VALUES (0, 1.68);
-ALTER TABLE nexttest ADD TABLE subtable3 AS PARTITION IN (1, 2, 10);
+ALTER TABLE nexttest ADD TABLE subtable3 AS PARTITION IN (1, 2, 10); --error
DROP TABLE subtable3;
-DROP TABLE nexttest;
+DROP TABLE nexttest; --error
DROP FUNCTION dosomethingelse;
diff --git a/sql/test/merge-partitions/Tests/mergepart21.stable.err
b/sql/test/merge-partitions/Tests/mergepart21.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/merge-partitions/Tests/mergepart21.stable.err
@@ -0,0 +1,87 @@
+stderr of test 'mergepart21` in directory 'sql/test/merge-partitions` itself:
+
+
+# 11:15:07 >
+# 11:15:07 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=34012" "--set"
"mapi_usock=/var/tmp/mtest-9195/.s.monetdb.34012" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/home/ferreira/repositories/MonetDB-merge-partitions/BUILD/var/MonetDB/mTests_sql_test_merge-partitions"
"--set" "embedded_c=true"
+# 11:15:07 >
+
+# builtin opt gdk_dbpath =
/home/ferreira/repositories/MonetDB-merge-partitions/BUILD/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = no
+# builtin opt monet_prompt = >
+# builtin opt monet_daemon = no
+# builtin opt mapi_port = 50000
+# builtin opt mapi_open = false
+# builtin opt mapi_autosense = false
+# builtin opt sql_optimizer = default_pipe
+# builtin opt sql_debug = 0
+# cmdline opt gdk_nr_threads = 0
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 34012
+# cmdline opt mapi_usock = /var/tmp/mtest-9195/.s.monetdb.34012
+# cmdline opt monet_prompt =
+# cmdline opt gdk_dbpath =
/home/ferreira/repositories/MonetDB-merge-partitions/BUILD/var/MonetDB/mTests_sql_test_merge-partitions
+# cmdline opt embedded_c = true
+# cmdline opt gdk_debug = 553648138
+
+# 11:15:08 >
+# 11:15:08 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-9195" "--port=34012"
+# 11:15:08 >
+
+MAPI = (monetdb) /var/tmp/mtest-9195/.s.monetdb.34012
+QUERY = ALTER TABLE trydropme ADD COLUMN failing int; --error
+ERROR = !ALTER TABLE: cannot add column to VIEW 'trydropme'
+CODE = 42000
+MAPI = (monetdb) /var/tmp/mtest-9195/.s.monetdb.34012
+QUERY = ALTER TABLE trydropme DROP COLUMN cc; --error
+ERROR = !ALTER TABLE: cannot drop column 'cc': is the partitioned column on
the table 'trydropme'
+CODE = 42000
+MAPI = (monetdb) /var/tmp/mtest-9195/.s.monetdb.34012
+QUERY = ALTER TABLE nexttest ADD COLUMN failing int; --error
+ERROR = !ALTER TABLE: cannot add column to VIEW 'nexttest'
+CODE = 42000
+MAPI = (monetdb) /var/tmp/mtest-9195/.s.monetdb.34012
+QUERY = ALTER TABLE nexttest DROP COLUMN a; --error
+ERROR = !ALTER TABLE: cannot drop column 'a': the expression used in
'nexttest' depends on it
+CODE = 42000
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list