mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
On the --summary output of wordcount, add the a PRAGMA integrity_check and
a 64-bit checksum of the entire table. FossilOrigin-Name: 1d1d13b89056903543c909b094030d205473fa82
This commit is contained in:
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
|||||||
C Add\smany\snew\soptions\sto\sthe\swordcount\stest\sprogram:\s--delete,\s--pagesize,\s\n--cachesize,\s--commit,\s--nosync,\sand\s--journal.
|
C On\sthe\s--summary\soutput\sof\swordcount,\sadd\sthe\sa\sPRAGMA\sintegrity_check\sand\na\s64-bit\schecksum\sof\sthe\sentire\stable.
|
||||||
D 2013-11-07T23:23:27.610
|
D 2013-11-08T00:16:58.039
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in d12e4455cf7a36e42d3949876c1c3b88ff70867a
|
F Makefile.in d12e4455cf7a36e42d3949876c1c3b88ff70867a
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@ -1083,7 +1083,7 @@ F test/without_rowid1.test aaa26da19d543cd8d3d2d0e686dfa255556c15c8
|
|||||||
F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
|
F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
|
||||||
F test/without_rowid3.test eac3d5c8a1924725b58503a368f2cbd24fd6c8a0
|
F test/without_rowid3.test eac3d5c8a1924725b58503a368f2cbd24fd6c8a0
|
||||||
F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
|
F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
|
||||||
F test/wordcount.c f6af51ef16ae702b38328702cef3dd40e38f7315
|
F test/wordcount.c 2c2cc1119de42e6730ca8bd149666f0e0095108a
|
||||||
F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688
|
F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688
|
||||||
F test/zerodamage.test 209d7ed441f44cc5299e4ebffbef06fd5aabfefd
|
F test/zerodamage.test 209d7ed441f44cc5299e4ebffbef06fd5aabfefd
|
||||||
F tool/build-all-msvc.bat 1bac6adc3fdb4d9204f21d17b14be25778370e48 x
|
F tool/build-all-msvc.bat 1bac6adc3fdb4d9204f21d17b14be25778370e48 x
|
||||||
@ -1135,7 +1135,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
||||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
||||||
P 404bd98fb41f71d041932d68a908570995825ec1
|
P e938112d316ca31460f247cc104ca3ff1d60b4da
|
||||||
R f6f16de177380742336b391bf29945a9
|
R 07f50decdc1dc09be9505de398f87899
|
||||||
U drh
|
U drh
|
||||||
Z b0cbff2a366519cd35e9a89b0b70c0e7
|
Z 566b6d1f5a2bce6772ade1b0310923b4
|
||||||
|
@ -1 +1 @@
|
|||||||
e938112d316ca31460f247cc104ca3ff1d60b4da
|
1d1d13b89056903543c909b094030d205473fa82
|
@ -93,16 +93,77 @@ static void traceCallback(void *NotUsed, const char *zSql){
|
|||||||
** each column separated by a single space. */
|
** each column separated by a single space. */
|
||||||
static int printResult(void *NotUsed, int nArg, char **azArg, char **azNm){
|
static int printResult(void *NotUsed, int nArg, char **azArg, char **azNm){
|
||||||
int i;
|
int i;
|
||||||
const char *zFormat = "%s";
|
printf("--");
|
||||||
for(i=0; i<nArg; i++){
|
for(i=0; i<nArg; i++){
|
||||||
printf(zFormat, azArg[i]);
|
printf(" %s", azArg[i]);
|
||||||
zFormat = " %s";
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Add one character to a hash
|
||||||
|
*/
|
||||||
|
static void addCharToHash(unsigned int *a, unsigned char x){
|
||||||
|
if( a[0]<4 ){
|
||||||
|
a[1] = (a[1]<<8) | x;
|
||||||
|
a[0]++;
|
||||||
|
}else{
|
||||||
|
a[2] = (a[2]<<8) | x;
|
||||||
|
a[0]++;
|
||||||
|
if( a[0]==8 ){
|
||||||
|
a[3] += a[1] + a[4];
|
||||||
|
a[4] += a[2] + a[3];
|
||||||
|
a[0] = a[1] = a[2] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Compute the final hash value.
|
||||||
|
*/
|
||||||
|
static void finalHash(unsigned int *a, char *z){
|
||||||
|
a[3] += a[1] + a[4] + a[0];
|
||||||
|
a[4] += a[2] + a[3];
|
||||||
|
sqlite3_snprintf(17, z, "%08x%08x", a[3], a[4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Implementation of a checksum() aggregate SQL function
|
||||||
|
*/
|
||||||
|
static void checksumStep(
|
||||||
|
sqlite3_context *context,
|
||||||
|
int argc,
|
||||||
|
sqlite3_value **argv
|
||||||
|
){
|
||||||
|
const unsigned char *zVal;
|
||||||
|
int nVal, i, j;
|
||||||
|
unsigned int *a;
|
||||||
|
a = (unsigned*)sqlite3_aggregate_context(context, sizeof(unsigned int)*5);
|
||||||
|
|
||||||
|
if( a ){
|
||||||
|
for(i=0; i<argc; i++){
|
||||||
|
nVal = sqlite3_value_bytes(argv[i]);
|
||||||
|
zVal = (const unsigned char*)sqlite3_value_text(argv[i]);
|
||||||
|
if( zVal ) for(j=0; j<nVal; j++) addCharToHash(a, zVal[j]);
|
||||||
|
addCharToHash(a, '|');
|
||||||
|
}
|
||||||
|
addCharToHash(a, '\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void checksumFinalize(sqlite3_context *context){
|
||||||
|
unsigned int *a;
|
||||||
|
char zResult[24];
|
||||||
|
a = sqlite3_aggregate_context(context, 0);
|
||||||
|
if( a ){
|
||||||
|
finalHash(a, zResult);
|
||||||
|
sqlite3_result_text(context, zResult, -1, SQLITE_TRANSIENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Define operating modes */
|
/* Define operating modes */
|
||||||
#define MODE_INSERT 0
|
#define MODE_INSERT 0
|
||||||
#define MODE_REPLACE 1
|
#define MODE_REPLACE 1
|
||||||
@ -357,13 +418,19 @@ int main(int argc, char **argv){
|
|||||||
sqlite3_finalize(pDelete);
|
sqlite3_finalize(pDelete);
|
||||||
|
|
||||||
if( showSummary ){
|
if( showSummary ){
|
||||||
|
sqlite3_create_function(db, "checksum", -1, SQLITE_UTF8, 0,
|
||||||
|
0, checksumStep, checksumFinalize);
|
||||||
sqlite3_exec(db,
|
sqlite3_exec(db,
|
||||||
"SELECT '-- count(*): ', count(*) FROM wordcount;\n"
|
"SELECT 'count(*): ', count(*) FROM wordcount;\n"
|
||||||
"SELECT '-- sum(cnt): ', sum(cnt) FROM wordcount;\n"
|
"SELECT 'sum(cnt): ', sum(cnt) FROM wordcount;\n"
|
||||||
"SELECT '-- avg(cnt): ', avg(cnt) FROM wordcount;\n"
|
"SELECT 'max(cnt): ', max(cnt) FROM wordcount;\n"
|
||||||
"SELECT '-- sum(cnt=1):', sum(cnt=1) FROM wordcount;\n"
|
"SELECT 'avg(cnt): ', avg(cnt) FROM wordcount;\n"
|
||||||
"SELECT '-- top 10: ', group_concat(word, ', ') FROM "
|
"SELECT 'sum(cnt=1):', sum(cnt=1) FROM wordcount;\n"
|
||||||
"(SELECT word FROM wordcount ORDER BY cnt DESC LIMIT 10);\n",
|
"SELECT 'top 10: ', group_concat(word, ', ') FROM "
|
||||||
|
"(SELECT word FROM wordcount ORDER BY cnt DESC LIMIT 10);\n"
|
||||||
|
"SELECT 'checksum: ', checksum(word, cnt) FROM "
|
||||||
|
"(SELECT word, cnt FROM wordcount ORDER BY word);\n"
|
||||||
|
"PRAGMA integrity_check;\n",
|
||||||
printResult, 0, 0);
|
printResult, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user