Use slots in trigger infrastructure, except for the actual invocation

Enterprise / PostgreSQL - Andres Freund [anarazel.de] - 27 February 2019 04:31 EST

In preparation for abstracting table storage, convert trigger.c to track tuples in slots. Which also happens to make code calling triggers simpler.

As the calling interface for triggers themselves is not changed in this patch, HeapTuples still are extracted from the slot at that time. But that's handled solely inside trigger.c, not visible to callers. It's quite likely that we'll want to revise the external trigger interface, but that's a separate large project.

As part of this work the slots used for old/new/return tuples are moved from EState into ResultRelInfo, as different updated tables might need different slots. The slots are now also now created on-demand, which is good both from an efficiency POV, but also makes the modifying code simpler.

Author: Andres Freund, Amit Khandekar and Ashutosh Bapat Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de

ff11e7f4b9 Use slots in trigger infrastructure, except for the actual invocation.
contrib/postgres_fdw/postgres_fdw.c | 16 +-
src/backend/commands/copy.c | 24 +-
src/backend/commands/tablecmds.c | 2 -
src/backend/commands/trigger.c | 673 ++++++++++++++++---------------
src/backend/executor/execMain.c | 6 +-
src/backend/executor/execReplication.c | 25 +-
src/backend/executor/execTuples.c | 4 +
src/backend/executor/execUtils.c | 69 +++-
src/backend/executor/nodeModifyTable.c | 166 +++-----
src/backend/replication/logical/worker.c | 5 -
src/backend/utils/adt/ri_triggers.c | 187 +++++----
src/include/commands/trigger.h | 24 +-
src/include/executor/executor.h | 4 +
src/include/nodes/execnodes.h | 8 +-
14 files changed, 642 insertions(+), 571 deletions(-)

Upstream: git.postgresql.org


  • Share