Fix an issue with infinity handling by the SUM() function that goes back

to the extended-precision SUM() enhancement of
[check-in c63e26e705f5e967].  Problem reported by
[forum:/forumpost/1c06ddcacc86032a|forum post 1c06ddcacc86032a].

FossilOrigin-Name: 77d3dcd283595c52f24c07fc59ba60c9133b71c440cf3f799cf48c907c6fae3e
This commit is contained in:
drh 2023-08-28 12:20:18 +00:00
parent 0d066bc8a6
commit bd953dfcad
4 changed files with 20 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Resolve\sa\scondition\swhich\scould\scause\san\sis-interrupted\sdb\sto\scall\sits\sprogress\scallback.
D 2023-08-28T12:06:38.596
C Fix\san\sissue\swith\sinfinity\shandling\sby\sthe\sSUM()\sfunction\sthat\sgoes\sback\nto\sthe\sextended-precision\sSUM()\senhancement\sof\n[check-in\sc63e26e705f5e967].\s\sProblem\sreported\sby\n[forum:/forumpost/1c06ddcacc86032a|forum\spost\s1c06ddcacc86032a].
D 2023-08-28T12:20:18.225
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -651,7 +651,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500
F src/expr.c 1affe0cc049683ef0ef3545d9b6901508556b0ef7e2892a344c3df6d7288d79d
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c a7fcbf7e66d14dbb73cf49f31489ebf66d0e6006c62b95246924a3bae9f37b36
F src/func.c dd1ecd1be6aaa67c9fa723f841e05e1536314c6aaa0509e25289b310f64dbb9c
F src/func.c f480d46974ecc84fefdd429377158981b974e0e33d656f1b0e919ba7c4bdd390
F src/global.c 29f56a330ed9d1b5cd9b79ac0ca36f97ac3afc730ff8bfa987b0db9e559d684d
F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220
F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
@ -1170,7 +1170,7 @@ F test/fts4umlaut.test fcaca4471de7e78c9d1f7e8976e3e8704d7d8ad979d57a739d00f3f75
F test/fts4unicode.test 82a9c16b68ba2f358a856226bb2ee02f81583797bc4744061c54401bf1a0f4c9
F test/fts4upfrom.test f25835162c989dffd5e2ef91ec24c4848cc9973093e2d492d1c7b32afac1b49d
F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d
F test/func.test 2acd982669b2c15ceccc046385b458e985f90c9ca58b14d0ef75eec79c32f45b
F test/func.test 719076723b13a6bfcff7b00b7987b1d7b06876ceb71e868b3d13d571d9b42cae
F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a
F test/func4.test 2285fb5792d593fef442358763f0fd9de806eda47dbc7a5934df57ffdc484c31
@ -2106,8 +2106,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P c393b1c9f5639c259406e587b3e08efdc1962203001823747681379ffc54fc10
R 8d931a50e177b7d6e53f54c42fcaa391
U stephan
Z bab39be70eb99e3f7bbba492a0a8edda
P a0d0f1aafc6086726131dff5e6628f2771c20db3122a53bdbb82945ab5d326d1
R fb83093e6e2cb948f127cf0c2e1878f8
U drh
Z 71db94e565d6eff1a32422e7510ceb2f
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
a0d0f1aafc6086726131dff5e6628f2771c20db3122a53bdbb82945ab5d326d1
77d3dcd283595c52f24c07fc59ba60c9133b71c440cf3f799cf48c907c6fae3e

View File

@ -1816,8 +1816,10 @@ static void sumFinalize(sqlite3_context *context){
if( p->approx ){
if( p->ovrfl ){
sqlite3_result_error(context,"integer overflow",-1);
}else{
}else if( !sqlite3IsNaN(p->rErr) ){
sqlite3_result_double(context, p->rSum+p->rErr);
}else{
sqlite3_result_double(context, p->rSum);
}
}else{
sqlite3_result_int64(context, p->iSum);

View File

@ -1545,4 +1545,12 @@ do_catchsql_test func-37.120 {
SELECT sum(x) FROM c;
} {1 {integer overflow}}
# 2023-08-28 forum post https://sqlite.org/forum/forumpost/1c06ddcacc86032a
# Incorrect handling of infinity by SUM().
#
do_execsql_test func-38.100 {
WITH t1(x) AS (VALUES(9e+999)) SELECT sum(x) FROM t1;
WITH t1(x) AS (VALUES(-9e+999)) SELECT sum(x) FROM t1;
} {Inf -Inf}
finish_test