pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ilya Anfimov <ilan@tzirechnoy.com>
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17646: create rule named "_RETURN" will cause pg core
Date: Mon, 17 Oct 2022 18:15:57 +0300
Message-ID: <20221017151557.GA3907605@azor.tzirechnoy.ru> (raw)
In-Reply-To: <2173460.1666017695@sss.pgh.pa.us>
References: <17646-70c93cfa40365776@postgresql.org>
	<2164336.1666016275@sss.pgh.pa.us>
	<20221017143338.GA3864491@azor.tzirechnoy.ru>
	<2173460.1666017695@sss.pgh.pa.us>

On Mon, Oct 17, 2022 at 10:41:35AM -0400, Tom Lane wrote:
> Ilya Anfimov <ilan@tzirechnoy.com> writes:
> > On Mon, Oct 17, 2022 at 10:17:55AM -0400, Tom Lane wrote:
> >> (Although the core dump is also not great --- something should've noticed
> >> the bogosity of the plan earlier than this.)
> 
> >  Id doesn't look much of a plan bogosity,
> > but rather implicit deletion of the "_RETURN" on select rule.
> 
> Right, but then since there's no applicable rule, we end up generating
> a plan that tries to do a seqscan directly on the view relation,
> which of course lacks storage.  Something should notice that a little
> sooner than segfaulting because of rel->rd_tableam being NULL --- it's
> not like we don't have hundreds of other sanity checks for not-really-
> supposed-to-happen catalog corruption.
> 
> In versions before v12, I get something like
> 
> regression=# select * from v1;
> ERROR:  could not open file "base/16384/49209": No such file or directory
> 
> which is a shade less bad, but still not great.

 Another  solution  would  be  to always create a real heap file and let
anyone dropped to that state select it, if he wishes.

btw, the documentation clearly says that it does so:
https://www.postgresql.org/docs/14/rules-views.html

<<In fact, there is essentially no difference between:

CREATE VIEW myview AS SELECT * FROM mytab;
compared against the two commands:

CREATE TABLE myview (same column list as mytab);
CREATE RULE "_RETURN" AS ON SELECT TO myview DO INSTEAD
    SELECT * FROM mytab;
because this is exactly what the CREATE VIEW command does internally. >>






view thread (6+ messages)

Message-ID: <20221017151557.GA3907605@azor.tzirechnoy.ru>
Permalink:  ../20221017151557.GA3907605@azor.tzirechnoy.ru/
Also on:    postgresql.org/message-id/20221017151557.GA3907605@azor.tzirechnoy.ru

 · 

reply

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: ilan@tzirechnoy.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17646: create rule named "_RETURN" will cause pg core
  In-Reply-To: <20221017151557.GA3907605@azor.tzirechnoy.ru>

* 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