Skip to content

Commit 07daca5

Browse files
committed
Fix inconsistencies in SRF checks of pg_config() and string_to_table()
The execution paths of those functions have been using a set of checks inconsistent with any other SRF function: - string_to_table() missed a check on expectedDesc, the tuple descriptor expected by the caller, that should never be NULL. Introduced in 66f1630. - pg_config() should check for a ReturnSetInfo, and expectedDesc cannot be NULL. Its error messages were also inconsistent. Introduced in a5c43b8. Extracted from a larger patch by the same author, in preparation for a larger patch set aimed at refactoring the way tuplestores are created and checked in SRF functions. Author: Melanie Plageman Reviewed-by: Justin Pryzby Discussion: https://postgr.es/m/CAAKRu_azyd1Z3W_r7Ou4sorTjRCs+PxeHw1CWJeXKofkE6TuZg@mail.gmail.com
1 parent 618c167 commit 07daca5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/backend/utils/adt/varlena.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4839,7 +4839,8 @@ text_to_table(PG_FUNCTION_ARGS)
48394839
ereport(ERROR,
48404840
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
48414841
errmsg("set-valued function called in context that cannot accept a set")));
4842-
if (!(rsi->allowedModes & SFRM_Materialize))
4842+
if (!(rsi->allowedModes & SFRM_Materialize) ||
4843+
rsi->expectedDesc == NULL)
48434844
ereport(ERROR,
48444845
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
48454846
errmsg("materialize mode required, but it is not allowed in this context")));

src/backend/utils/misc/pg_config.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ pg_config(PG_FUNCTION_ARGS)
3737
int i = 0;
3838

3939
/* check to see if caller supports us returning a tuplestore */
40-
if (!rsinfo || !(rsinfo->allowedModes & SFRM_Materialize))
40+
if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
4141
ereport(ERROR,
42-
(errcode(ERRCODE_SYNTAX_ERROR),
43-
errmsg("materialize mode required, but it is not "
44-
"allowed in this context")));
42+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
43+
errmsg("set-valued function called in context that cannot accept a set")));
44+
if (!(rsinfo->allowedModes & SFRM_Materialize) ||
45+
rsinfo->expectedDesc == NULL)
46+
ereport(ERROR,
47+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
48+
errmsg("materialize mode required, but it is not allowed in this context")));
4549

4650
per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
4751
oldcontext = MemoryContextSwitchTo(per_query_ctx);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy