pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: tomas@tuxteam.de
To: Дмитрий Иванов <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 15:20:57 +0100
Message-ID: <YZz4ySpB8OMYjAEz@tuxteam.de> (raw)
In-Reply-To: <CAPL5KHofiPEWqHx7a68pHAK=mOVSN8v1H8WnzghHPDJcWR3y3w@mail.gmail.com>
References: <YZzSa7qRtgg/+oLL@tuxteam.de>
	<CAPL5KHofiPEWqHx7a68pHAK=mOVSN8v1H8WnzghHPDJcWR3y3w@mail.gmail.com>

On Tue, Nov 23, 2021 at 06:39:27PM +0500, Дмитрий Иванов wrote:
> Hi
> A function cannot have an undefined signature, but can accept an array of
> arguments:

I see. So you propose passing an array as a single param to
PQexecParams, in PostgreSQL's syntax for arrays, e.g.. "{42, 45, 50}".

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.

I was hoping to get away "on the cheap" on this, letting PostgreSQL take
care of the injection avoidance ;-)

I'm converging in building the query dynamically, but still with
placeholders. I /know/ how many values are coming, and how many
placeholders used so-far in the query, so it'd be fairly easy to just
insert "$m"..."$n" as needed.

Thanks a lot, Dmitri

Cheers
 - t

Attachments:

  signature.asc (application/pgp-signature, 194B) download

view thread (8+ messages)  latest in thread

Message-ID: <YZz4ySpB8OMYjAEz@tuxteam.de>
Permalink:  ../YZz4ySpB8OMYjAEz@tuxteam.de/
Also on:    postgresql.org/message-id/YZz4ySpB8OMYjAEz@tuxteam.de

 · 

reply

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: tomas@tuxteam.de, firstdismay@gmail.com
  Subject: Re: PQexecParams, placeholders and variable lists of params
  In-Reply-To: <YZz4ySpB8OMYjAEz@tuxteam.de>
  References: <YZzSa7qRtgg/+oLL@tuxteam.de> <CAPL5KHofiPEWqHx7a68pHAK=mOVSN8v1H8WnzghHPDJcWR3y3w@mail.gmail.com> <YZz4ySpB8OMYjAEz@tuxteam.de>

* 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