Skip to content

Commit

Permalink
[postgresql] Add test cases (#4354)
Browse files Browse the repository at this point in the history
  • Loading branch information
be-happy4 authored and be happy committed Dec 12, 2024
1 parent af07bb3 commit 4a80f24
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions sql/postgresql/PostgreSQLLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -1317,10 +1317,12 @@ InvalidUnterminatedHexadecimalStringConstant: 'X' UnterminatedStringConstant;

Integral: Digits;

HexadecimalIntegral: '0x' Digits;

BinaryIntegral: '0b' Digits;

OctalIntegral: '0o' Digits;

HexadecimalIntegral: '0x' Digits;

NumericFail: Digits '..' {this.HandleNumericFail();};

Numeric:
Expand Down
3 changes: 2 additions & 1 deletion sql/postgresql/PostgreSQLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -4345,8 +4345,9 @@ fconst

iconst
: Integral
| HexadecimalIntegral
| BinaryIntegral
| OctalIntegral
| HexadecimalIntegral
;

sconst
Expand Down
6 changes: 6 additions & 0 deletions sql/postgresql/examples/numbers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--
-- Tests for numeric literal
--
SELECT 0b10, 0B10, 0x10, 0X10, 0o10, 0O10, 010, 0 x10, 0 b10, 0 o10;
SELECT abs(0b10), abs(0B10), abs(0x10), abs(0X10), abs(0o10), abs(0O10),
('{1}'::int[])[0b01], 1::char(0o01), (array[1])[0x01];

0 comments on commit 4a80f24

Please sign in to comment.