Re: BUG #13798: Unexpected multiple exection of user defined function with out parameters - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #13798: Unexpected multiple exection of user defined function with out parameters
Date
Msg-id CAKFQuwax1S+kJ0X-h=Buu+iDhuXg6eh-Mgat2irrRhNUrmfGug@mail.gmail.com
Whole thread Raw
In response to BUG #13798: Unexpected multiple exection of user defined function with out parameters  (mike.lang1010@gmail.com)
List pgsql-bugs
On Fri, Dec 4, 2015 at 11:30 PM, <mike.lang1010@gmail.com> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      13798
> Logged by:          Michael Lang
> Email address:      mike.lang1010@gmail.com
> PostgreSQL version: 9.4.5
> Operating system:   Ubuntu 12.04
> Description:
>
> I've found that when a user defined function has
> out parameters, it is invoked once per out parameter if invoked with the
> syntax:
>
> `SELECT (udf()).*`
>
> Is this the expected behavior?


=E2=80=8BYes, it is.

Using the recently introduced "LATERAL" feature is the preferred method.

=E2=80=8B(i think...)=E2=80=8B
=E2=80=8BSELECT *=E2=80=8B
=E2=80=8BFROM src
LATERAL func_call(src.col);=E2=80=8B

If that is not possible you can use a CTE.

WITH func_cte AS (
SELECT function_call(...)  --do not expand this yet; pass it out as a
composite
)
SELECT (func_cte.function_call).*  --now we expand the composite; not the
unusual parens - they are required.
FROM func_cte;

David J.

pgsql-bugs by date:

Previous
From: Kevin Grittner
Date:
Subject: Re: BUG #13798: Unexpected multiple exection of user defined function with out parameters
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #13798: Unexpected multiple exection of user defined function with out parameters