Cache by-reference missing values in a long lived context

Andrew Dunstan <andrew@dunslane.net>

Commit: 7f4515a58ebd0ae967638b0a27c730cbd49b3455
Author: Andrew Dunstan <andrew@dunslane.net>
Date: 2023-08-22T19:15:45Z
Releases: 14.10
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

Files

PathChange+/−
src/backend/access/common/heaptuple.c modified +89 −1
src/tools/pgindent/typedefs.list modified +1 −0

Discussion