postgresql/src/backend/utils/adt
Michael Paquier 9e98583898 Create routine able to set single-call SRFs for Materialize mode
Set-returning functions that use the Materialize mode, creating a
tuplestore to include all the tuples returned in a set rather than doing
so in multiple calls, use roughly the same set of steps to prepare
ReturnSetInfo for this job:
- Check if ReturnSetInfo supports returning a tuplestore and if the
materialize mode is enabled.
- Create a tuplestore for all the tuples part of the returned set in the
per-query memory context, stored in ReturnSetInfo->setResult.
- Build a tuple descriptor mostly from get_call_result_type(), then
stored in ReturnSetInfo->setDesc.  Note that there are some cases where
the SRF's tuple descriptor has to be the one specified by the function
caller.

This refactoring is done so as there are (well, should be) no behavior
changes in any of the in-core functions refactored, and the centralized
function that checks and sets up the function's ReturnSetInfo can be
controlled with a set of bits32 options.  Two of them prove to be
necessary now:
- SRF_SINGLE_USE_EXPECTED to use expectedDesc as tuple descriptor, as
expected by the function's caller.
- SRF_SINGLE_BLESS to validate the tuple descriptor for the SRF.

The same initialization pattern is simplified in 28 places per my
count as of src/backend/, shaving up to ~900 lines of code.  These
mostly come from the removal of the per-query initializations and the
sanity checks now grouped in a single location.  There are more
locations that could be simplified in contrib/, that are left for a
follow-up cleanup.

fcc2817, 07daca5 and d61a361 have prepared the areas of the code related
to this change, to ease this refactoring.

Author: Melanie Plageman, Michael Paquier
Reviewed-by: Álvaro Herrera, Justin Pryzby
Discussion: https://postgr.es/m/CAAKRu_azyd1Z3W_r7Ou4sorTjRCs+PxeHw1CWJeXKofkE6TuZg@mail.gmail.com
2022-03-07 10:26:29 +09:00
..
.gitignore Revert "Add gitignore entries for jsonpath_gram.h" 2019-03-23 00:19:34 +01:00
acl.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
amutils.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
array_expanded.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
array_selfuncs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
array_typanalyze.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
array_userfuncs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
arrayfuncs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
arraysubs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
arrayutils.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
ascii.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
bool.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
cash.c Remove unused includes 2021-12-01 16:10:56 +01:00
char.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
cryptohashfuncs.c Improve error handling of cryptohash computations 2022-01-11 09:55:16 +09:00
date.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
datetime.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
datum.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dbsize.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
domains.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
encode.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
enum.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
expandeddatum.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
expandedrecord.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
float.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
format_type.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
formatting.c Call pg_newlocale_from_collation() also with default collation 2022-01-20 09:50:18 +01:00
genfile.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
geo_ops.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
geo_selfuncs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
geo_spgist.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
inet_cidr_ntop.c Avoid conflicts with library versions of inet_net_ntop() and friends. 2019-08-18 19:27:23 -04:00
inet_net_pton.c Avoid conflicts with library versions of inet_net_ntop() and friends. 2019-08-18 19:27:23 -04:00
int8.c Move scanint8() to numutils.c 2022-02-14 21:57:26 +01:00
int.c Remove pg_atoi() 2022-02-15 07:44:26 +01:00
json.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
jsonb_gin.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
jsonb_op.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
jsonb_util.c Use bitwise rotate functions in more places 2022-02-20 13:22:08 +07:00
jsonb.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
jsonbsubs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
jsonfuncs.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
jsonpath_exec.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
jsonpath_gram.y Remove one use of pg_atoi() 2022-02-14 23:07:35 +01:00
jsonpath_scan.l Update copyright for 2022 2022-01-07 19:04:57 -05:00
jsonpath.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
levenshtein.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
like_match.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
like_support.c Call pg_newlocale_from_collation() also with default collation 2022-01-20 09:50:18 +01:00
like.c Call pg_newlocale_from_collation() also with default collation 2022-01-20 09:50:18 +01:00
lockfuncs.c Reduce more the number of calls to GetMaxBackends() 2022-02-10 10:27:29 +09:00
mac8.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
mac.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
Makefile Use "-I." in directories holding Bison parsers, for Oracle compilers. 2021-04-12 19:24:41 -07:00
mcxtfuncs.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
misc.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
multirangetypes_selfuncs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
multirangetypes.c Use bitwise rotate functions in more places 2022-02-20 13:22:08 +07:00
name.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
network_gist.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
network_selfuncs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
network_spgist.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
network.c Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
numeric.c Clean up assorted failures under clang's -fsanitize=undefined checks. 2022-03-03 18:13:24 -05:00
numutils.c Remove pg_atoi() 2022-02-15 07:44:26 +01:00
oid.c Rename value node fields 2022-01-14 11:26:08 +01:00
oracle_compat.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
orderedsetaggs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
partitionfuncs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_locale.c Update comment 2022-02-10 09:16:17 +01:00
pg_lsn.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_upgrade_support.c pg_upgrade: Preserve relfilenodes and tablespace OIDs. 2022-01-17 13:40:27 -05:00
pgstatfuncs.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
pseudotypes.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
quote.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rangetypes_gist.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rangetypes_selfuncs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rangetypes_spgist.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rangetypes_typanalyze.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rangetypes.c Use bitwise rotate functions in more places 2022-02-20 13:22:08 +07:00
regexp.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
regproc.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
ri_triggers.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rowtypes.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
ruleutils.c Add UNIQUE null treatment option 2022-02-03 11:48:21 +01:00
selfuncs.c Add stxdinherit flag to pg_statistic_ext_data 2022-01-16 13:38:01 +01:00
tid.c Tighten overflow checks in tidin(). 2022-03-03 20:04:35 -05:00
timestamp.c Handle integer overflow in interval justification functions. 2022-02-28 15:36:54 -05:00
trigfuncs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsginidx.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsgistidx.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsquery_cleanup.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsquery_gist.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsquery_op.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsquery_rewrite.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsquery_util.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsquery.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsrank.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsvector_op.c Ensure that length argument of memcmp() isn't seen as negative. 2022-02-15 17:28:17 -05:00
tsvector_parser.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsvector.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
uuid.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
varbit.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
varchar.c Call pg_newlocale_from_collation() also with default collation 2022-01-20 09:50:18 +01:00
varlena.c Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
version.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
windowfuncs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
xid8funcs.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
xid.c Add min() and max() aggregates for xid8. 2022-02-10 12:33:41 +09:00
xml.c Update copyright for 2022 2022-01-07 19:04:57 -05:00