pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly @ 2022-08-05 07:48 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 6+ messages in thread From: Alvaro Herrera @ 2022-08-05 07:48 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category of triggers. So this commit restores the code in EnableDisableTrigger() that 86f575948c77 had added to do the recursion, which would do it only for triggers that may be cloned, that is, row-level triggers. This also changes tablecmds.c such that ATExecCmd() is able to pass the value of ONLY flag down to EnableDisableTrigger() using its new 'recurse' parameter. This also fixes what seems like an oversight of 86f575948c77 that the recursion to partition triggers would only occur if EnableDisableTrigger() had actually changed the trigger. It is more apt to recurse to inspect partition triggers even if the parent's trigger didn't need to be changed: only then can we be certain that all descendants share the same state afterwards. Backpatch all the way back to 11, like bbb927b4db9b. Care is taken not to break ABI compatibility (and that no catversion bump is needed.) Co-authored-by: Amit Langote <amitlangote09@gmail.com> Reviewed-by: Dmitry Koval <d.koval@postgrespro.ru> Discussion: https://postgr.es/m/CA+HiwqG-cZT3XzGAnEgZQLoQbyfJApVwOTQaCaas1mhpf+4V5A@mail.gmail.com Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e78fd9084587cd485fdec3eb3eaeef567e1707d5 Modified Files -------------- src/backend/commands/tablecmds.c | 64 +++++++++++++++++++++++----------- src/backend/commands/trigger.c | 47 +++++++++++++++++++++++-- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/include/commands/trigger.h | 3 ++ src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/triggers.out | 40 +++++++++++++++------ src/test/regress/sql/triggers.sql | 11 +++++- 8 files changed, 134 insertions(+), 34 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly @ 2022-08-05 07:48 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 6+ messages in thread From: Alvaro Herrera @ 2022-08-05 07:48 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category of triggers. So this commit restores the code in EnableDisableTrigger() that 86f575948c77 had added to do the recursion, which would do it only for triggers that may be cloned, that is, row-level triggers. This also changes tablecmds.c such that ATExecCmd() is able to pass the value of ONLY flag down to EnableDisableTrigger() using its new 'recurse' parameter. This also fixes what seems like an oversight of 86f575948c77 that the recursion to partition triggers would only occur if EnableDisableTrigger() had actually changed the trigger. It is more apt to recurse to inspect partition triggers even if the parent's trigger didn't need to be changed: only then can we be certain that all descendants share the same state afterwards. Backpatch all the way back to 11, like bbb927b4db9b. Care is taken not to break ABI compatibility (and that no catversion bump is needed.) Co-authored-by: Amit Langote <amitlangote09@gmail.com> Reviewed-by: Dmitry Koval <d.koval@postgrespro.ru> Discussion: https://postgr.es/m/CA+HiwqG-cZT3XzGAnEgZQLoQbyfJApVwOTQaCaas1mhpf+4V5A@mail.gmail.com Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/6e7b37264e96d3216240b207f763913164cf6487 Modified Files -------------- src/backend/commands/tablecmds.c | 64 +++++++++++++++++++++++----------- src/backend/commands/trigger.c | 47 +++++++++++++++++++++++-- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/include/commands/trigger.h | 3 ++ src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/triggers.out | 40 +++++++++++++++------ src/test/regress/sql/triggers.sql | 11 +++++- 8 files changed, 134 insertions(+), 34 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly @ 2022-08-05 07:48 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 6+ messages in thread From: Alvaro Herrera @ 2022-08-05 07:48 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category of triggers. So this commit restores the code in EnableDisableTrigger() that 86f575948c77 had added to do the recursion, which would do it only for triggers that may be cloned, that is, row-level triggers. This also changes tablecmds.c such that ATExecCmd() is able to pass the value of ONLY flag down to EnableDisableTrigger() using its new 'recurse' parameter. This also fixes what seems like an oversight of 86f575948c77 that the recursion to partition triggers would only occur if EnableDisableTrigger() had actually changed the trigger. It is more apt to recurse to inspect partition triggers even if the parent's trigger didn't need to be changed: only then can we be certain that all descendants share the same state afterwards. Backpatch all the way back to 11, like bbb927b4db9b. Care is taken not to break ABI compatibility (and that no catversion bump is needed.) Co-authored-by: Amit Langote <amitlangote09@gmail.com> Reviewed-by: Dmitry Koval <d.koval@postgrespro.ru> Discussion: https://postgr.es/m/CA+HiwqG-cZT3XzGAnEgZQLoQbyfJApVwOTQaCaas1mhpf+4V5A@mail.gmail.com Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ab855663012c131bba8d16e6188eed0b627a27bc Modified Files -------------- src/backend/commands/tablecmds.c | 67 +++++++++++++++++++++++----------- src/backend/commands/trigger.c | 47 +++++++++++++++++++++++- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/include/commands/trigger.h | 3 ++ src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/triggers.out | 40 ++++++++++++++------ src/test/regress/sql/triggers.sql | 11 +++++- 8 files changed, 136 insertions(+), 35 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly @ 2022-08-05 07:48 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 6+ messages in thread From: Alvaro Herrera @ 2022-08-05 07:48 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category of triggers. So this commit restores the code in EnableDisableTrigger() that 86f575948c77 had added to do the recursion, which would do it only for triggers that may be cloned, that is, row-level triggers. This also changes tablecmds.c such that ATExecCmd() is able to pass the value of ONLY flag down to EnableDisableTrigger() using its new 'recurse' parameter. This also fixes what seems like an oversight of 86f575948c77 that the recursion to partition triggers would only occur if EnableDisableTrigger() had actually changed the trigger. It is more apt to recurse to inspect partition triggers even if the parent's trigger didn't need to be changed: only then can we be certain that all descendants share the same state afterwards. Backpatch all the way back to 11, like bbb927b4db9b. Care is taken not to break ABI compatibility (and that no catversion bump is needed.) Co-authored-by: Amit Langote <amitlangote09@gmail.com> Reviewed-by: Dmitry Koval <d.koval@postgrespro.ru> Discussion: https://postgr.es/m/CA+HiwqG-cZT3XzGAnEgZQLoQbyfJApVwOTQaCaas1mhpf+4V5A@mail.gmail.com Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/731d514ae58ff4b5c81729881d350c6f89c4e488 Modified Files -------------- src/backend/commands/tablecmds.c | 64 +++++++++++++++++++++++----------- src/backend/commands/trigger.c | 47 +++++++++++++++++++++++-- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/include/commands/trigger.h | 3 ++ src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/triggers.out | 40 +++++++++++++++------ src/test/regress/sql/triggers.sql | 11 +++++- 8 files changed, 134 insertions(+), 34 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly @ 2022-08-05 07:48 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 6+ messages in thread From: Alvaro Herrera @ 2022-08-05 07:48 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category of triggers. So this commit restores the code in EnableDisableTrigger() that 86f575948c77 had added to do the recursion, which would do it only for triggers that may be cloned, that is, row-level triggers. This also changes tablecmds.c such that ATExecCmd() is able to pass the value of ONLY flag down to EnableDisableTrigger() using its new 'recurse' parameter. This also fixes what seems like an oversight of 86f575948c77 that the recursion to partition triggers would only occur if EnableDisableTrigger() had actually changed the trigger. It is more apt to recurse to inspect partition triggers even if the parent's trigger didn't need to be changed: only then can we be certain that all descendants share the same state afterwards. Backpatch all the way back to 11, like bbb927b4db9b. Care is taken not to break ABI compatibility (and that no catversion bump is needed.) Co-authored-by: Amit Langote <amitlangote09@gmail.com> Reviewed-by: Dmitry Koval <d.koval@postgrespro.ru> Discussion: https://postgr.es/m/CA+HiwqG-cZT3XzGAnEgZQLoQbyfJApVwOTQaCaas1mhpf+4V5A@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/ec0925c22a3da7199650c9903a03a0017705ed5c Modified Files -------------- src/backend/commands/tablecmds.c | 64 +++++++++++++++++++++++----------- src/backend/commands/trigger.c | 32 ++++++++++++++++- src/include/commands/trigger.h | 3 +- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/triggers.out | 40 +++++++++++++++------ src/test/regress/sql/triggers.sql | 11 +++++- 6 files changed, 117 insertions(+), 34 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly @ 2022-08-05 07:48 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 6+ messages in thread From: Alvaro Herrera @ 2022-08-05 07:48 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category of triggers. So this commit restores the code in EnableDisableTrigger() that 86f575948c77 had added to do the recursion, which would do it only for triggers that may be cloned, that is, row-level triggers. This also changes tablecmds.c such that ATExecCmd() is able to pass the value of ONLY flag down to EnableDisableTrigger() using its new 'recurse' parameter. This also fixes what seems like an oversight of 86f575948c77 that the recursion to partition triggers would only occur if EnableDisableTrigger() had actually changed the trigger. It is more apt to recurse to inspect partition triggers even if the parent's trigger didn't need to be changed: only then can we be certain that all descendants share the same state afterwards. Backpatch all the way back to 11, like bbb927b4db9b. Care is taken not to break ABI compatibility (and that no catversion bump is needed.) Co-authored-by: Amit Langote <amitlangote09@gmail.com> Reviewed-by: Dmitry Koval <d.koval@postgrespro.ru> Discussion: https://postgr.es/m/CA+HiwqG-cZT3XzGAnEgZQLoQbyfJApVwOTQaCaas1mhpf+4V5A@mail.gmail.com Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ce8e066521d13b344411e5fe9f1aa32c7dc98cf5 Modified Files -------------- src/backend/commands/tablecmds.c | 64 +++++++++++++++++++++++----------- src/backend/commands/trigger.c | 47 +++++++++++++++++++++++-- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/include/commands/trigger.h | 5 ++- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/triggers.out | 40 +++++++++++++++------ src/test/regress/sql/triggers.sql | 11 +++++- 8 files changed, 135 insertions(+), 35 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2022-08-05 07:48 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-08-05 07:48 pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Alvaro Herrera <alvherre@alvh.no-ip.org> 2022-08-05 07:48 pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Alvaro Herrera <alvherre@alvh.no-ip.org> 2022-08-05 07:48 pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Alvaro Herrera <alvherre@alvh.no-ip.org> 2022-08-05 07:48 pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Alvaro Herrera <alvherre@alvh.no-ip.org> 2022-08-05 07:48 pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Alvaro Herrera <alvherre@alvh.no-ip.org> 2022-08-05 07:48 pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Alvaro Herrera <alvherre@alvh.no-ip.org>
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