Re: References to parameters by name are lost in INSERT INTO ... SELECT <parameter value> .... statements in case of routines with the SQL-standard function body

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Erki Eessaar <erki(dot)eessaar(at)taltech(dot)ee>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Subject: Re: References to parameters by name are lost in INSERT INTO ... SELECT <parameter value> .... statements in case of routines with the SQL-standard function body
Date: 2021-11-17 16:33:47
Message-ID: 2520161.1637166827@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> writes:
> On Wed, Nov 17, 2021 at 6:52 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message James Johnston 2021-11-18 02:31:53 Extensions, policies, and pg_dump don't work together and result in duplicate policies
Previous Message Andrew Dunstan 2021-11-17 15:07:17 Re: pg_upgrade test for binary compatibility of core data types