Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okRqc-0001wP-Sb for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Oct 2022 15:16:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1okRqa-0002PE-NW for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Oct 2022 15:16:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okRqa-0002P5-FK for pgsql-bugs@lists.postgresql.org; Mon, 17 Oct 2022 15:16:08 +0000 Received: from carbon.misis.ru ([85.143.104.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okRqS-0001Di-QP for pgsql-bugs@lists.postgresql.org; Mon, 17 Oct 2022 15:16:07 +0000 Received: from mail.tzirechnoy.ru (unknown [10.1.250.11]) by carbon.misis.ru (Postfix) with ESMTP id 337B820054 for ; Mon, 17 Oct 2022 18:15:57 +0300 (MSK) Received: by mail.tzirechnoy.ru (Postfix, from userid 1000) id D345CA42B1; Mon, 17 Oct 2022 18:15:57 +0300 (MSK) Date: Mon, 17 Oct 2022 18:15:57 +0300 From: Ilya Anfimov To: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17646: create rule named "_RETURN" will cause pg core Message-ID: <20221017151557.GA3907605@azor.tzirechnoy.ru> Mail-Followup-To: Ilya Anfimov , pgsql-bugs@lists.postgresql.org References: <17646-70c93cfa40365776@postgresql.org> <2164336.1666016275@sss.pgh.pa.us> <20221017143338.GA3864491@azor.tzirechnoy.ru> <2173460.1666017695@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2173460.1666017695@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spamd-Result: default: False [0.00 / 15.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2] X-Rspamd-Queue-Id: 337B820054 X-Rspamd-Server: carbon List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Oct 17, 2022 at 10:41:35AM -0400, Tom Lane wrote: > Ilya Anfimov 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 <>