public inbox for [email protected]  
help / color / mirror / Atom feed
From: Alexander Lakhin <[email protected]>
To: Tom Lane <[email protected]>
Cc: Alexander Pyhalov <[email protected]>
Cc: Pavel Stehule <[email protected]>
Cc: Alexander Korotkov <[email protected]>
Cc: [email protected]
Cc: Ronan Dunklau <[email protected]>
Subject: Re: SQLFunctionCache and generic plans
Date: Fri, 4 Apr 2025 22:00:01 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <8216639.NyiUUSuA9g@aivenlaptop>
	<CAFj8pRC_4gEfmDoB5KbacNDdt3e6Tnf1z1BFK=MVp3+2kcDVqw@mail.gmail.com>
	<CAFj8pRA7MFTfUPwDDWtghaUvAjbrMHFUPbHyLSX3h8+FDw4WFg@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<CAFj8pRDWDeF2cC+pCjLHJno7KnK5kdtjYN-f933R! ! ! ! ! [email protected]>
	<CAFj8pRD0diy5VDP=8B9au5sk_yRknCWqZx35VniBtP_OA4aJNw@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected].! pa.us>
	<[email protected]>
	<[email protected]>

Hello Tom,

03.04.2025 22:13, Tom Lane wrpte:
> Drat.  I thought I'd tested the empty-function-body case, but
> evidently that was a few changes too far back.  Will fix,
> thanks for catching it.

I've stumbled upon another defect introduced with 0dca5d68d:
CREATE FUNCTION f(VARIADIC ANYARRAY) RETURNS ANYELEMENT AS $$ SELECT x FROM generate_series(1,1) g(i) $$ LANGUAGE SQL 
IMMUTABLE;
SELECT f(1);
SELECT f(1);

fails under Valgrind with:
2025-04-04 18:31:13.771 UTC [242811] LOG:  statement: SELECT f(1);
==00:00:00:19.324 242811== Invalid read of size 4
==00:00:00:19.324 242811==    at 0x48D610: copyObjectImpl (copyfuncs.c:187)
==00:00:00:19.324 242811==    by 0x490194: _copyAlias (copyfuncs.funcs.c:48)
==00:00:00:19.324 242811==    by 0x48D636: copyObjectImpl (copyfuncs.switch.c:19)
==00:00:00:19.324 242811==    by 0x491CBF: _copyRangeFunction (copyfuncs.funcs.c:1279)
==00:00:00:19.324 242811==    by 0x48DC9C: copyObjectImpl (copyfuncs.switch.c:271)
==00:00:00:19.324 242811==    by 0x4A295C: list_copy_deep (list.c:1652)
==00:00:00:19.324 242811==    by 0x4900FA: copyObjectImpl (copyfuncs.c:192)
==00:00:00:19.324 242811==    by 0x4931E4: _copySelectStmt (copyfuncs.funcs.c:2109)
==00:00:00:19.324 242811==    by 0x48E00C: copyObjectImpl (copyfuncs.switch.c:436)
==00:00:00:19.324 242811==    by 0x492F85: _copyRawStmt (copyfuncs.funcs.c:2026)
==00:00:00:19.324 242811==    by 0x48DFBC: copyObjectImpl (copyfuncs.switch.c:421)
==00:00:00:19.324 242811==    by 0x76DCCE: CreateCachedPlan (plancache.c:213)
==00:00:00:19.324 242811==  Address 0x11b478d0 is 4,032 bytes inside a block of size 8,192 alloc'd
==00:00:00:19.324 242811==    at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==00:00:00:19.324 242811==    by 0x7AA15D: AllocSetContextCreateInternal (aset.c:444)
==00:00:00:19.324 242811==    by 0x43CF56: init_sql_fcache (functions.c:616)
==00:00:00:19.324 242811==    by 0x43CF56: fmgr_sql (functions.c:1484)
==00:00:00:19.324 242811==    by 0x423E13: ExecInterpExpr (execExprInterp.c:926)
==00:00:00:19.324 242811==    by 0x41EB54: ExecInterpExprStillValid (execExprInterp.c:2299)
...

Best regards,
Alexander Lakhin
Neon (https://neon.tech)

view thread (4+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: SQLFunctionCache and generic plans
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox