]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add an assert() to the implementation of count(*) that checks the
authordrh <drh@noemail.net>
Wed, 8 Apr 2009 23:04:14 +0000 (23:04 +0000)
committerdrh <drh@noemail.net>
Wed, 8 Apr 2009 23:04:14 +0000 (23:04 +0000)
correct operation of the sqlite3_aggregate_count() function. (CVS 6473)

FossilOrigin-Name: f322be3833c4a938ee7d9e4bcfd5decaca57db0b

manifest
manifest.uuid
src/func.c

index 9d73a45b342bd1c9d006c9a5882ad4a737a91314..111da394b5ceb275f13e164871fb5e3ebd0964f7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Reconfigure\sthe\sdefault\scase\sfor\sthe\sprintf\sswitch\sin\sorder\sto\simprove\nbranch\scoverage.\s(CVS\s6472)
-D 2009-04-08T16:10:04
+C Add\san\sassert()\sto\sthe\simplementation\sof\scount(*)\sthat\schecks\sthe\ncorrect\soperation\sof\sthe\ssqlite3_aggregate_count()\sfunction.\s(CVS\s6473)
+D 2009-04-08T23:04:14
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -113,7 +113,7 @@ F src/date.c 3e5c554b2f4f2d798761597c08147d7b15f35bea
 F src/delete.c eb1066b2f35489fee46ad765d2b66386fc7d8adf
 F src/expr.c ccc5b5fa3bac249a9ab6e5e10629d77ff293c9f8
 F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
-F src/func.c 99ae90d46154952e08282fcdfe72d08e9601e174
+F src/func.c 7d30fc856932dafc6cc94f8ad7c2b96d6a1cc02f
 F src/global.c 448419c44ce0701104c2121b0e06919b44514c0c
 F src/hash.c 5824e6ff7ba78cd34c8d6cd724367713583e5b55
 F src/hash.h 28f38ebb1006a5beedcb013bcdfe31befe7437ae
@@ -716,7 +716,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 6fe8b5d70247d9c6b70dd482db3990986be97e69
-R 1217eb61b95942982b0af25be8e3d84f
+P 3cc79162dbdbce9d08bb28942128780277101e0d
+R cad719d14d320e9183126e9bc8c80627
 U drh
-Z 52886030af0cdafae5902b187d1061f2
+Z f5295c7f28f949611e9fc538864887c4
index cb35b7e464fd166770c3c113f0afd3556c876fa5..210c3c4dce4a65b090e0038d2cb68b0467958460 100644 (file)
@@ -1 +1 @@
-3cc79162dbdbce9d08bb28942128780277101e0d
\ No newline at end of file
+f322be3833c4a938ee7d9e4bcfd5decaca57db0b
\ No newline at end of file
index 6cb8d5aa9fbc541c2954d0e5e0cf28f0ed5bb215..058b1580c0f9e2d03f3ea860b6ac907e34c94644 100644 (file)
@@ -16,7 +16,7 @@
 ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
 ** All other code has file scope.
 **
-** $Id: func.c,v 1.230 2009/04/02 14:05:22 drh Exp $
+** $Id: func.c,v 1.231 2009/04/08 23:04:14 drh Exp $
 */
 #include "sqliteInt.h"
 #include <stdlib.h>
@@ -1178,6 +1178,13 @@ static void countStep(sqlite3_context *context, int argc, sqlite3_value **argv){
   if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){
     p->n++;
   }
+
+  /* The sqlite3_aggregate_count() function is deprecated.  But just to make
+  ** sure it still operates correctly, verify that its count agrees with our 
+  ** internal count when using count(*) and when the total count can be
+  ** expressed as a 32-bit integer. */
+  assert( argc==1 || p==0 || p->n>0x7fffffff
+          || p->n==sqlite3_aggregate_count(context) );
 }   
 static void countFinalize(sqlite3_context *context){
   CountCtx *p;