Re: [HACKERS] Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly
Date
Msg-id 199804011641.LAA20424@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly  ("Thomas G. Lockhart" <lockhart@alumni.caltech.edu>)
List pgsql-hackers
>
> > > Well we maybe can, but it sure is ugly. This will be spread around a
> > > bunch of places (everywhere there is a unary minus allowed). I
> > > already did the wrong thing and brute-forced something similar into
> > > the CREATE SEQUENCE code in gram.y. Isolating it in transform_expr()
> > > or somewhere like that would be much cleaner.
> > But isn't it is just one line in gram.y.  That is where I was seeing
> > it happen.
>
> golem$ grep UMINUS gram.y
> %right          UMINUS
>                         | '-' default_expr %prec UMINUS
>                         | '-' constraint_expr %prec UMINUS
>                 | '-' a_expr %prec UMINUS
>                 | '-' b_expr %prec UMINUS
>                 | '-' position_expr %prec UMINUS
>
> So at least 5 different places, perhaps more when you get into it :(

OK, let's take a look at it.  The only one I have seen a problem with
is:

    | '-' a_expr %prec UMINUS

But let's look at the others.  Default_expr has it:

    default_expr:  AexprConst
                    {   $$ = makeConstantList((A_Const *) $1); }
                | NULL_P
                    {   $$ = lcons( makeString("NULL"), NIL); }
                | '-' default_expr %prec UMINUS
                    {   $$ = lcons( makeString( "-"), $2); }

But I don't understand why it is there.  Doesn't AexprConst handle such
a case, or do we get shift-reduce conflicts without it?

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly
Next
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly