Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] parser dilemma

From: Zoltan Boszormenyi <zb(at)cybertec(dot)at>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: List pgsql-patches <pgsql-patches(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, Bruce Momjian <bruce(at)momjian(dot)us>
Subject: Re: [HACKERS] parser dilemma
Date: 2007-04-20 08:35:29
Message-ID: 46287B51.5030004@cybertec.at (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Zoltan Boszormenyi írta:
> Martijn van Oosterhout írta:
>> On Thu, Apr 19, 2007 at 11:19:40AM +0200, Zoltan Boszormenyi wrote:
>>  
>>>> The problem comes from cases like
>>>>
>>>>     colname coltype DEFAULT 5! GENERATED ...
>>>>
>>>> Since b_expr allows postfix operators, it takes one more token of
>>>> lookahead than we have to tell if the default expression is "5!"
>>>> or "5!GENERATED ...".
>>>>       
>>
>> ISTM that as long as:
>>
>>  colname coltype DEFAULT (5!) GENERATED ...
>>
>> works I don't see why it would be a problem to require the parentheses
>> in this case. Postfis operators are not going to be that common here I
>> think.
>>
>> Have a nice day,
>>   
>
> You mean like this one?
> ------------------------------------------------------------------------
> *** gram.y.old  2007-04-20 09:23:16.000000000 +0200
> --- gram.y      2007-04-20 09:25:34.000000000 +0200
> ***************
> *** 7550,7557 ****
>                                { $$ = (Node *) makeA_Expr(AEXPR_OP, 
> $2, $1, $3, @2); }
>                        | qual_Op 
> b_expr                                        %prec Op
>                                { $$ = (Node *) makeA_Expr(AEXPR_OP, 
> $1, NULL, $2, @1); }
> !                       | b_expr 
> qual_Op                                        %prec POSTFIXOP
> !                               { $$ = (Node *) makeA_Expr(AEXPR_OP, 
> $2, $1, NULL, @2); }
>                        | b_expr IS DISTINCT FROM b_expr                
> %prec IS
>                                {
>                                        $$ = (Node *) 
> makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $5, @2);
> --- 7550,7557 ----
>                                { $$ = (Node *) makeA_Expr(AEXPR_OP, 
> $2, $1, $3, @2); }
>                        | qual_Op 
> b_expr                                        %prec Op
>                                { $$ = (Node *) makeA_Expr(AEXPR_OP, 
> $1, NULL, $2, @1); }
> !                       | '(' b_expr qual_Op    
> ')'                             %prec POSTFIXOP
> !                               { $$ = (Node *) makeA_Expr(AEXPR_OP, 
> $3, $2, NULL, @3); }
>                        | b_expr IS DISTINCT FROM b_expr                
> %prec IS
>                                {
>                                        $$ = (Node *) 
> makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $5, @2);
> ------------------------------------------------------------------------
>
> This change alone brings 13 reduce/reduce conflicts.

On the other hand, marking GENERATED as %right
solves this issue. I hope it's an acceptable solution.

Best regards,
Zoltán Böszörményi

-- 
----------------------------------
Zoltán Böszörményi
Cybertec Geschwinde & Schönig GmbH
http://www.postgresql.at/


Attachment: psql-serial-42.diff.gz
Description: application/x-tar (28.2 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Zoltan BoszormenyiDate: 2007-04-20 08:37:23
Subject: Re: parser dilemma
Previous:From: Andrew DunstanDate: 2007-04-20 08:26:24
Subject: Re: parser dilemma

pgsql-patches by date

Next:From: Zoltan BoszormenyiDate: 2007-04-20 08:37:23
Subject: Re: parser dilemma
Previous:From: Andrew DunstanDate: 2007-04-20 08:26:24
Subject: Re: parser dilemma

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group