Re: BUG #17994: Invalidating relcache corrupts tupDesc inside ExecEvalFieldStoreDeForm()

Alvaro Herrera <alvherre@alvh.no-ip.org>

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Andres Freund <andres@anarazel.de>, Tom Lane <tgl@sss.pgh.pa.us>, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2023-08-21T12:33:37Z
Lists: pgsql-bugs
Hello,

On 2023-Jul-12, Andrew Dunstan wrote:

> +			entry = hash_search(missing_cache, &key, HASH_ENTER, &found);
> +
> +			if (!found)
> +			{
> +				/* cache miss, so we need a non-transient copy of the datum */
> +				oldctx = MemoryContextSwitchTo(TopMemoryContext);
> +				entry->value =
> +					datumCopy(attrmiss->am_value, false, att->attlen);
> +				MemoryContextSwitchTo(oldctx);
> +			}

Hmm ... when exactly do these values get freed if no longer needed?  Is
the theory that leaking them is not relevant?

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"Oh, great altar of passive entertainment, bestow upon me thy discordant images
at such speed as to render linear thought impossible" (Calvin a la TV)



Commits

  1. Cache by-reference missing values in a long lived context

  2. Fix order of operations in ExecEvalFieldStoreDeForm().