postgresql/src/backend/catalog
Peter Geoghegan db6736c93c Fix memory leak in indexUnchanged hint mechanism.
Commit 9dc718bd added a "logically unchanged by UPDATE" hinting
mechanism, which is currently used within nbtree indexes only (see
commit d168b666).  This mechanism determined whether or not the incoming
item is a logically unchanged duplicate (a duplicate needed only for
MVCC versioning purposes) once per row updated per non-HOT update.  This
approach led to memory leaks which were noticeable with an UPDATE
statement that updated sufficiently many rows, at least on tables that
happen to have an expression index.

On HEAD, fix the issue by adding a cache to the executor's per-index
IndexInfo struct.

Take a different approach on Postgres 14 to avoid an ABI break: simply
pass down the hint to all indexes unconditionally with non-HOT UPDATEs.
This is deemed acceptable because the hint is currently interpreted
within btinsert() as "perform a bottom-up index deletion pass if and
when the only alternative is splitting the leaf page -- prefer to delete
any LP_DEAD-set items first".  nbtree must always treat the hint as a
noisy signal about what might work, as a strategy of last resort, with
costs imposed on non-HOT updaters.  (The same thing might not be true
within another index AM that applies the hint, which is why the original
behavior is preserved on HEAD.)

Author: Peter Geoghegan <pg@bowt.ie>
Reported-By: Klaudie Willis <Klaudie.Willis@protonmail.com>
Diagnosed-By: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/261065.1639497535@sss.pgh.pa.us
Backpatch: 14-, where the hinting mechanism was added.
2022-01-12 15:41:04 -08:00
..
.gitignore Build in some knowledge about foreign-key relationships in the catalogs. 2021-02-02 17:11:55 -05:00
Catalog.pm Update copyright for 2022 2022-01-07 19:04:57 -05:00
Makefile Update copyright for 2022 2022-01-07 19:04:57 -05:00
aclchk.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
catalog.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dependency.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
genbki.pl Update copyright for 2022 2022-01-07 19:04:57 -05:00
heap.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
index.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
indexing.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
information_schema.sql Update copyright for 2022 2022-01-07 19:04:57 -05:00
namespace.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
objectaccess.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
objectaddress.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
partition.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_aggregate.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_cast.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_class.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_collation.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_constraint.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_conversion.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_db_role_setting.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_depend.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_enum.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_inherits.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_largeobject.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_namespace.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_operator.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_proc.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_publication.c Add index on pg_publication_rel.prpubid 2022-01-12 16:24:26 -03:00
pg_range.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_shdepend.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_subscription.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_type.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
sql_feature_packages.txt Cleanup in SQL features files 2020-03-28 08:46:18 +01:00
sql_features.txt doc: More documentation on regular expressions and SQL standard 2021-12-20 10:36:44 +01:00
storage.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
system_functions.sql Update copyright for 2022 2022-01-07 19:04:57 -05:00
system_views.sql Update copyright for 2022 2022-01-07 19:04:57 -05:00
toasting.c Fix memory leak in indexUnchanged hint mechanism. 2022-01-12 15:41:04 -08:00