pgsql: Cache by-reference missing values in a long lived context

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Cache by-reference missing values in a long lived context
Date: 2023-08-22 19:18:36
Message-ID: E1qYWtg-000M09-Fl@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Cache by-reference missing values in a long lived context

Attribute missing values might be needed past the lifetime of the tuple
descriptors from which they are extracted. To avoid possibly using
pointers for by-reference values which might thus be left dangling, we
cache a datumCopy'd version of the datum in the TopMemoryContext. Since
we first search for the value this only needs to be done once per
session for any such value.

Original complaint from Tom Lane, idea for mitigation by Andrew Dunstan,
tweaked by Tom Lane.

Backpatch to version 11 where missing values were introduced.

Discussion: https://postgr.es/m/1306569.1687978174@sss.pgh.pa.us

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f938acd68b08704a086b5f41eaf1989026d6f013

Modified Files
--------------
src/backend/access/common/heaptuple.c | 90 ++++++++++++++++++++++++++++++++++-
src/tools/pgindent/typedefs.list | 1 +
2 files changed, 90 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2023-08-22 20:08:17 pgsql: Fix pg_dump assertion failure when dumping pg_catalog.
Previous Message Andrew Dunstan 2023-08-22 19:17:54 pgsql: Cache by-reference missing values in a long lived context