Inconsistent syntax for NumericOnly grammar production

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Inconsistent syntax for NumericOnly grammar production
Date: 2017-05-28 21:16:24
Message-ID: 30908.1496006184@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I noticed that gram.y has

NumericOnly:
FCONST { $$ = makeFloat($1); }
| '-' FCONST
{
$$ = makeFloat($2);
doNegateFloat($$);
}
| SignedIconst { $$ = makeInteger($1); }
;

but

SignedIconst: Iconst { $$ = $1; }
| '+' Iconst { $$ = + $2; }
| '-' Iconst { $$ = - $2; }
;

The inconsistency here means that you can do, for example,

regression=# set random_page_cost = +4;
SET
regression=# set random_page_cost = 4.2;
SET

but not

regression=# set random_page_cost = +4.2;
ERROR: syntax error at or near "4.2"
LINE 1: set random_page_cost = +4.2;
^

That's weird enough in itself, and the problem is about to get more
widespread because the partbound_datum production depends on NumericOnly.

Any objections to allowing "+ FCONST" here? I'm inclined to
fix this and back-patch it as well.

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Kirkwood 2017-05-28 22:17:49 Re: logical replication - still unstable after all these months
Previous Message Tom Lane 2017-05-28 19:20:52 Re: Index created in BEFORE trigger not updated during INSERT