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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to