postgresql/src/include/nodes
Tom Lane 1268e73781 Fix problems when a plain-inheritance parent table is excluded.
When an UPDATE/DELETE/MERGE's target table is an old-style
inheritance tree, it's possible for the parent to get excluded
from the plan while some children are not.  (I believe this is
only possible if we can prove that a CHECK ... NO INHERIT
constraint on the parent contradicts the query WHERE clause,
so it's a very unusual case.)  In such a case, ExecInitModifyTable
mistakenly concluded that the first surviving child is the target
table, leading to at least two bugs:

1. The wrong table's statement-level triggers would get fired.

2. In v16 and up, it was possible to fail with "invalid perminfoindex
0 in RTE with relid nnnn" due to the child RTE not having permissions
data included in the query plan.  This was hard to reproduce reliably
because it did not occur unless the update triggered some non-HOT
index updates.

In v14 and up, this is easy to fix by defining ModifyTable.rootRelation
to be the parent RTE in plain inheritance as well as partitioned cases.

While the wrong-triggers bug also appears in older branches, the
relevant code in both the planner and executor is quite a bit
different, so it would take a good deal of effort to develop and
test a suitable patch.  Given the lack of field complaints about the
trigger issue, I'll desist for now.  (Patching v11 for this seems
unwise anyway, given that it will have no more releases after next
month.)

Per bug #18147 from Hans Buschmann.

Amit Langote and Tom Lane

Discussion: https://postgr.es/m/18147-6fc796538913ee88@postgresql.org
2023-10-24 14:48:34 -04:00
..
bitmapset.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
execnodes.h Fix EvalPlanQual rechecking during MERGE. 2023-09-30 10:55:24 +01:00
extensible.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
lockoptions.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
makefuncs.h Revert SQL/JSON features 2022-09-01 17:10:42 -04:00
memnodes.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
nodeFuncs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
nodes.h Revert SQL/JSON features 2022-09-01 17:10:42 -04:00
params.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
parsenodes.h Fix calculation of which GENERATED columns need to be updated. 2023-01-05 14:12:17 -05:00
pathnodes.h Fix problems when a plain-inheritance parent table is excluded. 2023-10-24 14:48:34 -04:00
pg_list.h Tidy up code in get_cheapest_group_keys_order() 2022-07-13 14:03:24 +12:00
plannodes.h Fix problems when a plain-inheritance parent table is excluded. 2023-10-24 14:48:34 -04:00
primnodes.h Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. 2023-02-25 14:44:14 -05:00
print.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
readfuncs.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
replnodes.h Fix limitations on what SQL commands can be issued to a walsender. 2022-01-24 15:33:38 -05:00
subscripting.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
supportnodes.h Teach planner and executor about monotonic window funcs 2022-04-08 10:34:36 +12:00
tidbitmap.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
value.h Add Boolean node 2022-01-17 10:38:23 +01:00