@ -57,7 +57,16 @@ static TypeFuncClass get_type_func_class(Oid typid, Oid *base_typeid);
/*
/*
* SetSingleFuncCall
* Compatibility function for v15 .
*/
void
SetSingleFuncCall ( FunctionCallInfo fcinfo , bits32 flags )
{
InitMaterializedSRF ( fcinfo , flags ) ;
}
/*
* InitMaterializedSRF
*
*
* Helper function to build the state of a set - returning function used
* Helper function to build the state of a set - returning function used
* in the context of a single call with materialize mode . This code
* in the context of a single call with materialize mode . This code
@ -65,15 +74,15 @@ static TypeFuncClass get_type_func_class(Oid typid, Oid *base_typeid);
* the TupleDesc used with the function and stores them into the
* the TupleDesc used with the function and stores them into the
* function ' s ReturnSetInfo .
* function ' s ReturnSetInfo .
*
*
* " flags " can be set to SRF_SINGLE _USE_EXPECTED , to use the tuple
* " flags " can be set to MAT_ SRF_USE_EXPECTED_DESC , to use the tuple
* descriptor coming from expectedDesc , which is the tuple descriptor
* descriptor coming from expectedDesc , which is the tuple descriptor
* expected by the caller . SRF_SINGLE _BLESS can be set to complete the
* expected by the caller . MAT_ SRF_BLESS can be set to complete the
* information associated to the tuple descriptor , which is necessary
* information associated to the tuple descriptor , which is necessary
* in some cases where the tuple descriptor comes from a transient
* in some cases where the tuple descriptor comes from a transient
* RECORD datatype .
* RECORD datatype .
*/
*/
void
void
SetSingleFuncCall ( FunctionCallInfo fcinfo , bits32 flags )
InitMaterializedSRF ( FunctionCallInfo fcinfo , bits32 flags )
{
{
bool random_access ;
bool random_access ;
ReturnSetInfo * rsinfo = ( ReturnSetInfo * ) fcinfo - > resultinfo ;
ReturnSetInfo * rsinfo = ( ReturnSetInfo * ) fcinfo - > resultinfo ;
@ -88,7 +97,7 @@ SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags)
( errcode ( ERRCODE_FEATURE_NOT_SUPPORTED ) ,
( errcode ( ERRCODE_FEATURE_NOT_SUPPORTED ) ,
errmsg ( " set-valued function called in context that cannot accept a set " ) ) ) ;
errmsg ( " set-valued function called in context that cannot accept a set " ) ) ) ;
if ( ! ( rsinfo - > allowedModes & SFRM_Materialize ) | |
if ( ! ( rsinfo - > allowedModes & SFRM_Materialize ) | |
( ( flags & SRF_SINGLE _USE_EXPECTED ) ! = 0 & & rsinfo - > expectedDesc = = NULL ) )
( ( flags & MAT_ SRF_USE_EXPECTED_DESC ) ! = 0 & & rsinfo - > expectedDesc = = NULL ) )
ereport ( ERROR ,
ereport ( ERROR ,
( errcode ( ERRCODE_FEATURE_NOT_SUPPORTED ) ,
( errcode ( ERRCODE_FEATURE_NOT_SUPPORTED ) ,
errmsg ( " materialize mode required, but it is not allowed in this context " ) ) ) ;
errmsg ( " materialize mode required, but it is not allowed in this context " ) ) ) ;
@ -101,7 +110,7 @@ SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags)
old_context = MemoryContextSwitchTo ( per_query_ctx ) ;
old_context = MemoryContextSwitchTo ( per_query_ctx ) ;
/* build a tuple descriptor for our result type */
/* build a tuple descriptor for our result type */
if ( ( flags & SRF_SINGLE _USE_EXPECTED ) ! = 0 )
if ( ( flags & MAT_ SRF_USE_EXPECTED_DESC ) ! = 0 )
stored_tupdesc = CreateTupleDescCopy ( rsinfo - > expectedDesc ) ;
stored_tupdesc = CreateTupleDescCopy ( rsinfo - > expectedDesc ) ;
else
else
{
{
@ -110,7 +119,7 @@ SetSingleFuncCall(FunctionCallInfo fcinfo, bits32 flags)
}
}
/* If requested, bless the tuple descriptor */
/* If requested, bless the tuple descriptor */
if ( ( flags & SRF_SINGLE _BLESS ) ! = 0 )
if ( ( flags & MAT_ SRF_BLESS) ! = 0 )
BlessTupleDesc ( stored_tupdesc ) ;
BlessTupleDesc ( stored_tupdesc ) ;
random_access = ( rsinfo - > allowedModes & SFRM_Materialize_Random ) ! = 0 ;
random_access = ( rsinfo - > allowedModes & SFRM_Materialize_Random ) ! = 0 ;