Advise dropping foreign key in addition to create_reference_table hint (#4590)

pull/4582/head
Onur Tirtir 2021-01-27 17:59:06 +03:00 committed by GitHub
parent a18d4288e9
commit b20615cbbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -48,7 +48,8 @@
#define USE_CREATE_REFERENCE_TABLE_HINT \ #define USE_CREATE_REFERENCE_TABLE_HINT \
"You could use SELECT create_reference_table('%s') " \ "You could use SELECT create_reference_table('%s') " \
"to replicate the referenced table to all nodes" "to replicate the referenced table to all nodes or " \
"consider dropping the foreign key"
typedef bool (*CheckRelationFunc)(Oid); typedef bool (*CheckRelationFunc)(Oid);

View File

@ -861,7 +861,7 @@ CREATE TABLE reference_table(id int, referencing_column int REFERENCES reference
SELECT create_reference_table('reference_table'); SELECT create_reference_table('reference_table');
ERROR: referenced table "referenced_local_table" must be a distributed table or a reference table ERROR: referenced table "referenced_local_table" must be a distributed table or a reference table
DETAIL: To enforce foreign keys, the referencing and referenced rows need to be stored on the same node. DETAIL: To enforce foreign keys, the referencing and referenced rows need to be stored on the same node.
HINT: You could use SELECT create_reference_table('referenced_local_table') to replicate the referenced table to all nodes HINT: You could use SELECT create_reference_table('referenced_local_table') to replicate the referenced table to all nodes or consider dropping the foreign key
-- test foreign key creation on CREATE TABLE on self referencing reference table -- test foreign key creation on CREATE TABLE on self referencing reference table
CREATE TABLE self_referencing_reference_table( CREATE TABLE self_referencing_reference_table(
id int, id int,
@ -922,7 +922,7 @@ SELECT create_reference_table('reference_table');
ALTER TABLE reference_table ADD CONSTRAINT fk FOREIGN KEY(referencing_column) REFERENCES referenced_local_table(id); ALTER TABLE reference_table ADD CONSTRAINT fk FOREIGN KEY(referencing_column) REFERENCES referenced_local_table(id);
ERROR: referenced table "referenced_local_table" must be a distributed table or a reference table ERROR: referenced table "referenced_local_table" must be a distributed table or a reference table
DETAIL: To enforce foreign keys, the referencing and referenced rows need to be stored on the same node. DETAIL: To enforce foreign keys, the referencing and referenced rows need to be stored on the same node.
HINT: You could use SELECT create_reference_table('referenced_local_table') to replicate the referenced table to all nodes HINT: You could use SELECT create_reference_table('referenced_local_table') to replicate the referenced table to all nodes or consider dropping the foreign key
-- test foreign key creation on ALTER TABLE on self referencing reference table -- test foreign key creation on ALTER TABLE on self referencing reference table
DROP TABLE self_referencing_reference_table; DROP TABLE self_referencing_reference_table;
CREATE TABLE self_referencing_reference_table( CREATE TABLE self_referencing_reference_table(