1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Enhance the SUM() aggregate (and related AVG() and TOTAL()) so that the running

sum is accurate to about 100 bits.

FossilOrigin-Name: a915f15a916af698e0cef46c8b3e7ed11bda19349179d2d414073cd39c4cce24
This commit is contained in:
drh
2023-06-28 12:02:48 +00:00
6 changed files with 104 additions and 32 deletions

View File

@ -1543,6 +1543,22 @@ do_execsql_test func-36.110 {
SELECT 123 ->> 456
} {123->>456}
# 2023-06-26
# Enhanced precision of SUM().
#
reset_db
do_execsql_test func-37.100 {
WITH c(x) AS (VALUES(9223372036854775807),(9223372036854775807),
(123),(-9223372036854775807),(-9223372036854775807))
SELECT sum(x) FROM c;
} {123}
do_catchsql_test func-37.110 {
WITH c(x) AS (VALUES(9223372036854775807),(1))
SELECT sum(x) FROM c;
} {1 {integer overflow}}
do_catchsql_test func-37.120 {
WITH c(x) AS (VALUES(9223372036854775807),(100),(-101))
SELECT sum(x) FROM c;
} {0 9223372036854775806}
finish_test