Re: PQexecParams, placeholders and variable lists of params - Mailing list pgsql-general

From tomas@tuxteam.de
Subject Re: PQexecParams, placeholders and variable lists of params
Date
Msg-id YZz4ySpB8OMYjAEz@tuxteam.de
Whole thread Raw
In response to Re: PQexecParams, placeholders and variable lists of params  (Дмитрий Иванов <firstdismay@gmail.com>)
Responses Re: PQexecParams, placeholders and variable lists of params  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
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

Attachment

pgsql-general by date:

Previous
From:
Date:
Subject: Re: Regex for Word space Word space Word ....
Next
From: "David G. Johnston"
Date:
Subject: Re: Regex for Word space Word space Word ....