pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: drtr0jan@yandex.ru
Subject: BUG #18812: Conditional rule: inconsistent check for statement
Date: Fri, 14 Feb 2025 21:00:09 +0000
Message-ID: <18812-565809b4823e2b68@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      18812
Logged by:          Boris Korzun
Email address:      drtr0jan@yandex.ru
PostgreSQL version: 17.2
Operating system:   FreeBSD 14-stable
Description:        

Conditional rule checks underlying table for the types ignoring the
statement.

-----
CREATE TABLE t
(
    c varchar(10) NOT NULL
);

CREATE VIEW v AS
SELECT NULL::text AS c
FROM t;

CREATE RULE "insert" AS ON INSERT TO v
    WHERE FALSE
    DO INSTEAD
    INSERT INTO t (c)
    VALUES (new.c);

CREATE RULE "skip" AS ON INSERT TO v DO INSTEAD NOTHING;
-----

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.

-----
INSERT INTO v (c) VALUES ('testtesttest');
-----
[22001] ERROR: value too long for type character varying(10)
-----

Why? It seems like a bug.



view thread (3+ messages)  latest in thread

Message-ID: <18812-565809b4823e2b68@postgresql.org>
Permalink:  ../18812-565809b4823e2b68@postgresql.org/
Also on:    postgresql.org/message-id/18812-565809b4823e2b68@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, drtr0jan@yandex.ru
  Subject: Re: BUG #18812: Conditional rule: inconsistent check for statement
  In-Reply-To: <18812-565809b4823e2b68@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox