Re: Performance issues with v18 SQL-language-function changes
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>, pgsql-hackers@lists.postgresql.org,
Alexander Pyhalov <a.pyhalov@postgrespro.ru>,
Bruce Momjian <bruce@momjian.us>,
Pavel Stehule <pavel.stehule@gmail.com>
Date: 2025-05-01T14:19:06Z
Lists: pgsql-hackers
I wrote: > Hmm. What seems to be going on here is that once the aggfns_trans() > result gets large enough that the SQL-function-result tuplestore > decides to spill to disk, when we pull the result tuple back out > of the tuplestore with tuplestore_gettupleslot we end up with the > jf_resultSlot holding a should-free tuple pointer that points into > the tuplestore's storage. After tuplestore_clear that is a dangling > pointer, and the next use of the jf_resultSlot fails while trying to > free the tuple. I still haven't figured out why this wasn't a problem in the old version of functions.c. However, I did realize that my pending patch at [1] gets rid of the problem in another way, by removing functions.c's use of tuplestore_gettupleslot altogether. Now I'm tempted to just push that, instead of applying a band-aid that will leave v18 doing this differently from both earlier and later branches. regards, tom lane [1] https://www.postgresql.org/message-id/2443532.1744919968%40sss.pgh.pa.us
Commits
-
Don't use a tuplestore if we don't have to for SQL-language functions.
- e83a8ae44729 18.0 landed
-
Change SQL-language functions to use the plan cache.
- 0dca5d68d7be 18.0 cited
-
contrib/pageinspect: Use SQL-standard function bodies.
- 68ff25eef125 18.0 cited