mirror of https://github.com/citusdata/citus.git
Not try locking relations referencing to views (#6430)
Since there can't be such a foreign key already. This mainly fixes the error that Citus throws when trying to truncate a distributed view. Fixes #5990.pull/6445/head
parent
93e162def6
commit
5aec88d084
|
@ -1357,7 +1357,11 @@ AcquireDistributedLockOnRelations(List *relationList, LOCKMODE lockMode, uint32
|
|||
(void *) lockRelationRecord);
|
||||
}
|
||||
|
||||
if ((configs & DIST_LOCK_REFERENCING_TABLES) > 0)
|
||||
char relkind = get_rel_relkind(relationId);
|
||||
bool relationCanBeReferenced = (relkind == RELKIND_RELATION ||
|
||||
relkind == RELKIND_PARTITIONED_TABLE);
|
||||
if (relationCanBeReferenced &&
|
||||
(configs & DIST_LOCK_REFERENCING_TABLES) > 0)
|
||||
{
|
||||
CitusTableCacheEntry *cacheEntry = GetCitusTableCacheEntry(relationId);
|
||||
Assert(cacheEntry != NULL);
|
||||
|
|
|
@ -522,6 +522,18 @@ SELECT truncate_local_data_after_distributing_table('t1');
|
|||
(1 row)
|
||||
|
||||
ALTER TABLE t1 VALIDATE CONSTRAINT t1_a_check;
|
||||
CREATE TABLE tbl(a INT);
|
||||
SELECT create_distributed_table('tbl', 'a');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE VIEW vw AS SELECT * FROM tbl;
|
||||
-- throws an error because vw is not a table
|
||||
TRUNCATE TABLE tbl, vw CASCADE;
|
||||
ERROR: "vw" is not a table
|
||||
SET client_min_messages TO ERROR;
|
||||
DROP VIEW table_sizes;
|
||||
DROP TABLE t1;
|
||||
DROP SCHEMA multi_truncate CASCADE;
|
||||
|
|
|
@ -304,6 +304,15 @@ ALTER TABLE t1 VALIDATE CONSTRAINT t1_a_check;
|
|||
SELECT truncate_local_data_after_distributing_table('t1');
|
||||
ALTER TABLE t1 VALIDATE CONSTRAINT t1_a_check;
|
||||
|
||||
CREATE TABLE tbl(a INT);
|
||||
SELECT create_distributed_table('tbl', 'a');
|
||||
CREATE VIEW vw AS SELECT * FROM tbl;
|
||||
|
||||
-- throws an error because vw is not a table
|
||||
TRUNCATE TABLE tbl, vw CASCADE;
|
||||
|
||||
SET client_min_messages TO ERROR;
|
||||
|
||||
DROP VIEW table_sizes;
|
||||
DROP TABLE t1;
|
||||
DROP SCHEMA multi_truncate CASCADE;
|
||||
|
|
Loading…
Reference in New Issue