Re: dollar-quoting in psql and in general - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: dollar-quoting in psql and in general
Date
Msg-id 411ADF00.9000708@dunslane.net
Whole thread Raw
In response to dollar-quoting in psql and in general  (Philip Warner <pjw@rhyme.com.au>)
Responses Re: dollar-quoting in psql and in general
List pgsql-hackers

Philip Warner wrote:

> While trying to understand dollar-quoting, I found the following in psql:
>
>    select $a$ hello $a$;
>
> behaves as expected, but psql does not like
>
>    select $a$ \ $a$;
> or
>    select $a$ \\ $a$;
>
> Should it? How should a dollar-quote handle:
>
>    $a$ \$a\$a $a$
>
> ?
>
>
andrew=# select $a$ \ $a$;?column?
---------- \
(1 row)

andrew=# select $a$ \\ $a$;?column?
---------- \\
(1 row)

It is behaving as *I* expect, and as designed. \ is not magical inside 
dollar quotes, and if it were it would defeat the whole purpose of 
having them.

Dollar quotes are really designed for strings that are reparsed - most 
typically function bodies. The strings inside them are therefore totally 
opaque, and there is no escape character. Otherwise, if we wanted the 
plpgsql parsers, say, to see \ we'd have to write \\, and the idea was 
to get away from \\, \', '' and friends.

cheers

andrew


pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: dollar-quoting in psql and in general
Next
From: Philip Warner
Date:
Subject: Re: dollar-quoting in psql and in general