mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Non-decimal integer literals
Add support for hexadecimal, octal, and binary integer literals: 0x42F 0o273 0b100101 per SQL:202x draft. This adds support in the lexer as well as in the integer type input functions. Reviewed-by: John Naylor <john.naylor@enterprisedb.com> Reviewed-by: Zhihong Yu <zyu@yugabyte.com> Reviewed-by: David Rowley <dgrowleyml@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/b239564c-cad0-b23e-c57e-166d883cb97d@enterprisedb.com
This commit is contained in:
@ -694,6 +694,40 @@ $function$
|
||||
</literallayout>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Additionally, non-decimal integer constants can be used in these forms:
|
||||
<synopsis>
|
||||
0x<replaceable>hexdigits</replaceable>
|
||||
0o<replaceable>octdigits</replaceable>
|
||||
0b<replaceable>bindigits</replaceable>
|
||||
</synopsis>
|
||||
<replaceable>hexdigits</replaceable> is one or more hexadecimal digits
|
||||
(0-9, A-F), <replaceable>octdigits</replaceable> is one or more octal
|
||||
digits (0-7), <replaceable>bindigits</replaceable> is one or more binary
|
||||
digits (0 or 1). Hexadecimal digits and the radix prefixes can be in
|
||||
upper or lower case. Note that only integers can have non-decimal forms,
|
||||
not numbers with fractional parts.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
These are some examples of this:
|
||||
<literallayout>0b100101
|
||||
0B10011001
|
||||
0o273
|
||||
0O755
|
||||
0x42f
|
||||
0XFFFF
|
||||
</literallayout>
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
Nondecimal integer constants are currently only supported in the range
|
||||
of the <type>bigint</type> type (see <xref
|
||||
linkend="datatype-numeric-table"/>).
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
<indexterm><primary>integer</primary></indexterm>
|
||||
<indexterm><primary>bigint</primary></indexterm>
|
||||
|
Reference in New Issue
Block a user