Re: "CREATE RULE ... ON SELECT": redundant?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: "CREATE RULE ... ON SELECT": redundant?
Дата
Msg-id 3063372.1683172290@sss.pgh.pa.us
обсуждение исходный текст
Ответ на "CREATE RULE ... ON SELECT": redundant?  (Ian Lawrence Barwick <barwick@gmail.com>)
Ответы Re: "CREATE RULE ... ON SELECT": redundant?  (Ian Lawrence Barwick <barwick@gmail.com>)
Re: "CREATE RULE ... ON SELECT": redundant?  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список pgsql-hackers
Ian Lawrence Barwick <barwick@gmail.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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Ian Lawrence Barwick
Дата:
Сообщение: "CREATE RULE ... ON SELECT": redundant?
Следующее
От: "Hayato Kuroda (Fujitsu)"
Дата:
Сообщение: RE: [PoC] pg_upgrade: allow to upgrade publisher node