Re: Having trouble passing a shell variable to a query from psql command line

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Having trouble passing a shell variable to a query from psql command line
Дата
Msg-id 2343915.1756494912@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Having trouble passing a shell variable to a query from psql command line  (Ron Johnson <ronljohnsonjr@gmail.com>)
Ответы Re: Having trouble passing a shell variable to a query from psql command line
Список pgsql-admin
Ron Johnson <ronljohnsonjr@gmail.com> writes:
> Yeah.  From the cli KISS and do regular bash variable string expansion.

> psql -d mydb -tAc "SELECT relkind FROM pg_class WHERE relname =
> ${SHELL_VAR} ;"

This isn't a great recommendation because bash is not aware of
SQL's quoting rules.  It'll work in simple cases, but there's
a risk of SQL injection if the value of SHELL_VAR comes from
an untrustworthy source.

            regards, tom lane



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