From: Justin Pryzby <pryzby@telsasoft.com>
To: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: MERGE and parsing with prepared statements
Date: Fri, 15 Jul 2022 12:58:54 -0500
Message-ID: <20220715175854.GM18011@telsasoft.com> (raw)
In-Reply-To: <CAEze2WgUBfXK+VJ_oKacgEmpEfXiOHELm7nesTOXmfn_rJE=Ow@mail.gmail.com>
References: <20220714162618.GH18011@telsasoft.com>
<CAEze2WgUBfXK+VJ_oKacgEmpEfXiOHELm7nesTOXmfn_rJE=Ow@mail.gmail.com>
On Fri, Jul 15, 2022 at 11:25:35AM +0200, Matthias van de Meent wrote:
> On Thu, 14 Jul 2022, 18:26 Justin Pryzby, <pryzby@telsasoft.com> wrote:
> >
> > Why is $1 construed to be of type text ?
>
> The select statement that generates the row type of T `(select $1 CID,
> $2 TxV) AS T` does not put type bounds on the input parameters, so it
> remains `unknown` for the scope of that subselect. Once stored into
> the row type, the type of that column defaults to text, as a row type
> should not have 'unknown'-typed columns.
Thanks for looking into it.
I see now that the same thing can happen with "ON CONFLICT" if used with a
subselect.
PREPARE p AS INSERT INTO t SELECT a FROM (SELECT $1 AS a)a
ON CONFLICT (i) DO UPDATE SET i=excluded.i;
ERROR: column "i" is of type integer but expression is of type text
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).
--
Justin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: pryzby@telsasoft.com, boekewurm+postgres@gmail.com, alvherre@alvh.no-ip.org
Subject: Re: MERGE and parsing with prepared statements
In-Reply-To: <20220715175854.GM18011@telsasoft.com>
References: <20220714162618.GH18011@telsasoft.com> <CAEze2WgUBfXK+VJ_oKacgEmpEfXiOHELm7nesTOXmfn_rJE=Ow@mail.gmail.com> <20220715175854.GM18011@telsasoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox