Skip to content

Commit 13d1293

Browse files
committed
Add test case for trailing junk after numeric literals
PostgreSQL currently accepts numeric literals with trailing non-digits, such as 123abc where the abc is treated as the next token. This may be a bit surprising. This commit adds test cases for this; subsequent commits intend to change this behavior. Reviewed-by: John Naylor <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]
1 parent 7350847 commit 13d1293

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

src/test/regress/expected/numerology.out

+62
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,68 @@
22
-- NUMEROLOGY
33
-- Test various combinations of numeric types and functions.
44
--
5+
--
6+
-- Trailing junk in numeric literals
7+
--
8+
SELECT 123abc;
9+
abc
10+
-----
11+
123
12+
(1 row)
13+
14+
SELECT 0x0o;
15+
x0o
16+
-----
17+
0
18+
(1 row)
19+
20+
SELECT 1_2_3;
21+
_2_3
22+
------
23+
1
24+
(1 row)
25+
26+
SELECT 0.a;
27+
a
28+
---
29+
0
30+
(1 row)
31+
32+
SELECT 0.0a;
33+
a
34+
-----
35+
0.0
36+
(1 row)
37+
38+
SELECT .0a;
39+
a
40+
-----
41+
0.0
42+
(1 row)
43+
44+
SELECT 0.0e1a;
45+
a
46+
---
47+
0
48+
(1 row)
49+
50+
SELECT 0.0e;
51+
e
52+
-----
53+
0.0
54+
(1 row)
55+
56+
SELECT 0.0e+a;
57+
ERROR: syntax error at or near "+"
58+
LINE 1: SELECT 0.0e+a;
59+
^
60+
PREPARE p1 AS SELECT $1a;
61+
EXECUTE p1(1);
62+
a
63+
---
64+
1
65+
(1 row)
66+
567
--
668
-- Test implicit type conversions
769
-- This fails for Postgres v6.1 (and earlier?)

src/test/regress/sql/numerology.sql

+16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
-- Test various combinations of numeric types and functions.
44
--
55

6+
--
7+
-- Trailing junk in numeric literals
8+
--
9+
10+
SELECT 123abc;
11+
SELECT 0x0o;
12+
SELECT 1_2_3;
13+
SELECT 0.a;
14+
SELECT 0.0a;
15+
SELECT .0a;
16+
SELECT 0.0e1a;
17+
SELECT 0.0e;
18+
SELECT 0.0e+a;
19+
PREPARE p1 AS SELECT $1a;
20+
EXECUTE p1(1);
21+
622
--
723
-- Test implicit type conversions
824
-- This fails for Postgres v6.1 (and earlier?)

0 commit comments

Comments
 (0)