Re: select (fn()).* executes function multiple times

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: parihaaraka(at)gmail(dot)com
Cc: Postgres Bug <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: select (fn()).* executes function multiple times
Date: 2018-11-16 14:57:22
Message-ID: CAKFQuwbq=7xHuav_z6ET6=SALxcwi2UBHAt1u6XfUAsPYUDo3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Nov 16, 2018 at 7:49 AM Andrey <parihaaraka(at)gmail(dot)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.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-11-16 14:57:51 Re: select (fn()).* executes function multiple times
Previous Message Andrey 2018-11-16 14:49:35 select (fn()).* executes function multiple times