Re: "CREATE RULE ... ON SELECT": redundant? - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: "CREATE RULE ... ON SELECT": redundant?
Date
Msg-id 87o7n0bpvh.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: "CREATE RULE ... ON SELECT": redundant?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: "CREATE RULE ... ON SELECT": redundant?
List pgsql-hackers
>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.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)



pgsql-hackers by date:

Previous
From: "Drouvot, Bertrand"
Date:
Subject: Re: Add two missing tests in 035_standby_logical_decoding.pl
Next
From: Andrew Gierth
Date:
Subject: Re: "CREATE RULE ... ON SELECT": redundant?