summaryrefslogtreecommitdiff
path: root/contrib/tablefunc/tablefunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tablefunc/tablefunc.c')
-rw-r--r--contrib/tablefunc/tablefunc.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c
index 6ab79ebeff..97163c81a4 100644
--- a/contrib/tablefunc/tablefunc.c
+++ b/contrib/tablefunc/tablefunc.c
@@ -687,9 +687,13 @@ crosstab_hash(PG_FUNCTION_ARGS)
int num_categories;
/* check to see if caller supports us returning a tuplestore */
- if (!rsinfo || !(rsinfo->allowedModes & SFRM_Materialize))
+ if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("set-valued function called in context that cannot accept a set")));
+ if (!(rsinfo->allowedModes & SFRM_Materialize))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("materialize mode required, but it is not " \
"allowed in this context")));
@@ -1049,9 +1053,13 @@ connectby_text(PG_FUNCTION_ARGS)
MemoryContext oldcontext;
/* check to see if caller supports us returning a tuplestore */
- if (!rsinfo || !(rsinfo->allowedModes & SFRM_Materialize))
+ if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("set-valued function called in context that cannot accept a set")));
+ if (!(rsinfo->allowedModes & SFRM_Materialize))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("materialize mode required, but it is not " \
"allowed in this context")));
@@ -1076,13 +1084,6 @@ connectby_text(PG_FUNCTION_ARGS)
/* OK, use it then */
attinmeta = TupleDescGetAttInMetadata(tupdesc);
- /* check to see if caller supports us returning a tuplestore */
- if (!rsinfo || !(rsinfo->allowedModes & SFRM_Materialize))
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("materialize mode required, but it is not " \
- "allowed in this context")));
-
/* OK, go to work */
rsinfo->returnMode = SFRM_Materialize;
rsinfo->setResult = connectby(relname,
@@ -1131,9 +1132,15 @@ connectby_text_serial(PG_FUNCTION_ARGS)
MemoryContext oldcontext;
/* check to see if caller supports us returning a tuplestore */
- if (!rsinfo || !(rsinfo->allowedModes & SFRM_Materialize))
- elog(ERROR, "connectby: materialize mode required, but it is not "
- "allowed in this context");
+ if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("set-valued function called in context that cannot accept a set")));
+ if (!(rsinfo->allowedModes & SFRM_Materialize))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("materialize mode required, but it is not " \
+ "allowed in this context")));
if (fcinfo->nargs == 7)
{
@@ -1156,11 +1163,6 @@ connectby_text_serial(PG_FUNCTION_ARGS)
/* OK, use it then */
attinmeta = TupleDescGetAttInMetadata(tupdesc);
- /* check to see if caller supports us returning a tuplestore */
- if (!rsinfo->allowedModes & SFRM_Materialize)
- elog(ERROR, "connectby requires Materialize mode, but it is not "
- "allowed in this context");
-
/* OK, go to work */
rsinfo->returnMode = SFRM_Materialize;
rsinfo->setResult = connectby(relname,