pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix confusion about event trigger vs. plain function in plpgsql.
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix confusion about event trigger vs. plain function in plpgsql.
@ 2020-02-19 19:45 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-02-19 19:45 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix confusion about event trigger vs. plain function in plpgsql.

The function hash table keys made by compute_function_hashkey() failed
to distinguish event-trigger call context from regular call context.
This meant that once we'd successfully made a hash entry for an event
trigger (either by validation, or by normal use as an event trigger),
an attempt to call the trigger function as a plain function would
find this hash entry and thereby bypass the you-can't-do-that check in
do_compile().  Thus we'd attempt to execute the function, leading to
strange errors or even crashes, depending on function contents and
server version.

To fix, add an isEventTrigger field to PLpgSQL_func_hashkey,
paralleling the longstanding infrastructure for regular triggers.
This fits into what had been pad space, so there's no risk of an ABI
break, even assuming that any third-party code is looking at these
hash keys.  (I considered replacing isTrigger with a PLpgSQL_trigtype
enum field, but felt that that carried some API/ABI risk.  Maybe we
should change it in HEAD though.)

Per bug #16266 from Alexander Lakhin.  This has been broken since
event triggers were invented, so back-patch to all supported branches.

Discussion: https://postgr.es/m/16266-fcd7f838e97ba5d4@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/761a5688b179d46091e7314458571c5fc537084a

Modified Files
--------------
src/pl/plpgsql/src/pl_comp.c                | 15 +++++++++++----
src/pl/plpgsql/src/plpgsql.h                |  5 +++--
src/test/regress/expected/event_trigger.out |  4 ++++
src/test/regress/sql/event_trigger.sql      |  3 +++
4 files changed, 21 insertions(+), 6 deletions(-)



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

* pgsql: Fix confusion about event trigger vs. plain function in plpgsql.
@ 2020-02-19 19:45 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-02-19 19:45 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix confusion about event trigger vs. plain function in plpgsql.

The function hash table keys made by compute_function_hashkey() failed
to distinguish event-trigger call context from regular call context.
This meant that once we'd successfully made a hash entry for an event
trigger (either by validation, or by normal use as an event trigger),
an attempt to call the trigger function as a plain function would
find this hash entry and thereby bypass the you-can't-do-that check in
do_compile().  Thus we'd attempt to execute the function, leading to
strange errors or even crashes, depending on function contents and
server version.

To fix, add an isEventTrigger field to PLpgSQL_func_hashkey,
paralleling the longstanding infrastructure for regular triggers.
This fits into what had been pad space, so there's no risk of an ABI
break, even assuming that any third-party code is looking at these
hash keys.  (I considered replacing isTrigger with a PLpgSQL_trigtype
enum field, but felt that that carried some API/ABI risk.  Maybe we
should change it in HEAD though.)

Per bug #16266 from Alexander Lakhin.  This has been broken since
event triggers were invented, so back-patch to all supported branches.

Discussion: https://postgr.es/m/16266-fcd7f838e97ba5d4@postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/32aa14d40c7ce12e648c9f88fe22fa0146bee3b4

Modified Files
--------------
src/pl/plpgsql/src/pl_comp.c                | 15 +++++++++++----
src/pl/plpgsql/src/plpgsql.h                |  5 +++--
src/test/regress/expected/event_trigger.out |  4 ++++
src/test/regress/sql/event_trigger.sql      |  3 +++
4 files changed, 21 insertions(+), 6 deletions(-)



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

* pgsql: Fix confusion about event trigger vs. plain function in plpgsql.
@ 2020-02-19 19:45 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-02-19 19:45 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix confusion about event trigger vs. plain function in plpgsql.

The function hash table keys made by compute_function_hashkey() failed
to distinguish event-trigger call context from regular call context.
This meant that once we'd successfully made a hash entry for an event
trigger (either by validation, or by normal use as an event trigger),
an attempt to call the trigger function as a plain function would
find this hash entry and thereby bypass the you-can't-do-that check in
do_compile().  Thus we'd attempt to execute the function, leading to
strange errors or even crashes, depending on function contents and
server version.

To fix, add an isEventTrigger field to PLpgSQL_func_hashkey,
paralleling the longstanding infrastructure for regular triggers.
This fits into what had been pad space, so there's no risk of an ABI
break, even assuming that any third-party code is looking at these
hash keys.  (I considered replacing isTrigger with a PLpgSQL_trigtype
enum field, but felt that that carried some API/ABI risk.  Maybe we
should change it in HEAD though.)

Per bug #16266 from Alexander Lakhin.  This has been broken since
event triggers were invented, so back-patch to all supported branches.

Discussion: https://postgr.es/m/16266-fcd7f838e97ba5d4@postgresql.org

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/612d207bcc05d1048a8648407b064df14cd3104a

Modified Files
--------------
src/pl/plpgsql/src/pl_comp.c                | 15 +++++++++++----
src/pl/plpgsql/src/plpgsql.h                |  5 +++--
src/test/regress/expected/event_trigger.out |  4 ++++
src/test/regress/sql/event_trigger.sql      |  3 +++
4 files changed, 21 insertions(+), 6 deletions(-)



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

* pgsql: Fix confusion about event trigger vs. plain function in plpgsql.
@ 2020-02-19 19:45 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-02-19 19:45 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix confusion about event trigger vs. plain function in plpgsql.

The function hash table keys made by compute_function_hashkey() failed
to distinguish event-trigger call context from regular call context.
This meant that once we'd successfully made a hash entry for an event
trigger (either by validation, or by normal use as an event trigger),
an attempt to call the trigger function as a plain function would
find this hash entry and thereby bypass the you-can't-do-that check in
do_compile().  Thus we'd attempt to execute the function, leading to
strange errors or even crashes, depending on function contents and
server version.

To fix, add an isEventTrigger field to PLpgSQL_func_hashkey,
paralleling the longstanding infrastructure for regular triggers.
This fits into what had been pad space, so there's no risk of an ABI
break, even assuming that any third-party code is looking at these
hash keys.  (I considered replacing isTrigger with a PLpgSQL_trigtype
enum field, but felt that that carried some API/ABI risk.  Maybe we
should change it in HEAD though.)

Per bug #16266 from Alexander Lakhin.  This has been broken since
event triggers were invented, so back-patch to all supported branches.

Discussion: https://postgr.es/m/16266-fcd7f838e97ba5d4@postgresql.org

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6af63cf8c0b905f5c20cecff03b30ef52594e5f9

Modified Files
--------------
src/pl/plpgsql/src/pl_comp.c                | 15 +++++++++++----
src/pl/plpgsql/src/plpgsql.h                |  5 +++--
src/test/regress/expected/event_trigger.out |  4 ++++
src/test/regress/sql/event_trigger.sql      |  3 +++
4 files changed, 21 insertions(+), 6 deletions(-)



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

* pgsql: Fix confusion about event trigger vs. plain function in plpgsql.
@ 2020-02-19 19:45 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-02-19 19:45 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix confusion about event trigger vs. plain function in plpgsql.

The function hash table keys made by compute_function_hashkey() failed
to distinguish event-trigger call context from regular call context.
This meant that once we'd successfully made a hash entry for an event
trigger (either by validation, or by normal use as an event trigger),
an attempt to call the trigger function as a plain function would
find this hash entry and thereby bypass the you-can't-do-that check in
do_compile().  Thus we'd attempt to execute the function, leading to
strange errors or even crashes, depending on function contents and
server version.

To fix, add an isEventTrigger field to PLpgSQL_func_hashkey,
paralleling the longstanding infrastructure for regular triggers.
This fits into what had been pad space, so there's no risk of an ABI
break, even assuming that any third-party code is looking at these
hash keys.  (I considered replacing isTrigger with a PLpgSQL_trigtype
enum field, but felt that that carried some API/ABI risk.  Maybe we
should change it in HEAD though.)

Per bug #16266 from Alexander Lakhin.  This has been broken since
event triggers were invented, so back-patch to all supported branches.

Discussion: https://postgr.es/m/16266-fcd7f838e97ba5d4@postgresql.org

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3e5308969aca4f2ce2dcd3766f9fe953b86b2a0c

Modified Files
--------------
src/pl/plpgsql/src/pl_comp.c                | 5 +++++
src/pl/plpgsql/src/plpgsql.h                | 5 +++--
src/test/regress/expected/event_trigger.out | 4 ++++
src/test/regress/sql/event_trigger.sql      | 3 +++
4 files changed, 15 insertions(+), 2 deletions(-)



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

* pgsql: Fix confusion about event trigger vs. plain function in plpgsql.
@ 2020-02-19 19:45 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-02-19 19:45 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix confusion about event trigger vs. plain function in plpgsql.

The function hash table keys made by compute_function_hashkey() failed
to distinguish event-trigger call context from regular call context.
This meant that once we'd successfully made a hash entry for an event
trigger (either by validation, or by normal use as an event trigger),
an attempt to call the trigger function as a plain function would
find this hash entry and thereby bypass the you-can't-do-that check in
do_compile().  Thus we'd attempt to execute the function, leading to
strange errors or even crashes, depending on function contents and
server version.

To fix, add an isEventTrigger field to PLpgSQL_func_hashkey,
paralleling the longstanding infrastructure for regular triggers.
This fits into what had been pad space, so there's no risk of an ABI
break, even assuming that any third-party code is looking at these
hash keys.  (I considered replacing isTrigger with a PLpgSQL_trigtype
enum field, but felt that that carried some API/ABI risk.  Maybe we
should change it in HEAD though.)

Per bug #16266 from Alexander Lakhin.  This has been broken since
event triggers were invented, so back-patch to all supported branches.

Discussion: https://postgr.es/m/16266-fcd7f838e97ba5d4@postgresql.org

Branch
------
REL9_5_STABLE

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

Modified Files
--------------
src/pl/plpgsql/src/pl_comp.c                | 5 +++++
src/pl/plpgsql/src/plpgsql.h                | 5 +++--
src/test/regress/expected/event_trigger.out | 4 ++++
src/test/regress/sql/event_trigger.sql      | 3 +++
4 files changed, 15 insertions(+), 2 deletions(-)



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


end of thread, other threads:[~2020-02-19 19:45 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 19:45 pgsql: Fix confusion about event trigger vs. plain function in plpgsql. Tom Lane <tgl@sss.pgh.pa.us>
2020-02-19 19:45 pgsql: Fix confusion about event trigger vs. plain function in plpgsql. Tom Lane <tgl@sss.pgh.pa.us>
2020-02-19 19:45 pgsql: Fix confusion about event trigger vs. plain function in plpgsql. Tom Lane <tgl@sss.pgh.pa.us>
2020-02-19 19:45 pgsql: Fix confusion about event trigger vs. plain function in plpgsql. Tom Lane <tgl@sss.pgh.pa.us>
2020-02-19 19:45 pgsql: Fix confusion about event trigger vs. plain function in plpgsql. Tom Lane <tgl@sss.pgh.pa.us>
2020-02-19 19:45 pgsql: Fix confusion about event trigger vs. plain function in plpgsql. Tom Lane <tgl@sss.pgh.pa.us>

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