Re: Comments with embedded single quotes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Harvey Chapman <hchapman(at)3gfp(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: Comments with embedded single quotes
Date: 2000-06-29 02:59:34
Message-ID: 18683.962247574@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Richard Harvey Chapman <hchapman(at)3gfp(dot)com> writes:
> Are single quotation marks not allowed in comments?

> test2=# /* John's cat is fat. */
> test2'#
> test2'# '*/
> test2-# ;
> ERROR: Unterminated quoted string
> test2=#

They are, but it looks like psql's primitive parser is confused here.
What the backend sees when this is sent is
/* comment */

'*/

and it quite properly complains that the string starting '*/ is not
terminated. But it looks like psql mistakenly thinks that ' nests
inside /* ... */:

regression=# /*aaa
regression*# 'sss
regression'# ddd
regression'# */
regression'# 'sss
regression*# */
regression-#

Notice the pattern of the 'state' markers in the prompts. It seems
to get the reverse case correct though:

regression-# 'foo
regression'# /*bar
regression'# '
regression-#

Over to you, Peter...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message igor 2000-06-29 03:14:50 test
Previous Message Bruce Momjian 2000-06-29 02:41:52 Re: Comments with embedded single quotes