Close relations opened specifically for AFTER triggers

39dcfda2d fixed an incorrect reuse of ResultRelInfos for AFTER triggers
when the ResultRelInfo needed to have a different ri_RootResultRelInfo.
That caused an issue in logical replication apply workers as
finish_edata() neglects to call ExecCloseResultRelations() and instead
relies on ExecCleanupTupleRouting() to close relations opened during
partitioning's tuple routing.  Since 39dcfda2d, because we may have done
some additional table_opens() calls due to having to create an additional
ResultRelInfo because of requirements to have a different
ri_RootResultRelInfo, we should now be explicitly closing any relations
opened on ResultRelInfos in EState's es_trig_target_relations.

Since finish_edate() seems to want to avoid calling
ExecCloseResultRelations(), add a new external function named
ExecCloseTrigTargetRelations().

Reported-by: Hayato Kuroda (Fujitsu) <[email protected]>
Author: Hayato Kuroda (Fujitsu) <[email protected]>
Author: David Rowley <[email protected]>
Reviewed-by: Zhijie Hou (Fujitsu) <[email protected]>
Discussion: 
https://postgr.es/m/os9pr01mb121491e7e05950d108af9a6d8f5...@os9pr01mb12149.jpnprd01.prod.outlook.com
Backpatch-through: 15

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/059aae612f57b3be5942ea05158c1cf9afa8dd38

Modified Files
--------------
src/backend/executor/execMain.c          | 16 ++++++++++++++++
src/backend/replication/logical/worker.c | 12 ++++++++----
src/include/executor/executor.h          |  1 +
src/test/subscription/t/013_partition.pl |  7 +++++++
4 files changed, 32 insertions(+), 4 deletions(-)

Reply via email to