Underscores in numeric literals

Peter Eisentraut <peter.eisentraut@enterprisedb.com>

From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-12-27T09:15:00Z
Lists: pgsql-hackers

Attachments

Here is a patch to add support for underscores in numeric literals, for 
visual grouping, like

     1_500_000_000
     0b10001000_00000000
     0o_1_755
     0xFFFF_FFFF
     1.618_034

per SQL:202x draft.

This adds support in the lexer as well as in the integer type input 
functions.

TODO: float/numeric type input support

I did some performance tests similar to what was done in [0] and didn't 
find any problematic deviations.  Other tests would be welcome.

[0]: 
https://www.postgresql.org/message-id/flat/b239564c-cad0-b23e-c57e-166d883cb97d@enterprisedb.com

Commits

  1. Allow underscores in integer and numeric constants.