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