From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Ian Lawrence Barwick <barwick(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: "CREATE RULE ... ON SELECT": redundant? |
Date: | 2023-05-04 03:51:30 |
Message-ID: | 3063372.1683172290@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Ian Lawrence Barwick <barwick(at)gmail(dot)com> writes:
> While poking around at an update for that, unless I'm missing something it is
> now not possible to use "CREATE RULE ... ON SELECT" for any kind of relation,
> given that it's disallowed on views / material views already.
What makes you think it's disallowed on views? You do need to use
CREATE OR REPLACE, since the rule will already exist.
regression=# create view v as select * from int8_tbl ;
CREATE VIEW
regression=# create or replace rule "_RETURN" as on select to v do instead select q1, q2+1 as q2 from int8_tbl ;
CREATE RULE
regression=# \d+ v
View "public.v"
Column | Type | Collation | Nullable | Default | Storage | Description
--------+--------+-----------+----------+---------+---------+-------------
q1 | bigint | | | | plain |
q2 | bigint | | | | plain |
View definition:
SELECT int8_tbl.q1,
int8_tbl.q2 + 1 AS q2
FROM int8_tbl;
Now, this is certainly syntax that's deprecated in favor of using
CREATE OR REPLACE VIEW, but I'm very hesitant to remove it. ISTR
that ancient pg_dump files used it in cases involving circular
dependencies. If you want to adjust the docs to say that it's
deprecated in favor of CREATE OR REPLACE VIEW, I could get on
board with that.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Hayato Kuroda (Fujitsu) | 2023-05-04 04:03:55 | RE: [PoC] pg_upgrade: allow to upgrade publisher node |
Previous Message | Ian Lawrence Barwick | 2023-05-04 03:39:17 | "CREATE RULE ... ON SELECT": redundant? |