Re: right way of using case-expressions in plpgsql functions

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Victor Dobrovolsky <booby(dot)stager(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: right way of using case-expressions in plpgsql functions
Date: 2023-10-15 16:37:49
Message-ID: CAKFQuwbb4_XaC4PxVJEP+L8zWKFuBNRfz7+rQhub4TozcAjMBQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sunday, October 15, 2023, Victor Dobrovolsky <booby(dot)stager(at)gmail(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2023-10-15 17:08:16 Re: right way of using case-expressions in plpgsql functions
Previous Message Victor Dobrovolsky 2023-10-15 16:19:57 right way of using case-expressions in plpgsql functions