From: drh Date: Thu, 7 Nov 2013 23:23:27 +0000 (+0000) Subject: Add many new options to the wordcount test program: --delete, --pagesize, X-Git-Tag: version-3.8.2~131 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ac873261c4e592b087a33119b28575c118996007;p=thirdparty%2Fsqlite.git Add many new options to the wordcount test program: --delete, --pagesize, --cachesize, --commit, --nosync, and --journal. FossilOrigin-Name: e938112d316ca31460f247cc104ca3ff1d60b4da --- diff --git a/manifest b/manifest index c955dd6734..3c3a6b0049 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scompiler\swarning\sintroduced\sby\sthe\sprevious\scheck-in. -D 2013-11-07T21:32:16.228 +C Add\smany\snew\soptions\sto\sthe\swordcount\stest\sprogram:\s--delete,\s--pagesize,\s\n--cachesize,\s--commit,\s--nosync,\sand\s--journal. +D 2013-11-07T23:23:27.610 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d12e4455cf7a36e42d3949876c1c3b88ff70867a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1083,7 +1083,7 @@ F test/without_rowid1.test aaa26da19d543cd8d3d2d0e686dfa255556c15c8 F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99 F test/without_rowid3.test eac3d5c8a1924725b58503a368f2cbd24fd6c8a0 F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a -F test/wordcount.c c1ed122d6d8c288c7f21922ad64bba206ac51646 +F test/wordcount.c f6af51ef16ae702b38328702cef3dd40e38f7315 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688 F test/zerodamage.test 209d7ed441f44cc5299e4ebffbef06fd5aabfefd 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.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 215307985590c2f3f7aa0d5a0b7799155a506045 -R 71f9cd0b217f1ebad72089e906d8786f +P 404bd98fb41f71d041932d68a908570995825ec1 +R f6f16de177380742336b391bf29945a9 U drh -Z 02285a59f788837fde6c69fc94247fe6 +Z b0cbff2a366519cd35e9a89b0b70c0e7 diff --git a/manifest.uuid b/manifest.uuid index 2befe228a2..74cd954d41 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -404bd98fb41f71d041932d68a908570995825ec1 \ No newline at end of file +e938112d316ca31460f247cc104ca3ff1d60b4da \ No newline at end of file diff --git a/test/wordcount.c b/test/wordcount.c index a90d989aff..8596abf7de 100644 --- a/test/wordcount.c +++ b/test/wordcount.c @@ -18,10 +18,16 @@ ** --replace Use REPLACE mode ** --select Use SELECT mode ** --update Use UPDATE mode +** --delete Use DELETE mode ** --nocase Add the NOCASE collating sequence to the words. ** --trace Enable sqlite3_trace() output. ** --summary Show summary information on the collected data. ** --stats Show sqlite3_status() results at the end. +** --pagesize NNN Use a page size of NNN +** --cachesize NNN Use a cache size of NNN +** --commit NNN Commit after every NNN operations +** --nosync Use PRAGMA synchronous=OFF +** --journal MMMM Use PRAGMA journal_mode=MMMM ** ** Modes: ** @@ -37,11 +43,20 @@ ** (1) REPLACE INTO wordcount ** VALUES($new,ifnull((SELECT cnt FROM wordcount WHERE word=$new),0)+1); ** -** Select mode modes: -** (1) SELECT 1 FROM wordcount WHERE word=$newword +** Select mode means: +** (1) SELECT 1 FROM wordcount WHERE word=$new ** (2) INSERT INTO wordcount VALUES($new,1) -- if (1) returns nothing ** (3) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new --if (1) return TRUE ** +** Delete mode means: +** (1) DELETE FROM wordcount WHERE word=$new +** +** Note that delete mode is only useful for preexisting databases. The +** wordcount table is created using IF NOT EXISTS so this utility can be +** run multiple times on the same database file. The --without-rowid, +** --nocase, and --pagesize parameters are only effective when creating +** a new database and are harmless no-ops on preexisting databases. +** ****************************************************************************** ** ** Compile as follows: @@ -93,6 +108,7 @@ static int printResult(void *NotUsed, int nArg, char **azArg, char **azNm){ #define MODE_REPLACE 1 #define MODE_SELECT 2 #define MODE_UPDATE 3 +#define MODE_DELETE 4 int main(int argc, char **argv){ const char *zFileToRead = 0; /* Input file. NULL for stdin */ @@ -103,12 +119,19 @@ int main(int argc, char **argv){ int doTrace = 0; /* True for --trace */ int showStats = 0; /* True for --stats */ int showSummary = 0; /* True for --summary */ + int cacheSize = 0; /* Desired cache size. 0 means default */ + int pageSize = 0; /* Desired page size. 0 means default */ + int commitInterval = 0; /* How often to commit. 0 means never */ + int noSync = 0; /* True for --nosync */ + const char *zJMode = 0; /* Journal mode */ + int nOp = 0; /* Operation counter */ int i, j; /* Loop counters */ sqlite3 *db; /* The SQLite database connection */ char *zSql; /* Constructed SQL statement */ sqlite3_stmt *pInsert = 0; /* The INSERT statement */ sqlite3_stmt *pUpdate = 0; /* The UPDATE statement */ sqlite3_stmt *pSelect = 0; /* The SELECT statement */ + sqlite3_stmt *pDelete = 0; /* The DELETE statement */ FILE *in; /* The open input file */ int rc; /* Return code from an SQLite interface */ int iCur, iHiwtr; /* Statistics values, current and "highwater" */ @@ -129,14 +152,29 @@ int main(int argc, char **argv){ iMode = MODE_INSERT; }else if( strcmp(z,"update")==0 ){ iMode = MODE_UPDATE; + }else if( strcmp(z,"delete")==0 ){ + iMode = MODE_DELETE; }else if( strcmp(z,"nocase")==0 ){ useNocase = 1; }else if( strcmp(z,"trace")==0 ){ doTrace = 1; + }else if( strcmp(z,"nosync")==0 ){ + noSync = 1; }else if( strcmp(z,"stats")==0 ){ showStats = 1; }else if( strcmp(z,"summary")==0 ){ showSummary = 1; + }else if( strcmp(z,"cachesize")==0 && i0 && (nOp%commitInterval)==0 ){ + sqlite3_exec(db, "COMMIT; BEGIN IMMEDIATE", 0, 0, 0); + } } } sqlite3_exec(db, "COMMIT", 0, 0, 0); @@ -278,6 +354,7 @@ int main(int argc, char **argv){ sqlite3_finalize(pInsert); sqlite3_finalize(pUpdate); sqlite3_finalize(pSelect); + sqlite3_finalize(pDelete); if( showSummary ){ sqlite3_exec(db,