1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-29 15:58:33 +03:00

Initialize FOUND to false in PL/pgSQL event trigger functions.

The documentation says that FOUND starts out false within each
PL/pgSQL function call.  plpgsql_exec_function() and
plpgsql_exec_trigger() do set it so, but plpgsql_exec_event_trigger()
did not, leaving it NULL until the first statement that sets it.

Fix this by initializing FOUND to false, as the other two entry points
do.  While at it, also set estate.err_text to "during function entry"
during this action and the subsequent instrumentation plugin call,
again to match the other two routines.

Back-patch to v19, but no further.  It seems unlikely that any user
code is depending on the current behavior, but just in case, let's
not touch the stable branches.

Author: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAM2+6=U_=hZmgs1v1JJ-XJk2bpbfqQPP9MNRDbp5RoEsOW8xsQ@mail.gmail.com
Backpatch-through: 19
This commit is contained in:
Tom Lane
2026-10-26 17:15:27 -04:00
parent 07be6f384c
commit 1dc45adefa

View File

@@ -1199,6 +1199,13 @@ plpgsql_exec_event_trigger(PLpgSQL_function *func, EventTriggerData *trigdata)
estate.err_text = gettext_noop("during initialization of execution state");
copy_plpgsql_datums(&estate, func);
estate.err_text = gettext_noop("during function entry");
/*
* Set the magic variable FOUND to false
*/
exec_set_found(&estate, false);
/*
* Let the instrumentation plugin peek at this function
*/