Re: Escaping `psql --variable`

Поиск
Список
Период
Сортировка
Искать
От
Alan Gutierrez
Тема
Re: Escaping `psql --variable`
Дата
в 23:21:23
Msg-id
20120530022055.GB7607@gmail.com
Ответ на
Список
Дерево обсуждения
Escaping `psql --variable` Alan Gutierrez <alan@prettyrobots.com>
Re: Escaping `psql --variable` Jeff Davis <pgsql@j-davis.com>
Re: Escaping `psql --variable` Alan Gutierrez <alan@prettyrobots.com>
On Tue, May 29, 2012 at 05:19:49PM -0700, Jeff Davis wrote:
> On Tue, 2012-05-29 at 18:32 -0400, Alan Gutierrez wrote:
> > Surprised that this works:
> > 
> >      echo ":foo" | psql --variable foo="SELECT 1 AS FOO;"  template1
> > 
> > Why doesn't `psql` escape parameters passed in through `--variable`. When I use
> > a library in other languages, they will escape the variable.
> > 
> > How do I use `psql` from `bash` so that it will escape variables and thwart SQL
> > injection?
> 
> http://www.postgresql.org/docs/9.1/static/app-psql.html#APP-PSQL-VARIABLES
> 
> In particular, look at the section on SQL Interpolation. Hopefully that
> answers your question.
> 
> Regards,
> 	Jeff Davis
> 

Yes. Thank you. To escape a variable and thwart SQL injection:

cat <
В списке pgsql-general по дате отправления
От: Adrian Klaver
Дата:
От: yi huang
Дата:
FAQ