Re: right way of using case-expressions in plpgsql functions - Mailing list pgsql-general

From David G. Johnston
Subject Re: right way of using case-expressions in plpgsql functions
Date
Msg-id CAKFQuwbb4_XaC4PxVJEP+L8zWKFuBNRfz7+rQhub4TozcAjMBQ@mail.gmail.com
Whole thread Raw
In response to right way of using case-expressions in plpgsql functions  (Victor Dobrovolsky <booby.stager@gmail.com>)
Responses Re: right way of using case-expressions in plpgsql functions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Sunday, October 15, 2023, Victor Dobrovolsky <booby.stager@gmail.com> wrote:

select (case when px is not null then pf = px
        else pf is not distinct from py
end);


Every single time this function is called “px is not null” will be evaluated and then one of the two branches will be evaluated.  Nothing the optimizer does will change that.  The planner for the function internals does not know whether px will or will not be null on any given invocation.

David J.

pgsql-general by date:

Previous
From: Victor Dobrovolsky
Date:
Subject: right way of using case-expressions in plpgsql functions
Next
From: Tom Lane
Date:
Subject: Re: right way of using case-expressions in plpgsql functions