From cf85a51c2a7a89e52493efb3c0588e91771cb95e Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 9 Feb 2006 18:35:29 +0000 Subject: [PATCH] Deprecate the sqlite3_aggregate_count() API. Make sure all aggregate counters are 64 bits. Remove unused StdDev structure from func.c. Ticket #1669. (CVS 3065) FossilOrigin-Name: 44bd7ba432123ec77904b862d11521f4ab96d2cf --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/func.c | 15 ++------------- src/sqlite.h.in | 7 +++---- src/test_md5.c | 12 ++++++++---- src/vdbeapi.c | 7 ++++--- www/capi3ref.tcl | 11 +++++++---- 7 files changed, 35 insertions(+), 39 deletions(-) diff --git a/manifest b/manifest index d7b8d4fddb..29cb28ca88 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Integer\soverflow\sin\sSUM\scauses\san\sexception.\s\sTicket\s#1669.\s(CVS\s3064) -D 2006-02-09T17:47:42 +C Deprecate\sthe\ssqlite3_aggregate_count()\sAPI.\s\sMake\ssure\sall\saggregate\scounters\nare\s64\sbits.\s\sRemove\sunused\sStdDev\sstructure\sfrom\sfunc.c.\s\sTicket\s#1669.\s(CVS\s3065) +D 2006-02-09T18:35:30 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -43,7 +43,7 @@ F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e F src/delete.c 56ab34c3a384caa5d5ea06f5739944957e2e4213 F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/expr.c 1149c3380bfce27703f5e9bec7dfb8e51baaf9d9 -F src/func.c aad8c94768fe6b36563416facc19a198b5d7f8ed +F src/func.c 49f49131afb37d1f808e9b84029da8644fc4faf7 F src/hash.c 8747cf51d12de46512880dfcf1b68b4e24072863 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84 F src/insert.c 7e931b7f06afbcefcbbaab175c02eff8268db33f @@ -69,7 +69,7 @@ F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261 F src/select.c daee9b20702ba51cf3807fc1b130edd8846e3e48 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 F src/shell.c 738f55ed75fb36731e764bfdb40756ac43b90b08 -F src/sqlite.h.in 965128af2e36334824532aaa9b0909ab49436d1a +F src/sqlite.h.in 57d43548b59eed5116a322fc85bef4e3fc8a6bcc F src/sqliteInt.h 0121298397ac14eb468ab1ba9d488ac7ed7d88a1 F src/table.c 486dcfce532685b53b5a2b5da8bba0ded6fb2316 F src/tclsqlite.c 7764ab34df617b3d3cfd5f0fdf3444ed219c11d6 @@ -81,7 +81,7 @@ F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f F src/test6.c 60a02961ceb7b3edc25f5dc5c1ac2556622a76de F src/test7.c d28d3e62f9594923648fc6a8fb030eba36564ba1 F src/test_async.c 6776f5027ca6378c116ff5ccc2fe41b908e33772 -F src/test_md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217 +F src/test_md5.c e688969fc7db0acd9e4f4e0c33332e00228af60f F src/test_server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 F src/tokenize.c 9ae9a59238eb97fbc61baea280563b91100518fb F src/trigger.c 4d3644cbd16959b568c95ae73493402be8021b08 @@ -92,7 +92,7 @@ F src/vacuum.c 3865673cc66acd0717ecd517f6b8fdb2a5e7924b F src/vdbe.c 29c68f39ce8cba44814b0e1f3d909ef961eb28a7 F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13 F src/vdbeInt.h eb3f86ab08ef11635bc78eb88c3ff13f923c233b -F src/vdbeapi.c dcb2636f49b4807e34960d52a2fc257b3a751140 +F src/vdbeapi.c ee8e889d8b4df30e38cdcda63f4e9e515b292633 F src/vdbeaux.c 9bf50cdb6a6c40b8c06ca9a8d87cf90120a16797 F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5 F src/vdbemem.c 2034e93b32c14bda6e306bb54e3a8e930b963027 @@ -307,7 +307,7 @@ F www/audit.tcl 90e09d580f79c7efec0c7d6f447b7ec5c2dce5c0 F www/autoinc.tcl b357f5ba954b046ee35392ce0f884a2fcfcdea06 F www/c_interface.tcl b51b08591554c16a0c3ef718364a508ac25abc7e F www/capi3.tcl 7a7cc225fe02eb7ab861a6019b08baa0014409e1 -F www/capi3ref.tcl f5149a0115178d3ee07584c59a0c3ffd37dc0a66 +F www/capi3ref.tcl 458d541139b84155e518781dcb9ebe9f57fe5cbf F www/changes.tcl c36d331b25a3b193845c05a6fa3f914899634940 F www/common.tcl 14d121c28532ad20c3e349caa4db708b0b822083 F www/compile.tcl 276546d7eb445add5a867193bbd80f6919a6b084 @@ -351,7 +351,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 731f1e3245fafbda24355d5bdc5b249c4229305f -R 22cd9586db53f15d6d1d14e20e2bf24f +P c72b946198128cbceb12dffbdf4706d9fda0fd72 +R be1e635cafb90b5983ca91c9370b824f U drh -Z 643c5022622d4cd302ee4b3efceecf09 +Z d6f4b8669c07081bb92ea3ba047fbeee diff --git a/manifest.uuid b/manifest.uuid index 5cd4f5e273..84493ebc99 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c72b946198128cbceb12dffbdf4706d9fda0fd72 \ No newline at end of file +44bd7ba432123ec77904b862d11521f4ab96d2cf \ No newline at end of file diff --git a/src/func.c b/src/func.c index 5cd4c9ea87..3e685c6e44 100644 --- a/src/func.c +++ b/src/func.c @@ -16,7 +16,7 @@ ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.119 2006/02/09 17:47:42 drh Exp $ +** $Id: func.c,v 1.120 2006/02/09 18:35:30 drh Exp $ */ #include "sqliteInt.h" #include @@ -818,7 +818,7 @@ static void test_error( typedef struct SumCtx SumCtx; struct SumCtx { LONGDOUBLE_TYPE sum; /* Sum of terms */ - u32 cnt; /* Number of elements summed */ + i64 cnt; /* Number of elements summed */ u8 seenFloat; /* True if there has been any floating point value */ }; @@ -872,17 +872,6 @@ static void totalFinalize(sqlite3_context *context){ sqlite3_result_double(context, p ? p->sum : 0.0); } -/* -** An instance of the following structure holds the context of a -** variance or standard deviation computation. -*/ -typedef struct StdDevCtx StdDevCtx; -struct StdDevCtx { - double sum; /* Sum of terms */ - double sum2; /* Sum of the squares of terms */ - int cnt; /* Number of terms counted */ -}; - /* ** The following structure keeps track of state information for the ** count() aggregate function. diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 61af9a31da..09803f75ff 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -12,7 +12,7 @@ ** This header file defines the interface that the SQLite library ** presents to client programs. ** -** @(#) $Id: sqlite.h.in,v 1.158 2006/02/09 13:43:29 danielk1977 Exp $ +** @(#) $Id: sqlite.h.in,v 1.159 2006/02/09 18:35:30 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ @@ -981,9 +981,8 @@ int sqlite3_create_function16( ); /* -** The next routine returns the number of calls to xStep for a particular -** aggregate function instance. The current call to xStep counts so this -** routine always returns at least 1. +** This function is deprecated. Do not use it. It continues to exist +** so as not to break legacy code. But new code should avoid using it. */ int sqlite3_aggregate_count(sqlite3_context*); diff --git a/src/test_md5.c b/src/test_md5.c index a4c9931fba..f0da4db5e1 100644 --- a/src/test_md5.c +++ b/src/test_md5.c @@ -45,11 +45,12 @@ #endif struct Context { + int isInit; uint32 buf[4]; uint32 bits[2]; unsigned char in[64]; }; -typedef char MD5Context[88]; +typedef struct Context MD5Context; /* * Note: this code is harmless on little-endian machines. @@ -166,8 +167,8 @@ static void MD5Transform(uint32 buf[4], const uint32 in[16]){ * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ -static void MD5Init(MD5Context *pCtx){ - struct Context *ctx = (struct Context *)pCtx; +static void MD5Init(MD5Context *ctx){ + ctx->isInit = 1; ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; ctx->buf[2] = 0x98badcfe; @@ -352,6 +353,9 @@ int Md5_Init(Tcl_Interp *interp){ return TCL_OK; } +/* +** + /* ** During testing, the special md5sum() aggregate function is available. ** inside SQLite. The following routines implement that function. @@ -362,7 +366,7 @@ static void md5step(sqlite3_context *context, int argc, sqlite3_value **argv){ if( argc<1 ) return; p = sqlite3_aggregate_context(context, sizeof(*p)); if( p==0 ) return; - if( sqlite3_aggregate_count(context)==1 ){ + if( !p->isInit ){ MD5Init(p); } for(i=0; ipFunc && p->pFunc->xStep ); diff --git a/www/capi3ref.tcl b/www/capi3ref.tcl index 5f33aca42b..4841f94107 100644 --- a/www/capi3ref.tcl +++ b/www/capi3ref.tcl @@ -1,4 +1,4 @@ -set rcsid {$Id: capi3ref.tcl,v 1.31 2006/01/30 22:12:31 drh Exp $} +set rcsid {$Id: capi3ref.tcl,v 1.32 2006/02/09 18:35:30 drh Exp $} source common.tcl header {C/C++ Interface For SQLite Version 3} puts { @@ -72,9 +72,12 @@ api {} { api {} { int sqlite3_aggregate_count(sqlite3_context*); } { - The next routine returns the number of calls to xStep for a particular - aggregate function instance. The current call to xStep counts so this - routine always returns at least 1. + This function is deprecated. It continues to exist so as not to + break any legacy code that might happen to use it. But it should not + be used in any new code. + + In order to encourage people to not use this function, we are not going + to tell you what it does. } api {} { -- 2.47.2