Not invalidate fkey cache if citus not installed (#4521)

pull/4523/head
Onur Tirtir 2021-01-15 18:31:43 +03:00 committed by GitHub
parent 1e377ec699
commit 7dddfa2d0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 0 deletions

View File

@ -3596,6 +3596,15 @@ InvalidateForeignRelationGraphCacheCallback(Datum argument, Oid relationId)
void void
InvalidateForeignKeyGraph(void) InvalidateForeignKeyGraph(void)
{ {
if (!CitusHasBeenLoaded())
{
/*
* We should not try to invalidate foreign key graph
* if citus is not loaded.
*/
return;
}
CitusInvalidateRelcacheByRelid(DistColocationRelationId()); CitusInvalidateRelcacheByRelid(DistColocationRelationId());
/* bump command counter to force invalidation to take effect */ /* bump command counter to force invalidation to take effect */

View File

@ -18,6 +18,36 @@ SET client_min_messages TO 'WARNING';
DROP FUNCTION pg_catalog.master_create_worker_shards; DROP FUNCTION pg_catalog.master_create_worker_shards;
DROP EXTENSION citus CASCADE; DROP EXTENSION citus CASCADE;
RESET client_min_messages; RESET client_min_messages;
BEGIN;
SET client_min_messages TO ERROR;
SET search_path TO public;
CREATE EXTENSION citus;
SET citus.replicate_reference_tables_on_activate TO OFF;
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
?column?
---------------------------------------------------------------------
1
(1 row)
create table l1 (a int unique);
SELECT create_reference_table('l1');
create_reference_table
---------------------------------------------------------------------
(1 row)
create schema other_schema;
create table other_schema.l3 (a int);
select create_reference_table ('other_schema.l3');
create_reference_table
---------------------------------------------------------------------
(1 row)
alter table other_schema.l3 add constraint fkey foreign key (a) references l1(a);
-- show that works fine
drop schema public cascade;
ROLLBACK;
CREATE EXTENSION citus; CREATE EXTENSION citus;
-- this function is dropped in Citus10, added here for tests -- this function is dropped in Citus10, added here for tests
CREATE OR REPLACE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_count integer, CREATE OR REPLACE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_count integer,

View File

@ -19,6 +19,28 @@ DROP FUNCTION pg_catalog.master_create_worker_shards;
DROP EXTENSION citus CASCADE; DROP EXTENSION citus CASCADE;
RESET client_min_messages; RESET client_min_messages;
BEGIN;
SET client_min_messages TO ERROR;
SET search_path TO public;
CREATE EXTENSION citus;
-- not wait for replicating reference tables from other test files
SET citus.replicate_reference_tables_on_activate TO OFF;
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
create table l1 (a int unique);
SELECT create_reference_table('l1');
create schema other_schema;
create table other_schema.l3 (a int);
select create_reference_table ('other_schema.l3');
alter table other_schema.l3 add constraint fkey foreign key (a) references l1(a);
-- show that works fine
drop schema public cascade;
ROLLBACK;
CREATE EXTENSION citus; CREATE EXTENSION citus;
-- this function is dropped in Citus10, added here for tests -- this function is dropped in Citus10, added here for tests
CREATE OR REPLACE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_count integer, CREATE OR REPLACE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_count integer,