Re: [Bug] SELECT INSTEAD with sub-query - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [Bug] SELECT INSTEAD with sub-query
Date
Msg-id 29751.1350958024@sss.pgh.pa.us
Whole thread Raw
In response to [Bug] SELECT INSTEAD with sub-query  (Kohei KaiGai <kaigai@kaigai.gr.jp>)
List pgsql-hackers
Kohei KaiGai <kaigai@kaigai.gr.jp> writes:
> postgres=# CREATE TABLE t1 (x int, y text);
> CREATE TABLE

> postgres=# CREATE RULE "_RETURN" AS ON SELECT TO t1 DO INSTEAD SELECT
> 1 AS x, 'aaa'::text AS y;
> CREATE RULE

> postgres=# SELECT * FROM t1;
>  x |  y
> ---+-----
>  1 | aaa
> (1 row)

> postgres=# SELECT tableoid, * FROM t1;
> TRAP: FailedAssertion("!(attno >= rel->min_attr && attno <=
> rel->max_attr)", File: "initsplan.c", Line: 180)

Huh.  I'm amazed nobody noticed this before.  It's really a bug in the
"convert table to view" logic: a view has no system columns so we ought
to remove the pg_attribute entries for the system columns, but we don't.

Given that we can't retroactively fix the pg_attribute rows for existing
views, I guess that we'll also have to put in a defense in the parser to
not believe that views have any system columns, even if pg_attribute
claims they do.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: [RFC] CREATE QUEUE (log-only table) for londiste/pgQ ccompatibility
Next
From: Daniel Farina
Date:
Subject: Re: Successor of MD5 authentication, let's use SCRAM