Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h1DsI-00025y-F2 for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Mar 2019 17:29:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h1DsH-0008Ej-15 for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Mar 2019 17:29:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h1DsG-0008C5-EF for pgsql-bugs@lists.postgresql.org; Tue, 05 Mar 2019 17:29:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h1DsD-0000ZC-Ty for pgsql-bugs@lists.postgresql.org; Tue, 05 Mar 2019 17:29:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x25HSvja021483; Tue, 5 Mar 2019 12:28:57 -0500 From: Tom Lane To: Julien Rouhaud cc: thibaut.madelaine@dalibo.com, Robert Haas , PostgreSQL mailing lists Subject: Re: BUG #15669: Error with unnest in PG 11 (ERROR: 0A000) In-reply-to: References: <15669-02fb3296cca26203@postgresql.org> <19353.1551800347@sss.pgh.pa.us> Comments: In-reply-to Julien Rouhaud message dated "Tue, 05 Mar 2019 17:34:21 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21481.1551806937.1@sss.pgh.pa.us> Date: Tue, 05 Mar 2019 12:28:57 -0500 Message-ID: <21482.1551806937@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Julien Rouhaud writes: > On Tue, Mar 5, 2019 at 4:39 PM Tom Lane wrote: >> Hmm, that's definitely a bug. It looks like we're forgetting to make >> a ProjectSet plan node for the unnest() if we realize that the query >> is a no-op; but I'm not sure why 10.x doesn't have the same issue. >> Digging ... > It seems to be due to 11cf92f6e2e which bypass adjust_paths_for_srfs() > in case of dummy rel. I'm not familiar with that this code, but > attached patch seems to fix the issue without breaking regression > tests. Hm, yeah, that function is definitely a few bricks shy of a load. The amount of code it's bypassing for the dummy-rel case is pretty scary. While it doesn't look like anything except the SRF case is actively broken, there's a lot of room there for somebody to insert new code and not notice that they need to fix the dummy-rel path as well. Having to duplicate the adjust_paths_for_srfs call doesn't bode well for the future. I'm inclined to fix it by not having the early-return path, but rather if (is_dummy_rel) { // minimum possible amount of code here } else { // minimum possible amount of code here, too } // maximum possible amount of code here regards, tom lane