@@ -687,9 +687,13 @@ crosstab_hash(PG_FUNCTION_ARGS)
687687int num_categories ;
688688
689689/* check to see if caller supports us returning a tuplestore */
690- if (! rsinfo || !(rsinfo -> allowedModes & SFRM_Materialize ))
690+ if (rsinfo == NULL || !IsA (rsinfo , ReturnSetInfo ))
691691ereport (ERROR ,
692- (errcode (ERRCODE_SYNTAX_ERROR ),
692+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
693+ errmsg ("set-valued function called in context that cannot accept a set" )));
694+ if (!(rsinfo -> allowedModes & SFRM_Materialize ))
695+ ereport (ERROR ,
696+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
693697errmsg ("materialize mode required, but it is not " \
694698"allowed in this context" )));
695699
@@ -1049,9 +1053,13 @@ connectby_text(PG_FUNCTION_ARGS)
10491053MemoryContext oldcontext ;
10501054
10511055/* check to see if caller supports us returning a tuplestore */
1052- if (! rsinfo || !(rsinfo -> allowedModes & SFRM_Materialize ))
1056+ if (rsinfo == NULL || !IsA (rsinfo , ReturnSetInfo ))
10531057ereport (ERROR ,
1054- (errcode (ERRCODE_SYNTAX_ERROR ),
1058+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
1059+ errmsg ("set-valued function called in context that cannot accept a set" )));
1060+ if (!(rsinfo -> allowedModes & SFRM_Materialize ))
1061+ ereport (ERROR ,
1062+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
10551063errmsg ("materialize mode required, but it is not " \
10561064"allowed in this context" )));
10571065
@@ -1076,13 +1084,6 @@ connectby_text(PG_FUNCTION_ARGS)
10761084/* OK, use it then */
10771085attinmeta = TupleDescGetAttInMetadata (tupdesc );
10781086
1079- /* check to see if caller supports us returning a tuplestore */
1080- if (!rsinfo || !(rsinfo -> allowedModes & SFRM_Materialize ))
1081- ereport (ERROR ,
1082- (errcode (ERRCODE_SYNTAX_ERROR ),
1083- errmsg ("materialize mode required, but it is not " \
1084- "allowed in this context" )));
1085-
10861087/* OK, go to work */
10871088rsinfo -> returnMode = SFRM_Materialize ;
10881089rsinfo -> setResult = connectby (relname ,
@@ -1131,9 +1132,15 @@ connectby_text_serial(PG_FUNCTION_ARGS)
11311132MemoryContext oldcontext ;
11321133
11331134/* check to see if caller supports us returning a tuplestore */
1134- if (!rsinfo || !(rsinfo -> allowedModes & SFRM_Materialize ))
1135- elog (ERROR ,"connectby: materialize mode required, but it is not "
1136- "allowed in this context" );
1135+ if (rsinfo == NULL || !IsA (rsinfo ,ReturnSetInfo ))
1136+ ereport (ERROR ,
1137+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
1138+ errmsg ("set-valued function called in context that cannot accept a set" )));
1139+ if (!(rsinfo -> allowedModes & SFRM_Materialize ))
1140+ ereport (ERROR ,
1141+ (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
1142+ errmsg ("materialize mode required, but it is not " \
1143+ "allowed in this context" )));
11371144
11381145if (fcinfo -> nargs == 7 )
11391146{
@@ -1156,11 +1163,6 @@ connectby_text_serial(PG_FUNCTION_ARGS)
11561163/* OK, use it then */
11571164attinmeta = TupleDescGetAttInMetadata (tupdesc );
11581165
1159- /* check to see if caller supports us returning a tuplestore */
1160- if (!rsinfo -> allowedModes & SFRM_Materialize )
1161- elog (ERROR ,"connectby requires Materialize mode, but it is not "
1162- "allowed in this context" );
1163-
11641166/* OK, go to work */
11651167rsinfo -> returnMode = SFRM_Materialize ;
11661168rsinfo -> setResult = connectby (relname ,