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

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ian Lawrence Barwick <barwick(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: "CREATE RULE ... ON SELECT": redundant?
Date: 2023-05-04 06:13:04
Message-ID: 87o7n0bpvh.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

Tom> Now, this is certainly syntax that's deprecated in favor of using
Tom> CREATE OR REPLACE VIEW, but I'm very hesitant to remove it. ISTR
Tom> that ancient pg_dump files used it in cases involving circular
Tom> dependencies.

I thought they used CREATE RULE on a table?

In fact here is an example from a pg 9.5 pg_dump output (with cruft
removed):

CREATE TABLE public.cdep (
a integer,
b text
);
CREATE FUNCTION public.cdep_impl() RETURNS SETOF public.cdep
LANGUAGE plpgsql
AS $$ begin return query select a,b from (values (1,'foo'),(2,'bar')) v(a,b); end; $$;
CREATE RULE "_RETURN" AS
ON SELECT TO public.cdep DO INSTEAD SELECT cdep_impl.a,
cdep_impl.b
FROM public.cdep_impl() cdep_impl(a, b);

and this now fails to restore:

psql:t1.sql:68: ERROR: relation "cdep" cannot have ON SELECT rules
DETAIL: This operation is not supported for tables.

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2023-05-04 06:20:46 Re: "CREATE RULE ... ON SELECT": redundant?
Previous Message Drouvot, Bertrand 2023-05-04 05:46:04 Re: Add two missing tests in 035_standby_logical_decoding.pl