Thread: BUG #1486: Apostrophes are not ignored in pgplsql comments

BUG #1486: Apostrophes are not ignored in pgplsql comments

From
"Andrew Gold"
Date:
The following bug has been logged online:

Bug reference:      1486
Logged by:          Andrew Gold
Email address:      agold@cbamedia.com
PostgreSQL version: 7.4.7
Operating system:   Debian Linux
Description:        Apostrophes are not ignored in pgplsql comments
Details:

In pgplsql functions, apostrophes in comments are not ignored by the pgplsql
interpreter. Parsing errors result from correct spelling in comments. For
example, a comment such as:

-- This can't be a good way to solve this.

will generate errors. This seems to be a general bug and was easily
duplicated.

Thanks,

Andrew Gold

Re: BUG #1486: Apostrophes are not ignored in pgplsql comments

From
Richard Huxton
Date:
Andrew Gold wrote:
> The following bug has been logged online:
>
> Bug reference:      1486
> Logged by:          Andrew Gold
> Email address:      agold@cbamedia.com
> PostgreSQL version: 7.4.7
> Operating system:   Debian Linux
> Description:        Apostrophes are not ignored in pgplsql comments
> Details:
>
> In pgplsql functions, apostrophes in comments are not ignored by the pgplsql
> interpreter. Parsing errors result from correct spelling in comments. For
> example, a comment such as:
>
> -- This can't be a good way to solve this.
>
> will generate errors. This seems to be a general bug and was easily
> duplicated.

I don't think it's a plpgsql problem though - rather an artefact of the
SQL parser. You're actually doing

CREATE FUNCTION foo() RETURNS ... AS <some text value> LANGUAGE ...;

I think the problem is while the SQL parser is processing the text-value
- you need to escape the single-quote to get past that stage of parsing.

There are similar issues with regexp strings.

If you're using dollar-quoting in 8.0 the problem is gone.

--
   Richard Huxton
   Archonet Ltd