pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Fix event triggers for partitioned tables
10+ messages / 4 participants
[nested] [flat]
* pgsql: Fix event triggers for partitioned tables
@ 2018-10-06 22:18 Alvaro Herrera <alvherre@alvh.no-ip.org>
0 siblings, 0 replies; 10+ messages in thread
From: Alvaro Herrera @ 2018-10-06 22:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix event triggers for partitioned tables
Index DDL cascading on partitioned tables introduced a way for ALTER
TABLE to be called reentrantly. This caused an an important deficiency
in event trigger support to be exposed: on exiting the reentrant call,
the alter table state object was clobbered, causing a crash when the
outer alter table tries to finalize its processing. Fix the crash by
creating a stack of event trigger state objects. There are still ways
to cause things to misbehave (and probably other crashers) with more
elaborate tricks, but at least it now doesn't crash in the obvious
scenario.
Backpatch to 9.5, where DDL deparsing of event triggers was introduced.
Reported-by: Marco Slot
Authors: Michaël Paquier, Álvaro Herrera
Discussion: https://postgr.es/m/CANNhMLCpi+HQ7M36uPfGbJZEQLyTy7XvX=5EFkpR-b1bo0uJew@mail.gmail.com
Branch
------
REL9_5_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/a2a5159ed678f0e4a0efa7e8aabbd4c03eb36843
Modified Files
--------------
src/backend/catalog/index.c | 8 +++++++-
src/backend/commands/event_trigger.c | 13 +++++++------
src/backend/commands/indexcmds.c | 3 ++-
src/backend/commands/tablecmds.c | 2 +-
src/backend/commands/view.c | 4 ++++
src/include/catalog/index.h | 3 ++-
src/include/tcop/deparse_utility.h | 3 +++
7 files changed, 26 insertions(+), 10 deletions(-)
^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix event triggers for partitioned tables
@ 2018-10-06 22:18 Alvaro Herrera <alvherre@alvh.no-ip.org>
0 siblings, 0 replies; 10+ messages in thread
From: Alvaro Herrera @ 2018-10-06 22:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix event triggers for partitioned tables
Index DDL cascading on partitioned tables introduced a way for ALTER
TABLE to be called reentrantly. This caused an an important deficiency
in event trigger support to be exposed: on exiting the reentrant call,
the alter table state object was clobbered, causing a crash when the
outer alter table tries to finalize its processing. Fix the crash by
creating a stack of event trigger state objects. There are still ways
to cause things to misbehave (and probably other crashers) with more
elaborate tricks, but at least it now doesn't crash in the obvious
scenario.
Backpatch to 9.5, where DDL deparsing of event triggers was introduced.
Reported-by: Marco Slot
Authors: Michaël Paquier, Álvaro Herrera
Discussion: https://postgr.es/m/CANNhMLCpi+HQ7M36uPfGbJZEQLyTy7XvX=5EFkpR-b1bo0uJew@mail.gmail.com
Branch
------
REL_11_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/1a852f7c1e27eef563cf0577c2604baec1be5512
Modified Files
--------------
src/backend/catalog/index.c | 8 +++++++-
src/backend/commands/event_trigger.c | 13 +++++++------
src/backend/commands/indexcmds.c | 3 ++-
src/backend/commands/tablecmds.c | 2 +-
src/backend/commands/view.c | 4 ++++
src/include/catalog/index.h | 3 ++-
src/include/tcop/deparse_utility.h | 3 +++
.../test_ddl_deparse/expected/alter_table.out | 12 ++++++++++++
.../modules/test_ddl_deparse/sql/alter_table.sql | 8 ++++++++
src/test/regress/expected/event_trigger.out | 20 +++++++++++++++++++-
src/test/regress/sql/event_trigger.sql | 13 +++++++++++++
11 files changed, 78 insertions(+), 11 deletions(-)
^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix event triggers for partitioned tables
@ 2018-10-06 22:18 Alvaro Herrera <alvherre@alvh.no-ip.org>
0 siblings, 0 replies; 10+ messages in thread
From: Alvaro Herrera @ 2018-10-06 22:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix event triggers for partitioned tables
Index DDL cascading on partitioned tables introduced a way for ALTER
TABLE to be called reentrantly. This caused an an important deficiency
in event trigger support to be exposed: on exiting the reentrant call,
the alter table state object was clobbered, causing a crash when the
outer alter table tries to finalize its processing. Fix the crash by
creating a stack of event trigger state objects. There are still ways
to cause things to misbehave (and probably other crashers) with more
elaborate tricks, but at least it now doesn't crash in the obvious
scenario.
Backpatch to 9.5, where DDL deparsing of event triggers was introduced.
Reported-by: Marco Slot
Authors: Michaël Paquier, Álvaro Herrera
Discussion: https://postgr.es/m/CANNhMLCpi+HQ7M36uPfGbJZEQLyTy7XvX=5EFkpR-b1bo0uJew@mail.gmail.com
Branch
------
REL9_6_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/b2f266f58d4c24b372b3413e75acce9ff32e126a
Modified Files
--------------
src/backend/catalog/index.c | 8 +++++++-
src/backend/commands/event_trigger.c | 13 +++++++------
src/backend/commands/indexcmds.c | 3 ++-
src/backend/commands/tablecmds.c | 2 +-
src/backend/commands/view.c | 4 ++++
src/include/catalog/index.h | 3 ++-
src/include/tcop/deparse_utility.h | 3 +++
7 files changed, 26 insertions(+), 10 deletions(-)
^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix event triggers for partitioned tables
@ 2018-10-06 22:18 Alvaro Herrera <alvherre@alvh.no-ip.org>
0 siblings, 0 replies; 10+ messages in thread
From: Alvaro Herrera @ 2018-10-06 22:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix event triggers for partitioned tables
Index DDL cascading on partitioned tables introduced a way for ALTER
TABLE to be called reentrantly. This caused an an important deficiency
in event trigger support to be exposed: on exiting the reentrant call,
the alter table state object was clobbered, causing a crash when the
outer alter table tries to finalize its processing. Fix the crash by
creating a stack of event trigger state objects. There are still ways
to cause things to misbehave (and probably other crashers) with more
elaborate tricks, but at least it now doesn't crash in the obvious
scenario.
Backpatch to 9.5, where DDL deparsing of event triggers was introduced.
Reported-by: Marco Slot
Authors: Michaël Paquier, Álvaro Herrera
Discussion: https://postgr.es/m/CANNhMLCpi+HQ7M36uPfGbJZEQLyTy7XvX=5EFkpR-b1bo0uJew@mail.gmail.com
Branch
------
REL_10_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/101b21ead356023c0b86d28dac3d6c08828c77b5
Modified Files
--------------
src/backend/catalog/index.c | 8 +++++++-
src/backend/commands/event_trigger.c | 13 +++++++------
src/backend/commands/indexcmds.c | 3 ++-
src/backend/commands/tablecmds.c | 2 +-
src/backend/commands/view.c | 4 ++++
src/include/catalog/index.h | 3 ++-
src/include/tcop/deparse_utility.h | 3 +++
src/test/regress/expected/event_trigger.out | 20 +++++++++++++++++++-
src/test/regress/sql/event_trigger.sql | 13 +++++++++++++
9 files changed, 58 insertions(+), 11 deletions(-)
^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix event triggers for partitioned tables
@ 2018-10-06 22:18 Alvaro Herrera <alvherre@alvh.no-ip.org>
0 siblings, 2 replies; 10+ messages in thread
From: Alvaro Herrera @ 2018-10-06 22:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix event triggers for partitioned tables
Index DDL cascading on partitioned tables introduced a way for ALTER
TABLE to be called reentrantly. This caused an an important deficiency
in event trigger support to be exposed: on exiting the reentrant call,
the alter table state object was clobbered, causing a crash when the
outer alter table tries to finalize its processing. Fix the crash by
creating a stack of event trigger state objects. There are still ways
to cause things to misbehave (and probably other crashers) with more
elaborate tricks, but at least it now doesn't crash in the obvious
scenario.
Backpatch to 9.5, where DDL deparsing of event triggers was introduced.
Reported-by: Marco Slot
Authors: Michaël Paquier, Álvaro Herrera
Discussion: https://postgr.es/m/CANNhMLCpi+HQ7M36uPfGbJZEQLyTy7XvX=5EFkpR-b1bo0uJew@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/ad08006ba03797fed431af87de6e66c6c0985b7a
Modified Files
--------------
src/backend/catalog/index.c | 8 +++++++-
src/backend/commands/event_trigger.c | 13 +++++++------
src/backend/commands/indexcmds.c | 3 ++-
src/backend/commands/tablecmds.c | 2 +-
src/backend/commands/view.c | 4 ++++
src/include/catalog/index.h | 3 ++-
src/include/tcop/deparse_utility.h | 3 +++
.../test_ddl_deparse/expected/alter_table.out | 12 ++++++++++++
.../modules/test_ddl_deparse/sql/alter_table.sql | 8 ++++++++
src/test/regress/expected/event_trigger.out | 20 +++++++++++++++++++-
src/test/regress/sql/event_trigger.sql | 13 +++++++++++++
11 files changed, 78 insertions(+), 11 deletions(-)
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Fix event triggers for partitioned tables
@ 2018-10-08 09:12 Michael Paquier <michael@paquier.xyz>
parent: Alvaro Herrera <alvherre@alvh.no-ip.org>
1 sibling, 1 reply; 10+ messages in thread
From: Michael Paquier @ 2018-10-08 09:12 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: Postgres hackers <pgsql-hackers@postgresql.org>
Hi Alvaro,
On Sat, Oct 06, 2018 at 10:18:46PM +0000, Alvaro Herrera wrote:
> Fix event triggers for partitioned tables
>
> Index DDL cascading on partitioned tables introduced a way for ALTER
> TABLE to be called reentrantly. This caused an an important deficiency
> in event trigger support to be exposed: on exiting the reentrant call,
> the alter table state object was clobbered, causing a crash when the
> outer alter table tries to finalize its processing. Fix the crash by
> creating a stack of event trigger state objects. There are still ways
> to cause things to misbehave (and probably other crashers) with more
> elaborate tricks, but at least it now doesn't crash in the obvious
> scenario.
This commit is producing a warning with my compiler:
event_trigger.c:1764:9: note: in expansion of macro ‘OidIsValid’
Assert(OidIsValid(currentEventTriggerState->currentCommand));
The fix is obvious because currentCommand is a pointer and not an Oid.
Please see attached. Should I fix it myself?
--
Michael
Attachments:
event-trigger-warning.patch (text/x-diff, 634B) download
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index 2c1dc47541..9a702e4097 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -1761,7 +1761,7 @@ EventTriggerCollectAlterTableSubcmd(Node *subcmd, ObjectAddress address)
return;
Assert(IsA(subcmd, AlterTableCmd));
- Assert(OidIsValid(currentEventTriggerState->currentCommand));
+ Assert(currentEventTriggerState->currentCommand != NULL);
Assert(OidIsValid(currentEventTriggerState->currentCommand->d.alterTable.objectId));
oldcxt = MemoryContextSwitchTo(currentEventTriggerState->cxt);
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Fix event triggers for partitioned tables
@ 2018-10-08 09:32 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
parent: Alvaro Herrera <alvherre@alvh.no-ip.org>
1 sibling, 0 replies; 10+ messages in thread
From: Peter Eisentraut @ 2018-10-08 09:32 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@alvh.no-ip.org>; pgsql-committers@lists.postgresql.org
On 07/10/2018 00:18, Alvaro Herrera wrote:
> Fix event triggers for partitioned tables
It looks like this is causing compiler warnings:
event_trigger.c: In function 'EventTriggerCollectAlterTableSubcmd':
../../../src/include/c.h:605:51: error: comparison between pointer and
zero character constant [-Werror=pointer-compare]
#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Fix event triggers for partitioned tables
@ 2018-10-08 12:54 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 10+ messages in thread
From: Alvaro Herrera @ 2018-10-08 12:54 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Postgres hackers <pgsql-hackers@postgresql.org>
On 2018-Oct-08, Michael Paquier wrote:
> Hi Alvaro,
>
> On Sat, Oct 06, 2018 at 10:18:46PM +0000, Alvaro Herrera wrote:
> > Fix event triggers for partitioned tables
> >
> > Index DDL cascading on partitioned tables introduced a way for ALTER
> > TABLE to be called reentrantly. This caused an an important deficiency
> > in event trigger support to be exposed: on exiting the reentrant call,
> > the alter table state object was clobbered, causing a crash when the
> > outer alter table tries to finalize its processing. Fix the crash by
> > creating a stack of event trigger state objects. There are still ways
> > to cause things to misbehave (and probably other crashers) with more
> > elaborate tricks, but at least it now doesn't crash in the obvious
> > scenario.
>
> This commit is producing a warning with my compiler:
> event_trigger.c:1764:9: note: in expansion of macro ‘OidIsValid’
> Assert(OidIsValid(currentEventTriggerState->currentCommand));
>
> The fix is obvious because currentCommand is a pointer and not an Oid.
> Please see attached. Should I fix it myself?
If you have a commit ready, please do, thanks.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Fix event triggers for partitioned tables
@ 2018-10-08 13:39 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 10+ messages in thread
From: Alvaro Herrera @ 2018-10-08 13:39 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Postgres hackers <pgsql-hackers@postgresql.org>
On 2018-Oct-08, Alvaro Herrera wrote:
> On 2018-Oct-08, Michael Paquier wrote:
>
> > The fix is obvious because currentCommand is a pointer and not an Oid.
> > Please see attached. Should I fix it myself?
Pushed now, thanks.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Fix event triggers for partitioned tables
@ 2018-10-09 03:23 Michael Paquier <michael@paquier.xyz>
parent: Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 0 replies; 10+ messages in thread
From: Michael Paquier @ 2018-10-09 03:23 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Postgres hackers <pgsql-hackers@postgresql.org>
On Mon, Oct 08, 2018 at 10:39:23AM -0300, Alvaro Herrera wrote:
> Pushed now, thanks.
Thanks Alvaro for addressing the issue and back-patching.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2018-10-09 03:23 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-06 22:18 pgsql: Fix event triggers for partitioned tables Alvaro Herrera <alvherre@alvh.no-ip.org>
2018-10-08 09:12 ` Michael Paquier <michael@paquier.xyz>
2018-10-08 12:54 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2018-10-08 13:39 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2018-10-09 03:23 ` Michael Paquier <michael@paquier.xyz>
2018-10-08 09:32 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-10-06 22:18 pgsql: Fix event triggers for partitioned tables Alvaro Herrera <alvherre@alvh.no-ip.org>
2018-10-06 22:18 pgsql: Fix event triggers for partitioned tables Alvaro Herrera <alvherre@alvh.no-ip.org>
2018-10-06 22:18 pgsql: Fix event triggers for partitioned tables Alvaro Herrera <alvherre@alvh.no-ip.org>
2018-10-06 22:18 pgsql: Fix event triggers for partitioned tables 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