pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix BEFORE ROW trigger handling in cross-partition MERGE update.
3+ messages / 1 participants
[nested] [flat]

* pgsql: Fix BEFORE ROW trigger handling in cross-partition MERGE update.
@ 2023-12-21 12:57  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Dean Rasheed @ 2023-12-21 12:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix BEFORE ROW trigger handling in cross-partition MERGE update.

Fix a bug during MERGE if a cross-partition update is attempted on a
partitioned table with a BEFORE DELETE ROW trigger that returns NULL,
to prevent the update. This would cause an error to be thrown, or an
assert failure in an assert-enabled build.

This was an oversight in 9321c79c86, which failed to properly
distinguish a DELETE prevented by a trigger from one prevented by a
concurrent update. Fix by having ExecDelete() return the TM_Result
status to ExecCrossPartitionUpdate(), so that it can distinguish the
two cases, and make ExecCrossPartitionUpdate() return the TM_Result
status to ExecUpdateAct(), so that it can return the correct status
from a concurrent update.

In addition, ensure that the command tag is correctly updated by
having ExecMergeMatched() pass canSetTag to ExecUpdateAct(), rather
than passing false, so that it updates the command tag if it does a
cross-partition update, making this code path in ExecMergeMatched()
consistent with ExecUpdate().

Per bug #18238 from Alexander Lakhin. Back-patch to v15, where MERGE
was introduced.

Dean Rasheed, reviewed by Richard Guo and Jian He.

Discussion: https://postgr.es/m/18238-2f2bdc7f720180b9%40postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a0ff37173d7d412d53bc299fc611068be3bc7060

Modified Files
--------------
src/backend/executor/nodeModifyTable.c | 20 +++++---
src/test/regress/expected/merge.out    | 91 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/merge.sql         | 64 ++++++++++++++++++++++++
3 files changed, 167 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Fix BEFORE ROW trigger handling in cross-partition MERGE update.
@ 2023-12-21 12:57  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Dean Rasheed @ 2023-12-21 12:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix BEFORE ROW trigger handling in cross-partition MERGE update.

Fix a bug during MERGE if a cross-partition update is attempted on a
partitioned table with a BEFORE DELETE ROW trigger that returns NULL,
to prevent the update. This would cause an error to be thrown, or an
assert failure in an assert-enabled build.

This was an oversight in 9321c79c86, which failed to properly
distinguish a DELETE prevented by a trigger from one prevented by a
concurrent update. Fix by having ExecDelete() return the TM_Result
status to ExecCrossPartitionUpdate(), so that it can distinguish the
two cases, and make ExecCrossPartitionUpdate() return the TM_Result
status to ExecUpdateAct(), so that it can return the correct status
from a concurrent update.

In addition, ensure that the command tag is correctly updated by
having ExecMergeMatched() pass canSetTag to ExecUpdateAct(), rather
than passing false, so that it updates the command tag if it does a
cross-partition update, making this code path in ExecMergeMatched()
consistent with ExecUpdate().

Per bug #18238 from Alexander Lakhin. Back-patch to v15, where MERGE
was introduced.

Dean Rasheed, reviewed by Richard Guo and Jian He.

Discussion: https://postgr.es/m/18238-2f2bdc7f720180b9%40postgresql.org

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7f07384dc2697abb405e47a7447c6edf7e07d5f9

Modified Files
--------------
src/backend/executor/nodeModifyTable.c | 20 +++++---
src/test/regress/expected/merge.out    | 91 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/merge.sql         | 64 ++++++++++++++++++++++++
3 files changed, 167 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Fix BEFORE ROW trigger handling in cross-partition MERGE update.
@ 2023-12-21 12:57  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Dean Rasheed @ 2023-12-21 12:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix BEFORE ROW trigger handling in cross-partition MERGE update.

Fix a bug during MERGE if a cross-partition update is attempted on a
partitioned table with a BEFORE DELETE ROW trigger that returns NULL,
to prevent the update. This would cause an error to be thrown, or an
assert failure in an assert-enabled build.

This was an oversight in 9321c79c86, which failed to properly
distinguish a DELETE prevented by a trigger from one prevented by a
concurrent update. Fix by having ExecDelete() return the TM_Result
status to ExecCrossPartitionUpdate(), so that it can distinguish the
two cases, and make ExecCrossPartitionUpdate() return the TM_Result
status to ExecUpdateAct(), so that it can return the correct status
from a concurrent update.

In addition, ensure that the command tag is correctly updated by
having ExecMergeMatched() pass canSetTag to ExecUpdateAct(), rather
than passing false, so that it updates the command tag if it does a
cross-partition update, making this code path in ExecMergeMatched()
consistent with ExecUpdate().

Per bug #18238 from Alexander Lakhin. Back-patch to v15, where MERGE
was introduced.

Dean Rasheed, reviewed by Richard Guo and Jian He.

Discussion: https://postgr.es/m/18238-2f2bdc7f720180b9%40postgresql.org

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7e8c6d7af6588b8a7249cc3e1eb195cc32d120a2

Modified Files
--------------
src/backend/executor/nodeModifyTable.c | 20 +++++---
src/test/regress/expected/merge.out    | 91 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/merge.sql         | 64 ++++++++++++++++++++++++
3 files changed, 167 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2023-12-21 12:57 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-12-21 12:57 pgsql: Fix BEFORE ROW trigger handling in cross-partition MERGE update. Dean Rasheed <dean.a.rasheed@gmail.com>
2023-12-21 12:57 pgsql: Fix BEFORE ROW trigger handling in cross-partition MERGE update. Dean Rasheed <dean.a.rasheed@gmail.com>
2023-12-21 12:57 pgsql: Fix BEFORE ROW trigger handling in cross-partition MERGE update. Dean Rasheed <dean.a.rasheed@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox