postgresql/src/include
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
..
access Fix btmarkpos/btrestrpos array key wraparound bug. 2023-09-28 16:29:32 -07:00
backup Move basebackup code to new directory src/backend/backup 2022-08-10 14:03:09 -04:00
bootstrap Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
catalog Dissociate btequalimage() from interval_ops, ending its deduplication. 2023-10-14 16:33:54 -07:00
commands Fix concurrent update issues with MERGE. 2023-03-13 10:23:42 +00:00
common Expand palloc/pg_malloc API for more type safety 2022-09-14 06:04:24 +02:00
datatype Fix overflow hazards in interval input and output conversions. 2022-04-02 16:12:29 -04:00
executor Fix misbehavior of EvalPlanQual checks with multiple result relations. 2023-05-19 14:26:34 -04:00
fe_utils Allow db.schema.table patterns, but complain about random garbage. 2022-04-20 11:37:29 -04:00
foreign Update copyright for 2022 2022-01-07 19:04:57 -05:00
jit jit: Supply LLVMGlobalGetValueType() for LLVM < 8. 2023-10-19 03:03:27 +13:00
lib Fix type of iterator variable in SH_START_ITERATE 2023-07-06 09:57:31 -07:00
libpq Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certificates 2023-02-15 10:12:31 +09:00
mb Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
nodes Fix problems when a plain-inheritance parent table is excluded. 2023-10-24 14:48:34 -04:00
optimizer Disallow replacing joins with scans in problematic cases. 2023-07-28 15:45:02 +09:00
parser Avoid unnecessary plancache revalidation of utility statements. 2023-08-24 12:02:40 -04:00
partitioning Refactor and cleanup runtime partition prune code a little 2022-04-05 11:46:48 +02:00
port Fix detection of unseekable files for fseek() and ftello() with MSVC 2023-04-12 09:09:53 +09:00
portability Update copyright for 2022 2022-01-07 19:04:57 -05:00
postmaster Un-revert "Disable STARTUP_PROGRESS_TIMEOUT in standby mode." 2023-02-10 16:27:05 -05:00
regex Update copyright for 2022 2022-01-07 19:04:57 -05:00
replication Fix the display of UNKNOWN message type in apply worker. 2023-07-25 08:50:37 +05:30
rewrite Fix calculation of which GENERATED columns need to be updated. 2023-01-05 14:12:17 -05:00
snowball Update copyright for 2022 2022-01-07 19:04:57 -05:00
statistics Add stxdinherit flag to pg_statistic_ext_data 2022-01-16 13:38:01 +01:00
storage Improve heuristics for compressing the KnownAssignedXids array. 2022-11-29 15:43:17 -05:00
tcop Allow event trigger table_rewrite for ALTER MATERIALIZED VIEW 2022-08-17 14:55:24 +09:00
tsearch Add comments and a missing CHECK_FOR_INTERRUPTS in ts_headline. 2022-11-21 17:07:07 -05:00
utils Avoid calling proc_exit() in processes forked by system(). 2023-10-17 10:42:06 -05:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h perl: Hide warnings inside perl.h when using gcc compatible compiler 2023-01-02 15:49:33 -08:00
fmgr.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
funcapi.h Rename SetSingleFuncCall() to InitMaterializedSRF() 2022-10-18 10:22:40 +09:00
getaddrinfo.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
getopt_long.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
Makefile Build in some knowledge about foreign-key relationships in the catalogs. 2021-02-02 17:11:55 -05:00
miscadmin.h Process session_preload_libraries within InitPostgres's transaction. 2022-07-25 10:27:43 -04:00
pg_config.h.in Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certificates 2023-02-15 10:12:31 +09:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Fix old-fd issues using global barriers everywhere. 2022-05-07 16:47:29 +12:00
pg_getopt.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
pg_trace.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pgstat.h Fix assertion failure when updating stats_fetch_consistency in a transaction 2023-05-10 11:24:40 +09:00
pgtar.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pgtime.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
port.h pg_basebackup: Fix cross-platform tablespace relocation. 2022-10-21 08:31:39 -04:00
postgres.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
rusagestub.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
windowapi.h Update copyright for 2022 2022-01-07 19:04:57 -05:00