Re: PostgreSQL 10 changes in exclusion constraints - did something change? CASE WHEN behavior oddity

From: "Regina Obe" <lr(at)pcorp(dot)us>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'PostgreSQL-development'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PostgreSQL 10 changes in exclusion constraints - did something change? CASE WHEN behavior oddity
Date: 2017-05-26 19:14:37
Message-ID: 000c01d2d654$518f2be0$f4ad83a0$@pcorp.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> "Regina Obe" <lr(at)pcorp(dot)us> writes:
>> I figured out the culprit was the change in CASE WHEN behavior with
>> set returning functions Had a criteria something of the form:
>> CASE WHEN some_condition_dependent_on_sometable_that_resolves_to_false
>> THEN (regexp_matches(...))[1] ELSE ... END FROM sometable;

> You might want to consider changing such usages to use regexp_match()
instead of regexp_matches().

> regards, tom lane

Thanks. I ended up swapping out with substring which was a bit shorter than
regexp_match()[].

But I've got similar problems with PostGIS topology logic and the easiest
change to make was take advantage
of the fact that you guys are treating CASE constant ... THEN SRF ...

Differently

Than

CASE not_constant_based_on_table_value THEN SRF ..

So I switched those to constant checks. This feels a little dirty and
fragile to me though.

Is this behavior going to stay or change?

It seems inconsistent from a user perspective that

CASE constant .... == short-circuit skipping over SRFs that may otherwise
fail

While

CASE not_constant_table_dependent doesn't short-circuit.

I can understand the motive behind it, it just feels a little inconsistent
from an end-user POV.

Thanks,
Regina

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-05-26 19:20:46 Re: Renaming a table to an array's autogenerated name
Previous Message Jeff Janes 2017-05-26 19:07:50 Re: logical replication - still unstable after all these months