| From: | Andrew Dunstan <andrew(at)dunslane(dot)net> | 
|---|---|
| To: | Philip Warner <pjw(at)rhyme(dot)com(dot)au> | 
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> | 
| Subject: | Re: dollar-quoting in psql and in general | 
| Date: | 2004-08-12 03:07:44 | 
| Message-ID: | 411ADF00.9000708@dunslane.net | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Philip Warner | 2004-08-12 03:21:06 | Re: dollar-quoting in psql and in general | 
| Previous Message | Philip Warner | 2004-08-12 03:03:22 | Re: dollar-quoting in psql and in general |