Re: BUG #18812: Conditional rule: inconsistent check for statement - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18812: Conditional rule: inconsistent check for statement
Date
Msg-id 3914796.1739573714@sss.pgh.pa.us
Whole thread Raw
In response to BUG #18812: Conditional rule: inconsistent check for statement  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18812: Conditional rule: inconsistent check for statement
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.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.

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.

            regards, tom lane



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18812: Conditional rule: inconsistent check for statement
Next
From: PG Bug reporting form
Date:
Subject: BUG #18813: Materialized view creation regression when inlining recursive SQL function