Re: psql -c command parse "select $$hello$$" failed - Mailing list pgsql-general

From Julien Rouhaud
Subject Re: psql -c command parse "select $$hello$$" failed
Date
Msg-id 20230704123616.f5g67rkdpdlalypf@jrouhaud
Whole thread Raw
In response to psql -c command parse "select $$hello$$" failed  (jian he <jian.universality@gmail.com>)
List pgsql-general
Hi,

On Tue, Jul 04, 2023 at 08:21:10PM +0800, jian he wrote:
> Hi.
> 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
>                ^

That's expected, $ is used for variable in the shell and is the pid of the
current process.  You have to escape any $ in a double-quoted string, or use a
single quoted strings.



pgsql-general by date:

Previous
From: jian he
Date:
Subject: psql -c command parse "select $$hello$$" failed
Next
From: Erik Wienhold
Date:
Subject: Re: psql -c command parse "select $$hello$$" failed