should be it
This commit is contained in:
87
external/duckdb/test/sql/overflow/test_numeric_overflow.test
vendored
Normal file
87
external/duckdb/test/sql/overflow/test_numeric_overflow.test
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
# name: test/sql/overflow/test_numeric_overflow.test
|
||||
# description: Test handling of overflows in float/double
|
||||
# group: [overflow]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query I
|
||||
SELECT 1e1000
|
||||
----
|
||||
inf
|
||||
|
||||
# overflow on cast from double to real results in an error
|
||||
statement error
|
||||
SELECT 1e308::REAL
|
||||
----
|
||||
Conversion Error
|
||||
|
||||
# except we can cast inf -> inf
|
||||
query I
|
||||
SELECT 1e1000::REAL
|
||||
----
|
||||
inf
|
||||
|
||||
# test string casts
|
||||
query I
|
||||
SELECT '1e1000'::DOUBLE
|
||||
----
|
||||
inf
|
||||
|
||||
query I
|
||||
SELECT '1e100'::REAL
|
||||
----
|
||||
inf
|
||||
|
||||
# overflow in SUM/AVG overflow
|
||||
query I
|
||||
SELECT SUM(i) FROM (VALUES (1e308), (1e308)) tbl(i)
|
||||
----
|
||||
inf
|
||||
|
||||
query I
|
||||
SELECT AVG(i) FROM (VALUES (1e308), (1e308)) tbl(i)
|
||||
----
|
||||
inf
|
||||
|
||||
# overflow in arithmetic as well
|
||||
query I
|
||||
SELECT 1e308+1e308
|
||||
----
|
||||
inf
|
||||
|
||||
query I
|
||||
SELECT 1e308*2
|
||||
----
|
||||
inf
|
||||
|
||||
query I
|
||||
SELECT -1e308-1e308
|
||||
----
|
||||
-inf
|
||||
|
||||
query I
|
||||
SELECT 1e308/0.1
|
||||
----
|
||||
inf
|
||||
|
||||
query I
|
||||
SELECT 2e38::REAL+2e38::REAL
|
||||
----
|
||||
inf
|
||||
|
||||
query I
|
||||
SELECT 2e38::REAL*2
|
||||
----
|
||||
inf
|
||||
|
||||
query I
|
||||
SELECT -2e38::REAL-2e38::REAL
|
||||
----
|
||||
-inf
|
||||
|
||||
query I
|
||||
SELECT 2e38::REAL/0.1::REAL
|
||||
----
|
||||
inf
|
||||
|
||||
Reference in New Issue
Block a user