Re: select (fn()).* executes function multiple times - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: select (fn()).* executes function multiple times
Date
Msg-id CAKFQuwbq=7xHuav_z6ET6=SALxcwi2UBHAt1u6XfUAsPYUDo3A@mail.gmail.com
Whole thread Raw
In response to select (fn()).* executes function multiple times  (Andrey <parihaaraka@gmail.com>)
List pgsql-bugs
On Fri, Nov 16, 2018 at 7:49 AM Andrey <parihaaraka@gmail.com> wrote:
> perform (fn_ret_test()).*;

Yes it does [execute fn_ret_rest multiple times]; its known behavior
that while surprising is unlikely to get fixed.  Its simple to work
around using the LATERAL construct (i.e., placing said function call
in the FROM clause).

The root problem is the use of ".*" - the rewriter turns it into:
SELECT fn_ret_test.f1(), fn_ret_test().f2, fn_ret_test().f3; which
when written this way become evident why it is executed multiple
times.

David J.


pgsql-bugs by date:

Previous
From: Andrey
Date:
Subject: select (fn()).* executes function multiple times
Next
From: Tom Lane
Date:
Subject: Re: select (fn()).* executes function multiple times