Honor error message conventions

pull/4286/head
Hanefi Önaldı 2020-11-03 14:35:24 +03:00
parent 85a4b61a0e
commit d6f19e2298
No known key found for this signature in database
GPG Key ID: 45A2ACB84E394FBA
6 changed files with 34 additions and 35 deletions

View File

@ -1560,45 +1560,44 @@ UndistributeTable(Oid relationId)
Relation relation = try_relation_open(relationId, ExclusiveLock); Relation relation = try_relation_open(relationId, ExclusiveLock);
if (relation == NULL) if (relation == NULL)
{ {
ereport(ERROR, (errmsg("Cannot undistribute table"), ereport(ERROR, (errmsg("cannot undistribute table"),
errdetail("No such distributed table exists. " errdetail("because no such distributed table exists")));
"Might have already been undistributed.")));
} }
relation_close(relation, NoLock); relation_close(relation, NoLock);
if (!IsCitusTable(relationId)) if (!IsCitusTable(relationId))
{ {
ereport(ERROR, (errmsg("Cannot undistribute table."), ereport(ERROR, (errmsg("cannot undistribute table "),
errdetail("The table is not distributed."))); errdetail("because the table is not distributed")));
} }
if (TableReferencing(relationId)) if (TableReferencing(relationId))
{ {
ereport(ERROR, (errmsg("Cannot undistribute table " ereport(ERROR, (errmsg("cannot undistribute table "
"because it has a foreign key."))); "because it has a foreign key")));
} }
if (TableReferenced(relationId)) if (TableReferenced(relationId))
{ {
ereport(ERROR, (errmsg("Cannot undistribute table " ereport(ERROR, (errmsg("cannot undistribute table "
"because a foreign key references to it."))); "because a foreign key references to it")));
} }
char relationKind = get_rel_relkind(relationId); char relationKind = get_rel_relkind(relationId);
if (relationKind == RELKIND_FOREIGN_TABLE) if (relationKind == RELKIND_FOREIGN_TABLE)
{ {
ereport(ERROR, (errmsg("Cannot undistribute table " ereport(ERROR, (errmsg("cannot undistribute table "
"because it is a foreign table."))); "because it is a foreign table")));
} }
if (PartitionTable(relationId)) if (PartitionTable(relationId))
{ {
Oid parentRelationId = PartitionParentOid(relationId); Oid parentRelationId = PartitionParentOid(relationId);
char *parentRelationName = get_rel_name(parentRelationId); char *parentRelationName = get_rel_name(parentRelationId);
ereport(ERROR, (errmsg("Cannot undistribute table " ereport(ERROR, (errmsg("cannot undistribute table "
"because it is a partition."), "because it is a partition"),
errhint("Undistribute the partitioned table \"%s\" instead.", errhint("undistribute the partitioned table \"%s\" instead",
parentRelationName))); parentRelationName)));
} }
@ -1620,7 +1619,7 @@ UndistributeTable(Oid relationId)
if (PartitionedTable(relationId)) if (PartitionedTable(relationId))
{ {
ereport(NOTICE, (errmsg("Undistributing the partitions of %s", ereport(NOTICE, (errmsg("undistributing the partitions of %s",
quote_qualified_identifier(schemaName, relationName)))); quote_qualified_identifier(schemaName, relationName))));
List *partitionList = PartitionList(relationId); List *partitionList = PartitionList(relationId);
Oid partitionRelationId = InvalidOid; Oid partitionRelationId = InvalidOid;
@ -1651,7 +1650,7 @@ UndistributeTable(Oid relationId)
char *tableCreationCommand = NULL; char *tableCreationCommand = NULL;
ereport(NOTICE, (errmsg("Creating a new local table for %s", ereport(NOTICE, (errmsg("creating a new local table for %s",
quote_qualified_identifier(schemaName, relationName)))); quote_qualified_identifier(schemaName, relationName))));
foreach_ptr(tableCreationCommand, preLoadCommands) foreach_ptr(tableCreationCommand, preLoadCommands)

View File

@ -333,7 +333,7 @@ ERROR: Table 'citus_local_table_1' is a citus local table. Replicating shard of
-- undistribute_table is supported -- undistribute_table is supported
BEGIN; BEGIN;
SELECT undistribute_table('citus_local_table_1'); SELECT undistribute_table('citus_local_table_1');
NOTICE: Creating a new local table for citus_local_tables_test_schema.citus_local_table_1 NOTICE: creating a new local table for citus_local_tables_test_schema.citus_local_table_1
NOTICE: Moving the data of citus_local_tables_test_schema.citus_local_table_1 NOTICE: Moving the data of citus_local_tables_test_schema.citus_local_table_1
NOTICE: executing the command locally: SELECT a FROM citus_local_tables_test_schema.citus_local_table_1_1504027 citus_local_table_1 NOTICE: executing the command locally: SELECT a FROM citus_local_tables_test_schema.citus_local_table_1_1504027 citus_local_table_1
NOTICE: Dropping the old citus_local_tables_test_schema.citus_local_table_1 NOTICE: Dropping the old citus_local_tables_test_schema.citus_local_table_1
@ -559,7 +559,7 @@ FROM pg_dist_partition WHERE logicalrelid = 'citus_local_table_4'::regclass;
(1 row) (1 row)
SELECT column_name_to_column('citus_local_table_4', 'a'); SELECT column_name_to_column('citus_local_table_4', 'a');
column_name_to_column column_name_to_column
--------------------------------------------------------------------- ---------------------------------------------------------------------
{VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1}
(1 row) (1 row)

View File

@ -17,7 +17,7 @@ step s1-commit:
COMMIT; COMMIT;
step s2-undistribute: <... completed> step s2-undistribute: <... completed>
error in steps s1-commit s2-undistribute: ERROR: Cannot undistribute table error in steps s1-commit s2-undistribute: ERROR: cannot undistribute table
starting permutation: s1-begin s1-undistribute s2-select s1-commit starting permutation: s1-begin s1-undistribute s2-select s1-commit
step s1-begin: step s1-begin:

View File

@ -154,7 +154,7 @@ SELECT * FROM with_ties_table_2 ORDER BY a, b;
TRUNCATE with_ties_table_2; TRUNCATE with_ties_table_2;
-- test INSERT SELECTs into distributed table with a different distribution column -- test INSERT SELECTs into distributed table with a different distribution column
SELECT undistribute_table('with_ties_table_2'); SELECT undistribute_table('with_ties_table_2');
NOTICE: Creating a new local table for public.with_ties_table_2 NOTICE: creating a new local table for public.with_ties_table_2
NOTICE: Moving the data of public.with_ties_table_2 NOTICE: Moving the data of public.with_ties_table_2
NOTICE: Dropping the old public.with_ties_table_2 NOTICE: Dropping the old public.with_ties_table_2
NOTICE: Renaming the new table to public.with_ties_table_2 NOTICE: Renaming the new table to public.with_ties_table_2

View File

@ -775,7 +775,7 @@ RESET citus.task_executor_type;
-- make sure undistribute table works fine -- make sure undistribute table works fine
ALTER TABLE test DROP CONSTRAINT foreign_key; ALTER TABLE test DROP CONSTRAINT foreign_key;
SELECT undistribute_table('test_2'); SELECT undistribute_table('test_2');
NOTICE: Creating a new local table for single_node.test_2 NOTICE: creating a new local table for single_node.test_2
NOTICE: Moving the data of single_node.test_2 NOTICE: Moving the data of single_node.test_2
NOTICE: Dropping the old single_node.test_2 NOTICE: Dropping the old single_node.test_2
NOTICE: Renaming the new table to single_node.test_2 NOTICE: Renaming the new table to single_node.test_2

View File

@ -34,13 +34,13 @@ SELECT * FROM dist_table ORDER BY 1, 2, 3;
-- we cannot immediately convert in the same statement, because -- we cannot immediately convert in the same statement, because
-- the name->OID conversion happens at parse time. -- the name->OID conversion happens at parse time.
SELECT undistribute_table('dist_table'), create_distributed_table('dist_table', 'a'); SELECT undistribute_table('dist_table'), create_distributed_table('dist_table', 'a');
NOTICE: Creating a new local table for undistribute_table.dist_table NOTICE: creating a new local table for undistribute_table.dist_table
NOTICE: Moving the data of undistribute_table.dist_table NOTICE: Moving the data of undistribute_table.dist_table
NOTICE: Dropping the old undistribute_table.dist_table NOTICE: Dropping the old undistribute_table.dist_table
NOTICE: Renaming the new table to undistribute_table.dist_table NOTICE: Renaming the new table to undistribute_table.dist_table
ERROR: relation with OID XXXX does not exist ERROR: relation with OID XXXX does not exist
SELECT undistribute_table('dist_table'); SELECT undistribute_table('dist_table');
NOTICE: Creating a new local table for undistribute_table.dist_table NOTICE: creating a new local table for undistribute_table.dist_table
NOTICE: Moving the data of undistribute_table.dist_table NOTICE: Moving the data of undistribute_table.dist_table
NOTICE: Dropping the old undistribute_table.dist_table NOTICE: Dropping the old undistribute_table.dist_table
NOTICE: Renaming the new table to undistribute_table.dist_table NOTICE: Renaming the new table to undistribute_table.dist_table
@ -87,7 +87,7 @@ SELECT * FROM pg_indexes WHERE tablename = 'dist_table';
(1 row) (1 row)
SELECT undistribute_table('dist_table'); SELECT undistribute_table('dist_table');
NOTICE: Creating a new local table for undistribute_table.dist_table NOTICE: creating a new local table for undistribute_table.dist_table
NOTICE: Moving the data of undistribute_table.dist_table NOTICE: Moving the data of undistribute_table.dist_table
NOTICE: Dropping the old undistribute_table.dist_table NOTICE: Dropping the old undistribute_table.dist_table
NOTICE: Renaming the new table to undistribute_table.dist_table NOTICE: Renaming the new table to undistribute_table.dist_table
@ -122,9 +122,9 @@ SELECT create_distributed_table('referencing_table', 'id');
INSERT INTO referencing_table VALUES (4, 6, 'cba'), (1, 1, 'dcba'), (2, 3, 'aaa'); INSERT INTO referencing_table VALUES (4, 6, 'cba'), (1, 1, 'dcba'), (2, 3, 'aaa');
SELECT undistribute_table('referenced_table'); SELECT undistribute_table('referenced_table');
ERROR: Cannot undistribute table because a foreign key references to it. ERROR: cannot undistribute table because a foreign key references to it
SELECT undistribute_table('referencing_table'); SELECT undistribute_table('referencing_table');
ERROR: Cannot undistribute table because it has a foreign key. ERROR: cannot undistribute table because it has a foreign key
DROP TABLE referenced_table, referencing_table; DROP TABLE referenced_table, referencing_table;
-- test distributed foreign tables -- test distributed foreign tables
-- we expect errors -- we expect errors
@ -140,7 +140,7 @@ NOTICE: foreign-data wrapper "fake_fdw" does not have an extension defined
(1 row) (1 row)
SELECT undistribute_table('foreign_table'); SELECT undistribute_table('foreign_table');
ERROR: Cannot undistribute table because it is a foreign table. ERROR: cannot undistribute table because it is a foreign table
DROP FOREIGN TABLE foreign_table; DROP FOREIGN TABLE foreign_table;
-- test partitioned tables -- test partitioned tables
CREATE TABLE partitioned_table (id INT, a INT) PARTITION BY RANGE (id); CREATE TABLE partitioned_table (id INT, a INT) PARTITION BY RANGE (id);
@ -196,20 +196,20 @@ SELECT * FROM partitioned_table_6_10 ORDER BY 1, 2;
-- undistributing partitions are not supported -- undistributing partitions are not supported
SELECT undistribute_table('partitioned_table_1_5'); SELECT undistribute_table('partitioned_table_1_5');
ERROR: Cannot undistribute table because it is a partition. ERROR: cannot undistribute table because it is a partition
HINT: Undistribute the partitioned table "partitioned_table" instead. HINT: undistribute the partitioned table "partitioned_table" instead
-- we can undistribute partitioned parent tables -- we can undistribute partitioned parent tables
SELECT undistribute_table('partitioned_table'); SELECT undistribute_table('partitioned_table');
NOTICE: Undistributing the partitions of undistribute_table.partitioned_table NOTICE: undistributing the partitions of undistribute_table.partitioned_table
NOTICE: Creating a new local table for undistribute_table.partitioned_table_1_5 NOTICE: creating a new local table for undistribute_table.partitioned_table_1_5
NOTICE: Moving the data of undistribute_table.partitioned_table_1_5 NOTICE: Moving the data of undistribute_table.partitioned_table_1_5
NOTICE: Dropping the old undistribute_table.partitioned_table_1_5 NOTICE: Dropping the old undistribute_table.partitioned_table_1_5
NOTICE: Renaming the new table to undistribute_table.partitioned_table_1_5 NOTICE: Renaming the new table to undistribute_table.partitioned_table_1_5
NOTICE: Creating a new local table for undistribute_table.partitioned_table_6_10 NOTICE: creating a new local table for undistribute_table.partitioned_table_6_10
NOTICE: Moving the data of undistribute_table.partitioned_table_6_10 NOTICE: Moving the data of undistribute_table.partitioned_table_6_10
NOTICE: Dropping the old undistribute_table.partitioned_table_6_10 NOTICE: Dropping the old undistribute_table.partitioned_table_6_10
NOTICE: Renaming the new table to undistribute_table.partitioned_table_6_10 NOTICE: Renaming the new table to undistribute_table.partitioned_table_6_10
NOTICE: Creating a new local table for undistribute_table.partitioned_table NOTICE: creating a new local table for undistribute_table.partitioned_table
NOTICE: Moving the data of undistribute_table.partitioned_table NOTICE: Moving the data of undistribute_table.partitioned_table
NOTICE: Dropping the old undistribute_table.partitioned_table NOTICE: Dropping the old undistribute_table.partitioned_table
NOTICE: Renaming the new table to undistribute_table.partitioned_table NOTICE: Renaming the new table to undistribute_table.partitioned_table
@ -281,7 +281,7 @@ SELECT * FROM seq_table ORDER BY a;
(3 rows) (3 rows)
SELECT undistribute_table('seq_table'); SELECT undistribute_table('seq_table');
NOTICE: Creating a new local table for undistribute_table.seq_table NOTICE: creating a new local table for undistribute_table.seq_table
NOTICE: Moving the data of undistribute_table.seq_table NOTICE: Moving the data of undistribute_table.seq_table
NOTICE: Dropping the old undistribute_table.seq_table NOTICE: Dropping the old undistribute_table.seq_table
NOTICE: Renaming the new table to undistribute_table.seq_table NOTICE: Renaming the new table to undistribute_table.seq_table
@ -346,7 +346,7 @@ SELECT * FROM another_schema.undis_view3 ORDER BY 1, 2;
(3 rows) (3 rows)
SELECT undistribute_table('view_table'); SELECT undistribute_table('view_table');
NOTICE: Creating a new local table for undistribute_table.view_table NOTICE: creating a new local table for undistribute_table.view_table
NOTICE: Moving the data of undistribute_table.view_table NOTICE: Moving the data of undistribute_table.view_table
NOTICE: Dropping the old undistribute_table.view_table NOTICE: Dropping the old undistribute_table.view_table
NOTICE: drop cascades to 3 other objects NOTICE: drop cascades to 3 other objects