Re: SQLFunctionCache and generic plans

Alexander Law <exclusion@gmail.com>

From: Alexander Lakhin <exclusion@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>, Alexander Pyhalov <a.pyhalov@postgrespro.ru>
Cc: Pavel Stehule <pavel.stehule@gmail.com>, Alexander Korotkov <aekorotkov@gmail.com>, pgsql-hackers@lists.postgresql.org, Ronan Dunklau <ronan.dunklau@aiven.io>
Date: 2025-04-03T19:00:00Z
Lists: pgsql-hackers
Hello Tom,

02.04.2025 21:09, Tom Lane wrote:
> Since feature freeze is fast approaching, I did a tiny bit more
> cosmetic work on this patchset and then pushed it.  (There's still
> plenty of time for adjustments if you have further comments.)

I've discovered that starting from 0dca5d68d, the following query:
CREATE FUNCTION f(x anyelement) RETURNS anyarray AS '' LANGUAGE SQL;
SELECT f(0);

triggers:
TRAP: failed Assert("fcache->func->rettype == VOIDOID"), File: "functions.c", Line: 1737, PID: 3784779

On 0dca5d68d~1, it raises:
ERROR:  return type mismatch in function declared to return integer[]
DETAIL:  Function's final statement must be SELECT or INSERT/UPDATE/DELETE/MERGE RETURNING.
CONTEXT:  SQL function "f" during startup

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

Commits

  1. Fix performance issue in deadlock-parallel isolation test.

  2. functions.c: copy trees from source_list before parse analysis etc.

  3. Fix oversight in commit 0dca5d68d.

  4. Change SQL-language functions to use the plan cache.

  5. Reordering DISTINCT keys to match input path's pathkeys