diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-04-03 11:24:56 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-04-03 11:24:56 -0400 |
commit | 7b1552283465acc10a88038fe87c7901198c3b5e (patch) | |
tree | bbe22a5bbd233df728d55a637a99d39e6290857b /src/backend/commands/constraint.c | |
parent | 42da1db7b9d5dd2d3d2e887adb19c6a3c28804b9 (diff) | |
download | postgresql-7b1552283465acc10a88038fe87c7901198c3b5e.tar.gz postgresql-7b1552283465acc10a88038fe87c7901198c3b5e.zip |
Fix bogus CALLED_AS_TRIGGER() defenses.
contrib/lo's lo_manage() thought it could use
trigdata->tg_trigger->tgname in its error message about
not being called as a trigger. That naturally led to a core dump.
unique_key_recheck() figured it could Assert that fcinfo->context
is a TriggerData node in advance of having checked that it's
being called as a trigger. That's harmless in production builds,
and perhaps not that easy to reach in any case, but it's logically
wrong.
The first of these per bug #16340 from William Crowell;
the second from manual inspection of other CALLED_AS_TRIGGER
call sites.
Back-patch the lo.c change to all supported branches, the
other to v10 where the thinko crept in.
Discussion: https://postgr.es/m/16340-591c7449dc7c8c47@postgresql.org
Diffstat (limited to 'src/backend/commands/constraint.c')
-rw-r--r-- | src/backend/commands/constraint.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/commands/constraint.c b/src/backend/commands/constraint.c index 90f19ad3dd9..1ec93c1fd67 100644 --- a/src/backend/commands/constraint.c +++ b/src/backend/commands/constraint.c @@ -37,7 +37,7 @@ Datum unique_key_recheck(PG_FUNCTION_ARGS) { - TriggerData *trigdata = castNode(TriggerData, fcinfo->context); + TriggerData *trigdata = (TriggerData *) fcinfo->context; const char *funcname = "unique_key_recheck"; HeapTuple new_row; ItemPointerData tmptid; |