Changeset: 42937c39d53e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/42937c39d53e
Modified Files:
sql/server/rel_distribute.c
sql/server/rel_optimizer.c
sql/server/rel_schema.c
sql/server/rel_select.c
sql/test/merge-partitions/Tests/mergepart16.test
sql/test/mergetables/Tests/alter.test
sql/test/mergetables/Tests/emptymergequery.test
sql/test/mergetables/Tests/merge-tables-limitations.test
sql/test/mergetables/Tests/mergemergeload.test
sql/test/mergetables/Tests/mergetabledependencies.test
sql/test/mergetables/Tests/replicas.test
sql/test/mergetables/Tests/replicatabledependencies.test
sql/test/mergetables/Tests/types.test
Branch: default
Log Message:
Improve and harmonize error messages containing: ' should have at least one
table associated'.
They now show the table type (no more: MERGE or REPLICA TABLE) and which table
exactly is missing an associated table.
So less guessing/analysing for an SQL developer.
diffs (277 lines):
diff --git a/sql/server/rel_distribute.c b/sql/server/rel_distribute.c
--- a/sql/server/rel_distribute.c
+++ b/sql/server/rel_distribute.c
@@ -150,8 +150,8 @@ replica_rewrite(visitor *v, sql_table *t
}
if ((isMergeTable(pt) || isReplicaTable(pt)) &&
list_empty(pt->members))
- return sql_error(v->sql, 02, SQLSTATE(42000) "The %s
'%s.%s' should have at least one table associated",
-
TABLE_TYPE_DESCRIPTION(pt->type, pt->properties), pt->s->base.name,
pt->base.name);
+ return sql_error(v->sql, 02, SQLSTATE(42000) "%s
'%s'.'%s' should have at least one table associated",
+
TABLE_TYPE_DESCRIPTION(pt->type, pt->properties), pt->s->base.name,
pt->base.name);
res = isReplicaTable(pt) ? replica_rewrite(v, pt, exps) :
rewrite_replica(v->sql, exps, t, pt, remote);
}
return res;
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -86,8 +86,8 @@ merge_table_prune_and_unionize(visitor *
/* At the moment we throw an error in the optimizer, but later
this rewriter should move out from the optimizers */
if ((isMergeTable(pt) || isReplicaTable(pt)) &&
list_empty(pt->members))
- return sql_error(v->sql, 02, SQLSTATE(42000) "The %s
'%s.%s' should have at least one table associated",
-
TABLE_TYPE_DESCRIPTION(pt->type, pt->properties), pt->s->base.name,
pt->base.name);
+ return sql_error(v->sql, 02, SQLSTATE(42000) "%s
'%s'.'%s' should have at least one table associated",
+
TABLE_TYPE_DESCRIPTION(pt->type, pt->properties), pt->s->base.name,
pt->base.name);
/* Do not include empty partitions */
if (isTable(pt) && pt->access == TABLE_READONLY &&
!store->storage_api.count_col(v->sql->session->tr,
ol_first_node(pt->columns)->data, 10)) /* count active rows only */
continue;
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
@@ -1794,37 +1794,37 @@ sql_alter_table(sql_query *query, dlist
return NULL;
if (isView(pt))
return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE:
can't add/drop a view into a %s",
-
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
+
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
if (isDeclaredTable(pt))
return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE:
can't add/drop a declared table into a %s",
-
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
+
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
if (isTempSchema(pt->s))
return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE:
can't add/drop a temporary table into a %s",
-
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
+
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
if (isReplicaTable(t) && isMergeTable(pt))
return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE:
can't add/drop a %s table into a %s",
-
TABLE_TYPE_DESCRIPTION(pt->type, pt->properties),
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
+
TABLE_TYPE_DESCRIPTION(pt->type, pt->properties),
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
nsname = pt->s->base.name;
if (strcmp(sname, nsname) != 0)
- return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE:
all children tables of '%s.%s' must be "
- "part of schema
'%s'", sname, tname, sname);
+ return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE:
all children tables of '%s.%s' must be part of schema '%s'",
+ sname, tname, sname);
if (te->token == SQL_TABLE) {
symbol *extra = dl->h->next->next->next->data.sym;
if (!extra) {
if (isRangePartitionTable(t)) {
- return sql_error(sql,
02,SQLSTATE(42000) "ALTER TABLE: a range partition is required while adding
under a %s",
-
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
+ return sql_error(sql, 02,
SQLSTATE(42000) "ALTER TABLE: a range partition is required while adding under
a %s",
+
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
} else if (isListPartitionTable(t)) {
- return sql_error(sql,
02,SQLSTATE(42000) "ALTER TABLE: a value partition is required while adding
under a %s",
-
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
+ return sql_error(sql, 02,
SQLSTATE(42000) "ALTER TABLE: a value partition is required while adding under
a %s",
+
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
}
return rel_alter_table(sql->sa,
ddl_alter_table_add_table, sname, tname, nsname, ntname, 0);
}
if ((isMergeTable(pt) || isReplicaTable(pt)) &&
list_length(pt->members)==0)
- return sql_error(sql, 02, SQLSTATE(42000) "The
%s %s.%s should have at least one table associated",
-
TABLE_TYPE_DESCRIPTION(pt->type, pt->properties), pt->s->base.name,
pt->base.name);
+ return sql_error(sql, 02, SQLSTATE(42000) "%s
'%s'.'%s' should have at least one table associated",
+
TABLE_TYPE_DESCRIPTION(pt->type, pt->properties), pt->s->base.name,
pt->base.name);
if (extra->token == SQL_MERGE_PARTITION) { /* partition
to hold null values only */
dlist* ll = extra->data.lval;
@@ -1836,7 +1836,7 @@ sql_alter_table(sql_query *query, dlist
return
rel_alter_table_add_partition_list(query, t, pt, sname, tname, nsname, ntname,
NULL, true, update);
} else {
return sql_error(sql, 02,
SQLSTATE(42000) "ALTER TABLE: cannot add a partition into a %s",
-
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
+
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
}
} else if (extra->token == SQL_PARTITION_RANGE) {
dlist* ll = extra->data.lval;
@@ -1845,7 +1845,7 @@ sql_alter_table(sql_query *query, dlist
if (!isRangePartitionTable(t)) {
return sql_error(sql,
02,SQLSTATE(42000) "ALTER TABLE: cannot add a range partition into a %s",
-
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
+
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
}
assert(nills == 0 || nills == 1);
@@ -1856,7 +1856,7 @@ sql_alter_table(sql_query *query, dlist
if (!isListPartitionTable(t)) {
return sql_error(sql,
02,SQLSTATE(42000) "ALTER TABLE: cannot add a value partition into a %s",
-
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
+
TABLE_TYPE_DESCRIPTION(t->type, t->properties));
}
assert(nills == 0 || nills == 1);
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -1015,7 +1015,8 @@ table_ref(sql_query *query, symbol *tabl
return rel;
}
if ((isMergeTable(t) || isReplicaTable(t)) &&
list_length(t->members)==0)
- return sql_error(sql, 02, SQLSTATE(42000) "MERGE or
REPLICA TABLE should have at least one table associated");
+ return sql_error(sql, 02, SQLSTATE(42000) "%s '%s'.'%s'
should have at least one table associated",
+
TABLE_TYPE_DESCRIPTION(t->type, t->properties), t->s->base.name, tname);
res = rel_basetable(sql, t, tname);
if (!allowed) {
rel_base_disallow(res);
diff --git a/sql/test/merge-partitions/Tests/mergepart16.test
b/sql/test/merge-partitions/Tests/mergepart16.test
--- a/sql/test/merge-partitions/Tests/mergepart16.test
+++ b/sql/test/merge-partitions/Tests/mergepart16.test
@@ -22,7 +22,7 @@ CREATE TABLE subt4 (a int, b varchar(32)
statement error 42000!INSERT INTO: list partitioned table
'testnestedpartitions' has no partitions set
INSERT INTO testnestedpartitions VALUES (1, 'ups')
-statement error 42000!The RANGE PARTITION TABLE sys.subnested1 should have at
least one table associated
+statement error 42000!RANGE PARTITION TABLE 'sys'.'subnested1' should have at
least one table associated
ALTER TABLE testnestedpartitions ADD TABLE subnested1 AS PARTITION IN ('1',
'2', '3')
statement ok
@@ -82,7 +82,7 @@ ok
1
ok
-statement error 42000!The RANGE PARTITION TABLE sys.subnested2 should have at
least one table associated
+statement error 42000!RANGE PARTITION TABLE 'sys'.'subnested2' should have at
least one table associated
ALTER TABLE testnestedpartitions ADD TABLE subnested2 AS PARTITION IN ('3',
'4', '5')
statement ok
diff --git a/sql/test/mergetables/Tests/alter.test
b/sql/test/mergetables/Tests/alter.test
--- a/sql/test/mergetables/Tests/alter.test
+++ b/sql/test/mergetables/Tests/alter.test
@@ -28,7 +28,7 @@ alter table mys.smalltable add table par
statement error 42S02!ALTER TABLE: no such table 'mys'.'part1'
alter table mys.smalltable add table mys.part1
-statement error 42000!MERGE or REPLICA TABLE should have at least one table
associated
+statement error 42000!MERGE TABLE 'mys'.'smalltable' should have at least one
table associated
select * from mys.smalltable
statement ok
diff --git a/sql/test/mergetables/Tests/emptymergequery.test
b/sql/test/mergetables/Tests/emptymergequery.test
--- a/sql/test/mergetables/Tests/emptymergequery.test
+++ b/sql/test/mergetables/Tests/emptymergequery.test
@@ -1,7 +1,7 @@
statement ok
create merge table emptym(i integer, j integer)
-statement error 42000!MERGE or REPLICA TABLE should have at least one table
associated
+statement error 42000!MERGE TABLE 'sys'.'emptym' should have at least one
table associated
select * from emptym
statement ok
diff --git a/sql/test/mergetables/Tests/merge-tables-limitations.test
b/sql/test/mergetables/Tests/merge-tables-limitations.test
--- a/sql/test/mergetables/Tests/merge-tables-limitations.test
+++ b/sql/test/mergetables/Tests/merge-tables-limitations.test
@@ -45,7 +45,7 @@ 0
0
0
-statement error 42000!MERGE or REPLICA TABLE should have at least one table
associated
+statement error 42000!MERGE TABLE 'tst'.'mtbl' should have at least one table
associated
select * from tst.mtbl
----
@@ -87,14 +87,14 @@ 0
0
0
-statement error 42000!MERGE or REPLICA TABLE should have at least one table
associated
+statement error 42000!REPLICA TABLE 'tst'.'rtbl' should have at least one
table associated
select * from tst.rtbl
----
statement ok
ALTER TABLE tst.mtbl ADD TABLE tst.rtbl
-statement error 42000!The REPLICA TABLE 'tst.rtbl' should have at least one
table associated
+statement error 42000!REPLICA TABLE 'tst'.'rtbl' should have at least one
table associated
select * from tst.mtbl
----
diff --git a/sql/test/mergetables/Tests/mergemergeload.test
b/sql/test/mergetables/Tests/mergemergeload.test
--- a/sql/test/mergetables/Tests/mergemergeload.test
+++ b/sql/test/mergetables/Tests/mergemergeload.test
@@ -29,7 +29,7 @@ 3.0 0.0 0.0
2.0 1.0 0.0
3.0 1.0 0.0
-statement error 42000!The MERGE TABLE 'sys.part1' should have at least one
table associated
+statement error 42000!MERGE TABLE 'sys'.'part1' should have at least one table
associated
SELECT * FROM COMPLETE
statement ok
diff --git a/sql/test/mergetables/Tests/mergetabledependencies.test
b/sql/test/mergetables/Tests/mergetabledependencies.test
--- a/sql/test/mergetables/Tests/mergetabledependencies.test
+++ b/sql/test/mergetables/Tests/mergetabledependencies.test
@@ -118,7 +118,7 @@ alter table parent drop table child4
statement ok
savepoint sp1
-statement error 42000!MERGE or REPLICA TABLE should have at least one table
associated
+statement error 42000!MERGE TABLE 'sys'.'parent' should have at least one
table associated
SELECT a from myfunc()
statement ok
@@ -173,7 +173,7 @@ select count(*) - (select "a" from "depe
----
0
-statement error 42000!MERGE or REPLICA TABLE should have at least one table
associated
+statement error 42000!MERGE TABLE 'sys'.'parent' should have at least one
table associated
SELECT a from myview
statement ok
diff --git a/sql/test/mergetables/Tests/replicas.test
b/sql/test/mergetables/Tests/replicas.test
--- a/sql/test/mergetables/Tests/replicas.test
+++ b/sql/test/mergetables/Tests/replicas.test
@@ -13,10 +13,10 @@ insert into t3 values (1), (2), (3)
statement ok
alter table t1 add table t2
-statement error 42000!The REPLICA TABLE 'sys.t2' should have at least one
table associated
+statement error 42000!REPLICA TABLE 'sys'.'t2' should have at least one table
associated
select a from t1
-statement error 42000!MERGE or REPLICA TABLE should have at least one table
associated
+statement error 42000!REPLICA TABLE 'sys'.'t2' should have at least one table
associated
select a from t2
statement ok
diff --git a/sql/test/mergetables/Tests/replicatabledependencies.test
b/sql/test/mergetables/Tests/replicatabledependencies.test
--- a/sql/test/mergetables/Tests/replicatabledependencies.test
+++ b/sql/test/mergetables/Tests/replicatabledependencies.test
@@ -82,7 +82,7 @@ alter table parent drop table child3
statement ok
savepoint sp1
-statement error 42000!MERGE or REPLICA TABLE should have at least one table
associated
+statement error 42000!REPLICA TABLE 'sys'.'parent' should have at least one
table associated
SELECT a from myfunc()
statement ok
@@ -112,7 +112,7 @@ alter table parent drop table child3
statement ok
savepoint sp2
-statement error 42000!MERGE or REPLICA TABLE should have at least one table
associated
+statement error 42000!REPLICA TABLE 'sys'.'parent' should have at least one
table associated
SELECT a from myview
statement ok
diff --git a/sql/test/mergetables/Tests/types.test
b/sql/test/mergetables/Tests/types.test
--- a/sql/test/mergetables/Tests/types.test
+++ b/sql/test/mergetables/Tests/types.test
@@ -13,7 +13,7 @@ ALTER TABLE complete ADD TABLE part1
statement error 3F000!ALTER MERGE TABLE: to be added table column type doesn't
match MERGE TABLE definition
ALTER TABLE complete ADD TABLE part2
-statement error 42000!MERGE or REPLICA TABLE should have at least one table
associated
+statement error 42000!MERGE TABLE 'sys'.'complete' should have at least one
table associated
SELECT * FROM COMPLETE
statement ok
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]