Re: PQexecParams, placeholders and variable lists of params

From: tomas(at)tuxteam(dot)de
To: Дмитрий Иванов <firstdismay(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: PQexecParams, placeholders and variable lists of params
Date: 2021-11-23 14:20:57
Message-ID: YZz4ySpB8OMYjAEz@tuxteam.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2021-11-23 15:31:16 Re: Regex for Word space Word space Word ....
Previous Message tomas 2021-11-23 13:53:58 Re: Regex for Word space Word space Word ....