Re: psql -c command parse "select $$hello$$" failed
| От | Erik Wienhold |
|---|---|
| Тема | Re: psql -c command parse "select $$hello$$" failed |
| Дата | |
| Msg-id | 1823426797.696934.1688474716571@office.mailbox.org обсуждение исходный текст |
| Ответ на | psql -c command parse "select $$hello$$" failed (jian he <jian.universality@gmail.com>) |
| Список | pgsql-general |
> On 04/07/2023 14:21 CEST jian he <jian.universality@gmail.com> wrote:
>
> not sure this is the expected result.
>
> /home/jian/postgres/pg16_test/bin/psql -d test_dev -p 5455 -c "select $$hello$$"
> 2023-07-04 20:15:51.066 CST [1562050] ERROR: trailing junk after
> numeric literal at or near "884070h" at character 8
> 2023-07-04 20:15:51.066 CST [1562050] STATEMENT: select 884070hello884070
> ERROR: trailing junk after numeric literal at or near "884070h"
> LINE 1: select 884070hello884070
The error is expected because the shell replaces $$ with its process ID inside
double quoted strings. Check out Bash quoting [1] (assuming that you use bash
but this applies to every(?) shell).
Either use single quotes around the statement or escape every $ with \$:
psql -c 'select $$hello$$'
psql -c "select \$\$hello\$\$\"
[1] https://www.gnu.org/software/bash/manual/bash.html#Quoting
--
Erik
В списке pgsql-general по дате отправления: