Allow underscores in integer and numeric constants.
authorDean Rasheed <[email protected]>
Sat, 4 Feb 2023 09:48:51 +0000 (09:48 +0000)
committerDean Rasheed <[email protected]>
Sat, 4 Feb 2023 09:48:51 +0000 (09:48 +0000)
commitfaff8f8e47f18c7d589453e2e0d841d2bd96c1ac
tree84c64f4f9cb6e7713d955f8b3193ff84b42c8cee
parent1b6f632a35f8715f8c64e7930adebc7f1d292074
Allow underscores in integer and numeric constants.

This allows underscores to be used in integer and numeric literals,
and their corresponding type input functions, for visual grouping.
For example:

    1_500_000_000
    3.14159_26535_89793
    0xffff_ffff
    0b_1001_0001

A single underscore is allowed between any 2 digits, or immediately
after the base prefix indicator of non-decimal integers, per SQL:202x
draft.

Peter Eisentraut and Dean Rasheed

Discussion: https://postgr.es/m/84aae844-dc55-a4be-86d9-4f0fa405cc97%40enterprisedb.com
22 files changed:
doc/src/sgml/syntax.sgml
src/backend/catalog/sql_features.txt
src/backend/parser/parse_node.c
src/backend/parser/scan.l
src/backend/utils/adt/numeric.c
src/backend/utils/adt/numutils.c
src/fe_utils/psqlscan.l
src/interfaces/ecpg/preproc/pgc.l
src/pl/plpgsql/src/expected/plpgsql_trap.out
src/pl/plpgsql/src/sql/plpgsql_trap.sql
src/test/regress/expected/int2.out
src/test/regress/expected/int4.out
src/test/regress/expected/int8.out
src/test/regress/expected/numeric.out
src/test/regress/expected/numerology.out
src/test/regress/expected/partition_prune.out
src/test/regress/sql/int2.sql
src/test/regress/sql/int4.sql
src/test/regress/sql/int8.sql
src/test/regress/sql/numeric.sql
src/test/regress/sql/numerology.sql
src/test/regress/sql/partition_prune.sql