2 ** This C program extracts all "words" from an input document and adds them
3 ** to an SQLite database. A "word" is any contiguous sequence of alphabetic
4 ** characters. All digits, punctuation, and whitespace characters are
5 ** word separators. The database stores a single entry for each distinct
6 ** word together with a count of the number of occurrences of that word.
7 ** A fresh database is created automatically on each run.
9 ** wordcount DATABASE INPUTFILE
11 ** The INPUTFILE name can be omitted, in which case input it taken from
20 ** (1) INSERT OR IGNORE INTO wordcount VALUES($new,1)
21 ** (2) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new -- if (1) is a noop
24 ** (1) INSERT OR IGNORE INTO wordcount VALUES($new,0)
25 ** (2) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new
27 ** Replace mode means:
28 ** (1) REPLACE INTO wordcount
29 ** VALUES($new,ifnull((SELECT cnt FROM wordcount WHERE word=$new),0)+1);
32 ** (1) SELECT 1 FROM wordcount WHERE word=$new
33 ** (2) INSERT INTO wordcount VALUES($new,1) -- if (1) returns nothing
34 ** (3) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new --if (1) return TRUE
37 ** (1) DELETE FROM wordcount WHERE word=$new
40 ** (1) SELECT cnt FROM wordcount WHERE word=$new
42 ** Note that delete mode and query mode are only useful for preexisting
43 ** databases. The wordcount table is created using IF NOT EXISTS so this
44 ** utility can be run multiple times on the same database file. The
45 ** --without-rowid, --nocase, and --pagesize parameters are only effective
46 ** when creating a new database and are harmless no-ops on preexisting
49 ******************************************************************************
51 ** Compile as follows:
53 ** gcc -I. wordcount.c sqlite3.c -ldl -lpthreads
57 ** gcc -I. -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
58 ** wordcount.c sqlite3.c
71 #define ISALPHA(X) isalpha((unsigned char)(X))
74 "Usage: wordcount [OPTIONS] DATABASE [INPUT]\n"
75 " --all Repeat the test for all test modes\n"
76 " --cachesize NNN Use a cache size of NNN\n"
77 " --commit NNN Commit after every NNN operations\n"
78 " --delete Use DELETE mode\n"
79 " --insert Use INSERT mode (the default)\n"
80 " --journal MMMM Use PRAGMA journal_mode=MMMM\n"
81 " --nocase Add the NOCASE collating sequence to the words.\n"
82 " --nosync Use PRAGMA synchronous=OFF\n"
83 " --pagesize NNN Use a page size of NNN\n"
84 " --query Use QUERY mode\n"
85 " --replace Use REPLACE mode\n"
86 " --select Use SELECT mode\n"
87 " --stats Show sqlite3_status() results at the end.\n"
88 " --summary Show summary information on the collected data.\n"
89 " --tag NAME Tag all output using NAME. Use only stdout.\n"
90 " --timer Time the operation of this program\n"
91 " --trace Enable sqlite3_trace() output.\n"
92 " --update Use UPDATE mode\n"
93 " --without-rowid Use a WITHOUT ROWID table to store the words.\n"
99 /* Return the current wall-clock time */
100 static sqlite3_int64
realTime(void){
101 static sqlite3_vfs
*clockVfs
= 0;
103 if( clockVfs
==0 ) clockVfs
= sqlite3_vfs_find(0);
104 if( clockVfs
->iVersion
>=1 && clockVfs
->xCurrentTimeInt64
!=0 ){
105 clockVfs
->xCurrentTimeInt64(clockVfs
, &t
);
108 clockVfs
->xCurrentTime(clockVfs
, &r
);
109 t
= (sqlite3_int64
)(r
*86400000.0);
114 /* Print an error message and exit */
115 static void fatal_error(const char *zMsg
, ...){
118 vfprintf(stderr
, zMsg
, ap
);
123 /* Print a usage message and quit */
124 static void usage(void){
129 /* The sqlite3_trace() callback function */
130 static void traceCallback(void *NotUsed
, const char *zSql
){
131 printf("%s;\n", zSql
);
134 /* An sqlite3_exec() callback that prints results on standard output,
135 ** each column separated by a single space. */
136 static int printResult(void *NotUsed
, int nArg
, char **azArg
, char **azNm
){
139 for(i
=0; i
<nArg
; i
++){
140 printf(" %s", azArg
[i
] ? azArg
[i
] : "(null)");
148 ** Add one character to a hash
150 static void addCharToHash(unsigned int *a
, unsigned char x
){
152 a
[1] = (a
[1]<<8) | x
;
155 a
[2] = (a
[2]<<8) | x
;
160 a
[0] = a
[1] = a
[2] = 0;
166 ** Compute the final hash value.
168 static void finalHash(unsigned int *a
, char *z
){
169 a
[3] += a
[1] + a
[4] + a
[0];
171 sqlite3_snprintf(17, z
, "%08x%08x", a
[3], a
[4]);
176 ** Implementation of a checksum() aggregate SQL function
178 static void checksumStep(
179 sqlite3_context
*context
,
183 const unsigned char *zVal
;
186 a
= (unsigned*)sqlite3_aggregate_context(context
, sizeof(unsigned int)*5);
189 for(i
=0; i
<argc
; i
++){
190 nVal
= sqlite3_value_bytes(argv
[i
]);
191 zVal
= (const unsigned char*)sqlite3_value_text(argv
[i
]);
192 if( zVal
) for(j
=0; j
<nVal
; j
++) addCharToHash(a
, zVal
[j
]);
193 addCharToHash(a
, '|');
195 addCharToHash(a
, '\n');
198 static void checksumFinalize(sqlite3_context
*context
){
201 a
= sqlite3_aggregate_context(context
, 0);
203 finalHash(a
, zResult
);
204 sqlite3_result_text(context
, zResult
, -1, SQLITE_TRANSIENT
);
208 /* Define operating modes */
209 #define MODE_INSERT 0
210 #define MODE_REPLACE 1
211 #define MODE_SELECT 2
212 #define MODE_UPDATE 3
213 #define MODE_DELETE 4
216 #define MODE_ALL (-1)
219 static const char *azMode
[] = {
229 ** Determine if another iteration of the test is required. Return true
230 ** if so. Return zero if all iterations have finished.
233 int iMode
, /* The selected test mode */
234 int *piLoopCnt
, /* Iteration loop counter */
235 int *piMode2
, /* The test mode to use on the next iteration */
236 int *pUseWithoutRowid
/* Whether or not to use --without-rowid */
239 if( iMode
!=MODE_ALL
){
240 if( *piLoopCnt
) return 0;
245 if( (*piLoopCnt
)>=MODE_COUNT
*2 ) return 0;
247 *pUseWithoutRowid
= i
&1;
252 int main(int argc
, char **argv
){
253 const char *zFileToRead
= 0; /* Input file. NULL for stdin */
254 const char *zDbName
= 0; /* Name of the database file to create */
255 int useWithoutRowid
= 0; /* True for --without-rowid */
256 int iMode
= MODE_INSERT
; /* One of MODE_xxxxx */
257 int iMode2
; /* Mode to use for current --all iteration */
258 int iLoopCnt
= 0; /* Which iteration when running --all */
259 int useNocase
= 0; /* True for --nocase */
260 int doTrace
= 0; /* True for --trace */
261 int showStats
= 0; /* True for --stats */
262 int showSummary
= 0; /* True for --summary */
263 int showTimer
= 0; /* True for --timer */
264 int cacheSize
= 0; /* Desired cache size. 0 means default */
265 int pageSize
= 0; /* Desired page size. 0 means default */
266 int commitInterval
= 0; /* How often to commit. 0 means never */
267 int noSync
= 0; /* True for --nosync */
268 const char *zJMode
= 0; /* Journal mode */
269 int nOp
= 0; /* Operation counter */
270 int i
, j
; /* Loop counters */
271 sqlite3
*db
; /* The SQLite database connection */
272 char *zSql
; /* Constructed SQL statement */
273 sqlite3_stmt
*pInsert
= 0; /* The INSERT statement */
274 sqlite3_stmt
*pUpdate
= 0; /* The UPDATE statement */
275 sqlite3_stmt
*pSelect
= 0; /* The SELECT statement */
276 sqlite3_stmt
*pDelete
= 0; /* The DELETE statement */
277 FILE *in
; /* The open input file */
278 int rc
; /* Return code from an SQLite interface */
279 int iCur
, iHiwtr
; /* Statistics values, current and "highwater" */
280 FILE *pTimer
= stderr
; /* Output channel for the timer */
281 sqlite3_int64 sumCnt
= 0; /* Sum in QUERY mode */
282 sqlite3_int64 startTime
; /* Time of start */
283 sqlite3_int64 totalTime
= 0; /* Total time */
284 char zInput
[2000]; /* A single line of input */
286 /* Process command-line arguments */
287 for(i
=1; i
<argc
; i
++){
288 const char *z
= argv
[i
];
290 do{ z
++; }while( z
[0]=='-' );
291 if( strcmp(z
,"without-rowid")==0 ){
293 }else if( strcmp(z
,"replace")==0 ){
294 iMode
= MODE_REPLACE
;
295 }else if( strcmp(z
,"select")==0 ){
297 }else if( strcmp(z
,"insert")==0 ){
299 }else if( strcmp(z
,"update")==0 ){
301 }else if( strcmp(z
,"delete")==0 ){
303 }else if( strcmp(z
,"query")==0 ){
305 }else if( strcmp(z
,"all")==0 ){
308 }else if( strcmp(z
,"nocase")==0 ){
310 }else if( strcmp(z
,"trace")==0 ){
312 }else if( strcmp(z
,"nosync")==0 ){
314 }else if( strcmp(z
,"stats")==0 ){
316 }else if( strcmp(z
,"summary")==0 ){
318 }else if( strcmp(z
,"timer")==0 ){
320 }else if( strcmp(z
,"cachesize")==0 && i
<argc
-1 ){
322 cacheSize
= atoi(argv
[i
]);
323 }else if( strcmp(z
,"pagesize")==0 && i
<argc
-1 ){
325 pageSize
= atoi(argv
[i
]);
326 }else if( strcmp(z
,"commit")==0 && i
<argc
-1 ){
328 commitInterval
= atoi(argv
[i
]);
329 }else if( strcmp(z
,"journal")==0 && i
<argc
-1 ){
331 }else if( strcmp(z
,"tag")==0 && i
<argc
-1 ){
334 }else if( strcmp(z
, "help")==0 || strcmp(z
,"?")==0 ){
337 fatal_error("unknown option: \"%s\"\n"
338 "Use --help for a list of options\n",
341 }else if( zDbName
==0 ){
343 }else if( zFileToRead
==0 ){
344 zFileToRead
= argv
[i
];
346 fatal_error("surplus argument: \"%s\"\n", argv
[i
]);
352 startTime
= realTime();
354 /* Open the database and the input file */
355 if( zDbName
[0] && strcmp(zDbName
,":memory:")!=0 ){
358 if( sqlite3_open(zDbName
, &db
) ){
359 fatal_error("Cannot open database file: %s\n", zDbName
);
362 in
= fopen(zFileToRead
, "rb");
364 fatal_error("Could not open input file \"%s\"\n", zFileToRead
);
367 if( iMode
==MODE_ALL
){
368 fatal_error("The --all mode cannot be used with stdin\n");
373 /* Set database connection options */
374 if( doTrace
) sqlite3_trace(db
, traceCallback
, 0);
376 zSql
= sqlite3_mprintf("PRAGMA page_size=%d", pageSize
);
377 sqlite3_exec(db
, zSql
, 0, 0, 0);
381 zSql
= sqlite3_mprintf("PRAGMA cache_size=%d", cacheSize
);
382 sqlite3_exec(db
, zSql
, 0, 0, 0);
385 if( noSync
) sqlite3_exec(db
, "PRAGMA synchronous=OFF", 0, 0, 0);
387 zSql
= sqlite3_mprintf("PRAGMA journal_mode=%s", zJMode
);
388 sqlite3_exec(db
, zSql
, 0, 0, 0);
393 while( allLoop(iMode
, &iLoopCnt
, &iMode2
, &useWithoutRowid
) ){
394 /* Delete prior content in --all mode */
395 if( iMode
==MODE_ALL
){
396 if( sqlite3_exec(db
, "DROP TABLE IF EXISTS wordcount; VACUUM;",0,0,0) ){
397 fatal_error("Could not clean up prior iteration\n");
399 startTime
= realTime();
403 /* Construct the "wordcount" table into which to put the words */
404 if( sqlite3_exec(db
, "BEGIN IMMEDIATE", 0, 0, 0) ){
405 fatal_error("Could not start a transaction\n");
407 zSql
= sqlite3_mprintf(
408 "CREATE TABLE IF NOT EXISTS wordcount(\n"
409 " word TEXT PRIMARY KEY COLLATE %s,\n"
412 useNocase
? "nocase" : "binary",
413 useWithoutRowid
? " WITHOUT ROWID" : ""
415 if( zSql
==0 ) fatal_error("out of memory\n");
416 rc
= sqlite3_exec(db
, zSql
, 0, 0, 0);
417 if( rc
) fatal_error("Could not create the wordcount table: %s.\n",
421 /* Prepare SQL statements that will be needed */
422 if( iMode2
==MODE_QUERY
){
423 rc
= sqlite3_prepare_v2(db
,
424 "SELECT cnt FROM wordcount WHERE word=?1",
426 if( rc
) fatal_error("Could not prepare the SELECT statement: %s\n",
429 if( iMode2
==MODE_SELECT
){
430 rc
= sqlite3_prepare_v2(db
,
431 "SELECT 1 FROM wordcount WHERE word=?1",
433 if( rc
) fatal_error("Could not prepare the SELECT statement: %s\n",
435 rc
= sqlite3_prepare_v2(db
,
436 "INSERT INTO wordcount(word,cnt) VALUES(?1,1)",
438 if( rc
) fatal_error("Could not prepare the INSERT statement: %s\n",
441 if( iMode2
==MODE_SELECT
|| iMode2
==MODE_UPDATE
|| iMode2
==MODE_INSERT
){
442 rc
= sqlite3_prepare_v2(db
,
443 "UPDATE wordcount SET cnt=cnt+1 WHERE word=?1",
445 if( rc
) fatal_error("Could not prepare the UPDATE statement: %s\n",
448 if( iMode2
==MODE_INSERT
){
449 rc
= sqlite3_prepare_v2(db
,
450 "INSERT OR IGNORE INTO wordcount(word,cnt) VALUES(?1,1)",
452 if( rc
) fatal_error("Could not prepare the INSERT statement: %s\n",
455 if( iMode2
==MODE_UPDATE
){
456 rc
= sqlite3_prepare_v2(db
,
457 "INSERT OR IGNORE INTO wordcount(word,cnt) VALUES(?1,0)",
459 if( rc
) fatal_error("Could not prepare the INSERT statement: %s\n",
462 if( iMode2
==MODE_REPLACE
){
463 rc
= sqlite3_prepare_v2(db
,
464 "REPLACE INTO wordcount(word,cnt)"
465 "VALUES(?1,coalesce((SELECT cnt FROM wordcount WHERE word=?1),0)+1)",
467 if( rc
) fatal_error("Could not prepare the REPLACE statement: %s\n",
470 if( iMode2
==MODE_DELETE
){
471 rc
= sqlite3_prepare_v2(db
,
472 "DELETE FROM wordcount WHERE word=?1",
474 if( rc
) fatal_error("Could not prepare the DELETE statement: %s\n",
478 /* Process the input file */
479 while( fgets(zInput
, sizeof(zInput
), in
) ){
480 for(i
=0; zInput
[i
]; i
++){
481 if( !ISALPHA(zInput
[i
]) ) continue;
482 for(j
=i
+1; ISALPHA(zInput
[j
]); j
++){}
484 /* Found a new word at zInput[i] that is j-i bytes long.
485 ** Process it into the wordcount table. */
486 if( iMode2
==MODE_DELETE
){
487 sqlite3_bind_text(pDelete
, 1, zInput
+i
, j
-i
, SQLITE_STATIC
);
488 if( sqlite3_step(pDelete
)!=SQLITE_DONE
){
489 fatal_error("DELETE failed: %s\n", sqlite3_errmsg(db
));
491 sqlite3_reset(pDelete
);
492 }else if( iMode2
==MODE_SELECT
){
493 sqlite3_bind_text(pSelect
, 1, zInput
+i
, j
-i
, SQLITE_STATIC
);
494 rc
= sqlite3_step(pSelect
);
495 sqlite3_reset(pSelect
);
496 if( rc
==SQLITE_ROW
){
497 sqlite3_bind_text(pUpdate
, 1, zInput
+i
, j
-i
, SQLITE_STATIC
);
498 if( sqlite3_step(pUpdate
)!=SQLITE_DONE
){
499 fatal_error("UPDATE failed: %s\n", sqlite3_errmsg(db
));
501 sqlite3_reset(pUpdate
);
502 }else if( rc
==SQLITE_DONE
){
503 sqlite3_bind_text(pInsert
, 1, zInput
+i
, j
-i
, SQLITE_STATIC
);
504 if( sqlite3_step(pInsert
)!=SQLITE_DONE
){
505 fatal_error("Insert failed: %s\n", sqlite3_errmsg(db
));
507 sqlite3_reset(pInsert
);
509 fatal_error("SELECT failed: %s\n", sqlite3_errmsg(db
));
511 }else if( iMode2
==MODE_QUERY
){
512 sqlite3_bind_text(pSelect
, 1, zInput
+i
, j
-i
, SQLITE_STATIC
);
513 if( sqlite3_step(pSelect
)==SQLITE_ROW
){
514 sumCnt
+= sqlite3_column_int64(pSelect
, 0);
516 sqlite3_reset(pSelect
);
518 sqlite3_bind_text(pInsert
, 1, zInput
+i
, j
-i
, SQLITE_STATIC
);
519 if( sqlite3_step(pInsert
)!=SQLITE_DONE
){
520 fatal_error("INSERT failed: %s\n", sqlite3_errmsg(db
));
522 sqlite3_reset(pInsert
);
523 if( iMode2
==MODE_UPDATE
524 || (iMode2
==MODE_INSERT
&& sqlite3_changes(db
)==0)
526 sqlite3_bind_text(pUpdate
, 1, zInput
+i
, j
-i
, SQLITE_STATIC
);
527 if( sqlite3_step(pUpdate
)!=SQLITE_DONE
){
528 fatal_error("UPDATE failed: %s\n", sqlite3_errmsg(db
));
530 sqlite3_reset(pUpdate
);
535 /* Increment the operation counter. Do a COMMIT if it is time. */
537 if( commitInterval
>0 && (nOp
%commitInterval
)==0 ){
538 sqlite3_exec(db
, "COMMIT; BEGIN IMMEDIATE", 0, 0, 0);
542 sqlite3_exec(db
, "COMMIT", 0, 0, 0);
543 sqlite3_finalize(pInsert
); pInsert
= 0;
544 sqlite3_finalize(pUpdate
); pUpdate
= 0;
545 sqlite3_finalize(pSelect
); pSelect
= 0;
546 sqlite3_finalize(pDelete
); pDelete
= 0;
548 if( iMode2
==MODE_QUERY
&& iMode
!=MODE_ALL
){
549 printf("%s sum of cnt: %lld\n", zTag
, sumCnt
);
550 rc
= sqlite3_prepare_v2(db
,"SELECT sum(cnt*cnt) FROM wordcount", -1,
552 if( rc
==SQLITE_OK
&& sqlite3_step(pSelect
)==SQLITE_ROW
){
553 printf("%s double-check: %lld\n", zTag
,sqlite3_column_int64(pSelect
,0));
555 sqlite3_finalize(pSelect
);
560 sqlite3_int64 elapseTime
= realTime() - startTime
;
561 totalTime
+= elapseTime
;
562 fprintf(pTimer
, "%3d.%03d wordcount", (int)(elapseTime
/1000),
563 (int)(elapseTime
%1000));
564 if( iMode
==MODE_ALL
){
565 fprintf(pTimer
, " %s%s\n", azMode
[iMode2
],
566 useWithoutRowid
? " --without-rowid" : "");
568 for(i
=1; i
<argc
; i
++) if( i
!=showTimer
) fprintf(pTimer
," %s",argv
[i
]);
569 fprintf(pTimer
, "\n");
574 sqlite3_create_function(db
, "checksum", -1, SQLITE_UTF8
, 0,
575 0, checksumStep
, checksumFinalize
);
577 "SELECT 'count(*): ', count(*) FROM wordcount;\n"
578 "SELECT 'sum(cnt): ', sum(cnt) FROM wordcount;\n"
579 "SELECT 'max(cnt): ', max(cnt) FROM wordcount;\n"
580 "SELECT 'avg(cnt): ', avg(cnt) FROM wordcount;\n"
581 "SELECT 'sum(cnt=1):', sum(cnt=1) FROM wordcount;\n"
582 "SELECT 'top 10: ', group_concat(word, ', ') FROM "
583 "(SELECT word FROM wordcount ORDER BY cnt DESC, word LIMIT 10);\n"
584 "SELECT 'checksum: ', checksum(word, cnt) FROM "
585 "(SELECT word, cnt FROM wordcount ORDER BY word);\n"
586 "PRAGMA integrity_check;\n",
589 } /* End the --all loop */
591 /* Close the input file after the last read */
592 if( zFileToRead
) fclose(in
);
594 /* In --all mode, so the total time */
595 if( iMode
==MODE_ALL
&& showTimer
){
596 fprintf(pTimer
, "%3d.%03d wordcount --all\n", (int)(totalTime
/1000),
597 (int)(totalTime
%1000));
600 /* Database connection statistics printed after both prepared statements
601 ** have been finalized */
603 sqlite3_db_status(db
, SQLITE_DBSTATUS_LOOKASIDE_USED
, &iCur
, &iHiwtr
, 0);
604 printf("%s Lookaside Slots Used: %d (max %d)\n", zTag
, iCur
,iHiwtr
);
605 sqlite3_db_status(db
, SQLITE_DBSTATUS_LOOKASIDE_HIT
, &iCur
, &iHiwtr
, 0);
606 printf("%s Successful lookasides: %d\n", zTag
, iHiwtr
);
607 sqlite3_db_status(db
, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
, &iCur
,&iHiwtr
,0);
608 printf("%s Lookaside size faults: %d\n", zTag
, iHiwtr
);
609 sqlite3_db_status(db
, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
, &iCur
,&iHiwtr
,0);
610 printf("%s Lookaside OOM faults: %d\n", zTag
, iHiwtr
);
611 sqlite3_db_status(db
, SQLITE_DBSTATUS_CACHE_USED
, &iCur
, &iHiwtr
, 0);
612 printf("%s Pager Heap Usage: %d bytes\n", zTag
, iCur
);
613 sqlite3_db_status(db
, SQLITE_DBSTATUS_CACHE_HIT
, &iCur
, &iHiwtr
, 1);
614 printf("%s Page cache hits: %d\n", zTag
, iCur
);
615 sqlite3_db_status(db
, SQLITE_DBSTATUS_CACHE_MISS
, &iCur
, &iHiwtr
, 1);
616 printf("%s Page cache misses: %d\n", zTag
, iCur
);
617 sqlite3_db_status(db
, SQLITE_DBSTATUS_CACHE_WRITE
, &iCur
, &iHiwtr
, 1);
618 printf("%s Page cache writes: %d\n", zTag
, iCur
);
619 sqlite3_db_status(db
, SQLITE_DBSTATUS_SCHEMA_USED
, &iCur
, &iHiwtr
, 0);
620 printf("%s Schema Heap Usage: %d bytes\n", zTag
, iCur
);
621 sqlite3_db_status(db
, SQLITE_DBSTATUS_STMT_USED
, &iCur
, &iHiwtr
, 0);
622 printf("%s Statement Heap Usage: %d bytes\n", zTag
, iCur
);
627 /* Global memory usage statistics printed after the database connection
628 ** has closed. Memory usage should be zero at this point. */
630 sqlite3_status(SQLITE_STATUS_MEMORY_USED
, &iCur
, &iHiwtr
, 0);
631 printf("%s Memory Used (bytes): %d (max %d)\n", zTag
,iCur
,iHiwtr
);
632 sqlite3_status(SQLITE_STATUS_MALLOC_COUNT
, &iCur
, &iHiwtr
, 0);
633 printf("%s Outstanding Allocations: %d (max %d)\n",zTag
,iCur
,iHiwtr
);
634 sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW
, &iCur
, &iHiwtr
, 0);
635 printf("%s Pcache Overflow Bytes: %d (max %d)\n",zTag
,iCur
,iHiwtr
);
636 sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW
, &iCur
, &iHiwtr
, 0);
637 printf("%s Scratch Overflow Bytes: %d (max %d)\n",zTag
,iCur
,iHiwtr
);
638 sqlite3_status(SQLITE_STATUS_MALLOC_SIZE
, &iCur
, &iHiwtr
, 0);
639 printf("%s Largest Allocation: %d bytes\n",zTag
,iHiwtr
);
640 sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE
, &iCur
, &iHiwtr
, 0);
641 printf("%s Largest Pcache Allocation: %d bytes\n",zTag
,iHiwtr
);
642 sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE
, &iCur
, &iHiwtr
, 0);
643 printf("%s Largest Scratch Allocation: %d bytes\n",zTag
,iHiwtr
);