Re: BUG #13798: Unexpected multiple exection of user defined function with out parameters

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: mike(dot)lang1010(at)gmail(dot)com
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13798: Unexpected multiple exection of user defined function with out parameters
Date: 2015-12-08 16:16:04
Message-ID: CAKFQuwax1S+kJ0X-h=Buu+iDhuXg6eh-Mgat2irrRhNUrmfGug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Dec 4, 2015 at 11:30 PM, <mike(dot)lang1010(at)gmail(dot)com> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 13798
> Logged by: Michael Lang
> Email address: mike(dot)lang1010(at)gmail(dot)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?

​Yes, it is.

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

​(i think...)​
​SELECT *​
​FROM src
LATERAL func_call(src.col);​

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.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2015-12-08 16:24:39 Re: BUG #13798: Unexpected multiple exection of user defined function with out parameters
Previous Message Michael Lang 2015-12-08 16:10:17 Re: BUG #13799: Unexpected multiple exection of user defined function with out parameters