Re: [SQL] parser :parse error - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] parser :parse error
Date
Msg-id 29186.942479419@sss.pgh.pa.us
Whole thread Raw
In response to Re: [SQL] parser :parse error  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-sql
[ sorry for not responding sooner, but I was on vacation... ]

>> create table tablename (
>> thefield varchar(50) default 'Fred''s car'
>> );
>> 
>> Error : parser: parse error at or near "s"

Bruce Momjian <maillist@candle.pha.pa.us> writes:
> Works on current tree.  Try 6.5.3.

It does work now, but is broken in 6.5.* and (AFAIK) all prior releases.
The problem is that the parser retranslates DEFAULT expressions into
source form after parsing them --- and the retranslation code is not
bright enough to provide quoting for embedded quotes and backslashes
in string constants.  So the system ends up trying to processDEFAULT 'Fred's car'
which obviously won't work.

Current sources fix this by eliminating the retranslation step.  That's
a pretty major change, so I don't think it's practical/safe to backpatch
it into 6.5.*.  If someone wants to fix this problem as a patch for
6.5.*, probably the best way to proceed would be to fix
backend/parser/gram.y's makeConstantList() to apply appropriate
backslash-quoting within string constants.  I don't have the time or
interest to do it myself though.
        regards, tom lane


pgsql-sql by date:

Previous
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [SQL] HAVING in EXISTS-clause ...
Next
From: Mark Stosberg
Date:
Subject: Porting MySQL's DESCRIBE and ENUM features