> WARNING: relcache reference leak: relation "xxx" not closed.
> 
> Example of the procedure:
> ------publisher------
> create table test (a int primary key);
> create publication pub for table test;
> 
> ------subscriber------
> create table test (a int primary key);
> create subscription sub connection 'dbname=postgres' publication pub;
> create function funcA() returns trigger as $$ begin return null; end; $$ 
> language
> plpgsql; create trigger my_trig after insert or update or delete on test for 
> each
> row execute procedure funcA(); alter table test enable replica trigger 
> my_trig;
> 
> ------publisher------
> insert into test values (6);
> 
> It seems an issue about reference leak. Anyone can fix this?

It seems ExecGetTriggerResultRel will reopen the target table because it cannot 
find an existing one.
Storing the opened table in estate->es_opened_result_relations seems solves the 
problem.

Attaching a patch that fix this.
BTW, it seems better to add a testcase for this ?

Best regards,
houzj

Attachment: fix_table_refer_leak.diff
Description: fix_table_refer_leak.diff

Reply via email to