Re: [HACKERS] Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: hackers(at)postgresql(dot)org, mdalphin(at)sanger(dot)otago(dot)ac(dot)nz
Subject: Re: [HACKERS] Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly
Date: 1998-04-01 17:08:35
Message-ID: 35227493.75D281E@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > 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?

No, _no_ negative numbers get through scan.l without being separated
into a minus sign and a positive number. This is because the scanner
does not have any information about context, and cannot distinguish the
usage of the minus, for example between the two cases "a - b" and "- b".
So, to handle "a - b" correctly, the minus sign must always be
separated, otherwise you get "a (-b)" which the grammar does not
understand.

The one place which will see every node come through is in the parser
transformations or in the optimizer, which is why it seems that those
might be good places to look for this case.

- Tom

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Gould 1998-04-01 19:56:56 Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6
Previous Message Bruce Momjian 1998-04-01 16:41:45 Re: [HACKERS] Re: [PORTS] Port Bug Report: int2 negative numbers not parsed correctly