From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: todoubaba@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16856: Crash when add "_RETURN" rule on child table
Date: Sat, 06 Feb 2021 12:20:25 -0500
Message-ID: <191747.1612632025@sss.pgh.pa.us> (raw)
In-Reply-To: <YB6QA1T0X//P+99P@paquier.xyz>
References: <16856-0363e05c6e1612fd@postgresql.org>
<YB6QA1T0X//P+99P@paquier.xyz>
Michael Paquier <michael@paquier.xyz> writes:
> On Sat, Feb 06, 2021 at 07:46:14AM +0000, PG Bug reporting form wrote:
>> create table parent(a text);
>> create table child() inherits (parent);
>> create or replace rule "_RETURN" as
>> on select
>> to child
>> do instead
>> select *
>> from (values('x')) as t(a);
>>
>> select * from parent;
> Yes, reproduced here. This crashes as the relcache entry of the child
> relation is not getting its rd_tableam initialized.
I don't think it's unreasonable for the code to assume that child
relations are tables and not views. If you did the equivalent
regression=# create table parent(a text);
CREATE TABLE
regression=# create view child as select *
regression-# from (values('x')) as t(a);
CREATE VIEW
regression=# alter table child inherit parent;
ERROR: "child" is not a table or foreign table
or for that matter
regression=# alter table parent inherit child;
ERROR: "child" is not a table or foreign table
So my take is that this is an oversight in the CREATE RULE logic
that allows converting a table to a view: if it has inheritance
parents or children we must disallow doing that.
I'd be inclined to back-patch further than 12, too. Even if
there's not an obvious instant crash in those branches, it's
unlikely that their behavior is entirely sane.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, michael@paquier.xyz, todoubaba@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16856: Crash when add "_RETURN" rule on child table
In-Reply-To: <191747.1612632025@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox