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 1mnNsi-0001OM-6m for pgsql-bugs@arkaria.postgresql.org; Wed, 17 Nov 2021 16:33:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mnNsh-0007ES-3W for pgsql-bugs@arkaria.postgresql.org; Wed, 17 Nov 2021 16:33:55 +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 1mnNsg-0007EJ-RV for pgsql-bugs@lists.postgresql.org; Wed, 17 Nov 2021 16:33:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mnNsc-0004e3-Gj for pgsql-bugs@lists.postgresql.org; Wed, 17 Nov 2021 16:33:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1AHGXllU2520162; Wed, 17 Nov 2021 11:33:47 -0500 From: Tom Lane To: Masahiko Sawada cc: Erki Eessaar , "pgsql-bugs@lists.postgresql.org" , Peter Eisentraut Subject: Re: References to parameters by name are lost in INSERT INTO ... SELECT .... statements in case of routines with the SQL-standard function body In-reply-to: References: <2345766.1637099577@sss.pgh.pa.us> Comments: In-reply-to Masahiko Sawada message dated "Wed, 17 Nov 2021 10:06:15 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2520160.1637166827.1@sss.pgh.pa.us> Date: Wed, 17 Nov 2021 11:33:47 -0500 Message-ID: <2520161.1637166827@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Masahiko Sawada writes: > On Wed, Nov 17, 2021 at 6:52 AM Tom Lane wrote: >> Yeah, it's weird that the same parameter is printed two different ways. >> I dug into it and found out that we're losing the "context->namespace" >> list when recursing into the sub-SELECT from get_insert_query_def. >> The fix is trivial (attached). The other places where get_query_def is >> invoked quasi-recursively all pass down the parent namespace list already. >> The fact that this one is out of step is a very ancient oversight (it's >> at least old enough to vote, according to some quick git archaeology). >> But as far as I can see, it didn't have any visible consequences until >> commit e717a9a18 taught get_parameter() to pay attention to the last >> entry of the list. So I'm inclined not to change it before v14. > Agreed. I've confirmed by the attached test that the patch fixes this issue. Pushed, thanks for writing the test case. regards, tom lane