dbTalk Databases Forums  

[BUGS] Minor irritant with comment parsing in a function (SQL) body

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] Minor irritant with comment parsing in a function (SQL) body in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Richard Huxton
 
Posts: n/a

Default [BUGS] Minor irritant with comment parsing in a function (SQL) body - 10-08-2003 , 01:25 PM






Versions: 7.3, 7.4beta (not latest)
Applies to SQL functions, but not apparently to plpgsql (because of the
different parser, I presume).

This is really a "doctor it hurts when I..." thing - the fact that I've never
come across it before must mean it's pretty hard to trigger.

The first version of this function compiles fine, the second doesn't.

CREATE OR REPLACE FUNCTION zzz_test () RETURNS text AS '
SELECT ''hello world''::text;
-- SELECT ''goodbye world''
' LANGUAGE 'SQL';

CREATE OR REPLACE FUNCTION zzz_test () RETURNS text AS '
SELECT ''hello world''
-- SELECT ''goodbye world''
::text;
' LANGUAGE 'SQL';

ERROR: parser: unterminated quoted string at or near "'hello world'
-- SELECT 'goodbye world'
::text;
"

It took forever to find a simple reproducible example, but the rules seem to
be:
1. You must have quoting at the end of both adjacent lines
2. Both lines must be within a single SQL statement.
3. You must use the -- comment, not /* ... */

Originally spotted with a formulation like:
AND type1 = ''A''
AND type2 = ''B''
...
I commented one test and got an error message.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)

Reply With Quote
  #2  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [BUGS] Minor irritant with comment parsing in a function (SQL) body - 10-09-2003 , 02:44 PM







Peter has fixed this in CVS. Thanks for the report.

---------------------------------------------------------------------------

Richard Huxton wrote:
Quote:
Versions: 7.3, 7.4beta (not latest)
Applies to SQL functions, but not apparently to plpgsql (because of the
different parser, I presume).

This is really a "doctor it hurts when I..." thing - the fact that I've never
come across it before must mean it's pretty hard to trigger.

The first version of this function compiles fine, the second doesn't.

CREATE OR REPLACE FUNCTION zzz_test () RETURNS text AS '
SELECT ''hello world''::text;
-- SELECT ''goodbye world''
' LANGUAGE 'SQL';

CREATE OR REPLACE FUNCTION zzz_test () RETURNS text AS '
SELECT ''hello world''
-- SELECT ''goodbye world''
::text;
' LANGUAGE 'SQL';

ERROR: parser: unterminated quoted string at or near "'hello world'
-- SELECT 'goodbye world'
::text;
"

It took forever to find a simple reproducible example, but the rules seem to
be:
1. You must have quoting at the end of both adjacent lines
2. Both lines must be within a single SQL statement.
3. You must use the -- comment, not /* ... */

Originally spotted with a formulation like:
AND type1 = ''A''
AND type2 = ''B''
...
I commented one test and got an error message.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)

--
Bruce Momjian | http://candle.pha.pa.us
pgman (AT) candle (DOT) pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.