Set Returning Functions and array_agg() - Mailing list pgsql-general

From Stephen Scheck
Subject Set Returning Functions and array_agg()
Date
Msg-id CAKjnHz2FxGKqGRj7BNVfFTt-kxKSLGakK3xnurKRHHk3-GxkEg@mail.gmail.com
Whole thread Raw
Responses Re: Set Returning Functions and array_agg()
List pgsql-general
Hi,

I have a UDF (written in C) that returns SETOF RECORD of an anonymous record type
(defined via OUT parameters). I'm trying to use array_agg() to transform its output to
an array:

pg_dev=# SELECT array_agg((my_setof_record_returning_func()).col1);
ERROR:  set-valued function called in context that cannot accept a set

Or the alternate syntax:

pg_dev=# SELECT array_agg(col1(my_setof_record_returning_func()));
ERROR:  set-valued function called in context that cannot accept a set

Can somebody explain why I get the error message? Presumably the parser is deciding that
the expression provided to array_agg() is a set, based on my_setof_record_returning_func()'s
definition. But shouldn't the column selection (or equivalent column-as-func-call notation) supply
the expected context to array_agg()?

Thanks.

pgsql-general by date:

Previous
From: Daniel Cristian Cruz
Date:
Subject: Re: Memory usage after upgrade to 9.2.4
Next
From: Alexander Reichstadt
Date:
Subject: Re: DISTINCT ON changes sort order