BUG #2779: Making an inherited table to a view causes could not open relation error in base table

Started by Sven Klemmover 19 years ago4 messagesbugs
Jump to latest
#1Sven Klemm
sven@c3d2.de

The following bug has been logged online:

Bug reference: 2779
Logged by: Sven Klemm
Email address: sven@c3d2.de
PostgreSQL version: 8.1
Operating system: Linux (Debian)
Description: Making an inherited table to a view causes could not
open relation error in base table
Details:

Steps to reproduce:

CREATE TABLE base( name TEXT );
CREATE TABLE child() INHERITS( base );

CREATE RULE "_RETURN" AS ON SELECT TO child DO INSTEAD SELECT 'Chunky
Bacon'::text AS name;

SELECT * FROM child;
SELECT * FROM ONLY base;
-- the next query causes the error
SELECT * FROM base;

After dropping child queries to base work again.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Sven Klemm (#1)
Re: BUG #2779: Making an inherited table to a view causes could not open relation error in base table

"Sven Klemm" <sven@c3d2.de> writes:

CREATE TABLE base( name TEXT );
CREATE TABLE child() INHERITS( base );

CREATE RULE "_RETURN" AS ON SELECT TO child DO INSTEAD SELECT 'Chunky
Bacon'::text AS name;

This is definitely in the category of "don't do that". It's an
oversight that DefineQueryRewrite() doesn't check for the case.

Actually, I wonder whether we still need to support conversion of
tables to views at all. That was never meant as anything but a
temporary hack to allow loading pre-7.1 pg_dump scripts.

regards, tom lane

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#2)
Re: BUG #2779: Making an inherited table to a view causes could not open relation error in base table

Tom Lane wrote:

"Sven Klemm" <sven@c3d2.de> writes:

CREATE TABLE base( name TEXT );
CREATE TABLE child() INHERITS( base );

CREATE RULE "_RETURN" AS ON SELECT TO child DO INSTEAD SELECT 'Chunky
Bacon'::text AS name;

This is definitely in the category of "don't do that". It's an
oversight that DefineQueryRewrite() doesn't check for the case.

Actually, I wonder whether we still need to support conversion of
tables to views at all. That was never meant as anything but a
temporary hack to allow loading pre-7.1 pg_dump scripts.

IIRC I tried it when I was reviewing the updatable views patch, and it
worked.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#3)
Re: BUG #2779: Making an inherited table to a view causes could not open relation error in base table

Alvaro Herrera <alvherre@commandprompt.com> writes:

Tom Lane wrote:

Actually, I wonder whether we still need to support conversion of
tables to views at all. That was never meant as anything but a
temporary hack to allow loading pre-7.1 pg_dump scripts.

IIRC I tried it when I was reviewing the updatable views patch, and it
worked.

Well, yeah, it still works for the cases it was intended to work for.
What I'm wondering is what other weird corner cases might need to be
forbidden to keep it secure against people who are looking for ways
to break it.

regards, tom lane