mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
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 <john.naylor@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/b239564c-cad0-b23e-c57e-166d883cb97d@enterprisedb.com
This commit is contained in:
@ -2,6 +2,68 @@
|
|||||||
-- NUMEROLOGY
|
-- NUMEROLOGY
|
||||||
-- Test various combinations of numeric types and functions.
|
-- Test various combinations of numeric types and functions.
|
||||||
--
|
--
|
||||||
|
--
|
||||||
|
-- Trailing junk in numeric literals
|
||||||
|
--
|
||||||
|
SELECT 123abc;
|
||||||
|
abc
|
||||||
|
-----
|
||||||
|
123
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT 0x0o;
|
||||||
|
x0o
|
||||||
|
-----
|
||||||
|
0
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT 1_2_3;
|
||||||
|
_2_3
|
||||||
|
------
|
||||||
|
1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT 0.a;
|
||||||
|
a
|
||||||
|
---
|
||||||
|
0
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT 0.0a;
|
||||||
|
a
|
||||||
|
-----
|
||||||
|
0.0
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT .0a;
|
||||||
|
a
|
||||||
|
-----
|
||||||
|
0.0
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT 0.0e1a;
|
||||||
|
a
|
||||||
|
---
|
||||||
|
0
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT 0.0e;
|
||||||
|
e
|
||||||
|
-----
|
||||||
|
0.0
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT 0.0e+a;
|
||||||
|
ERROR: syntax error at or near "+"
|
||||||
|
LINE 1: SELECT 0.0e+a;
|
||||||
|
^
|
||||||
|
PREPARE p1 AS SELECT $1a;
|
||||||
|
EXECUTE p1(1);
|
||||||
|
a
|
||||||
|
---
|
||||||
|
1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Test implicit type conversions
|
-- Test implicit type conversions
|
||||||
-- This fails for Postgres v6.1 (and earlier?)
|
-- This fails for Postgres v6.1 (and earlier?)
|
||||||
|
@ -3,6 +3,22 @@
|
|||||||
-- Test various combinations of numeric types and functions.
|
-- Test various combinations of numeric types and functions.
|
||||||
--
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Trailing junk in numeric literals
|
||||||
|
--
|
||||||
|
|
||||||
|
SELECT 123abc;
|
||||||
|
SELECT 0x0o;
|
||||||
|
SELECT 1_2_3;
|
||||||
|
SELECT 0.a;
|
||||||
|
SELECT 0.0a;
|
||||||
|
SELECT .0a;
|
||||||
|
SELECT 0.0e1a;
|
||||||
|
SELECT 0.0e;
|
||||||
|
SELECT 0.0e+a;
|
||||||
|
PREPARE p1 AS SELECT $1a;
|
||||||
|
EXECUTE p1(1);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Test implicit type conversions
|
-- Test implicit type conversions
|
||||||
-- This fails for Postgres v6.1 (and earlier?)
|
-- This fails for Postgres v6.1 (and earlier?)
|
||||||
|
Reference in New Issue
Block a user