Re: BUG #18812: Conditional rule: inconsistent check for statement

From: "Boris P(dot) Korzun" <drtr0jan(at)yandex(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18812: Conditional rule: inconsistent check for statement
Date: 2025-02-17 10:58:12
Message-ID: 29274cc1-26fa-4382-ae14-60e771d89699@yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Tom,

thanks for the fastest and exhaustive answer!

On 15/02/2025 01:55, Tom Lane wrote:
> We get variants of this complaint from time to time, but few of
> them present use-cases that seem compelling enough to justify the
> performance costs of not doing constant-folding.

I think it's the right decision! But...

On 15/02/2025 01:55, Tom Lane wrote:
> PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
>> I've two rules for a view - unconditional INSTEAD (skip) and conditional
>> INSTEAD (always FALSE). But if I trying to insert a type mismatched
data to
>> the view, I've got a type constraint error.
>
> [ shrug... ] The WHERE FALSE condition is evaluated later than it
> would need to be to prevent this error. If we use a value that
> doesn't trigger the error:
>
> =# explain verbose INSERT INTO v (c) VALUES ('testtest');
> QUERY PLAN
> ------------------------------------------------------
> Insert on public.t (cost=0.00..0.01 rows=0 width=0)
> -> Result (cost=0.00..0.01 rows=1 width=14)
> Output: 'testtest'::character varying(10)
> One-Time Filter: false
> (4 rows)
>
> we can see that the "false" is actually applied at runtime, but the
> value coercion happened during planner constant-folding. In general
> the order of application of WHERE clauses is not guaranteed, so
> there's not a good argument that this outcome is wrong.

What do you think about adding the behavior described above (undefined
behavior, generally) to the help?

---
WBR
Boris

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Raghu Dev Ramaiah 2025-02-17 12:19:04 issue with PSQL 17.1 on Suse 15 Linux SP6
Previous Message PG Bug reporting form 2025-02-17 10:52:32 BUG #18815: Logical replication worker Segmentation fault