From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: tomas@tuxteam.de, Дмитрий Иванов <firstdismay@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: PQexecParams, placeholders and variable lists of params
Date: Tue, 23 Nov 2021 10:43:03 -0500
Message-ID: <4176869.1637682183@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbjD0jokC3WBJ-TcCXtXuW=pHDknZOKSBQ2tLtVm+um7w@mail.gmail.com>
References: <YZzSa7qRtgg/+oLL@tuxteam.de>
<CAPL5KHofiPEWqHx7a68pHAK=mOVSN8v1H8WnzghHPDJcWR3y3w@mail.gmail.com>
<YZz4ySpB8OMYjAEz@tuxteam.de>
<CAKFQuwbjD0jokC3WBJ-TcCXtXuW=pHDknZOKSBQ2tLtVm+um7w@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Tue, Nov 23, 2021 at 7:21 AM <tomas@tuxteam.de> wrote:
>> Makes sense. Problem is, that, again, the application would be
>> responsible of making sure the individual values don't contain nasty
>> stuff (for example, if they are strings) before consolidating them to
>> one PostgreSQL array literal.
> So long as you actually pass the literal value via a parameter the worst
> problem you can have is a syntax error in converting the literal into
> whatever type is being cast to.
PG's array quoting rules are odd enough that I can sympathize with not
wanting to deal with them. (Although, if you only have to build an
array and not parse one, taking the always-quote-even-if-not-necessary
approach makes it easier.)
I don't see many other alternatives though. *Somehow* you have to
separate one value from the next. If you don't want to pass 'em as
distinct parameters, then you have to obey some kind of composite-value
syntax.
regards, tom lane
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-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, firstdismay@gmail.com
Subject: Re: PQexecParams, placeholders and variable lists of params
In-Reply-To: <4176869.1637682183@sss.pgh.pa.us>
References: <YZzSa7qRtgg/+oLL@tuxteam.de> <CAPL5KHofiPEWqHx7a68pHAK=mOVSN8v1H8WnzghHPDJcWR3y3w@mail.gmail.com> <YZz4ySpB8OMYjAEz@tuxteam.de> <CAKFQuwbjD0jokC3WBJ-TcCXtXuW=pHDknZOKSBQ2tLtVm+um7w@mail.gmail.com> <4176869.1637682183@sss.pgh.pa.us>
* 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