Inconsistent syntax for NumericOnly grammar production

Started by Tom Laneover 8 years ago2 messages
#1Tom Lane
tgl@sss.pgh.pa.us

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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Vik Fearing
vik.fearing@2ndquadrant.com
In reply to: Tom Lane (#1)
Re: Inconsistent syntax for NumericOnly grammar production

On 05/28/2017 11:16 PM, Tom Lane wrote:

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;
^
Any objections to allowing "+ FCONST" here? I'm inclined to
fix this and back-patch it as well.

Seems like the right thing to do; no objections here.
--
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers