Re: PQexecParams, placeholders and variable lists of params

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: PQexecParams, placeholders and variable lists of params
Дата
Msg-id CAKFQuwbjD0jokC3WBJ-TcCXtXuW=pHDknZOKSBQ2tLtVm+um7w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PQexecParams, placeholders and variable lists of params  (tomas@tuxteam.de)
Ответы Re: PQexecParams, placeholders and variable lists of params
Список pgsql-general
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.

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.

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Max connections reached without max connections reached
Следующее
От: Tom Lane
Дата:
Сообщение: Re: PQexecParams, placeholders and variable lists of params