Clean up and simplify code in a couple of set-returning functions
Michael Paquier <michael@paquier.xyz>
Clean up and simplify code in a couple of set-returning functions The following set-returning functions have their logic simplified, to be more consistent with other in-core areas: - pg_prepared_statement()'s tuple descriptor is now created with get_call_result_type() instead of being created from scratch, saving from some duplication with pg_proc.dat. - show_all_file_settings(), similarly, now uses get_call_result_type() to build its tuple descriptor instead of creating it from scratch. - pg_options_to_table() made use of a static routine called only once. This commit removes this internal routine to make the function easier to follow. - pg_config() was using a unique logic style, doing checks on the tuple descriptor passed down in expectedDesc, but it has no need to do so. This switches the function to use a tuplestore with a tuple descriptor retrieved from get_call_result_type(), instead. This simplifies an upcoming patch aimed at refactoring the way tuplestores are created and checked in set-returning functions, this change making sense as its own independent cleanup by shaving some code. Author: Melanie Plageman, Michael Paquier Reviewed-by: Justin Pryzby Discussion: https://postgr.es/m/CAAKRu_azyd1Z3W_r7Ou4sorTjRCs+PxeHw1CWJeXKofkE6TuZg@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/commands/prepare.c | modified | +7 −24 |
| src/backend/foreign/foreign.c | modified | +15 −22 |
| src/backend/utils/misc/guc.c | modified | +3 −17 |
| src/backend/utils/misc/pg_config.c | modified | +17 −48 |
| src/backend/utils/mmgr/portalmem.c | modified | +6 −17 |
Discussion
- make tuplestore helper function 23 messages · 2021-11-02 → 2022-03-08