diff --git a/Makefile.in b/Makefile.in index 5593b4c6ff..3d7c74ba37 100644 --- a/Makefile.in +++ b/Makefile.in @@ -934,6 +934,7 @@ clean: rm -f mkkeywordhash$(BEXE) keywordhash.h rm -f $(PUBLISH) rm -f *.da *.bb *.bbg gmon.out + rm -rf quota2a quota2b quota2c rm -rf tsrc .target_source rm -f tclsqlite3$(TEXE) rm -f testfixture$(TEXE) test.db diff --git a/Makefile.msc b/Makefile.msc index 8e3fed8f8c..83293cf6db 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1001,6 +1001,9 @@ clean: del /Q mkkeywordhash.exe keywordhash.h -rmdir /Q/S .deps -rmdir /Q/S .libs + -rmdir /Q/S quota2a + -rmdir /Q/S quota2b + -rmdir /Q/S quota2c -rmdir /Q/S tsrc del /Q .target_source del /Q tclsqlite3.exe diff --git a/Makefile.vxworks b/Makefile.vxworks index 8d57da7283..4398c18265 100644 --- a/Makefile.vxworks +++ b/Makefile.vxworks @@ -657,6 +657,7 @@ clean: rm -f lemon lempar.c parse.* sqlite*.tar.gz mkkeywordhash keywordhash.h rm -f $(PUBLISH) rm -f *.da *.bb *.bbg gmon.out + rm -rf quota2a quota2b quota2c rm -rf tsrc target_source rm -f testloadext.dll libtestloadext.so rm -f sqlite3.c fts?amal.c tclsqlite3.c diff --git a/ext/fts3/fts3_porter.c b/ext/fts3/fts3_porter.c index 84aa132229..579745b85f 100644 --- a/ext/fts3/fts3_porter.c +++ b/ext/fts3/fts3_porter.c @@ -630,6 +630,7 @@ static const sqlite3_tokenizer_module porterTokenizerModule = { porterOpen, porterClose, porterNext, + 0 }; /* diff --git a/ext/fts3/fts3_test.c b/ext/fts3/fts3_test.c index 7cbc9eae9f..01873d4978 100644 --- a/ext/fts3/fts3_test.c +++ b/ext/fts3/fts3_test.c @@ -317,6 +317,7 @@ static int fts3_configure_incr_load_cmd( return TCL_OK; } +#ifdef SQLITE_ENABLE_FTS3 /************************************************************************** ** Beginning of test tokenizer code. ** @@ -479,6 +480,7 @@ static int testTokenizerLanguage( } return rc; } +#endif static int fts3_test_tokenizer_cmd( ClientData clientData, @@ -486,6 +488,7 @@ static int fts3_test_tokenizer_cmd( int objc, Tcl_Obj *CONST objv[] ){ +#ifdef SQLITE_ENABLE_FTS3 static const sqlite3_tokenizer_module testTokenizerModule = { 1, testTokenizerCreate, @@ -503,6 +506,7 @@ static int fts3_test_tokenizer_cmd( Tcl_SetObjResult(interp, Tcl_NewByteArrayObj( (const unsigned char *)&pPtr, sizeof(sqlite3_tokenizer_module *) )); +#endif return TCL_OK; } diff --git a/ext/fts3/fts3_tokenizer1.c b/ext/fts3/fts3_tokenizer1.c index d11a499766..deea06d92b 100644 --- a/ext/fts3/fts3_tokenizer1.c +++ b/ext/fts3/fts3_tokenizer1.c @@ -218,6 +218,7 @@ static const sqlite3_tokenizer_module simpleTokenizerModule = { simpleOpen, simpleClose, simpleNext, + 0, }; /* diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 8f97c8be98..bc20dfa3f3 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -434,16 +434,42 @@ int sqlite3Fts3ReadLock(Fts3Table *p){ return rc; } +/* +** FTS maintains a separate indexes for each language-id (a 32-bit integer). +** Within each language id, a separate index is maintained to store the +** document terms, and each configured prefix size (configured the FTS +** "prefix=" option). And each index consists of multiple levels ("relative +** levels"). +** +** All three of these values (the language id, the specific index and the +** level within the index) are encoded in 64-bit integer values stored +** in the %_segdir table on disk. This function is used to convert three +** separate component values into the single 64-bit integer value that +** can be used to query the %_segdir table. +** +** Specifically, each language-id/index combination is allocated 1024 +** 64-bit integer level values ("absolute levels"). The main terms index +** for language-id 0 is allocate values 0-1023. The first prefix index +** (if any) for language-id 0 is allocated values 1024-2047. And so on. +** Language 1 indexes are allocated immediately following language 0. +** +** So, for a system with nPrefix prefix indexes configured, the block of +** absolute levels that corresponds to language-id iLangid and index +** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024). +*/ static sqlite3_int64 getAbsoluteLevel( Fts3Table *p, int iLangid, int iIndex, int iLevel ){ + sqlite3_int64 iBase; /* First absolute level for iLangid/iIndex */ assert( iLangid>=0 ); assert( p->nIndex>0 ); assert( iIndex>=0 && iIndexnIndex ); - return (iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL + iLevel; + + iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL; + return iBase + iLevel; } @@ -468,7 +494,7 @@ int sqlite3Fts3AllSegdirs( Fts3Table *p, /* FTS3 table */ int iLangid, /* Language being queried */ int iIndex, /* Index for p->aIndex[] */ - int iLevel, /* Level to select */ + int iLevel, /* Level to select (relative level) */ sqlite3_stmt **ppStmt /* OUT: Compiled statement */ ){ int rc; @@ -483,7 +509,7 @@ int sqlite3Fts3AllSegdirs( rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0); if( rc==SQLITE_OK ){ sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); - sqlite3_bind_int(pStmt, 2, + sqlite3_bind_int64(pStmt, 2, getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1) ); } @@ -491,7 +517,7 @@ int sqlite3Fts3AllSegdirs( /* "SELECT * FROM %_segdir WHERE level = ? ORDER BY ..." */ rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0); if( rc==SQLITE_OK ){ - sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)); + sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel)); } } *ppStmt = pStmt; @@ -1763,7 +1789,7 @@ static int fts3WriteSegment( */ static int fts3WriteSegdir( Fts3Table *p, /* Virtual table handle */ - int iLevel, /* Value for "level" field */ + sqlite3_int64 iLevel, /* Value for "level" field (absolute level) */ int iIdx, /* Value for "idx" field */ sqlite3_int64 iStartBlock, /* Value for "start_block" field */ sqlite3_int64 iLeafEndBlock, /* Value for "leaves_end_block" field */ @@ -1774,7 +1800,7 @@ static int fts3WriteSegdir( sqlite3_stmt *pStmt; int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0); if( rc==SQLITE_OK ){ - sqlite3_bind_int(pStmt, 1, iLevel); + sqlite3_bind_int64(pStmt, 1, iLevel); sqlite3_bind_int(pStmt, 2, iIdx); sqlite3_bind_int64(pStmt, 3, iStartBlock); sqlite3_bind_int64(pStmt, 4, iLeafEndBlock); @@ -2157,7 +2183,7 @@ static int fts3SegWriterAdd( static int fts3SegWriterFlush( Fts3Table *p, /* Virtual table handle */ SegmentWriter *pWriter, /* SegmentWriter to flush to the db */ - int iLevel, /* Value for 'level' column of %_segdir */ + sqlite3_int64 iLevel, /* Value for 'level' column of %_segdir */ int iIdx /* Value for 'idx' column of %_segdir */ ){ int rc; /* Return code */ @@ -2239,7 +2265,7 @@ static int fts3SegmentMaxLevel( Fts3Table *p, int iLangid, int iIndex, - int *pnMax + sqlite3_int64 *pnMax ){ sqlite3_stmt *pStmt; int rc; @@ -2253,12 +2279,12 @@ static int fts3SegmentMaxLevel( */ rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0); if( rc!=SQLITE_OK ) return rc; - sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); - sqlite3_bind_int(pStmt, 2, + sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); + sqlite3_bind_int64(pStmt, 2, getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1) ); if( SQLITE_ROW==sqlite3_step(pStmt) ){ - *pnMax = sqlite3_column_int(pStmt, 0); + *pnMax = sqlite3_column_int64(pStmt, 0); } return sqlite3_reset(pStmt); } @@ -2307,15 +2333,17 @@ static int fts3DeleteSegdir( if( iLevel==FTS3_SEGCURSOR_ALL ){ rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0); if( rc==SQLITE_OK ){ - sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); - sqlite3_bind_int(pDelete, 2, + sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); + sqlite3_bind_int64(pDelete, 2, getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1) ); } }else{ rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0); if( rc==SQLITE_OK ){ - sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel)); + sqlite3_bind_int64( + pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel) + ); } } @@ -2792,7 +2820,7 @@ static int fts3SegmentMerge( ){ int rc; /* Return code */ int iIdx = 0; /* Index of new segment */ - int iNewLevel = 0; /* Level/index to create new segment at */ + sqlite3_int64 iNewLevel = 0; /* Level/index to create new segment at */ SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */ Fts3SegFilter filter; /* Segment term filter condition */ Fts3MultiSegReader csr; /* Cursor to iterate through level(s) */ diff --git a/main.mk b/main.mk index 423f8d7b85..d0cc7b0573 100644 --- a/main.mk +++ b/main.mk @@ -604,6 +604,7 @@ clean: rm -f mkkeywordhash mkkeywordhash.exe keywordhash.h rm -f $(PUBLISH) rm -f *.da *.bb *.bbg gmon.out + rm -rf quota2a quota2b quota2c rm -rf tsrc target_source rm -f testloadext.dll libtestloadext.so rm -f amalgamation-testfixture amalgamation-testfixture.exe diff --git a/manifest b/manifest index 6b587a1394..d9fb759883 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Merge\sin\sthe\slatest\strunk\schanges. -D 2012-03-05T16:26:00.280 +C Merge\sthe\slatest\strunk\schanges\sinto\sthe\ssessions\sbranch. +D 2012-03-19T11:17:17.067 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 +F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc ceec8f4ac0f7f463f5ec241dc0115de7a84daba2 -F Makefile.vxworks 1deb39c8bb047296c30161ffa10c1b5423e632f9 +F Makefile.msc efc373edae0f99cb3b04672ccefea8162664d40b +F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION bb4c2a86abe53ea3c1d6ea515b69a426040e2414 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -71,14 +71,14 @@ F ext/fts3/fts3_expr.c dbc7ba4c3a6061adde0f38ed8e9b349568299551 F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c 6c8f395cdf9e1e3afa7fadb7e523dbbf381c6dfa -F ext/fts3/fts3_porter.c b7e5276f9f0a5fc7018b6fa55ce0f31f269ef881 +F ext/fts3/fts3_porter.c a465b49fcb8249a755792f87516eff182efa42b3 F ext/fts3/fts3_snippet.c c9e126c20760988aa7c43c6ea1379db34738282e F ext/fts3/fts3_term.c d3466cf99432291be08e379d89645462431809d6 -F ext/fts3/fts3_test.c a026412a41450a014ccb7abdd5efaa7c9711d49e +F ext/fts3/fts3_test.c 6b7cc68aef4efb084e1449f7d20c4b20d3bdf6b4 F ext/fts3/fts3_tokenizer.c 3da7254a9881f7e270ab28e2004e0d22b3212bce F ext/fts3/fts3_tokenizer.h 66dec98e365854b6cd2d54f1a96bb6d428fc5a68 -F ext/fts3/fts3_tokenizer1.c 0dde8f307b8045565cf63797ba9acfaff1c50c68 -F ext/fts3/fts3_write.c f87bb2d27d31cb7a7bf306747079095393c9d073 +F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 +F ext/fts3/fts3_write.c 8eedfeb2e61114cfd94fd1d917daf3658203332c F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -117,7 +117,7 @@ F ext/session/sqlite3session.h f374c9c4c96e08f67ac418871c29d423245c7673 F ext/session/test_session.c ea4dc9b4a1895c8e6bddcbfe3838d7eb57df2d99 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F main.mk 0f09cc961194da519af6bdd3004bb3ec9ebddc80 +F main.mk a7a6511a621e89c25b59deb9614cf83611d724e1 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -131,7 +131,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 149cc80d9257971b0bff34e58fb2263e01998289 -F src/analyze.c f32ff304da413851eefa562b04e61ff6cb88248b +F src/analyze.c 70c46504c0d2543ea5cdca01140b2cd3e1d886e7 F src/attach.c 12c6957996908edc31c96d7c68d4942c2474405f F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 6be23a344d3301ae38e92fddb3a33b91c309fce4 @@ -159,7 +159,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c 18ef52feda1f9e151d1dcd032d0c7b95275a7397 +F src/main.c acab639c93295650b9ef056689e8092cfcf49f2a F src/malloc.c 15afac5e59b6584efe072e9933aefb4230e74f97 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -194,19 +194,19 @@ F src/resolve.c 3d3e80a98f203ac6b9329e9621e29eda85ddfd40 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 44ccdcb5d2a1c48622c179b2d72167b716388581 F src/shell.c aa28f117033ba3e44b5eaaf2ad572222bcdfd66e -F src/sqlite.h.in fc8237a04a17cb31addc670bc9abc99c6712d6d8 +F src/sqlite.h.in 7708d60987705890c8f7bb638202a69befcc1bf5 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h 3242e4adac818351aed6306a679df3390c771c8b +F src/sqliteInt.h f94543c697d5af8e48f9132be52723d021e10101 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 4568e72dfd36b6a5911f93457364deb072e0b03a F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 47d088f383a106b2914ac970586fdab66c1bd169 -F src/test1.c 328cbe4a4ee6d10d67ece2a7adaa2770569fae0f +F src/test1.c 07f30e8714bab94d8de8a88865d9c59bc512a1a8 F src/test2.c 711555927f1f7e8db9aab86b512bc6934a774abe F src/test3.c 91d3f1a09cfae3533ef17d8b484a160f3d1f1a21 F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013 -F src/test6.c cf6ab27a59e1ab64b011bb251ba600131e803e59 +F src/test6.c 846ed1ed2f470de9b1e205fe3878a12e237b3e19 F src/test7.c 2e0781754905c8adc3268d8f0967e7633af58843 F src/test8.c 99f70341d6ec480313775127f4cd14b4a47db557 F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 @@ -265,7 +265,7 @@ F src/vtab.c ab90fb600a3f5e4b7c48d22a4cdb2d6b23239847 F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c f2cf59751f7facb4c422adf83ddc989aa5772874 +F src/where.c 6baab5dfcf4472552c0346d04f6fd2f4f8539c78 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 @@ -308,8 +308,8 @@ F test/backup_malloc.test 7162d604ec2b4683c4b3799a48657fb8b5e2d450 F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f F test/badutf2.test f5bc7f2d280670ecd79b9cf4f0f1760c607fe51f F test/between.test 16b1776c6323faadb097a52d673e8e3d8be7d070 -F test/bigfile.test a8ec8073a20207456dab01a29ad9cde42b0dd103 -F test/bigfile2.test f8e83eca9abef60692a34255a2ebcb96aff897fc +F test/bigfile.test 82dfe93ee7eb9e2e05641afa2b39ffd947a92ff1 +F test/bigfile2.test 852f948cb492aadab45b58f4d2f3b0832a115cb0 F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747 F test/bind.test 3c7b320969000c441a70952b0b15938fbb66237c F test/bindxfer.test efecd12c580c14df5f4ad3b3e83c667744a4f7e0 @@ -367,7 +367,7 @@ F test/crash.test 519dc29f6fea151f015a23236e555239353946eb F test/crash2.test 5b14d4eb58b880e231361d3b609b216acda86651 F test/crash3.test 8f5de9d32ab9ab95475a9efe7f47a940aa889418 F test/crash4.test fe2821baf37168dc59dd733dcf7dba2a401487bc -F test/crash5.test 69226a1b948d8961395b7ad2a1df084c212ce8cf +F test/crash5.test 13b9ca94e048194bca070e26160ce76b406c56be F test/crash6.test 4c56f1e40d0291e1110790a99807aa875b1647ba F test/crash7.test 6c6a369af266af2ef50ab34df8f94d719065e2c1 F test/crash8.test 38767cb504bbe491de6be4a7006b154973a2309f @@ -401,7 +401,7 @@ F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 F test/e_select.test f5d4b81205701deacfae42051ae200969c41d2c0 F test/e_select2.test 5c3d3da19c7b3e90ae444579db2b70098599ab92 F test/e_update.test 161d5dc6a3ed9dd08f5264d13e20735d7a89f00c -F test/e_uri.test 6f35b491f80dac005c8144f38b2dfb4d96483596 +F test/e_uri.test e8b894474fdfe7b18b0c9cb2d911270de2ad64ce F test/e_vacuum.test 331da289ae186656cf5f2eb27f577a89c0c221af F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 796c59832e2b9a52842f382ffda8f3e989db03ad @@ -416,7 +416,7 @@ F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 F test/exists.test 8f7b27b61c2fbe5822f0a1f899c715d14e416e30 F test/expr.test 67c9fd6f8f829e239dc8b0f4a08a73c08b09196d F test/fallocate.test b5d34437bd7ab01d41b1464b8117aefd4d32160e -F test/filectrl.test 4eb0178956ca25a756e6d79711a90fec7157b454 +F test/filectrl.test f0327bd804d9c7bd048fa7a151c5eab8e27df42b F test/filefmt.test ffa17b5aebc3eb4b1e3be1ccb5ee906ffbd97f6e F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da F test/fkey2.test 080969fe219b3b082b0e097ac18c6af2e5b0631f @@ -508,7 +508,7 @@ F test/fts3snippet.test 8e956051221a34c7daeb504f023cb54d5fa5a8b2 F test/fts3sort.test 95be0b19d7e41c44b29014f13ea8bddd495fd659 F test/fts4aa.test 6e7f90420b837b2c685f3bcbe84c868492d40a68 F test/fts4content.test 17b2360f7d1a9a7e5aa8022783f5c5731b6dfd4f -F test/fts4langid.test fabdd5a8db0fa00292e0704809f566e3fb6dba3a +F test/fts4langid.test 2081c357bb6f170f34ef8e08c6abb88002b95c69 F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a @@ -550,7 +550,7 @@ F test/interrupt.test 42e7cf98646fd9cb4a3b131a93ed3c50b9e149f1 F test/intpkey.test 537669fd535f62632ca64828e435b9e54e8d677f F test/io.test b278aa8fa609ed0dcc825df31b2d9f526c5a52bd F test/ioerr.test 40bb2cfcab63fb6aa7424cd97812a84bc16b5fb8 -F test/ioerr2.test 1b56cb80d5b0726ee3ba325ca175734541e32955 +F test/ioerr2.test 9d71166f8466eda510f1af6137bdabaa82b5408d F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd F test/ioerr4.test f130fe9e71008577b342b8874d52984bd04ede2c F test/ioerr5.test 2edfa4fb0f896f733071303b42224df8bedd9da4 @@ -622,7 +622,7 @@ F test/misc3.test fe55130a43e444ee75e2156ff75dc96e964b5738 F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 -F test/misc7.test 6743b810884ef64ae14c07ad1f9f858c40c06100 +F test/misc7.test 4337d84e441f36cee62656f9f7ba8bc22a7ca721 F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054 F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a @@ -637,7 +637,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3 -F test/pager1.test efef0bb4035d7180ec58308f1d449475e4670b48 +F test/pager1.test cf8f40cf77b5c4f762b1e8492390d61b46a81623 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442 @@ -648,15 +648,15 @@ F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/permutations.test 24f0e5141b6aea74d023ac1d688c78df845d02dc -F test/pragma.test f11c59ec935a52edb4d3d5676d456588121fcefa +F test/pragma.test c51c148defe32bf4a419a522f95d26838d5cf677 F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26 -F test/quota.test af47d25c166aa7b33ef25f21bb7f2afb29d82c77 -F test/quota2.test 1b8df088e604f2df573f96e726b5e518cb0cddaa +F test/quota.test c2f778dab4c7fb07bcfa962cc5c762f36d8061dc +F test/quota2.test 7e1c84f71f59388963fa8181a1292c87ae814d2d F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6 F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459 F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df @@ -732,7 +732,7 @@ F test/tclsqlite.test 2f2aa887763af30641f5561bdc26c5d3fbc73a88 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2 F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d -F test/tester.tcl 58281fb65095d5cacb9b70f40d72bba9ff3fad34 +F test/tester.tcl a3e41436033f39f7009de8bc4cb0de09d63f500a F test/thread001.test 7cc2ce08f9cde95964736d11e91f9ab610f82f91 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -766,7 +766,7 @@ F test/tkt-80ba201079.test 9eb040d81c404f56838a6af93593f42790def63f F test/tkt-80e031a00f.test 9a154173461a4dbe2de49cda73963e04842d52f7 F test/tkt-8454a207b9.test c583a9f814a82a2b5ba95207f55001c9f0cd816c F test/tkt-91e2e8ba6f.test 08c4f94ae07696b05c9b822da0b4e5337a2f54c5 -F test/tkt-94c04eaadb.test be5ea61cb04dfdc047d19b5c5a9e75fa3da67a7f +F test/tkt-94c04eaadb.test fa9c71192f7e2ea2d51bf078bc34e8da6088bf71 F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67 F test/tkt-b1d3a2e531.test 610ef582413171b379652663111b1f996d9f8f78 F test/tkt-b351d95f9.test d14a503c414c5c58fdde3e80f9a3cfef986498c0 @@ -868,7 +868,7 @@ F test/tkt3997.test a335fa41ca3985660a139df7b734a26ef53284bd F test/tkt4018.test 7c2c9ba4df489c676a0a7a0e809a1fb9b2185bd1 F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/trace.test 4b36a41a3e9c7842151af6da5998f5080cdad9e5 -F test/trace2.test 962175290996d5f06dc4402ca218bbfc7df4cb20 +F test/trace2.test 37c3a05701e7f133ebdf078a61aa9479a23a73b0 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test d5337e61de45e66b1fcbf9db833fa8c82e624b22 F test/trans3.test 373ac5183cc56be69f48ae44090e7f672939f732 @@ -893,7 +893,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test a9870e46cc6f8390a494513d4f2bf55b5a8b3e46 F test/unordered.test f53095cee37851bf30130fa1bf299a8845e837bb F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test 0d289d32396bdbc491e9dc845f1a52e13f861e0b +F test/uri.test 78e869db1ff6331157b08ef089b1b3e65819c74c F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d F test/vacuum2.test af432e6e3bfc0ea20a80cb86a03c7d9876d38324 @@ -920,7 +920,7 @@ F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test 82f463886e18d7f8395a4b6167c91815efe54839 -F test/wal.test edefe316b4125d7f68004ea53c5e73c398d436cc +F test/wal.test 2fbf4bbd0cb03aff6ada8150f29808c79370d50b F test/wal2.test 8871e7fd2c86711ff415a5817d68ea3101a15312 F test/wal3.test 6504bbf348b2d6dfade64a064f1050fd617e8706 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c @@ -930,7 +930,7 @@ F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd F test/wal8.test 5ab217d21f7e5e86af2933a4ffd0d8357cc2c0bd F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe F test/walbak.test b9f68e39646375c2b877be906babcc15d38b4877 -F test/walbig.test 0ab8a430ef420a3114f7092e0f30fc9585ffa155 +F test/walbig.test f437473a16cfb314867c6b5d1dbcd519e73e3434 F test/walcksum.test f5447800a157c9e2234fbb8e80243f0813941bde F test/walcrash.test 4457436593be8c136f9148487c7dccd5e9013af2 F test/walcrash2.test 019d60b89d96c1937adb2b30b850ac7e86e5a142 @@ -950,10 +950,10 @@ F test/where3.test 667e75642102c97a00bf9b23d3cb267db321d006 F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b -F test/where7.test 814d7373413398e074f134cff5f8872e2c08bd3b +F test/where7.test 5c566388f0cc318b0032ce860f4ac5548e3c265a F test/where8.test a6c740fd286d7883e274e17b6230a9d672a7ab1f F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 -F test/where9.test cd4ee5e455799ddba7041e5ac539044bb24e3874 +F test/where9.test ae98dc22ef9b6f2bc81e9f164e41b38faa9bda06 F test/whereA.test 24c234263c8fe358f079d5e57d884fb569d2da0a F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5 F test/whereC.test 13ff5ec0dba407c0e0c075980c75b3275a6774e5 @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 361fb66a799f4f253e61ca94d999accde2c75b2c 99a9073b5e411ce94f38ce49608baaa15de8b850 -R 73eef84d2253d0c1c19d15becb5073fc -U drh -Z 84b512c9c826efc22484fef61936c099 +P ff86875ca35e04cea6c3d5e1b5117a4f227a6b15 32bb1ecee4e43a4683512dbca047abf735afd313 +R 948a6e5b4554cc0073571b0bc86d24bd +U dan +Z e481b29f0a9859d30dda533d61d9b2c9 diff --git a/manifest.uuid b/manifest.uuid index dbe8f15c1f..456b503bb7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ff86875ca35e04cea6c3d5e1b5117a4f227a6b15 \ No newline at end of file +2277c70b6f14e2f8043112a5c49a8bc18b7504f3 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index cbfdc8587e..4dfc331bef 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -932,6 +932,7 @@ static int loadStat3(sqlite3 *db, const char *zDb){ int eType; /* Datatype of a sample */ IndexSample *pSample; /* A slot in pIdx->aSample[] */ + assert( db->lookaside.bEnabled==0 ); if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){ return SQLITE_OK; } @@ -958,7 +959,7 @@ static int loadStat3(sqlite3 *db, const char *zDb){ if( pIdx==0 ) continue; assert( pIdx->nSample==0 ); pIdx->nSample = nSample; - pIdx->aSample = sqlite3MallocZero( nSample*sizeof(IndexSample) ); + pIdx->aSample = sqlite3DbMallocZero(db, nSample*sizeof(IndexSample)); pIdx->avgEq = pIdx->aiRowEst[1]; if( pIdx->aSample==0 ){ db->mallocFailed = 1; @@ -1031,7 +1032,7 @@ static int loadStat3(sqlite3 *db, const char *zDb){ if( n < 1){ pSample->u.z = 0; }else{ - pSample->u.z = sqlite3Malloc(n); + pSample->u.z = sqlite3DbMallocRaw(db, n); if( pSample->u.z==0 ){ db->mallocFailed = 1; sqlite3_finalize(pStmt); @@ -1107,7 +1108,10 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ /* Load the statistics from the sqlite_stat3 table. */ #ifdef SQLITE_ENABLE_STAT3 if( rc==SQLITE_OK ){ + int lookasideEnabled = db->lookaside.bEnabled; + db->lookaside.bEnabled = 0; rc = loadStat3(db, sInfo.zDatabase); + db->lookaside.bEnabled = lookasideEnabled; } #endif diff --git a/src/main.c b/src/main.c index 4c0fad4428..53a9a3ce63 100644 --- a/src/main.c +++ b/src/main.c @@ -2725,35 +2725,27 @@ int sqlite3_extended_result_codes(sqlite3 *db, int onoff){ */ int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){ int rc = SQLITE_ERROR; - int iDb; + Btree *pBtree; + sqlite3_mutex_enter(db->mutex); - if( zDbName==0 ){ - iDb = 0; - }else{ - for(iDb=0; iDbnDb; iDb++){ - if( strcmp(db->aDb[iDb].zName, zDbName)==0 ) break; - } - } - if( iDbnDb ){ - Btree *pBtree = db->aDb[iDb].pBt; - if( pBtree ){ - Pager *pPager; - sqlite3_file *fd; - sqlite3BtreeEnter(pBtree); - pPager = sqlite3BtreePager(pBtree); - assert( pPager!=0 ); - fd = sqlite3PagerFile(pPager); - assert( fd!=0 ); - if( op==SQLITE_FCNTL_FILE_POINTER ){ - *(sqlite3_file**)pArg = fd; - rc = SQLITE_OK; - }else if( fd->pMethods ){ - rc = sqlite3OsFileControl(fd, op, pArg); - }else{ - rc = SQLITE_NOTFOUND; - } - sqlite3BtreeLeave(pBtree); + pBtree = sqlite3DbNameToBtree(db, zDbName); + if( pBtree ){ + Pager *pPager; + sqlite3_file *fd; + sqlite3BtreeEnter(pBtree); + pPager = sqlite3BtreePager(pBtree); + assert( pPager!=0 ); + fd = sqlite3PagerFile(pPager); + assert( fd!=0 ); + if( op==SQLITE_FCNTL_FILE_POINTER ){ + *(sqlite3_file**)pArg = fd; + rc = SQLITE_OK; + }else if( fd->pMethods ){ + rc = sqlite3OsFileControl(fd, op, pArg); + }else{ + rc = SQLITE_NOTFOUND; } + sqlite3BtreeLeave(pBtree); } sqlite3_mutex_leave(db->mutex); return rc; @@ -3049,15 +3041,34 @@ sqlite3_int64 sqlite3_uri_int64( } /* -** Return the filename of the database associated with a database -** connection. +** Return the Btree pointer identified by zDbName. Return NULL if not found. */ -const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){ +Btree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){ int i; for(i=0; inDb; i++){ - if( db->aDb[i].pBt && sqlite3StrICmp(zDbName, db->aDb[i].zName)==0 ){ - return sqlite3BtreeGetFilename(db->aDb[i].pBt); + if( db->aDb[i].pBt + && (zDbName==0 || sqlite3StrICmp(zDbName, db->aDb[i].zName)==0) + ){ + return db->aDb[i].pBt; } } return 0; } + +/* +** Return the filename of the database associated with a database +** connection. +*/ +const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){ + Btree *pBt = sqlite3DbNameToBtree(db, zDbName); + return pBt ? sqlite3BtreeGetFilename(pBt) : 0; +} + +/* +** Return 1 if database is read-only or 0 if read/write. Return -1 if +** no such database exists. +*/ +int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){ + Btree *pBt = sqlite3DbNameToBtree(db, zDbName); + return pBt ? sqlite3PagerIsreadonly(sqlite3BtreePager(pBt)) : -1; +} diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9017f0225f..757e8514a5 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4494,6 +4494,15 @@ sqlite3 *sqlite3_db_handle(sqlite3_stmt*); */ const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); +/* +** CAPI3REF: Determine if a database is read-only +** +** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N +** of connection D is read-only, 0 if it is read/write, or -1 if N is not +** the name of a database on connection D. +*/ +int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); + /* ** CAPI3REF: Find the next prepared statement ** diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 9e15ae6b0b..33d4f65db1 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2710,6 +2710,7 @@ void sqlite3AddCollateType(Parse*, Token*); void sqlite3EndTable(Parse*,Token*,Token*,Select*); int sqlite3ParseUri(const char*,const char*,unsigned int*, sqlite3_vfs**,char**,char **); +Btree *sqlite3DbNameToBtree(sqlite3*,const char*); int sqlite3CodeOnce(Parse *); Bitvec *sqlite3BitvecCreate(u32); diff --git a/src/test1.c b/src/test1.c index 281823d5a8..e1220cf11f 100644 --- a/src/test1.c +++ b/src/test1.c @@ -4665,6 +4665,30 @@ static int test_db_filename( return TCL_OK; } +/* +** Usage: sqlite3_db_readonly DB DBNAME +** +** Return 1 or 0 if DBNAME is readonly or not. Return -1 if DBNAME does +** not exist. +*/ +static int test_db_readonly( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3 *db; + const char *zDbName; + if( objc!=3 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); + return TCL_ERROR; + } + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; + zDbName = Tcl_GetString(objv[2]); + Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_db_readonly(db, zDbName))); + return TCL_OK; +} + /* ** Usage: sqlite3_soft_heap_limit ?N? ** @@ -6055,6 +6079,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_release_memory", test_release_memory, 0}, { "sqlite3_db_release_memory", test_db_release_memory, 0}, { "sqlite3_db_filename", test_db_filename, 0}, + { "sqlite3_db_readonly", test_db_readonly, 0}, { "sqlite3_soft_heap_limit", test_soft_heap_limit, 0}, { "sqlite3_thread_cleanup", test_thread_cleanup, 0}, { "sqlite3_pager_refcounts", test_pager_refcounts, 0}, diff --git a/src/test6.c b/src/test6.c index 89f4a090b0..5f64cacca0 100644 --- a/src/test6.c +++ b/src/test6.c @@ -476,7 +476,15 @@ static int cfSync(sqlite3_file *pFile, int flags){ if( nName>nCrashFile ) nName = nCrashFile; } +#ifdef TRACE_CRASHTEST + printf("cfSync(): nName = %d, nCrashFile = %d, zName = %s, zCrashFile = %s\n", + nName, nCrashFile, zName, zCrashFile); +#endif + if( nName==nCrashFile && 0==memcmp(zName, zCrashFile, nName) ){ +#ifdef TRACE_CRASHTEST + printf("cfSync(): name matched, g.iCrash = %d\n", g.iCrash); +#endif if( (--g.iCrash)==0 ) isCrash = 1; } diff --git a/src/where.c b/src/where.c index eda8d5fb8e..e6083f0033 100644 --- a/src/where.c +++ b/src/where.c @@ -3802,8 +3802,7 @@ static Bitmask codeOneLoopStart( WhereInfo *pWInfo, /* Complete information about the WHERE clause */ int iLevel, /* Which level of pWInfo->a[] should be coded */ u16 wctrlFlags, /* One of the WHERE_* flags defined in sqliteInt.h */ - Bitmask notReady, /* Which tables are currently available */ - Expr *pWhere /* Complete WHERE clause */ + Bitmask notReady /* Which tables are currently available */ ){ int j, k; /* Loop counters */ int iCur; /* The VDBE cursor for the table */ @@ -4342,10 +4341,25 @@ static Bitmask codeOneLoopStart( ** Then for every term xN, evaluate as the subexpression: xN AND z ** That way, terms in y that are factored into the disjunction will ** be picked up by the recursive calls to sqlite3WhereBegin() below. + ** + ** Actually, each subexpression is converted to "xN AND w" where w is + ** the "interesting" terms of z - terms that did not originate in the + ** ON or USING clause of a LEFT JOIN, and terms that are usable as + ** indices. */ if( pWC->nTerm>1 ){ - pAndExpr = sqlite3ExprAlloc(pParse->db, TK_AND, 0, 0); - pAndExpr->pRight = pWhere; + int iTerm; + for(iTerm=0; iTermnTerm; iTerm++){ + Expr *pExpr = pWC->a[iTerm].pExpr; + if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; + if( pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_ORINFO) ) continue; + if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue; + pExpr = sqlite3ExprDup(pParse->db, pExpr, 0); + pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr); + } + if( pAndExpr ){ + pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0); + } } for(ii=0; iinTerm; ii++){ @@ -4387,7 +4401,10 @@ static Bitmask codeOneLoopStart( } } } - sqlite3DbFree(pParse->db, pAndExpr); + if( pAndExpr ){ + pAndExpr->pLeft = 0; + sqlite3ExprDelete(pParse->db, pAndExpr); + } sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk); sqlite3VdbeResolveLabel(v, iLoopBody); @@ -5043,7 +5060,7 @@ WhereInfo *sqlite3WhereBegin( for(i=0; ia[i]; explainOneScan(pParse, pTabList, pLevel, i, pLevel->iFrom, wctrlFlags); - notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady, pWhere); + notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady); pWInfo->iContinue = pLevel->addrCont; } diff --git a/test/bigfile.test b/test/bigfile.test index 52d74edbe6..d9470acfba 100644 --- a/test/bigfile.test +++ b/test/bigfile.test @@ -69,7 +69,7 @@ do_test bigfile-1.1 { # large files. So skip all of the remaining tests in this file. # db close -if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} { +if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} { puts "**** Unable to create a file larger than 4096 MB. *****" finish_test return @@ -109,7 +109,7 @@ do_test bigfile-1.4 { } $::MAGIC_SUM db close -if {[catch {fake_big_file 8192 [pwd]/test.db}]} { +if {[catch {fake_big_file 8192 [get_pwd]/test.db}]} { puts "**** Unable to create a file larger than 8192 MB. *****" finish_test return @@ -148,7 +148,7 @@ do_test bigfile-1.9 { } $::MAGIC_SUM db close -if {[catch {fake_big_file 16384 [pwd]/test.db}]} { +if {[catch {fake_big_file 16384 [get_pwd]/test.db}]} { puts "**** Unable to create a file larger than 16384 MB. *****" finish_test return diff --git a/test/bigfile2.test b/test/bigfile2.test index 9810d3a0f3..b13b75641b 100644 --- a/test/bigfile2.test +++ b/test/bigfile2.test @@ -29,7 +29,7 @@ do_execsql_test 1.1 { # are actually in use and new pages will be appended to the file. # db close -if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} { +if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} { puts "**** Unable to create a file larger than 4096 MB. *****" finish_test return diff --git a/test/crash5.test b/test/crash5.test index 42248d719e..a786712354 100644 --- a/test/crash5.test +++ b/test/crash5.test @@ -47,7 +47,7 @@ for {set ii 0} {$ii < 10} {incr ii} { do_test crash5-$ii.$jj.1 { crashsql -delay 1 -file test.db-journal -seed $ii -tclbody [join [list \ [list set iFail $jj] { - sqlite3_crashparams 0 [file join [pwd] test.db-journal] + sqlite3_crashparams 0 [file join [get_pwd] test.db-journal] # Begin a transaction and evaluate a "CREATE INDEX" statement # with the iFail'th malloc() set to fail. This operation will @@ -89,7 +89,7 @@ for {set ii 0} {$ii < 10} {incr ii} { # by writing page 4 out to the db file. If it crashes later on, # before syncing the journal... Corruption! # - sqlite3_crashparams 1 [file join [pwd] test.db-journal] + sqlite3_crashparams 1 [file join [get_pwd] test.db-journal] sqlite3_release_memory 8092 }]] {} expr 1 diff --git a/test/e_uri.test b/test/e_uri.test index 5275ec1b54..8110d70497 100644 --- a/test/e_uri.test +++ b/test/e_uri.test @@ -131,10 +131,10 @@ sqlite3_config_uri 1 if {$tcl_platform(platform) == "unix"} { set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI] foreach {tn uri error} " - 1 {file://localhost[pwd]/test.db} {not an error} - 2 {file://[pwd]/test.db} {not an error} - 3 {file://x[pwd]/test.db} {invalid uri authority: x} - 4 {file://invalid[pwd]/test.db} {invalid uri authority: invalid} + 1 {file://localhost[get_pwd]/test.db} {not an error} + 2 {file://[get_pwd]/test.db} {not an error} + 3 {file://x[get_pwd]/test.db} {invalid uri authority: x} + 4 {file://invalid[get_pwd]/test.db} {invalid uri authority: invalid} " { do_test 2.$tn { set DB [sqlite3_open_v2 $uri $flags ""] @@ -153,9 +153,9 @@ if {$tcl_platform(platform) == "unix"} { # parameters passed through to the VFS xOpen() methods. # foreach {tn uri parse} " - 1 {file:test.db#abc} {[pwd]/test.db {}} - 2 {file:test.db?a=b#abc} {[pwd]/test.db {a b}} - 3 {file:test.db?a=b#?c=d} {[pwd]/test.db {a b}} + 1 {file:test.db#abc} {[get_pwd]/test.db {}} + 2 {file:test.db?a=b#abc} {[get_pwd]/test.db {a b}} + 3 {file:test.db?a=b#?c=d} {[get_pwd]/test.db {a b}} " { do_filepath_test 3.$tn { parse_uri $uri } $parse } @@ -171,7 +171,7 @@ foreach {tn uri parse} " # path is interpreted as a relative path. # foreach {tn uri parse} " - 1 {file:test.db} {[pwd]/test.db {}} + 1 {file:test.db} {[get_pwd]/test.db {}} 2 {file:/test.db} {/test.db {}} 3 {file:///test.db} {/test.db {}} 4 {file://localhost/test.db} {/test.db {}} diff --git a/test/filectrl.test b/test/filectrl.test index 9f077d523c..1e4ec59853 100644 --- a/test/filectrl.test +++ b/test/filectrl.test @@ -34,7 +34,7 @@ do_test filectrl-1.4 { do_test filectrl-1.5 { db close sqlite3 db test_control_lockproxy.db - file_control_lockproxy_test db [pwd] + file_control_lockproxy_test db [get_pwd] } {} db close forcedelete .test_control_lockproxy.db-conch test.proxy diff --git a/test/fts4langid.test b/test/fts4langid.test index 08f1a21c17..8ad06766b7 100644 --- a/test/fts4langid.test +++ b/test/fts4langid.test @@ -382,4 +382,105 @@ do_catchsql_test 4.1.5 { INSERT INTO t4(content, lid) VALUES('hello world', 101) } {1 {SQL logic error or missing database}} +#------------------------------------------------------------------------- +# Test cases 5.* +# +# The following test cases are designed to detect a 32-bit overflow bug +# that existed at one point. +# +proc build_multilingual_db_3 {db} { + $db eval { + CREATE VIRTUAL TABLE t5 USING fts4(languageid=lid); + } + set languages [list 0 1 2 [expr 1<<30]] + + foreach lid $languages { + execsql { + INSERT INTO t5(docid, content, lid) VALUES( + $lid, 'My language is ' || $lid, $lid + ) + } + } +} + +do_test 5.1.0 { + reset_db + build_multilingual_db_3 db +} {} + +do_execsql_test 5.1.1 { + SELECT level FROM t5_segdir; +} [list 0 1024 2048 [expr 1<<40]] + +do_execsql_test 5.1.2 {SELECT docid FROM t5 WHERE t5 MATCH 'language'} 0 +foreach langid [list 0 1 2 [expr 1<<30]] { + do_execsql_test 5.2.$langid { + SELECT docid FROM t5 WHERE t5 MATCH 'language' AND lid = $langid + } $langid +} + +set lid [expr 1<<30] +do_execsql_test 5.3.1 { + CREATE VIRTUAL TABLE t6 USING fts4(languageid=lid); + INSERT INTO t6 VALUES('I belong to language 0!'); +} +do_test 5.3.2 { + for {set i 0} {$i < 20} {incr i} { + execsql { + INSERT INTO t6(content, lid) VALUES( + 'I (row '||$i||') belong to langauge N!', $lid + ); + } + } + execsql { SELECT docid FROM t6 WHERE t6 MATCH 'belong' } +} {1} + +do_test 5.3.3 { + execsql { SELECT docid FROM t6 WHERE t6 MATCH 'belong' AND lid=$lid} +} {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21} + +do_execsql_test 5.3.4 { INSERT INTO t6(t6) VALUES('optimize') } {} +do_execsql_test 5.3.5 { SELECT docid FROM t6 WHERE t6 MATCH 'belong' } {1} +do_execsql_test 5.3.6 { + SELECT docid FROM t6 WHERE t6 MATCH 'belong' AND lid=$lid +} {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21} + + +set lid [expr 1<<30] +foreach lid [list 4 [expr 1<<30]] { + do_execsql_test 5.4.$lid.1 { + DELETE FROM t6; + SELECT count(*) FROM t6_segdir; + SELECT count(*) FROM t6_segments; + } {0 0} + do_execsql_test 5.4.$lid.2 { + INSERT INTO t6(content, lid) VALUES('zero zero zero', $lid); + INSERT INTO t6(content, lid) VALUES('zero zero one', $lid); + INSERT INTO t6(content, lid) VALUES('zero one zero', $lid); + INSERT INTO t6(content, lid) VALUES('zero one one', $lid); + INSERT INTO t6(content, lid) VALUES('one zero zero', $lid); + INSERT INTO t6(content, lid) VALUES('one zero one', $lid); + INSERT INTO t6(content, lid) VALUES('one one zero', $lid); + INSERT INTO t6(content, lid) VALUES('one one one', $lid); + + SELECT docid FROM t6 WHERE t6 MATCH '"zero zero"' AND lid=$lid; + } {1 2 5} + + do_execsql_test 5.4.$lid.3 { + SELECT count(*) FROM t6_segdir; + SELECT count(*) FROM t6_segments; + } {8 0} + + do_execsql_test 5.4.$lid.4 { + INSERT INTO t6(t6) VALUES('optimize'); + SELECT docid FROM t6 WHERE t6 MATCH '"zero zero"' AND lid=$lid; + } {1 2 5} + + do_execsql_test 5.4.$lid.5 { + SELECT count(*) FROM t6_segdir; + SELECT count(*) FROM t6_segments; + } {1 0} +} + + finish_test diff --git a/test/ioerr2.test b/test/ioerr2.test index 325c0baded..5150ace3ab 100644 --- a/test/ioerr2.test +++ b/test/ioerr2.test @@ -130,7 +130,7 @@ do_test ioerr2-5 { } } msg] list $rc $msg -} {1 {callback requested query abort}} +} {1 {abort due to ROLLBACK}} if {$::tcl_platform(platform) == "unix"} { # Cause the call to xAccess used by [pragma temp_store_directory] to diff --git a/test/misc7.test b/test/misc7.test index c69e60bb7c..146dca0412 100644 --- a/test/misc7.test +++ b/test/misc7.test @@ -483,7 +483,7 @@ do_test misc7-20.1 { # Try to open a really long file name. # do_test misc7-21.1 { - set zFile [file join [pwd] "[string repeat abcde 104].db"] + set zFile [file join [get_pwd] "[string repeat abcde 104].db"] set rc [catch {sqlite3 db2 $zFile} msg] list $rc $msg } {1 {unable to open database file}} diff --git a/test/pager1.test b/test/pager1.test index 415eb6ab81..45253857c3 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -535,7 +535,7 @@ proc copy_on_mj_delete {method filename args} { return SQLITE_OK } -set pwd [pwd] +set pwd [get_pwd] foreach {tn1 tcl} { 1 { set prefix "test.db" } 2 { @@ -887,6 +887,24 @@ do_test pager1.4.7.3 { delete_file test.db-journal file exists test.db-journal } {0} +do_test pager1.4.8.1 { + catch {file attributes test.db -permissions r--------} + catch {file attributes test.db -readonly 1} + sqlite3 db test.db + db eval { SELECT * FROM t1 } + sqlite3_db_readonly db main +} {1} +do_test pager1.4.8.2 { + sqlite3_db_readonly db xyz +} {-1} +do_test pager1.4.8.3 { + db close + catch {file attributes test.db -readonly 0} + catch {file attributes test.db -permissions rw-rw-rw-} msg + sqlite3 db test.db + db eval { SELECT * FROM t1 } + sqlite3_db_readonly db main +} {0} #------------------------------------------------------------------------- # The following tests deal with multi-file commits. @@ -1001,7 +1019,7 @@ do_test pager1-5.4.1 { # the master-journal name encoded as utf-8 with no nul term. # set mj_pointer [expr { - 20 + [string length [pwd]] + [string length "/test.db-mjXXXXXX9XX"] + 20 + [string length [get_pwd]] + [string length "/test.db-mjXXXXXX9XX"] }] expr {$::max_journal==(512+2*(1024+8)+$mj_pointer)} } 1 @@ -1020,7 +1038,7 @@ do_test pager1-5.4.2 { # written starting at the next (in this case 512 byte) sector boundary. # set mj_pointer [expr { - 20 + [string length [pwd]] + [string length "/test.db-mjXXXXXX9XX"] + 20 + [string length [get_pwd]] + [string length "/test.db-mjXXXXXX9XX"] }] expr {$::max_journal==(((512+2*(1024+8)+511)/512)*512 + $mj_pointer)} } 1 diff --git a/test/pragma.test b/test/pragma.test index 3f17bd742b..bb10327c3a 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -990,7 +990,7 @@ do_test pragma-9.4 { } {} ifcapable wsd { do_test pragma-9.5 { - set pwd [string map {' ''} [file nativename [pwd]]] + set pwd [string map {' ''} [file nativename [get_pwd]]] execsql " PRAGMA temp_store_directory='$pwd'; " @@ -999,7 +999,7 @@ ifcapable wsd { execsql { PRAGMA temp_store_directory; } - } [list [file nativename [pwd]]] + } [list [file nativename [get_pwd]]] do_test pragma-9.7 { catchsql { PRAGMA temp_store_directory='/NON/EXISTENT/PATH/FOOBAR'; diff --git a/test/quota.test b/test/quota.test index e12b83a429..ec89086d35 100644 --- a/test/quota.test +++ b/test/quota.test @@ -221,7 +221,7 @@ do_test quota-3.3.1 { execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b set ::quota -} [list [file join [pwd] test.db] 5120] +} [list [file join [get_pwd] test.db] 5120] do_test quota-3.2.X { foreach db {db1a db2a db2b db1b} { catch { $db close } } diff --git a/test/quota2.test b/test/quota2.test index cf3449dafc..fae4d2dbd7 100644 --- a/test/quota2.test +++ b/test/quota2.test @@ -28,7 +28,7 @@ foreach dir {quota2a quota2a/x1 quota2a/x2 quota2b quota2c} { # that is the same across platforms. # unset -nocomplain ::quota_pwd ::quota_mapping -set ::quota_pwd [string map {\\ /} [pwd]] +set ::quota_pwd [string map {\\ /} [get_pwd]] set ::quota_mapping [list $::quota_pwd PWD] proc standard_path {x} { set x [string map {\\ /} $x] diff --git a/test/tester.tcl b/test/tester.tcl index b4f8fc7470..30f6e25575 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -19,6 +19,7 @@ # # Commands to manipulate the db and the file-system at a high level: # +# get_pwd # copy_file FROM TO # delete_file FILENAME # drop_all_tables ?DB? @@ -148,6 +149,24 @@ proc getFileRetryDelay {} { return $::G(file-retry-delay) } +# Return the string representing the name of the current directory. On +# Windows, the result is "normalized" to whatever our parent command shell +# is using to prevent case-mismatch issues. +# +proc get_pwd {} { + if {$::tcl_platform(platform) eq "windows"} { + # + # NOTE: Cannot use [file normalize] here because it would alter the + # case of the result to what Tcl considers canonical, which would + # defeat the purpose of this procedure. + # + return [string map [list \\ /] \ + [string trim [exec -- $::env(ComSpec) /c echo %CD%]]] + } else { + return [pwd] + } +} + # Copy file $from into $to. This is used because some versions of # TCL for windows (notably the 8.4.1 binary package shipped with the # current mingw release) have a broken "file copy" command. @@ -990,7 +1009,7 @@ proc crashsql {args} { # $crashfile gets compared to the native filename in # cfSync(), which can be different then what TCL uses by # default, so here we force it to the "nativename" format. - set cfile [string map {\\ \\\\} [file nativename [file join [pwd] $crashfile]]] + set cfile [string map {\\ \\\\} [file nativename [file join [get_pwd] $crashfile]]] set f [open crash.tcl w] puts $f "sqlite3_crash_enable 1" diff --git a/test/tkt-94c04eaadb.test b/test/tkt-94c04eaadb.test index cce8a98eb4..0063de664d 100644 --- a/test/tkt-94c04eaadb.test +++ b/test/tkt-94c04eaadb.test @@ -27,7 +27,7 @@ do_test tkt-94c94-1.1 { # Grow the file to larger than 4096MB (2^32 bytes) db close -if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} { +if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} { puts "**** Unable to create a file larger than 4096 MB. *****" finish_test return diff --git a/test/trace2.test b/test/trace2.test index 42738db3aa..0e3130ec00 100644 --- a/test/trace2.test +++ b/test/trace2.test @@ -141,6 +141,7 @@ ifcapable fts3 { INSERT INTO x1(x1) VALUES('optimize'); } { "INSERT INTO x1(x1) VALUES('optimize');" + "-- SELECT DISTINCT level / (1024 * ?) FROM 'main'.'x1_segdir'" "-- SELECT idx, start_block, leaves_end_block, end_block, root FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?ORDER BY level DESC, idx ASC" "-- SELECT max(level) FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?" "-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)" diff --git a/test/uri.test b/test/uri.test index 90074d0d27..93a32b773e 100644 --- a/test/uri.test +++ b/test/uri.test @@ -54,9 +54,9 @@ foreach {tn uri file} { if {$tcl_platform(platform)=="windows"} { if {$tn>14} break - set uri [string map [list PWD /[pwd]] $uri] + set uri [string map [list PWD /[get_pwd]] $uri] } else { - set uri [string map [list PWD [pwd]] $uri] + set uri [string map [list PWD [get_pwd]] $uri] } if {[file isdir $file]} {error "$file is a directory"} @@ -274,9 +274,9 @@ foreach {tn uri res} { } { if {$tcl_platform(platform)=="windows"} { - set uri [string map [list PWD [string range [pwd] 3 end]] $uri] + set uri [string map [list PWD [string range [get_pwd] 3 end]] $uri] } else { - set uri [string map [list PWD [string range [pwd] 1 end]] $uri] + set uri [string map [list PWD [string range [get_pwd] 1 end]] $uri] } do_test 6.$tn { diff --git a/test/wal.test b/test/wal.test index 3b63d3e792..9d2c6b14b4 100644 --- a/test/wal.test +++ b/test/wal.test @@ -1477,7 +1477,7 @@ foreach pgsz {512 1024 2048 4096 8192 16384 32768 65536} { # Test that when 1 or more pages are recovered from a WAL file, # sqlite3_log() is invoked to report this to the user. # -set walfile [file nativename [file join [pwd] test.db-wal]] +set walfile [file nativename [file join [get_pwd] test.db-wal]] catch {db close} forcedelete test.db do_test wal-23.1 { diff --git a/test/walbig.test b/test/walbig.test index 092db2381b..c43b7e2503 100644 --- a/test/walbig.test +++ b/test/walbig.test @@ -52,7 +52,7 @@ do_test walbig-1.0 { } {wal} db close -if {[catch {fake_big_file 5000 [pwd]/test.db}]} { +if {[catch {fake_big_file 5000 [get_pwd]/test.db}]} { puts "**** Unable to create a file larger than 5000 MB. *****" finish_test return diff --git a/test/where7.test b/test/where7.test index ffb7173d21..b6cd7ccbbc 100644 --- a/test/where7.test +++ b/test/where7.test @@ -23339,7 +23339,7 @@ do_execsql_test where7-3.1 { OR t301.c8 = 1407424651264000) ORDER BY t302.c5 LIMIT 200; } { - 0 0 1 {SEARCH TABLE t301 USING COVERING INDEX t301_c4 (c4=?) (~5 rows)} + 0 0 1 {SEARCH TABLE t301 USING COVERING INDEX t301_c4 (c4=?) (~10 rows)} 0 0 1 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)} 0 1 0 {SEARCH TABLE t302 USING INDEX t302_c8_c3 (c8=? AND c3>?) (~2 rows)} 0 0 0 {USE TEMP B-TREE FOR ORDER BY} diff --git a/test/where9.test b/test/where9.test index 8c5c96e2a8..23260a6b65 100644 --- a/test/where9.test +++ b/test/where9.test @@ -364,7 +364,7 @@ ifcapable explain { } { 0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)} 0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?) (~2 rows)} - 0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~5 rows)} + 0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~10 rows)} } do_execsql_test where9-3.2 { EXPLAIN QUERY PLAN @@ -374,7 +374,7 @@ ifcapable explain { } { 0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)} 0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?) (~2 rows)} - 0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~5 rows)} + 0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~10 rows)} } } @@ -453,8 +453,8 @@ ifcapable explain { do_execsql_test where9-5.1 { EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c=31031 OR d IS NULL) } { - 0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?) (~2 rows)} - 0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?) (~2 rows)} + 0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?) (~3 rows)} + 0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?) (~3 rows)} } # In contrast, b=1000 is preferred over any OR-clause. @@ -856,5 +856,25 @@ do_test where9-7.3.2 { } } {79 81} +# Fix for ticket [b7c8682cc17f32903f03a610bd0d35ffd3c1e6e4] +# "Incorrect result from LEFT JOIN with OR in the WHERE clause" +# +do_test where9-8.1 { + db eval { + CREATE TABLE t81(a INTEGER PRIMARY KEY, b, c, d); + CREATE TABLE t82(x INTEGER PRIMARY KEY, y); + CREATE TABLE t83(p INTEGER PRIMARY KEY, q); + + INSERT INTO t81 VALUES(2,3,4,5); + INSERT INTO t81 VALUES(3,4,5,6); + INSERT INTO t82 VALUES(2,4); + INSERT INTO t83 VALUES(5,55); + + SELECT * + FROM t81 LEFT JOIN t82 ON y=b JOIN t83 + WHERE c==p OR d==p + ORDER BY +a; + } +} {2 3 4 5 {} {} 5 55 3 4 5 6 2 4 5 55} finish_test