From 263a8e8c0a7682fd3fc67cd086a4b6135dff505b Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 18 Jul 2023 13:55:19 +0000 Subject: [PATCH 1/5] Fix a buffer overrun in fts5 that could occur in 'secure-delete' mode when dealing with corrupt database records. FossilOrigin-Name: def41225b2f10b0294ab506f28bc87873688d4030f7056839298ff18e058ece5 --- ext/fts5/fts5_index.c | 4 ++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 7b9d21e87f..6bf3f0f8c7 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4658,6 +4658,10 @@ static void fts5SecureDeleteOverflow( aIdx = sqlite3Fts5MallocZero(&p->rc, (pLeaf->nn-pLeaf->szLeaf)+2); if( aIdx==0 ) break; i1 += fts5GetVarint32(&aPg[i1], iFirst); + if( iFirstrc = FTS5_CORRUPT; + break; + } i2 = sqlite3Fts5PutVarint(aIdx, iFirst-nShift); if( i1nn ){ memcpy(&aIdx[i2], &aPg[i1], pLeaf->nn-i1); diff --git a/manifest b/manifest index 918e28c08b..b55679b3ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sinternal\scleanups\sin\sthe\sOPFS\sVFS. -D 2023-07-14T21:06:00.870 +C Fix\sa\sbuffer\soverrun\sin\sfts5\sthat\scould\soccur\sin\s'secure-delete'\smode\swhen\sdealing\swith\scorrupt\sdatabase\srecords. +D 2023-07-18T13:55:19.822 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,7 +92,7 @@ F ext/fts5/fts5_buffer.c 3001fbabb585d6de52947b44b455235072b741038391f830d6b7292 F ext/fts5/fts5_config.c 051056a9052f5d3a4d1c695f996fd364f920e341f136c60ab2c04aa7e267113f F ext/fts5/fts5_expr.c 58fb8ceddfb1cefcd54510f9f2f33c220ef9d1b3fa77462111f5ae2a825ab7b1 F ext/fts5/fts5_hash.c d4fb70940359f2120ccd1de7ffe64cc3efe65de9e8995b822cd536ff64c96982 -F ext/fts5/fts5_index.c fe98ebd8835760b9c787d20f6b50d648a761afd8e3b55780e718ee34c694743b +F ext/fts5/fts5_index.c ab6809cdee08c2698147e3e266378978ea75b2da3010fedc91830313f8bc587e F ext/fts5/fts5_main.c b4dba04a36aaf9b8e8cef0100b6dbb422cc74753eacc11d6401cac7a87c0f38d F ext/fts5/fts5_storage.c 76c6085239eb44424004c022e9da17a5ecd5aaec859fba90ad47d3b08f4c8082 F ext/fts5/fts5_tcl.c b1445cbe69908c411df8084a10b2485500ac70a9c747cdc8cda175a3da59d8ae @@ -2043,8 +2043,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 816b503f093c4e6d92d0eb2f9fbd841acd01cc9bc89ee58d961b56c64f71406a -R 6597235c929ad6ed0b90d6716177ff1b -U stephan -Z b7b5463364c5290e11704a96855173c7 +P 984d491eb3fe06f714bf07d6873321f3992a072812b46508e599bfefd39dff3e +R b5dbc1b2e0f8c0b371198b0b049fe385 +U dan +Z 503789c5124758a0ebc4d5ce1274a009 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d9fb0905d5..a328a9f646 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -984d491eb3fe06f714bf07d6873321f3992a072812b46508e599bfefd39dff3e \ No newline at end of file +def41225b2f10b0294ab506f28bc87873688d4030f7056839298ff18e058ece5 \ No newline at end of file From a5b1f341250e65899812c17ad53ca7e1a2d2523d Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 18 Jul 2023 16:29:34 +0000 Subject: [PATCH 2/5] Fix memory leak in fts5 introduced by [def41225]. FossilOrigin-Name: 4dcad2db743fdb9ef72871ca5a4d1384f76cb697161b0f5110e2670a83a18e8a --- ext/fts5/fts5_index.c | 4 ++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 6bf3f0f8c7..347ee56908 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4655,13 +4655,13 @@ static void fts5SecureDeleteOverflow( int i1 = pLeaf->szLeaf; int i2 = 0; - aIdx = sqlite3Fts5MallocZero(&p->rc, (pLeaf->nn-pLeaf->szLeaf)+2); - if( aIdx==0 ) break; i1 += fts5GetVarint32(&aPg[i1], iFirst); if( iFirstrc = FTS5_CORRUPT; break; } + aIdx = sqlite3Fts5MallocZero(&p->rc, (pLeaf->nn-pLeaf->szLeaf)+2); + if( aIdx==0 ) break; i2 = sqlite3Fts5PutVarint(aIdx, iFirst-nShift); if( i1nn ){ memcpy(&aIdx[i2], &aPg[i1], pLeaf->nn-i1); diff --git a/manifest b/manifest index b55679b3ff..1303d23154 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbuffer\soverrun\sin\sfts5\sthat\scould\soccur\sin\s'secure-delete'\smode\swhen\sdealing\swith\scorrupt\sdatabase\srecords. -D 2023-07-18T13:55:19.822 +C Fix\smemory\sleak\sin\sfts5\sintroduced\sby\s[def41225]. +D 2023-07-18T16:29:34.926 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -92,7 +92,7 @@ F ext/fts5/fts5_buffer.c 3001fbabb585d6de52947b44b455235072b741038391f830d6b7292 F ext/fts5/fts5_config.c 051056a9052f5d3a4d1c695f996fd364f920e341f136c60ab2c04aa7e267113f F ext/fts5/fts5_expr.c 58fb8ceddfb1cefcd54510f9f2f33c220ef9d1b3fa77462111f5ae2a825ab7b1 F ext/fts5/fts5_hash.c d4fb70940359f2120ccd1de7ffe64cc3efe65de9e8995b822cd536ff64c96982 -F ext/fts5/fts5_index.c ab6809cdee08c2698147e3e266378978ea75b2da3010fedc91830313f8bc587e +F ext/fts5/fts5_index.c 430d3edfc5b51d02f0671e2b8268c12bf485f7dc80db2b61c996e74814bc46b0 F ext/fts5/fts5_main.c b4dba04a36aaf9b8e8cef0100b6dbb422cc74753eacc11d6401cac7a87c0f38d F ext/fts5/fts5_storage.c 76c6085239eb44424004c022e9da17a5ecd5aaec859fba90ad47d3b08f4c8082 F ext/fts5/fts5_tcl.c b1445cbe69908c411df8084a10b2485500ac70a9c747cdc8cda175a3da59d8ae @@ -2043,8 +2043,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 984d491eb3fe06f714bf07d6873321f3992a072812b46508e599bfefd39dff3e -R b5dbc1b2e0f8c0b371198b0b049fe385 +P def41225b2f10b0294ab506f28bc87873688d4030f7056839298ff18e058ece5 +R e9300e0dc9583f0f9cd6aefb60fd68d9 U dan -Z 503789c5124758a0ebc4d5ce1274a009 +Z 5551f44d2ee1d451fc303b92968039b5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a328a9f646..273a4023bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -def41225b2f10b0294ab506f28bc87873688d4030f7056839298ff18e058ece5 \ No newline at end of file +4dcad2db743fdb9ef72871ca5a4d1384f76cb697161b0f5110e2670a83a18e8a \ No newline at end of file From 6a9be2cbc72bb81208227a1130b9b447817a0979 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 18 Jul 2023 20:41:09 +0000 Subject: [PATCH 3/5] Improved ".wheretrace" for the VIEWSCAN optimization. FossilOrigin-Name: 27057ea76b5f72c73fb6f16094736685019643c665b49fd0bb8d60a812ce2338 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1303d23154..2333353d42 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\smemory\sleak\sin\sfts5\sintroduced\sby\s[def41225]. -D 2023-07-18T16:29:34.926 +C Improved\s".wheretrace"\sfor\sthe\sVIEWSCAN\soptimization. +D 2023-07-18T20:41:09.317 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -722,7 +722,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c dd843f619ac60d5dadab7109cf402432ba74dde0c301505fd1c202add07659e3 F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c 2dc708cf8b6a691fb79f16bbc46567497ee6f991043318d421e294b2da114d93 +F src/where.c e551d13d4aff9176690368ae1b3acff10ede1f451652c75e9dfc9bb2d85d5970 F src/whereInt.h c7d19902863beadec1d04e66aca39c0bcd60b74f05f0eaa7422c7005dfc5d51a F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c dc5096eca5ed503999be3bdee8a90c51361289a678d396a220912e9cb73b3c00 @@ -2043,8 +2043,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 def41225b2f10b0294ab506f28bc87873688d4030f7056839298ff18e058ece5 -R e9300e0dc9583f0f9cd6aefb60fd68d9 -U dan -Z 5551f44d2ee1d451fc303b92968039b5 +P 4dcad2db743fdb9ef72871ca5a4d1384f76cb697161b0f5110e2670a83a18e8a +R 226cc4c3c153723bae524ae831eeb8ad +U drh +Z 09fb8db5361f1b823e48611e4afd0f28 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 273a4023bd..f9b2c165b4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4dcad2db743fdb9ef72871ca5a4d1384f76cb697161b0f5110e2670a83a18e8a \ No newline at end of file +27057ea76b5f72c73fb6f16094736685019643c665b49fd0bb8d60a812ce2338 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 858e33c8ac..923a4d77c7 100644 --- a/src/where.c +++ b/src/where.c @@ -5125,6 +5125,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 ){ rCost += -10; nOut += -30; + WHERETRACE(0x80,("VIEWSCAN cost reduction for %c\n",pWLoop->cId)); } /* Check to see if pWLoop should be added to the set of From 9246c85b61d37f071c4f6197423a0baf41de14f9 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 18 Jul 2023 21:06:19 +0000 Subject: [PATCH 4/5] Do not use the [/info/609fbb94b8f01d67|viewscan optimization] on a query that has only a single loop, as the cost adjustments can cause problems for outer queries. Proposed fix for the performance regression reported by [forum:/forumpost/64d36440e473516c|forum post 64d36440e473516c]. FossilOrigin-Name: 76152ad2ffe56034f2fd93d9a1ce9358e1677a7e9cd3dcd9f3a34a5c956a463e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 2333353d42..e1145c527f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\s".wheretrace"\sfor\sthe\sVIEWSCAN\soptimization. -D 2023-07-18T20:41:09.317 +C Do\snot\suse\sthe\s[/info/609fbb94b8f01d67|viewscan\soptimization]\son\sa\squery\nthat\shas\sonly\sa\ssingle\sloop,\sas\sthe\scost\sadjustments\scan\scause\sproblems\nfor\souter\squeries.\s\sProposed\sfix\sfor\sthe\sperformance\sregression\sreported\sby\n[forum:/forumpost/64d36440e473516c|forum\spost\s64d36440e473516c]. +D 2023-07-18T21:06:19.893 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -722,7 +722,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c dd843f619ac60d5dadab7109cf402432ba74dde0c301505fd1c202add07659e3 F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 -F src/where.c e551d13d4aff9176690368ae1b3acff10ede1f451652c75e9dfc9bb2d85d5970 +F src/where.c 477fcc5e561ef169e6002499602af6b805156c2aae6b2f5c2c93ef8c1cd64768 F src/whereInt.h c7d19902863beadec1d04e66aca39c0bcd60b74f05f0eaa7422c7005dfc5d51a F src/wherecode.c 5d77db30a2a3dd532492ae882de114edba2fae672622056b1c7fd61f5917a8f1 F src/whereexpr.c dc5096eca5ed503999be3bdee8a90c51361289a678d396a220912e9cb73b3c00 @@ -2043,8 +2043,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 4dcad2db743fdb9ef72871ca5a4d1384f76cb697161b0f5110e2670a83a18e8a -R 226cc4c3c153723bae524ae831eeb8ad +P 27057ea76b5f72c73fb6f16094736685019643c665b49fd0bb8d60a812ce2338 +R e083cfeae9842a7650b26a959bcc57e4 U drh -Z 09fb8db5361f1b823e48611e4afd0f28 +Z 4c6375f8dd8261298072fd9d19053ffb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f9b2c165b4..24332574c1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -27057ea76b5f72c73fb6f16094736685019643c665b49fd0bb8d60a812ce2338 \ No newline at end of file +76152ad2ffe56034f2fd93d9a1ce9358e1677a7e9cd3dcd9f3a34a5c956a463e \ No newline at end of file diff --git a/src/where.c b/src/where.c index 923a4d77c7..35b9056ffe 100644 --- a/src/where.c +++ b/src/where.c @@ -5122,7 +5122,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ /* TUNING: A full-scan of a VIEW or subquery in the outer loop ** is not so bad. */ - if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 ){ + if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 && nLoop>1 ){ rCost += -10; nOut += -30; WHERETRACE(0x80,("VIEWSCAN cost reduction for %c\n",pWLoop->cId)); From 37fd50df1fdf67ba2d46dab956b921d14ad956be Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 19 Jul 2023 09:52:10 +0000 Subject: [PATCH 5/5] Two minor improvements to sum(), one of which was inspired by [forum:/forumpost/af5be98dbc|forum post af5be98dbc]. FossilOrigin-Name: a0d3e7571aded8d1e03908059d2d5aa5d62ec49bff099cb38f6f35df5e4b18b5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index e1145c527f..575934e4e2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\suse\sthe\s[/info/609fbb94b8f01d67|viewscan\soptimization]\son\sa\squery\nthat\shas\sonly\sa\ssingle\sloop,\sas\sthe\scost\sadjustments\scan\scause\sproblems\nfor\souter\squeries.\s\sProposed\sfix\sfor\sthe\sperformance\sregression\sreported\sby\n[forum:/forumpost/64d36440e473516c|forum\spost\s64d36440e473516c]. -D 2023-07-18T21:06:19.893 +C Two\sminor\simprovements\sto\ssum(),\sone\sof\swhich\swas\sinspired\sby\n[forum:/forumpost/af5be98dbc|forum\spost\saf5be98dbc]. +D 2023-07-19T09:52:10.467 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -590,7 +590,7 @@ F src/delete.c cd5f5cd06ed0b6a882ec1a8c2a0d73b3cecb28479ad19e9931c4706c5e2182be F src/expr.c 8d1656b65e26af3e34f78e947ac423f0d20c214ed25a67486e433bf16ca6b543 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c a7fcbf7e66d14dbb73cf49f31489ebf66d0e6006c62b95246924a3bae9f37b36 -F src/func.c cffa6edb4aa4865d8e237022399ba9c2b22fd11e5581efba7c5b524b525952ca +F src/func.c 25f2e0204c011be56fc3c9a180534b68ca4866c61ec19806880136450434112d F src/global.c 29f56a330ed9d1b5cd9b79ac0ca36f97ac3afc730ff8bfa987b0db9e559d684d F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -2043,8 +2043,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 27057ea76b5f72c73fb6f16094736685019643c665b49fd0bb8d60a812ce2338 -R e083cfeae9842a7650b26a959bcc57e4 +P 76152ad2ffe56034f2fd93d9a1ce9358e1677a7e9cd3dcd9f3a34a5c956a463e +R 47d8d8ca9ec8151ad0210262a08ac711 U drh -Z 4c6375f8dd8261298072fd9d19053ffb +Z b98de7129167c58b9385610fbdec3119 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 24332574c1..4a5750f1d2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76152ad2ffe56034f2fd93d9a1ce9358e1677a7e9cd3dcd9f3a34a5c956a463e \ No newline at end of file +a0d3e7571aded8d1e03908059d2d5aa5d62ec49bff099cb38f6f35df5e4b18b5 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 542d71a23d..8382e4a5c5 100644 --- a/src/func.c +++ b/src/func.c @@ -1764,11 +1764,10 @@ static void sumStep(sqlite3_context *context, int argc, sqlite3_value **argv){ p->ovrfl = 1; kahanBabuskaNeumaierInit(p, p->iSum); p->approx = 1; - kahanBabuskaNeumaierStep(p, sqlite3_value_double(argv[0])); + kahanBabuskaNeumaierStepInt64(p, sqlite3_value_int64(argv[0])); } } }else{ - p->approx = 1; if( type==SQLITE_INTEGER ){ kahanBabuskaNeumaierStepInt64(p, sqlite3_value_int64(argv[0])); }else{