Re: Comments with embedded single quotes

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Richard Harvey Chapman <hchapman(at)3gfp(dot)com>, 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 16:27:47
Message-ID: 200006291627.MAA05841@candle.pha.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...

OK, here is the patch. The problem was that quotes were being checked
before checking if we were in a comment. Patch applied to current tree
only.

--
Bruce Momjian | http://www.op.net/~candle
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Attachment Content-Type Size
unknown_filename text/plain 4.0 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Lockhart 2000-06-29 17:42:00 Re: Importing data w/ Unix timestamp
Previous Message Bob Parkinson 2000-06-29 16:24:52 pg_dump/load quoting.