Re: PQexecParams, placeholders and variable lists of params

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: tomas(at)tuxteam(dot)de
Cc: Дмитрий Иванов <firstdismay(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: PQexecParams, placeholders and variable lists of params
Date: 2021-11-23 15:35:04
Message-ID: CAKFQuwbjD0jokC3WBJ-TcCXtXuW=pHDknZOKSBQ2tLtVm+um7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Nov 23, 2021 at 7:21 AM <tomas(at)tuxteam(dot)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.

I personally tend to just build up a CSV-like string (my data is usually
controlled enough the using the pipe symbol as a separator
alleviates escaping concerns) and using string_to_array($1,'|') to get the
array of values into the query.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2021-11-23 15:43:03 Re: PQexecParams, placeholders and variable lists of params
Previous Message Tom Lane 2021-11-23 15:33:27 Re: Max connections reached without max connections reached