Re: MERGE and parsing with prepared statements - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: MERGE and parsing with prepared statements
Date
Msg-id CAKFQuwbtQk52zWLYsXvO2+ZGTPu+MPvWgaCS7jQKuGhrwn0-rA@mail.gmail.com
Whole thread Raw
In response to Re: MERGE and parsing with prepared statements  (Justin Pryzby <pryzby@telsasoft.com>)
Responses Re: MERGE and parsing with prepared statements
List pgsql-hackers
On Fri, Jul 15, 2022 at 11:40 AM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2022-Jul-15, Justin Pryzby wrote:

> It seems a bit odd that it's impossible to use merge with prepared statements
> without specifically casting the source types (which I did now to continue my
> experiment).

I have no comments on this.  Maybe it can be improved, but I don't know
how.


Not tested, but the example prepare command fails to make use of the optional data types specification.  Using that should remove the need to cast the parameter placeholder within the query itself.

That said, in theory the INSERT specification of the MERGE could be used to either resolve unknowns or even forcibly convert the data types of the relation produced by the USING clause to match the actual types required for the INSERT (since that will happen at insert time anyway).  This would make the UPDATE behavior slightly different than a top-level UPDATE command though, since that does not have the same context information.

David J.

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: MERGE and parsing with prepared statements
Next
From: "David G. Johnston"
Date:
Subject: Re: Move Section 9.27.7 (Data Object Management Functions) to System Information Chapter