Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit13d1293

Browse files
committed
Add test case for trailing junk after numeric literals
PostgreSQL currently accepts numeric literals with trailingnon-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 <john.naylor@enterprisedb.com>Discussion:https://www.postgresql.org/message-id/flat/b239564c-cad0-b23e-c57e-166d883cb97d@enterprisedb.com
1 parent7350847 commit13d1293

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

‎src/test/regress/expected/numerology.out

Lines changed: 62 additions & 0 deletions
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

Lines changed: 16 additions & 0 deletions
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+
SELECT0.a;
14+
SELECT0.0a;
15+
SELECT .0a;
16+
SELECT0.0e1a;
17+
SELECT0.0e;
18+
SELECT0.0e+a;
19+
PREPARE p1ASSELECT $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)

[8]ページ先頭

©2009-2025 Movatter.jp