Re: make tuplestore helper function
Melanie Plageman <melanieplageman@gmail.com>
From: Melanie Plageman <melanieplageman@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Justin Pryzby <pryzby@telsasoft.com>,
Pg Hackers <pgsql-hackers@postgresql.org>, Andres Freund <andres@anarazel.de>, Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: 2022-03-07T22:09:19Z
Lists: pgsql-hackers
Attachments
- 0001-contrib-SRFs-use-helper.patch (text/x-patch) patch 0001
On Sun, Mar 6, 2022 at 9:29 PM Michael Paquier <michael@paquier.xyz> wrote: > > On Wed, Mar 02, 2022 at 03:43:17PM +0900, Michael Paquier wrote: > > This is actually setting up a function in the context of a single call > > where we fill the tuplestore with all its values, so instead I have > > settled down to name that SetSingleFuncCall(), to make a parallel with > > the existing MultiFuncCall*(). funcapi.c is the right place for > > that, and I have added more documentation in the fmgr's README as well > > as funcapi.h. > > I have tortured all those code paths for the last couple of days, and > the new function name, as well as its options, still seemed fine to > me, so I have applied the patch. The buildfarm is cool with it. It > is worth noting that there are more code paths in contrib/ that could > be simplified with this new routine. Wow! Thanks so much for taking the time to review, refine, and commit this work. I've attached a patch using the helper in most locations in contrib modules that seemed useful. The following I don't think we can use the helper or it is not worth it: - pg_logdir_ls() in contrib/adminpack has return type TYPEFUNC_RECORD and expectedDesc is not already created, so the helper can't be used. But basically, since it doesn't specify OUT argument names, it has to do TupleDescInitEntry() itself anyway, I think. - contrib/tablefunc.c was also not simple to refactor. the various parts of SetSingleFuncCall are spread throughout different functions in the file. - contrib/dblink has one function which returns a tuplestore that was simple to change (dblink_get_notify()) and I've done so. However, most of the other creation of tuplestore and tupledescriptors is in helper functions (like materializeResult()) which separate the tuplestore creation from the tuple descriptor initialization in a way that made it hard to do a drop-in replacement with the helper function. - Melanie
Commits
-
Simplify SRFs using materialize mode in contrib/ modules
- 5b81703787bf 15.0 landed
-
Create routine able to set single-call SRFs for Materialize mode
- 9e98583898c3 15.0 landed
-
Simplify more checks related to set-returning functions
- e77216fcb021 15.0 landed
-
Clean up and simplify code in a couple of set-returning functions
- fcc28178c694 15.0 landed
-
Fix inconsistencies in SRF checks of pg_config() and string_to_table()
- 07daca53bfca 15.0 landed
-
Remove all traces of tuplestore_donestoring() in the C code
- d61a361d1aef 15.0 landed
-
Support domains over composite types in PL/Perl.
- 60651e4cddbb 11.0 cited