Report the correct is_temporary flag for column defaults.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 11 Sep 2025 21:11:54 +0000 (17:11 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 11 Sep 2025 21:11:54 +0000 (17:11 -0400)
commit3c02c46521b01f1e60caff2d056f3da5ee98ce58
tree61e91fa704e23bc65b77661f8837cad555f67adc
parent3e43a7b1ab971ed22e663891d941d4d00b6dd9fe
Report the correct is_temporary flag for column defaults.

pg_event_trigger_dropped_objects() would report a column default
object with is_temporary = false, even if it belongs to a
temporary table.  This seems clearly wrong, so adjust it to
report the table's temp-ness.

While here, refactor EventTriggerSQLDropAddObject to make its
handling of namespace objects less messy and avoid duplication
of the schema-lookup code.  And add some explicit test coverage
of dropped-object reports for dependencies of temp tables.

Back-patch to v15.  The bug exists further back, but the
GetAttrDefaultColumnAddress function this patch depends on does not,
and it doesn't seem worth adjusting it to cope with the older code.

Author: Antoine Violin <violin.antuan@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAFjUV9x3-hv0gihf+CtUc-1it0hh7Skp9iYFhMS7FJjtAeAptA@mail.gmail.com
Backpatch-through: 15
src/backend/commands/event_trigger.c
src/test/regress/expected/event_trigger.out
src/test/regress/sql/event_trigger.sql