[Bug] SELECT INSTEAD with sub-query

From: Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>
To: PgHacker <pgsql-hackers(at)postgresql(dot)org>
Subject: [Bug] SELECT INSTEAD with sub-query
Date: 2012-10-22 21:05:25
Message-ID: CADyhKSUWa8wqWXTH59_NRj3a=nSooAnHJhmB_e+yS+RSC+=x1A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I could find out a case to cause Assert() failure during investigation of RLS...

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)
The connection to the server was lost. Attempting reset: LOG: server
process (PID 27345) was terminated by signal 6: Aborted
DETAIL: Failed process was running: SELECT tableoid, * FROM t1;

The failure scenario is obvious. Reference to "t1" was replaced by a sub-query
that does not have any system columns, however, the given query tries to the
column with negative attribute number. Then, it was caught on the
FailedAssertion.
How do we fix the problem? Please give us some comments.

Thanks,
--
KaiGai Kohei <kaigai(at)kaigai(dot)gr(dot)jp>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2012-10-22 21:29:21 Re: [v9.3] Extra Daemons (Re: elegant and effective way for running jobs inside a database)
Previous Message Kohei KaiGai 2012-10-22 20:54:50 Re: [v9.3] Row-Level Security