From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kovacs Zoltan <kovacsz(at)pc10(dot)radnoti-szeged(dot)sulinet(dot)hu> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: bug (?) with RULEs with WHERE |
Date: | 2001-10-27 18:04:02 |
Message-ID: | 3033.1004205842@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Kovacs Zoltan <kovacsz(at)pc10(dot)radnoti-szeged(dot)sulinet(dot)hu> writes:
> foo=# CREATE TABLE a(foo integer);
> CREATE
> foo=# CREATE TABLE b(foo integer);
> CREATE
> foo=# CREATE VIEW c AS SELECT foo FROM a;
> CREATE
> foo=# CREATE RULE d AS ON INSERT TO c WHERE new.foo=5 DO INSTEAD SELECT foo FROM b;
> CREATE
> foo=# INSERT INTO c VALUES (5);
> ERROR: Cannot insert into a view without an appropriate rule
You didn't provide a rule covering the new.foo<>5 case.
In practice, you *must* have an unconditional INSTEAD rule present for
any view operation you want to allow. It can be DO INSTEAD NOTHING,
and then you can do all your useful work in conditional rules, but the
unconditional rule must be there. Else the system thinks that perhaps
the insert into the view would really happen.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2001-10-27 18:56:31 | Re: HISTORY file |
Previous Message | Peter Eisentraut | 2001-10-27 17:44:05 | HISTORY file |