Re: psql -c command parse "select $$hello$$" failed

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>, g(at)jrouhaud
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: psql -c command parse "select $$hello$$" failed
Date: 2023-07-04 12:36:16
Message-ID: 20230704123616.f5g67rkdpdlalypf@jrouhaud
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Erik Wienhold 2023-07-04 12:45:16 Re: psql -c command parse "select $$hello$$" failed
Previous Message jian he 2023-07-04 12:21:10 psql -c command parse "select $$hello$$" failed