From 07bdba86d55b298c44cacdf92f164c1a5953504c Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 23 Nov 2015 21:09:54 +0000 Subject: [PATCH 001/232] Add experimental support for LIKE, GLOB and REGEXP to the virtual table interface. FossilOrigin-Name: 277a5b4027d4c2caba8143228a4f7d6df899dbb4 --- manifest | 26 +++++++++++++++----------- manifest.uuid | 2 +- src/sqlite.h.in | 15 +++++++++------ src/test8.c | 6 ++++++ src/where.c | 3 +++ src/whereInt.h | 1 + src/whereexpr.c | 28 ++++++++++++++++++++++------ test/vtab1.test | 8 ++++---- test/vtabH.test | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 110 insertions(+), 28 deletions(-) create mode 100644 test/vtabH.test diff --git a/manifest b/manifest index 1ed1813193..77ed28994e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sobscure\smemory\sleak\sfound\sby\slibfuzzer\sthat\smay\soccur\sunder\ssome\scircumstances\sif\sexpanding\sa\s"*"\sexpression\scauses\sa\sSELECT\sto\sreturn\smore\sthan\s32767\scolumns. -D 2015-11-21T19:43:29.760 +C Add\sexperimental\ssupport\sfor\sLIKE,\sGLOB\sand\sREGEXP\sto\sthe\svirtual\stable\sinterface. +D 2015-11-23T21:09:54.478 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -341,7 +341,7 @@ F src/resolve.c f4c897ca76ca6d5e0b3f0499c627392ffe657c8e F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c e10586c750d87211caa8f4b239e2bfa6a2049e5b F src/shell.c f0f59ea60ad297f671b7ae0fb957a736ad17c92c -F src/sqlite.h.in fa62718f73553f06b2f2e362fd09ccb4e1cbb626 +F src/sqlite.h.in a71226fe80bded2af3b99c5aed7363ef486962e1 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 4b66e3e3435da4b4c8c83696d0349f0c503b3924 F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 @@ -356,7 +356,7 @@ F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e F src/test5.c 5a34feec76d9b3a86aab30fd4f6cc9c48cbab4c1 F src/test6.c 41cacf3b0dd180823919bf9e1fbab287c9266723 F src/test7.c 9c89a4f1ed6bb13af0ed805b8d782bd83fcd57e3 -F src/test8.c 610e3d523018ca63b08081795e76794a2121ec38 +F src/test8.c 59d91e1ff19aa91603aa409d4f41568cab1b9a2d F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8 F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12 @@ -416,10 +416,10 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 18b0ed49830cf04fe2d68224b41838a73ac6cd24 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba -F src/where.c 6aceb72cc58dc06922a9e1604d559c8ca4c3e728 -F src/whereInt.h 7892bb54cf9ca0ae5c7e6094491b94c9286dc647 +F src/where.c 6687fb2675d9c1c1936ceca77529e2f21fb3a769 +F src/whereInt.h 6afc0d70cf6213e58e8fbe10b6e50d1aa16f122f F src/wherecode.c 4c96182e7b25e4be54008dee2da5b9c2f8480b9b -F src/whereexpr.c bd4877cd4dd11f6ab551ef0054535ca3c6224950 +F src/whereexpr.c 12c6fa7576674d24bf0116364a39885925c89188 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1259,7 +1259,7 @@ F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test f6c3a39e0c819891265e1d0754e99960d81ef6c9 -F test/vtab1.test 6210e076997f176bedc300a87ad6404651b601dd +F test/vtab1.test ec5cb767277d7e0eff34d3a02824c1dd959a5959 F test/vtab2.test f8cd1bb9aba7143eba97812d9617880a36d247ad F test/vtab3.test b45f47d20f225ccc9c28dc915d92740c2dee311e F test/vtab4.test 942f8b8280b3ea8a41dae20e7822d065ca1cb275 @@ -1274,6 +1274,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test 7c4693638d7797ce2eda17af74292b97e705cc61 F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e +F test/vtabH.test 15e137d2af9b0b81fedca6697518eb8834c013f4 F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test ea8778d5b0df200adef2ca7c00c3c37d4375f772 @@ -1404,7 +1405,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 198d191b2f5ef7d63ac0093c701955c9052fd734 -R 8ed8d9e954ea81e19ae35a6836359b00 +P 60de5f23424552c98aa760ac89149a3d51f895be +R b6557d1407b51115ef511b97d0fc16c1 +T *branch * vtab-like-operator +T *sym-vtab-like-operator * +T -sym-trunk * U dan -Z f96d100152be981f85597b50bc9a8134 +Z 249ced27266ff2c4ebd31fcaec9b55b5 diff --git a/manifest.uuid b/manifest.uuid index 90fb983695..eee0121605 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -60de5f23424552c98aa760ac89149a3d51f895be \ No newline at end of file +277a5b4027d4c2caba8143228a4f7d6df899dbb4 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 13c97d8d4a..42652061fb 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5709,12 +5709,15 @@ struct sqlite3_index_info { ** an operator that is part of a constraint term in the wHERE clause of ** a query that uses a [virtual table]. */ -#define SQLITE_INDEX_CONSTRAINT_EQ 2 -#define SQLITE_INDEX_CONSTRAINT_GT 4 -#define SQLITE_INDEX_CONSTRAINT_LE 8 -#define SQLITE_INDEX_CONSTRAINT_LT 16 -#define SQLITE_INDEX_CONSTRAINT_GE 32 -#define SQLITE_INDEX_CONSTRAINT_MATCH 64 +#define SQLITE_INDEX_CONSTRAINT_EQ 2 +#define SQLITE_INDEX_CONSTRAINT_GT 4 +#define SQLITE_INDEX_CONSTRAINT_LE 8 +#define SQLITE_INDEX_CONSTRAINT_LT 16 +#define SQLITE_INDEX_CONSTRAINT_GE 32 +#define SQLITE_INDEX_CONSTRAINT_MATCH 64 +#define SQLITE_INDEX_CONSTRAINT_LIKE 65 +#define SQLITE_INDEX_CONSTRAINT_GLOB 66 +#define SQLITE_INDEX_CONSTRAINT_REGEXP 67 /* ** CAPI3REF: Register A Virtual Table Implementation diff --git a/src/test8.c b/src/test8.c index 2107710a99..6d70c3042b 100644 --- a/src/test8.c +++ b/src/test8.c @@ -849,6 +849,12 @@ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ zOp = ">="; break; case SQLITE_INDEX_CONSTRAINT_MATCH: zOp = "LIKE"; break; + case SQLITE_INDEX_CONSTRAINT_LIKE: + zOp = "like"; break; + case SQLITE_INDEX_CONSTRAINT_GLOB: + zOp = "glob"; break; + case SQLITE_INDEX_CONSTRAINT_REGEXP: + zOp = "regexp"; break; } if( zOp[0]=='L' ){ zNew = sqlite3_mprintf(" %s %s LIKE (SELECT '%%'||?||'%%')", diff --git a/src/where.c b/src/where.c index 1c87706ea2..737bfc4e6f 100644 --- a/src/where.c +++ b/src/where.c @@ -893,6 +893,9 @@ static sqlite3_index_info *allocateIndexInfo( pIdxCons[j].iTermOffset = i; op = (u8)pTerm->eOperator & WO_ALL; if( op==WO_IN ) op = WO_EQ; + if( op==WO_MATCH ){ + op = pTerm->eMatchOp; + } pIdxCons[j].op = op; /* The direct assignment in the previous line is possible only because ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The diff --git a/src/whereInt.h b/src/whereInt.h index cae09acc82..86164d8c1f 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -253,6 +253,7 @@ struct WhereTerm { u16 eOperator; /* A WO_xx value describing */ u16 wtFlags; /* TERM_xxx bit flags. See below */ u8 nChild; /* Number of children that must disable us */ + u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */ WhereClause *pWC; /* The clause this term is part of */ Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */ Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */ diff --git a/src/whereexpr.c b/src/whereexpr.c index 21301ac046..0cc2fd7209 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -282,16 +282,24 @@ static int isLikeOrGlob( ** If it is then return TRUE. If not, return FALSE. */ static int isMatchOfColumn( - Expr *pExpr /* Test this expression */ + Expr *pExpr, /* Test this expression */ + unsigned char *peOp2 /* OUT: 0 for MATCH, or else an op2 value */ ){ + struct Op2 { + const char *zOp; + unsigned char eOp2; + } aOp[] = { + { "match", SQLITE_INDEX_CONSTRAINT_MATCH }, + { "glob", SQLITE_INDEX_CONSTRAINT_GLOB }, + { "like", SQLITE_INDEX_CONSTRAINT_LIKE }, + { "regex", SQLITE_INDEX_CONSTRAINT_REGEXP } + }; ExprList *pList; + int i; if( pExpr->op!=TK_FUNCTION ){ return 0; } - if( sqlite3StrICmp(pExpr->u.zToken,"match")!=0 ){ - return 0; - } pList = pExpr->x.pList; if( pList->nExpr!=2 ){ return 0; @@ -299,7 +307,13 @@ static int isMatchOfColumn( if( pList->a[1].pExpr->op != TK_COLUMN ){ return 0; } - return 1; + for(i=0; iu.zToken, aOp[i].zOp)==0 ){ + *peOp2 = aOp[i].eOp2; + return 1; + } + } + return 0; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ @@ -876,6 +890,7 @@ static void exprAnalyze( int op; /* Top-level operator. pExpr->op */ Parse *pParse = pWInfo->pParse; /* Parsing context */ sqlite3 *db = pParse->db; /* Database connection */ + unsigned char eOp2; /* op2 value for LIKE/REGEXP/GLOB */ if( db->mallocFailed ){ return; @@ -1099,7 +1114,7 @@ static void exprAnalyze( ** virtual tables. The native query optimizer does not attempt ** to do anything with MATCH functions. */ - if( isMatchOfColumn(pExpr) ){ + if( isMatchOfColumn(pExpr, &eOp2) ){ int idxNew; Expr *pRight, *pLeft; WhereTerm *pNewTerm; @@ -1120,6 +1135,7 @@ static void exprAnalyze( pNewTerm->leftCursor = pLeft->iTable; pNewTerm->u.leftColumn = pLeft->iColumn; pNewTerm->eOperator = WO_MATCH; + pNewTerm->eMatchOp = eOp2; markTermAsChild(pWC, idxNew, idxTerm); pTerm = &pWC->a[idxTerm]; pTerm->wtFlags |= TERM_COPIED; diff --git a/test/vtab1.test b/test/vtab1.test index 84de4cffa5..d5fae941af 100644 --- a/test/vtab1.test +++ b/test/vtab1.test @@ -1306,10 +1306,10 @@ foreach {tn sql res filter} { {xFilter {SELECT rowid, * FROM 't6' WHERE b >= ? AND b < ?} J K} 1.3 "SELECT a FROM e6 WHERE b LIKE 'J%'" {3 4} - {xFilter {SELECT rowid, * FROM 't6'}} + {xFilter {SELECT rowid, * FROM 't6' WHERE b like ?} J%} 1.4 "SELECT a FROM e6 WHERE b LIKE 'j%'" {3 4} - {xFilter {SELECT rowid, * FROM 't6'}} + {xFilter {SELECT rowid, * FROM 't6' WHERE b like ?} j%} } { set echo_module {} do_execsql_test 18.$tn.1 $sql $res @@ -1319,10 +1319,10 @@ foreach {tn sql res filter} { do_execsql_test 18.2.0 { PRAGMA case_sensitive_like = ON } foreach {tn sql res filter} { 2.1 "SELECT a FROM e6 WHERE b LIKE 'J%'" {3 4} - {xFilter {SELECT rowid, * FROM 't6'}} + {xFilter {SELECT rowid, * FROM 't6' WHERE b like ?} J%} 2.2 "SELECT a FROM e6 WHERE b LIKE 'j%'" {} - {xFilter {SELECT rowid, * FROM 't6'}} + {xFilter {SELECT rowid, * FROM 't6' WHERE b like ?} j%} } { set echo_module {} do_execsql_test 18.$tn.1 $sql $res diff --git a/test/vtabH.test b/test/vtabH.test new file mode 100644 index 0000000000..b0577eccab --- /dev/null +++ b/test/vtabH.test @@ -0,0 +1,49 @@ +# 2015 Nov 24 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix vtabH + +ifcapable !vtab { + finish_test + return +} + +register_echo_module db + +do_execsql_test 1.0 { + CREATE TABLE t6(a, b TEXT); + CREATE INDEX i6 ON t6(b, a); + CREATE VIRTUAL TABLE e6 USING echo(t6); +} + +foreach {tn sql expect} { + 1 "SELECT * FROM e6 WHERE b LIKE 'abc'" { + xBestIndex {SELECT rowid, * FROM 't6' WHERE b like ?} + xFilter {SELECT rowid, * FROM 't6' WHERE b like ?} abc + } + + 2 "SELECT * FROM e6 WHERE b GLOB 'abc'" { + xBestIndex {SELECT rowid, * FROM 't6' WHERE b glob ?} + xFilter {SELECT rowid, * FROM 't6' WHERE b glob ?} abc + } +} { + do_test 1.$tn { + set echo_module {} + execsql $sql + set ::echo_module + } [list {*}$expect] +} + +finish_test From 3d4143a38a374e092ff6e41b99549f05b5d6dcf0 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 Nov 2015 00:49:44 +0000 Subject: [PATCH 002/232] Do not try to eliminate No-ops at the end of VDBE program as this can cause problems for some DISTINCT handling algorithms, and does not improve performance. This also fixes an assertion fault found by libFuzzer. FossilOrigin-Name: 19d9f9ce691963310fa73ac5ff728ea8dea9d2b2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 1ed1813193..164471ab97 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sobscure\smemory\sleak\sfound\sby\slibfuzzer\sthat\smay\soccur\sunder\ssome\scircumstances\sif\sexpanding\sa\s"*"\sexpression\scauses\sa\sSELECT\sto\sreturn\smore\sthan\s32767\scolumns. -D 2015-11-21T19:43:29.760 +C Do\snot\stry\sto\seliminate\sNo-ops\sat\sthe\send\sof\sVDBE\sprogram\sas\sthis\scan\scause\nproblems\sfor\ssome\sDISTINCT\shandling\salgorithms,\sand\sdoes\snot\simprove\nperformance.\s\sThis\salso\sfixes\san\sassertion\sfault\sfound\sby\slibFuzzer. +D 2015-11-24T00:49:44.712 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -406,7 +406,7 @@ F src/vdbe.c b56b2fc9b2f2d0a99d1dbd02d47efaacec253a4c F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c b660c995256e3d3e2cb47ccd20b82a1c342fa093 +F src/vdbeaux.c 9a234c9aaab4ad725daf94667cfed441a437c52d F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1404,7 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 198d191b2f5ef7d63ac0093c701955c9052fd734 -R 8ed8d9e954ea81e19ae35a6836359b00 -U dan -Z f96d100152be981f85597b50bc9a8134 +P 60de5f23424552c98aa760ac89149a3d51f895be +R 22b08ad19af1727f96b09a8caa1d2b95 +U drh +Z 5e461470e8ebbd6a466d30753f42166b diff --git a/manifest.uuid b/manifest.uuid index 90fb983695..d9bf317509 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -60de5f23424552c98aa760ac89149a3d51f895be \ No newline at end of file +19d9f9ce691963310fa73ac5ff728ea8dea9d2b2 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 9ced9480b7..1889aec79f 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -837,7 +837,6 @@ void sqlite3VdbeChangeToNoop(Vdbe *p, int addr){ freeP4(db, pOp->p4type, pOp->p4.p); memset(pOp, 0, sizeof(pOp[0])); pOp->opcode = OP_Noop; - if( addr==p->nOp-1 ) p->nOp--; } } From a9124d359b4fe798a0d1ed3531427c4012b1ff2e Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 24 Nov 2015 01:17:01 +0000 Subject: [PATCH 003/232] Add a clarifying comment to the virtual table test module 'test8'. FossilOrigin-Name: e92f97a6794440eb9d64e21218d39cb0e297a98e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test8.c | 7 +++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 164471ab97..7f76cef1ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\stry\sto\seliminate\sNo-ops\sat\sthe\send\sof\sVDBE\sprogram\sas\sthis\scan\scause\nproblems\sfor\ssome\sDISTINCT\shandling\salgorithms,\sand\sdoes\snot\simprove\nperformance.\s\sThis\salso\sfixes\san\sassertion\sfault\sfound\sby\slibFuzzer. -D 2015-11-24T00:49:44.712 +C Add\sa\sclarifying\scomment\sto\sthe\svirtual\stable\stest\smodule\s'test8'. +D 2015-11-24T01:17:01.246 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -356,7 +356,7 @@ F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e F src/test5.c 5a34feec76d9b3a86aab30fd4f6cc9c48cbab4c1 F src/test6.c 41cacf3b0dd180823919bf9e1fbab287c9266723 F src/test7.c 9c89a4f1ed6bb13af0ed805b8d782bd83fcd57e3 -F src/test8.c 610e3d523018ca63b08081795e76794a2121ec38 +F src/test8.c 697c9c84a13e08c72ea95a3637d4374caf54fc93 F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8 F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12 @@ -1404,7 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 60de5f23424552c98aa760ac89149a3d51f895be -R 22b08ad19af1727f96b09a8caa1d2b95 -U drh -Z 5e461470e8ebbd6a466d30753f42166b +P 19d9f9ce691963310fa73ac5ff728ea8dea9d2b2 +R 5f2e3f4f59d38b9500a642209d9901f8 +U mistachkin +Z 92cc12dd9fcb76285889b066a4a2f02e diff --git a/manifest.uuid b/manifest.uuid index d9bf317509..e7ce74a97f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -19d9f9ce691963310fa73ac5ff728ea8dea9d2b2 \ No newline at end of file +e92f97a6794440eb9d64e21218d39cb0e297a98e \ No newline at end of file diff --git a/src/test8.c b/src/test8.c index 2107710a99..7d3756aece 100644 --- a/src/test8.c +++ b/src/test8.c @@ -848,6 +848,13 @@ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ case SQLITE_INDEX_CONSTRAINT_GE: zOp = ">="; break; case SQLITE_INDEX_CONSTRAINT_MATCH: + /* Purposely translate the MATCH operator into a LIKE, which + ** will be used by the next block of code to construct a new + ** query. It should also be noted here that the next block + ** of code requires the first letter of this operator to be + ** in upper-case to trigger the special MATCH handling (i.e. + ** wrapping the bound parameter with literal '%'s). + */ zOp = "LIKE"; break; } if( zOp[0]=='L' ){ From 2edc5fd73a9d98d7dabe896c01fa4b0438af25de Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 Nov 2015 02:10:52 +0000 Subject: [PATCH 004/232] Remove an incorrect ALWAYS() macro. Fix for ticket [e5c6268dd807fa8950] - a problem introduced in SQLite 3.9.0 and found by libFuzzer. FossilOrigin-Name: 824ad96f72cb0c948ec98aca9d17a7e6790c575f --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 2 +- test/distinct.test | 17 +++++++++++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 7f76cef1ff..8f1d010fc6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sclarifying\scomment\sto\sthe\svirtual\stable\stest\smodule\s'test8'. -D 2015-11-24T01:17:01.246 +C Remove\san\sincorrect\sALWAYS()\smacro.\s\sFix\sfor\sticket\s[e5c6268dd807fa8950]\s-\s\na\sproblem\sintroduced\sin\sSQLite\s3.9.0\sand\sfound\sby\slibFuzzer. +D 2015-11-24T02:10:52.306 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -292,7 +292,7 @@ F src/ctime.c 509ef9c64d1321f42448f111da86400b1799218a F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c dfccb439a2a981d71970ce3d15effeb59b258798 +F src/expr.c cb1a419508e5b27769a91e00e36e94724e7b1d51 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 F src/func.c ecdd69ec6a1e406f04cc73324be2ebbf6354197f @@ -579,7 +579,7 @@ F test/descidx1.test 6d03b44c8538fe0eb4924e19fba10cdd8f3c9240 F test/descidx2.test 9f1a0c83fd57f8667c82310ca21b30a350888b5d F test/descidx3.test 09ddbe3f5295f482d2f8b687cf6db8bad7acd9a2 F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e -F test/distinct.test 175d49ee783febaf368192dfe7f5afbc68910230 +F test/distinct.test a1783b960ad8c15a77cd9f207be072898db1026c F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376 F test/e_blobbytes.test 9bea1d3e2b20f3010b04abba58f6ba172301f49f F test/e_blobclose.test df756753f571bc30e42e3a6cba2807576e49e716 @@ -1404,7 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 19d9f9ce691963310fa73ac5ff728ea8dea9d2b2 -R 5f2e3f4f59d38b9500a642209d9901f8 -U mistachkin -Z 92cc12dd9fcb76285889b066a4a2f02e +P e92f97a6794440eb9d64e21218d39cb0e297a98e +R 67e74267bda19ceddf30801e5b6dab85 +U drh +Z 988f4fae8dad66d5bbc6c477f18a57af diff --git a/manifest.uuid b/manifest.uuid index e7ce74a97f..3fce085be0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e92f97a6794440eb9d64e21218d39cb0e297a98e \ No newline at end of file +824ad96f72cb0c948ec98aca9d17a7e6790c575f \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 0255d6902f..8cf018f9d4 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3818,7 +3818,7 @@ int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){ } return 2; } - if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken ){ + if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){ if( pA->op==TK_FUNCTION ){ if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){ diff --git a/test/distinct.test b/test/distinct.test index 2fb90dc3e3..dac2269b0b 100644 --- a/test/distinct.test +++ b/test/distinct.test @@ -252,4 +252,21 @@ do_execsql_test 5.6 { SELECT DISTINCT x FROM t1 ORDER BY x; } {1 2 3 4 5 6} +#------------------------------------------------------------------------- +# 2015-11-23. Problem discovered by Kostya Serebryany using libFuzzer +# +db close +sqlite3 db :memory: +do_execsql_test 6.1 { + CREATE TABLE jjj(x); + SELECT (SELECT 'mmm' UNION SELECT DISTINCT max(name) ORDER BY 1) + FROM sqlite_master; +} {jjj} +do_execsql_test 6.2 { + CREATE TABLE nnn(x); + SELECT (SELECT 'mmm' UNION SELECT DISTINCT max(name) ORDER BY 1) + FROM sqlite_master; +} {mmm} + + finish_test From 7060ef9294f2ec3e6eed0fac0e30952c46027f2c Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 Nov 2015 03:50:16 +0000 Subject: [PATCH 005/232] Add a test case for the fix of check-in [19d9f9ce691963310] FossilOrigin-Name: 19a9c07b26a4123dc60abdcc84a956f88c352bab --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/hexlit.test | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 8f1d010fc6..d75d52e9d5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sincorrect\sALWAYS()\smacro.\s\sFix\sfor\sticket\s[e5c6268dd807fa8950]\s-\s\na\sproblem\sintroduced\sin\sSQLite\s3.9.0\sand\sfound\sby\slibFuzzer. -D 2015-11-24T02:10:52.306 +C Add\sa\stest\scase\sfor\sthe\sfix\sof\scheck-in\s[19d9f9ce691963310] +D 2015-11-24T03:50:16.891 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -761,7 +761,7 @@ F test/fuzzdata4.db 1882f0055fb63214d8407ddc7aca9b0b1c59af21 F test/fuzzer1.test d4c52aaf3ef923da293a2653cfab33d02f718a36 F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536 F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 -F test/hexlit.test 1d312fa816dfd3650a3bb488093bc09a0c927f67 +F test/hexlit.test d7b0a5f41123df1e43985b91b8b2e70f95282d21 F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711 F test/hook.test 162d7cef7a2d2b04839fe14402934e6a1b79442f F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4 @@ -1404,7 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e92f97a6794440eb9d64e21218d39cb0e297a98e -R 67e74267bda19ceddf30801e5b6dab85 +P 824ad96f72cb0c948ec98aca9d17a7e6790c575f +R 9c18c36b835edbc9e97b6e63032cda67 U drh -Z 988f4fae8dad66d5bbc6c477f18a57af +Z babd8e22395e7e3423172e307e2f6983 diff --git a/manifest.uuid b/manifest.uuid index 3fce085be0..4c32ac931c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -824ad96f72cb0c948ec98aca9d17a7e6790c575f \ No newline at end of file +19a9c07b26a4123dc60abdcc84a956f88c352bab \ No newline at end of file diff --git a/test/hexlit.test b/test/hexlit.test index 2edd458e89..c48930b49b 100644 --- a/test/hexlit.test +++ b/test/hexlit.test @@ -109,6 +109,9 @@ do_execsql_test hexlit-301 { do_catchsql_test hexlist-400 { SELECT 0x10000000000000000; } {1 {hex literal too big: 0x10000000000000000}} +do_catchsql_test hexlist-401 { + SELECT DISTINCT 0x10000000000000000; +} {1 {hex literal too big: 0x10000000000000000}} do_catchsql_test hexlist-410 { DROP TABLE IF EXISTS t1; CREATE TABLE t1(x); From 6226ca2a6d33b2499fed9320d0d6319599bd8bc8 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 Nov 2015 15:06:28 +0000 Subject: [PATCH 006/232] Make the geteuid() system call overloadable using xSetSystemCall() on the unix VFSes. FossilOrigin-Name: 6c2ddea65e1871b2fcb4991c5b3e6992993db3ea --- manifest | 14 ++++++------- manifest.uuid | 2 +- src/os_unix.c | 51 ++++++++++++++++++++++++++--------------------- test/syscall.test | 2 +- 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/manifest b/manifest index d75d52e9d5..2d0b9a58f6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\scase\sfor\sthe\sfix\sof\scheck-in\s[19d9f9ce691963310] -D 2015-11-24T03:50:16.891 +C Make\sthe\sgeteuid()\ssystem\scall\soverloadable\susing\sxSetSystemCall()\son\sthe\nunix\sVFSes. +D 2015-11-24T15:06:28.338 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c bddde71dc024574ace03ffee859abb99d152fd4a +F src/os_unix.c c5e7976c47cfd3134513ebfb2d140825d50e5275 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e @@ -1051,7 +1051,7 @@ F test/subtype1.test 7fe09496352f97053af1437150751be2d0a0cae8 F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2 F test/symlink.test 2513f7c030df0f435c6415687ba8b739f3d312df F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85 -F test/syscall.test fba9ebdc6905d05bba6a835e691f20ed9ea2cc88 +F test/syscall.test 2aa9e111b79fb385681ff8940124def6f8faab87 F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6 F test/tabfunc01.test cc33684f9480fcf1fd5ce287ac28d22971cad1cc F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f @@ -1404,7 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 824ad96f72cb0c948ec98aca9d17a7e6790c575f -R 9c18c36b835edbc9e97b6e63032cda67 +P 19a9c07b26a4123dc60abdcc84a956f88c352bab +R 02104466c6b651805702e9bf38bb181e U drh -Z babd8e22395e7e3423172e307e2f6983 +Z eddf0171a3f4a4814f215292a42ba620 diff --git a/manifest.uuid b/manifest.uuid index 4c32ac931c..ef64e4e41c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -19a9c07b26a4123dc60abdcc84a956f88c352bab \ No newline at end of file +6c2ddea65e1871b2fcb4991c5b3e6992993db3ea \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 4594e2d870..687baa107e 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -324,19 +324,6 @@ static int posixOpen(const char *zFile, int flags, int mode){ return open(zFile, flags, mode); } -/* -** On some systems, calls to fchown() will trigger a message in a security -** log if they come from non-root processes. So avoid calling fchown() if -** we are not running as root. -*/ -static int posixFchown(int fd, uid_t uid, gid_t gid){ -#if OS_VXWORKS - return 0; -#else - return geteuid() ? 0 : fchown(fd,uid,gid); -#endif -} - /* Forward reference */ static int openDirectory(const char*, int*); static int unixGetpagesize(void); @@ -423,7 +410,7 @@ static struct unix_syscall { #define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off_t))\ aSyscall[13].pCurrent) - { "fchmod", (sqlite3_syscall_ptr)fchmod, 0 }, + { "fchmod", (sqlite3_syscall_ptr)fchmod, 0 }, #define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent) #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE @@ -445,32 +432,50 @@ static struct unix_syscall { { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) - { "fchown", (sqlite3_syscall_ptr)posixFchown, 0 }, + { "fchown", (sqlite3_syscall_ptr)fchown, 0 }, #define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent) + { "geteuid", (sqlite3_syscall_ptr)geteuid, 0 }, +#define osGeteuid ((uid_t(*)(void))aSyscall[21].pCurrent) + #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 { "mmap", (sqlite3_syscall_ptr)mmap, 0 }, -#define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[21].pCurrent) +#define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[22].pCurrent) { "munmap", (sqlite3_syscall_ptr)munmap, 0 }, -#define osMunmap ((void*(*)(void*,size_t))aSyscall[22].pCurrent) +#define osMunmap ((void*(*)(void*,size_t))aSyscall[23].pCurrent) #if HAVE_MREMAP { "mremap", (sqlite3_syscall_ptr)mremap, 0 }, #else { "mremap", (sqlite3_syscall_ptr)0, 0 }, #endif -#define osMremap ((void*(*)(void*,size_t,size_t,int,...))aSyscall[23].pCurrent) +#define osMremap ((void*(*)(void*,size_t,size_t,int,...))aSyscall[24].pCurrent) + { "getpagesize", (sqlite3_syscall_ptr)unixGetpagesize, 0 }, -#define osGetpagesize ((int(*)(void))aSyscall[24].pCurrent) +#define osGetpagesize ((int(*)(void))aSyscall[25].pCurrent) { "readlink", (sqlite3_syscall_ptr)readlink, 0 }, -#define osReadlink ((ssize_t(*)(const char*,char*,size_t))aSyscall[25].pCurrent) +#define osReadlink ((ssize_t(*)(const char*,char*,size_t))aSyscall[26].pCurrent) #endif }; /* End of the overrideable system calls */ + +/* +** On some systems, calls to fchown() will trigger a message in a security +** log if they come from non-root processes. So avoid calling fchown() if +** we are not running as root. +*/ +static int robustFchown(int fd, uid_t uid, gid_t gid){ +#if OS_VXWORKS + return 0; +#else + return osGeteuid() ? 0 : osFchown(fd,uid,gid); +#endif +} + /* ** This is the xSetSystemCall() method of sqlite3_vfs for all of the ** "unix" VFSes. Return SQLITE_OK opon successfully updating the @@ -4343,7 +4348,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ ** is owned by the same user that owns the original database. Otherwise, ** the original owner will not be able to connect. */ - osFchown(pShmNode->h, sStat.st_uid, sStat.st_gid); + robustFchown(pShmNode->h, sStat.st_uid, sStat.st_gid); /* Check to see if another process is holding the dead-man switch. ** If not, truncate the file to zero length. @@ -5827,7 +5832,7 @@ static int unixOpen( ** the same as the original database. */ if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ - osFchown(fd, uid, gid); + robustFchown(fd, uid, gid); } } assert( fd>=0 ); @@ -7584,7 +7589,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==26 ); + assert( ArraySize(aSyscall)==27 ); /* Register all VFSes defined in the aVfs[] array */ for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ diff --git a/test/syscall.test b/test/syscall.test index 83b8b8b40f..a935957d39 100644 --- a/test/syscall.test +++ b/test/syscall.test @@ -60,7 +60,7 @@ foreach s { open close access getcwd stat fstat ftruncate fcntl read pread write pwrite fchmod fallocate pread64 pwrite64 unlink openDirectory mkdir rmdir - statvfs fchown umask mmap munmap mremap + statvfs fchown geteuid umask mmap munmap mremap getpagesize readlink } { if {[test_syscall exists $s]} {lappend syscall_list $s} From aaeaa18e2e4ba3f82c4f11929f50fa9837d50e00 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 Nov 2015 15:12:47 +0000 Subject: [PATCH 007/232] Fix a comment typo in the unix VFS. No changes to code. FossilOrigin-Name: 32e138796c66c88e8cbb77aa3a4282a38d1f959a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 2d0b9a58f6..69d2b5459d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\sgeteuid()\ssystem\scall\soverloadable\susing\sxSetSystemCall()\son\sthe\nunix\sVFSes. -D 2015-11-24T15:06:28.338 +C Fix\sa\scomment\stypo\sin\sthe\sunix\sVFS.\s\sNo\schanges\sto\scode. +D 2015-11-24T15:12:47.482 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c c5e7976c47cfd3134513ebfb2d140825d50e5275 +F src/os_unix.c 3ca4a23db3ad0b809a0b8d7f879cf66f56b693d5 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e @@ -1404,7 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 19a9c07b26a4123dc60abdcc84a956f88c352bab -R 02104466c6b651805702e9bf38bb181e +P 6c2ddea65e1871b2fcb4991c5b3e6992993db3ea +R 81ff6ba247633e5ac5ffc463969dd7f1 U drh -Z eddf0171a3f4a4814f215292a42ba620 +Z 2bab8f8a8131461afe24bb3f0bfc9cb2 diff --git a/manifest.uuid b/manifest.uuid index ef64e4e41c..501322045a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6c2ddea65e1871b2fcb4991c5b3e6992993db3ea \ No newline at end of file +32e138796c66c88e8cbb77aa3a4282a38d1f959a \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 687baa107e..768a2a9eec 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1104,7 +1104,7 @@ static unixInodeInfo *inodeList = 0; /* ** -** This function - unixLogError_x(), is only ever called via the macro +** This function - unixLogErrorAtLine(), is only ever called via the macro ** unixLogError(). ** ** It is invoked after an error occurs in an OS function and errno has been From 5a8d190b9ecf9e38857bfa77440a4e9c91aa28e3 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 Nov 2015 16:40:23 +0000 Subject: [PATCH 008/232] Remove from os_unix.c pointless logic that tries to prevent a recurrence of a warning message that can only occur once. FossilOrigin-Name: 20256177072caa4f2b4114038ad1c8f6e26bc562 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 12 +----------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 69d2b5459d..36e5b27570 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scomment\stypo\sin\sthe\sunix\sVFS.\s\sNo\schanges\sto\scode. -D 2015-11-24T15:12:47.482 +C Remove\sfrom\sos_unix.c\spointless\slogic\sthat\stries\sto\sprevent\sa\srecurrence\sof\na\swarning\smessage\sthat\scan\sonly\soccur\sonce. +D 2015-11-24T16:40:23.118 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 3ca4a23db3ad0b809a0b8d7f879cf66f56b693d5 +F src/os_unix.c 80ec49758dbce979e4f89eda7695bbc01b0c4cd3 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e @@ -1404,7 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6c2ddea65e1871b2fcb4991c5b3e6992993db3ea -R 81ff6ba247633e5ac5ffc463969dd7f1 +P 32e138796c66c88e8cbb77aa3a4282a38d1f959a +R 39dda72890996a1a2961e4723fcfeb24 U drh -Z 2bab8f8a8131461afe24bb3f0bfc9cb2 +Z 6e0fb81bf9792119f74030230681d485 diff --git a/manifest.uuid b/manifest.uuid index 501322045a..9df0621fea 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -32e138796c66c88e8cbb77aa3a4282a38d1f959a \ No newline at end of file +20256177072caa4f2b4114038ad1c8f6e26bc562 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 768a2a9eec..82224053f0 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -258,8 +258,7 @@ static pid_t randomnessPid = 0; #define UNIXFILE_DELETE 0x20 /* Delete on close */ #define UNIXFILE_URI 0x40 /* Filename might have query parameters */ #define UNIXFILE_NOLOCK 0x80 /* Do no file locking */ -#define UNIXFILE_WARNED 0x0100 /* verifyDbFile() warnings issued */ -#define UNIXFILE_BLOCK 0x0200 /* Next SHM lock might block */ +#define UNIXFILE_BLOCK 0x0100 /* Next SHM lock might block */ /* ** Include code that is common to all os_*.c files @@ -1360,30 +1359,21 @@ static int fileHasMoved(unixFile *pFile){ static void verifyDbFile(unixFile *pFile){ struct stat buf; int rc; - if( pFile->ctrlFlags & UNIXFILE_WARNED ){ - /* One or more of the following warnings have already been issued. Do not - ** repeat them so as not to clutter the error log */ - return; - } rc = osFstat(pFile->h, &buf); if( rc!=0 ){ sqlite3_log(SQLITE_WARNING, "cannot fstat db file %s", pFile->zPath); - pFile->ctrlFlags |= UNIXFILE_WARNED; return; } if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){ sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath); - pFile->ctrlFlags |= UNIXFILE_WARNED; return; } if( buf.st_nlink>1 ){ sqlite3_log(SQLITE_WARNING, "multiple links to file: %s", pFile->zPath); - pFile->ctrlFlags |= UNIXFILE_WARNED; return; } if( fileHasMoved(pFile) ){ sqlite3_log(SQLITE_WARNING, "file renamed while open: %s", pFile->zPath); - pFile->ctrlFlags |= UNIXFILE_WARNED; return; } } From 43970dd7745c3fdb258ce6bb86971fd5ce87cfdf Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 24 Nov 2015 17:39:01 +0000 Subject: [PATCH 009/232] Add further tests and related fixes for GLOB/REGEXP/LIKE support in virtual tables. FossilOrigin-Name: c5e9fd0dc92a07db3d3b5f5c5ad8fb63b3425c2b --- manifest | 21 +++-- manifest.uuid | 2 +- src/test_tclvar.c | 194 +++++++++++++++++++++++++++++++++++++++------- src/whereexpr.c | 17 ++-- test/vtabE.test | 2 + test/vtabH.test | 63 ++++++++++++++- 6 files changed, 252 insertions(+), 47 deletions(-) diff --git a/manifest b/manifest index 77ed28994e..1a5fc94c5f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sexperimental\ssupport\sfor\sLIKE,\sGLOB\sand\sREGEXP\sto\sthe\svirtual\stable\sinterface. -D 2015-11-23T21:09:54.478 +C Add\sfurther\stests\sand\srelated\sfixes\sfor\sGLOB/REGEXP/LIKE\ssupport\sin\svirtual\stables. +D 2015-11-24T17:39:01.810 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -389,7 +389,7 @@ F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe F src/test_sqllog.c 0d138a8180a312bf996b37fa66da5c5799d4d57b F src/test_superlock.c 06797157176eb7085027d9dd278c0d7a105e3ec9 F src/test_syscall.c 2e21ca7f7dc54a028f1967b63f1e76155c356f9b -F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa +F src/test_tclvar.c 2fd910e9f0ef7686889f50f448d33810c895da86 F src/test_thread.c af391ec03d23486dffbcc250b7e58e073f172af9 F src/test_vfs.c 3b65d42e18b262805716bd96178c81da8f2d9283 F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 @@ -419,7 +419,7 @@ F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c 6687fb2675d9c1c1936ceca77529e2f21fb3a769 F src/whereInt.h 6afc0d70cf6213e58e8fbe10b6e50d1aa16f122f F src/wherecode.c 4c96182e7b25e4be54008dee2da5b9c2f8480b9b -F src/whereexpr.c 12c6fa7576674d24bf0116364a39885925c89188 +F src/whereexpr.c 17d62d8bb7fd357920b46ee86851b5d6629412bf F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1272,9 +1272,9 @@ F test/vtabA.test 1317f06a03597eee29f40a49b6c21e1aaba4285f F test/vtabB.test 04df5dc531b9f44d9ca65b9c1b79f12b5922a796 F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 -F test/vtabE.test 7c4693638d7797ce2eda17af74292b97e705cc61 +F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test 15e137d2af9b0b81fedca6697518eb8834c013f4 +F test/vtabH.test 694aa399eb28ed0db2aef59f2f37532781eeb957 F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test ea8778d5b0df200adef2ca7c00c3c37d4375f772 @@ -1405,10 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 60de5f23424552c98aa760ac89149a3d51f895be -R b6557d1407b51115ef511b97d0fc16c1 -T *branch * vtab-like-operator -T *sym-vtab-like-operator * -T -sym-trunk * +P 277a5b4027d4c2caba8143228a4f7d6df899dbb4 +R f59356e8fc475908365127ad504d9518 U dan -Z 249ced27266ff2c4ebd31fcaec9b55b5 +Z 673386578c6b1eaa8b17502c533df301 diff --git a/manifest.uuid b/manifest.uuid index eee0121605..77e0da032b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -277a5b4027d4c2caba8143228a4f7d6df899dbb4 \ No newline at end of file +c5e9fd0dc92a07db3d3b5f5c5ad8fb63b3425c2b \ No newline at end of file diff --git a/src/test_tclvar.c b/src/test_tclvar.c index 1219190c03..975f07fc8d 100644 --- a/src/test_tclvar.c +++ b/src/test_tclvar.c @@ -23,6 +23,15 @@ #ifndef SQLITE_OMIT_VIRTUALTABLE +/* +** Characters that make up the idxStr created by xBestIndex for xFilter. +*/ +#define TCLVAR_NAME_EQ 'e' +#define TCLVAR_NAME_MATCH 'm' +#define TCLVAR_VALUE_GLOB 'g' +#define TCLVAR_VALUE_REGEXP 'r' +#define TCLVAR_VALUE_LIKE 'l' + typedef struct tclvar_vtab tclvar_vtab; typedef struct tclvar_cursor tclvar_cursor; @@ -155,15 +164,44 @@ static int tclvarFilter( ){ tclvar_cursor *pCur = (tclvar_cursor *)pVtabCursor; Tcl_Interp *interp = ((tclvar_vtab *)(pVtabCursor->pVtab))->interp; + Tcl_Obj *p = Tcl_NewStringObj("tclvar_filter_cmd", -1); - Tcl_Obj *p = Tcl_NewStringObj("info vars", -1); - Tcl_IncrRefCount(p); + const char *zEq = ""; + const char *zMatch = ""; + const char *zGlob = ""; + const char *zRegexp = ""; + const char *zLike = ""; + int i; - assert( argc==0 || argc==1 ); - if( argc==1 ){ - Tcl_Obj *pArg = Tcl_NewStringObj((char*)sqlite3_value_text(argv[0]), -1); - Tcl_ListObjAppendElement(0, p, pArg); + for(i=0; idxStr[i]; i++){ + switch( idxStr[i] ){ + case TCLVAR_NAME_EQ: + zEq = sqlite3_value_text(argv[i]); + break; + case TCLVAR_NAME_MATCH: + zMatch = sqlite3_value_text(argv[i]); + break; + case TCLVAR_VALUE_GLOB: + zGlob = sqlite3_value_text(argv[i]); + break; + case TCLVAR_VALUE_REGEXP: + zRegexp = sqlite3_value_text(argv[i]); + break; + case TCLVAR_VALUE_LIKE: + zLike = sqlite3_value_text(argv[i]); + break; + default: + assert( 0 ); + } } + + Tcl_IncrRefCount(p); + Tcl_ListObjAppendElement(0, p, Tcl_NewStringObj(zEq, -1)); + Tcl_ListObjAppendElement(0, p, Tcl_NewStringObj(zMatch, -1)); + Tcl_ListObjAppendElement(0, p, Tcl_NewStringObj(zGlob, -1)); + Tcl_ListObjAppendElement(0, p, Tcl_NewStringObj(zRegexp, -1)); + Tcl_ListObjAppendElement(0, p, Tcl_NewStringObj(zLike, -1)); + Tcl_EvalObjEx(interp, p, TCL_EVAL_GLOBAL); if( pCur->pList1 ){ Tcl_DecrRefCount(pCur->pList1); @@ -176,7 +214,6 @@ static int tclvarFilter( pCur->i2 = 0; pCur->pList1 = Tcl_GetObjResult(interp); Tcl_IncrRefCount(pCur->pList1); - assert( pCur->i1==0 && pCur->i2==0 && pCur->pList2==0 ); Tcl_DecrRefCount(p); return tclvarNext(pVtabCursor); @@ -224,32 +261,113 @@ static int tclvarEof(sqlite3_vtab_cursor *cur){ return (pCur->pList2?0:1); } +/* +** If nul-terminated string zStr does not already contain the character +** passed as the second argument, append it and return 0. Or, if there is +** already an instance of x in zStr, do nothing return 1; +** +** There is guaranteed to be enough room in the buffer pointed to by zStr +** for the new character and nul-terminator. +*/ +static int tclvarAddToIdxstr(char *zStr, char x){ + int i; + for(i=0; zStr[i]; i++){ + if( zStr[i]==x ) return 1; + } + zStr[i] = x; + zStr[i+1] = '\0'; + return 0; +} + +/* +** Return true if variable $::tclvar_set_omit exists and is set to true. +** False otherwise. +*/ +static int tclvarSetOmit(Tcl_Interp *interp){ + int rc; + int res = 0; + Tcl_Obj *pRes; + rc = Tcl_Eval(interp, + "expr {[info exists ::tclvar_set_omit] && $::tclvar_set_omit}" + ); + if( rc==TCL_OK ){ + pRes = Tcl_GetObjResult(interp); + rc = Tcl_GetBooleanFromObj(0, pRes, &res); + } + return (rc==TCL_OK && res); +} + +/* +** The xBestIndex() method. This virtual table supports the following +** operators: +** +** name = ? (omit flag clear) +** name MATCH ? (omit flag set) +** value GLOB ? (omit flag set iff $::tclvar_set_omit) +** value REGEXP ? (omit flag set iff $::tclvar_set_omit) +** value LIKE ? (omit flag set iff $::tclvar_set_omit) +** +** For each constraint present, the corresponding TCLVAR_XXX character is +** appended to the idxStr value. +*/ static int tclvarBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ + tclvar_vtab *pTab = (tclvar_vtab*)tab; int ii; + char *zStr = sqlite3_malloc(32); + int iStr = 0; + + if( zStr==0 ) return SQLITE_NOMEM; + zStr[0] = '\0'; for(ii=0; iinConstraint; ii++){ struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[ii]; - if( pCons->iColumn==0 && pCons->usable - && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ ){ - struct sqlite3_index_constraint_usage *pUsage; - pUsage = &pIdxInfo->aConstraintUsage[ii]; - pUsage->omit = 0; - pUsage->argvIndex = 1; - return SQLITE_OK; - } - } + struct sqlite3_index_constraint_usage *pUsage; + + pUsage = &pIdxInfo->aConstraintUsage[ii]; + if( pCons->usable ){ + /* name = ? */ + if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ && pCons->iColumn==0 ){ + if( 0==tclvarAddToIdxstr(zStr, TCLVAR_NAME_EQ) ){ + pUsage->argvIndex = ++iStr; + pUsage->omit = 0; + } + } - for(ii=0; iinConstraint; ii++){ - struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[ii]; - if( pCons->iColumn==0 && pCons->usable - && pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH ){ - struct sqlite3_index_constraint_usage *pUsage; - pUsage = &pIdxInfo->aConstraintUsage[ii]; - pUsage->omit = 1; - pUsage->argvIndex = 1; - return SQLITE_OK; + /* name MATCH ? */ + if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH && pCons->iColumn==0 ){ + if( 0==tclvarAddToIdxstr(zStr, TCLVAR_NAME_MATCH) ){ + pUsage->argvIndex = ++iStr; + pUsage->omit = 1; + } + } + + /* value GLOB ? */ + if( pCons->op==SQLITE_INDEX_CONSTRAINT_GLOB && pCons->iColumn==2 ){ + if( 0==tclvarAddToIdxstr(zStr, TCLVAR_VALUE_GLOB) ){ + pUsage->argvIndex = ++iStr; + pUsage->omit = tclvarSetOmit(pTab->interp); + } + } + + /* value REGEXP ? */ + if( pCons->op==SQLITE_INDEX_CONSTRAINT_REGEXP && pCons->iColumn==2 ){ + if( 0==tclvarAddToIdxstr(zStr, TCLVAR_VALUE_REGEXP) ){ + pUsage->argvIndex = ++iStr; + pUsage->omit = tclvarSetOmit(pTab->interp); + } + } + + /* value LIKE ? */ + if( pCons->op==SQLITE_INDEX_CONSTRAINT_LIKE && pCons->iColumn==2 ){ + if( 0==tclvarAddToIdxstr(zStr, TCLVAR_VALUE_LIKE) ){ + pUsage->argvIndex = ++iStr; + pUsage->omit = tclvarSetOmit(pTab->interp); + } + } } } + pIdxInfo->idxStr = zStr; + pIdxInfo->needToFreeIdxStr = 1; return SQLITE_OK; } @@ -295,6 +413,7 @@ static int register_tclvar_module( int objc, /* Number of arguments */ Tcl_Obj *CONST objv[] /* Command arguments */ ){ + int rc = TCL_OK; sqlite3 *db; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "DB"); @@ -302,9 +421,30 @@ static int register_tclvar_module( } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; #ifndef SQLITE_OMIT_VIRTUALTABLE - sqlite3_create_module(db, "tclvar", &tclvarModule, (void *)interp); + sqlite3_create_module(db, "tclvar", &tclvarModule, (void*)interp); + rc = Tcl_Eval(interp, + "proc like {pattern str} {\n" + " set p [string map {% * _ ?} $pattern]\n" + " string match $p $str\n" + "}\n" + "proc tclvar_filter_cmd {eq match glob regexp like} {\n" + " set res {}\n" + " set pattern $eq\n" + " if {$pattern=={}} { set pattern $match }\n" + " if {$pattern=={}} { set pattern * }\n" + " foreach v [uplevel #0 info vars $pattern] {\n" + " if {($glob=={} || [string match $glob [uplevel #0 set $v]])\n" + " && ($like=={} || [like $like [uplevel #0 set $v]])\n" + " && ($regexp=={} || [regexp $regexp [uplevel #0 set $v]])\n" + " } {\n" + " lappend res $v\n" + " }\n" + " }\n" + " set res\n" + "}\n" + ); #endif - return TCL_OK; + return rc; } #endif diff --git a/src/whereexpr.c b/src/whereexpr.c index 0cc2fd7209..8ef91b03eb 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -277,7 +277,10 @@ static int isLikeOrGlob( /* ** Check to see if the given expression is of the form ** -** column MATCH expr +** column OP expr +** +** where OP is one of MATCH, GLOB, LIKE or REGEXP and "column" is a +** column of a virtual table. ** ** If it is then return TRUE. If not, return FALSE. */ @@ -289,12 +292,13 @@ static int isMatchOfColumn( const char *zOp; unsigned char eOp2; } aOp[] = { - { "match", SQLITE_INDEX_CONSTRAINT_MATCH }, - { "glob", SQLITE_INDEX_CONSTRAINT_GLOB }, - { "like", SQLITE_INDEX_CONSTRAINT_LIKE }, - { "regex", SQLITE_INDEX_CONSTRAINT_REGEXP } + { "match", SQLITE_INDEX_CONSTRAINT_MATCH }, + { "glob", SQLITE_INDEX_CONSTRAINT_GLOB }, + { "like", SQLITE_INDEX_CONSTRAINT_LIKE }, + { "regexp", SQLITE_INDEX_CONSTRAINT_REGEXP } }; ExprList *pList; + Expr *pCol; /* Column reference */ int i; if( pExpr->op!=TK_FUNCTION ){ @@ -304,7 +308,8 @@ static int isMatchOfColumn( if( pList->nExpr!=2 ){ return 0; } - if( pList->a[1].pExpr->op != TK_COLUMN ){ + pCol = pList->a[1].pExpr; + if( pCol->op!=TK_COLUMN || !IsVirtual(pCol->pTab) ){ return 0; } for(i=0; i Date: Tue, 24 Nov 2015 18:04:39 +0000 Subject: [PATCH 010/232] Fix harmless compiler warnings in the TCL test harness logic. FossilOrigin-Name: 2fba7a96566b5448f527a4ec6a26e860c4889813 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test_tclvar.c | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 19ec7c82ff..bf1a2b9a42 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\slatest\strunk\schanges\swith\sthis\sbranch. -D 2015-11-24T17:44:26.959 +C Fix\sharmless\scompiler\swarnings\sin\sthe\sTCL\stest\sharness\slogic. +D 2015-11-24T18:04:39.335 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -389,7 +389,7 @@ F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe F src/test_sqllog.c 0d138a8180a312bf996b37fa66da5c5799d4d57b F src/test_superlock.c 06797157176eb7085027d9dd278c0d7a105e3ec9 F src/test_syscall.c 2e21ca7f7dc54a028f1967b63f1e76155c356f9b -F src/test_tclvar.c 2fd910e9f0ef7686889f50f448d33810c895da86 +F src/test_tclvar.c d86412527da65468ee6fa1b8607c65d0af736bc4 F src/test_thread.c af391ec03d23486dffbcc250b7e58e073f172af9 F src/test_vfs.c 3b65d42e18b262805716bd96178c81da8f2d9283 F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c5e9fd0dc92a07db3d3b5f5c5ad8fb63b3425c2b 20256177072caa4f2b4114038ad1c8f6e26bc562 -R f66db3dfd01f74a8efe805dce920d093 -U dan -Z 1605220e9da94a8d162b093db7a72a24 +P 99222bb3e5f9b2a9a10d9561a9fd8c0f717baaff +R a81a9eaa4d026b7ec9f13ce6cc6dd8d0 +U drh +Z 1d3e92ad91e9ae564e61187f77c574d6 diff --git a/manifest.uuid b/manifest.uuid index 8f981f6a08..72fbceb60b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -99222bb3e5f9b2a9a10d9561a9fd8c0f717baaff \ No newline at end of file +2fba7a96566b5448f527a4ec6a26e860c4889813 \ No newline at end of file diff --git a/src/test_tclvar.c b/src/test_tclvar.c index 975f07fc8d..63ed394734 100644 --- a/src/test_tclvar.c +++ b/src/test_tclvar.c @@ -176,19 +176,19 @@ static int tclvarFilter( for(i=0; idxStr[i]; i++){ switch( idxStr[i] ){ case TCLVAR_NAME_EQ: - zEq = sqlite3_value_text(argv[i]); + zEq = (const char*)sqlite3_value_text(argv[i]); break; case TCLVAR_NAME_MATCH: - zMatch = sqlite3_value_text(argv[i]); + zMatch = (const char*)sqlite3_value_text(argv[i]); break; case TCLVAR_VALUE_GLOB: - zGlob = sqlite3_value_text(argv[i]); + zGlob = (const char*)sqlite3_value_text(argv[i]); break; case TCLVAR_VALUE_REGEXP: - zRegexp = sqlite3_value_text(argv[i]); + zRegexp = (const char*)sqlite3_value_text(argv[i]); break; case TCLVAR_VALUE_LIKE: - zLike = sqlite3_value_text(argv[i]); + zLike = (const char*)sqlite3_value_text(argv[i]); break; default: assert( 0 ); From ff7b22b714eb6202412b7b0aa5bc81fdbaad43c0 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 24 Nov 2015 18:16:15 +0000 Subject: [PATCH 011/232] Fix a problem in whereexpr.c causing a crash while processing a user-function taht accepts zero arguments. FossilOrigin-Name: 069e51b19c773aa3017a8d307c8daa0766c224ba --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/whereexpr.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index bf1a2b9a42..95094a3c1e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sthe\sTCL\stest\sharness\slogic. -D 2015-11-24T18:04:39.335 +C Fix\sa\sproblem\sin\swhereexpr.c\scausing\sa\scrash\swhile\sprocessing\sa\suser-function\staht\saccepts\szero\sarguments. +D 2015-11-24T18:16:15.798 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -419,7 +419,7 @@ F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c 6687fb2675d9c1c1936ceca77529e2f21fb3a769 F src/whereInt.h 6afc0d70cf6213e58e8fbe10b6e50d1aa16f122f F src/wherecode.c 4c96182e7b25e4be54008dee2da5b9c2f8480b9b -F src/whereexpr.c 17d62d8bb7fd357920b46ee86851b5d6629412bf +F src/whereexpr.c eebba8340c90de73b3d3bbe8c43b84559b8e6e2c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 99222bb3e5f9b2a9a10d9561a9fd8c0f717baaff -R a81a9eaa4d026b7ec9f13ce6cc6dd8d0 -U drh -Z 1d3e92ad91e9ae564e61187f77c574d6 +P 2fba7a96566b5448f527a4ec6a26e860c4889813 +R f36b8e4e640480a045269560fe77bd48 +U dan +Z 2212cd97f0c21ee66344a63115e7e327 diff --git a/manifest.uuid b/manifest.uuid index 72fbceb60b..2adfe4df8a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2fba7a96566b5448f527a4ec6a26e860c4889813 \ No newline at end of file +069e51b19c773aa3017a8d307c8daa0766c224ba \ No newline at end of file diff --git a/src/whereexpr.c b/src/whereexpr.c index 8ef91b03eb..99a97079be 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -305,7 +305,7 @@ static int isMatchOfColumn( return 0; } pList = pExpr->x.pList; - if( pList->nExpr!=2 ){ + if( pList==0 || pList->nExpr!=2 ){ return 0; } pCol = pList->a[1].pExpr; From 8b4a94adc1dea3254a7eed1e33c210509c496e2d Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 Nov 2015 21:23:59 +0000 Subject: [PATCH 012/232] Add the sqlite3_strlike() interface, which might be useful for implementing LIKE operators on virtual tables. FossilOrigin-Name: e70ec71d6883f2f8fc75301ff985bccb5aa06127 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/analyze.c | 2 +- src/func.c | 7 +++++++ src/sqlite.h.in | 27 +++++++++++++++++++++++++++ src/sqlite3ext.h | 4 ++++ 6 files changed, 50 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 95094a3c1e..f37520206d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\swhereexpr.c\scausing\sa\scrash\swhile\sprocessing\sa\suser-function\staht\saccepts\szero\sarguments. -D 2015-11-24T18:16:15.798 +C Add\sthe\ssqlite3_strlike()\sinterface,\swhich\smight\sbe\suseful\sfor\simplementing\nLIKE\soperators\son\svirtual\stables. +D 2015-11-24T21:23:59.705 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -276,7 +276,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 9d649e46c780166e416fb11dbd23f8d49aab8267 -F src/analyze.c 4c308880cf53c558070cb8513bdff4ffb1a38a77 +F src/analyze.c 977bd50c751bb939ef52917892e12bedbfcea7ce F src/attach.c e944d0052b577703b9b83aac1638452ff42a8395 F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc @@ -295,7 +295,7 @@ F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c cb1a419508e5b27769a91e00e36e94724e7b1d51 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 -F src/func.c ecdd69ec6a1e406f04cc73324be2ebbf6354197f +F src/func.c 5790a898a0c53e6787020ec268425d415e7e03c9 F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 @@ -341,9 +341,9 @@ F src/resolve.c f4c897ca76ca6d5e0b3f0499c627392ffe657c8e F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c e10586c750d87211caa8f4b239e2bfa6a2049e5b F src/shell.c f0f59ea60ad297f671b7ae0fb957a736ad17c92c -F src/sqlite.h.in a71226fe80bded2af3b99c5aed7363ef486962e1 +F src/sqlite.h.in cbe8643b6a1c7313bf6447a2aa7abdb31c73dd77 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad -F src/sqlite3ext.h 4b66e3e3435da4b4c8c83696d0349f0c503b3924 +F src/sqlite3ext.h 41ef50b0418a7c5ad1337bb80db5a7928dee764f F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2fba7a96566b5448f527a4ec6a26e860c4889813 -R f36b8e4e640480a045269560fe77bd48 -U dan -Z 2212cd97f0c21ee66344a63115e7e327 +P 069e51b19c773aa3017a8d307c8daa0766c224ba +R d30ed8c32e99c9a94479405580943fff +U drh +Z d8529710de4140b85add41abcb0a95e1 diff --git a/manifest.uuid b/manifest.uuid index 2adfe4df8a..79fcb989cf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -069e51b19c773aa3017a8d307c8daa0766c224ba \ No newline at end of file +e70ec71d6883f2f8fc75301ff985bccb5aa06127 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index ad752d2c0e..06918eb744 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -990,7 +990,7 @@ static void analyzeOneTable( /* Do not gather statistics on views or virtual tables */ return; } - if( sqlite3_strnicmp(pTab->zName, "sqlite_", 7)==0 ){ + if( sqlite3_strlike("sqlite_%", pTab->zName, 0)==0 ){ /* Do not gather statistics on system tables */ return; } diff --git a/src/func.c b/src/func.c index 8ea1169327..b134c1a7c2 100644 --- a/src/func.c +++ b/src/func.c @@ -763,6 +763,13 @@ int sqlite3_strglob(const char *zGlobPattern, const char *zString){ return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0; } +/* +** The sqlite3_strlike() interface. +*/ +int sqlite3_strlike(const char *zPattern, const char *zStr, unsigned int esc){ + return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc)==0; +} + /* ** Count the number of times that the LIKE operator (or GLOB which is ** just a variation of LIKE) gets called. This is used for testing diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 42652061fb..b93ff5873e 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -7377,9 +7377,36 @@ int sqlite3_strnicmp(const char *, const char *, int); ** ** Note that this routine returns zero on a match and non-zero if the strings ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. +** +** See also: sqlite3_strlike(). */ int sqlite3_strglob(const char *zGlob, const char *zStr); +/* +** CAPI3REF: String LIKE Matching +* +** ^The [sqlite3_strlike(P,X,E)] interface returns zero if string X matches +** the LIKE pattern P with escape character E, and it returns non-zero if +** string X does not match the like pattern. +** ^The definition of LIKE pattern matching used in +** [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E" +** operator in the SQL dialect used by SQLite. ^For "X LIKE P" without +** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0. +** ^As with the LIKE operator, the [sqlite3_str(P,X,E)] function is case +** insensitive - equivalent upper and lower case ASCII characters match +** one another. +** +** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though +** only ASCII characters are case folded. (This is because when SQLite was +** first written, the case folding rules for Unicode where still in flux.) +** +** Note that this routine returns zero on a match and non-zero if the strings +** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. +** +** See also: sqlite3_strglob(). +*/ +int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc); + /* ** CAPI3REF: Error Logging Interface ** diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 017ea308b1..3029a82fa1 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -275,6 +275,8 @@ struct sqlite3_api_routines { /* Version 3.9.0 and later */ unsigned int (*value_subtype)(sqlite3_value*); void (*result_subtype)(sqlite3_context*,unsigned int); + /* Version 3.10.0 and later */ + int (*strlike)(const char*,const char*,unsigned int); }; /* @@ -514,6 +516,8 @@ struct sqlite3_api_routines { /* Version 3.9.0 and later */ #define sqlite3_value_subtype sqlite3_api->value_subtype #define sqlite3_result_subtype sqlite3_api->result_subtype +/* Version 3.10.0 and later */ +#define sqlite3_strlike sqlite3_api->strlike #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) From f5d8c58950c808bf7e08bc99b374bb63d0887309 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 25 Nov 2015 11:56:24 +0000 Subject: [PATCH 013/232] Fix the fts5 "prefix=" option to match the documentation (space separated list, multiple prefix= options supported). The undocumented comma-separated format (compatible with fts4) still works. FossilOrigin-Name: 11eb8e877e2ba859ef6b44318f286597186dfaf2 --- ext/fts5/fts5_config.c | 47 ++++++++++++++++++++++++----------- ext/fts5/test/fts5config.test | 22 +++++++++++----- ext/fts5/test/fts5prefix.test | 42 +++++++++++++++++++++++++++++++ manifest | 19 +++++++------- manifest.uuid | 2 +- 5 files changed, 101 insertions(+), 31 deletions(-) diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index 4f6272dbe2..6b0e2b28b6 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -216,34 +216,53 @@ static int fts5ConfigParseSpecial( if( sqlite3_strnicmp("prefix", zCmd, nCmd)==0 ){ const int nByte = sizeof(int) * FTS5_MAX_PREFIX_INDEXES; const char *p; - if( pConfig->aPrefix ){ - *pzErr = sqlite3_mprintf("multiple prefix=... directives"); - rc = SQLITE_ERROR; - }else{ + int bFirst = 1; + if( pConfig->aPrefix==0 ){ pConfig->aPrefix = sqlite3Fts5MallocZero(&rc, nByte); + if( rc ) return rc; } + p = zArg; - while( rc==SQLITE_OK && p[0] ){ + while( 1 ){ int nPre = 0; + while( p[0]==' ' ) p++; + if( bFirst==0 && p[0]==',' ){ + p++; + while( p[0]==' ' ) p++; + }else if( p[0]=='\0' ){ + break; + } + if( p[0]<'0' || p[0]>'9' ){ + *pzErr = sqlite3_mprintf("malformed prefix=... directive"); + rc = SQLITE_ERROR; + break; + } + + if( pConfig->nPrefix==FTS5_MAX_PREFIX_INDEXES ){ + *pzErr = sqlite3_mprintf( + "too many prefix indexes (max %d)", FTS5_MAX_PREFIX_INDEXES + ); + rc = SQLITE_ERROR; + break; + } + while( p[0]>='0' && p[0]<='9' && nPre<1000 ){ nPre = nPre*10 + (p[0] - '0'); p++; } - while( p[0]==' ' ) p++; - if( p[0]==',' ){ - p++; - }else if( p[0] ){ - *pzErr = sqlite3_mprintf("malformed prefix=... directive"); - rc = SQLITE_ERROR; - } - if( rc==SQLITE_OK && (nPre==0 || nPre>=1000) ){ - *pzErr = sqlite3_mprintf("prefix length out of range: %d", nPre); + + if( rc==SQLITE_OK && (nPre<=0 || nPre>=1000) ){ + *pzErr = sqlite3_mprintf("prefix length out of range (max 999)"); rc = SQLITE_ERROR; + break; } + pConfig->aPrefix[pConfig->nPrefix] = nPre; pConfig->nPrefix++; + bFirst = 0; } + assert( pConfig->nPrefix<=FTS5_MAX_PREFIX_INDEXES ); return rc; } diff --git a/ext/fts5/test/fts5config.test b/ext/fts5/test/fts5config.test index 7c88e03d38..dcda2d42a6 100644 --- a/ext/fts5/test/fts5config.test +++ b/ext/fts5/test/fts5config.test @@ -42,6 +42,8 @@ foreach {tn opt} { 1 {prefix=x} 2 {prefix='x'} 3 {prefix='$'} + 4 {prefix='1,2,'} + 5 {prefix=',1'} } { set res [list 1 {malformed prefix=... directive}] do_catchsql_test 2.$tn "CREATE VIRTUAL TABLE f1 USING fts5(x, $opt)" $res @@ -118,18 +120,15 @@ do_catchsql_test 5.3 { #------------------------------------------------------------------------- # Errors in prefix= directives. # -do_catchsql_test 6.1 { - CREATE VIRTUAL TABLE abc USING fts5(a, prefix=1, prefix=2); -} {1 {multiple prefix=... directives}} do_catchsql_test 6.2 { CREATE VIRTUAL TABLE abc USING fts5(a, prefix='1, 2, 1001'); -} {1 {prefix length out of range: 1001}} +} {1 {prefix length out of range (max 999)}} do_catchsql_test 6.3 { CREATE VIRTUAL TAbLE abc USING fts5(a, prefix='1, 2, 0000'); -} {1 {prefix length out of range: 0}} +} {1 {prefix length out of range (max 999)}} do_catchsql_test 6.4 { CREATE VIRTUAL TABLE abc USING fts5(a, prefix='1 , 1000000'); -} {1 {malformed prefix=... directive}} +} {1 {prefix length out of range (max 999)}} #------------------------------------------------------------------------- # Duplicate tokenize= and other options. @@ -204,5 +203,16 @@ do_catchsql_test 9.4.1 { INSERT INTO abc(abc, rank) VALUES('nosuchoption', 1); } {1 {SQL logic error or missing database}} +#------------------------------------------------------------------------- +# Too many prefix indexes. Maximum allowed is 31. +# +foreach {tn spec} { + 1 {prefix="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32"} + 2 {prefix="1 2 3 4", prefix="5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32"} +} { + set sql "CREATE VIRTUAL TABLE xyz USING fts5(x, $spec)" + do_catchsql_test 10.$tn $sql {1 {too many prefix indexes (max 31)}} +} + finish_test diff --git a/ext/fts5/test/fts5prefix.test b/ext/fts5/test/fts5prefix.test index 70de0bc78a..8e0d5a2954 100644 --- a/ext/fts5/test/fts5prefix.test +++ b/ext/fts5/test/fts5prefix.test @@ -298,6 +298,48 @@ foreach {tn col pattern} { do_execsql_test 6.$tn { SELECT rowid FROM t5($query) } $res } +#------------------------------------------------------------------------- +# Check that the various ways of creating prefix indexes produce the +# same database on disk. +# +save_prng_state +foreach {tn create} { + 1 { CREATE VIRTUAL TABLE tt USING fts5(x, y, prefix="1,2,3") } + 2 { CREATE VIRTUAL TABLE tt USING fts5(x, y, prefix="1 2 3") } + 3 { CREATE VIRTUAL TABLE tt USING fts5(x, y, prefix=1, prefix=2, prefix=3) } + 4 { CREATE VIRTUAL TABLE tt USING fts5(x, y, prefix="1 2", prefix=3) } +} { + execsql { DROP TABLE IF EXISTS tt } + restore_prng_state + execsql $create + execsql { + INSERT INTO tt VALUES('cc b ggg ccc aa eee hh', 'aa g b hh a e'); + INSERT INTO tt VALUES('cc bb cc gg j g cc', 'ii jjj ggg jjj cc cc'); + INSERT INTO tt VALUES('h eee cc h iii', 'aaa iii dd iii dd'); + INSERT INTO tt VALUES('jjj hh eee c e b gg', 'j bbb jj ddd jj'); + INSERT INTO tt VALUES('ii hhh aaa ff c hhh iii', 'j cc hh bb e'); + INSERT INTO tt VALUES('e fff hhh i aaa', 'g b aa gg c aa dd'); + INSERT INTO tt VALUES('i aaa ccc gg hhh aa h', 'j bbb bbb d ff'); + INSERT INTO tt VALUES('g f gg ff ff jjj d', 'jjj d j fff fff ee j'); + INSERT INTO tt VALUES('a cc e ccc jjj c', 'ccc iii d bb a eee g'); + INSERT INTO tt VALUES('jj hh hh bb bbb gg', 'j c jjj bb iii f'); + INSERT INTO tt VALUES('a ggg g cc ccc aa', 'jjj j j aaa c'); + INSERT INTO tt VALUES('ddd j dd b i', 'aaa bbb iii ggg ff ccc ddd'); + INSERT INTO tt VALUES('jj ii hh c ii h gg', 'hhh bbb ddd bbb hh g ggg'); + INSERT INTO tt VALUES('aa hhh ccc h ggg ccc', 'iii d jj a ff ii'); + } + + #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM tt_data} {puts $r} + + if {$tn==1} { + set ::checksum [execsql {SELECT md5sum(id, block) FROM tt_data}] + } else { + do_execsql_test 7.$tn { + SELECT md5sum(id, block) FROM tt_data + } [list $::checksum] + } +} + finish_test diff --git a/manifest b/manifest index 85f1621207..3b43cff7f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancement\sthe\svirtual\stable\sinterface\sto\ssupport\sLIKE,\sGLOB,\sand\sREGEXP\noperators.\s\sAlso\sadd\sthe\ssqlite3_strlike()\sinterface,\swhich\smight\sbe\suseful\nas\spart\sof\sthe\simplementation\sof\sLIKE\son\ssome\svirtual\stables. -D 2015-11-25T01:57:42.585 +C Fix\sthe\sfts5\s"prefix="\soption\sto\smatch\sthe\sdocumentation\s(space\sseparated\slist,\smultiple\sprefix=\soptions\ssupported).\sThe\sundocumented\scomma-separated\sformat\s(compatible\swith\sfts4)\sstill\sworks. +D 2015-11-25T11:56:24.532 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -106,7 +106,7 @@ F ext/fts5/fts5.h 8b9a13b309b180e9fb88ea5666c0d8d73c6102d9 F ext/fts5/fts5Int.h acf968e43d57b6b1caf7554d34ec35d6ed3b4fe8 F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 1e49512a535045e621246dc7f4f65f3593fa0fc2 -F ext/fts5/fts5_config.c 6fc92c0b1bda5244c28a54c9ba740736bd5513d9 +F ext/fts5/fts5_config.c 0ee66188609a62342e9f9aeefa3c3e44518a4dd6 F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f F ext/fts5/fts5_index.c b622a0a70f57a96469e6828da2dd70e0872aeb37 @@ -139,7 +139,7 @@ F ext/fts5/test/fts5aux.test 8c687c948cc98e9a94be014df7d518acc1b3b74f F ext/fts5/test/fts5auxdata.test 141a7cbffcceb1bd2799b4b29c183ff8780d586e F ext/fts5/test/fts5bigpl.test 04ee0d7eebbebf17c31f5a0b5c5f9494eac3a0cb F ext/fts5/test/fts5columnsize.test a8cfef21ffa1c264b9f670a7d94eeaccb5341c07 -F ext/fts5/test/fts5config.test ad2ff42ddc856aed2d05bf89dc1c578c8a39ea3b +F ext/fts5/test/fts5config.test 42c1336cc6ed33d7e9c4a05dbce81721b765e7d0 F ext/fts5/test/fts5conflict.test 26f4e46c4d31e16221794832a990dc4e30e18de5 F ext/fts5/test/fts5content.test 9a952c95518a14182dc3b59e3c8fa71cda82a4e1 F ext/fts5/test/fts5corrupt.test c2ad090192708150d50d961278df10ae7a4b8b62 @@ -168,7 +168,7 @@ F ext/fts5/test/fts5phrase.test f6d1d464da5beb25dc56277aa4f1d6102f0d9a2f F ext/fts5/test/fts5plan.test 6a55ecbac9890765b0e16f8c421c7e0888cfe436 F ext/fts5/test/fts5porter.test 7cdc07bef301d70eebbfa75dcaf45c3680e1d0e1 F ext/fts5/test/fts5porter2.test 2e65633d58a1c525d5af0f6c01e5a59155bb3487 -F ext/fts5/test/fts5prefix.test 7ccbdf180ed561a912acef520519e85af8642239 +F ext/fts5/test/fts5prefix.test efd42e00bb8e8a36383f25c838185508681c093f F ext/fts5/test/fts5query.test f5ec25f5f2fbb70033424113cdffc101b1985a40 F ext/fts5/test/fts5rank.test 7e9e64eac7245637f6f2033aec4b292aaf611aab F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b @@ -1405,8 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 20256177072caa4f2b4114038ad1c8f6e26bc562 e70ec71d6883f2f8fc75301ff985bccb5aa06127 -R d30ed8c32e99c9a94479405580943fff -T +closed e70ec71d6883f2f8fc75301ff985bccb5aa06127 -U drh -Z 535a3252c539f51f296331cdb8ca572e +P a6bfd4692c3f8b107546fbcaeb985d2c1817b3c1 +R 1d5b11516958faf6b08e74d20f3f2fa4 +U dan +Z 6f4c4e6edf8914578c51e0efeab8cf04 diff --git a/manifest.uuid b/manifest.uuid index 453c2a5a99..70c5c2cfac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a6bfd4692c3f8b107546fbcaeb985d2c1817b3c1 \ No newline at end of file +11eb8e877e2ba859ef6b44318f286597186dfaf2 \ No newline at end of file From 91c4defbcf7f53e37720efb67209ad3b76f0f834 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 25 Nov 2015 14:00:07 +0000 Subject: [PATCH 014/232] Simplification of the error code translator in os_unix.c. Code cleanup only. The logic is unchanged. FossilOrigin-Name: 2a20f793fdf6a2e88b679a7bd4e8ccf2935df049 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 53 +++++---------------------------------------------- 3 files changed, 13 insertions(+), 56 deletions(-) diff --git a/manifest b/manifest index 3b43cff7f4..2454a3f417 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sfts5\s"prefix="\soption\sto\smatch\sthe\sdocumentation\s(space\sseparated\slist,\smultiple\sprefix=\soptions\ssupported).\sThe\sundocumented\scomma-separated\sformat\s(compatible\swith\sfts4)\sstill\sworks. -D 2015-11-25T11:56:24.532 +C Simplification\sof\sthe\serror\scode\stranslator\sin\sos_unix.c.\s\sCode\scleanup\sonly.\nThe\slogic\sis\sunchanged. +D 2015-11-25T14:00:07.501 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 80ec49758dbce979e4f89eda7695bbc01b0c4cd3 +F src/os_unix.c cedce5fdeec172e9392a54805979423cf5720159 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a6bfd4692c3f8b107546fbcaeb985d2c1817b3c1 -R 1d5b11516958faf6b08e74d20f3f2fa4 -U dan -Z 6f4c4e6edf8914578c51e0efeab8cf04 +P 11eb8e877e2ba859ef6b44318f286597186dfaf2 +R 6dd872f66c2b35bfdd31a4b155581f40 +U drh +Z ffd91438f4f00e7137108dd3e9d6d335 diff --git a/manifest.uuid b/manifest.uuid index 70c5c2cfac..100264e01f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -11eb8e877e2ba859ef6b44318f286597186dfaf2 \ No newline at end of file +2a20f793fdf6a2e88b679a7bd4e8ccf2935df049 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 82224053f0..6afbfe5cae 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -759,23 +759,12 @@ static int robust_ftruncate(int h, sqlite3_int64 sz){ ** should handle ENOLCK, ENOTSUP, EOPNOTSUPP separately. */ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) { + assert( (sqliteIOErr == SQLITE_IOERR_LOCK) || + (sqliteIOErr == SQLITE_IOERR_UNLOCK) || + (sqliteIOErr == SQLITE_IOERR_RDLOCK) || + (sqliteIOErr == SQLITE_IOERR_CHECKRESERVEDLOCK) ); switch (posixError) { -#if 0 - /* At one point this code was not commented out. In theory, this branch - ** should never be hit, as this function should only be called after - ** a locking-related function (i.e. fcntl()) has returned non-zero with - ** the value of errno as the first argument. Since a system call has failed, - ** errno should be non-zero. - ** - ** Despite this, if errno really is zero, we still don't want to return - ** SQLITE_OK. The system call failed, and *some* SQLite error should be - ** propagated back to the caller. Commenting this branch out means errno==0 - ** will be handled by the "default:" case below. - */ - case 0: - return SQLITE_OK; -#endif - + case EACCES: case EAGAIN: case ETIMEDOUT: case EBUSY: @@ -785,41 +774,9 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) { * introspection, in which it actually means what it says */ return SQLITE_BUSY; - case EACCES: - /* EACCES is like EAGAIN during locking operations, but not any other time*/ - if( (sqliteIOErr == SQLITE_IOERR_LOCK) || - (sqliteIOErr == SQLITE_IOERR_UNLOCK) || - (sqliteIOErr == SQLITE_IOERR_RDLOCK) || - (sqliteIOErr == SQLITE_IOERR_CHECKRESERVEDLOCK) ){ - return SQLITE_BUSY; - } - /* else fall through */ case EPERM: return SQLITE_PERM; -#if EOPNOTSUPP!=ENOTSUP - case EOPNOTSUPP: - /* something went terribly awry, unless during file system support - * introspection, in which it actually means what it says */ -#endif -#ifdef ENOTSUP - case ENOTSUP: - /* invalid fd, unless during file system support introspection, in which - * it actually means what it says */ -#endif - case EIO: - case EBADF: - case EINVAL: - case ENOTCONN: - case ENODEV: - case ENXIO: - case ENOENT: -#ifdef ESTALE /* ESTALE is not defined on Interix systems */ - case ESTALE: -#endif - case ENOSYS: - /* these should force the client to close the file and reconnect */ - default: return sqliteIOErr; } From 5337dacbad4d61f48873ad228a0bf4399043d854 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 25 Nov 2015 15:15:03 +0000 Subject: [PATCH 015/232] Remove unused methods from the unix VFS. FossilOrigin-Name: 228bd15bbb7a1e6e3e0d03832e7f39ba169356a8 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 8 ++++++++ test/fuzzcheck.c | 10 ++-------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 2454a3f417..4aa83052a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sof\sthe\serror\scode\stranslator\sin\sos_unix.c.\s\sCode\scleanup\sonly.\nThe\slogic\sis\sunchanged. -D 2015-11-25T14:00:07.501 +C Remove\sunused\smethods\sfrom\sthe\sunix\sVFS. +D 2015-11-25T15:15:03.618 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c cedce5fdeec172e9392a54805979423cf5720159 +F src/os_unix.c a6ed7d9ae6e2308b61bd842d6aa296727d26b4fd F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e @@ -753,7 +753,7 @@ F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1 F test/fuzz3.test 53fabcd5f0f430f8b221282f6c12c4d0903c21eb F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26 -F test/fuzzcheck.c 7c61352f20a28429b221f406f3854cf9c912f63b +F test/fuzzcheck.c ccdcdc28579b2c9744696bca8726bdbd729eea11 F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664 F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 11eb8e877e2ba859ef6b44318f286597186dfaf2 -R 6dd872f66c2b35bfdd31a4b155581f40 +P 2a20f793fdf6a2e88b679a7bd4e8ccf2935df049 +R 9425887a4af2be1f5866057e942bff78 U drh -Z ffd91438f4f00e7137108dd3e9d6d335 +Z 8531bdf5b0fab73861e87c8c638f4398 diff --git a/manifest.uuid b/manifest.uuid index 100264e01f..468142cf2d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2a20f793fdf6a2e88b679a7bd4e8ccf2935df049 \ No newline at end of file +228bd15bbb7a1e6e3e0d03832e7f39ba169356a8 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 6afbfe5cae..e31843af3b 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -6227,6 +6227,7 @@ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ return rc; } +#if 0 /* Not used */ /* ** Find the current time (in Universal Coordinated Time). Write the ** current time and date as a Julian Day number into *prNow and @@ -6240,7 +6241,11 @@ static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){ *prNow = i/86400000.0; return rc; } +#else +# define unixCurrentTime 0 +#endif +#if 0 /* Not used */ /* ** We added the xGetLastError() method with the intention of providing ** better low-level error messages when operating-system problems come up @@ -6254,6 +6259,9 @@ static int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){ UNUSED_PARAMETER(NotUsed3); return 0; } +#else +# define unixGetLastError 0 +#endif /* diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index 32690dc466..6d9c745528 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -588,18 +588,13 @@ static int inmemFullPathname( return SQLITE_OK; } -/* GetLastError() is never used */ -static int inmemGetLastError(sqlite3_vfs *pVfs, int n, char *z){ - return SQLITE_OK; -} - /* ** Register the VFS that reads from the g.aFile[] set of files. */ static void inmemVfsRegister(void){ static sqlite3_vfs inmemVfs; sqlite3_vfs *pDefault = sqlite3_vfs_find(0); - inmemVfs.iVersion = 1; + inmemVfs.iVersion = 3; inmemVfs.szOsFile = sizeof(VHandle); inmemVfs.mxPathname = 200; inmemVfs.zName = "inmem"; @@ -609,8 +604,7 @@ static void inmemVfsRegister(void){ inmemVfs.xFullPathname = inmemFullPathname; inmemVfs.xRandomness = pDefault->xRandomness; inmemVfs.xSleep = pDefault->xSleep; - inmemVfs.xCurrentTime = pDefault->xCurrentTime; - inmemVfs.xGetLastError = inmemGetLastError; + inmemVfs.xCurrentTimeInt64 = pDefault->xCurrentTimeInt64; sqlite3_vfs_register(&inmemVfs, 0); }; From d260b5b2ce9acf1d8ef5eafc1c9d8754c5babe57 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 25 Nov 2015 18:03:33 +0000 Subject: [PATCH 016/232] Make the xAccess method of the unix VFS smaller and faster. FossilOrigin-Name: 191aef986ffc4ef34d813e417e52a4ec820b0300 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 31 ++++++++++--------------------- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/manifest b/manifest index 4aa83052a7..412e61730b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunused\smethods\sfrom\sthe\sunix\sVFS. -D 2015-11-25T15:15:03.618 +C Make\sthe\sxAccess\smethod\sof\sthe\sunix\sVFS\ssmaller\sand\sfaster. +D 2015-11-25T18:03:33.041 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c a6ed7d9ae6e2308b61bd842d6aa296727d26b4fd +F src/os_unix.c 066d6f8e4ea9c9b82e93eef2daee3cf25759fa36 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2a20f793fdf6a2e88b679a7bd4e8ccf2935df049 -R 9425887a4af2be1f5866057e942bff78 +P 228bd15bbb7a1e6e3e0d03832e7f39ba169356a8 +R e147c2a2e15689c8fb9a94a36196c06f U drh -Z 8531bdf5b0fab73861e87c8c638f4398 +Z 62ff0fd6ec1e0622890fd7a98828488f diff --git a/manifest.uuid b/manifest.uuid index 468142cf2d..a972ab8efd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -228bd15bbb7a1e6e3e0d03832e7f39ba169356a8 \ No newline at end of file +191aef986ffc4ef34d813e417e52a4ec820b0300 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index e31843af3b..48f38fdfa2 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5940,29 +5940,19 @@ static int unixAccess( int flags, /* What do we want to learn about the zPath file? */ int *pResOut /* Write result boolean here */ ){ - int amode = 0; UNUSED_PARAMETER(NotUsed); SimulateIOError( return SQLITE_IOERR_ACCESS; ); - switch( flags ){ - case SQLITE_ACCESS_EXISTS: - amode = F_OK; - break; - case SQLITE_ACCESS_READWRITE: - amode = W_OK|R_OK; - break; - case SQLITE_ACCESS_READ: - amode = R_OK; - break; + assert( pResOut!=0 ); - default: - assert(!"Invalid flags argument"); - } - *pResOut = (osAccess(zPath, amode)==0); - if( flags==SQLITE_ACCESS_EXISTS && *pResOut ){ + /* The spec says there are three possible values for flags. But only + ** two of them are actually used */ + assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE ); + + if( flags==SQLITE_ACCESS_EXISTS ){ struct stat buf; - if( 0==osStat(zPath, &buf) && buf.st_size==0 ){ - *pResOut = 0; - } + *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0); + }else{ + *pResOut = osAccess(zPath, W_OK|R_OK)==0; } return SQLITE_OK; } @@ -6005,8 +5995,7 @@ static int unixFullPathname( if( errno!=EINVAL && errno!=ENOENT ){ return unixLogError(SQLITE_CANTOPEN_BKPT, "readlink", zPath); } - zOut[nOut-1] = '\0'; - sqlite3_snprintf(nOut-1, zOut, "%s", zPath); + sqlite3_snprintf(nOut, zOut, "%s", zPath); nByte = sqlite3Strlen30(zOut); }else{ zOut[nByte] = '\0'; From 1e93173ffcfbe2ebb4eae02622cd6e52c36a1729 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 25 Nov 2015 18:07:46 +0000 Subject: [PATCH 017/232] Update test_fs.c to include a virtual table that reads a file-system hierarchy. Use it to further test GLOB and LIKE support for virtual tables. FossilOrigin-Name: 6ef6578c03b7cfbeaaf3627b9eea2febf501ace5 --- manifest | 18 +- manifest.uuid | 2 +- src/test_fs.c | 543 +++++++++++++++++++++++++++++++++++++++++- test/fts4content.test | 4 +- test/vtabH.test | 80 ++++++- 5 files changed, 631 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 412e61730b..4c40672e14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\sxAccess\smethod\sof\sthe\sunix\sVFS\ssmaller\sand\sfaster. -D 2015-11-25T18:03:33.041 +C Update\stest_fs.c\sto\sinclude\sa\svirtual\stable\sthat\sreads\sa\sfile-system\shierarchy.\sUse\sit\sto\sfurther\stest\sGLOB\sand\sLIKE\ssupport\sfor\svirtual\stables. +D 2015-11-25T18:07:46.837 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -366,7 +366,7 @@ F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f F src/test_config.c f2824de39f59d8d621e2d6ec5cc67006d000b2eb F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc -F src/test_fs.c ced436e3d4b8e4681328409b8081051ce614e28f +F src/test_fs.c 802b1863c77f0531603c4a70f30ac5bca89a60da F src/test_func.c 0d9c25956152adefee8881c6fadc8354793764d0 F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32 @@ -728,7 +728,7 @@ F test/fts3tok_err.test 52273cd193b9036282f7bacb43da78c6be87418d F test/fts3varint.test 752c08ed5d32c5d7dc211b056f4ed68a76b7e36e F test/fts4aa.test 10aac8e9d62c7357590acfabe3fad01e9a9ce1cb F test/fts4check.test 9d9e818fd6cb29c0e007cd6d00447739d4fde430 -F test/fts4content.test abb0c77bc3da3df64fec72e00844d2257a90025d +F test/fts4content.test 8707425b926663f8ca81de866c007900442b5ec0 F test/fts4docid.test e33c383cfbdff0284685604d256f347a18fdbf01 F test/fts4growth.test df10fde9f47cf5c71861e63fd8efcd573c4f7e53 F test/fts4growth2.test 2f063be1902a73cd087355837c52fed42ac11a5d @@ -1274,7 +1274,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test 694aa399eb28ed0db2aef59f2f37532781eeb957 +F test/vtabH.test 2030e7183e41c3cc7521c06aa7bc5a232f7e8986 F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test ea8778d5b0df200adef2ca7c00c3c37d4375f772 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 228bd15bbb7a1e6e3e0d03832e7f39ba169356a8 -R e147c2a2e15689c8fb9a94a36196c06f -U drh -Z 62ff0fd6ec1e0622890fd7a98828488f +P 191aef986ffc4ef34d813e417e52a4ec820b0300 +R 98283e54084b319f4a987e20b98e348d +U dan +Z 4eb24c0ce56061f040de45e89ced3c69 diff --git a/manifest.uuid b/manifest.uuid index a972ab8efd..44129864bc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -191aef986ffc4ef34d813e417e52a4ec820b0300 \ No newline at end of file +6ef6578c03b7cfbeaaf3627b9eea2febf501ace5 \ No newline at end of file diff --git a/src/test_fs.c b/src/test_fs.c index 417c81b49f..eab5a4a7ad 100644 --- a/src/test_fs.c +++ b/src/test_fs.c @@ -29,6 +29,37 @@ ** Adding the row to the idx table automatically creates a row in the ** virtual table with rowid=4, path=/etc/passwd and a text field that ** contains data read from file /etc/passwd on disk. +** +************************************************************************* +** Virtual table module "fsdir" +** +** This module is designed to be used as a read-only eponymous virtual table. +** Its schema is as follows: +** +** CREATE TABLE fsdir(dir TEXT, name TEXT); +** +** When queried, a WHERE term of the form "dir = $dir" must be provided. The +** virtual table then appears to have one row for each entry in file-system +** directory $dir. Column dir contains a copy of $dir, and column "name" +** contains the name of the directory entry. +** +** If the specified $dir cannot be opened or is not a directory, it is not +** an error. The virtual table appears to be empty in this case. +** +************************************************************************* +** Virtual table module "fstree" +** +** This module is also a read-only eponymous virtual table with the +** following schema: +** +** CREATE TABLE fstree(path TEXT, size INT, data BLOB); +** +** Running a "SELECT * FROM fstree" query on this table returns the entire +** contents of the file-system, starting at "/". To restrict the search +** space, the virtual table supports LIKE and GLOB constraints on the +** 'path' column. For example: +** +** SELECT * FROM fstree WHERE path LIKE '/home/dan/sqlite/%' */ #include "sqliteInt.h" #include "tcl.h" @@ -41,6 +72,7 @@ #if SQLITE_OS_UNIX # include +# include #endif #if SQLITE_OS_WIN # include @@ -70,6 +102,463 @@ struct fs_cursor { int nAlloc; }; +/************************************************************************* +** Start of fsdir implementation. +*/ +typedef struct FsdirVtab FsdirVtab; +typedef struct FsdirCsr FsdirCsr; +struct FsdirVtab { + sqlite3_vtab base; +}; + +struct FsdirCsr { + sqlite3_vtab_cursor base; + char *zDir; /* Buffer containing directory scanned */ + DIR *pDir; /* Open directory */ + sqlite3_int64 iRowid; + struct dirent entry; /* Current entry */ +}; + +/* +** This function is the implementation of both the xConnect and xCreate +** methods of the fsdir virtual table. +** +** The argv[] array contains the following: +** +** argv[0] -> module name ("fs") +** argv[1] -> database name +** argv[2] -> table name +** argv[...] -> other module argument fields. +*/ +static int fsdirConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + FsdirVtab *pTab; + + if( argc!=3 ){ + *pzErr = sqlite3_mprintf("wrong number of arguments"); + return SQLITE_ERROR; + } + + pTab = (FsdirVtab *)sqlite3_malloc(sizeof(FsdirVtab)); + if( !pTab ) return SQLITE_NOMEM; + memset(pTab, 0, sizeof(FsdirVtab)); + + *ppVtab = &pTab->base; + sqlite3_declare_vtab(db, "CREATE TABLE xyz(dir, name);"); + + return SQLITE_OK; +} + +/* +** xDestroy/xDisconnect implementation. +*/ +static int fsdirDisconnect(sqlite3_vtab *pVtab){ + sqlite3_free(pVtab); + return SQLITE_OK; +} + +/* +** xBestIndex implementation. The only constraint supported is: +** +** (dir = ?) +*/ +static int fsdirBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ + int ii; + + pIdxInfo->estimatedCost = 1000000000.0; + + for(ii=0; iinConstraint; ii++){ + struct sqlite3_index_constraint const *p = &pIdxInfo->aConstraint[ii]; + if( p->iColumn==0 && p->usable && p->op==SQLITE_INDEX_CONSTRAINT_EQ ){ + struct sqlite3_index_constraint_usage *pUsage; + pUsage = &pIdxInfo->aConstraintUsage[ii]; + pUsage->omit = 1; + pUsage->argvIndex = 1; + pIdxInfo->idxNum = 1; + pIdxInfo->estimatedCost = 1.0; + break; + } + } + + return SQLITE_OK; +} + +/* +** xOpen implementation. +** +** Open a new fsdir cursor. +*/ +static int fsdirOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ + FsdirCsr *pCur; + pCur = (FsdirCsr*)sqlite3_malloc(sizeof(FsdirCsr)); + if( pCur==0 ) return SQLITE_NOMEM; + memset(pCur, 0, sizeof(FsdirCsr)); + *ppCursor = &pCur->base; + return SQLITE_OK; +} + +/* +** Close a fsdir cursor. +*/ +static int fsdirClose(sqlite3_vtab_cursor *cur){ + FsdirCsr *pCur = (FsdirCsr*)cur; + if( pCur->pDir ) closedir(pCur->pDir); + sqlite3_free(pCur->zDir); + sqlite3_free(pCur); + return SQLITE_OK; +} + +/* +** Skip the cursor to the next entry. +*/ +static int fsdirNext(sqlite3_vtab_cursor *cur){ + FsdirCsr *pCsr = (FsdirCsr*)cur; + + if( pCsr->pDir ){ + struct dirent *pRes = 0; + readdir_r(pCsr->pDir, &pCsr->entry, &pRes); + if( pRes==0 ){ + closedir(pCsr->pDir); + pCsr->pDir = 0; + } + pCsr->iRowid++; + } + + return SQLITE_OK; +} + +/* +** xFilter method implementation. +*/ +static int fsdirFilter( + sqlite3_vtab_cursor *pVtabCursor, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + FsdirCsr *pCsr = (FsdirCsr*)pVtabCursor; + int rc; + const char *zDir; + int nDir; + + + if( idxNum!=1 || argc!=1 ){ + return SQLITE_ERROR; + } + + pCsr->iRowid = 0; + sqlite3_free(pCsr->zDir); + if( pCsr->pDir ){ + closedir(pCsr->pDir); + pCsr->pDir = 0; + } + + zDir = (const char*)sqlite3_value_text(argv[0]); + nDir = sqlite3_value_bytes(argv[0]); + pCsr->zDir = sqlite3_malloc(nDir+1); + if( pCsr->zDir==0 ) return SQLITE_NOMEM; + memcpy(pCsr->zDir, zDir, nDir+1); + + pCsr->pDir = opendir(pCsr->zDir); + return fsdirNext(pVtabCursor); +} + +/* +** xEof method implementation. +*/ +static int fsdirEof(sqlite3_vtab_cursor *cur){ + FsdirCsr *pCsr = (FsdirCsr*)cur; + return pCsr->pDir==0; +} + +/* +** xColumn method implementation. +*/ +static int fsdirColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ + FsdirCsr *pCsr = (FsdirCsr*)cur; + switch( i ){ + case 0: /* dir */ + sqlite3_result_text(ctx, pCsr->zDir, -1, SQLITE_STATIC); + break; + + case 1: /* name */ + sqlite3_result_text(ctx, pCsr->entry.d_name, -1, SQLITE_TRANSIENT); + break; + + default: + assert( 0 ); + } + + return SQLITE_OK; +} + +/* +** xRowid method implementation. +*/ +static int fsdirRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + FsdirCsr *pCsr = (FsdirCsr*)cur; + *pRowid = pCsr->iRowid; + return SQLITE_OK; +} +/* +** End of fsdir implementation. +*************************************************************************/ + +/************************************************************************* +** Start of fstree implementation. +*/ +typedef struct FstreeVtab FstreeVtab; +typedef struct FstreeCsr FstreeCsr; +struct FstreeVtab { + sqlite3_vtab base; + sqlite3 *db; +}; + +struct FstreeCsr { + sqlite3_vtab_cursor base; + sqlite3_stmt *pStmt; /* Statement to list paths */ + int fd; /* File descriptor open on current path */ +}; + +/* +** This function is the implementation of both the xConnect and xCreate +** methods of the fstree virtual table. +** +** The argv[] array contains the following: +** +** argv[0] -> module name ("fs") +** argv[1] -> database name +** argv[2] -> table name +** argv[...] -> other module argument fields. +*/ +static int fstreeConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + FstreeVtab *pTab; + + if( argc!=3 ){ + *pzErr = sqlite3_mprintf("wrong number of arguments"); + return SQLITE_ERROR; + } + + pTab = (FstreeVtab *)sqlite3_malloc(sizeof(FstreeVtab)); + if( !pTab ) return SQLITE_NOMEM; + memset(pTab, 0, sizeof(FstreeVtab)); + pTab->db = db; + + *ppVtab = &pTab->base; + sqlite3_declare_vtab(db, "CREATE TABLE xyz(path, size, data);"); + + return SQLITE_OK; +} + +/* +** xDestroy/xDisconnect implementation. +*/ +static int fstreeDisconnect(sqlite3_vtab *pVtab){ + sqlite3_free(pVtab); + return SQLITE_OK; +} + +/* +** xBestIndex implementation. The only constraint supported is: +** +** (dir = ?) +*/ +static int fstreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ + int ii; + + for(ii=0; iinConstraint; ii++){ + struct sqlite3_index_constraint const *p = &pIdxInfo->aConstraint[ii]; + if( p->iColumn==0 && p->usable && ( + p->op==SQLITE_INDEX_CONSTRAINT_GLOB + || p->op==SQLITE_INDEX_CONSTRAINT_LIKE + || p->op==SQLITE_INDEX_CONSTRAINT_EQ + )){ + struct sqlite3_index_constraint_usage *pUsage; + pUsage = &pIdxInfo->aConstraintUsage[ii]; + pIdxInfo->idxNum = p->op; + pUsage->argvIndex = 1; + pIdxInfo->estimatedCost = 100000.0; + return SQLITE_OK; + } + } + + pIdxInfo->estimatedCost = 1000000000.0; + return SQLITE_OK; +} + +/* +** xOpen implementation. +** +** Open a new fstree cursor. +*/ +static int fstreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ + FstreeCsr *pCur; + pCur = (FstreeCsr*)sqlite3_malloc(sizeof(FstreeCsr)); + if( pCur==0 ) return SQLITE_NOMEM; + memset(pCur, 0, sizeof(FstreeCsr)); + pCur->fd = -1; + *ppCursor = &pCur->base; + return SQLITE_OK; +} + +static void fstreeCloseFd(FstreeCsr *pCsr){ + if( pCsr->fd>=0 ){ + close(pCsr->fd); + pCsr->fd = -1; + } +} + +/* +** Close a fstree cursor. +*/ +static int fstreeClose(sqlite3_vtab_cursor *cur){ + FstreeCsr *pCsr = (FstreeCsr*)cur; + sqlite3_finalize(pCsr->pStmt); + fstreeCloseFd(pCsr); + sqlite3_free(pCsr); + return SQLITE_OK; +} + +/* +** Skip the cursor to the next entry. +*/ +static int fstreeNext(sqlite3_vtab_cursor *cur){ + FstreeCsr *pCsr = (FstreeCsr*)cur; + int rc; + + fstreeCloseFd(pCsr); + rc = sqlite3_step(pCsr->pStmt); + if( rc!=SQLITE_ROW ){ + rc = sqlite3_finalize(pCsr->pStmt); + pCsr->pStmt = 0; + }else{ + rc = SQLITE_OK; + pCsr->fd = open(sqlite3_column_text(pCsr->pStmt, 0), O_RDONLY); + } + + return rc; +} + +/* +** xFilter method implementation. +*/ +static int fstreeFilter( + sqlite3_vtab_cursor *pVtabCursor, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + FstreeCsr *pCsr = (FstreeCsr*)pVtabCursor; + FstreeVtab *pTab = (FstreeVtab*)(pCsr->base.pVtab); + int rc; + const char *zSql = +"WITH r(d) AS (" +" SELECT CASE WHEN dir='/' THEN '' ELSE dir END || '/' || name " +" FROM fsdir WHERE dir=? AND name NOT LIKE '.%'" +" UNION ALL" +" SELECT dir || '/' || name FROM r, fsdir WHERE dir=d AND name NOT LIKE '.%'" +") SELECT d FROM r;"; + + const char *zDir = "/"; + int nDir = 1; + char aWild[2] = {'\0', '\0' }; + + fstreeCloseFd(pCsr); + sqlite3_finalize(pCsr->pStmt); + pCsr->pStmt = 0; + rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0); + if( rc!=SQLITE_OK ) return rc; + + if( idxNum ){ + const char *zQuery = (const char*)sqlite3_value_text(argv[0]); + switch( idxNum ){ + case SQLITE_INDEX_CONSTRAINT_GLOB: + aWild[0] = '*'; + aWild[1] = '?'; + break; + case SQLITE_INDEX_CONSTRAINT_LIKE: + aWild[0] = '_'; + aWild[1] = '%'; + break; + } + + if( zQuery[0]=='/' ){ + int i; + for(i=1; zQuery[i]; i++){ + if( zQuery[i]==aWild[0] || zQuery[i]==aWild[1] ) break; + if( zQuery[i]=='/' ) nDir = i; + } + zDir = zQuery; + } + } + + sqlite3_bind_text(pCsr->pStmt, 1, zDir, nDir, SQLITE_TRANSIENT); + + return fstreeNext(pVtabCursor); +} + +/* +** xEof method implementation. +*/ +static int fstreeEof(sqlite3_vtab_cursor *cur){ + FstreeCsr *pCsr = (FstreeCsr*)cur; + return pCsr->pStmt==0; +} + +/* +** xColumn method implementation. +*/ +static int fstreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ + FstreeCsr *pCsr = (FstreeCsr*)cur; + if( i==0 ){ /* path */ + sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pStmt, 0)); + }else{ + struct stat sBuf; + fstat(pCsr->fd, &sBuf); + + if( S_ISREG(sBuf.st_mode) ){ + if( i==1 ){ + sqlite3_result_int64(ctx, sBuf.st_size); + }else{ + int nRead; + char *aBuf = sqlite3_malloc(sBuf.st_mode+1); + if( !aBuf ) return SQLITE_NOMEM; + nRead = read(pCsr->fd, aBuf, sBuf.st_mode); + if( nRead!=sBuf.st_mode ){ + return SQLITE_IOERR; + } + sqlite3_result_blob(ctx, aBuf, nRead, SQLITE_TRANSIENT); + sqlite3_free(aBuf); + } + } + } + + return SQLITE_OK; +} + +/* +** xRowid method implementation. +*/ +static int fstreeRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + *pRowid = 0; + return SQLITE_OK; +} +/* +** End of fstree implementation. +*************************************************************************/ + + + + /* ** This function is the implementation of both the xConnect and xCreate ** methods of the fs virtual table. @@ -109,7 +598,7 @@ static int fsConnect( memcpy(pVtab->zTbl, zTbl, strlen(zTbl)); memcpy(pVtab->zDb, zDb, strlen(zDb)); *ppVtab = &pVtab->base; - sqlite3_declare_vtab(db, "CREATE TABLE xyz(path TEXT, data TEXT)"); + sqlite3_declare_vtab(db, "CREATE TABLE x(path TEXT, data TEXT)"); return SQLITE_OK; } @@ -188,15 +677,15 @@ static int fsFilter( static int fsColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ fs_cursor *pCur = (fs_cursor*)cur; - assert( i==0 || i==1 ); + assert( i==0 || i==1 || i==2 ); if( i==0 ){ sqlite3_result_value(ctx, sqlite3_column_value(pCur->pStmt, 0)); }else{ const char *zFile = (const char *)sqlite3_column_text(pCur->pStmt, 1); struct stat sbuf; int fd; - int n; + int n; fd = open(zFile, O_RDONLY); if( fd<0 ) return SQLITE_IOERR; fstat(fd, &sbuf); @@ -284,6 +773,52 @@ static sqlite3_module fsModule = { 0, /* xRename */ }; +static sqlite3_module fsdirModule = { + 0, /* iVersion */ + fsdirConnect, /* xCreate */ + fsdirConnect, /* xConnect */ + fsdirBestIndex, /* xBestIndex */ + fsdirDisconnect, /* xDisconnect */ + fsdirDisconnect, /* xDestroy */ + fsdirOpen, /* xOpen - open a cursor */ + fsdirClose, /* xClose - close a cursor */ + fsdirFilter, /* xFilter - configure scan constraints */ + fsdirNext, /* xNext - advance a cursor */ + fsdirEof, /* xEof - check for end of scan */ + fsdirColumn, /* xColumn - read data */ + fsdirRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ +}; + +static sqlite3_module fstreeModule = { + 0, /* iVersion */ + fstreeConnect, /* xCreate */ + fstreeConnect, /* xConnect */ + fstreeBestIndex, /* xBestIndex */ + fstreeDisconnect, /* xDisconnect */ + fstreeDisconnect, /* xDestroy */ + fstreeOpen, /* xOpen - open a cursor */ + fstreeClose, /* xClose - close a cursor */ + fstreeFilter, /* xFilter - configure scan constraints */ + fstreeNext, /* xNext - advance a cursor */ + fstreeEof, /* xEof - check for end of scan */ + fstreeColumn, /* xColumn - read data */ + fstreeRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ +}; + /* ** Decode a pointer to an sqlite3 object. */ @@ -306,6 +841,8 @@ static int register_fs_module( if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; #ifndef SQLITE_OMIT_VIRTUALTABLE sqlite3_create_module(db, "fs", &fsModule, (void *)interp); + sqlite3_create_module(db, "fsdir", &fsdirModule, 0); + sqlite3_create_module(db, "fstree", &fstreeModule, 0); #endif return TCL_OK; } diff --git a/test/fts4content.test b/test/fts4content.test index 481c6ec008..5a91987867 100644 --- a/test/fts4content.test +++ b/test/fts4content.test @@ -587,7 +587,7 @@ do_execsql_test 10.1 { INSERT INTO idx VALUES (3, 't3.txt'); CREATE VIRTUAL TABLE vt USING fs(idx); - SELECT * FROM vt; + SELECT path, data FROM vt; } { 1 {a b c d e f g h i j k l m n o p q r s t u v w x y z} 2 {a b c d e f g h i j k l m a b c d e f g h i j k l m} @@ -595,7 +595,7 @@ do_execsql_test 10.1 { } do_execsql_test 10.2 { - SELECT * FROM vt WHERE rowid = 2; + SELECT path, data FROM vt WHERE rowid = 2; } { 2 {a b c d e f g h i j k l m a b c d e f g h i j k l m} } diff --git a/test/vtabH.test b/test/vtabH.test index 53ecf0a948..dab5343da5 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -92,7 +92,6 @@ foreach ::tclvar_set_omit {0 1} { 2 {value LIKE '%ac%'} {x1 aback x7 backbone x8 backarrow} 300 3 {value REGEXP '^......$'} {x5 babble x6 baboon x9 castle} 30000 } { - if {$tn==3} breakpoint db cache flush set ::gfunc 0 if {$::tclvar_set_omit} {set cnt 0} @@ -107,4 +106,83 @@ foreach ::tclvar_set_omit {0 1} { } } +#------------------------------------------------------------------------- +# +if {$::tcl_platform(platform)=="unix"} { + reset_db + register_fs_module db + do_execsql_test 3.0 { + SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db'; + SELECT name FROM fsdir WHERE dir = '.' AND name = '.' + } {test.db .} + + # Read the first 5 entries from the root directory. + # + set res [list] + foreach p [lrange [exec ls -U /] 0 4] { + lappend res "/$p" + } + do_execsql_test 3.1 { + SELECT path FROM fstree LIMIT 5; + } $res + + # Read all entries in the current directory. + # + proc contents {pattern} { + set res [list] + foreach f [glob -nocomplain $pattern] { + lappend res $f + if {[file isdir $f]} { + set res [concat $res [contents "$f/*"]] + } + } + set res + } + set pwd "[pwd]/*" + set res [contents $pwd] + do_execsql_test 3.2 { + SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1 + } [lsort $res] + + # Add some sub-directories and files to the current directory. + # + do_test 3.3 { + catch { file delete -force subdir } + foreach {path sz} { + subdir/x1.txt 143 + subdir/x2.txt 153 + } { + set dir [file dirname $path] + catch { file mkdir $dir } + set fd [open $path w] + puts -nonewline $fd [string repeat 1 $sz] + close $fd + } + } {} + + set pwd [pwd] + do_execsql_test 3.5 { + SELECT path, size FROM fstree WHERE path GLOB $pwd || '/subdir/*' ORDER BY 1 + } [list \ + "$pwd/subdir/x1.txt" 143 \ + "$pwd/subdir/x2.txt" 153 \ + ] + do_execsql_test 3.6 { + SELECT path, size FROM fstree WHERE path LIKE $pwd || '/subdir/%' ORDER BY 1 + } [list \ + "$pwd/subdir/x1.txt" 143 \ + "$pwd/subdir/x2.txt" 153 \ + ] + do_execsql_test 3.7 { + SELECT sum(size) FROM fstree WHERE path LIKE $pwd || '/subdir/%' + } 296 + do_execsql_test 3.8 { + SELECT size FROM fstree WHERE path = $pwd || '/subdir/x1.txt' + } 143 + +} + + finish_test + + From 489f1e86e3ad5dcf7e2a84c472c752d52355a8f9 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 25 Nov 2015 18:40:38 +0000 Subject: [PATCH 018/232] Fix harmless compiler warnings in test_fs.c. Fix typos and clean up the text of the documentation for sqlite3_strglob() and sqlite3_strlike(). FossilOrigin-Name: 697b20534c2d780cdd8cc165d2930f6e56480770 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqlite.h.in | 28 +++++++++++++--------------- src/test_fs.c | 3 +-- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index 4c40672e14..3eb5cb0f1a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\stest_fs.c\sto\sinclude\sa\svirtual\stable\sthat\sreads\sa\sfile-system\shierarchy.\sUse\sit\sto\sfurther\stest\sGLOB\sand\sLIKE\ssupport\sfor\svirtual\stables. -D 2015-11-25T18:07:46.837 +C Fix\sharmless\scompiler\swarnings\sin\stest_fs.c.\s\sFix\stypos\sand\sclean\sup\sthe\stext\nof\sthe\sdocumentation\sfor\ssqlite3_strglob()\sand\ssqlite3_strlike(). +D 2015-11-25T18:40:38.741 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -341,7 +341,7 @@ F src/resolve.c f4c897ca76ca6d5e0b3f0499c627392ffe657c8e F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c e10586c750d87211caa8f4b239e2bfa6a2049e5b F src/shell.c f0f59ea60ad297f671b7ae0fb957a736ad17c92c -F src/sqlite.h.in cbe8643b6a1c7313bf6447a2aa7abdb31c73dd77 +F src/sqlite.h.in 1340aa105f53fbc6fd5b9918b54b64c64e910ee7 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 41ef50b0418a7c5ad1337bb80db5a7928dee764f F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 @@ -366,7 +366,7 @@ F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f F src/test_config.c f2824de39f59d8d621e2d6ec5cc67006d000b2eb F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc -F src/test_fs.c 802b1863c77f0531603c4a70f30ac5bca89a60da +F src/test_fs.c 9a56a587ce1db424af430d5ff650b5736b498238 F src/test_func.c 0d9c25956152adefee8881c6fadc8354793764d0 F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 191aef986ffc4ef34d813e417e52a4ec820b0300 -R 98283e54084b319f4a987e20b98e348d -U dan -Z 4eb24c0ce56061f040de45e89ced3c69 +P 6ef6578c03b7cfbeaaf3627b9eea2febf501ace5 +R 6a7e3073277459e34ef3bc33d986fb8e +U drh +Z 86f0abe6c80c8309344887b29ae04a0c diff --git a/manifest.uuid b/manifest.uuid index 44129864bc..c10a55b520 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6ef6578c03b7cfbeaaf3627b9eea2febf501ace5 \ No newline at end of file +697b20534c2d780cdd8cc165d2930f6e56480770 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index b93ff5873e..d340c05bf9 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -7368,42 +7368,40 @@ int sqlite3_strnicmp(const char *, const char *, int); /* ** CAPI3REF: String Globbing * -** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches -** the glob pattern P, and it returns non-zero if string X does not match -** the glob pattern P. ^The definition of glob pattern matching used in +** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if +** string X matches the [GLOB] pattern P. +** ^The definition of [GLOB] pattern matching used in ** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the -** SQL dialect used by SQLite. ^The sqlite3_strglob(P,X) function is case -** sensitive. +** SQL dialect understood by SQLite. ^The [sqlite3_strglob(P,X)] function +** is case sensitive. ** ** Note that this routine returns zero on a match and non-zero if the strings ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. ** -** See also: sqlite3_strlike(). +** See also: [sqlite3_strlike()]. */ int sqlite3_strglob(const char *zGlob, const char *zStr); /* ** CAPI3REF: String LIKE Matching * -** ^The [sqlite3_strlike(P,X,E)] interface returns zero if string X matches -** the LIKE pattern P with escape character E, and it returns non-zero if -** string X does not match the like pattern. -** ^The definition of LIKE pattern matching used in +** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if +** string X matches the [LIKE] pattern P with escape character E. +** ^The definition of [LIKE] pattern matching used in ** [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E" -** operator in the SQL dialect used by SQLite. ^For "X LIKE P" without +** operator in the SQL dialect understood by SQLite. ^For "X LIKE P" without ** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0. -** ^As with the LIKE operator, the [sqlite3_str(P,X,E)] function is case +** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case ** insensitive - equivalent upper and lower case ASCII characters match ** one another. ** ** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though -** only ASCII characters are case folded. (This is because when SQLite was -** first written, the case folding rules for Unicode where still in flux.) +** only ASCII characters are case folded. ** ** Note that this routine returns zero on a match and non-zero if the strings ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. ** -** See also: sqlite3_strglob(). +** See also: [sqlite3_strglob()]. */ int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc); diff --git a/src/test_fs.c b/src/test_fs.c index eab5a4a7ad..213b65689a 100644 --- a/src/test_fs.c +++ b/src/test_fs.c @@ -241,7 +241,6 @@ static int fsdirFilter( int argc, sqlite3_value **argv ){ FsdirCsr *pCsr = (FsdirCsr*)pVtabCursor; - int rc; const char *zDir; int nDir; @@ -443,7 +442,7 @@ static int fstreeNext(sqlite3_vtab_cursor *cur){ pCsr->pStmt = 0; }else{ rc = SQLITE_OK; - pCsr->fd = open(sqlite3_column_text(pCsr->pStmt, 0), O_RDONLY); + pCsr->fd = open((const char*)sqlite3_column_text(pCsr->pStmt, 0), O_RDONLY); } return rc; From 970942e4fc734b8a33c1b7c36849c1843f4c9ef5 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 25 Nov 2015 23:13:14 +0000 Subject: [PATCH 019/232] Simplify the temporary filename generator and the time-of-day functions in the unix VFS. FossilOrigin-Name: 6c5621ce1b1a65913b088ed8be65f9b689260d2c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 35 +++++++++-------------------------- 3 files changed, 16 insertions(+), 33 deletions(-) diff --git a/manifest b/manifest index 3eb5cb0f1a..36771d7a16 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\stest_fs.c.\s\sFix\stypos\sand\sclean\sup\sthe\stext\nof\sthe\sdocumentation\sfor\ssqlite3_strglob()\sand\ssqlite3_strlike(). -D 2015-11-25T18:40:38.741 +C Simplify\sthe\stemporary\sfilename\sgenerator\sand\sthe\stime-of-day\sfunctions\sin\nthe\sunix\sVFS. +D 2015-11-25T23:13:14.833 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 066d6f8e4ea9c9b82e93eef2daee3cf25759fa36 +F src/os_unix.c 3f22d7f2577b963261e9ef3b177b10a3083ed518 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6ef6578c03b7cfbeaaf3627b9eea2febf501ace5 -R 6a7e3073277459e34ef3bc33d986fb8e +P 697b20534c2d780cdd8cc165d2930f6e56480770 +R 8a05f9924f5556e21d4d47be27f99435 U drh -Z 86f0abe6c80c8309344887b29ae04a0c +Z fea2e37220480a85fb0635b776213ee8 diff --git a/manifest.uuid b/manifest.uuid index c10a55b520..1b75114db0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -697b20534c2d780cdd8cc165d2930f6e56480770 \ No newline at end of file +6c5621ce1b1a65913b088ed8be65f9b689260d2c \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 48f38fdfa2..3745827f69 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5424,11 +5424,6 @@ static const char *unixTempFileDir(void){ ** pVfs->mxPathname bytes. */ static int unixGetTempname(int nBuf, char *zBuf){ - static const unsigned char zChars[] = - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789"; - unsigned int i, j; const char *zDir; /* It's odd to simulate an io-error here, but really this is just @@ -5439,23 +5434,14 @@ static int unixGetTempname(int nBuf, char *zBuf){ zDir = unixTempFileDir(); if( zDir==0 ) zDir = "."; - - /* Check that the output buffer is large enough for the temporary file - ** name. If it is not, return SQLITE_ERROR. - */ - if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){ - return SQLITE_ERROR; - } - do{ - sqlite3_snprintf(nBuf-18, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX, zDir); - j = (int)strlen(zBuf); - sqlite3_randomness(15, &zBuf[j]); - for(i=0; i<15; i++, j++){ - zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; - } - zBuf[j] = 0; - zBuf[j+1] = 0; + u64 r; + sqlite3_randomness(sizeof(r), &r); + assert( nBuf>2 ); + zBuf[nBuf-2] = 0; + sqlite3_snprintf(nBuf, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX"%llx%c", + zDir, r, 0); + if( zBuf[nBuf-2]!=0 ) return SQLITE_ERROR; }while( osAccess(zBuf,0)==0 ); return SQLITE_OK; } @@ -6200,11 +6186,8 @@ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_nsec/1000000; #else struct timeval sNow; - if( gettimeofday(&sNow, 0)==0 ){ - *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000; - }else{ - rc = SQLITE_ERROR; - } + (void)gettimeofday(&sNow, 0); /* Cannot fail given valid arguments */ + *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000; #endif #ifdef SQLITE_TEST From 5a2d970a1a0e1d2a292ae60552dacbb77c1ca598 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 26 Nov 2015 02:21:05 +0000 Subject: [PATCH 020/232] Small simplification to the xOpen method in the unix VFS. FossilOrigin-Name: 96e7d638ecdabbf84a152036eb01d408d142839e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 36771d7a16..38bdbfc421 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplify\sthe\stemporary\sfilename\sgenerator\sand\sthe\stime-of-day\sfunctions\sin\nthe\sunix\sVFS. -D 2015-11-25T23:13:14.833 +C Small\ssimplification\sto\sthe\sxOpen\smethod\sin\sthe\sunix\sVFS. +D 2015-11-26T02:21:05.964 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 3f22d7f2577b963261e9ef3b177b10a3083ed518 +F src/os_unix.c 9b3a586ea41129a0a09c13fe421b2d9464964330 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 697b20534c2d780cdd8cc165d2930f6e56480770 -R 8a05f9924f5556e21d4d47be27f99435 +P 6c5621ce1b1a65913b088ed8be65f9b689260d2c +R 8d655a3f1e63bc6ba67ee6f8b2910653 U drh -Z fea2e37220480a85fb0635b776213ee8 +Z 1746dd40560755829f1cb168fd739f6f diff --git a/manifest.uuid b/manifest.uuid index 1b75114db0..89850da981 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6c5621ce1b1a65913b088ed8be65f9b689260d2c \ No newline at end of file +96e7d638ecdabbf84a152036eb01d408d142839e \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 3745827f69..d86a4a7457 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5746,7 +5746,8 @@ static int unixOpen( } fd = robust_open(zName, openFlags, openMode); OSTRACE(("OPENX %-3d %s 0%o\n", fd, zName, openFlags)); - if( fd<0 && errno!=EISDIR && isReadWrite && !isExclusive ){ + assert( !isExclusive || (openFlags & O_CREAT)!=0 ); + if( fd<0 && errno!=EISDIR && isReadWrite ){ /* Failed to open the file for read/write access. Try read-only. */ flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE); openFlags &= ~(O_RDWR|O_CREAT); From acb6b28d6065e07b73587c9ca5671f9ebf341678 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 26 Nov 2015 10:37:05 +0000 Subject: [PATCH 021/232] Simplify logic for syncing directories after creating or deleting a file in the unix VFS. FossilOrigin-Name: eb180b4f04d412dcd0af138e2dd7f62fbb5ac439 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 11 +++++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 38bdbfc421..cf9f6bf0a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\ssimplification\sto\sthe\sxOpen\smethod\sin\sthe\sunix\sVFS. -D 2015-11-26T02:21:05.964 +C Simplify\slogic\sfor\ssyncing\sdirectories\safter\screating\sor\sdeleting\sa\sfile\sin\nthe\sunix\sVFS. +D 2015-11-26T10:37:05.218 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 9b3a586ea41129a0a09c13fe421b2d9464964330 +F src/os_unix.c 8b35dc3b8b0a789052855cfc6eab6cd1d206fb81 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6c5621ce1b1a65913b088ed8be65f9b689260d2c -R 8d655a3f1e63bc6ba67ee6f8b2910653 +P 96e7d638ecdabbf84a152036eb01d408d142839e +R d6c3f6ff43a112db1f417e3ad4527c02 U drh -Z 1746dd40560755829f1cb168fd739f6f +Z aa5e5077b0093450034838901b6e8de8 diff --git a/manifest.uuid b/manifest.uuid index 89850da981..ec7fac2084 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -96e7d638ecdabbf84a152036eb01d408d142839e \ No newline at end of file +eb180b4f04d412dcd0af138e2dd7f62fbb5ac439 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index d86a4a7457..43eec4c1f5 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3500,7 +3500,8 @@ static int openDirectory(const char *zFilename, int *pFd){ } } *pFd = fd; - return (fd>=0?SQLITE_OK:unixLogError(SQLITE_CANTOPEN_BKPT, "open", zDirname)); + if( fd>=0 ) return SQLITE_OK; + return unixLogError(SQLITE_CANTOPEN_BKPT, "openDirectory", zDirname); } /* @@ -3553,10 +3554,11 @@ static int unixSync(sqlite3_file *id, int flags){ OSTRACE(("DIRSYNC %s (have_fullfsync=%d fullsync=%d)\n", pFile->zPath, HAVE_FULLFSYNC, isFullsync)); rc = osOpenDirectory(pFile->zPath, &dirfd); - if( rc==SQLITE_OK && dirfd>=0 ){ + if( rc==SQLITE_OK ){ full_fsync(dirfd, 0, 0); robust_close(pFile, dirfd, __LINE__); - }else if( rc==SQLITE_CANTOPEN ){ + }else{ + assert( rc==SQLITE_CANTOPEN ); rc = SQLITE_OK; } pFile->ctrlFlags &= ~UNIXFILE_DIRSYNC; @@ -5903,7 +5905,8 @@ static int unixDelete( rc = unixLogError(SQLITE_IOERR_DIR_FSYNC, "fsync", zPath); } robust_close(0, fd, __LINE__); - }else if( rc==SQLITE_CANTOPEN ){ + }else{ + assert( rc==SQLITE_CANTOPEN ); rc = SQLITE_OK; } } From fab1d401f80e1646341727c50b91377e6f5eb80a Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 26 Nov 2015 15:51:55 +0000 Subject: [PATCH 022/232] Fix a problem with the userauth extension and no-authentication databases. Run the tests for this extension as part of the Debug-One module in releasetest.tcl. FossilOrigin-Name: 8b15621952889b4ba53b2ea3171fef7ef0479ddb --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/build.c | 7 +------ test/releasetest.tcl | 1 + 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index cf9f6bf0a7..ca8c3ee0ee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplify\slogic\sfor\ssyncing\sdirectories\safter\screating\sor\sdeleting\sa\sfile\sin\nthe\sunix\sVFS. -D 2015-11-26T10:37:05.218 +C Fix\sa\sproblem\swith\sthe\suserauth\sextension\sand\sno-authentication\sdatabases.\sRun\sthe\stests\sfor\sthis\sextension\sas\spart\sof\sthe\sDebug-One\smodule\sin\sreleasetest.tcl. +D 2015-11-26T15:51:55.157 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -285,7 +285,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c d3bdd8462a86492e2ebc9aca4a0168429017de25 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 -F src/build.c 19f7585c9747d5043dae64bc82f9cac759f69700 +F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 509ef9c64d1321f42448f111da86400b1799218a @@ -950,7 +950,7 @@ F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl 622f2381b217facdf429584a5c292cc1fc47e7c0 +F test/releasetest.tcl 7e1cda0cf50a41a0eb9f4de0ac8198d4db0423d3 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 96e7d638ecdabbf84a152036eb01d408d142839e -R d6c3f6ff43a112db1f417e3ad4527c02 -U drh -Z aa5e5077b0093450034838901b6e8de8 +P eb180b4f04d412dcd0af138e2dd7f62fbb5ac439 +R f2567fd8ad211c2f6878e625db7a4000 +U dan +Z 033052b1e1d9566ff82c655910d67041 diff --git a/manifest.uuid b/manifest.uuid index ec7fac2084..ffee151b00 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eb180b4f04d412dcd0af138e2dd7f62fbb5ac439 \ No newline at end of file +8b15621952889b4ba53b2ea3171fef7ef0479ddb \ No newline at end of file diff --git a/src/build.c b/src/build.c index 5f2dc28235..765196f821 100644 --- a/src/build.c +++ b/src/build.c @@ -376,12 +376,7 @@ Table *sqlite3LocateTable( } pParse->checkSchema = 1; } -#if SQLITE_USER_AUTHENTICATION - else if( pParse->db->auth.authLevel Date: Thu, 26 Nov 2015 19:33:41 +0000 Subject: [PATCH 023/232] Add the "colUsed" field to the sqlite3_index_info structure passed to virtual table xBestIndex methods. To indicate the subset of the virtual table columns that may be required by the current scan. FossilOrigin-Name: 116b206494eb8ba963c7c5acfbf9e7b6db11c79c --- manifest | 30 ++++++----- manifest.uuid | 2 +- src/sqlite.h.in | 13 +++++ src/test8.c | 38 ++++++++++++-- src/update.c | 8 +-- src/where.c | 1 + test/tkt3871.test | 10 ++-- test/vtab1.test | 86 ++++++++++++++++--------------- test/vtab4.test | 32 ++++++------ test/vtabH.test | 8 +-- test/vtabI.test | 126 ++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 267 insertions(+), 87 deletions(-) create mode 100644 test/vtabI.test diff --git a/manifest b/manifest index ca8c3ee0ee..f8aee8c533 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sthe\suserauth\sextension\sand\sno-authentication\sdatabases.\sRun\sthe\stests\sfor\sthis\sextension\sas\spart\sof\sthe\sDebug-One\smodule\sin\sreleasetest.tcl. -D 2015-11-26T15:51:55.157 +C Add\sthe\s"colUsed"\sfield\sto\sthe\ssqlite3_index_info\sstructure\spassed\sto\svirtual\stable\sxBestIndex\smethods.\sTo\sindicate\sthe\ssubset\sof\sthe\svirtual\stable\scolumns\sthat\smay\sbe\srequired\sby\sthe\scurrent\sscan. +D 2015-11-26T19:33:41.794 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -341,7 +341,7 @@ F src/resolve.c f4c897ca76ca6d5e0b3f0499c627392ffe657c8e F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c e10586c750d87211caa8f4b239e2bfa6a2049e5b F src/shell.c f0f59ea60ad297f671b7ae0fb957a736ad17c92c -F src/sqlite.h.in 1340aa105f53fbc6fd5b9918b54b64c64e910ee7 +F src/sqlite.h.in e7eed45d38f9426b7608b761260574d2c61873f1 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 41ef50b0418a7c5ad1337bb80db5a7928dee764f F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 @@ -356,7 +356,7 @@ F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e F src/test5.c 5a34feec76d9b3a86aab30fd4f6cc9c48cbab4c1 F src/test6.c 41cacf3b0dd180823919bf9e1fbab287c9266723 F src/test7.c 9c89a4f1ed6bb13af0ed805b8d782bd83fcd57e3 -F src/test8.c 85b8c6a0309130300d560e2334ee71e70391785e +F src/test8.c b3a416298dab54537d5aec68697a8b31f5ddf69c F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8 F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12 @@ -398,7 +398,7 @@ F src/threads.c bbfb74450643cb5372a43ad4f6cffd7e9dfcecb0 F src/tokenize.c 5606871a377f390af7040ec3c12e0d183512d785 F src/treeview.c 78842e90c1f71269e7a73a1d4221b6fe360bab66 F src/trigger.c 322f23aad694e8f31d384dcfa386d52a48d3c52f -F src/update.c 40e51cd0883cb5bfd6abb7d8a7cd8aa47fab2945 +F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 @@ -416,7 +416,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 18b0ed49830cf04fe2d68224b41838a73ac6cd24 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba -F src/where.c 6687fb2675d9c1c1936ceca77529e2f21fb3a769 +F src/where.c 9c04982ba9ecfc7751c670ed5a3bddc81d7eb74c F src/whereInt.h 6afc0d70cf6213e58e8fbe10b6e50d1aa16f122f F src/wherecode.c 4c96182e7b25e4be54008dee2da5b9c2f8480b9b F src/whereexpr.c eebba8340c90de73b3d3bbe8c43b84559b8e6e2c @@ -1204,7 +1204,7 @@ F test/tkt3824.test 150aa00bb6220672e5f0eb14dc8eaa36750425f0 F test/tkt3832.test 2300d10d57562b89875b72148338ac3e14f8847d F test/tkt3838.test 292e72489101cd1320d7278dc111c173ebf334d4 F test/tkt3841.test 4659845bc53f809a5932c61c6ce8c5bb9d6b947f -F test/tkt3871.test 43ecbc8d90dc83908e2a454aef345acc9d160c6f +F test/tkt3871.test d921703d07c68f4fd5312073215a17fa34b0401d F test/tkt3879.test 2ad5bef2c87e9991ce941e054c31abe26ef7fb90 F test/tkt3911.test 74cd324f3ba653040cc6d94cc4857b290d12d633 F test/tkt3918.test ea78bf164e4d55cbde0d83c671ef6fbe930a0032 @@ -1259,10 +1259,10 @@ F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test f6c3a39e0c819891265e1d0754e99960d81ef6c9 -F test/vtab1.test ec5cb767277d7e0eff34d3a02824c1dd959a5959 +F test/vtab1.test 7c4b81abd88361ada9cbe414c459efca26be6bda F test/vtab2.test f8cd1bb9aba7143eba97812d9617880a36d247ad F test/vtab3.test b45f47d20f225ccc9c28dc915d92740c2dee311e -F test/vtab4.test 942f8b8280b3ea8a41dae20e7822d065ca1cb275 +F test/vtab4.test 8e73ed268f3d596bc3590f45fc948fb40f28e9c3 F test/vtab5.test 889f444970393c73f1e077e2bdc5d845e157a391 F test/vtab6.test d2986cf418dc51e7fb81d12366bea2caa8b812df F test/vtab7.test ae560ebea870ed04e9aa4177cc302f910faaabb5 @@ -1274,7 +1274,8 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test 2030e7183e41c3cc7521c06aa7bc5a232f7e8986 +F test/vtabH.test 186f118d6a4dd25fdb36adfd471993003f83790c +F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test ea8778d5b0df200adef2ca7c00c3c37d4375f772 @@ -1405,7 +1406,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P eb180b4f04d412dcd0af138e2dd7f62fbb5ac439 -R f2567fd8ad211c2f6878e625db7a4000 +P 8b15621952889b4ba53b2ea3171fef7ef0479ddb +R 5ccf7ece7a7865caf2729b522847c5bb +T *branch * vtab-colused +T *sym-vtab-colused * +T -sym-trunk * U dan -Z 033052b1e1d9566ff82c655910d67041 +Z 5f2bf909c1f2bf69ad08297f10962d86 diff --git a/manifest.uuid b/manifest.uuid index ffee151b00..f1b8240b4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b15621952889b4ba53b2ea3171fef7ef0479ddb \ No newline at end of file +116b206494eb8ba963c7c5acfbf9e7b6db11c79c \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index d340c05bf9..ea23eb27e2 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5615,6 +5615,17 @@ struct sqlite3_module { ** ^Information about the ORDER BY clause is stored in aOrderBy[]. ** ^Each term of aOrderBy records a column of the ORDER BY clause. ** +** The colUsed field indicates which columns of the virtual table may be +** required by the current scan. Virtual table columns are numbered from +** zero in the order in which they appear within the CREATE TABLE statement +** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62), +** the corresponding bit is set within the colUsed mask if the column may be +** required by SQLite. If the table has at least 64 columns and any column +** to the right of the first 63 is required, then bit 63 of colUsed is also +** set. In other words, column iCol may be required if the expression +** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to +** non-zero. +** ** The [xBestIndex] method must fill aConstraintUsage[] with information ** about what parameters to pass to xFilter. ^If argvIndex>0 then ** the right-hand side of the corresponding aConstraint[] is evaluated @@ -5694,6 +5705,8 @@ struct sqlite3_index_info { sqlite3_int64 estimatedRows; /* Estimated number of rows returned */ /* Fields below are only available in SQLite 3.9.0 and later */ int idxFlags; /* Mask of SQLITE_INDEX_SCAN_* flags */ + /* Fields below are only available in SQLite 3.10.0 and later */ + sqlite3_uint64 colUsed; /* Input: Mask of columns used by statement */ }; /* diff --git a/src/test8.c b/src/test8.c index 0c5dc0206e..3e506e36b4 100644 --- a/src/test8.c +++ b/src/test8.c @@ -745,6 +745,34 @@ static void string_concat(char **pzStr, char *zAppend, int doFree, int *pRc){ } } +/* +** This function returns a pointer to an sqlite3_malloc()ed buffer +** containing the select-list (the thing between keywords SELECT and FROM) +** to query the underlying real table with for the scan described by +** argument pIdxInfo. +** +** If the current SQLite version is earlier than 3.10.0, this is just "*" +** (select all columns). Or, for version 3.10.0 and greater, the list of +** columns identified by the pIdxInfo->colUsed mask. +*/ +static char *echoSelectList(echo_vtab *pTab, sqlite3_index_info *pIdxInfo){ + char *zRet = 0; + if( sqlite3_libversion_number()<3010000 ){ + zRet = sqlite3_mprintf(", *"); + }else{ + int i; + for(i=0; inCol; i++){ + if( pIdxInfo->colUsed & ((sqlite3_uint64)1 << (i>=63 ? 63 : i)) ){ + zRet = sqlite3_mprintf("%z, %s", zRet, pTab->aCol[i]); + }else{ + zRet = sqlite3_mprintf("%z, NULL", zRet); + } + if( !zRet ) break; + } + } + return zRet; +} + /* ** The echo module implements the subset of query constraints and sort ** orders that may take advantage of SQLite indices on the underlying @@ -770,6 +798,7 @@ static void string_concat(char **pzStr, char *zAppend, int doFree, int *pRc){ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ int ii; char *zQuery = 0; + char *zCol = 0; char *zNew; int nArg = 0; const char *zSep = "WHERE"; @@ -817,10 +846,11 @@ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ } } - zQuery = sqlite3_mprintf("SELECT rowid, * FROM %Q", pVtab->zTableName); - if( !zQuery ){ - return SQLITE_NOMEM; - } + zCol = echoSelectList(pVtab, pIdxInfo); + if( !zCol ) return SQLITE_NOMEM; + zQuery = sqlite3_mprintf("SELECT rowid%z FROM %Q", zCol, pVtab->zTableName); + if( !zQuery ) return SQLITE_NOMEM; + for(ii=0; iinConstraint; ii++){ const struct sqlite3_index_constraint *pConstraint; struct sqlite3_index_constraint_usage *pUsage; diff --git a/src/update.c b/src/update.c index 1335c269ed..a9735cadca 100644 --- a/src/update.c +++ b/src/update.c @@ -263,10 +263,12 @@ void sqlite3Update( assert( chngPk==0 || chngPk==1 ); chngKey = chngRowid + chngPk; - /* The SET expressions are not actually used inside the WHERE loop. - ** So reset the colUsed mask + /* The SET expressions are not actually used inside the WHERE loop. + ** So reset the colUsed mask. Unless this is a virtual table. In that + ** case, set all bits of the colUsed mask (to ensure that the virtual + ** table implementation makes all columns available). */ - pTabList->a[0].colUsed = 0; + pTabList->a[0].colUsed = IsVirtual(pTab) ? (Bitmask)-1 : 0; hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey); diff --git a/src/where.c b/src/where.c index 737bfc4e6f..30ad58e01b 100644 --- a/src/where.c +++ b/src/where.c @@ -2864,6 +2864,7 @@ static int whereLoopAddVirtual( pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2; pIdxInfo->estimatedRows = 25; pIdxInfo->idxFlags = 0; + pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed; rc = vtabBestIndex(pParse, pTab, pIdxInfo); if( rc ) goto whereLoopAddVtab_exit; pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint; diff --git a/test/tkt3871.test b/test/tkt3871.test index e7dbfde714..d587910d39 100644 --- a/test/tkt3871.test +++ b/test/tkt3871.test @@ -32,8 +32,8 @@ do_test tkt3871-1.3 { execsql { SELECT * FROM e WHERE a = 1 OR a = 2 } set echo_module } [list \ - xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 1 \ - xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 2 \ + xFilter {SELECT rowid, a, b FROM 't1' WHERE a = ?} 1 \ + xFilter {SELECT rowid, a, b FROM 't1' WHERE a = ?} 2 \ ] do_test tkt3871-1.4 { @@ -44,9 +44,9 @@ do_test tkt3871-1.5 { execsql { SELECT * FROM e WHERE a = 1 OR a = 2 OR b = 9 } set echo_module } [list \ - xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 1 \ - xFilter {SELECT rowid, * FROM 't1' WHERE a = ?} 2 \ - xFilter {SELECT rowid, * FROM 't1' WHERE b = ?} 9 + xFilter {SELECT rowid, a, b FROM 't1' WHERE a = ?} 1 \ + xFilter {SELECT rowid, a, b FROM 't1' WHERE a = ?} 2 \ + xFilter {SELECT rowid, a, b FROM 't1' WHERE b = ?} 9 ] diff --git a/test/vtab1.test b/test/vtab1.test index d5fae941af..6b6a0e2683 100644 --- a/test/vtab1.test +++ b/test/vtab1.test @@ -393,7 +393,7 @@ do_test vtab1-3.7 { SELECT rowid, * FROM t1; } } {1 1 2 3 2 4 5 6} -do_test vtab1-3.8 { +do_test vtab1-3.8.1 { execsql { SELECT a AS d, b AS e, c AS f FROM t1; } @@ -404,14 +404,14 @@ do_test vtab1-3.8 { # in test8.c) to make sure the xBestIndex() and xFilter() methods were # called correctly. # -do_test vtab1-3.8 { +do_test vtab1-3.8.2 { set echo_module "" execsql { SELECT * FROM t1; } set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal'} \ - xFilter {SELECT rowid, * FROM 'treal'} ] +} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal'} \ + xFilter {SELECT rowid, a, b, c FROM 'treal'} ] do_test vtab1-3.9 { set echo_module "" execsql { @@ -420,8 +420,8 @@ do_test vtab1-3.9 { } {4 5 6} do_test vtab1-3.10 { set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal' WHERE b = ?} \ - xFilter {SELECT rowid, * FROM 'treal' WHERE b = ?} 5 ] +} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal' WHERE b = ?} \ + xFilter {SELECT rowid, a, b, c FROM 'treal' WHERE b = ?} 5 ] do_test vtab1-3.10 { set echo_module "" execsql { @@ -430,8 +430,9 @@ do_test vtab1-3.10 { } {4 5 6} do_test vtab1-3.11 { set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal' WHERE b >= ? AND b <= ?} \ - xFilter {SELECT rowid, * FROM 'treal' WHERE b >= ? AND b <= ?} 5 10 ] +} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal' WHERE b >= ? AND b <= ?}\ + xFilter {SELECT rowid, a, b, c FROM 'treal' WHERE b >= ? AND b <= ?}\ + 5 10 ] do_test vtab1-3.12 { set echo_module "" execsql { @@ -440,8 +441,9 @@ do_test vtab1-3.12 { } {1 2 3 4 5 6} do_test vtab1-3.13 { set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal' WHERE b >= ? AND b <= ?} \ - xFilter {SELECT rowid, * FROM 'treal' WHERE b >= ? AND b <= ?} 2 10 ] +} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal' WHERE b >= ? AND b <= ?}\ + xFilter {SELECT rowid, a, b, c FROM 'treal' WHERE b >= ? AND b <= ?}\ + 2 10 ] # Add a function for the MATCH operator. Everything always matches! #proc test_match {lhs rhs} { @@ -459,8 +461,8 @@ do_test vtab1-3.12 { } {1 {unable to use function MATCH in the requested context}} do_test vtab1-3.13 { set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal'} \ - xFilter {SELECT rowid, * FROM 'treal'}] +} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal'} \ + xFilter {SELECT rowid, a, b, c FROM 'treal'}] ifcapable subquery { # The echo module uses a subquery internally to implement the MATCH operator. do_test vtab1-3.14 { @@ -472,9 +474,9 @@ do_test vtab1-3.14 { do_test vtab1-3.15 { set echo_module } [list xBestIndex \ - {SELECT rowid, * FROM 'treal' WHERE b LIKE (SELECT '%'||?||'%')} \ + {SELECT rowid, a, b, c FROM 'treal' WHERE b LIKE (SELECT '%'||?||'%')} \ xFilter \ - {SELECT rowid, * FROM 'treal' WHERE b LIKE (SELECT '%'||?||'%')} \ + {SELECT rowid, a, b, c FROM 'treal' WHERE b LIKE (SELECT '%'||?||'%')} \ string ] }; #ifcapable subquery @@ -505,8 +507,8 @@ do_test vtab1-4.1 { } {2 5 nosort} do_test vtab1-4.2 { set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal' ORDER BY b ASC} \ - xFilter {SELECT rowid, * FROM 'treal' ORDER BY b ASC} ] +} [list xBestIndex {SELECT rowid, NULL, b, NULL FROM 'treal' ORDER BY b ASC} \ + xFilter {SELECT rowid, NULL, b, NULL FROM 'treal' ORDER BY b ASC} ] do_test vtab1-4.3 { set echo_module "" cksort { @@ -515,8 +517,8 @@ do_test vtab1-4.3 { } {5 2 nosort} do_test vtab1-4.4 { set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal' ORDER BY b DESC} \ - xFilter {SELECT rowid, * FROM 'treal' ORDER BY b DESC} ] +} [list xBestIndex {SELECT rowid, NULL, b, NULL FROM 'treal' ORDER BY b DESC} \ + xFilter {SELECT rowid, NULL, b, NULL FROM 'treal' ORDER BY b DESC} ] do_test vtab1-4.3 { set echo_module "" cksort { @@ -525,8 +527,8 @@ do_test vtab1-4.3 { } {2 5 sort} do_test vtab1-4.4 { set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal'} \ - xFilter {SELECT rowid, * FROM 'treal'} ] +} [list xBestIndex {SELECT rowid, NULL, b, NULL FROM 'treal'} \ + xFilter {SELECT rowid, NULL, b, NULL FROM 'treal'} ] execsql { DROP TABLE t1; @@ -575,9 +577,9 @@ do_test vtab1-5-2 { do_test vtab1-5-3 { filter $echo_module } [list \ - xFilter {SELECT rowid, * FROM 't1'} \ - xFilter {SELECT rowid, * FROM 't2'} \ - xFilter {SELECT rowid, * FROM 't2'} \ + xFilter {SELECT rowid, a, b, c FROM 't1'} \ + xFilter {SELECT rowid, d, e, f FROM 't2'} \ + xFilter {SELECT rowid, d, e, f FROM 't2'} \ ] do_test vtab1-5-4 { set echo_module "" @@ -591,9 +593,9 @@ do_test vtab1-5-4 { do_test vtab1-5-5 { filter $echo_module } [list \ - xFilter {SELECT rowid, * FROM 't1'} \ - xFilter {SELECT rowid, * FROM 't2'} \ - xFilter {SELECT rowid, * FROM 't2'} \ + xFilter {SELECT rowid, a, b, c FROM 't1'} \ + xFilter {SELECT rowid, d, e, f FROM 't2'} \ + xFilter {SELECT rowid, d, e, f FROM 't2'} \ ] do_test vtab1-5-6 { execsql { @@ -615,9 +617,9 @@ do_test vtab1-5-6 { do_test vtab1-5-7 { filter $::echo_module } [list \ - xFilter {SELECT rowid, * FROM 't1'} \ - xFilter {SELECT rowid, * FROM 't2' WHERE d = ?} \ - xFilter {SELECT rowid, * FROM 't2' WHERE d = ?} \ + xFilter {SELECT rowid, a, b, c FROM 't1'} \ + xFilter {SELECT rowid, d, e, f FROM 't2' WHERE d = ?} \ + xFilter {SELECT rowid, d, e, f FROM 't2' WHERE d = ?} \ ] execsql { @@ -967,8 +969,8 @@ do_test vtab1.10-5 { } set echo_module } [list \ - xBestIndex {SELECT rowid, * FROM 'r'} \ - xFilter {SELECT rowid, * FROM 'r'} \ + xBestIndex {SELECT rowid, a, b, c FROM 'r'} \ + xFilter {SELECT rowid, a, b, c FROM 'r'} \ ] proc match_func {args} {return ""} do_test vtab1.10-6 { @@ -979,8 +981,8 @@ do_test vtab1.10-6 { } set echo_module } [list \ - xBestIndex {SELECT rowid, * FROM 'r'} \ - xFilter {SELECT rowid, * FROM 'r'} \ + xBestIndex {SELECT rowid, a, b, c FROM 'r'} \ + xFilter {SELECT rowid, a, b, c FROM 'r'} \ ] @@ -1153,13 +1155,15 @@ do_test vtab1-14.2 { set echo_module "" execsql { SELECT * FROM echo_c WHERE rowid = 1 } set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'c' WHERE rowid = ?} xFilter {SELECT rowid, * FROM 'c' WHERE rowid = ?} 1] +} [list xBestIndex {SELECT rowid, a, b, c FROM 'c' WHERE rowid = ?} \ + xFilter {SELECT rowid, a, b, c FROM 'c' WHERE rowid = ?} 1] do_test vtab1-14.3 { set echo_module "" execsql { SELECT * FROM echo_c WHERE a = 1 } set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'c' WHERE a = ?} xFilter {SELECT rowid, * FROM 'c' WHERE a = ?} 1] +} [list xBestIndex {SELECT rowid, a, b, c FROM 'c' WHERE a = ?} \ + xFilter {SELECT rowid, a, b, c FROM 'c' WHERE a = ?} 1] #do_test vtab1-14.4 { # set echo_module "" @@ -1300,16 +1304,16 @@ do_execsql_test 18.1.0 { foreach {tn sql res filter} { 1.1 "SELECT a FROM e6 WHERE b>'James'" {4 1 5} - {xFilter {SELECT rowid, * FROM 't6' WHERE b > ?} James} + {xFilter {SELECT rowid, a, b FROM 't6' WHERE b > ?} James} 1.2 "SELECT a FROM e6 WHERE b>='J' AND b<'K'" {3 4} - {xFilter {SELECT rowid, * FROM 't6' WHERE b >= ? AND b < ?} J K} + {xFilter {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ?} J K} 1.3 "SELECT a FROM e6 WHERE b LIKE 'J%'" {3 4} - {xFilter {SELECT rowid, * FROM 't6' WHERE b like ?} J%} + {xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} J%} 1.4 "SELECT a FROM e6 WHERE b LIKE 'j%'" {3 4} - {xFilter {SELECT rowid, * FROM 't6' WHERE b like ?} j%} + {xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} j%} } { set echo_module {} do_execsql_test 18.$tn.1 $sql $res @@ -1319,10 +1323,10 @@ foreach {tn sql res filter} { do_execsql_test 18.2.0 { PRAGMA case_sensitive_like = ON } foreach {tn sql res filter} { 2.1 "SELECT a FROM e6 WHERE b LIKE 'J%'" {3 4} - {xFilter {SELECT rowid, * FROM 't6' WHERE b like ?} J%} + {xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} J%} 2.2 "SELECT a FROM e6 WHERE b LIKE 'j%'" {} - {xFilter {SELECT rowid, * FROM 't6' WHERE b like ?} j%} + {xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} j%} } { set echo_module {} do_execsql_test 18.$tn.1 $sql $res diff --git a/test/vtab4.test b/test/vtab4.test index 07b6e839d7..d12ca33cc0 100644 --- a/test/vtab4.test +++ b/test/vtab4.test @@ -57,9 +57,9 @@ do_test vtab4-1.3 { UPDATE techo SET a = 2; } set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal'} \ +} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal'} \ xBegin echo(treal) \ - xFilter {SELECT rowid, * FROM 'treal'} \ + xFilter {SELECT rowid, a, b, c FROM 'treal'} \ xSync echo(treal) \ xCommit echo(treal) \ ] @@ -69,9 +69,9 @@ do_test vtab4-1.4 { DELETE FROM techo; } set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal'} \ +} [list xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'treal'} \ xBegin echo(treal) \ - xFilter {SELECT rowid, * FROM 'treal'} \ + xFilter {SELECT rowid, NULL, NULL, NULL FROM 'treal'} \ xSync echo(treal) \ xCommit echo(treal) \ ] @@ -105,12 +105,12 @@ do_test vtab4-2.2 { COMMIT; } set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'treal'} \ +} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal'} \ xBegin echo(sreal) \ - xFilter {SELECT rowid, * FROM 'treal'} \ - xBestIndex {SELECT rowid, * FROM 'treal'} \ + xFilter {SELECT rowid, a, b, c FROM 'treal'} \ + xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'treal'} \ xBegin echo(treal) \ - xFilter {SELECT rowid, * FROM 'treal'} \ + xFilter {SELECT rowid, NULL, NULL, NULL FROM 'treal'} \ xSync echo(sreal) \ xSync echo(treal) \ xCommit echo(sreal) \ @@ -137,12 +137,12 @@ do_test vtab4-2.5 { ROLLBACK; } set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'sreal'} \ +} [list xBestIndex {SELECT rowid, a, b, c FROM 'sreal'} \ xBegin echo(treal) \ - xFilter {SELECT rowid, * FROM 'sreal'} \ - xBestIndex {SELECT rowid, * FROM 'sreal'} \ + xFilter {SELECT rowid, a, b, c FROM 'sreal'} \ + xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'sreal'} \ xBegin echo(sreal) \ - xFilter {SELECT rowid, * FROM 'sreal'} \ + xFilter {SELECT rowid, NULL, NULL, NULL FROM 'sreal'} \ xRollback echo(treal) \ xRollback echo(sreal) \ ] @@ -178,12 +178,12 @@ do_test vtab4-3.3 { COMMIT; } set echo_module -} [list xBestIndex {SELECT rowid, * FROM 'sreal'} \ +} [list xBestIndex {SELECT rowid, a, b, c FROM 'sreal'} \ xBegin echo(treal) \ - xFilter {SELECT rowid, * FROM 'sreal'} \ - xBestIndex {SELECT rowid, * FROM 'sreal'} \ + xFilter {SELECT rowid, a, b, c FROM 'sreal'} \ + xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'sreal'} \ xBegin echo(sreal) \ - xFilter {SELECT rowid, * FROM 'sreal'} \ + xFilter {SELECT rowid, NULL, NULL, NULL FROM 'sreal'} \ xSync echo(treal) \ xSync echo(sreal) \ xRollback echo(treal) \ diff --git a/test/vtabH.test b/test/vtabH.test index dab5343da5..7216677d2a 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -32,13 +32,13 @@ do_execsql_test 1.0 { foreach {tn sql expect} { 1 "SELECT * FROM e6 WHERE b LIKE 'abc'" { - xBestIndex {SELECT rowid, * FROM 't6' WHERE b like ?} - xFilter {SELECT rowid, * FROM 't6' WHERE b like ?} abc + xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b like ?} + xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} abc } 2 "SELECT * FROM e6 WHERE b GLOB 'abc'" { - xBestIndex {SELECT rowid, * FROM 't6' WHERE b glob ?} - xFilter {SELECT rowid, * FROM 't6' WHERE b glob ?} abc + xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b glob ?} + xFilter {SELECT rowid, a, b FROM 't6' WHERE b glob ?} abc } } { do_test 1.$tn { diff --git a/test/vtabI.test b/test/vtabI.test new file mode 100644 index 0000000000..4b5a0a8c32 --- /dev/null +++ b/test/vtabI.test @@ -0,0 +1,126 @@ +# 2015 Nov 26 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. Specifically, +# it tests the sqlite3_index_info.colUsed variable is set correctly. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix vtabI + +ifcapable !vtab { + finish_test + return +} + +register_echo_module db + +do_execsql_test 1.0 { + CREATE TABLE t1(a, b, c, d, e); + CREATE VIRTUAL TABLE e1 USING echo(t1); +} + +foreach {tn query filter} { + 1 {SELECT * FROM e1} + {SELECT rowid, a, b, c, d, e FROM 't1'} + + 2 {SELECT a, b FROM e1} + {SELECT rowid, a, b, NULL, NULL, NULL FROM 't1'} + + 3 {SELECT count(*) FROM e1 GROUP BY b} + {SELECT rowid, NULL, b, NULL, NULL, NULL FROM 't1'} + + 4 {SELECT count(*) FROM e1 GROUP BY b HAVING a=?} + {SELECT rowid, a, b, NULL, NULL, NULL FROM 't1'} + + 5 {SELECT a FROM e1 WHERE c=?} + {SELECT rowid, a, NULL, c, NULL, NULL FROM 't1'} + + 6 {SELECT a FROM e1 ORDER BY e} + {SELECT rowid, a, NULL, NULL, NULL, e FROM 't1'} + + 7 {SELECT a FROM e1 ORDER BY e, d} + {SELECT rowid, a, NULL, NULL, d, e FROM 't1'} +} { + do_test 1.$tn { + set ::echo_module [list] + execsql $query + set idx [lsearch -exact $::echo_module xFilter] + lindex $::echo_module [expr $idx+1] + } $filter +} + +#------------------------------------------------------------------------- +# Tests with a table with more than 64 columns. +# +proc all_col_list {} { + set L [list] + for {set i 1} {$i <= 100} {incr i} { lappend L "c$i" } + set L +} + +proc part_col_list {cols} { + set L [list] + for {set i 1} {$i <= 100} {incr i} { + set c "c$i" + if {[lsearch $cols $c]>=0} { + lappend L "c$i" + } else { + lappend L NULL + } + } + set L +} +proc CL {args} { + join [part_col_list $args] ", " +} +proc CLT {args} { + set cols $args + for {set i 64} {$i <= 100} {incr i} { + lappend cols "c$i" + } + join [part_col_list $cols] ", " +} + +do_test 2.0 { + execsql "CREATE TABLE t2([join [all_col_list] ,])" + execsql "CREATE VIRTUAL TABLE e2 USING echo(t2)" +} {} + +foreach {tn query filter} { + 1 {SELECT c1, c10, c20 FROM e2} + {SELECT rowid, [CL c1 c10 c20] FROM 't2'} + + 2 {SELECT c40, c50, c60 FROM e2} + {SELECT rowid, [CL c40 c50 c60] FROM 't2'} + + 3 {SELECT c7, c80, c90 FROM e2} + {SELECT rowid, [CLT c7] FROM 't2'} + + 4 {SELECT c64 FROM e2} + {SELECT rowid, [CLT c64] FROM 't2'} + + 5 {SELECT c63 FROM e2} + {SELECT rowid, [CL c63] FROM 't2'} + + 6 {SELECT c22 FROM e2 ORDER BY c50, c70} + {SELECT rowid, [CLT c22 c50] FROM 't2'} + +} { + do_test 2.$tn { + set ::echo_module [list] + execsql $query + set idx [lsearch -exact $::echo_module xFilter] + lindex $::echo_module [expr $idx+1] + } [subst $filter] +} + +finish_test From a6082f699e1ce60b67781b3133c83bdd34ebcc5e Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 26 Nov 2015 22:12:41 +0000 Subject: [PATCH 024/232] The first argument to SQLITE_CONFIG_PAGECACHE, SQLITE_CONFIG_SCRATCH, and SQLITE_CONFIG_HEAP must always be a pointer. FossilOrigin-Name: 5e14cadff09d7425c8e1cc5e817f2b0609e52a46 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pcache1.c | 2 +- src/test_malloc.c | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index ca8c3ee0ee..7225dffcc9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sthe\suserauth\sextension\sand\sno-authentication\sdatabases.\sRun\sthe\stests\sfor\sthis\sextension\sas\spart\sof\sthe\sDebug-One\smodule\sin\sreleasetest.tcl. -D 2015-11-26T15:51:55.157 +C The\sfirst\sargument\sto\sSQLITE_CONFIG_PAGECACHE,\sSQLITE_CONFIG_SCRATCH,\sand\nSQLITE_CONFIG_HEAP\smust\salways\sbe\sa\spointer. +D 2015-11-26T22:12:41.852 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -331,7 +331,7 @@ F src/pager.h 87c4118a71ba3965184148b379a6d93179071091 F src/parse.y 23737e649c26ce327603799e57f5c2ff50e5e6ba F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 F src/pcache.h 1ff11adce609ba7de139b6abfabaf9a2bac947b5 -F src/pcache1.c 902e1bc7bdaa81b40f8543407c5e2ac8ef4dc035 +F src/pcache1.c 46a110be31a8d9f9b41431733836822ca0dd27ab F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 3d94aebbebd2089899fecc01909bf2608b39507d F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 @@ -374,7 +374,7 @@ F src/test_intarray.c 870124b95ec4c645d4eb84f15efb7133528fb1a5 F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4 -F src/test_malloc.c 27d9e11b6e9d30267465d41ad81edbe24256408b +F src/test_malloc.c 8e1c2112fa4f543b46c990a8872f9e6d37938744 F src/test_multiplex.c 9fefd23f6cc3fa9bf0748a5e453167e7b9f193ce F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P eb180b4f04d412dcd0af138e2dd7f62fbb5ac439 -R f2567fd8ad211c2f6878e625db7a4000 -U dan -Z 033052b1e1d9566ff82c655910d67041 +P 8b15621952889b4ba53b2ea3171fef7ef0479ddb +R a3e84259ce6e6a067ea3262d31b1f32d +U drh +Z 19eaefd26a6af3441c1f68a49d2dd3d1 diff --git a/manifest.uuid b/manifest.uuid index ffee151b00..7899946004 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b15621952889b4ba53b2ea3171fef7ef0479ddb \ No newline at end of file +5e14cadff09d7425c8e1cc5e817f2b0609e52a46 \ No newline at end of file diff --git a/src/pcache1.c b/src/pcache1.c index 256e53a579..3f56d025e2 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -65,7 +65,7 @@ ** that is allocated when the page cache is created. The size of the local ** bulk allocation can be adjusted using ** -** sqlite3_config(SQLITE_CONFIG_PAGECACHE, 0, 0, N). +** sqlite3_config(SQLITE_CONFIG_PAGECACHE, (void*)0, 0, N). ** ** If N is positive, then N pages worth of memory are allocated using a single ** sqlite3Malloc() call and that memory is used for the first N pages allocated. diff --git a/src/test_malloc.c b/src/test_malloc.c index 3ab177dcb7..a3ff9d205b 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -910,7 +910,7 @@ static int test_config_scratch( free(buf); if( sz<0 ){ buf = 0; - rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, 0, 0, 0); + rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, (void*)0, 0, 0); }else{ buf = malloc( sz*N + 1 ); rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, buf, sz, N); @@ -957,7 +957,7 @@ static int test_config_pagecache( Tcl_SetObjResult(interp, pRes); if( sz<0 ){ - sqlite3_config(SQLITE_CONFIG_PAGECACHE, 0, 0, 0); + sqlite3_config(SQLITE_CONFIG_PAGECACHE, (void*)0, 0, 0); }else{ buf = malloc( sz*N ); sqlite3_config(SQLITE_CONFIG_PAGECACHE, buf, sz, N); From ecf0c275bb0533cf30db987983446604eeda51af Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 28 Nov 2015 17:38:22 +0000 Subject: [PATCH 025/232] Disable testing with SQLITE_USER_AUTHENTICATION as the makefiles are not set up to do that. FossilOrigin-Name: 14bbcdc64ecc21f47aed8935858788928ca63107 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/releasetest.tcl | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7225dffcc9..918524a62f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sfirst\sargument\sto\sSQLITE_CONFIG_PAGECACHE,\sSQLITE_CONFIG_SCRATCH,\sand\nSQLITE_CONFIG_HEAP\smust\salways\sbe\sa\spointer. -D 2015-11-26T22:12:41.852 +C Disable\stesting\swith\sSQLITE_USER_AUTHENTICATION\sas\sthe\smakefiles\sare\snot\sset\nup\sto\sdo\sthat. +D 2015-11-28T17:38:22.785 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -950,7 +950,7 @@ F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl 7e1cda0cf50a41a0eb9f4de0ac8198d4db0423d3 +F test/releasetest.tcl 622f2381b217facdf429584a5c292cc1fc47e7c0 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8b15621952889b4ba53b2ea3171fef7ef0479ddb -R a3e84259ce6e6a067ea3262d31b1f32d +P 5e14cadff09d7425c8e1cc5e817f2b0609e52a46 +R 7798aa5b56dd0b98eb234cc9b845071b U drh -Z 19eaefd26a6af3441c1f68a49d2dd3d1 +Z b2af84eb02809218e4429ecabdfe0703 diff --git a/manifest.uuid b/manifest.uuid index 7899946004..4af52e1a7c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5e14cadff09d7425c8e1cc5e817f2b0609e52a46 \ No newline at end of file +14bbcdc64ecc21f47aed8935858788928ca63107 \ No newline at end of file diff --git a/test/releasetest.tcl b/test/releasetest.tcl index a6ddae530c..7f53fd1523 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -121,7 +121,6 @@ array set ::Configs [strip_comments { -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_HIDDEN_COLUMNS -DSQLITE_MAX_ATTACHED=125 - -DSQLITE_USER_AUTHENTICATION=1 } "Fast-One" { -O6 From 790f287c532a1803b71eb960b871cf84e875fe60 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 28 Nov 2015 18:06:36 +0000 Subject: [PATCH 026/232] Add the SQLITE_FCNTL_VFS_POINTER file control which obtains a pointer to the top-level VFS in use by a database connection. FossilOrigin-Name: 7c6a809e25138950f50554e1fb96e0b6ebbe0bd4 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/main.c | 3 +++ src/pager.c | 2 +- src/pager.h | 2 +- src/shell.c | 15 +++++++++++++++ src/sqlite.h.in | 10 ++++++++++ 7 files changed, 41 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 918524a62f..6f5906d400 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\stesting\swith\sSQLITE_USER_AUTHENTICATION\sas\sthe\smakefiles\sare\snot\sset\nup\sto\sdo\sthat. -D 2015-11-28T17:38:22.785 +C Add\sthe\sSQLITE_FCNTL_VFS_POINTER\sfile\scontrol\swhich\sobtains\sa\spointer\sto\nthe\stop-level\sVFS\sin\suse\sby\sa\sdatabase\sconnection. +D 2015-11-28T18:06:36.652 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -304,7 +304,7 @@ F src/insert.c e1d20ae8979e25519c2670233718676bedcfedc9 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 18586e45a215325f15096821e9c082035d4fb810 -F src/main.c 91feb5c7e393ad8f0c434754114a3493c3b0617a +F src/main.c 3f2828fce1e45c3ad096c69eee1e96962c7281c5 F src/malloc.c 337bbe9c7d436ef9b7d06b5dd10bbfc8f3025972 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -326,8 +326,8 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 8b35dc3b8b0a789052855cfc6eab6cd1d206fb81 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e -F src/pager.h 87c4118a71ba3965184148b379a6d93179071091 +F src/pager.c f92aacd5216d8815136c9e0190041783c602641a +F src/pager.h 9153c71a89dc82a5a77e485f3929792116c70aae F src/parse.y 23737e649c26ce327603799e57f5c2ff50e5e6ba F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 F src/pcache.h 1ff11adce609ba7de139b6abfabaf9a2bac947b5 @@ -340,8 +340,8 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c f4c897ca76ca6d5e0b3f0499c627392ffe657c8e F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c e10586c750d87211caa8f4b239e2bfa6a2049e5b -F src/shell.c f0f59ea60ad297f671b7ae0fb957a736ad17c92c -F src/sqlite.h.in 1340aa105f53fbc6fd5b9918b54b64c64e910ee7 +F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21 +F src/sqlite.h.in 4334a48781a59d6cedd99d4033a1febf33e6bd08 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h 41ef50b0418a7c5ad1337bb80db5a7928dee764f F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5e14cadff09d7425c8e1cc5e817f2b0609e52a46 -R 7798aa5b56dd0b98eb234cc9b845071b +P 14bbcdc64ecc21f47aed8935858788928ca63107 +R 52e474e0d673136d0f27ca1064e30322 U drh -Z b2af84eb02809218e4429ecabdfe0703 +Z 722f1d3b58c0811ab92bc5ee1b6e0186 diff --git a/manifest.uuid b/manifest.uuid index 4af52e1a7c..1b5072eef9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -14bbcdc64ecc21f47aed8935858788928ca63107 \ No newline at end of file +7c6a809e25138950f50554e1fb96e0b6ebbe0bd4 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 9078630892..2bcecdb78b 100644 --- a/src/main.c +++ b/src/main.c @@ -3420,6 +3420,9 @@ int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){ if( op==SQLITE_FCNTL_FILE_POINTER ){ *(sqlite3_file**)pArg = fd; rc = SQLITE_OK; + }else if( op==SQLITE_FCNTL_VFS_POINTER ){ + *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager); + rc = SQLITE_OK; }else if( fd->pMethods ){ rc = sqlite3OsFileControl(fd, op, pArg); }else{ diff --git a/src/pager.c b/src/pager.c index f633a77927..bf74eac549 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6679,7 +6679,7 @@ const char *sqlite3PagerFilename(Pager *pPager, int nullIfMemDb){ /* ** Return the VFS structure for the pager. */ -const sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){ +sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){ return pPager->pVfs; } diff --git a/src/pager.h b/src/pager.h index 22e73f4c76..cf9cda625d 100644 --- a/src/pager.h +++ b/src/pager.h @@ -182,7 +182,7 @@ u32 sqlite3PagerDataVersion(Pager*); #endif int sqlite3PagerMemUsed(Pager*); const char *sqlite3PagerFilename(Pager*, int); -const sqlite3_vfs *sqlite3PagerVfs(Pager*); +sqlite3_vfs *sqlite3PagerVfs(Pager*); sqlite3_file *sqlite3PagerFile(Pager*); const char *sqlite3PagerJournalname(Pager*); int sqlite3PagerNosync(Pager*); diff --git a/src/shell.c b/src/shell.c index d2f9ca500a..bcad59e806 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1847,6 +1847,7 @@ static char zHelp[] = ".timeout MS Try opening locked tables for MS milliseconds\n" ".timer on|off Turn SQL timer on or off\n" ".trace FILE|off Output each SQL statement as it is run\n" + ".vfsinfo ?AUX? Information about the top-level VFS\n" ".vfsname ?AUX? Print the name of the VFS stack\n" ".width NUM1 NUM2 ... Set column widths for \"column\" mode\n" " Negative values right-justify\n" @@ -4067,6 +4068,20 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_libversion(), sqlite3_sourceid()); }else + if( c=='v' && strncmp(azArg[0], "vfsinfo", n)==0 ){ + const char *zDbName = nArg==2 ? azArg[1] : "main"; + sqlite3_vfs *pVfs; + if( p->db ){ + sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFS_POINTER, &pVfs); + if( pVfs ){ + fprintf(p->out, "vfs.zName = \"%s\"\n", pVfs->zName); + fprintf(p->out, "vfs.iVersion = %d\n", pVfs->iVersion); + fprintf(p->out, "vfs.szOsFile = %d\n", pVfs->szOsFile); + fprintf(p->out, "vfs.mxPathname = %d\n", pVfs->mxPathname); + } + } + }else + if( c=='v' && strncmp(azArg[0], "vfsname", n)==0 ){ const char *zDbName = nArg==2 ? azArg[1] : "main"; char *zVfsName = 0; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index d340c05bf9..54ce42dee9 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -882,6 +882,15 @@ struct sqlite3_io_methods { ** pointer in case this file-control is not implemented. This file-control ** is intended for diagnostic use only. ** +**
  • [[SQLITE_FCNTL_VFS_POINTER]] +** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level +** [VFSes] currently in use. ^(The argument X in +** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be +** of type "[sqlite3_vfs] **". This opcodes will set *X +** to a pointer to the top-level VFS.^) +** ^When there are multiple VFS shims in the stack, this opcode finds the +** upper-most shim only. +** **
  • [[SQLITE_FCNTL_PRAGMA]] ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] ** file control is sent to the open [sqlite3_file] object corresponding @@ -1000,6 +1009,7 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_WAL_BLOCK 24 #define SQLITE_FCNTL_ZIPVFS 25 #define SQLITE_FCNTL_RBU 26 +#define SQLITE_FCNTL_VFS_POINTER 27 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE From b7e50ad55590416474a292e5233e2b2e8d4f46de Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 28 Nov 2015 21:49:53 +0000 Subject: [PATCH 027/232] Improvements to temporary file creation logic in the unix VFS. FossilOrigin-Name: d6e177fd09c83d46adc5b5d36e9a439aa5397450 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 16 +++++++--------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 6f5906d400..0d6185d0cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_FCNTL_VFS_POINTER\sfile\scontrol\swhich\sobtains\sa\spointer\sto\nthe\stop-level\sVFS\sin\suse\sby\sa\sdatabase\sconnection. -D 2015-11-28T18:06:36.652 +C Improvements\sto\stemporary\sfile\screation\slogic\sin\sthe\sunix\sVFS. +D 2015-11-28T21:49:53.832 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 8b35dc3b8b0a789052855cfc6eab6cd1d206fb81 +F src/os_unix.c 951ef130fd491531d03f4ab07ba4ac4df7861364 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 14bbcdc64ecc21f47aed8935858788928ca63107 -R 52e474e0d673136d0f27ca1064e30322 +P 7c6a809e25138950f50554e1fb96e0b6ebbe0bd4 +R ca93330e61d31cc358456a5d19f9fb0f U drh -Z 722f1d3b58c0811ab92bc5ee1b6e0186 +Z a3585e71cbbc630dcd21f2a2025e8592 diff --git a/manifest.uuid b/manifest.uuid index 1b5072eef9..09f90bf155 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c6a809e25138950f50554e1fb96e0b6ebbe0bd4 \ No newline at end of file +d6e177fd09c83d46adc5b5d36e9a439aa5397450 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 43eec4c1f5..82224e18ff 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5395,21 +5395,19 @@ static int fillInUnixFile( */ static const char *unixTempFileDir(void){ static const char *azDirs[] = { - 0, 0, 0, "/var/tmp", "/usr/tmp", "/tmp", - 0 /* List terminator */ + "." }; unsigned int i; struct stat buf; - const char *zDir = 0; + const char *zDir = sqlite3_temp_directory; - azDirs[0] = sqlite3_temp_directory; - if( !azDirs[1] ) azDirs[1] = getenv("SQLITE_TMPDIR"); - if( !azDirs[2] ) azDirs[2] = getenv("TMPDIR"); + if( !azDirs[0] ) azDirs[0] = getenv("SQLITE_TMPDIR"); + if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR"); for(i=0; i10 ) return SQLITE_ERROR; }while( osAccess(zBuf,0)==0 ); return SQLITE_OK; } @@ -5715,7 +5713,7 @@ static int unixOpen( }else if( !zName ){ /* If zName is NULL, the upper layer is requesting a temp file. */ assert(isDelete && !syncDir); - rc = unixGetTempname(MAX_PATHNAME+2, zTmpname); + rc = unixGetTempname(pVfs->mxPathname, zTmpname); if( rc!=SQLITE_OK ){ return rc; } From 06db66f989d10807c66b0bc64d9ecdbe142e6b24 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 29 Nov 2015 21:46:19 +0000 Subject: [PATCH 028/232] Fix the sqldiff utility program so that it works for schemas that have tables with zero-length column names. FossilOrigin-Name: 64263ccb8f9835c615242de6e28db24f953422fa --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/sqldiff.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 0d6185d0cc..9c1ed45896 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\stemporary\sfile\screation\slogic\sin\sthe\sunix\sVFS. -D 2015-11-28T21:49:53.832 +C Fix\sthe\ssqldiff\sutility\sprogram\sso\sthat\sit\sworks\sfor\sschemas\sthat\shave\ntables\swith\szero-length\scolumn\snames. +D 2015-11-29T21:46:19.675 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -1394,7 +1394,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c db1232df457fdd4cbf2a919a497fc44bb18fb933 +F tool/sqldiff.c 653db1a9294e0b34849c4504599c282a18d8b8c6 F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7c6a809e25138950f50554e1fb96e0b6ebbe0bd4 -R ca93330e61d31cc358456a5d19f9fb0f +P d6e177fd09c83d46adc5b5d36e9a439aa5397450 +R 6d96f803f67943fdc4d03a972304e707 U drh -Z a3585e71cbbc630dcd21f2a2025e8592 +Z e1ff9fd256204ded8600114936035e27 diff --git a/manifest.uuid b/manifest.uuid index 09f90bf155..8041987da4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d6e177fd09c83d46adc5b5d36e9a439aa5397450 \ No newline at end of file +64263ccb8f9835c615242de6e28db24f953422fa \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index 0f406d8a03..56ff53ee25 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -155,6 +155,7 @@ static char *safeId(const char *zId){ "WITH", "WITHOUT", }; int lwr, upr, mid, c, i, x; + if( zId[0]==0 ) return sqlite3_mprintf("\"\""); for(i=x=0; (c = zId[i])!=0; i++){ if( !isalpha(c) && c!='_' ){ if( i>0 && isdigit(c) ){ From a8de1e1c90d45521dfdcf198b58ba95f1c12e9fa Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 30 Nov 2015 00:05:39 +0000 Subject: [PATCH 029/232] Simplifications to the locking logic in the unix-dotfile VFS. FossilOrigin-Name: 583813525888c7e106f3e8cb46c1a507006daee6 --- manifest | 12 +++---- manifest.uuid | 2 +- src/os_unix.c | 92 +++++++++++++++++++-------------------------------- 3 files changed, 41 insertions(+), 65 deletions(-) diff --git a/manifest b/manifest index 9c1ed45896..a4e23dcb0f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\ssqldiff\sutility\sprogram\sso\sthat\sit\sworks\sfor\sschemas\sthat\shave\ntables\swith\szero-length\scolumn\snames. -D 2015-11-29T21:46:19.675 +C Simplifications\sto\sthe\slocking\slogic\sin\sthe\sunix-dotfile\sVFS. +D 2015-11-30T00:05:39.456 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 951ef130fd491531d03f4ab07ba4ac4df7861364 +F src/os_unix.c d4ca37d4fa3d65d2d553751f147e61276f5e06bf F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d6e177fd09c83d46adc5b5d36e9a439aa5397450 -R 6d96f803f67943fdc4d03a972304e707 +P 64263ccb8f9835c615242de6e28db24f953422fa +R dc472c39e1975a0a69aca2b2404edc3d U drh -Z e1ff9fd256204ded8600114936035e27 +Z 57f1db7fea7d09de3a215136ff8d3a37 diff --git a/manifest.uuid b/manifest.uuid index 8041987da4..edbe835481 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -64263ccb8f9835c615242de6e28db24f953422fa \ No newline at end of file +583813525888c7e106f3e8cb46c1a507006daee6 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 82224e18ff..eb20041ed5 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1350,6 +1350,7 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){ SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; ); assert( pFile ); + assert( pFile->eFileLock<=SHARED_LOCK ); unixEnterMutex(); /* Because pFile->pInode is shared across threads */ /* Check if a thread in this process holds such a lock */ @@ -1760,9 +1761,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){ if( unixFileLock(pFile, &lock)==(-1) ){ tErrno = errno; rc = SQLITE_IOERR_UNLOCK; - if( IS_LOCK_ERROR(rc) ){ - storeLastErrno(pFile, tErrno); - } + storeLastErrno(pFile, tErrno); goto end_unlock; } lock.l_type = F_RDLCK; @@ -1784,9 +1783,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){ if( unixFileLock(pFile, &lock)==(-1) ){ tErrno = errno; rc = SQLITE_IOERR_UNLOCK; - if( IS_LOCK_ERROR(rc) ){ - storeLastErrno(pFile, tErrno); - } + storeLastErrno(pFile, tErrno); goto end_unlock; } }else @@ -2037,17 +2034,7 @@ static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) { SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; ); assert( pFile ); - - /* Check if a thread in this process holds such a lock */ - if( pFile->eFileLock>SHARED_LOCK ){ - /* Either this connection or some other connection in the same process - ** holds a lock on the file. No need to check further. */ - reserved = 1; - }else{ - /* The lock is held if and only if the lockfile exists */ - const char *zLockFile = (const char*)pFile->lockingContext; - reserved = osAccess(zLockFile, 0)==0; - } + reserved = osAccess((const char*)pFile->lockingContext, 0)==0; OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, rc, reserved)); *pResOut = reserved; return rc; @@ -2109,7 +2096,7 @@ static int dotlockLock(sqlite3_file *id, int eFileLock) { rc = SQLITE_BUSY; } else { rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK); - if( IS_LOCK_ERROR(rc) ){ + if( rc!=SQLITE_BUSY ){ storeLastErrno(pFile, tErrno); } } @@ -2156,14 +2143,12 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) { /* To fully unlock the database, delete the lock file */ assert( eFileLock==NO_LOCK ); rc = osRmdir(zLockFile); - if( rc<0 && errno==ENOTDIR ) rc = osUnlink(zLockFile); if( rc<0 ){ int tErrno = errno; - rc = 0; - if( ENOENT != tErrno ){ + if( tErrno==ENOENT ){ + rc = SQLITE_OK; + }else{ rc = SQLITE_IOERR_UNLOCK; - } - if( IS_LOCK_ERROR(rc) ){ storeLastErrno(pFile, tErrno); } return rc; @@ -2176,14 +2161,11 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) { ** Close a file. Make sure the lock has been released before closing. */ static int dotlockClose(sqlite3_file *id) { - int rc = SQLITE_OK; - if( id ){ - unixFile *pFile = (unixFile*)id; - dotlockUnlock(id, NO_LOCK); - sqlite3_free(pFile->lockingContext); - rc = closeUnixFile(id); - } - return rc; + unixFile *pFile = (unixFile*)id; + assert( id!=0 ); + dotlockUnlock(id, NO_LOCK); + sqlite3_free(pFile->lockingContext); + return closeUnixFile(id); } /****************** End of the dot-file lock implementation ******************* ******************************************************************************/ @@ -2249,10 +2231,8 @@ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){ int tErrno = errno; /* unlock failed with an error */ lrc = SQLITE_IOERR_UNLOCK; - if( IS_LOCK_ERROR(lrc) ){ - storeLastErrno(pFile, tErrno); - rc = lrc; - } + storeLastErrno(pFile, tErrno); + rc = lrc; } } else { int tErrno = errno; @@ -2385,12 +2365,9 @@ static int flockUnlock(sqlite3_file *id, int eFileLock) { ** Close a file. */ static int flockClose(sqlite3_file *id) { - int rc = SQLITE_OK; - if( id ){ - flockUnlock(id, NO_LOCK); - rc = closeUnixFile(id); - } - return rc; + assert( id!=0 ); + flockUnlock(id, NO_LOCK); + return closeUnixFile(id); } #endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */ @@ -3015,23 +2992,22 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) { */ static int afpClose(sqlite3_file *id) { int rc = SQLITE_OK; - if( id ){ - unixFile *pFile = (unixFile*)id; - afpUnlock(id, NO_LOCK); - unixEnterMutex(); - if( pFile->pInode && pFile->pInode->nLock ){ - /* If there are outstanding locks, do not actually close the file just - ** yet because that would clear those locks. Instead, add the file - ** descriptor to pInode->aPending. It will be automatically closed when - ** the last lock is cleared. - */ - setPendingFd(pFile); - } - releaseInodeInfo(pFile); - sqlite3_free(pFile->lockingContext); - rc = closeUnixFile(id); - unixLeaveMutex(); + unixFile *pFile = (unixFile*)id; + assert( id!=0 ); + afpUnlock(id, NO_LOCK); + unixEnterMutex(); + if( pFile->pInode && pFile->pInode->nLock ){ + /* If there are outstanding locks, do not actually close the file just + ** yet because that would clear those locks. Instead, add the file + ** descriptor to pInode->aPending. It will be automatically closed when + ** the last lock is cleared. + */ + setPendingFd(pFile); } + releaseInodeInfo(pFile); + sqlite3_free(pFile->lockingContext); + rc = closeUnixFile(id); + unixLeaveMutex(); return rc; } @@ -7374,7 +7350,7 @@ static int proxyUnlock(sqlite3_file *id, int eFileLock) { ** Close a file that uses proxy locks. */ static int proxyClose(sqlite3_file *id) { - if( id ){ + if( ALWAYS(id) ){ unixFile *pFile = (unixFile*)id; proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; unixFile *lockProxy = pCtx->lockProxy; From f8b0be48d157d30a0f5aed78ab732b3a83223ded Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 30 Nov 2015 19:15:25 +0000 Subject: [PATCH 030/232] Fix the threadtest3 test program so that it works with VFSes that omit the xCurrentTime() method and supply only xCurrentTimeInt64(). FossilOrigin-Name: 3b155855f3d5918f1df7dbd19783215b3da0ca3e --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/threadtest3.c | 36 ++++++++++++++++++------------------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index f39be554da..5201b9519b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"colUsed"\sfield\sto\sthe\ssqlite3_index_info\sstructure\spassed\sto\svirtual\stable\sxBestIndex\smethods.\sTo\sindicate\sthe\ssubset\sof\sthe\svirtual\stable\scolumns\sthat\smay\sbe\srequired\sby\sthe\scurrent\sscan. -D 2015-11-30T12:01:37.135 +C Fix\sthe\sthreadtest3\stest\sprogram\sso\sthat\sit\sworks\swith\sVFSes\sthat\somit\sthe\nxCurrentTime()\smethod\sand\ssupply\sonly\sxCurrentTimeInt64(). +D 2015-11-30T19:15:25.436 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -1072,7 +1072,7 @@ F test/thread2.test f35d2106452b77523b3a2b7d1dcde2e5ee8f9e46 F test/thread_common.tcl 334639cadcb9f912bf82aa73f49efd5282e6cadd F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b F test/threadtest2.c a70a8e94bef23339d34226eb9521015ef99f4df8 -F test/threadtest3.c 9ab4b168681c3a6f70f6c833ba08e0d48dd4af9b +F test/threadtest3.c 0707c28e0954acbef654f91675e14f3573cf9a10 F test/threadtest4.c c1e67136ceb6c7ec8184e56ac61db28f96bd2925 F test/tkt-02a8e81d44.test 6c80d9c7514e2a42d4918bf87bf6bc54f379110c F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 583813525888c7e106f3e8cb46c1a507006daee6 116b206494eb8ba963c7c5acfbf9e7b6db11c79c -R 85fc84cc9bc3e1532ec1e735dc703c3b -U dan -Z eb992ed0e070d727cd79b36741d8ea82 +P 47f10b7e5d8c1d965df891990090623444933cc9 +R 585e8fe5d4364350ebf759c316009b08 +U drh +Z a830d371ea8bc3ea09f7879f209590a2 diff --git a/manifest.uuid b/manifest.uuid index 29b821c451..a098f55953 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -47f10b7e5d8c1d965df891990090623444933cc9 \ No newline at end of file +3b155855f3d5918f1df7dbd19783215b3da0ca3e \ No newline at end of file diff --git a/test/threadtest3.c b/test/threadtest3.c index 25caeb89f9..a3fcae28cc 100644 --- a/test/threadtest3.c +++ b/test/threadtest3.c @@ -868,22 +868,28 @@ static void filecopy_x( ** Used by setstoptime() and timetostop(). */ static double timelimit = 0.0; -static sqlite3_vfs *pTimelimitVfs = 0; + +static double currentTime(void){ + double t; + static sqlite3_vfs *pTimelimitVfs = 0; + if( pTimelimitVfs==0 ) pTimelimitVfs = sqlite3_vfs_find(0); + if( pTimelimitVfs->iVersion>=1 && pTimelimitVfs->xCurrentTimeInt64!=0 ){ + sqlite3_int64 tm; + pTimelimitVfs->xCurrentTimeInt64(pTimelimitVfs, &tm); + t = tm/86400000.0; + }else{ + pTimelimitVfs->xCurrentTime(pTimelimitVfs, &t); + } + return t; +} static void setstoptime_x( Error *pErr, /* IN/OUT: Error code */ int nMs /* Milliseconds until "stop time" */ ){ if( pErr->rc==SQLITE_OK ){ - double t; - int rc; - pTimelimitVfs = sqlite3_vfs_find(0); - rc = pTimelimitVfs->xCurrentTime(pTimelimitVfs, &t); - if( rc!=SQLITE_OK ){ - pErr->rc = rc; - }else{ - timelimit = t + ((double)nMs)/(1000.0*60.0*60.0*24.0); - } + double t = currentTime(); + timelimit = t + ((double)nMs)/(1000.0*60.0*60.0*24.0); } } @@ -892,14 +898,8 @@ static int timetostop_x( ){ int ret = 1; if( pErr->rc==SQLITE_OK ){ - double t; - int rc; - rc = pTimelimitVfs->xCurrentTime(pTimelimitVfs, &t); - if( rc!=SQLITE_OK ){ - pErr->rc = rc; - }else{ - ret = (t >= timelimit); - } + double t = currentTime(); + ret = (t >= timelimit); } return ret; } From 40fe8d31f54a823da92a85f9aa43fde92091fca5 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 30 Nov 2015 20:36:26 +0000 Subject: [PATCH 031/232] The EOVERFLOW errors from fstat() is not possible unless SQLite has been compiled with SQLITE_DISABLE_LFS. FossilOrigin-Name: 8cfb7a50bb70ba1e021c1d12d31563e98a20d291 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5201b9519b..c54175987a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sthreadtest3\stest\sprogram\sso\sthat\sit\sworks\swith\sVFSes\sthat\somit\sthe\nxCurrentTime()\smethod\sand\ssupply\sonly\sxCurrentTimeInt64(). -D 2015-11-30T19:15:25.436 +C The\sEOVERFLOW\serrors\sfrom\sfstat()\sis\snot\spossible\sunless\sSQLite\shas\sbeen\ncompiled\swith\sSQLITE_DISABLE_LFS. +D 2015-11-30T20:36:26.173 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c d4ca37d4fa3d65d2d553751f147e61276f5e06bf +F src/os_unix.c 641b7da6960b5bfa2120a97464578da436f4876c F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 47f10b7e5d8c1d965df891990090623444933cc9 -R 585e8fe5d4364350ebf759c316009b08 +P 3b155855f3d5918f1df7dbd19783215b3da0ca3e +R 8c60b47a7d3bee2b87d7070795b628ee U drh -Z a830d371ea8bc3ea09f7879f209590a2 +Z 055a22d7d501db707cd4b91440df8d3a diff --git a/manifest.uuid b/manifest.uuid index a098f55953..9535da50f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3b155855f3d5918f1df7dbd19783215b3da0ca3e \ No newline at end of file +8cfb7a50bb70ba1e021c1d12d31563e98a20d291 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index eb20041ed5..49f6563b17 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1229,7 +1229,7 @@ static int findInodeInfo( rc = osFstat(fd, &statbuf); if( rc!=0 ){ storeLastErrno(pFile, errno); -#ifdef EOVERFLOW +#if defined(EOVERFLOW) && defined(SQLITE_DISABLE_LFS) if( pFile->lastErrno==EOVERFLOW ) return SQLITE_NOLFS; #endif return SQLITE_IOERR; From 025d2f7ad8d29f25c111b3abb668528b7389570a Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 30 Nov 2015 22:22:23 +0000 Subject: [PATCH 032/232] Fix a problem in xFullPathname for the unix VFS. The problem was found by Kostya Serebryany using libFuzzer. FossilOrigin-Name: bb1e2c4df0b81327923f121dd6c002845486a314 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 4 +++- test/symlink.test | 10 ++++++++++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c54175987a..882023698b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sEOVERFLOW\serrors\sfrom\sfstat()\sis\snot\spossible\sunless\sSQLite\shas\sbeen\ncompiled\swith\sSQLITE_DISABLE_LFS. -D 2015-11-30T20:36:26.173 +C Fix\sa\sproblem\sin\sxFullPathname\sfor\sthe\sunix\sVFS.\s\sThe\sproblem\swas\sfound\sby\nKostya\sSerebryany\susing\slibFuzzer. +D 2015-11-30T22:22:23.455 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 641b7da6960b5bfa2120a97464578da436f4876c +F src/os_unix.c 88d9fd1da4f3d26c64ef954fb32cce583605eba0 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1049,7 +1049,7 @@ F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4 F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a F test/subtype1.test 7fe09496352f97053af1437150751be2d0a0cae8 F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2 -F test/symlink.test 2513f7c030df0f435c6415687ba8b739f3d312df +F test/symlink.test cbf6cb8c6c4b63a39e9f0f6b0d5c99e249dbc102 F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85 F test/syscall.test 2aa9e111b79fb385681ff8940124def6f8faab87 F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3b155855f3d5918f1df7dbd19783215b3da0ca3e -R 8c60b47a7d3bee2b87d7070795b628ee +P 8cfb7a50bb70ba1e021c1d12d31563e98a20d291 +R f79c0be9f023b27dbe04efacb9601efe U drh -Z 055a22d7d501db707cd4b91440df8d3a +Z cf313c6c46c31a94ce13dac473c0da9d diff --git a/manifest.uuid b/manifest.uuid index 9535da50f6..eb072bebe4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8cfb7a50bb70ba1e021c1d12d31563e98a20d291 \ No newline at end of file +bb1e2c4df0b81327923f121dd6c002845486a314 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 49f6563b17..e5103856bd 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5981,7 +5981,9 @@ static int unixFullPathname( ** truncated to make it fit. This is Ok, as SQLite refuses to open any ** file for which this function returns a full path larger than (nOut-8) ** bytes in size. */ - if( zOut[0]!='/' ){ + testcase( nByte==nOut-5 ); + testcase( nByte==nOut-4 ); + if( zOut[0]!='/' && nByte Date: Mon, 30 Nov 2015 22:52:14 +0000 Subject: [PATCH 033/232] Add the SQLITE_PRINTF_PRECISION_LIMIT compile-time option. FossilOrigin-Name: ecad75d69e0d5c83dd3584d363e557e84b65f7f2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/printf.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 882023698b..135ade46f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sxFullPathname\sfor\sthe\sunix\sVFS.\s\sThe\sproblem\swas\sfound\sby\nKostya\sSerebryany\susing\slibFuzzer. -D 2015-11-30T22:22:23.455 +C Add\sthe\sSQLITE_PRINTF_PRECISION_LIMIT\scompile-time\soption. +D 2015-11-30T22:52:14.011 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -335,7 +335,7 @@ F src/pcache1.c 46a110be31a8d9f9b41431733836822ca0dd27ab F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 3d94aebbebd2089899fecc01909bf2608b39507d F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 -F src/printf.c f8fc8f04e75b1e983ef2793c27ec7a43b287e94a +F src/printf.c ca05561795ad6c2fa47acdd007702586282f7feb F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c f4c897ca76ca6d5e0b3f0499c627392ffe657c8e F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8cfb7a50bb70ba1e021c1d12d31563e98a20d291 -R f79c0be9f023b27dbe04efacb9601efe +P bb1e2c4df0b81327923f121dd6c002845486a314 +R d3b18adc3009f6c25adcd36c4f052eab U drh -Z cf313c6c46c31a94ce13dac473c0da9d +Z 7ba0fba490eff520c14229730eb61dd8 diff --git a/manifest.uuid b/manifest.uuid index eb072bebe4..3749928415 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bb1e2c4df0b81327923f121dd6c002845486a314 \ No newline at end of file +ecad75d69e0d5c83dd3584d363e557e84b65f7f2 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 9caeef8ff7..88bb82e3e3 100644 --- a/src/printf.c +++ b/src/printf.c @@ -270,6 +270,12 @@ void sqlite3VXPrintf( testcase( wx>0x7fffffff ); width = wx & 0x7fffffff; } + assert( width>=0 ); +#ifdef SQLITE_PRINTF_PRECISION_LIMIT + if( width>SQLITE_PRINTF_PRECISION_LIMIT ){ + width = SQLITE_PRINTF_PRECISION_LIMIT; + } +#endif /* Get the precision */ if( c=='.' ){ @@ -296,6 +302,14 @@ void sqlite3VXPrintf( }else{ precision = -1; } + assert( precision>=(-1) ); +#ifdef SQLITE_PRINTF_PRECISION_LIMIT + if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){ + precision = SQLITE_PRINTF_PRECISION_LIMIT; + } +#endif + + /* Get the conversion type modifier */ if( c=='l' ){ flag_long = 1; From 92af1ebc75d8077c4885d02436e3630d7e91d473 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 30 Nov 2015 23:29:07 +0000 Subject: [PATCH 034/232] Add experimental support for the 'test_fs' test module on Win32. FossilOrigin-Name: f3ffb3aeea95712e92919fd5071741327add9643 --- Makefile.in | 1 + Makefile.msc | 1 + main.mk | 1 + manifest | 27 +++++--- manifest.uuid | 2 +- src/test_fs.c | 51 +++++++++++--- src/test_windirent.c | 157 +++++++++++++++++++++++++++++++++++++++++++ src/test_windirent.h | 105 +++++++++++++++++++++++++++++ test/vtabH.test | 38 +++++++++-- 9 files changed, 358 insertions(+), 25 deletions(-) create mode 100644 src/test_windirent.c create mode 100644 src/test_windirent.h diff --git a/Makefile.in b/Makefile.in index eaf021b412..f8766ac8f7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -402,6 +402,7 @@ TESTSRC = \ $(TOP)/src/test_tclvar.c \ $(TOP)/src/test_thread.c \ $(TOP)/src/test_vfs.c \ + $(TOP)/src/test_windirent.c \ $(TOP)/src/test_wsd.c \ $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_test.c \ diff --git a/Makefile.msc b/Makefile.msc index 57fba11c53..5c72001532 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1071,6 +1071,7 @@ TESTSRC = \ $(TOP)\src\test_tclvar.c \ $(TOP)\src\test_thread.c \ $(TOP)\src\test_vfs.c \ + $(TOP)\src\test_windirent.c \ $(TOP)\src\test_wsd.c \ $(TOP)\ext\fts3\fts3_term.c \ $(TOP)\ext\fts3\fts3_test.c \ diff --git a/main.mk b/main.mk index 838e0753d9..f3a37dc194 100644 --- a/main.mk +++ b/main.mk @@ -312,6 +312,7 @@ TESTSRC = \ $(TOP)/src/test_tclvar.c \ $(TOP)/src/test_thread.c \ $(TOP)/src/test_vfs.c \ + $(TOP)/src/test_windirent.c \ $(TOP)/src/test_wsd.c # Extensions to be statically loaded. diff --git a/manifest b/manifest index 135ade46f1..885c09aea0 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Add\sthe\sSQLITE_PRINTF_PRECISION_LIMIT\scompile-time\soption. -D 2015-11-30T22:52:14.011 -F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 +C Add\sexperimental\ssupport\sfor\sthe\s'test_fs'\stest\smodule\son\sWin32. +D 2015-11-30T23:29:07.971 +F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc e928e68168df69b353300ac87c10105206653a03 +F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 8b9d3ac6f1962f94e06ba05462422a544f9c4e36 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -263,7 +263,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk ae99be5eb22933b1ecf80f94d41d25a3ea80aaf3 +F main.mk 9001039f432baeba1074e2d1885f3dfd572b8636 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -366,7 +366,7 @@ F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f F src/test_config.c f2824de39f59d8d621e2d6ec5cc67006d000b2eb F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc -F src/test_fs.c 9a56a587ce1db424af430d5ff650b5736b498238 +F src/test_fs.c aab47ac456316502faa265daadf9ac832fea12b9 F src/test_func.c 0d9c25956152adefee8881c6fadc8354793764d0 F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32 @@ -393,6 +393,8 @@ F src/test_tclvar.c d86412527da65468ee6fa1b8607c65d0af736bc4 F src/test_thread.c af391ec03d23486dffbcc250b7e58e073f172af9 F src/test_vfs.c 3b65d42e18b262805716bd96178c81da8f2d9283 F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 +F src/test_windirent.c 8f5fada630348558d5745b334702f301da1ffc61 +F src/test_windirent.h b12055cab6227f7be10f5c19296f67c60cc5e2a5 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c bbfb74450643cb5372a43ad4f6cffd7e9dfcecb0 F src/tokenize.c 5606871a377f390af7040ec3c12e0d183512d785 @@ -1274,7 +1276,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test 186f118d6a4dd25fdb36adfd471993003f83790c +F test/vtabH.test 2803a8773d1017ac93bbec6900fc7c35bb56c1c3 F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 @@ -1406,7 +1408,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P bb1e2c4df0b81327923f121dd6c002845486a314 -R d3b18adc3009f6c25adcd36c4f052eab -U drh -Z 7ba0fba490eff520c14229730eb61dd8 +P ecad75d69e0d5c83dd3584d363e557e84b65f7f2 +R b2c7ca19fb46e255338240c0ac77a2e4 +T *branch * testFsWin32 +T *sym-testFsWin32 * +T -sym-trunk * +U mistachkin +Z b75cf97131a1f035edfb9c37c590fcf6 diff --git a/manifest.uuid b/manifest.uuid index 3749928415..2659aede24 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ecad75d69e0d5c83dd3584d363e557e84b65f7f2 \ No newline at end of file +f3ffb3aeea95712e92919fd5071741327add9643 \ No newline at end of file diff --git a/src/test_fs.c b/src/test_fs.c index 213b65689a..de332fa2f5 100644 --- a/src/test_fs.c +++ b/src/test_fs.c @@ -73,9 +73,16 @@ #if SQLITE_OS_UNIX # include # include +# ifndef DIRENT +# define DIRENT dirent +# endif #endif #if SQLITE_OS_WIN # include +# include "test_windirent.h" +# ifndef S_ISREG +# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) +# endif #endif #ifndef SQLITE_OMIT_VIRTUALTABLE @@ -116,7 +123,7 @@ struct FsdirCsr { char *zDir; /* Buffer containing directory scanned */ DIR *pDir; /* Open directory */ sqlite3_int64 iRowid; - struct dirent entry; /* Current entry */ + struct DIRENT entry; /* Current entry */ }; /* @@ -220,7 +227,7 @@ static int fsdirNext(sqlite3_vtab_cursor *cur){ FsdirCsr *pCsr = (FsdirCsr*)cur; if( pCsr->pDir ){ - struct dirent *pRes = 0; + struct DIRENT *pRes = 0; readdir_r(pCsr->pDir, &pCsr->entry, &pRes); if( pRes==0 ){ closedir(pCsr->pDir); @@ -461,15 +468,34 @@ static int fstreeFilter( int rc; const char *zSql = "WITH r(d) AS (" -" SELECT CASE WHEN dir='/' THEN '' ELSE dir END || '/' || name " -" FROM fsdir WHERE dir=? AND name NOT LIKE '.%'" +" SELECT CASE WHEN dir=?2 THEN ?3 ELSE dir END || '/' || name " +" FROM fsdir WHERE dir=?1 AND name NOT LIKE '.%'" " UNION ALL" " SELECT dir || '/' || name FROM r, fsdir WHERE dir=d AND name NOT LIKE '.%'" ") SELECT d FROM r;"; - const char *zDir = "/"; - int nDir = 1; - char aWild[2] = {'\0', '\0' }; + char *zRoot; + int nRoot; + char *zPrefix; + int nPrefix; + const char *zDir; + int nDir; + char aWild[2] = { '\0', '\0' }; + +#if SQLITE_OS_WIN + zRoot = sqlite3_mprintf("%s%c", getenv("SystemDrive"), '/'); + nRoot = strlen(zRoot); + zPrefix = sqlite3_mprintf("%s", getenv("SystemDrive")); + nPrefix = strlen(zPrefix); +#else + zRoot = "/"; + nRoot = 1; + zPrefix = ""; + nPrefix = 0; +#endif + + zDir = zRoot; + nDir = nRoot; fstreeCloseFd(pCsr); sqlite3_finalize(pCsr->pStmt); @@ -490,9 +516,9 @@ static int fstreeFilter( break; } - if( zQuery[0]=='/' ){ + if( sqlite3_strnicmp(zQuery, zPrefix, nPrefix)==0 ){ int i; - for(i=1; zQuery[i]; i++){ + for(i=nPrefix; zQuery[i]; i++){ if( zQuery[i]==aWild[0] || zQuery[i]==aWild[1] ) break; if( zQuery[i]=='/' ) nDir = i; } @@ -501,6 +527,13 @@ static int fstreeFilter( } sqlite3_bind_text(pCsr->pStmt, 1, zDir, nDir, SQLITE_TRANSIENT); + sqlite3_bind_text(pCsr->pStmt, 2, zRoot, nRoot, SQLITE_TRANSIENT); + sqlite3_bind_text(pCsr->pStmt, 3, zPrefix, nPrefix, SQLITE_TRANSIENT); + +#if SQLITE_OS_WIN + sqlite3_free(zPrefix); + sqlite3_free(zRoot); +#endif return fstreeNext(pVtabCursor); } diff --git a/src/test_windirent.c b/src/test_windirent.c new file mode 100644 index 0000000000..11d7dc07d0 --- /dev/null +++ b/src/test_windirent.c @@ -0,0 +1,157 @@ +/* +** 2015 November 30 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code to implement most of the opendir() family of +** POSIX functions on Win32 using the MSVCRT. +*/ + +#if defined(_WIN32) && defined(_MSC_VER) + +#include "test_windirent.h" + +/* +** Implementation of the POSIX opendir() function using the MSVCRT. +*/ +LPDIR opendir( + const char *dirname +){ + struct _finddata_t data; + LPDIR dirp = (LPDIR)sqlite3_malloc(sizeof(DIR)); + SIZE_T namesize = sizeof(data.name) / sizeof(data.name[0]); + + if( dirp==NULL ) return NULL; + memset(dirp, 0, sizeof(DIR)); + + /* TODO: Remove this if Unix-style root paths are not used. */ + if( sqlite3_stricmp(dirname, "/")==0 ){ + dirname = getenv("SystemDrive"); + } + + _snprintf(data.name, namesize, "%s\\*", dirname); + dirp->d_handle = _findfirst(data.name, &data); + + if( dirp->d_handle==BAD_INTPTR_T ){ + closedir(dirp); + return NULL; + } + + /* TODO: Remove this block to allow hidden and system files. */ + if( data.attrib&_A_HIDDEN || data.attrib&_A_SYSTEM ){ + if( _findnext(dirp->d_handle, &data)==-1 ){ + closedir(dirp); + return NULL; + } + } + + dirp->d_first.d_attributes = data.attrib; + strncpy(dirp->d_first.d_name, data.name, NAME_MAX); + dirp->d_first.d_name[NAME_MAX] = '\0'; + + return dirp; +} + +/* +** Implementation of the POSIX readdir() function using the MSVCRT. +*/ +LPDIRENT readdir( + LPDIR dirp +){ + struct _finddata_t data; + + if( dirp==NULL ) return NULL; + + if( dirp->d_first.d_ino==0 ){ + dirp->d_first.d_ino++; + dirp->d_next.d_ino++; + + return &dirp->d_first; + } + +next: + + if( _findnext(dirp->d_handle, &data)==-1 ) return NULL; + + /* TODO: Remove this block to allow hidden and system files. */ + if( data.attrib&_A_HIDDEN ) goto next; + if( data.attrib&_A_SYSTEM ) goto next; + + dirp->d_next.d_ino++; + dirp->d_next.d_attributes = data.attrib; + strncpy(dirp->d_next.d_name, data.name, NAME_MAX); + dirp->d_next.d_name[NAME_MAX] = '\0'; + + return &dirp->d_next; +} + +/* +** Implementation of the POSIX readdir_r() function using the MSVCRT. +*/ +INT readdir_r( + LPDIR dirp, + LPDIRENT entry, + LPDIRENT *result +){ + struct _finddata_t data; + + if( dirp==NULL ) return EBADF; + + if( dirp->d_first.d_ino==0 ){ + dirp->d_first.d_ino++; + dirp->d_next.d_ino++; + + entry->d_ino = dirp->d_first.d_ino; + entry->d_attributes = dirp->d_first.d_attributes; + strncpy(entry->d_name, dirp->d_first.d_name, NAME_MAX); + entry->d_name[NAME_MAX] = '\0'; + + *result = entry; + return 0; + } + +next: + + if( _findnext(dirp->d_handle, &data)==-1 ){ + *result = NULL; + return ENOENT; + } + + /* TODO: Remove this block to allow hidden and system files. */ + if( data.attrib&_A_HIDDEN ) goto next; + if( data.attrib&_A_SYSTEM ) goto next; + + entry->d_ino = (ino_t)-1; /* not available */ + entry->d_attributes = data.attrib; + strncpy(entry->d_name, data.name, NAME_MAX); + entry->d_name[NAME_MAX] = '\0'; + + *result = entry; + return 0; +} + +/* +** Implementation of the POSIX closedir() function using the MSVCRT. +*/ +INT closedir( + LPDIR dirp +){ + INT result = 0; + + if( dirp==NULL ) return EINVAL; + + if( dirp->d_handle!=NULL_INTPTR_T && dirp->d_handle!=BAD_INTPTR_T ){ + result = _findclose(dirp->d_handle); + } + + sqlite3_free(dirp); + return result; +} + +#endif /* defined(WIN32) && defined(_MSC_VER) */ diff --git a/src/test_windirent.h b/src/test_windirent.h new file mode 100644 index 0000000000..0b8d1a7b51 --- /dev/null +++ b/src/test_windirent.h @@ -0,0 +1,105 @@ +/* +** 2015 November 30 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains declarations for most of the opendir() family of +** POSIX functions on Win32 using the MSVCRT. +*/ + +#if defined(_WIN32) && defined(_MSC_VER) + +/* +** We need several data types from the Windows SDK header. +*/ + +#define WIN32_LEAN_AND_MEAN +#include "windows.h" + +/* +** We need several support functions from the SQLite core. +*/ + +#include "sqlite3.h" + +/* +** We need several things from the ANSI and MSVCRT headers. +*/ + +#include +#include +#include +#include +#include + +/* +** We may need to provide the "ino_t" type. +*/ + +#ifndef INO_T_DEFINED + #define INO_T_DEFINED + typedef unsigned short ino_t; +#endif + +/* +** We need to define "NAME_MAX" if it was not present in "limits.h". +*/ + +#ifndef NAME_MAX +# ifdef FILENAME_MAX +# define NAME_MAX (FILENAME_MAX) +# else +# define NAME_MAX (260) +# endif +#endif + +/* +** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T". +*/ + +#ifndef NULL_INTPTR_T +# define NULL_INTPTR_T ((intptr_t)(0)) +#endif + +#ifndef BAD_INTPTR_T +# define BAD_INTPTR_T ((intptr_t)(-1)) +#endif + +/* +** We need to provide the necessary structures and related types. +*/ + +typedef struct DIRENT DIRENT; +typedef struct DIR DIR; +typedef DIRENT *LPDIRENT; +typedef DIR *LPDIR; + +struct DIRENT { + ino_t d_ino; /* Sequence number, do not use. */ + unsigned d_attributes; /* Win32 file attributes. */ + char d_name[NAME_MAX + 1]; /* Name within the directory. */ +}; + +struct DIR { + intptr_t d_handle; /* Value returned by "_findfirst". */ + DIRENT d_first; /* DIRENT constructed based on "_findfirst". */ + DIRENT d_next; /* DIRENT constructed based on "_findnext". */ +}; + +/* +** Finally, we can provide the function prototypes for the opendir(), +** readdir(), readdir_r(), and closedir() POSIX functions. +*/ + +extern LPDIR opendir(const char *dirname); +extern LPDIRENT readdir(LPDIR dirp); +extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result); +extern INT closedir(LPDIR dirp); + +#endif /* defined(WIN32) && defined(_MSC_VER) */ diff --git a/test/vtabH.test b/test/vtabH.test index 7216677d2a..6034d95fa1 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -108,7 +108,7 @@ foreach ::tclvar_set_omit {0 1} { #------------------------------------------------------------------------- # -if {$::tcl_platform(platform)=="unix"} { +if {1} { reset_db register_fs_module db do_execsql_test 3.0 { @@ -116,11 +116,41 @@ if {$::tcl_platform(platform)=="unix"} { SELECT name FROM fsdir WHERE dir = '.' AND name = '.' } {test.db .} + proc list_root_files {} { + if {$::tcl_platform(platform) eq "windows"} { + set res [list] + foreach name [glob -directory $::env(SystemDrive)/ -- *] { + if {[string index [file tail $name] 0] eq "."} continue + lappend res $name + } + return $res + } else { + return [exec ls -U /] + } + } + + proc list_files { pattern } { + if {$::tcl_platform(platform) eq "windows"} { + set res [list] + foreach name [glob -nocomplain $pattern] { + if {[string index [file tail $name] 0] eq "."} continue + lappend res $name + } + return $res + } else { + return [glob -nocomplain $pattern] + } + } + # Read the first 5 entries from the root directory. # set res [list] - foreach p [lrange [exec ls -U /] 0 4] { - lappend res "/$p" + foreach p [lrange [list_root_files] 0 4] { + if {$::tcl_platform(platform) eq "windows"} { + lappend res $p + } else { + lappend res "/$p" + } } do_execsql_test 3.1 { SELECT path FROM fstree LIMIT 5; @@ -130,7 +160,7 @@ if {$::tcl_platform(platform)=="unix"} { # proc contents {pattern} { set res [list] - foreach f [glob -nocomplain $pattern] { + foreach f [list_files $pattern] { lappend res $f if {[file isdir $f]} { set res [concat $res [contents "$f/*"]] From e1818ec7400a9917fbdbec566a70769b3fc94235 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 1 Dec 2015 16:21:35 +0000 Subject: [PATCH 035/232] Simplification to the read and write primatives in the unix VFS. FossilOrigin-Name: 9eefa449792f03c4c149edcbc6b9b7692617994c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 25 +++++++++++-------------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 135ade46f1..245528dd63 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_PRINTF_PRECISION_LIMIT\scompile-time\soption. -D 2015-11-30T22:52:14.011 +C Simplification\sto\sthe\sread\sand\swrite\sprimatives\sin\sthe\sunix\sVFS. +D 2015-12-01T16:21:35.045 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e928e68168df69b353300ac87c10105206653a03 @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 88d9fd1da4f3d26c64ef954fb32cce583605eba0 +F src/os_unix.c 7d56433ac85e77423d2d613fd5e53db08c5868ed F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P bb1e2c4df0b81327923f121dd6c002845486a314 -R d3b18adc3009f6c25adcd36c4f052eab +P ecad75d69e0d5c83dd3584d363e557e84b65f7f2 +R bca4975588f4da52a9a8fe0cd42dc56d U drh -Z 7ba0fba490eff520c14229730eb61dd8 +Z 462bb50cf4ea1a0b7483c62da14af105 diff --git a/manifest.uuid b/manifest.uuid index 3749928415..669572ced9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ecad75d69e0d5c83dd3584d363e557e84b65f7f2 \ No newline at end of file +9eefa449792f03c4c149edcbc6b9b7692617994c \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index e5103856bd..475beed28b 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3086,13 +3086,9 @@ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){ SimulateIOError( got = -1 ); #else newOffset = lseek(id->h, offset, SEEK_SET); - SimulateIOError( newOffset-- ); - if( newOffset!=offset ){ - if( newOffset == -1 ){ - storeLastErrno((unixFile*)id, errno); - }else{ - storeLastErrno((unixFile*)id, 0); - } + SimulateIOError( newOffset = -1 ); + if( newOffset<0 ){ + storeLastErrno((unixFile*)id, errno); return -1; } got = osRead(id->h, pBuf, cnt); @@ -3191,6 +3187,7 @@ static int seekAndWriteFd( assert( nBuf==(nBuf&0x1ffff) ); assert( fd>2 ); + assert( piErrno!=0 ); nBuf &= 0x1ffff; TIMER_START; @@ -3201,11 +3198,10 @@ static int seekAndWriteFd( #else do{ i64 iSeek = lseek(fd, iOff, SEEK_SET); - SimulateIOError( iSeek-- ); - - if( iSeek!=iOff ){ - if( piErrno ) *piErrno = (iSeek==-1 ? errno : 0); - return -1; + SimulateIOError( iSeek = -1 ); + if( iSeek<0 ){ + rc = -1; + break; } rc = osWrite(fd, pBuf, nBuf); }while( rc<0 && errno==EINTR ); @@ -3214,7 +3210,7 @@ static int seekAndWriteFd( TIMER_END; OSTRACE(("WRITE %-3d %5d %7lld %llu\n", fd, rc, iOff, TIMER_ELAPSED)); - if( rc<0 && piErrno ) *piErrno = errno; + if( rc<0 ) *piErrno = errno; return rc; } @@ -4410,7 +4406,8 @@ static int unixShmMap( /* Write to the last byte of each newly allocated or extended page */ assert( (nByte % pgsz)==0 ); for(iPg=(sStat.st_size/pgsz); iPg<(nByte/pgsz); iPg++){ - if( seekAndWriteFd(pShmNode->h, iPg*pgsz + pgsz-1, "", 1, 0)!=1 ){ + int x = 0; + if( seekAndWriteFd(pShmNode->h, iPg*pgsz + pgsz-1, "", 1, &x)!=1 ){ const char *zFile = pShmNode->zFilename; rc = unixLogError(SQLITE_IOERR_SHMSIZE, "write", zFile); goto shmpage_out; From 41d2e66ef3de25a0d78a79bfbb781f305842c77b Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 1 Dec 2015 21:23:07 +0000 Subject: [PATCH 036/232] Add the SQLITE_LIKE_DOESNT_MATCH_BLOBS compile-time option. FossilOrigin-Name: 9e1d6d4c391ff90077f0d1cdeb567969fee9f747 --- manifest | 35 +++++++++++++++++------------------ manifest.uuid | 2 +- src/ctime.c | 3 +++ src/func.c | 11 +++++++++++ src/test_config.c | 6 ++++++ src/vdbe.c | 2 ++ src/where.c | 2 ++ src/whereInt.h | 2 ++ src/wherecode.c | 14 ++++++++++++++ test/analyze3.test | 20 ++++++++++++++------ test/enc3.test | 5 +++-- test/like.test | 36 ++++++++++++++++++++++++++---------- test/like3.test | 7 +++++-- test/where8.test | 22 +++++++++++++++------- 14 files changed, 121 insertions(+), 46 deletions(-) diff --git a/manifest b/manifest index 25c8979c29..1171656df0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\stest_fs.c\stest\smodule\snow\sworks\son\sWindows. -D 2015-12-01T17:48:45.370 +C Add\sthe\sSQLITE_LIKE_DOESNT_MATCH_BLOBS\scompile-time\soption. +D 2015-12-01T21:23:07.560 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -288,14 +288,14 @@ F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f -F src/ctime.c 509ef9c64d1321f42448f111da86400b1799218a +F src/ctime.c 58eda76364fb6f374e044aa4493219b13abf9400 F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c cb1a419508e5b27769a91e00e36e94724e7b1d51 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 -F src/func.c 5790a898a0c53e6787020ec268425d415e7e03c9 +F src/func.c fe50a9ab977acc0bb0fcd46741e0071fa388888e F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 @@ -363,7 +363,7 @@ F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12 F src/test_backup.c 2e6e6a081870150f20c526a2e9d0d29cda47d803 F src/test_blob.c e5a7a81d61a780da79101aeb1e60d300af169e07 F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f -F src/test_config.c f2824de39f59d8d621e2d6ec5cc67006d000b2eb +F src/test_config.c 48850687dd5abc8260e23835632511054ccae172 F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_fs.c aab47ac456316502faa265daadf9ac832fea12b9 @@ -404,7 +404,7 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c b56b2fc9b2f2d0a99d1dbd02d47efaacec253a4c +F src/vdbe.c 4d75375fa8bf911aa76ab8383d6f7eea0dec0fda F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca @@ -418,9 +418,9 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 18b0ed49830cf04fe2d68224b41838a73ac6cd24 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba -F src/where.c 9c04982ba9ecfc7751c670ed5a3bddc81d7eb74c -F src/whereInt.h 6afc0d70cf6213e58e8fbe10b6e50d1aa16f122f -F src/wherecode.c 4c96182e7b25e4be54008dee2da5b9c2f8480b9b +F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 +F src/whereInt.h e20801d89e34de1912bb6a3babb30c390da27add +F src/wherecode.c dfbfe198e418b01f208b489e088edd230c91a4e7 F src/whereexpr.c eebba8340c90de73b3d3bbe8c43b84559b8e6e2c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -435,7 +435,7 @@ F test/alter4.test c461150723ac957f3b2214aa0b11552cd72023ec F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f F test/analyze.test 3eb35a4af972f98422e5dc0586501b17d103d321 -F test/analyze3.test 0f0ee6135b293a0e5af471a8423b80b688469d71 +F test/analyze3.test 1dccda46a6c374018af617fba00bfe297a61d442 F test/analyze4.test eff2df19b8dd84529966420f29ea52edc6b56213 F test/analyze5.test 765c4e284aa69ca172772aa940946f55629bc8c4 F test/analyze6.test f1c552ce39cca4ec922a7e4e0e5d0203d6b3281f @@ -610,7 +610,7 @@ F test/e_walckpt.test 65e29b6631e51f210f83e4ff11571e647ba93608 F test/e_walhook.test da3ea8b3483d1af72190337bda50155a91a4b664 F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 83437a79ba1545a55fb549309175c683fb334473 -F test/enc3.test 90683ad0e6ea587b9d5542ca93568af9a9858c40 +F test/enc3.test 6807f7a7740a00361ca8d0ccd66bc60c8dc5f2b6 F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020 F test/eqp.test 85873fa5816c48915c82c4e74cb5c35a5b48160f F test/errmsg.test f31592a594b44ee121371d25ddd5d63497bb3401 @@ -829,9 +829,9 @@ F test/json102.test bf3fe7a706d30936a76a0f7a0375e1e8e73aff5a F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 -F test/like.test 4f2a71d36a536233727f71995fef900756705e56 +F test/like.test edcf6d0a055816fd793eab92454597c1be91f720 F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da -F test/like3.test 7b0525a39e4f25c4fd113de7e2e28eb712dcdedf +F test/like3.test 3608a2042b6f922f900fbfd5d3ce4e7eca57f7c4 F test/limit.test 0c99a27a87b14c646a9d583c7c89fd06c352663e F test/loadext.test 648cb95f324d1775c54a55c12271b2d1156b633b F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 @@ -1315,7 +1315,7 @@ F test/where4.test 4a371bfcc607f41d233701bdec33ac2972908ba8 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b F test/where7.test 5a4b0abc207d71da4deecd734ad8579e8dd40aa8 -F test/where8.test 2eafe74e01cc10355985874e1ff868ac03dbae5e +F test/where8.test 98eedca0d375fb400b8377269c4b4686582dfb45 F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 F test/where9.test 729c3ba9b47e8f9f1aab96bae7dad2a524f1d1a2 F test/whereA.test 4d253178d135ec46d1671e440cd8f2b916aa6e6b @@ -1408,8 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9eefa449792f03c4c149edcbc6b9b7692617994c f3ffb3aeea95712e92919fd5071741327add9643 -R e64b655038c6ea5e388ada04c5bc3077 -T +closed f3ffb3aeea95712e92919fd5071741327add9643 +P e3d8628456848a70035bbdeca6dc6c21f688b9a5 +R ee2257e707ea5c58e9d484a1c772cd3c U drh -Z d6f52c287ea9591be795be1577b20991 +Z b3c4a1b23e3be107d1964e5242f6524b diff --git a/manifest.uuid b/manifest.uuid index e2f8fb6ba3..b0e59d95bb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e3d8628456848a70035bbdeca6dc6c21f688b9a5 \ No newline at end of file +9e1d6d4c391ff90077f0d1cdeb567969fee9f747 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index 17dd710bc3..c3149ad913 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -158,6 +158,9 @@ static const char * const azCompileOpt[] = { #ifdef SQLITE_INT64_TYPE "INT64_TYPE", #endif +#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS + "LIKE_DOESNT_MATCH_BLOBS", +#endif #if SQLITE_LOCK_TRACE "LOCK_TRACE", #endif diff --git a/src/func.c b/src/func.c index b134c1a7c2..3fbd2b736b 100644 --- a/src/func.c +++ b/src/func.c @@ -802,6 +802,17 @@ static void likeFunc( int nPat; sqlite3 *db = sqlite3_context_db_handle(context); +#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS + if( sqlite3_value_type(argv[0])==SQLITE_BLOB + || sqlite3_value_type(argv[1])==SQLITE_BLOB + ){ +#ifdef SQLITE_TEST + sqlite3_like_count++; +#endif + sqlite3_result_int(context, 0); + return; + } +#endif zB = sqlite3_value_text(argv[0]); zA = sqlite3_value_text(argv[1]); diff --git a/src/test_config.c b/src/test_config.c index b84424bbdc..a9ef182e02 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -185,6 +185,12 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options", "json1", "0", TCL_GLOBAL_ONLY); #endif +#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS + Tcl_SetVar2(interp, "sqlite_options", "like_match_blobs", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "like_match_blobs", "1", TCL_GLOBAL_ONLY); +#endif + #ifdef SQLITE_OMIT_ATTACH Tcl_SetVar2(interp, "sqlite_options", "attach", "0", TCL_GLOBAL_ONLY); #else diff --git a/src/vdbe.c b/src/vdbe.c index 66b507b285..f87fddafed 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1088,6 +1088,7 @@ case OP_String: { /* out2 */ pOut->n = pOp->p1; pOut->enc = encoding; UPDATE_MAX_BLOBSIZE(pOut); +#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS if( pOp->p5 ){ assert( pOp->p3>0 ); assert( pOp->p3<=(p->nMem-p->nCursor) ); @@ -1095,6 +1096,7 @@ case OP_String: { /* out2 */ assert( pIn3->flags & MEM_Int ); if( pIn3->u.i ) pOut->flags = MEM_Blob|MEM_Static|MEM_Term; } +#endif break; } diff --git a/src/where.c b/src/where.c index 30ad58e01b..7d68664598 100644 --- a/src/where.c +++ b/src/where.c @@ -4492,6 +4492,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ sqlite3VdbeJumpHere(v, pLevel->addrSkip); sqlite3VdbeJumpHere(v, pLevel->addrSkip-2); } +#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS if( pLevel->addrLikeRep ){ int op; if( sqlite3VdbeGetOp(v, pLevel->addrLikeRep-1)->p1 ){ @@ -4502,6 +4503,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){ sqlite3VdbeAddOp2(v, op, pLevel->iLikeRepCntr, pLevel->addrLikeRep); VdbeCoverage(v); } +#endif if( pLevel->iLeftJoin ){ addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v); assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 diff --git a/src/whereInt.h b/src/whereInt.h index 86164d8c1f..63d2d71cb4 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -69,8 +69,10 @@ struct WhereLevel { int addrCont; /* Jump here to continue with the next loop cycle */ int addrFirst; /* First instruction of interior of the loop */ int addrBody; /* Beginning of the body of this loop */ +#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS int iLikeRepCntr; /* LIKE range processing counter register */ int addrLikeRep; /* LIKE range processing address */ +#endif u8 iFrom; /* Which entry in the FROM clause */ u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */ int p1, p2; /* Operands of the opcode used to ends the loop */ diff --git a/src/wherecode.c b/src/wherecode.c index 87db0e0a25..bc72e0ac7d 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -561,6 +561,7 @@ static int codeAllEqualityTerms( return regBase; } +#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS /* ** If the most recently coded instruction is a constant range contraint ** that originated from the LIKE optimization, then change the P3 to be @@ -572,6 +573,10 @@ static int codeAllEqualityTerms( ** The OP_String opcodes on the second pass convert the upper and lower ** bound string contants to blobs. This routine makes the necessary changes ** to the OP_String opcodes for that to happen. +** +** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then +** only the one pass through the string space is required, so this routine +** becomes a no-op. */ static void whereLikeOptimizationStringFixup( Vdbe *v, /* prepared statement under construction */ @@ -589,6 +594,9 @@ static void whereLikeOptimizationStringFixup( pOp->p5 = 1; } } +#else +# define whereLikeOptimizationStringFixup(A,B,C) +#endif #ifdef SQLITE_ENABLE_CURSOR_HINTS /* @@ -1075,6 +1083,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( if( pLoop->wsFlags & WHERE_TOP_LIMIT ){ pRangeEnd = pLoop->aLTerm[j++]; nExtraReg = 1; +#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){ assert( pRangeStart!=0 ); /* LIKE opt constraints */ assert( pRangeStart->wtFlags & TERM_LIKEOPT ); /* occur in pairs */ @@ -1087,6 +1096,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( VdbeComment((v, "LIKE loop counter")); pLevel->addrLikeRep = sqlite3VdbeCurrentAddr(v); } +#endif if( pRangeStart==0 && (j = pIdx->aiColumn[nEq])>=0 && pIdx->pTable->aCol[j].notNull==0 @@ -1590,9 +1600,13 @@ Bitmask sqlite3WhereCodeOneLoopStart( continue; } if( pTerm->wtFlags & TERM_LIKECOND ){ +#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS + continue; +#else assert( pLevel->iLikeRepCntr>0 ); skipLikeAddr = sqlite3VdbeAddOp1(v, OP_IfNot, pLevel->iLikeRepCntr); VdbeCoverage(v); +#endif } sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL); if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr); diff --git a/test/analyze3.test b/test/analyze3.test index d61d21a947..2fb558d16a 100644 --- a/test/analyze3.test +++ b/test/analyze3.test @@ -283,9 +283,17 @@ do_eqp_test analyze3-2.3 { SELECT count(a) FROM t1 WHERE b LIKE '%a' } {0 0 0 {SCAN TABLE t1}} +# Return the first argument if like_match_blobs is true (the default) +# or the second argument if not +# +proc ilmb {a b} { + ifcapable like_match_blobs {return $a} + return $b +} + do_test analyze3-2.4 { sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE 'a%' } -} {102 0 100} +} [list [ilmb 102 101] 0 100] do_test analyze3-2.5 { sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE '%a' } } {999 999 100} @@ -293,7 +301,7 @@ do_test analyze3-2.5 { do_test analyze3-2.6 { set like "a%" sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } -} {102 0 100} +} [list [ilmb 102 101] 0 100] do_test analyze3-2.7 { set like "%a" sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } @@ -301,19 +309,19 @@ do_test analyze3-2.7 { do_test analyze3-2.8 { set like "a" sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } -} {102 0 0} +} [list [ilmb 102 101] 0 0] do_test analyze3-2.9 { set like "ab" sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } -} {12 0 0} +} [list [ilmb 12 11] 0 0] do_test analyze3-2.10 { set like "abc" sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } -} {3 0 1} +} [list [ilmb 3 2] 0 1] do_test analyze3-2.11 { set like "a_c" sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } -} {102 0 10} +} [list [ilmb 102 101] 0 10] #------------------------------------------------------------------------- diff --git a/test/enc3.test b/test/enc3.test index 1d8a258165..7ede2b716f 100644 --- a/test/enc3.test +++ b/test/enc3.test @@ -62,7 +62,7 @@ ifcapable {bloblit && utf16} { execsql { CREATE TABLE t2(a); INSERT INTO t2 VALUES(x'61006200630064006500'); - SELECT CAST(a AS text) FROM t2 WHERE a LIKE 'abc%'; + SELECT CAST(a AS text) FROM t2 WHERE CAST(a AS text) LIKE 'abc%'; } } {abcde} do_test enc3-2.3 { @@ -72,7 +72,8 @@ ifcapable {bloblit && utf16} { } {abcde} do_test enc3-2.4 { execsql { - SELECT rowid FROM t2 WHERE a LIKE x'610062002500'; + SELECT rowid FROM t2 + WHERE CAST(a AS text) LIKE CAST(x'610062002500' AS text); } } {1} } diff --git a/test/like.test b/test/like.test index 18a01dc996..ceb5f2bfac 100644 --- a/test/like.test +++ b/test/like.test @@ -745,11 +745,19 @@ ifcapable like_opt&&!icu { SELECT a FROM t10 WHERE e LIKE '12%' ORDER BY +a; } } {12 123 scan 5 like 6} - do_test like-10.5 { - count { - SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY +a; - } - } {12 123 scan 4 like 0} + ifcapable like_match_blobs { + do_test like-10.5a { + count { + SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY +a; + } + } {12 123 scan 4 like 0} + } else { + do_test like-10.5b { + count { + SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY +a; + } + } {12 123 scan 3 like 0} + } do_test like-10.6 { count { SELECT a FROM t10 WHERE a LIKE '12%' ORDER BY +a; @@ -786,11 +794,19 @@ ifcapable like_opt&&!icu { SELECT a FROM t10b WHERE e GLOB '12*' ORDER BY +a; } } {12 123 scan 5 like 6} - do_test like-10.14 { - count { - SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY +a; - } - } {12 123 scan 4 like 0} + ifcapable like_match_blobs { + do_test like-10.14 { + count { + SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY +a; + } + } {12 123 scan 4 like 0} + } else { + do_test like-10.14 { + count { + SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY +a; + } + } {12 123 scan 3 like 0} + } do_test like-10.15 { count { SELECT a FROM t10b WHERE a GLOB '12*' ORDER BY +a; diff --git a/test/like3.test b/test/like3.test index a1faf76915..9280c2c5d2 100644 --- a/test/like3.test +++ b/test/like3.test @@ -29,6 +29,11 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +ifcapable !like_match_blobs { + finish_test + return +} + do_execsql_test like3-1.1 { PRAGMA encoding=UTF8; CREATE TABLE t1(a,b TEXT COLLATE nocase); @@ -107,6 +112,4 @@ do_execsql_test like3-4.2ck { SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY +x ASC; } {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'} - - finish_test diff --git a/test/where8.test b/test/where8.test index a155a95ab2..38214bc895 100644 --- a/test/where8.test +++ b/test/where8.test @@ -64,13 +64,21 @@ do_test where8-1.3 { execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b = 'two' } } {IX X II 0 0 6} -do_test where8-1.4 { - execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 't*' } -} {IX X III II 0 0 10} - -do_test where8-1.5 { - execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 'f*' } -} {IX X V IV 0 0 10} +ifcapable like_match_blobs { + do_test where8-1.4a { + execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 't*' } + } {IX X III II 0 0 10} + do_test where8-1.5a { + execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 'f*' } + } {IX X V IV 0 0 10} +} else { + do_test where8-1.4b { + execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 't*' } + } {IX X III II 0 0 9} + do_test where8-1.5 { + execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 'f*' } + } {IX X V IV 0 0 9} +} do_test where8-1.6 { execsql_status { SELECT c FROM t1 WHERE a = 1 OR b = 'three' ORDER BY rowid } From 053378dfa82c7e03f76dd78d5968ea43b0b1cce5 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 1 Dec 2015 22:09:42 +0000 Subject: [PATCH 037/232] Simplification to the posix_fallocate() replacement used for the SQLITE_FCNTL_SIZE_HINT file control in the unix VFS. FossilOrigin-Name: 74934d3f60ad9f6550297410eada0f288e0123c4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 10 +++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 1171656df0..ce2f2c25e3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_LIKE_DOESNT_MATCH_BLOBS\scompile-time\soption. -D 2015-12-01T21:23:07.560 +C Simplification\sto\sthe\sposix_fallocate()\sreplacement\sused\sfor\sthe\nSQLITE_FCNTL_SIZE_HINT\sfile\scontrol\sin\sthe\sunix\sVFS. +D 2015-12-01T22:09:42.967 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 7d56433ac85e77423d2d613fd5e53db08c5868ed +F src/os_unix.c 5808a077bf6842a47d65197f7843d4c391636b75 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e3d8628456848a70035bbdeca6dc6c21f688b9a5 -R ee2257e707ea5c58e9d484a1c772cd3c +P 9e1d6d4c391ff90077f0d1cdeb567969fee9f747 +R 769374e25ea21fa88cb308a9a19cbf86 U drh -Z b3c4a1b23e3be107d1964e5242f6524b +Z d260ee6b5b66bd6991fd3ea098b02c75 diff --git a/manifest.uuid b/manifest.uuid index b0e59d95bb..dc83ba56f8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e1d6d4c391ff90077f0d1cdeb567969fee9f747 \ No newline at end of file +74934d3f60ad9f6550297410eada0f288e0123c4 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 475beed28b..e3a6f778dd 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3662,18 +3662,14 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){ int nWrite = 0; /* Number of bytes written by seekAndWrite */ i64 iWrite; /* Next offset to write to */ - iWrite = ((buf.st_size + 2*nBlk - 1)/nBlk)*nBlk-1; + iWrite = (buf.st_size/nBlk)*nBlk + nBlk - 1; assert( iWrite>=buf.st_size ); - assert( (iWrite/nBlk)==((buf.st_size+nBlk-1)/nBlk) ); assert( ((iWrite+1)%nBlk)==0 ); - for(/*no-op*/; iWrite=nSize ) iWrite = nSize - 1; nWrite = seekAndWrite(pFile, iWrite, "", 1); if( nWrite!=1 ) return SQLITE_IOERR_WRITE; } - if( nWrite==0 || (nSize%nBlk) ){ - nWrite = seekAndWrite(pFile, nSize-1, "", 1); - if( nWrite!=1 ) return SQLITE_IOERR_WRITE; - } #endif } } From dcfb9652fda0becc56e4a2f507155e5352c785ab Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 2 Dec 2015 00:05:26 +0000 Subject: [PATCH 038/232] Remove all traces of SQLITE_FCNTL_WAL_BLOCK from the unix VFS - that feature had been disabled for a long time and never actually worked. FossilOrigin-Name: e1d5320ca089336e26d200305b744b06ce883be4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 10 +--------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index ce2f2c25e3..278638f8a9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sto\sthe\sposix_fallocate()\sreplacement\sused\sfor\sthe\nSQLITE_FCNTL_SIZE_HINT\sfile\scontrol\sin\sthe\sunix\sVFS. -D 2015-12-01T22:09:42.967 +C Remove\sall\straces\sof\sSQLITE_FCNTL_WAL_BLOCK\sfrom\sthe\sunix\sVFS\s-\sthat\sfeature\nhad\sbeen\sdisabled\sfor\sa\slong\stime\sand\snever\sactually\sworked. +D 2015-12-02T00:05:26.857 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 5808a077bf6842a47d65197f7843d4c391636b75 +F src/os_unix.c 8f8f11b64aa5b20f75f0a9e4ed494e51a641e62f F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9e1d6d4c391ff90077f0d1cdeb567969fee9f747 -R 769374e25ea21fa88cb308a9a19cbf86 +P 74934d3f60ad9f6550297410eada0f288e0123c4 +R 1d7fdc365e66b6a0c98551c7522b87df U drh -Z d260ee6b5b66bd6991fd3ea098b02c75 +Z 0a345589f1af443a2c8f5dbd810973ee diff --git a/manifest.uuid b/manifest.uuid index dc83ba56f8..8cf64f6d0d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -74934d3f60ad9f6550297410eada0f288e0123c4 \ No newline at end of file +e1d5320ca089336e26d200305b744b06ce883be4 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index e3a6f778dd..35f401e74c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -258,7 +258,6 @@ static pid_t randomnessPid = 0; #define UNIXFILE_DELETE 0x20 /* Delete on close */ #define UNIXFILE_URI 0x40 /* Filename might have query parameters */ #define UNIXFILE_NOLOCK 0x80 /* Do no file locking */ -#define UNIXFILE_BLOCK 0x0100 /* Next SHM lock might block */ /* ** Include code that is common to all os_*.c files @@ -3717,10 +3716,6 @@ static int unixGetTempname(int nBuf, char *zBuf); static int unixFileControl(sqlite3_file *id, int op, void *pArg){ unixFile *pFile = (unixFile*)id; switch( op ){ - case SQLITE_FCNTL_WAL_BLOCK: { - /* pFile->ctrlFlags |= UNIXFILE_BLOCK; // Deferred feature */ - return SQLITE_OK; - } case SQLITE_FCNTL_LOCKSTATE: { *(int*)pArg = pFile->eFileLock; return SQLITE_OK; @@ -4050,7 +4045,6 @@ static int unixShmSystemLock( assert( n>=1 && nh>=0 ){ - int lkType; /* Initialize the locking parameters */ memset(&f, 0, sizeof(f)); f.l_type = lockType; @@ -4058,10 +4052,8 @@ static int unixShmSystemLock( f.l_start = ofst; f.l_len = n; - lkType = (pFile->ctrlFlags & UNIXFILE_BLOCK)!=0 ? F_SETLKW : F_SETLK; - rc = osFcntl(pShmNode->h, lkType, &f); + rc = osFcntl(pShmNode->h, F_SETLK, &f); rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY; - pFile->ctrlFlags &= ~UNIXFILE_BLOCK; } /* Update the global lock state and do debug tracing */ From 50358adfaaef3ab020bbf0d51560141d9a6713db Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 2 Dec 2015 01:04:33 +0000 Subject: [PATCH 039/232] Simplification of the logic used to take the process-wide lock in the unix-excl VFS. FossilOrigin-Name: 73defd52bb0e3e5db763d3bfbeebc972b645867e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 4 +--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 278638f8a9..f950ba358b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sall\straces\sof\sSQLITE_FCNTL_WAL_BLOCK\sfrom\sthe\sunix\sVFS\s-\sthat\sfeature\nhad\sbeen\sdisabled\sfor\sa\slong\stime\sand\snever\sactually\sworked. -D 2015-12-02T00:05:26.857 +C Simplification\sof\sthe\slogic\sused\sto\stake\sthe\sprocess-wide\slock\sin\sthe\nunix-excl\sVFS. +D 2015-12-02T01:04:33.889 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 8f8f11b64aa5b20f75f0a9e4ed494e51a641e62f +F src/os_unix.c 207fef7c47f3d77cf8a52edd5ebd53b67e731fd1 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 74934d3f60ad9f6550297410eada0f288e0123c4 -R 1d7fdc365e66b6a0c98551c7522b87df +P e1d5320ca089336e26d200305b744b06ce883be4 +R 529fef7e01cd9bbdb6610da9a8964270 U drh -Z 0a345589f1af443a2c8f5dbd810973ee +Z 697c3f68f06eec6f2193816dd17daae9 diff --git a/manifest.uuid b/manifest.uuid index 8cf64f6d0d..9faa68982f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1d5320ca089336e26d200305b744b06ce883be4 \ No newline at end of file +73defd52bb0e3e5db763d3bfbeebc972b645867e \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 35f401e74c..38c8d7b619 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1406,9 +1406,7 @@ static int unixFileLock(unixFile *pFile, struct flock *pLock){ unixInodeInfo *pInode = pFile->pInode; assert( unixMutexHeld() ); assert( pInode!=0 ); - if( ((pFile->ctrlFlags & UNIXFILE_EXCL)!=0 || pInode->bProcessLock) - && ((pFile->ctrlFlags & UNIXFILE_RDONLY)==0) - ){ + if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){ if( pInode->bProcessLock==0 ){ struct flock lock; assert( pInode->nLock==0 ); From adfa22e118e7a0db0a89ff899ddcd48d517e9c31 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 2 Dec 2015 02:08:30 +0000 Subject: [PATCH 040/232] Fix a (harmless) off-by-one error in the unix VFS logic that fsync()s a directory after deleting a file. FossilOrigin-Name: 3d02711a709a7e708edb0ea8ca5d17b39dd307f6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f950ba358b..0870896448 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sof\sthe\slogic\sused\sto\stake\sthe\sprocess-wide\slock\sin\sthe\nunix-excl\sVFS. -D 2015-12-02T01:04:33.889 +C Fix\sa\s(harmless)\soff-by-one\serror\sin\sthe\sunix\sVFS\slogic\sthat\sfsync()s\sa\ndirectory\safter\sdeleting\sa\sfile. +D 2015-12-02T02:08:30.997 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 207fef7c47f3d77cf8a52edd5ebd53b67e731fd1 +F src/os_unix.c 27a7ead71bfca5d90ad965f2ac46b37b63f07189 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e1d5320ca089336e26d200305b744b06ce883be4 -R 529fef7e01cd9bbdb6610da9a8964270 +P 73defd52bb0e3e5db763d3bfbeebc972b645867e +R e028288719c771a5625e51b4f5de27be U drh -Z 697c3f68f06eec6f2193816dd17daae9 +Z 2550f7a73cc643eb4c13a681e63731c8 diff --git a/manifest.uuid b/manifest.uuid index 9faa68982f..9e1954b28f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -73defd52bb0e3e5db763d3bfbeebc972b645867e \ No newline at end of file +3d02711a709a7e708edb0ea8ca5d17b39dd307f6 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 38c8d7b619..8eff392a66 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3461,7 +3461,7 @@ static int openDirectory(const char *zFilename, int *pFd){ sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename); for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--); - if( ii>0 ){ + if( ii>1 ){ zDirname[ii] = '\0'; fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); if( fd>=0 ){ From 2c8fd12f42e9f093b935e5225d9e6978825f77b6 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 2 Dec 2015 02:33:36 +0000 Subject: [PATCH 041/232] Change the SQLITE_NO_SYNC compile-time option to call fstat() in place of fsync() rather than being a total no-op. FossilOrigin-Name: f64ea8a052af9790d5e6987cbd5e81d77da6f172 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 9 +++++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 0870896448..20fe8059ef 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\s(harmless)\soff-by-one\serror\sin\sthe\sunix\sVFS\slogic\sthat\sfsync()s\sa\ndirectory\safter\sdeleting\sa\sfile. -D 2015-12-02T02:08:30.997 +C Change\sthe\sSQLITE_NO_SYNC\scompile-time\soption\sto\scall\sfstat()\sin\splace\sof\nfsync()\srather\sthan\sbeing\sa\stotal\sno-op. +D 2015-12-02T02:33:36.549 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 27a7ead71bfca5d90ad965f2ac46b37b63f07189 +F src/os_unix.c badd3d7b007daa74df6a12c1e5a89a8504ef3594 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 73defd52bb0e3e5db763d3bfbeebc972b645867e -R e028288719c771a5625e51b4f5de27be +P 3d02711a709a7e708edb0ea8ca5d17b39dd307f6 +R 32c34918a379a944fbe8e3ec0a4b5179 U drh -Z 2550f7a73cc643eb4c13a681e63731c8 +Z d4a14e46436f968eb1bd48b7a43684a4 diff --git a/manifest.uuid b/manifest.uuid index 9e1954b28f..88f3adba23 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3d02711a709a7e708edb0ea8ca5d17b39dd307f6 \ No newline at end of file +f64ea8a052af9790d5e6987cbd5e81d77da6f172 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 8eff392a66..7038bf12df 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3391,10 +3391,15 @@ static int full_fsync(int fd, int fullSync, int dataOnly){ #endif /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a - ** no-op + ** no-op. But go ahead and call fstat() to validate the file + ** descriptor as we need a method to provoke a failure during + ** coverate testing. */ #ifdef SQLITE_NO_SYNC - rc = SQLITE_OK; + { + struct stat buf; + rc = osFstat(fd, &buf); + } #elif HAVE_FULLFSYNC if( fullSync ){ rc = osFcntl(fd, F_FULLFSYNC, 0); From f3b1ed0fc219d9c3a7caac14694b18bcc6c5c025 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 2 Dec 2015 13:11:03 +0000 Subject: [PATCH 042/232] Minor simplifications to the unix VFS. FossilOrigin-Name: 2f13c16b45685ec6850cbd9da79e8198bad6a491 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 12 ++++-------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 20fe8059ef..23275e1740 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sSQLITE_NO_SYNC\scompile-time\soption\sto\scall\sfstat()\sin\splace\sof\nfsync()\srather\sthan\sbeing\sa\stotal\sno-op. -D 2015-12-02T02:33:36.549 +C Minor\ssimplifications\sto\sthe\sunix\sVFS. +D 2015-12-02T13:11:03.174 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c badd3d7b007daa74df6a12c1e5a89a8504ef3594 +F src/os_unix.c 2b65298be9db161beb0e3ffadc9be0080d51c320 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3d02711a709a7e708edb0ea8ca5d17b39dd307f6 -R 32c34918a379a944fbe8e3ec0a4b5179 +P f64ea8a052af9790d5e6987cbd5e81d77da6f172 +R 7335e7d7ad4ea5951ac863300cf3bdc9 U drh -Z d4a14e46436f968eb1bd48b7a43684a4 +Z 5e48ed834d343e9f2a57065e0ab37833 diff --git a/manifest.uuid b/manifest.uuid index 88f3adba23..4a79fe8bad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f64ea8a052af9790d5e6987cbd5e81d77da6f172 \ No newline at end of file +2f13c16b45685ec6850cbd9da79e8198bad6a491 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 7038bf12df..00602c6b82 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4123,7 +4123,7 @@ static int unixShmRegionPerMap(void){ static void unixShmPurge(unixFile *pFd){ unixShmNode *p = pFd->pInode->pShmNode; assert( unixMutexHeld() ); - if( p && p->nRef==0 ){ + if( p && ALWAYS(p->nRef==0) ){ int nShmPerMap = unixShmRegionPerMap(); int i; assert( p->pInode==pFd->pInode ); @@ -4210,7 +4210,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ ** a new *-shm file is created, an attempt will be made to create it ** with the same permissions. */ - if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){ + if( osFstat(pDbFd->h, &sStat) ){ rc = SQLITE_IOERR_FSTAT; goto shm_open_err; } @@ -4766,17 +4766,13 @@ static void unixRemapfile( ** recreated as a result of outstanding references) or an SQLite error ** code otherwise. */ -static int unixMapfile(unixFile *pFd, i64 nByte){ - i64 nMap = nByte; - int rc; - +static int unixMapfile(unixFile *pFd, i64 nMap){ assert( nMap>=0 || pFd->nFetchOut==0 ); if( pFd->nFetchOut>0 ) return SQLITE_OK; if( nMap<0 ){ struct stat statbuf; /* Low-level file information */ - rc = osFstat(pFd->h, &statbuf); - if( rc!=SQLITE_OK ){ + if( osFstat(pFd->h, &statbuf) ){ return SQLITE_IOERR_FSTAT; } nMap = statbuf.st_size; From 333e6ca9a5a38d756cac1e64669b4b4a5c65e8e8 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 2 Dec 2015 15:44:39 +0000 Subject: [PATCH 043/232] Remove an unreachable branch from the unixMapfile() routine of the unix VFS. FossilOrigin-Name: b50f67bc46e65fe4e51667d48b4add58706a9443 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 8 +++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 23275e1740..a287e3b468 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\ssimplifications\sto\sthe\sunix\sVFS. -D 2015-12-02T13:11:03.174 +C Remove\san\sunreachable\sbranch\sfrom\sthe\sunixMapfile()\sroutine\sof\sthe\sunix\sVFS. +D 2015-12-02T15:44:39.206 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 2b65298be9db161beb0e3ffadc9be0080d51c320 +F src/os_unix.c b2482c403890fc94ee6810a939c667911d871656 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f64ea8a052af9790d5e6987cbd5e81d77da6f172 -R 7335e7d7ad4ea5951ac863300cf3bdc9 +P 2f13c16b45685ec6850cbd9da79e8198bad6a491 +R abab3e669867554a3d4200296f7779a0 U drh -Z 5e48ed834d343e9f2a57065e0ab37833 +Z cde83eb7aba3982fd2548e9f5c9718be diff --git a/manifest.uuid b/manifest.uuid index 4a79fe8bad..9a8daa1e72 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f13c16b45685ec6850cbd9da79e8198bad6a491 \ No newline at end of file +b50f67bc46e65fe4e51667d48b4add58706a9443 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 00602c6b82..31e3215b8a 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4768,6 +4768,7 @@ static void unixRemapfile( */ static int unixMapfile(unixFile *pFd, i64 nMap){ assert( nMap>=0 || pFd->nFetchOut==0 ); + assert( nMap>0 || (pFd->mmapSize==0 && pFd->pMapRegion==0) ); if( pFd->nFetchOut>0 ) return SQLITE_OK; if( nMap<0 ){ @@ -4781,12 +4782,9 @@ static int unixMapfile(unixFile *pFd, i64 nMap){ nMap = pFd->mmapSizeMax; } + assert( nMap>0 || (pFd->mmapSize==0 && pFd->pMapRegion==0) ); if( nMap!=pFd->mmapSize ){ - if( nMap>0 ){ - unixRemapfile(pFd, nMap); - }else{ - unixUnmapfile(pFd); - } + unixRemapfile(pFd, nMap); } return SQLITE_OK; From ab37277367effdaa555c11b02a62d75b2e962de2 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 2 Dec 2015 16:10:16 +0000 Subject: [PATCH 044/232] Remove more (dead) SQLITE_FCNTL_WAL_BLOCK logic from wal.c - code that was missed during the [e1d5320ca08933] check-in. FossilOrigin-Name: 58c15c6af964563ac7ece8606d16730ccf9ee72b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/wal.c | 17 ++++++++--------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index a287e3b468..c2e303db81 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunreachable\sbranch\sfrom\sthe\sunixMapfile()\sroutine\sof\sthe\sunix\sVFS. -D 2015-12-02T15:44:39.206 +C Remove\smore\s(dead)\sSQLITE_FCNTL_WAL_BLOCK\slogic\sfrom\swal.c\s-\scode\sthat\swas\nmissed\sduring\sthe\s[e1d5320ca08933]\scheck-in. +D 2015-12-02T16:10:16.198 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 18b0ed49830cf04fe2d68224b41838a73ac6cd24 +F src/wal.c 1569802364cd192bbd5c4a8ea3fd6de593edecbd F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2f13c16b45685ec6850cbd9da79e8198bad6a491 -R abab3e669867554a3d4200296f7779a0 +P b50f67bc46e65fe4e51667d48b4add58706a9443 +R b4ba7b1cdaa73453f30b9d196a7f9fe7 U drh -Z cde83eb7aba3982fd2548e9f5c9718be +Z 22cdb6e0aa6d053c442a36686d71e782 diff --git a/manifest.uuid b/manifest.uuid index 9a8daa1e72..38bbe3b842 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b50f67bc46e65fe4e51667d48b4add58706a9443 \ No newline at end of file +58c15c6af964563ac7ece8606d16730ccf9ee72b \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index d87d2c17ce..144db27a30 100644 --- a/src/wal.c +++ b/src/wal.c @@ -789,10 +789,9 @@ static void walUnlockShared(Wal *pWal, int lockIdx){ SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED); WALTRACE(("WAL%p: release SHARED-%s\n", pWal, walLockName(lockIdx))); } -static int walLockExclusive(Wal *pWal, int lockIdx, int n, int fBlock){ +static int walLockExclusive(Wal *pWal, int lockIdx, int n){ int rc; if( pWal->exclusiveMode ) return SQLITE_OK; - if( fBlock ) sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_WAL_BLOCK, 0); rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n, SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE); WALTRACE(("WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\n", pWal, @@ -1078,7 +1077,7 @@ static int walIndexRecover(Wal *pWal){ assert( pWal->writeLock ); iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock; nLock = SQLITE_SHM_NLOCK - iLock; - rc = walLockExclusive(pWal, iLock, nLock, 0); + rc = walLockExclusive(pWal, iLock, nLock); if( rc ){ return rc; } @@ -1616,7 +1615,7 @@ static int walBusyLock( ){ int rc; do { - rc = walLockExclusive(pWal, lockIdx, n, 0); + rc = walLockExclusive(pWal, lockIdx, n); }while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) ); return rc; } @@ -2057,7 +2056,7 @@ static int walIndexReadHdr(Wal *pWal, int *pChanged){ walUnlockShared(pWal, WAL_WRITE_LOCK); rc = SQLITE_READONLY_RECOVERY; } - }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 1)) ){ + }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){ pWal->writeLock = 1; if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){ badHdr = walIndexTryHdr(pWal, pChanged); @@ -2263,7 +2262,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ && (mxReadMarkhdr.mxFrame || mxI==0) ){ for(i=1; iaReadMark[i] = pWal->hdr.mxFrame; mxI = i; @@ -2537,7 +2536,7 @@ int sqlite3WalBeginWriteTransaction(Wal *pWal){ /* Only one writer allowed at a time. Get the write lock. Return ** SQLITE_BUSY if unable. */ - rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 0); + rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1); if( rc ){ return rc; } @@ -2682,7 +2681,7 @@ static int walRestartLog(Wal *pWal){ if( pInfo->nBackfill>0 ){ u32 salt1; sqlite3_randomness(4, &salt1); - rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1, 0); + rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1); if( rc==SQLITE_OK ){ /* If all readers are using WAL_READ_LOCK(0) (in other words if no ** readers are currently using the WAL), then the transactions @@ -3007,7 +3006,7 @@ int sqlite3WalCheckpoint( /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive ** "checkpoint" lock on the database file. */ - rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1, 0); + rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1); if( rc ){ /* EVIDENCE-OF: R-10421-19736 If any other process is running a ** checkpoint operation at the same time, the lock cannot be obtained and From af19f173d3b5172a46f65ab34cff77b8ed71cc3f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 2 Dec 2015 17:40:13 +0000 Subject: [PATCH 045/232] Fix an incorrect, though harmless, assert() in the unix VFS. FossilOrigin-Name: 4692ae84f93530e27d7c106a60236355e176b7fd --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c2e303db81..f70e8620e9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\smore\s(dead)\sSQLITE_FCNTL_WAL_BLOCK\slogic\sfrom\swal.c\s-\scode\sthat\swas\nmissed\sduring\sthe\s[e1d5320ca08933]\scheck-in. -D 2015-12-02T16:10:16.198 +C Fix\san\sincorrect,\sthough\sharmless,\sassert()\sin\sthe\sunix\sVFS. +D 2015-12-02T17:40:13.058 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c b2482c403890fc94ee6810a939c667911d871656 +F src/os_unix.c 60997373a8d90bd17e1c0e49d11ef361b713439b F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b50f67bc46e65fe4e51667d48b4add58706a9443 -R b4ba7b1cdaa73453f30b9d196a7f9fe7 +P 58c15c6af964563ac7ece8606d16730ccf9ee72b +R b2d2115192da5a36c6008a1f85419e31 U drh -Z 22cdb6e0aa6d053c442a36686d71e782 +Z a2ea6ee7bac71fd2eda9f163b8a48c3e diff --git a/manifest.uuid b/manifest.uuid index 38bbe3b842..a67ac0541e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58c15c6af964563ac7ece8606d16730ccf9ee72b \ No newline at end of file +4692ae84f93530e27d7c106a60236355e176b7fd \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 31e3215b8a..5f4cbca2aa 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4045,7 +4045,7 @@ static int unixShmSystemLock( assert( n==1 || lockType!=F_RDLCK ); /* Locks are within range */ - assert( n>=1 && n=1 && n<=SQLITE_SHM_NLOCK ); if( pShmNode->h>=0 ){ /* Initialize the locking parameters */ From 9a8941fc83f87b45e5c149b936bebc8bb254acde Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 2 Dec 2015 18:59:44 +0000 Subject: [PATCH 046/232] Have the sqlite3_column_decltype() API report the declared types for the left-most SELECT statement in a compound SELECT. FossilOrigin-Name: 3e1d71fcaf57c0223ab9a7366c8607f8f66bb21c --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 6 +++--- test/capi3c.test | 23 +++++++++++++++++++++++ 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index f70e8620e9..c3e7dba328 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sincorrect,\sthough\sharmless,\sassert()\sin\sthe\sunix\sVFS. -D 2015-12-02T17:40:13.058 +C Have\sthe\ssqlite3_column_decltype()\sAPI\sreport\sthe\sdeclared\stypes\sfor\sthe\sleft-most\sSELECT\sstatement\sin\sa\scompound\sSELECT. +D 2015-12-02T18:59:44.537 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -339,7 +339,7 @@ F src/printf.c ca05561795ad6c2fa47acdd007702586282f7feb F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c f4c897ca76ca6d5e0b3f0499c627392ffe657c8e F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c e10586c750d87211caa8f4b239e2bfa6a2049e5b +F src/select.c dd04f017d1402e1a8cbacb13f53c279dc48543b4 F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21 F src/sqlite.h.in 5bd83191711d3dc85030326daa9e8e5226a495e7 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -508,7 +508,7 @@ F test/cacheflush.test a755c93482ce2e20c04825304bef27e7b7ea0111 F test/capi2.test 011c16da245fdc0106a2785035de6b242c05e738 F test/capi3.test bf6f0308bbbba1e770dac13aa08e5c2ac61c7324 F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 -F test/capi3c.test fdc0d67a2cb8e8fc400d5b7735e330161ea057a2 +F test/capi3c.test 06f6261f9e9b4ef6f76afcd9900f3665408af1c8 F test/capi3d.test 485048dc5cd07bc68011e4917ad035ad6047ab82 F test/capi3e.test 3d49c01ef2a1a55f41d73cba2b23b5059ec460fe F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 58c15c6af964563ac7ece8606d16730ccf9ee72b -R b2d2115192da5a36c6008a1f85419e31 -U drh -Z a2ea6ee7bac71fd2eda9f163b8a48c3e +P 4692ae84f93530e27d7c106a60236355e176b7fd +R cccfb2982bfd6a0aab4098f75a44ccf8 +U dan +Z e453763f88995e08cd02dca755bc7590 diff --git a/manifest.uuid b/manifest.uuid index a67ac0541e..d924d8a8d3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4692ae84f93530e27d7c106a60236355e176b7fd \ No newline at end of file +3e1d71fcaf57c0223ab9a7366c8607f8f66bb21c \ No newline at end of file diff --git a/src/select.c b/src/select.c index cf486e5b85..c9d9637fcb 100644 --- a/src/select.c +++ b/src/select.c @@ -2369,7 +2369,7 @@ static int multiSelect( if( dest.eDest==SRT_Output ){ Select *pFirst = p; while( pFirst->pPrior ) pFirst = pFirst->pPrior; - generateColumnNames(pParse, 0, pFirst->pEList); + generateColumnNames(pParse, pFirst->pSrc, pFirst->pEList); } iBreak = sqlite3VdbeMakeLabel(v); iCont = sqlite3VdbeMakeLabel(v); @@ -2444,7 +2444,7 @@ static int multiSelect( if( dest.eDest==SRT_Output ){ Select *pFirst = p; while( pFirst->pPrior ) pFirst = pFirst->pPrior; - generateColumnNames(pParse, 0, pFirst->pEList); + generateColumnNames(pParse, pFirst->pSrc, pFirst->pEList); } iBreak = sqlite3VdbeMakeLabel(v); iCont = sqlite3VdbeMakeLabel(v); @@ -3059,7 +3059,7 @@ static int multiSelectOrderBy( if( pDest->eDest==SRT_Output ){ Select *pFirst = pPrior; while( pFirst->pPrior ) pFirst = pFirst->pPrior; - generateColumnNames(pParse, 0, pFirst->pEList); + generateColumnNames(pParse, pFirst->pSrc, pFirst->pEList); } /* Reassembly the compound query so that it will be freed correctly diff --git a/test/capi3c.test b/test/capi3c.test index 6ab3bc24f6..15307a7f7a 100644 --- a/test/capi3c.test +++ b/test/capi3c.test @@ -18,6 +18,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix capi3c # Do not use a codec for tests in this file, as the database file is # manipulated directly using tcl scripts (using the [hexio_write] command). @@ -1375,4 +1376,26 @@ do_test capi3c-24.3 { decltype {SELECT (SELECT x FROM (SELECT t5.a AS x)) FROM t5} } {INTEGER} + +# Further tests of sqlite3_column_decltype(): +# +do_execsql_test 25.0 { + CREATE TABLE t11(a VARCHAR(10), b INTEGER); + CREATE TABLE t12(a VARCHAR(15), b FLOAT); +} + +foreach {tn sql} { + 1 "SELECT * FROM t11 UNION ALL SELECT * FROM t12" + 2 "SELECT * FROM t11 UNION SELECT * FROM t12" + 3 "SELECT * FROM t11 EXCEPT SELECT * FROM t12" + 4 "SELECT * FROM t11 INTERSECT SELECT * FROM t12" + + 5 "SELECT * FROM t11 UNION ALL SELECT * FROM t12 ORDER BY 1" + 6 "SELECT * FROM t11 UNION SELECT * FROM t12 ORDER BY 1" + 7 "SELECT * FROM t11 EXCEPT SELECT * FROM t12 ORDER BY 1" + 8 "SELECT * FROM t11 INTERSECT SELECT * FROM t12 ORDER BY 1" +} { + do_test 25.$tn { decltype $sql } {VARCHAR(10) INTEGER} +} + finish_test From f7ce4291a94573cdb04e5f3fcf59ed9e69226479 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 2 Dec 2015 19:46:12 +0000 Subject: [PATCH 047/232] Remove unreachable branches from the decltype computation logic in the query planner. FossilOrigin-Name: 4f2bcff94c672312805be1400050a7026f93a9d7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/select.c | 6 ++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index c3e7dba328..123da22f21 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sthe\ssqlite3_column_decltype()\sAPI\sreport\sthe\sdeclared\stypes\sfor\sthe\sleft-most\sSELECT\sstatement\sin\sa\scompound\sSELECT. -D 2015-12-02T18:59:44.537 +C Remove\sunreachable\sbranches\sfrom\sthe\sdecltype\scomputation\slogic\sin\sthe\squery\nplanner. +D 2015-12-02T19:46:12.775 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -339,7 +339,7 @@ F src/printf.c ca05561795ad6c2fa47acdd007702586282f7feb F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c f4c897ca76ca6d5e0b3f0499c627392ffe657c8e F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c dd04f017d1402e1a8cbacb13f53c279dc48543b4 +F src/select.c 1611828a7116e5f6cc1e69cd07d59b0d2c662ea9 F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21 F src/sqlite.h.in 5bd83191711d3dc85030326daa9e8e5226a495e7 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4692ae84f93530e27d7c106a60236355e176b7fd -R cccfb2982bfd6a0aab4098f75a44ccf8 -U dan -Z e453763f88995e08cd02dca755bc7590 +P 3e1d71fcaf57c0223ab9a7366c8607f8f66bb21c +R 0397cf9717330ffe9055735c8207c81a +U drh +Z 6381d064415ccbeec9de47fb6017aaa8 diff --git a/manifest.uuid b/manifest.uuid index d924d8a8d3..c4252b6021 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e1d71fcaf57c0223ab9a7366c8607f8f66bb21c \ No newline at end of file +4f2bcff94c672312805be1400050a7026f93a9d7 \ No newline at end of file diff --git a/src/select.c b/src/select.c index c9d9637fcb..fca8665cd7 100644 --- a/src/select.c +++ b/src/select.c @@ -1340,7 +1340,8 @@ static const char *columnTypeImpl( char const *zOrigCol = 0; #endif - if( NEVER(pExpr==0) || pNC->pSrcList==0 ) return 0; + assert( pExpr!=0 ); + assert( pNC->pSrcList!=0 ); switch( pExpr->op ){ case TK_AGG_COLUMN: case TK_COLUMN: { @@ -1528,6 +1529,7 @@ static void generateColumnNames( } #endif + assert( pTabList!=0 ); if( pParse->colNamesSet || NEVER(v==0) || db->mallocFailed ) return; pParse->colNamesSet = 1; fullNames = (db->flags & SQLITE_FullColNames)!=0; @@ -1540,7 +1542,7 @@ static void generateColumnNames( if( pEList->a[i].zName ){ char *zName = pEList->a[i].zName; sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT); - }else if( (p->op==TK_COLUMN || p->op==TK_AGG_COLUMN) && pTabList ){ + }else if( p->op==TK_COLUMN || p->op==TK_AGG_COLUMN ){ Table *pTab; char *zCol; int iCol = p->iColumn; From c18ed977e8d7e9e7d0d2917013b24e8a286628df Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 3 Dec 2015 01:48:32 +0000 Subject: [PATCH 048/232] A unix VFS change replaces fsync() with fstat() when using SQLITE_NO_SYNC, so set PRAGMA synchronous=OFF in the sysfault-3 test to avoid erroneously causing errors in xSync. FossilOrigin-Name: 4f7f355021f9eb048fffc84e559bfb3fdb1e1e69 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/sysfault.test | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 123da22f21..0f6f52c4c6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunreachable\sbranches\sfrom\sthe\sdecltype\scomputation\slogic\sin\sthe\squery\nplanner. -D 2015-12-02T19:46:12.775 +C A\sunix\sVFS\schange\sreplaces\sfsync()\swith\sfstat()\swhen\susing\sSQLITE_NO_SYNC,\sso\nset\sPRAGMA\ssynchronous=OFF\sin\sthe\ssysfault-3\stest\sto\savoid\serroneously\scausing\nerrors\sin\sxSync. +D 2015-12-03T01:48:32.232 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -1054,7 +1054,7 @@ F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2 F test/symlink.test cbf6cb8c6c4b63a39e9f0f6b0d5c99e249dbc102 F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85 F test/syscall.test 2aa9e111b79fb385681ff8940124def6f8faab87 -F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6 +F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 F test/tabfunc01.test cc33684f9480fcf1fd5ce287ac28d22971cad1cc F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3e1d71fcaf57c0223ab9a7366c8607f8f66bb21c -R 0397cf9717330ffe9055735c8207c81a +P 4f2bcff94c672312805be1400050a7026f93a9d7 +R 029751c01b929451cff95b86da0868ac U drh -Z 6381d064415ccbeec9de47fb6017aaa8 +Z 7f6ec6c824be76681c81bd551b601799 diff --git a/manifest.uuid b/manifest.uuid index c4252b6021..ee47648488 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f2bcff94c672312805be1400050a7026f93a9d7 \ No newline at end of file +4f7f355021f9eb048fffc84e559bfb3fdb1e1e69 \ No newline at end of file diff --git a/test/sysfault.test b/test/sysfault.test index 92fb534dd0..4c3d34dbb9 100644 --- a/test/sysfault.test +++ b/test/sysfault.test @@ -226,6 +226,7 @@ do_faultsim_test 3 -faults vfsfault-* -prep { faultsim_delete_and_reopen file_control_chunksize_test db main 8192 execsql { + PRAGMA synchronous=OFF; CREATE TABLE t1(a, b); BEGIN; SELECT * FROM t1; From 48c06f32ca6442b8c9befeadda9c17489285e716 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 3 Dec 2015 11:51:18 +0000 Subject: [PATCH 049/232] Improve concurrency in test_multiplex.c. Add a switch to "threadtest3" allowing it to run using the multiplexor VFS. FossilOrigin-Name: 9d2c62b04e3a9ac5d9adea2aac7ec3f3bc3e88bd --- main.mk | 4 ++-- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/test_multiplex.c | 17 ++++++----------- test/threadtest3.c | 29 +++++++++++++++++++++++++++-- 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/main.mk b/main.mk index f3a37dc194..7f2cf7abd6 100644 --- a/main.mk +++ b/main.mk @@ -795,8 +795,8 @@ THREADTEST3_SRC = $(TOP)/test/threadtest3.c \ $(TOP)/test/tt3_stress.c \ $(TOP)/test/tt3_lookaside1.c -threadtest3$(EXE): sqlite3.o $(THREADTEST3_SRC) - $(TCCX) $(TOP)/test/threadtest3.c sqlite3.o -o $@ $(THREADLIB) +threadtest3$(EXE): libsqlite3.a $(THREADTEST3_SRC) $(TOP)/src/test_multiplex.c + $(TCCX) $(TOP)/test/threadtest3.c $(TOP)/src/test_multiplex.c libsqlite3.a -o $@ $(THREADLIB) threadtest: threadtest3$(EXE) ./threadtest3$(EXE) diff --git a/manifest b/manifest index 0f6f52c4c6..341bd3ac31 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C A\sunix\sVFS\schange\sreplaces\sfsync()\swith\sfstat()\swhen\susing\sSQLITE_NO_SYNC,\sso\nset\sPRAGMA\ssynchronous=OFF\sin\sthe\ssysfault-3\stest\sto\savoid\serroneously\scausing\nerrors\sin\sxSync. -D 2015-12-03T01:48:32.232 +C Improve\sconcurrency\sin\stest_multiplex.c.\sAdd\sa\sswitch\sto\s"threadtest3"\sallowing\sit\sto\srun\susing\sthe\smultiplexor\sVFS. +D 2015-12-03T11:51:18.767 F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -263,7 +263,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 9001039f432baeba1074e2d1885f3dfd572b8636 +F main.mk 2a1196d5e10ce062862b24a4cf9a985fe477de34 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -375,7 +375,7 @@ F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4 F src/test_malloc.c 8e1c2112fa4f543b46c990a8872f9e6d37938744 -F src/test_multiplex.c 9fefd23f6cc3fa9bf0748a5e453167e7b9f193ce +F src/test_multiplex.c 6a088d8d9d4aad4bec45dd8878af11b15900702d F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c F src/test_onefile.c 38f7cbe79d5bafe95bde683cc3a53b8ca16daf10 @@ -1074,7 +1074,7 @@ F test/thread2.test f35d2106452b77523b3a2b7d1dcde2e5ee8f9e46 F test/thread_common.tcl 334639cadcb9f912bf82aa73f49efd5282e6cadd F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b F test/threadtest2.c a70a8e94bef23339d34226eb9521015ef99f4df8 -F test/threadtest3.c 0707c28e0954acbef654f91675e14f3573cf9a10 +F test/threadtest3.c 469ea7fe7030d75bd67dcf8047b16c1deea5210d F test/threadtest4.c c1e67136ceb6c7ec8184e56ac61db28f96bd2925 F test/tkt-02a8e81d44.test 6c80d9c7514e2a42d4918bf87bf6bc54f379110c F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4f2bcff94c672312805be1400050a7026f93a9d7 -R 029751c01b929451cff95b86da0868ac -U drh -Z 7f6ec6c824be76681c81bd551b601799 +P 4f7f355021f9eb048fffc84e559bfb3fdb1e1e69 +R 17fe6dc83cb64fc6198b93af9ffea9ca +U dan +Z de557aa3ec0a739d4121e9d650d8e092 diff --git a/manifest.uuid b/manifest.uuid index ee47648488..3704b84542 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f7f355021f9eb048fffc84e559bfb3fdb1e1e69 \ No newline at end of file +9d2c62b04e3a9ac5d9adea2aac7ec3f3bc3e88bd \ No newline at end of file diff --git a/src/test_multiplex.c b/src/test_multiplex.c index 843a92ca65..82845ea7e1 100644 --- a/src/test_multiplex.c +++ b/src/test_multiplex.c @@ -189,8 +189,11 @@ static struct { int isInitialized; /* For run-time access any of the other global data structures in this - ** shim, the following mutex must be held. - */ + ** shim, the following mutex must be held. In practice, all this mutex + ** protects is add/remove operations to/from the linked list of group objects + ** starting at pGroups below. More specifically, it protects the value of + ** pGroups itself, and the pNext/pPrev fields of each multiplexGroup + ** structure. */ sqlite3_mutex *pMutex; /* List of multiplexGroup objects. @@ -758,11 +761,8 @@ static int multiplexRead( multiplexConn *p = (multiplexConn*)pConn; multiplexGroup *pGroup = p->pGroup; int rc = SQLITE_OK; - int nMutex = 0; - multiplexEnter(); nMutex++; if( !pGroup->bEnabled ){ sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0); - multiplexLeave(); nMutex--; if( pSubOpen==0 ){ rc = SQLITE_IOERR_READ; }else{ @@ -772,9 +772,7 @@ static int multiplexRead( while( iAmt > 0 ){ int i = (int)(iOfst / pGroup->szChunk); sqlite3_file *pSubOpen; - if( nMutex==0 ){ multiplexEnter(); nMutex++; } pSubOpen = multiplexSubOpen(pGroup, i, &rc, NULL, 1); - multiplexLeave(); nMutex--; if( pSubOpen ){ int extra = ((int)(iOfst % pGroup->szChunk) + iAmt) - pGroup->szChunk; if( extra<0 ) extra = 0; @@ -791,8 +789,7 @@ static int multiplexRead( } } } - assert( nMutex==0 || nMutex==1 ); - if( nMutex ) multiplexLeave(); + return rc; } @@ -809,7 +806,6 @@ static int multiplexWrite( multiplexConn *p = (multiplexConn*)pConn; multiplexGroup *pGroup = p->pGroup; int rc = SQLITE_OK; - multiplexEnter(); if( !pGroup->bEnabled ){ sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0); if( pSubOpen==0 ){ @@ -834,7 +830,6 @@ static int multiplexWrite( } } } - multiplexLeave(); return rc; } diff --git a/test/threadtest3.c b/test/threadtest3.c index a3fcae28cc..a0fad0f91d 100644 --- a/test/threadtest3.c +++ b/test/threadtest3.c @@ -88,6 +88,8 @@ #include #include +#include "test_multiplex.h" + /* * This code implements the MD5 message-digest algorithm. * The algorithm is due to Ron Rivest. This code was @@ -1460,13 +1462,36 @@ int main(int argc, char **argv){ argc = 2; argv = substArgv; } + + /* Loop through the command-line arguments to ensure that each argument + ** selects at least one test. If not, assume there is a typo on the + ** command-line and bail out with the usage message. */ for(iArg=1; iArg=sizeof(aTest)/sizeof(aTest[0]) ) goto usage; } + for(iArg=1; iArg0 ? 255 : 0); usage: - printf("Usage: %s [testname|testprefix*]...\n", argv[0]); + printf("Usage: %s [-multiplexor] [testname|testprefix*]...\n", argv[0]); printf("Available tests are:\n"); for(i=0; i Date: Thu, 3 Dec 2015 12:01:54 +0000 Subject: [PATCH 050/232] Fix threadtest3 so that it builds using the autoconf build system. FossilOrigin-Name: d96de532cc4a192cfebae900701dcee0a7d29273 --- Makefile.in | 2 +- main.mk | 4 ++-- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/threadtest3.c | 5 +++++ 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index f8766ac8f7..d06b3ca49d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1156,7 +1156,7 @@ THREADTEST3_SRC = $(TOP)/test/threadtest3.c \ $(TOP)/test/tt3_lookaside1.c threadtest3$(TEXE): sqlite3.lo $(THREADTEST3_SRC) - $(LTLINK) $(TOP)/test/threadtest3.c sqlite3.lo -o $@ $(TLIBS) + $(LTLINK) $(TOP)/test/threadtest3.c $(TOP)/src/test_multiplex.c sqlite3.lo -o $@ $(TLIBS) threadtest: threadtest3$(TEXE) ./threadtest3$(TEXE) diff --git a/main.mk b/main.mk index 7f2cf7abd6..398bb9d149 100644 --- a/main.mk +++ b/main.mk @@ -795,8 +795,8 @@ THREADTEST3_SRC = $(TOP)/test/threadtest3.c \ $(TOP)/test/tt3_stress.c \ $(TOP)/test/tt3_lookaside1.c -threadtest3$(EXE): libsqlite3.a $(THREADTEST3_SRC) $(TOP)/src/test_multiplex.c - $(TCCX) $(TOP)/test/threadtest3.c $(TOP)/src/test_multiplex.c libsqlite3.a -o $@ $(THREADLIB) +threadtest3$(EXE): sqlite3.o $(THREADTEST3_SRC) $(TOP)/src/test_multiplex.c + $(TCCX) $(TOP)/test/threadtest3.c $(TOP)/src/test_multiplex.c sqlite3.o -o $@ $(THREADLIB) threadtest: threadtest3$(EXE) ./threadtest3$(EXE) diff --git a/manifest b/manifest index 341bd3ac31..df6fb21669 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ -C Improve\sconcurrency\sin\stest_multiplex.c.\sAdd\sa\sswitch\sto\s"threadtest3"\sallowing\sit\sto\srun\susing\sthe\smultiplexor\sVFS. -D 2015-12-03T11:51:18.767 -F Makefile.in 23d9a63484a383fc64951b25ef44067930f98dc6 +C Fix\sthreadtest3\sso\sthat\sit\sbuilds\susing\sthe\sautoconf\sbuild\ssystem. +D 2015-12-03T12:01:54.310 +F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 @@ -263,7 +263,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 2a1196d5e10ce062862b24a4cf9a985fe477de34 +F main.mk ed77cbb97848c8dae1ab928245432f74b0580162 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1074,7 +1074,7 @@ F test/thread2.test f35d2106452b77523b3a2b7d1dcde2e5ee8f9e46 F test/thread_common.tcl 334639cadcb9f912bf82aa73f49efd5282e6cadd F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b F test/threadtest2.c a70a8e94bef23339d34226eb9521015ef99f4df8 -F test/threadtest3.c 469ea7fe7030d75bd67dcf8047b16c1deea5210d +F test/threadtest3.c 7ca82330041456afa52e4968196bb0867371f91b F test/threadtest4.c c1e67136ceb6c7ec8184e56ac61db28f96bd2925 F test/tkt-02a8e81d44.test 6c80d9c7514e2a42d4918bf87bf6bc54f379110c F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4f7f355021f9eb048fffc84e559bfb3fdb1e1e69 -R 17fe6dc83cb64fc6198b93af9ffea9ca +P 9d2c62b04e3a9ac5d9adea2aac7ec3f3bc3e88bd +R 614db3259b048bd04399b66e7b5154a7 U dan -Z de557aa3ec0a739d4121e9d650d8e092 +Z 6db6492a66042b93eb13e3c236809127 diff --git a/manifest.uuid b/manifest.uuid index 3704b84542..fbb82f11fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d2c62b04e3a9ac5d9adea2aac7ec3f3bc3e88bd \ No newline at end of file +d96de532cc4a192cfebae900701dcee0a7d29273 \ No newline at end of file diff --git a/test/threadtest3.c b/test/threadtest3.c index a0fad0f91d..8d213c61f1 100644 --- a/test/threadtest3.c +++ b/test/threadtest3.c @@ -90,6 +90,11 @@ #include "test_multiplex.h" +/* Required to link test_multiplex.c */ +#ifndef SQLITE_OMIT_WSD +int sqlite3PendingByte = 0x40000000; +#endif + /* * This code implements the MD5 message-digest algorithm. * The algorithm is due to Ron Rivest. This code was From 7be53fe441c128deff7f8f130a3833488e08d06d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 3 Dec 2015 13:43:07 +0000 Subject: [PATCH 051/232] Make the sqlite3_status64(), sqlite3_strlike(), and sqlite3_db_cacheflush() APIs available to loadable extensions. FossilOrigin-Name: a78e865607194718e2ef958879dbf549ac3c9970 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/loadext.c | 6 +++++- src/sqlite3ext.h | 4 ++++ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index df6fb21669..c5398fbeca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthreadtest3\sso\sthat\sit\sbuilds\susing\sthe\sautoconf\sbuild\ssystem. -D 2015-12-03T12:01:54.310 +C Make\sthe\ssqlite3_status64(),\ssqlite3_strlike(),\sand\nsqlite3_db_cacheflush()\sAPIs\savailable\sto\sloadable\sextensions. +D 2015-12-03T13:43:07.848 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -303,7 +303,7 @@ F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c e1d20ae8979e25519c2670233718676bedcfedc9 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e -F src/loadext.c 18586e45a215325f15096821e9c082035d4fb810 +F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b F src/main.c 3f2828fce1e45c3ad096c69eee1e96962c7281c5 F src/malloc.c 337bbe9c7d436ef9b7d06b5dd10bbfc8f3025972 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -343,7 +343,7 @@ F src/select.c 1611828a7116e5f6cc1e69cd07d59b0d2c662ea9 F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21 F src/sqlite.h.in 5bd83191711d3dc85030326daa9e8e5226a495e7 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad -F src/sqlite3ext.h 41ef50b0418a7c5ad1337bb80db5a7928dee764f +F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9d2c62b04e3a9ac5d9adea2aac7ec3f3bc3e88bd -R 614db3259b048bd04399b66e7b5154a7 -U dan -Z 6db6492a66042b93eb13e3c236809127 +P d96de532cc4a192cfebae900701dcee0a7d29273 +R ea1163e38de91a0ef50bee8a60cd0c9a +U drh +Z 21e053713b9d8cfc5b99a96ebe62cd3d diff --git a/manifest.uuid b/manifest.uuid index fbb82f11fe..619e0d1a54 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d96de532cc4a192cfebae900701dcee0a7d29273 \ No newline at end of file +a78e865607194718e2ef958879dbf549ac3c9970 \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index b6d50e96c8..94298c4763 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -410,7 +410,11 @@ static const sqlite3_api_routines sqlite3Apis = { sqlite3_bind_zeroblob64, /* Version 3.9.0 and later */ sqlite3_value_subtype, - sqlite3_result_subtype + sqlite3_result_subtype, + /* Version 3.10.0 and later */ + sqlite3_status64, + sqlite3_strlike, + sqlite3_db_cacheflush }; /* diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 3029a82fa1..2e1c764a52 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -276,7 +276,9 @@ struct sqlite3_api_routines { unsigned int (*value_subtype)(sqlite3_value*); void (*result_subtype)(sqlite3_context*,unsigned int); /* Version 3.10.0 and later */ + int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int); int (*strlike)(const char*,const char*,unsigned int); + int (*db_cacheflush)(sqlite3*); }; /* @@ -517,7 +519,9 @@ struct sqlite3_api_routines { #define sqlite3_value_subtype sqlite3_api->value_subtype #define sqlite3_result_subtype sqlite3_api->result_subtype /* Version 3.10.0 and later */ +#define sqlite3_status64 sqlite3_api->status64 #define sqlite3_strlike sqlite3_api->strlike +#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) From 90e5dda217b4d939d8609d8728dc7c3015f9c164 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 3 Dec 2015 20:42:28 +0000 Subject: [PATCH 052/232] Cleaner code and additional comments on the handling of 8+3 filenames when trying to find the name of a database file based on its journal filename, in the unix VFS. FossilOrigin-Name: 9e489a71f2aeb1f13f9ca6f106b9144d07ca25aa --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 15 +++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index c5398fbeca..ce05de0d3c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\ssqlite3_status64(),\ssqlite3_strlike(),\sand\nsqlite3_db_cacheflush()\sAPIs\savailable\sto\sloadable\sextensions. -D 2015-12-03T13:43:07.848 +C Cleaner\scode\sand\sadditional\scomments\son\sthe\shandling\sof\s8+3\sfilenames\swhen\ntrying\sto\sfind\sthe\sname\sof\sa\sdatabase\sfile\sbased\son\sits\sjournal\sfilename,\s\nin\sthe\sunix\sVFS. +D 2015-12-03T20:42:28.920 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 60997373a8d90bd17e1c0e49d11ef361b713439b +F src/os_unix.c 2563734669b06432cea640cbb4f7e9d543f227b9 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d96de532cc4a192cfebae900701dcee0a7d29273 -R ea1163e38de91a0ef50bee8a60cd0c9a +P a78e865607194718e2ef958879dbf549ac3c9970 +R 2562256032b891190294739fad90243c U drh -Z 21e053713b9d8cfc5b99a96ebe62cd3d +Z b2f15a80162f9f125f88e21b8ca96ffa diff --git a/manifest.uuid b/manifest.uuid index 619e0d1a54..2df7d425e6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a78e865607194718e2ef958879dbf549ac3c9970 \ No newline at end of file +9e489a71f2aeb1f13f9ca6f106b9144d07ca25aa \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 5f4cbca2aa..beaac0d15d 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5521,16 +5521,19 @@ static int findCreateFileMode( ** used by the test_multiplex.c module. */ nDb = sqlite3Strlen30(zPath) - 1; -#ifdef SQLITE_ENABLE_8_3_NAMES - while( nDb>0 && sqlite3Isalnum(zPath[nDb]) ) nDb--; - if( nDb==0 || zPath[nDb]!='-' ) return SQLITE_OK; -#else while( zPath[nDb]!='-' ){ +#ifndef SQLITE_ENABLE_8_3_NAMES + /* In the normal case (8+3 filenames disabled) the journal filename + ** is guaranteed to contain a '-' character. */ assert( nDb>0 ); - assert( zPath[nDb]!='\n' ); + assert( sqlite3Isalnum(zPath[nDb]) ); +#else + /* If 8+3 names are possible, then the journal file might not contain + ** a '-' character. So check for that case and return early. */ + if( nDb==0 || zPath[nDb]=='.' ) return SQLITE_OK; +#endif nDb--; } -#endif memcpy(zDb, zPath, nDb); zDb[nDb] = '\0'; From 7a7f688979fafb7f345db9463d8b8991606ba410 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 3 Dec 2015 20:50:10 +0000 Subject: [PATCH 053/232] Make the SQLITE_ENABLE_8_3_NAMES compile-time option available to sqlite3_compileoption_used(). FossilOrigin-Name: 06338201f3f00151232e5c6a40edcdbea04d7553 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/ctime.c | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index ce05de0d3c..f8bc4600fb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Cleaner\scode\sand\sadditional\scomments\son\sthe\shandling\sof\s8+3\sfilenames\swhen\ntrying\sto\sfind\sthe\sname\sof\sa\sdatabase\sfile\sbased\son\sits\sjournal\sfilename,\s\nin\sthe\sunix\sVFS. -D 2015-12-03T20:42:28.920 +C Make\sthe\sSQLITE_ENABLE_8_3_NAMES\scompile-time\soption\savailable\sto\nsqlite3_compileoption_used(). +D 2015-12-03T20:50:10.543 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -288,7 +288,7 @@ F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f -F src/ctime.c 58eda76364fb6f374e044aa4493219b13abf9400 +F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a78e865607194718e2ef958879dbf549ac3c9970 -R 2562256032b891190294739fad90243c +P 9e489a71f2aeb1f13f9ca6f106b9144d07ca25aa +R 75c2a8b340ff172a704bb3359504d6a3 U drh -Z b2f15a80162f9f125f88e21b8ca96ffa +Z b1df76d2c021fec1e48360d9f33aa631 diff --git a/manifest.uuid b/manifest.uuid index 2df7d425e6..fe02ea2e6e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e489a71f2aeb1f13f9ca6f106b9144d07ca25aa \ No newline at end of file +06338201f3f00151232e5c6a40edcdbea04d7553 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index c3149ad913..f1bb69c16a 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -63,6 +63,9 @@ static const char * const azCompileOpt[] = { #if SQLITE_DISABLE_LFS "DISABLE_LFS", #endif +#if SQLITE_ENABLE_8_3_NAMES + "ENABLE_8_3_NAMES", +#endif #if SQLITE_ENABLE_API_ARMOR "ENABLE_API_ARMOR", #endif From 9802947fd88ece99796b444e06f918b6578fe3ab Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 3 Dec 2015 21:47:30 +0000 Subject: [PATCH 054/232] Improved OOM recovery in the SELECT code generator logic. FossilOrigin-Name: e6521a436d464a42b87a7d5ba5cc98235b92440a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f8bc4600fb..f20b0b8fdd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\sSQLITE_ENABLE_8_3_NAMES\scompile-time\soption\savailable\sto\nsqlite3_compileoption_used(). -D 2015-12-03T20:50:10.543 +C Improved\sOOM\srecovery\sin\sthe\sSELECT\scode\sgenerator\slogic. +D 2015-12-03T21:47:30.716 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -339,7 +339,7 @@ F src/printf.c ca05561795ad6c2fa47acdd007702586282f7feb F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c f4c897ca76ca6d5e0b3f0499c627392ffe657c8e F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c 1611828a7116e5f6cc1e69cd07d59b0d2c662ea9 +F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21 F src/sqlite.h.in 5bd83191711d3dc85030326daa9e8e5226a495e7 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9e489a71f2aeb1f13f9ca6f106b9144d07ca25aa -R 75c2a8b340ff172a704bb3359504d6a3 +P 06338201f3f00151232e5c6a40edcdbea04d7553 +R 145702191e68cee758981a8fb775b160 U drh -Z b1df76d2c021fec1e48360d9f33aa631 +Z 9a3c93cbb014714fd53297dd3e278abb diff --git a/manifest.uuid b/manifest.uuid index fe02ea2e6e..f6d2d01ac4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -06338201f3f00151232e5c6a40edcdbea04d7553 \ No newline at end of file +e6521a436d464a42b87a7d5ba5cc98235b92440a \ No newline at end of file diff --git a/src/select.c b/src/select.c index fca8665cd7..f8b8e9e77f 100644 --- a/src/select.c +++ b/src/select.c @@ -1529,8 +1529,9 @@ static void generateColumnNames( } #endif + if( pParse->colNamesSet || db->mallocFailed ) return; + assert( v!=0 ); assert( pTabList!=0 ); - if( pParse->colNamesSet || NEVER(v==0) || db->mallocFailed ) return; pParse->colNamesSet = 1; fullNames = (db->flags & SQLITE_FullColNames)!=0; shortNames = (db->flags & SQLITE_ShortColNames)!=0; From 15427279c89f766e8ec8519e92c0ddd49d5af22a Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 3 Dec 2015 22:33:55 +0000 Subject: [PATCH 055/232] Fix typos in requirements text and update requirements marks. No changes to code. FossilOrigin-Name: 8534a46c06601ad35b97caee442371f24c718d0f --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/main.c | 7 ++++--- src/resolve.c | 3 +-- src/sqlite.h.in | 2 +- test/pragma2.test | 9 +++++++-- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index f20b0b8fdd..f2736d883d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sOOM\srecovery\sin\sthe\sSELECT\scode\sgenerator\slogic. -D 2015-12-03T21:47:30.716 +C Fix\stypos\sin\srequirements\stext\sand\supdate\srequirements\smarks.\s\sNo\schanges\nto\scode. +D 2015-12-03T22:33:55.362 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -304,7 +304,7 @@ F src/insert.c e1d20ae8979e25519c2670233718676bedcfedc9 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b -F src/main.c 3f2828fce1e45c3ad096c69eee1e96962c7281c5 +F src/main.c a950e48920e8c0f0ff82b2b2ccfe11aa89ca11d4 F src/malloc.c 337bbe9c7d436ef9b7d06b5dd10bbfc8f3025972 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -337,11 +337,11 @@ F src/pragma.h 3d94aebbebd2089899fecc01909bf2608b39507d F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 F src/printf.c ca05561795ad6c2fa47acdd007702586282f7feb F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c f4c897ca76ca6d5e0b3f0499c627392ffe657c8e +F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21 -F src/sqlite.h.in 5bd83191711d3dc85030326daa9e8e5226a495e7 +F src/sqlite.h.in 1248a78548024bdc8ef5893faa0ff9552b4cceb4 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 @@ -934,7 +934,7 @@ F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff F test/permutations.test 4ea119731c62d2f7d0aa86dd5b184cbb61ca411b F test/pragma.test a44253f911e7d50127d4a08f927f47c861a4c772 -F test/pragma2.test 00065068eeab2d15ea55465ec0f1e0a70e2c369e +F test/pragma2.test a9400a7289605280576098b97f5cde3f204075c0 F test/pragma3.test 6f849ccffeee7e496d2f2b5e74152306c0b8757c F test/printf.test b3ff34e73d59124140eaf89f7672e21bc2ca5fcc F test/printf2.test 0b61566dd1c0f0b802f59dffa228c5dc5aa6b054 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 06338201f3f00151232e5c6a40edcdbea04d7553 -R 145702191e68cee758981a8fb775b160 +P e6521a436d464a42b87a7d5ba5cc98235b92440a +R 846383f75bcba4c7d26192303dc02f09 U drh -Z 9a3c93cbb014714fd53297dd3e278abb +Z be77de4336a8b095fa17ae32142959b3 diff --git a/manifest.uuid b/manifest.uuid index f6d2d01ac4..1f813c303c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e6521a436d464a42b87a7d5ba5cc98235b92440a \ No newline at end of file +8534a46c06601ad35b97caee442371f24c718d0f \ No newline at end of file diff --git a/src/main.c b/src/main.c index 2bcecdb78b..d552f7fbc8 100644 --- a/src/main.c +++ b/src/main.c @@ -445,9 +445,10 @@ int sqlite3_config(int op, ...){ break; } case SQLITE_CONFIG_PAGECACHE: { - /* EVIDENCE-OF: R-31408-40510 There are three arguments to - ** SQLITE_CONFIG_PAGECACHE: A pointer to 8-byte aligned memory, the size - ** of each page buffer (sz), and the number of pages (N). */ + /* EVIDENCE-OF: R-18761-36601 There are three arguments to + ** SQLITE_CONFIG_PAGECACHE: A pointer to 8-byte aligned memory (pMem), + ** the size of each page cache line (sz), and the number of cache lines + ** (N). */ sqlite3GlobalConfig.pPage = va_arg(ap, void*); sqlite3GlobalConfig.szPage = va_arg(ap, int); sqlite3GlobalConfig.nPage = va_arg(ap, int); diff --git a/src/resolve.c b/src/resolve.c index b3e887778d..bb6646256a 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -328,7 +328,6 @@ static int lookupName( } if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){ /* IMP: R-51414-32910 */ - /* IMP: R-44911-55124 */ iCol = -1; } if( iColnCol ){ @@ -363,7 +362,7 @@ static int lookupName( && VisibleRowid(pMatch->pTab) ){ cnt = 1; - pExpr->iColumn = -1; /* IMP: R-44911-55124 */ + pExpr->iColumn = -1; pExpr->affinity = SQLITE_AFF_INTEGER; } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 6ad3da5df2..e797571062 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -887,7 +887,7 @@ struct sqlite3_io_methods { ** [VFSes] currently in use. ^(The argument X in ** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be ** of type "[sqlite3_vfs] **". This opcodes will set *X -** to a pointer to the top-level VFS.^) +** to a pointer to the top-level VFS.)^ ** ^When there are multiple VFS shims in the stack, this opcode finds the ** upper-most shim only. ** diff --git a/test/pragma2.test b/test/pragma2.test index 64b396bd1f..a4fb2ce657 100644 --- a/test/pragma2.test +++ b/test/pragma2.test @@ -125,8 +125,8 @@ ifcapable attach { # Default setting of PRAGMA cache_spill is always ON # -# EVIDENCE-OF: R-51036-62828 PRAGMA cache_spill; PRAGMA -# cache_spill=boolean; +# EVIDENCE-OF: R-63549-59887 PRAGMA cache_spill; PRAGMA +# cache_spill=boolean; PRAGMA schema.cache_spill=N; # # EVIDENCE-OF: R-23955-02765 Cache_spill is enabled by default # @@ -190,6 +190,11 @@ do_test pragma2-4.5.1 { PRAGMA lock_status; } } {0 main reserved temp unknown} ;# No cache spill, so no exclusive lock + + +# EVIDENCE-OF: R-34657-61226 The "PRAGMA cache_spill=N" form of this +# pragma sets a minimum cache size threshold required for spilling to +# occur. do_test pragma2-4.5.2 { db eval { ROLLBACK; From 2f5bfd959a389037eb46e4c6e8e50fc3cd9c05bb Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 4 Dec 2015 03:27:45 +0000 Subject: [PATCH 056/232] Prevent a segfault on Solaris in the test_fs.c due to differences in the definition of the dirent object. FossilOrigin-Name: 042738ad3b769ad70fd7603f928d5b94a952267d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test_fs.c | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f2736d883d..88e6966481 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypos\sin\srequirements\stext\sand\supdate\srequirements\smarks.\s\sNo\schanges\nto\scode. -D 2015-12-03T22:33:55.362 +C Prevent\sa\ssegfault\son\sSolaris\sin\sthe\stest_fs.c\sdue\sto\sdifferences\sin\sthe\ndefinition\sof\sthe\sdirent\sobject. +D 2015-12-04T03:27:45.044 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -366,7 +366,7 @@ F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f F src/test_config.c 48850687dd5abc8260e23835632511054ccae172 F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc -F src/test_fs.c aab47ac456316502faa265daadf9ac832fea12b9 +F src/test_fs.c 993c7eab65bed6add4bb48cca29775e963f710cf F src/test_func.c 0d9c25956152adefee8881c6fadc8354793764d0 F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e6521a436d464a42b87a7d5ba5cc98235b92440a -R 846383f75bcba4c7d26192303dc02f09 +P 8534a46c06601ad35b97caee442371f24c718d0f +R 3f397aa5ab8af4d521cc061fb2695078 U drh -Z be77de4336a8b095fa17ae32142959b3 +Z 11a613e2a3c9a8773b81f1dda236b457 diff --git a/manifest.uuid b/manifest.uuid index 1f813c303c..0adeb79067 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8534a46c06601ad35b97caee442371f24c718d0f \ No newline at end of file +042738ad3b769ad70fd7603f928d5b94a952267d \ No newline at end of file diff --git a/src/test_fs.c b/src/test_fs.c index de332fa2f5..ab6bed8a95 100644 --- a/src/test_fs.c +++ b/src/test_fs.c @@ -202,7 +202,10 @@ static int fsdirBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ */ static int fsdirOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ FsdirCsr *pCur; - pCur = (FsdirCsr*)sqlite3_malloc(sizeof(FsdirCsr)); + /* Allocate an extra 256 bytes because it is undefined how big dirent.d_name + ** is and we need enough space. Linux provides plenty already, but + ** Solaris only provides one byte. */ + pCur = (FsdirCsr*)sqlite3_malloc(sizeof(FsdirCsr)+256); if( pCur==0 ) return SQLITE_NOMEM; memset(pCur, 0, sizeof(FsdirCsr)); *ppCursor = &pCur->base; From 28a6a1168b8352161035a10c8c459eae77187657 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 4 Dec 2015 13:44:07 +0000 Subject: [PATCH 057/232] Remove the dependence on "exec ls -U" from the vtabH.test module, as the -U option to "ls" is not universally available. FossilOrigin-Name: 4ecbc75b465533cf80e166a9d0879b9afd3fe2be --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/vtabH.test | 4 +--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 88e6966481..00191f9fd0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\sa\ssegfault\son\sSolaris\sin\sthe\stest_fs.c\sdue\sto\sdifferences\sin\sthe\ndefinition\sof\sthe\sdirent\sobject. -D 2015-12-04T03:27:45.044 +C Remove\sthe\sdependence\son\s"exec\sls\s-U"\sfrom\sthe\svtabH.test\smodule,\sas\sthe\s-U\noption\sto\s"ls"\sis\snot\suniversally\savailable. +D 2015-12-04T13:44:07.797 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -1276,7 +1276,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test 2803a8773d1017ac93bbec6900fc7c35bb56c1c3 +F test/vtabH.test f77296bbf55675b72817cc10fbbcb236ac986abf F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8534a46c06601ad35b97caee442371f24c718d0f -R 3f397aa5ab8af4d521cc061fb2695078 +P 042738ad3b769ad70fd7603f928d5b94a952267d +R d4a001dfc820878042f471ef37d7e668 U drh -Z 11a613e2a3c9a8773b81f1dda236b457 +Z 2a98a6e0179300d3f1024c7c0c5f05bd diff --git a/manifest.uuid b/manifest.uuid index 0adeb79067..b3054dd7aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -042738ad3b769ad70fd7603f928d5b94a952267d \ No newline at end of file +4ecbc75b465533cf80e166a9d0879b9afd3fe2be \ No newline at end of file diff --git a/test/vtabH.test b/test/vtabH.test index 6034d95fa1..7973819bd1 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -125,7 +125,7 @@ if {1} { } return $res } else { - return [exec ls -U /] + return [string map {/ {}} [glob /*]] } } @@ -214,5 +214,3 @@ if {1} { finish_test - - From fc1acf33b88a23a7475aaa14287a72044674fcda Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 5 Dec 2015 20:51:54 +0000 Subject: [PATCH 058/232] Add untested implementations of experimental APIs sqlite3_snapshot_get(), _open() and _free(). FossilOrigin-Name: 0715eb00aa8891400cd50a15509d3d7b13789626 --- manifest | 29 +++++++++-------- manifest.uuid | 2 +- src/main.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++ src/pager.c | 28 ++++++++++++++++ src/pager.h | 4 +++ src/sqlite.h.in | 23 +++++++++++++ src/test1.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ src/wal.c | 78 +++++++++++++++++++++++++++++++++++++++++--- src/wal.h | 5 +++ 9 files changed, 320 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 00191f9fd0..2447acbb5a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sdependence\son\s"exec\sls\s-U"\sfrom\sthe\svtabH.test\smodule,\sas\sthe\s-U\noption\sto\s"ls"\sis\snot\suniversally\savailable. -D 2015-12-04T13:44:07.797 +C Add\suntested\simplementations\sof\sexperimental\sAPIs\ssqlite3_snapshot_get(),\s_open()\sand\s_free(). +D 2015-12-05T20:51:54.748 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -304,7 +304,7 @@ F src/insert.c e1d20ae8979e25519c2670233718676bedcfedc9 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b -F src/main.c a950e48920e8c0f0ff82b2b2ccfe11aa89ca11d4 +F src/main.c 3dc84d9bd722fb16c196a867d39acf86b8f72b70 F src/malloc.c 337bbe9c7d436ef9b7d06b5dd10bbfc8f3025972 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -326,8 +326,8 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 2563734669b06432cea640cbb4f7e9d543f227b9 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c f92aacd5216d8815136c9e0190041783c602641a -F src/pager.h 9153c71a89dc82a5a77e485f3929792116c70aae +F src/pager.c 58d2593612acb6b542de6715b4af397ea1fa0a35 +F src/pager.h bf25005b4656cd805af43487c3139fca9678d0cc F src/parse.y 23737e649c26ce327603799e57f5c2ff50e5e6ba F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 F src/pcache.h 1ff11adce609ba7de139b6abfabaf9a2bac947b5 @@ -341,7 +341,7 @@ F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21 -F src/sqlite.h.in 1248a78548024bdc8ef5893faa0ff9552b4cceb4 +F src/sqlite.h.in fc8a2875a318df1b9dabd82cb00b1ac98081423a F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 @@ -349,7 +349,7 @@ F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e F src/tclsqlite.c d9439b6a910985b7fff43ba6756bcef00de22649 -F src/test1.c 4004bcc1b3b361a9137acd1d875599ecbdd6f961 +F src/test1.c de18fc36e0830039058e9829ac201bb203d31718 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c a8887dabbbee3059af338f20d290084a63ed1b0f F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -415,8 +415,8 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 1569802364cd192bbd5c4a8ea3fd6de593edecbd -F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 +F src/wal.c b9b1d5a1dd6e9b4f14f62326f34d719d14b33f08 +F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 F src/whereInt.h e20801d89e34de1912bb6a3babb30c390da27add @@ -1408,7 +1408,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 042738ad3b769ad70fd7603f928d5b94a952267d -R d4a001dfc820878042f471ef37d7e668 -U drh -Z 2a98a6e0179300d3f1024c7c0c5f05bd +P 4ecbc75b465533cf80e166a9d0879b9afd3fe2be +R 89117c604019561442a571d3627293e1 +T *branch * snapshot-get +T *sym-snapshot-get * +T -sym-trunk * +U dan +Z 6ebcf0f2bc9e753be007db23f7cb64c3 diff --git a/manifest.uuid b/manifest.uuid index b3054dd7aa..f4219011d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4ecbc75b465533cf80e166a9d0879b9afd3fe2be \ No newline at end of file +0715eb00aa8891400cd50a15509d3d7b13789626 \ No newline at end of file diff --git a/src/main.c b/src/main.c index d552f7fbc8..902954b60d 100644 --- a/src/main.c +++ b/src/main.c @@ -3866,3 +3866,85 @@ int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){ pBt = sqlite3DbNameToBtree(db, zDbName); return pBt ? sqlite3BtreeIsReadonly(pBt) : -1; } + +#ifdef SQLITE_ENABLE_SNAPSHOT +/* +** Obtain a snapshot handle for the snapshot of database zDb currently +** being read by handle db. +*/ +int sqlite3_snapshot_get( + sqlite3 *db, + const char *zDb, + sqlite3_snapshot **ppSnapshot +){ + int rc = SQLITE_ERROR; +#ifndef SQLITE_OMIT_WAL + int iDb; + +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ){ + return SQLITE_MISUSE_BKPT; + } +#endif + sqlite3_mutex_enter(db->mutex); + + iDb = sqlite3FindDbName(db, zDb); + if( iDb==0 || iDb>1 ){ + Btree *pBt = db->aDb[iDb].pBt; + if( 0!=sqlite3BtreeIsInReadTrans(pBt) + && 0==sqlite3BtreeIsInTrans(pBt) + ){ + rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot); + } + } + + sqlite3_mutex_leave(db->mutex); +#endif /* SQLITE_OMIT_WAL */ + return rc; +} + +/* +** Open a read-transaction on the snapshot idendified by pSnapshot. +*/ +int sqlite3_snapshot_open( + sqlite3 *db, + const char *zDb, + sqlite3_snapshot *pSnapshot +){ + int rc = SQLITE_ERROR; +#ifndef SQLITE_OMIT_WAL + +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ){ + return SQLITE_MISUSE_BKPT; + } +#endif + sqlite3_mutex_enter(db->mutex); + if( db->autoCommit==0 ){ + int iDb; + iDb = sqlite3FindDbName(db, zDb); + if( iDb==0 || iDb>1 ){ + Btree *pBt = db->aDb[iDb].pBt; + if( 0==sqlite3BtreeIsInReadTrans(pBt) ){ + rc = sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), pSnapshot); + if( rc==SQLITE_OK ){ + rc = sqlite3BtreeBeginTrans(pBt, 0); + sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), 0); + } + } + } + } + + sqlite3_mutex_leave(db->mutex); +#endif /* SQLITE_OMIT_WAL */ + return rc; +} + +/* +** Free a snapshot handle obtained from sqlite3_snapshot_get(). +*/ +void sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){ + sqlite3_free(pSnapshot); +} +#endif /* SQLITE_ENABLE_SNAPSHOT */ + diff --git a/src/pager.c b/src/pager.c index bf74eac549..2c8dceb750 100644 --- a/src/pager.c +++ b/src/pager.c @@ -7301,6 +7301,34 @@ int sqlite3PagerCloseWal(Pager *pPager){ return rc; } +#ifdef SQLITE_ENABLE_SNAPSHOT +/* +** If this is a WAL database, obtain a snapshot handle for the snapshot +** currently open. Otherwise, return an error. +*/ +int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot){ + int rc = SQLITE_ERROR; + if( pPager->pWal ){ + rc = sqlite3WalSnapshotGet(pPager->pWal, ppSnapshot); + } + return rc; +} + +/* +** If this is a WAL database, store a pointer to pSnapshot. Next time a +** read transaction is opened, attempt to read from the snapshot it +** identifies. If this is not a WAL database, return an error. +*/ +int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot){ + int rc = SQLITE_OK; + if( pPager->pWal ){ + sqlite3WalSnapshotOpen(pPager->pWal, pSnapshot); + }else{ + rc = SQLITE_ERROR; + } + return rc; +} +#endif /* SQLITE_ENABLE_SNAPSHOT */ #endif /* !SQLITE_OMIT_WAL */ #ifdef SQLITE_ENABLE_ZIPVFS diff --git a/src/pager.h b/src/pager.h index cf9cda625d..ba4eec438d 100644 --- a/src/pager.h +++ b/src/pager.h @@ -168,6 +168,10 @@ int sqlite3PagerSharedLock(Pager *pPager); int sqlite3PagerWalCallback(Pager *pPager); int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); int sqlite3PagerCloseWal(Pager *pPager); +# ifdef SQLITE_ENABLE_SNAPSHOT + int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot); + int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot); +# endif #endif #ifdef SQLITE_ENABLE_ZIPVFS diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e797571062..e8940b5e08 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -7878,6 +7878,29 @@ void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*); */ int sqlite3_db_cacheflush(sqlite3*); +/* +** CAPI3REF: Open old database snapshots. +** +** The second argument passed to sqlite3_snapshot_get() must be the name +** of a database file attached to the database handle passed as the first. +** The database handle must have an open read transaction on the named +** database, which must be in wal mode. +** +** If successful, sqlite3_snapshot_get() sets *ppSnapshot to point to a new +** snapshot handle that may be used with sqlite3_snapshot_open() and returns +** SQLITE_OK. +** +** If the specified database does not exist, or is not a wal mode database, +** or the database handle does not have an open read transaction on it, +** SQLITE_ERROR is returned. If any other error occurs, for example an IO +** error or an OOM condition, the corresponding SQLite error code is +** returned. +*/ +typedef struct sqlite3_snapshot sqlite3_snapshot; +int sqlite3_snapshot_get(sqlite3*, const char*, sqlite3_snapshot **ppSnapshot); +int sqlite3_snapshot_open(sqlite3*, const char*, sqlite3_snapshot*); +void sqlite3_snapshot_free(sqlite3_snapshot*); + /* ** Undo the hack that converts floating point types to integer for ** builds on processors without floating point support. diff --git a/src/test1.c b/src/test1.c index 186e4e4684..31f506ea4f 100644 --- a/src/test1.c +++ b/src/test1.c @@ -2269,6 +2269,88 @@ static int vfsCurrentTimeInt64( return TCL_OK; } +/* +** Usage: sqlite3_snapshot_get DB DBNAME +*/ +static int test_snapshot_get( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + int rc; + sqlite3 *db; + char *zName; + sqlite3_snapshot *pSnapshot = 0; + + if( objc!=3 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); + return TCL_ERROR; + } + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; + zName = Tcl_GetString(objv[2]); + + rc = sqlite3_snapshot_get(db, zName, &pSnapshot); + if( rc!=SQLITE_OK ){ + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); + return TCL_ERROR; + }else{ + char zBuf[100]; + if( sqlite3TestMakePointerStr(interp, zBuf, pSnapshot) ) return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_NewStringObj(zBuf, -1)); + } + return TCL_OK; +} + +/* +** Usage: sqlite3_snapshot_open DB DBNAME SNAPSHOT +*/ +static int test_snapshot_open( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + int rc; + sqlite3 *db; + char *zName; + sqlite3_snapshot *pSnapshot; + + if( objc!=4 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME SNAPSHOT"); + return TCL_ERROR; + } + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; + zName = Tcl_GetString(objv[2]); + pSnapshot = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[3])); + + rc = sqlite3_snapshot_open(db, zName, pSnapshot); + if( rc!=SQLITE_OK ){ + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); + return TCL_ERROR; + } + return TCL_OK; +} + +/* +** Usage: sqlite3_snapshot_free SNAPSHOT +*/ +static int test_snapshot_free( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_snapshot *pSnapshot; + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "SNAPSHOT"); + return TCL_ERROR; + } + pSnapshot = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[1])); + sqlite3_snapshot_free(pSnapshot); + return TCL_OK; +} + /* ** Usage: sqlite3_next_stmt DB STMT ** @@ -7083,6 +7165,11 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_config_sqllog", test_config_sqllog, 0 }, #endif { "vfs_current_time_int64", vfsCurrentTimeInt64, 0 }, +#ifdef SQLITE_ENABLE_SNAPSHOT + { "sqlite3_snapshot_get", test_snapshot_get, 0 }, + { "sqlite3_snapshot_open", test_snapshot_open, 0 }, + { "sqlite3_snapshot_free", test_snapshot_free, 0 }, +#endif }; static int bitmask_size = sizeof(Bitmask)*8; static int longdouble_size = sizeof(LONGDOUBLE_TYPE); diff --git a/src/wal.c b/src/wal.c index 144db27a30..c4823c7cd2 100644 --- a/src/wal.c +++ b/src/wal.c @@ -434,6 +434,9 @@ struct Wal { #ifdef SQLITE_DEBUG u8 lockError; /* True if a locking error has occurred */ #endif +#ifdef SQLITE_ENABLE_SNAPSHOT + WalIndexHdr *pSnapshot; +#endif }; /* @@ -2147,6 +2150,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ int mxI; /* Index of largest aReadMark[] value */ int i; /* Loop counter */ int rc = SQLITE_OK; /* Return code */ + int mxFrame; /* Wal frame to lock to */ assert( pWal->readLock<0 ); /* Not currently locked */ @@ -2210,7 +2214,12 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ } pInfo = walCkptInfo(pWal); - if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame ){ + if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame +#ifdef SQLITE_ENABLE_SNAPSHOT + && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0 + || 0==memcmp(&pWal->hdr, pWal->pSnapshot, sizeof(WalIndexHdr))) +#endif + ){ /* The WAL has been completely backfilled (or it is empty). ** and can be safely ignored. */ @@ -2248,9 +2257,13 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ */ mxReadMark = 0; mxI = 0; + mxFrame = pWal->hdr.mxFrame; +#ifdef SQLITE_ENABLE_SNAPSHOT + if( pWal->pSnapshot ) mxFrame = pWal->pSnapshot->mxFrame; +#endif for(i=1; iaReadMark[i]; - if( mxReadMark<=thisMark && thisMark<=pWal->hdr.mxFrame ){ + if( mxReadMark<=thisMark && thisMark<=mxFrame ){ assert( thisMark!=READMARK_NOT_USED ); mxReadMark = thisMark; mxI = i; @@ -2259,12 +2272,12 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ /* There was once an "if" here. The extra "{" is to preserve indentation. */ { if( (pWal->readOnly & WAL_SHM_RDONLY)==0 - && (mxReadMarkhdr.mxFrame || mxI==0) + && (mxReadMarkaReadMark[i] = pWal->hdr.mxFrame; + mxReadMark = pInfo->aReadMark[i] = mxFrame; mxI = i; walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); break; @@ -2349,6 +2362,14 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ int rc; /* Return code */ int cnt = 0; /* Number of TryBeginRead attempts */ +#ifdef SQLITE_ENABLE_SNAPSHOT + int bChanged = 0; + WalIndexHdr *pSnapshot = pWal->pSnapshot; + if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))){ + bChanged = 1; + } +#endif + do{ rc = walTryBeginRead(pWal, pChanged, 0, ++cnt); }while( rc==WAL_RETRY ); @@ -2356,6 +2377,32 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ testcase( (rc&0xff)==SQLITE_IOERR ); testcase( rc==SQLITE_PROTOCOL ); testcase( rc==SQLITE_OK ); + +#ifdef SQLITE_ENABLE_SNAPSHOT + if( rc==SQLITE_OK ){ + if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr)) ){ + volatile WalCkptInfo *pInfo = walCkptInfo(pWal); + rc = walLockShared(pWal, WAL_READ_LOCK(0)); + if( rc==SQLITE_OK ){ + if( pInfo->nBackfill<=pSnapshot->mxFrame + && pSnapshot->aSalt[0]==pWal->hdr.aSalt[0] + && pSnapshot->aSalt[1]==pWal->hdr.aSalt[1] + ){ + assert( pWal->readLock>0 ); + assert( pInfo->aReadMark[pWal->readLock]<=pSnapshot->mxFrame ); + memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr)); + *pChanged = bChanged; + }else{ + rc = SQLITE_BUSY_SNAPSHOT; + } + walUnlockShared(pWal, WAL_READ_LOCK(0)); + } + if( rc!=SQLITE_OK ){ + sqlite3WalEndReadTransaction(pWal); + } + } + } +#endif return rc; } @@ -3165,6 +3212,29 @@ int sqlite3WalHeapMemory(Wal *pWal){ return (pWal && pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ); } +#ifdef SQLITE_ENABLE_SNAPSHOT +int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){ + int rc = SQLITE_OK; + WalIndexHdr *pRet; + + assert( pWal->readLock>=0 && pWal->writeLock==0 ); + + pRet = (WalIndexHdr*)sqlite3_malloc(sizeof(WalIndexHdr)); + if( pRet==0 ){ + rc = SQLITE_NOMEM; + }else{ + memcpy(pRet, &pWal->hdr, sizeof(WalIndexHdr)); + *ppSnapshot = (sqlite3_snapshot*)pRet; + } + + return rc; +} + +void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot){ + pWal->pSnapshot = (WalIndexHdr*)pSnapshot; +} +#endif /* SQLITE_ENABLE_SNAPSHOT */ + #ifdef SQLITE_ENABLE_ZIPVFS /* ** If the argument is not NULL, it points to a Wal object that holds a diff --git a/src/wal.h b/src/wal.h index 092546354b..94a049493e 100644 --- a/src/wal.h +++ b/src/wal.h @@ -126,6 +126,11 @@ int sqlite3WalExclusiveMode(Wal *pWal, int op); */ int sqlite3WalHeapMemory(Wal *pWal); +#ifdef SQLITE_ENABLE_SNAPSHOT +int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot); +void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot); +#endif + #ifdef SQLITE_ENABLE_ZIPVFS /* If the WAL file is not empty, return the number of bytes of content ** stored in each frame (i.e. the db page-size when the WAL was created). From 818b11aebba69c0aee29030075c19aa100683aa6 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 7 Dec 2015 14:33:07 +0000 Subject: [PATCH 059/232] Add tests for snapshot_get(), _open() and _free(). FossilOrigin-Name: 502cc6f353358946080d9bcd335aed526825b88a --- manifest | 16 ++-- manifest.uuid | 2 +- src/wal.c | 4 +- test/snapshot.test | 218 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 229 insertions(+), 11 deletions(-) create mode 100644 test/snapshot.test diff --git a/manifest b/manifest index 2447acbb5a..1e9eafc39e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\suntested\simplementations\sof\sexperimental\sAPIs\ssqlite3_snapshot_get(),\s_open()\sand\s_free(). -D 2015-12-05T20:51:54.748 +C Add\stests\sfor\ssnapshot_get(),\s_open()\sand\s_free(). +D 2015-12-07T14:33:07.393 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c b9b1d5a1dd6e9b4f14f62326f34d719d14b33f08 +F src/wal.c abce669053edf5cd1cd1751d654d48d74ed47839 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1020,6 +1020,7 @@ F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b +F test/snapshot.test 061dc75b77ca65c0e9c5976499625abe5be7a5c0 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 F test/sort.test 3f492e5b7be1d3f756728d2ff6edf4f6091e84cb @@ -1408,10 +1409,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4ecbc75b465533cf80e166a9d0879b9afd3fe2be -R 89117c604019561442a571d3627293e1 -T *branch * snapshot-get -T *sym-snapshot-get * -T -sym-trunk * +P 0715eb00aa8891400cd50a15509d3d7b13789626 +R e71fd4e8a4bba215d14ff5f093a4f95d U dan -Z 6ebcf0f2bc9e753be007db23f7cb64c3 +Z b314e37499d3a0450136f5ece5d06812 diff --git a/manifest.uuid b/manifest.uuid index f4219011d6..d3b0195b25 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0715eb00aa8891400cd50a15509d3d7b13789626 \ No newline at end of file +502cc6f353358946080d9bcd335aed526825b88a \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index c4823c7cd2..49811fb9b4 100644 --- a/src/wal.c +++ b/src/wal.c @@ -2259,7 +2259,9 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ mxI = 0; mxFrame = pWal->hdr.mxFrame; #ifdef SQLITE_ENABLE_SNAPSHOT - if( pWal->pSnapshot ) mxFrame = pWal->pSnapshot->mxFrame; + if( pWal->pSnapshot && pWal->pSnapshot->mxFramepSnapshot->mxFrame; + } #endif for(i=1; iaReadMark[i]; diff --git a/test/snapshot.test b/test/snapshot.test new file mode 100644 index 0000000000..4d94225701 --- /dev/null +++ b/test/snapshot.test @@ -0,0 +1,218 @@ +# 2015 December 7 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing the SELECT statement. +# +# $Id: select1.test,v 1.70 2009/05/28 01:00:56 drh Exp $ + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix snapshot + +#------------------------------------------------------------------------- +# Check some error conditions in snapshot_get(). It is an error if: +# +# 1) snapshot_get() is called on a non-WAL database. +# 2) there is no open read transaction on the database, or +# 3) there is an open write transaction on the database. +# +do_execsql_test 1.0 { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2); + INSERT INTO t1 VALUES(3, 4); +} + +do_test 1.1.1 { + execsql { BEGIN; SELECT * FROM t1; } + list [catch { sqlite3_snapshot_get db main } msg] $msg +} {1 SQLITE_ERROR} +do_execsql_test 1.1.2 COMMIT + +do_test 1.2.1 { + execsql { + PRAGMA journal_mode = wal; + INSERT INTO t1 VALUES(5, 6); + } + list [catch { sqlite3_snapshot_get db main } msg] $msg +} {1 SQLITE_ERROR} + +do_test 1.3.1 { + execsql { + BEGIN; + INSERT INTO t1 VALUES(7, 8); + } + list [catch { sqlite3_snapshot_get db main } msg] $msg +} {1 SQLITE_ERROR} +do_execsql_test 1.3.2 COMMIT + +#------------------------------------------------------------------------- +# Check that a simple case works. Reuse the database created by the +# block of tests above. +# +do_execsql_test 2.0 { + BEGIN; + SELECT * FROM t1; +} {1 2 3 4 5 6 7 8} + +do_test 2.1 { + set snapshot [sqlite3_snapshot_get db main] + execsql { + COMMIT; + INSERT INTO t1 VALUES(9, 10); + SELECT * FROM t1; + } +} {1 2 3 4 5 6 7 8 9 10} + +do_test 2.2 { + execsql BEGIN + sqlite3_snapshot_open db main $snapshot + execsql { SELECT * FROM t1 } +} {1 2 3 4 5 6 7 8} + +do_test 2.3 { + sqlite3_snapshot_free $snapshot + execsql COMMIT +} {} + +#------------------------------------------------------------------------- +# Check some errors in sqlite3_snapshot_open(). It is an error if: +# +# 1) the db is in auto-commit mode, +# 2) the db has an open (read or write) transaction, +# 3) the db is not a wal database, +# +# Reuse the database created by earlier tests. +# +do_execsql_test 3.0.0 { + CREATE TABLE t2(x, y); + INSERT INTO t2 VALUES('a', 'b'); + INSERT INTO t2 VALUES('c', 'd'); + BEGIN; + SELECT * FROM t2; +} {a b c d} +do_test 3.0.1 { + set snapshot [sqlite3_snapshot_get db main] + execsql { COMMIT } + execsql { INSERT INTO t2 VALUES('e', 'f'); } +} {} + +do_test 3.1 { + list [catch {sqlite3_snapshot_open db main $snapshot } msg] $msg +} {1 SQLITE_ERROR} + +do_test 3.2.1 { + execsql { + BEGIN; + SELECT * FROM t2; + } +} {a b c d e f} +do_test 3.2.2 { + list [catch {sqlite3_snapshot_open db main $snapshot } msg] $msg +} {1 SQLITE_ERROR} + +do_test 3.2.3 { + execsql { + COMMIT; + BEGIN; + INSERT INTO t2 VALUES('g', 'h'); + } + list [catch {sqlite3_snapshot_open db main $snapshot } msg] $msg +} {1 SQLITE_ERROR} +do_execsql_test 3.2.4 COMMIT + +do_test 3.3.1 { + execsql { PRAGMA journal_mode = DELETE } + execsql { BEGIN } + list [catch {sqlite3_snapshot_open db main $snapshot } msg] $msg +} {1 SQLITE_ERROR} + +do_test 3.3.2 { + sqlite3_snapshot_free $snapshot + execsql COMMIT +} {} + +#------------------------------------------------------------------------- +# Check that SQLITE_BUSY_SNAPSHOT is returned if the specified snapshot +# no longer exists because the wal file has been checkpointed. +# +# 1. Reading a snapshot from the middle of a wal file is not possible +# after the wal file has been checkpointed. +# +# 2. That a snapshot from the end of a wal file can not be read once +# the wal file has been wrapped. +# +do_execsql_test 4.1.0 { + PRAGMA journal_mode = wal; + CREATE TABLE t3(i, j); + INSERT INTO t3 VALUES('o', 't'); + INSERT INTO t3 VALUES('t', 'f'); + BEGIN; + SELECT * FROM t3; +} {wal o t t f} + +do_test 4.1.1 { + set snapshot [sqlite3_snapshot_get db main] + execsql COMMIT +} {} +do_test 4.1.2 { + execsql { + INSERT INTO t3 VALUES('f', 's'); + BEGIN; + } + sqlite3_snapshot_open db main $snapshot + execsql { SELECT * FROM t3 } +} {o t t f} + +do_test 4.1.3 { + execsql { + COMMIT; + PRAGMA wal_checkpoint; + BEGIN; + } + list [catch {sqlite3_snapshot_open db main $snapshot} msg] $msg +} {1 SQLITE_BUSY_SNAPSHOT} +do_test 4.1.4 { + sqlite3_snapshot_free $snapshot + execsql COMMIT +} {} + +do_test 4.2.1 { + execsql { + INSERT INTO t3 VALUES('s', 'e'); + INSERT INTO t3 VALUES('n', 't'); + BEGIN; + SELECT * FROM t3; + } +} {o t t f f s s e n t} +do_test 4.2.2 { + set snapshot [sqlite3_snapshot_get db main] + execsql { + COMMIT; + PRAGMA wal_checkpoint; + BEGIN; + } + sqlite3_snapshot_open db main $snapshot + execsql { SELECT * FROM t3 } +} {o t t f f s s e n t} +do_test 4.2.3 { + execsql { + COMMIT; + INSERT INTO t3 VALUES('e', 't'); + BEGIN; + } + list [catch {sqlite3_snapshot_open db main $snapshot} msg] $msg +} {1 SQLITE_BUSY_SNAPSHOT} +do_test 4.2.4 { + sqlite3_snapshot_free $snapshot +} {} + +finish_test + From d797a9b5cb22e248015aabf0148ca544a7a7da3d Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 7 Dec 2015 16:43:44 +0000 Subject: [PATCH 060/232] Changes to avoid obscure, theoretical undefined behavior. This is preventative measures only - no actual problems observed on tested compilers. FossilOrigin-Name: a9e819082ba19e72db03bba37edfb7702ff489a5 --- manifest | 18 +++++++-------- manifest.uuid | 2 +- src/printf.c | 2 +- src/test1.c | 4 ++-- src/test_malloc.c | 3 ++- src/vdbeaux.c | 58 ++++++++++++++++++++++++----------------------- 6 files changed, 45 insertions(+), 42 deletions(-) diff --git a/manifest b/manifest index 00191f9fd0..35182fc887 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sdependence\son\s"exec\sls\s-U"\sfrom\sthe\svtabH.test\smodule,\sas\sthe\s-U\noption\sto\s"ls"\sis\snot\suniversally\savailable. -D 2015-12-04T13:44:07.797 +C Changes\sto\savoid\sobscure,\stheoretical\sundefined\sbehavior.\sThis\sis\spreventative\nmeasures\sonly\s-\sno\sactual\sproblems\sobserved\son\stested\scompilers. +D 2015-12-07T16:43:44.102 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -335,7 +335,7 @@ F src/pcache1.c 46a110be31a8d9f9b41431733836822ca0dd27ab F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 3d94aebbebd2089899fecc01909bf2608b39507d F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 -F src/printf.c ca05561795ad6c2fa47acdd007702586282f7feb +F src/printf.c 9a9105464fbbdf84b81fb902f2eaf1f771896af1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -349,7 +349,7 @@ F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e F src/tclsqlite.c d9439b6a910985b7fff43ba6756bcef00de22649 -F src/test1.c 4004bcc1b3b361a9137acd1d875599ecbdd6f961 +F src/test1.c 90c4e80c7f4b0ad82c6dbe699c8f430b641769f5 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c a8887dabbbee3059af338f20d290084a63ed1b0f F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -374,7 +374,7 @@ F src/test_intarray.c 870124b95ec4c645d4eb84f15efb7133528fb1a5 F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4 -F src/test_malloc.c 8e1c2112fa4f543b46c990a8872f9e6d37938744 +F src/test_malloc.c 96df9381a1ff1f6d3805ff7231b9baf1386aaabf F src/test_multiplex.c 6a088d8d9d4aad4bec45dd8878af11b15900702d F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c @@ -408,7 +408,7 @@ F src/vdbe.c 4d75375fa8bf911aa76ab8383d6f7eea0dec0fda F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 9a234c9aaab4ad725daf94667cfed441a437c52d +F src/vdbeaux.c f7a3e80d96e0e383bf5b636bbb770d452f52cea2 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 042738ad3b769ad70fd7603f928d5b94a952267d -R d4a001dfc820878042f471ef37d7e668 +P 4ecbc75b465533cf80e166a9d0879b9afd3fe2be +R 52003d35f295f961555bc017c6dea8be U drh -Z 2a98a6e0179300d3f1024c7c0c5f05bd +Z df68b9901f4a3c159da303c7427e83e3 diff --git a/manifest.uuid b/manifest.uuid index b3054dd7aa..72ed16cea5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4ecbc75b465533cf80e166a9d0879b9afd3fe2be \ No newline at end of file +a9e819082ba19e72db03bba37edfb7702ff489a5 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 88bb82e3e3..e34ddd3bde 100644 --- a/src/printf.c +++ b/src/printf.c @@ -788,7 +788,7 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ } if( zNew ){ assert( p->zText!=0 || p->nChar==0 ); - if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); + if( p->zText==p->zBase && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; p->nAlloc = sqlite3DbMallocSize(p->db, zNew); }else{ diff --git a/src/test1.c b/src/test1.c index 186e4e4684..b8154a64fe 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5906,13 +5906,13 @@ static int test_sqlite3_log( Tcl_DecrRefCount(logcallback.pObj); logcallback.pObj = 0; logcallback.pInterp = 0; - sqlite3_config(SQLITE_CONFIG_LOG, 0, 0); + sqlite3_config(SQLITE_CONFIG_LOG, (void*)0, (void*)0); } if( objc>1 ){ logcallback.pObj = objv[1]; Tcl_IncrRefCount(logcallback.pObj); logcallback.pInterp = interp; - sqlite3_config(SQLITE_CONFIG_LOG, xLogcallback, 0); + sqlite3_config(SQLITE_CONFIG_LOG, xLogcallback, (void*)0); } return TCL_OK; } diff --git a/src/test_malloc.c b/src/test_malloc.c index a3ff9d205b..aaa640b03a 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -222,7 +222,8 @@ static int faultsimInstall(int install){ assert( memcmp(&m2, &memfault.m, sizeof(m2))==0 ); rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memfault.m); - sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, 0, 0); + sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, + (void*)0, (void*)0); } if( rc==SQLITE_OK ){ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 1889aec79f..acf3864280 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1725,30 +1725,31 @@ void sqlite3VdbeIOTraceSql(Vdbe *p){ ** ** nByte is the number of bytes of space needed. ** -** *ppFrom points to available space and pEnd points to the end of the -** available space. When space is allocated, *ppFrom is advanced past -** the end of the allocated space. +** pFrom points to *pnFrom bytes of available space. New space is allocated +** from the end of the pFrom buffer and *pnFrom is decremented. ** -** *pnByte is a counter of the number of bytes of space that have failed -** to allocate. If there is insufficient space in *ppFrom to satisfy the -** request, then increment *pnByte by the amount of the request. +** *pnNeeded is a counter of the number of bytes of space that have failed +** to allocate. If there is insufficient space in pFrom to satisfy the +** request, then increment *pnNeeded by the amount of the request. */ static void *allocSpace( void *pBuf, /* Where return pointer will be stored */ int nByte, /* Number of bytes to allocate */ - u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */ - u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ - int *pnByte /* If allocation cannot be made, increment *pnByte */ + u8 *pFrom, /* Memory available for allocation */ + int *pnFrom, /* IN/OUT: Space available at pFrom */ + int *pnNeeded /* If allocation cannot be made, increment *pnByte */ ){ - assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) ); - if( pBuf ) return pBuf; - nByte = ROUND8(nByte); - if( &(*ppFrom)[nByte] <= pEnd ){ - pBuf = (void*)*ppFrom; - *ppFrom += nByte; - }else{ - *pnByte += nByte; + assert( EIGHT_BYTE_ALIGNMENT(pFrom) ); + if( pBuf==0 ){ + nByte = ROUND8(nByte); + if( nByte <= *pnFrom ){ + *pnFrom -= nByte; + pBuf = &pFrom[*pnFrom]; + }else{ + *pnNeeded += nByte; + } } + assert( EIGHT_BYTE_ALIGNMENT(pBuf) ); return pBuf; } @@ -1821,8 +1822,8 @@ void sqlite3VdbeMakeReady( int nArg; /* Number of arguments in subprograms */ int nOnce; /* Number of OP_Once instructions */ int n; /* Loop counter */ + int nFree; /* Available free space */ u8 *zCsr; /* Memory available for allocation */ - u8 *zEnd; /* First byte past allocated memory */ int nByte; /* How much extra memory is needed */ assert( p!=0 ); @@ -1854,14 +1855,15 @@ void sqlite3VdbeMakeReady( ** an array to marshal SQL function arguments in. */ zCsr = (u8*)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ - zEnd = (u8*)&p->aOp[pParse->nOpAlloc]; /* First byte past end of zCsr[] */ + assert( pParse->nOpAlloc*sizeof(Op) <= 0x7fffff00 ); + nFree = (pParse->nOpAlloc - p->nOp)*sizeof(p->aOp[0]); /* Available space */ resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); if( pParse->explain && nMem<10 ){ nMem = 10; } - memset(zCsr, 0, zEnd-zCsr); + memset(zCsr, 0, nFree); zCsr += (zCsr - (u8*)0)&7; assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); p->expired = 0; @@ -1878,21 +1880,21 @@ void sqlite3VdbeMakeReady( */ do { nByte = 0; - p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte); - p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte); - p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte); - p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte); + p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), zCsr, &nFree, &nByte); + p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), zCsr, &nFree, &nByte); + p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), zCsr, &nFree, &nByte); + p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), zCsr, &nFree, &nByte); p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*), - &zCsr, zEnd, &nByte); - p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, &zCsr, zEnd, &nByte); + zCsr, &nFree, &nByte); + p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, zCsr, &nFree, &nByte); #ifdef SQLITE_ENABLE_STMT_SCANSTATUS - p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), &zCsr, zEnd, &nByte); + p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), zCsr, &nFree, &nByte); #endif if( nByte ){ p->pFree = sqlite3DbMallocZero(db, nByte); } zCsr = p->pFree; - zEnd = &zCsr[nByte]; + nFree = nByte; }while( nByte && !db->mallocFailed ); p->nCursor = nCursor; From dc27851e21a94a0200bace098f61ec6deb4b427a Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 7 Dec 2015 18:18:33 +0000 Subject: [PATCH 061/232] Fix the openDirectory() routine in the unix VFS so that it works for databases located in the root of the filesystem and for database files that have no pathname at all. FossilOrigin-Name: e7ae120d04cffafd9bc2b4ecd68571c17e05ed72 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 15 +++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 35182fc887..1054bbef33 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\savoid\sobscure,\stheoretical\sundefined\sbehavior.\sThis\sis\spreventative\nmeasures\sonly\s-\sno\sactual\sproblems\sobserved\son\stested\scompilers. -D 2015-12-07T16:43:44.102 +C Fix\sthe\sopenDirectory()\sroutine\sin\sthe\sunix\sVFS\sso\sthat\sit\sworks\sfor\sdatabases\nlocated\sin\sthe\sroot\sof\sthe\sfilesystem\sand\sfor\sdatabase\sfiles\sthat\shave\sno\npathname\sat\sall. +D 2015-12-07T18:18:33.086 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 2563734669b06432cea640cbb4f7e9d543f227b9 +F src/os_unix.c 0ca6d8710366fbb01a275160f018334cd347cbda F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c f92aacd5216d8815136c9e0190041783c602641a @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4ecbc75b465533cf80e166a9d0879b9afd3fe2be -R 52003d35f295f961555bc017c6dea8be +P a9e819082ba19e72db03bba37edfb7702ff489a5 +R 24074b14133d8cbad307bf1c20e69806 U drh -Z df68b9901f4a3c159da303c7427e83e3 +Z bce64672fed9a01eb65d3786fa37a9f1 diff --git a/manifest.uuid b/manifest.uuid index 72ed16cea5..dc8c28b89e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a9e819082ba19e72db03bba37edfb7702ff489a5 \ No newline at end of file +e7ae120d04cffafd9bc2b4ecd68571c17e05ed72 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index beaac0d15d..791ba5d8d9 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3465,13 +3465,16 @@ static int openDirectory(const char *zFilename, int *pFd){ char zDirname[MAX_PATHNAME+1]; sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename); - for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--); - if( ii>1 ){ + for(ii=(int)strlen(zDirname); ii>0 && zDirname[ii]!='/'; ii--); + if( ii>0 ){ zDirname[ii] = '\0'; - fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); - if( fd>=0 ){ - OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); - } + }else{ + if( zDirname[0]!='/' ) zDirname[0] = '.'; + zDirname[1] = 0; + } + fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); + if( fd>=0 ){ + OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); } *pFd = fd; if( fd>=0 ) return SQLITE_OK; From df12f1c69bad540de5036f99812a7e41ea377ddb Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 7 Dec 2015 21:46:19 +0000 Subject: [PATCH 062/232] Add the ".changes ON|OFF" command to the sqlite3.exe command-line shell, for testing and verifying the sqlite3_changes() and sqlite3_total_changes() interfaces. FossilOrigin-Name: 9bbe1afc1521b111a0a93803b41ff04e0ee55630 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 1054bbef33..3a0b27394c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sopenDirectory()\sroutine\sin\sthe\sunix\sVFS\sso\sthat\sit\sworks\sfor\sdatabases\nlocated\sin\sthe\sroot\sof\sthe\sfilesystem\sand\sfor\sdatabase\sfiles\sthat\shave\sno\npathname\sat\sall. -D 2015-12-07T18:18:33.086 +C Add\sthe\s".changes\sON|OFF"\scommand\sto\sthe\ssqlite3.exe\scommand-line\sshell,\sfor\ntesting\sand\sverifying\sthe\ssqlite3_changes()\sand\nsqlite3_total_changes()\sinterfaces. +D 2015-12-07T21:46:19.114 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -340,7 +340,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f -F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21 +F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 1248a78548024bdc8ef5893faa0ff9552b4cceb4 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a9e819082ba19e72db03bba37edfb7702ff489a5 -R 24074b14133d8cbad307bf1c20e69806 +P e7ae120d04cffafd9bc2b4ecd68571c17e05ed72 +R 73237b31faf24d2547a2561196384a88 U drh -Z bce64672fed9a01eb65d3786fa37a9f1 +Z 44232263f2d956132c0ce354e853bbb1 diff --git a/manifest.uuid b/manifest.uuid index dc8c28b89e..65f5be92c9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e7ae120d04cffafd9bc2b4ecd68571c17e05ed72 \ No newline at end of file +9bbe1afc1521b111a0a93803b41ff04e0ee55630 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index bcad59e806..ff1336a4b7 100644 --- a/src/shell.c +++ b/src/shell.c @@ -525,6 +525,7 @@ struct ShellState { int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */ int statsOn; /* True to display memory stats before each finalize */ int scanstatsOn; /* True to display scan stats before each finalize */ + int countChanges; /* True to display change counts */ int backslashOn; /* Resolve C-style \x escapes in SQL input text */ int outCount; /* Revert to stdout when reaching zero */ int cnt; /* Number of records displayed so far */ @@ -1785,6 +1786,7 @@ static char zHelp[] = ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" ".bail on|off Stop after hitting an error. Default OFF\n" ".binary on|off Turn binary output on or off. Default OFF\n" + ".changes on|off Show number of rows changed by SQL\n" ".clone NEWDB Clone data into NEWDB from the existing database\n" ".databases List names and files of attached databases\n" ".dbinfo ?DB? Show status information about the database\n" @@ -2757,6 +2759,15 @@ static int do_meta_command(char *zLine, ShellState *p){ test_breakpoint(); }else + if( c=='c' && n>=3 && strncmp(azArg[0], "changes", n)==0 ){ + if( nArg==2 ){ + p->countChanges = booleanValue(azArg[1]); + }else{ + fprintf(stderr, "Usage: .changes on|off\n"); + rc = 1; + } + }else + if( c=='c' && strncmp(azArg[0], "clone", n)==0 ){ if( nArg==2 ){ tryToClone(p, azArg[1]); @@ -4286,6 +4297,9 @@ static int process_input(ShellState *p, FILE *in){ fprintf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db)); } errCnt++; + }else if( p->countChanges ){ + fprintf(p->out, "changes: %3d total_changes: %d\n", + sqlite3_changes(p->db), sqlite3_total_changes(p->db)); } nSql = 0; if( p->outCount ){ From 855ed4a3b48f5bc08d42a4a331325a4e0518e4ba Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 7 Dec 2015 23:31:59 +0000 Subject: [PATCH 063/232] Update MSVC batch build tool to the latest Windows 10 SDK version. FossilOrigin-Name: 2ad5017190334b7dd53294a30c3b3232e0c35869 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/build-all-msvc.bat | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 3a0b27394c..ee2b3ef82f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s".changes\sON|OFF"\scommand\sto\sthe\ssqlite3.exe\scommand-line\sshell,\sfor\ntesting\sand\sverifying\sthe\ssqlite3_changes()\sand\nsqlite3_total_changes()\sinterfaces. -D 2015-12-07T21:46:19.114 +C Update\sMSVC\sbatch\sbuild\stool\sto\sthe\slatest\sWindows\s10\sSDK\sversion. +D 2015-12-07T23:31:59.191 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -1350,7 +1350,7 @@ F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8606413d3035c05373a0d7fae82ebf59ae9e16c3 F tool/addopcodes.tcl 4ca9c3ef196f08da30add5d07ce0c9458dc8c633 -F tool/build-all-msvc.bat e42141ca3c3812315432f9813ef9eb78aa8d99c9 x +F tool/build-all-msvc.bat 204a039f985d5a4f4f9df3a3aa594fd17848c37e x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 F tool/cg_anno.tcl 692ce4b8693d59e3a3de77ca97f4139ecfa641b0 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e7ae120d04cffafd9bc2b4ecd68571c17e05ed72 -R 73237b31faf24d2547a2561196384a88 -U drh -Z 44232263f2d956132c0ce354e853bbb1 +P 9bbe1afc1521b111a0a93803b41ff04e0ee55630 +R 09e1a6b4b7c25190447a2783c034d72c +U mistachkin +Z e9b23e5e87abed46d08ef4a9e1279cbf diff --git a/manifest.uuid b/manifest.uuid index 65f5be92c9..0efcda5e92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9bbe1afc1521b111a0a93803b41ff04e0ee55630 \ No newline at end of file +2ad5017190334b7dd53294a30c3b3232e0c35869 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index e081c73b38..87794132b6 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -320,7 +320,7 @@ REM IF DEFINED UCRTVersion ( SET NUCRTVER=%UCRTVersion% ) ELSE ( - SET NUCRTVER=10.0.10240.0 + SET NUCRTVER=10.0.10586.0 ) REM From a295d1521a94f0c0277d60c53f8bd058a3f94204 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 8 Dec 2015 00:47:32 +0000 Subject: [PATCH 064/232] Update the TclKit download URL. FossilOrigin-Name: 07e5199c6f868cc02a0b708865254056c4f3daf3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/GetTclKit.bat | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ee2b3ef82f..dac89710e1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sMSVC\sbatch\sbuild\stool\sto\sthe\slatest\sWindows\s10\sSDK\sversion. -D 2015-12-07T23:31:59.191 +C Update\sthe\sTclKit\sdownload\sURL. +D 2015-12-08T00:47:32.597 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -1348,7 +1348,7 @@ F test/wordcount.c 2a0a6c0d0e8e8bbbac1f06d72a6791828c37c0cf F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 -F tool/GetTclKit.bat 8606413d3035c05373a0d7fae82ebf59ae9e16c3 +F tool/GetTclKit.bat 629d87562e0487c386db630033931d12d62e6372 F tool/addopcodes.tcl 4ca9c3ef196f08da30add5d07ce0c9458dc8c633 F tool/build-all-msvc.bat 204a039f985d5a4f4f9df3a3aa594fd17848c37e x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9bbe1afc1521b111a0a93803b41ff04e0ee55630 -R 09e1a6b4b7c25190447a2783c034d72c +P 2ad5017190334b7dd53294a30c3b3232e0c35869 +R 3561bc5f3aaa22b7dbf4b237affa0cef U mistachkin -Z e9b23e5e87abed46d08ef4a9e1279cbf +Z 2e63742234f7b704fba2b32627d437ce diff --git a/manifest.uuid b/manifest.uuid index 0efcda5e92..0dd1181e30 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2ad5017190334b7dd53294a30c3b3232e0c35869 \ No newline at end of file +07e5199c6f868cc02a0b708865254056c4f3daf3 \ No newline at end of file diff --git a/tool/GetTclKit.bat b/tool/GetTclKit.bat index 1ed15ea7f3..84235cf97a 100644 --- a/tool/GetTclKit.bat +++ b/tool/GetTclKit.bat @@ -62,7 +62,7 @@ IF NOT DEFINED TEMP ( %_VECHO% Temp = '%TEMP%' IF NOT DEFINED TCLKIT_URI ( - SET TCLKIT_URI=http://tclsh.com/ + SET TCLKIT_URI=https://tclsh.com/ ) %_VECHO% TclKitUri = '%TCLKIT_URI%' From 92a82771498c19c39abaa3754ff0d307ad7da9dd Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 8 Dec 2015 04:18:33 +0000 Subject: [PATCH 065/232] Add a test case of the form "WHERE a<2 OR a<3" using PRAGMA count_changes. This test case was failing before the 3.9.0 release. FossilOrigin-Name: 177862c1d50ba899d890fbc35f35e7423bc6aed5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/where7.test | 12 ++++++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index dac89710e1..d584f281f3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sTclKit\sdownload\sURL. -D 2015-12-08T00:47:32.597 +C Add\sa\stest\scase\sof\sthe\sform\s"WHERE\sa<2\sOR\sa<3"\susing\sPRAGMA\scount_changes.\nThis\stest\scase\swas\sfailing\sbefore\sthe\s3.9.0\srelease. +D 2015-12-08T04:18:33.696 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -1314,7 +1314,7 @@ F test/where3.test 1ad55ba900bd7747f98b6082e65bd3e442c5004e F test/where4.test 4a371bfcc607f41d233701bdec33ac2972908ba8 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b -F test/where7.test 5a4b0abc207d71da4deecd734ad8579e8dd40aa8 +F test/where7.test f520bcec2c3d12dc4615623b06b2aec7c2d67e94 F test/where8.test 98eedca0d375fb400b8377269c4b4686582dfb45 F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 F test/where9.test 729c3ba9b47e8f9f1aab96bae7dad2a524f1d1a2 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2ad5017190334b7dd53294a30c3b3232e0c35869 -R 3561bc5f3aaa22b7dbf4b237affa0cef -U mistachkin -Z 2e63742234f7b704fba2b32627d437ce +P 07e5199c6f868cc02a0b708865254056c4f3daf3 +R 17b34bcad46ec764b462c91813dd5909 +U drh +Z 86e126efc794a5aaf900005c30a5cf69 diff --git a/manifest.uuid b/manifest.uuid index 0dd1181e30..d39829dc75 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -07e5199c6f868cc02a0b708865254056c4f3daf3 \ No newline at end of file +177862c1d50ba899d890fbc35f35e7423bc6aed5 \ No newline at end of file diff --git a/test/where7.test b/test/where7.test index 5032c698b2..00cf5eb278 100644 --- a/test/where7.test +++ b/test/where7.test @@ -47,6 +47,18 @@ do_test where7-1.1 { SELECT * FROM t1; } } {1 2 3 4 2 3 4 5 3 4 6 8 4 5 10 15 5 10 100 1000} +do_execsql_test where7-1.1.1 { + CREATE TABLE t(a); + CREATE INDEX ta ON t(a); + INSERT INTO t(a) VALUES(1),(2); + SELECT * FROM t ORDER BY a; + SELECT * FROM t WHERE a<2 OR a<3 ORDER BY a; + PRAGMA count_changes=ON; + DELETE FROM t WHERE a<2 OR a<3; + SELECT * FROM t; + PRAGMA count_changes=OFF; + DROP TABLE t; +} {1 2 1 2 2} do_test where7-1.2 { count_steps { SELECT a FROM t1 WHERE b=3 OR c=6 ORDER BY a From ea06a271a4cfd530325c35a5a9ba00e185059bd2 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 8 Dec 2015 16:08:10 +0000 Subject: [PATCH 066/232] Avoid doing comparisons with pointers that might have been previously been passed to realloc() and/or free(). FossilOrigin-Name: f20396adb2cff12a17a3fc90b36241ae3fdfd62a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/printf.c | 17 +++++++++++++---- src/sqliteInt.h | 1 + 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index d584f281f3..0a0d901caa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\scase\sof\sthe\sform\s"WHERE\sa<2\sOR\sa<3"\susing\sPRAGMA\scount_changes.\nThis\stest\scase\swas\sfailing\sbefore\sthe\s3.9.0\srelease. -D 2015-12-08T04:18:33.696 +C Avoid\sdoing\scomparisons\swith\spointers\sthat\smight\shave\sbeen\spreviously\sbeen\npassed\sto\srealloc()\sand/or\sfree(). +D 2015-12-08T16:08:10.872 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -335,7 +335,7 @@ F src/pcache1.c 46a110be31a8d9f9b41431733836822ca0dd27ab F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 3d94aebbebd2089899fecc01909bf2608b39507d F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 -F src/printf.c 9a9105464fbbdf84b81fb902f2eaf1f771896af1 +F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -344,7 +344,7 @@ F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 1248a78548024bdc8ef5893faa0ff9552b4cceb4 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 +F src/sqliteInt.h 5caacf37a776f9d6178e519cb0b5248ca22a3828 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 07e5199c6f868cc02a0b708865254056c4f3daf3 -R 17b34bcad46ec764b462c91813dd5909 +P 177862c1d50ba899d890fbc35f35e7423bc6aed5 +R 428581991da630a9c7b367e41a5c2afb U drh -Z 86e126efc794a5aaf900005c30a5cf69 +Z 910de169aa0a3078fbedf4d83c3245e1 diff --git a/manifest.uuid b/manifest.uuid index d39829dc75..294312aa8e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -177862c1d50ba899d890fbc35f35e7423bc6aed5 \ No newline at end of file +f20396adb2cff12a17a3fc90b36241ae3fdfd62a \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index e34ddd3bde..969950c154 100644 --- a/src/printf.c +++ b/src/printf.c @@ -766,8 +766,9 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ setStrAccumError(p, STRACCUM_TOOBIG); return N; }else{ - char *zOld = (p->zText==p->zBase ? 0 : p->zText); + char *zOld = p->bMalloced ? p->zText : 0; i64 szNew = p->nChar; + assert( (p->zText==0 || p->zText==p->zBase)==(p->bMalloced==0) ); szNew += N + 1; if( szNew+p->nChar<=p->mxAlloc ){ /* Force exponential buffer size growth as long as it does not overflow, @@ -788,9 +789,10 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ } if( zNew ){ assert( p->zText!=0 || p->nChar==0 ); - if( p->zText==p->zBase && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); + if( !p->bMalloced && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; p->nAlloc = sqlite3DbMallocSize(p->db, zNew); + p->bMalloced = 1; }else{ sqlite3StrAccumReset(p); setStrAccumError(p, STRACCUM_NOMEM); @@ -808,6 +810,7 @@ void sqlite3AppendChar(StrAccum *p, int N, char c){ if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){ return; } + assert( (p->zText==p->zBase)==(p->bMalloced==0) ); while( (N--)>0 ) p->zText[p->nChar++] = c; } @@ -825,6 +828,7 @@ static void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z, int N){ memcpy(&p->zText[p->nChar], z, N); p->nChar += N; } + assert( (p->zText==0 || p->zText==p->zBase)==(p->bMalloced==0) ); } /* @@ -860,11 +864,13 @@ void sqlite3StrAccumAppendAll(StrAccum *p, const char *z){ */ char *sqlite3StrAccumFinish(StrAccum *p){ if( p->zText ){ + assert( (p->zText==p->zBase)==(p->bMalloced==0) ); p->zText[p->nChar] = 0; - if( p->mxAlloc>0 && p->zText==p->zBase ){ + if( p->mxAlloc>0 && p->bMalloced==0 ){ p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 ); if( p->zText ){ memcpy(p->zText, p->zBase, p->nChar+1); + p->bMalloced = 1; }else{ setStrAccumError(p, STRACCUM_NOMEM); } @@ -877,8 +883,10 @@ char *sqlite3StrAccumFinish(StrAccum *p){ ** Reset an StrAccum string. Reclaim all malloced memory. */ void sqlite3StrAccumReset(StrAccum *p){ - if( p->zText!=p->zBase ){ + assert( (p->zText==0 || p->zText==p->zBase)==(p->bMalloced==0) ); + if( p->bMalloced ){ sqlite3DbFree(p->db, p->zText); + p->bMalloced = 0; } p->zText = 0; } @@ -904,6 +912,7 @@ void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, int n, int mx){ p->nAlloc = n; p->mxAlloc = mx; p->accError = 0; + p->bMalloced = 0; } /* diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 338a573253..0d477dc06f 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2952,6 +2952,7 @@ struct StrAccum { int nAlloc; /* Amount of space allocated in zText */ int mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */ u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */ + u8 bMalloced; /* zText points to allocated space */ }; #define STRACCUM_NOMEM 1 #define STRACCUM_TOOBIG 2 From 72ea29d7ae7395c66869f6848d3af94c20843a72 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 8 Dec 2015 16:58:45 +0000 Subject: [PATCH 067/232] Changes to avoid undefined behavior in memset() and memcpy() and in the comparisons of pointers from different allocations. All problems are found by analysis tools - none have been seen in the wild. FossilOrigin-Name: 901d0b8f3b72e96ffa8e9436993a12980f5ebd51 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/btree.c | 5 +++++ src/expr.c | 6 +++++- src/vdbeaux.c | 2 +- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 0a0d901caa..4be65dcffd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sdoing\scomparisons\swith\spointers\sthat\smight\shave\sbeen\spreviously\sbeen\npassed\sto\srealloc()\sand/or\sfree(). -D 2015-12-08T16:08:10.872 +C Changes\sto\savoid\sundefined\sbehavior\sin\smemset()\sand\smemcpy()\sand\sin\sthe\ncomparisons\sof\spointers\sfrom\sdifferent\sallocations.\s\sAll\sproblems\sare\sfound\nby\sanalysis\stools\s-\snone\shave\sbeen\sseen\sin\sthe\swild. +D 2015-12-08T16:58:45.426 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -282,7 +282,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c d3bdd8462a86492e2ebc9aca4a0168429017de25 +F src/btree.c 81d041421359bbffc091c8a95dd0507aa4f09093 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b @@ -292,7 +292,7 @@ F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c cb1a419508e5b27769a91e00e36e94724e7b1d51 +F src/expr.c ccb93d7b7e1ac5d187c9b153bae145933f93ee5c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 F src/func.c fe50a9ab977acc0bb0fcd46741e0071fa388888e @@ -408,7 +408,7 @@ F src/vdbe.c 4d75375fa8bf911aa76ab8383d6f7eea0dec0fda F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c f7a3e80d96e0e383bf5b636bbb770d452f52cea2 +F src/vdbeaux.c 8405f7441cb75c5d1816d1731a041d450e9ff2e9 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 177862c1d50ba899d890fbc35f35e7423bc6aed5 -R 428581991da630a9c7b367e41a5c2afb +P f20396adb2cff12a17a3fc90b36241ae3fdfd62a +R 70bc46af51bec4fcd5f5ac34f7fbc9eb U drh -Z 910de169aa0a3078fbedf4d83c3245e1 +Z 9b6f69f2c38f1825e156d39e6c72b0a2 diff --git a/manifest.uuid b/manifest.uuid index 294312aa8e..a26e28b825 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f20396adb2cff12a17a3fc90b36241ae3fdfd62a \ No newline at end of file +901d0b8f3b72e96ffa8e9436993a12980f5ebd51 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 4a51b01d75..34ce8c3592 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7521,8 +7521,13 @@ static int balance_nonroot( ** overflow cell), we can skip updating the pointer map entries. */ if( iOld>=nNew || pNew->pgno!=aPgno[iOld] +#ifdef HAVE_STDINT_H + || (intptr_t)pCell<(intptr_t)aOld + || (intptr_t)pCell>=(intptr_t)&aOld[usableSize] +#else || pCell=&aOld[usableSize] +#endif ){ if( !leafCorrection ){ ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc); diff --git a/src/expr.c b/src/expr.c index 8cf018f9d4..8f6377e664 100644 --- a/src/expr.c +++ b/src/expr.c @@ -853,6 +853,7 @@ static int dupedExprSize(Expr *p, int flags){ */ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ Expr *pNew = 0; /* Value to return */ + assert( flags==0 || flags==EXPRDUP_REDUCE ); if( p ){ const int isReduced = (flags&EXPRDUP_REDUCE); u8 *zAlloc; @@ -889,7 +890,9 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ }else{ int nSize = exprStructSize(p); memcpy(zAlloc, p, nSize); - memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); + if( nSizen + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0) == (int)sqlite3VdbeSerialTypeLen(serial_type) ); len = pMem->n; - memcpy(buf, pMem->z, len); + if( len>0 ) memcpy(buf, pMem->z, len); return len; } From 8c8dddc90411eef6d23bf6b40bcb05eb65d240bf Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 9 Dec 2015 16:26:38 +0000 Subject: [PATCH 068/232] Simplification of the DROP TRIGGER logic using sqlite3NestedParse() instead of hand-coded VDBE code. This is a manual cherry-pick of the key change from check-in [c80bbf14b365d]. FossilOrigin-Name: 8021b4c8139ba56d6b1e2e26aeec4f9bf77f37c9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/trigger.c | 27 ++++----------------------- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index 4be65dcffd..677d1f72d0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\savoid\sundefined\sbehavior\sin\smemset()\sand\smemcpy()\sand\sin\sthe\ncomparisons\sof\spointers\sfrom\sdifferent\sallocations.\s\sAll\sproblems\sare\sfound\nby\sanalysis\stools\s-\snone\shave\sbeen\sseen\sin\sthe\swild. -D 2015-12-08T16:58:45.426 +C Simplification\sof\sthe\sDROP\sTRIGGER\slogic\susing\ssqlite3NestedParse()\sinstead\nof\shand-coded\sVDBE\scode.\s\sThis\sis\sa\smanual\scherry-pick\sof\sthe\skey\schange\sfrom\ncheck-in\s[c80bbf14b365d]. +D 2015-12-09T16:26:38.759 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -399,7 +399,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c bbfb74450643cb5372a43ad4f6cffd7e9dfcecb0 F src/tokenize.c 5606871a377f390af7040ec3c12e0d183512d785 F src/treeview.c 78842e90c1f71269e7a73a1d4221b6fe360bab66 -F src/trigger.c 322f23aad694e8f31d384dcfa386d52a48d3c52f +F src/trigger.c de3ed31ad3218a20d7d7e18bf1b3b734e78bda66 F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f20396adb2cff12a17a3fc90b36241ae3fdfd62a -R 70bc46af51bec4fcd5f5ac34f7fbc9eb +P 901d0b8f3b72e96ffa8e9436993a12980f5ebd51 +R e560f751f53c5733305e8b0ee0bd6c81 U drh -Z 9b6f69f2c38f1825e156d39e6c72b0a2 +Z 957e158965f07497a4d00489add5865f diff --git a/manifest.uuid b/manifest.uuid index a26e28b825..dc29bbac6d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -901d0b8f3b72e96ffa8e9436993a12980f5ebd51 \ No newline at end of file +8021b4c8139ba56d6b1e2e26aeec4f9bf77f37c9 \ No newline at end of file diff --git a/src/trigger.c b/src/trigger.c index 2eba0cf92c..be490e923a 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -559,31 +559,12 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){ */ assert( pTable!=0 ); if( (v = sqlite3GetVdbe(pParse))!=0 ){ - int base; - static const int iLn = VDBE_OFFSET_LINENO(2); - static const VdbeOpList dropTrigger[] = { - { OP_Rewind, 0, ADDR(9), 0}, - { OP_String8, 0, 1, 0}, /* 1 */ - { OP_Column, 0, 1, 2}, - { OP_Ne, 2, ADDR(8), 1}, - { OP_String8, 0, 1, 0}, /* 4: "trigger" */ - { OP_Column, 0, 0, 2}, - { OP_Ne, 2, ADDR(8), 1}, - { OP_Delete, 0, 0, 0}, - { OP_Next, 0, ADDR(1), 0}, /* 8 */ - }; - - sqlite3BeginWriteOperation(pParse, 0, iDb); - sqlite3OpenMasterTable(pParse, iDb); - base = sqlite3VdbeAddOpList(v, ArraySize(dropTrigger), dropTrigger, iLn); - sqlite3VdbeChangeP4(v, base+1, pTrigger->zName, P4_TRANSIENT); - sqlite3VdbeChangeP4(v, base+4, "trigger", P4_STATIC); + sqlite3NestedParse(pParse, + "DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'", + db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pTrigger->zName + ); sqlite3ChangeCookie(pParse, iDb); - sqlite3VdbeAddOp2(v, OP_Close, 0, 0); sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0); - if( pParse->nMem<3 ){ - pParse->nMem = 3; - } } } From 5ef09bf918bb26fbb900ec14850114b47f83cbfe Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 9 Dec 2015 17:23:12 +0000 Subject: [PATCH 069/232] Further simplifications to the VDBE code generation logic that flow out of the previous check-in. FossilOrigin-Name: 6a5dfe85b519b920ce8c842057767a8793d92236 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 17 ++++++----------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 677d1f72d0..cc0c4b013d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sof\sthe\sDROP\sTRIGGER\slogic\susing\ssqlite3NestedParse()\sinstead\nof\shand-coded\sVDBE\scode.\s\sThis\sis\sa\smanual\scherry-pick\sof\sthe\skey\schange\sfrom\ncheck-in\s[c80bbf14b365d]. -D 2015-12-09T16:26:38.759 +C Further\ssimplifications\sto\sthe\sVDBE\scode\sgeneration\slogic\sthat\sflow\sout\nof\sthe\sprevious\scheck-in. +D 2015-12-09T17:23:12.345 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -408,7 +408,7 @@ F src/vdbe.c 4d75375fa8bf911aa76ab8383d6f7eea0dec0fda F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 8405f7441cb75c5d1816d1731a041d450e9ff2e9 +F src/vdbeaux.c e07b2c8d14064f2094d20d002a2a1082913bbd2a F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 901d0b8f3b72e96ffa8e9436993a12980f5ebd51 -R e560f751f53c5733305e8b0ee0bd6c81 +P 8021b4c8139ba56d6b1e2e26aeec4f9bf77f37c9 +R 9fa6094a1e8a72da130ce9bebe3afcb3 U drh -Z 957e158965f07497a4d00489add5865f +Z e514ce3bd686c655a7118cedbf26535f diff --git a/manifest.uuid b/manifest.uuid index dc29bbac6d..01a18cf6eb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8021b4c8139ba56d6b1e2e26aeec4f9bf77f37c9 \ No newline at end of file +6a5dfe85b519b920ce8c842057767a8793d92236 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 26d162e93a..38cd492afa 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -349,7 +349,7 @@ int sqlite3VdbeMakeLabel(Vdbe *v){ if( p->aLabel ){ p->aLabel[i] = -1; } - return -1-i; + return ADDR(i); } /* @@ -359,7 +359,7 @@ int sqlite3VdbeMakeLabel(Vdbe *v){ */ void sqlite3VdbeResolveLabel(Vdbe *v, int x){ Parse *p = v->pParse; - int j = -1-x; + int j = ADDR(x); assert( v->magic==VDBE_MAGIC_INIT ); assert( jnLabel ); assert( j>=0 ); @@ -586,8 +586,8 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ pOp->opflags = sqlite3OpcodeProperty[opcode]; if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){ - assert( -1-pOp->p2nLabel ); - pOp->p2 = aLabel[-1-pOp->p2]; + assert( ADDR(pOp->p2)nLabel ); + pOp->p2 = aLabel[ADDR(pOp->p2)]; } } sqlite3DbFree(p->db, pParse->aLabel); @@ -644,15 +644,10 @@ int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp, int iLineno){ addr = p->nOp; pOut = &p->aOp[addr]; for(i=0; ip2; pOut->opcode = aOp->opcode; pOut->p1 = aOp->p1; - if( p2<0 ){ - assert( sqlite3OpcodeProperty[pOut->opcode] & OPFLG_JUMP ); - pOut->p2 = addr + ADDR(p2); - }else{ - pOut->p2 = p2; - } + pOut->p2 = aOp->p2; + assert( aOp->p2>=0 ); pOut->p3 = aOp->p3; pOut->p4type = P4_NOTUSED; pOut->p4.p = 0; From 65127cd57d20a2dc302dc2cc51a389f1089bad13 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 9 Dec 2015 20:05:27 +0000 Subject: [PATCH 070/232] Update sqlite3_snapshot_open() to reduce the chances of reading a corrupt snapshot created by a checkpointer process exiting unexpectedly. FossilOrigin-Name: 7315f7cbf4179aadda0f1a0baa1526a9b9f9729f --- manifest | 18 ++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 30 ++++++++++++++++++++- src/wal.c | 66 ++++++++++++++++++++++++++++++++++++---------- test/snapshot.test | 46 +++++++++++++++++++++++++++----- 5 files changed, 130 insertions(+), 32 deletions(-) diff --git a/manifest b/manifest index f06c0af37a..09955e2042 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sunrelated\sfixes\sfrom\strunk. -D 2015-12-09T16:04:06.348 +C Update\ssqlite3_snapshot_open()\sto\sreduce\sthe\schances\sof\sreading\sa\scorrupt\ssnapshot\screated\sby\sa\scheckpointer\sprocess\sexiting\sunexpectedly. +D 2015-12-09T20:05:27.534 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -341,7 +341,7 @@ F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 -F src/sqlite.h.in fc8a2875a318df1b9dabd82cb00b1ac98081423a +F src/sqlite.h.in 19dea4862ccfcc1a733d0fd18d4744b02a505ac6 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d F src/sqliteInt.h 5caacf37a776f9d6178e519cb0b5248ca22a3828 @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c abce669053edf5cd1cd1751d654d48d74ed47839 +F src/wal.c 0bd8aa8e0db924493af4c72f527afc9b9e22257a F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1020,7 +1020,7 @@ F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b -F test/snapshot.test 061dc75b77ca65c0e9c5976499625abe5be7a5c0 +F test/snapshot.test 800e0be4488acb88dd38ff9e9b83edb71d9d5a9d F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 F test/sort.test 3f492e5b7be1d3f756728d2ff6edf4f6091e84cb @@ -1409,7 +1409,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 502cc6f353358946080d9bcd335aed526825b88a 901d0b8f3b72e96ffa8e9436993a12980f5ebd51 -R 9b1d7228446872f8d72f41cfd12e515e -U drh -Z 3ae5744205bfcf5cc63a2630633fbd47 +P 362615b4df94358d0264b0991c3090a0878f054c +R cfc950fbd468350b7777662be2b401a3 +U dan +Z 51de2f0ad57bbe117dc864890e31b83c diff --git a/manifest.uuid b/manifest.uuid index 44bc42da2d..33aefc5d3b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -362615b4df94358d0264b0991c3090a0878f054c \ No newline at end of file +7315f7cbf4179aadda0f1a0baa1526a9b9f9729f \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e8940b5e08..601415b907 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -7895,11 +7895,39 @@ int sqlite3_db_cacheflush(sqlite3*); ** SQLITE_ERROR is returned. If any other error occurs, for example an IO ** error or an OOM condition, the corresponding SQLite error code is ** returned. +** +** Each successful call to sqlite3_snapshot_get() must be matched by a call +** to sqlite3_snapshot_free() to delete the snapshot handle. Not doing so +** is a memory leak. The results of using a snapshot handle after it has +** been deleted by sqlite3_snapshot_free() are undefined. +** +** Given a snapshot handle, the sqlite3_snapshot_open() API function may be +** used to open a read transaction on the same database snapshot that was +** being read when sqlite3_snapshot_get() was called to obtain it. The +** combination of the first two arguments to sqlite3_snapshot_open() - a +** database handle and the name (e.g. "main") of one of its attached +** databases - must refer to the same database file as that identified by +** the arguments passed to the sqlite3_snapshot_get() call. The database +** handle must not have an open read or write transaction on this database +** file, and must not be in auto-commit mode. +** +** An old database snapshot may only be opened if SQLite is able to +** determine that it is still valid. The only way for an application to +** guarantee that a snapshot remains valid is by holding an open +** read-transaction on it or on an older snapshot of the same database +** file. If SQLite cannot determine that the snapshot identified by the +** snapshot handle, SQLITE_BUSY_SNAPSHOT is returned. +** +** Otherwise, if the read transaction is successfully opened, SQLITE_OK is +** returned. If the named database is not in wal mode or if the database +** handle already has an open read or write transaction on it, or if the +** database handle is in auto-commit mode, SQLITE_ERROR is returned. If +** an OOM or IO error occurs, the associated SQLite error code is returned. */ typedef struct sqlite3_snapshot sqlite3_snapshot; int sqlite3_snapshot_get(sqlite3*, const char*, sqlite3_snapshot **ppSnapshot); -int sqlite3_snapshot_open(sqlite3*, const char*, sqlite3_snapshot*); void sqlite3_snapshot_free(sqlite3_snapshot*); +int sqlite3_snapshot_open(sqlite3*, const char*, sqlite3_snapshot*); /* ** Undo the hack that converts floating point types to integer for diff --git a/src/wal.c b/src/wal.c index 49811fb9b4..af93694e8d 100644 --- a/src/wal.c +++ b/src/wal.c @@ -2275,6 +2275,9 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ { if( (pWal->readOnly & WAL_SHM_RDONLY)==0 && (mxReadMarkpSnapshot==0 +#endif ){ for(i=1; ipSnapshot ) return SQLITE_BUSY_SNAPSHOT; +#endif assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 ); return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTLOCK; } @@ -2383,22 +2389,54 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ #ifdef SQLITE_ENABLE_SNAPSHOT if( rc==SQLITE_OK ){ if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr)) ){ + /* At this point the client has a lock on an aReadMark[] slot holding + ** a value equal to or smaller than pSnapshot->mxFrame. This client + ** did not populate the aReadMark[] slot. pWal->hdr is populated with + ** the wal-index header for the snapshot currently at the head of the + ** wal file, which is different from pSnapshot. + ** + ** The presence of the aReadMark[] slot entry makes it very likely + ** that either there is currently another read-transaction open on + ** pSnapshot, or that there has been one more recently than the last + ** checkpoint of any frames greater than pSnapshot->mxFrame was + ** started. There is an exception though: client 1 may have called + ** walTryBeginRead and started to open snapshot pSnapshot, setting + ** the aReadMark[] slot to do so. At the same time, client 2 may + ** have committed a new snapshot to disk and started a checkpoint. + ** In this circumstance client 1 does not end up reading pSnapshot, + ** but may leave the aReadMark[] slot populated. + ** + ** The race condition above is difficult to detect. One approach would + ** be to check the aReadMark[] slot for another client. But this is + ** prone to false-positives from other snapshot clients. And there + ** is no equivalent to xCheckReservedLock() for wal locks. Another + ** approach would be to take the checkpointer lock and check that + ** fewer than pSnapshot->mxFrame frames have been checkpointed. But + ** that does not account for checkpointer processes that failed after + ** checkpointing frames but before updating WalCkptInfo.nBackfill. + ** And it would mean that this function would block on checkpointers + ** and vice versa. + ** + ** TODO: For now, this race condition is ignored. + */ volatile WalCkptInfo *pInfo = walCkptInfo(pWal); - rc = walLockShared(pWal, WAL_READ_LOCK(0)); - if( rc==SQLITE_OK ){ - if( pInfo->nBackfill<=pSnapshot->mxFrame - && pSnapshot->aSalt[0]==pWal->hdr.aSalt[0] - && pSnapshot->aSalt[1]==pWal->hdr.aSalt[1] - ){ - assert( pWal->readLock>0 ); - assert( pInfo->aReadMark[pWal->readLock]<=pSnapshot->mxFrame ); - memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr)); - *pChanged = bChanged; - }else{ - rc = SQLITE_BUSY_SNAPSHOT; - } - walUnlockShared(pWal, WAL_READ_LOCK(0)); + + assert( pWal->readLock>0 ); + assert( pInfo->aReadMark[pWal->readLock]<=pSnapshot->mxFrame ); + + /* Check that the wal file has not been wrapped. Assuming it has not, + ** overwrite pWal->hdr with *pSnapshot and set *pChanged as appropriate + ** for opening the snapshot. Or, if the wal file has been wrapped + ** since pSnapshot was written, return SQLITE_BUSY_SNAPSHOT. */ + if( pSnapshot->aSalt[0]==pWal->hdr.aSalt[0] + && pSnapshot->aSalt[1]==pWal->hdr.aSalt[1] + ){ + memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr)); + *pChanged = bChanged; + }else{ + rc = SQLITE_BUSY_SNAPSHOT; } + if( rc!=SQLITE_OK ){ sqlite3WalEndReadTransaction(pWal); } diff --git a/test/snapshot.test b/test/snapshot.test index 4d94225701..5d3758c010 100644 --- a/test/snapshot.test +++ b/test/snapshot.test @@ -57,12 +57,14 @@ do_execsql_test 1.3.2 COMMIT # Check that a simple case works. Reuse the database created by the # block of tests above. # -do_execsql_test 2.0 { +# UPDATE: This case (2.1) no longer works. 2.2 does. +# +do_execsql_test 2.1.0 { BEGIN; SELECT * FROM t1; } {1 2 3 4 5 6 7 8} -do_test 2.1 { +do_test 2.1.1 { set snapshot [sqlite3_snapshot_get db main] execsql { COMMIT; @@ -71,17 +73,47 @@ do_test 2.1 { } } {1 2 3 4 5 6 7 8 9 10} -do_test 2.2 { +do_test 2.1.2 { execsql BEGIN - sqlite3_snapshot_open db main $snapshot - execsql { SELECT * FROM t1 } -} {1 2 3 4 5 6 7 8} + list [catch { sqlite3_snapshot_open db main $snapshot } msg] $msg +} {1 SQLITE_BUSY_SNAPSHOT} -do_test 2.3 { +do_test 2.1.3 { sqlite3_snapshot_free $snapshot execsql COMMIT } {} +do_test 2.2.0 { + sqlite3 db2 test.db + execsql { + BEGIN; + SELECT * FROM t1; + } db2 +} {1 2 3 4 5 6 7 8 9 10} + +do_test 2.2.1 { + set snapshot [sqlite3_snapshot_get db2 main] + execsql { + INSERT INTO t1 VALUES(11, 12); + SELECT * FROM t1; + } +} {1 2 3 4 5 6 7 8 9 10 11 12} + +do_test 2.1.2 { + execsql BEGIN + sqlite3_snapshot_open db main $snapshot + execsql { + SELECT * FROM t1; + } +} {1 2 3 4 5 6 7 8 9 10} + +do_test 2.1.3 { + sqlite3_snapshot_free $snapshot + execsql COMMIT + execsql COMMIT db2 + db2 close +} {} + #------------------------------------------------------------------------- # Check some errors in sqlite3_snapshot_open(). It is an error if: # From 998147ec38ce64fff6307891b067192d2c089097 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 10 Dec 2015 02:15:03 +0000 Subject: [PATCH 071/232] Add the nBackfillAttempted field in formerly unused space in WalCkptInfo and use that field to close the race condition on opening a snapshot. FossilOrigin-Name: cb68e9d0738fc7db7316947b4d2aab91aae819f2 --- manifest | 14 ++-- manifest.uuid | 2 +- src/wal.c | 214 +++++++++++++++++++++++++------------------------- 3 files changed, 116 insertions(+), 114 deletions(-) diff --git a/manifest b/manifest index 09955e2042..32f43abbab 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\ssqlite3_snapshot_open()\sto\sreduce\sthe\schances\sof\sreading\sa\scorrupt\ssnapshot\screated\sby\sa\scheckpointer\sprocess\sexiting\sunexpectedly. -D 2015-12-09T20:05:27.534 +C Add\sthe\snBackfillAttempted\sfield\sin\sformerly\sunused\sspace\sin\sWalCkptInfo\sand\nuse\sthat\sfield\sto\sclose\sthe\srace\scondition\son\sopening\sa\ssnapshot. +D 2015-12-10T02:15:03.333 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 0bd8aa8e0db924493af4c72f527afc9b9e22257a +F src/wal.c 115765a38fa4a03d7334b6ba77db0cedae682eb0 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1409,7 +1409,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 362615b4df94358d0264b0991c3090a0878f054c -R cfc950fbd468350b7777662be2b401a3 -U dan -Z 51de2f0ad57bbe117dc864890e31b83c +P 7315f7cbf4179aadda0f1a0baa1526a9b9f9729f +R 70ffd1e2449a67c034eb4185ab7bdad1 +U drh +Z 159fdbba63f7473f88a04e9240766d6d diff --git a/manifest.uuid b/manifest.uuid index 33aefc5d3b..028205ec43 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7315f7cbf4179aadda0f1a0baa1526a9b9f9729f \ No newline at end of file +cb68e9d0738fc7db7316947b4d2aab91aae819f2 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index af93694e8d..784f993bfc 100644 --- a/src/wal.c +++ b/src/wal.c @@ -272,7 +272,8 @@ int sqlite3WalTrace = 0; /* ** Indices of various locking bytes. WAL_NREADER is the number -** of available reader locks and should be at least 3. +** of available reader locks and should be at least 3. The default +** is SQLITE_SHM_NLOCK==8 and WAL_NREADER==5. */ #define WAL_WRITE_LOCK 0 #define WAL_ALL_BUT_WRITE 1 @@ -292,7 +293,10 @@ typedef struct WalCkptInfo WalCkptInfo; ** The following object holds a copy of the wal-index header content. ** ** The actual header in the wal-index consists of two copies of this -** object. +** object followed by one instance of the WalCkptInfo object. +** For all versions of SQLite through 3.10.0 and probably beyond, +** the locking bytes (WalCkptInfo.aLock) start at offset 120 and +** the total header size is 136 bytes. ** ** The szPage value can be any power of 2 between 512 and 32768, inclusive. ** Or it can be 1 to represent a 65536-byte page. The latter case was @@ -325,6 +329,16 @@ struct WalIndexHdr { ** However, a WAL_WRITE_LOCK thread can move the value of nBackfill from ** mxFrame back to zero when the WAL is reset. ** +** nBackfillAttempted is the largest value of nBackfill that a checkpoint +** has attempted to achieve. Normally nBackfill==nBackfillAtempted, however +** the nBackfillAttempted is set before any backfilling is done and the +** nBackfill is only set afte rall backfilling completes. So if a checkpoint +** crashes, nBackfillAttempted might be larger than nBackfill. The +** WalIndexHdr.mxFrame must never be less than nBackfillAttempted. +** +** The aLock[] field is a set of bytes used for locking. These bytes should +** never be read or written. +** ** There is one entry in aReadMark[] for each reader lock. If a reader ** holds read-lock K, then the value in aReadMark[K] is no greater than ** the mxFrame for that reader. The value READMARK_NOT_USED (0xffffffff) @@ -364,6 +378,9 @@ struct WalIndexHdr { struct WalCkptInfo { u32 nBackfill; /* Number of WAL frames backfilled into DB */ u32 aReadMark[WAL_NREADER]; /* Reader marks */ + u8 aLock[SQLITE_SHM_NLOCK]; /* Reserved space for locks */ + u32 nBackfillAttempted; /* WAL frames perhaps written, or maybe not */ + u32 notUsed0; /* Available for future enhancements */ }; #define READMARK_NOT_USED 0xffffffff @@ -373,9 +390,8 @@ struct WalCkptInfo { ** only support mandatory file-locks, we do not read or write data ** from the region of the file on which locks are applied. */ -#define WALINDEX_LOCK_OFFSET (sizeof(WalIndexHdr)*2 + sizeof(WalCkptInfo)) -#define WALINDEX_LOCK_RESERVED 16 -#define WALINDEX_HDR_SIZE (WALINDEX_LOCK_OFFSET+WALINDEX_LOCK_RESERVED) +#define WALINDEX_LOCK_OFFSET (sizeof(WalIndexHdr)*2+offsetof(WalCkptInfo,aLock)) +#define WALINDEX_HDR_SIZE (sizeof(WalIndexHdr)*2+sizeof(WalCkptInfo)) /* Size of header before each frame in wal */ #define WAL_FRAME_HDRSIZE 24 @@ -435,7 +451,7 @@ struct Wal { u8 lockError; /* True if a locking error has occurred */ #endif #ifdef SQLITE_ENABLE_SNAPSHOT - WalIndexHdr *pSnapshot; + WalIndexHdr *pSnapshot; /* Start transaction here if not NULL */ #endif }; @@ -1201,6 +1217,7 @@ finished: */ pInfo = walCkptInfo(pWal); pInfo->nBackfill = 0; + pInfo->nBackfillAttempted = 0; pInfo->aReadMark[0] = 0; for(i=1; iaReadMark[i] = READMARK_NOT_USED; if( pWal->hdr.mxFrame ) pInfo->aReadMark[1] = pWal->hdr.mxFrame; @@ -1272,7 +1289,11 @@ int sqlite3WalOpen( /* In the amalgamation, the os_unix.c and os_win.c source files come before ** this source file. Verify that the #defines of the locking byte offsets ** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value. + ** For that matter, if the lock offset ever changes from its initial design + ** value of 120, we need to know that so there is an assert() to check it. */ + assert( 120==WALINDEX_LOCK_OFFSET ); + assert( 136==WALINDEX_HDR_SIZE ); #ifdef WIN_SHM_BASE assert( WIN_SHM_BASE==WALINDEX_LOCK_OFFSET ); #endif @@ -1658,6 +1679,7 @@ static void walRestartHdr(Wal *pWal, u32 salt1){ memcpy(&pWal->hdr.aSalt[1], &salt1, 4); walIndexWriteHdr(pWal); pInfo->nBackfill = 0; + pInfo->nBackfillAttempted = 0; pInfo->aReadMark[1] = 0; for(i=2; iaReadMark[i] = READMARK_NOT_USED; assert( pInfo->aReadMark[0]==0 ); @@ -1735,6 +1757,7 @@ static int walCheckpoint( ** cannot be backfilled from the WAL. */ mxSafeFrame = pWal->hdr.mxFrame; + pInfo->nBackfillAttempted = mxSafeFrame; mxPage = pWal->hdr.nPage; for(i=1; ireadOnly & WAL_SHM_RDONLY)==0 - && (mxReadMarkreadOnly & WAL_SHM_RDONLY)==0 + && (mxReadMarkpSnapshot==0 + && pWal->pSnapshot==0 #endif - ){ - for(i=1; iaReadMark[i] = mxFrame; - mxI = i; - walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); - break; - }else if( rc!=SQLITE_BUSY ){ - return rc; - } + ){ + for(i=1; iaReadMark[i] = mxFrame; + mxI = i; + walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); + break; + }else if( rc!=SQLITE_BUSY ){ + return rc; } } - if( mxI==0 ){ + } + if( mxI==0 ){ #ifdef SQLITE_ENABLE_SNAPSHOT - if( pWal->pSnapshot ) return SQLITE_BUSY_SNAPSHOT; + if( pWal->pSnapshot ) return SQLITE_BUSY_SNAPSHOT; #endif - assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 ); - return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTLOCK; - } + assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 ); + return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTLOCK; + } - rc = walLockShared(pWal, WAL_READ_LOCK(mxI)); - if( rc ){ - return rc==SQLITE_BUSY ? WAL_RETRY : rc; - } - /* Now that the read-lock has been obtained, check that neither the - ** value in the aReadMark[] array or the contents of the wal-index - ** header have changed. - ** - ** It is necessary to check that the wal-index header did not change - ** between the time it was read and when the shared-lock was obtained - ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility - ** that the log file may have been wrapped by a writer, or that frames - ** that occur later in the log than pWal->hdr.mxFrame may have been - ** copied into the database by a checkpointer. If either of these things - ** happened, then reading the database with the current value of - ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry - ** instead. - ** - ** Before checking that the live wal-index header has not changed - ** since it was read, set Wal.minFrame to the first frame in the wal - ** file that has not yet been checkpointed. This client will not need - ** to read any frames earlier than minFrame from the wal file - they - ** can be safely read directly from the database file. - ** - ** Because a ShmBarrier() call is made between taking the copy of - ** nBackfill and checking that the wal-header in shared-memory still - ** matches the one cached in pWal->hdr, it is guaranteed that the - ** checkpointer that set nBackfill was not working with a wal-index - ** header newer than that cached in pWal->hdr. If it were, that could - ** cause a problem. The checkpointer could omit to checkpoint - ** a version of page X that lies before pWal->minFrame (call that version - ** A) on the basis that there is a newer version (version B) of the same - ** page later in the wal file. But if version B happens to like past - ** frame pWal->hdr.mxFrame - then the client would incorrectly assume - ** that it can read version A from the database file. However, since - ** we can guarantee that the checkpointer that set nBackfill could not - ** see any pages past pWal->hdr.mxFrame, this problem does not come up. - */ - pWal->minFrame = pInfo->nBackfill+1; - walShmBarrier(pWal); - if( pInfo->aReadMark[mxI]!=mxReadMark - || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) - ){ - walUnlockShared(pWal, WAL_READ_LOCK(mxI)); - return WAL_RETRY; - }else{ - assert( mxReadMark<=pWal->hdr.mxFrame ); - pWal->readLock = (i16)mxI; - } + rc = walLockShared(pWal, WAL_READ_LOCK(mxI)); + if( rc ){ + return rc==SQLITE_BUSY ? WAL_RETRY : rc; + } + /* Now that the read-lock has been obtained, check that neither the + ** value in the aReadMark[] array or the contents of the wal-index + ** header have changed. + ** + ** It is necessary to check that the wal-index header did not change + ** between the time it was read and when the shared-lock was obtained + ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility + ** that the log file may have been wrapped by a writer, or that frames + ** that occur later in the log than pWal->hdr.mxFrame may have been + ** copied into the database by a checkpointer. If either of these things + ** happened, then reading the database with the current value of + ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry + ** instead. + ** + ** Before checking that the live wal-index header has not changed + ** since it was read, set Wal.minFrame to the first frame in the wal + ** file that has not yet been checkpointed. This client will not need + ** to read any frames earlier than minFrame from the wal file - they + ** can be safely read directly from the database file. + ** + ** Because a ShmBarrier() call is made between taking the copy of + ** nBackfill and checking that the wal-header in shared-memory still + ** matches the one cached in pWal->hdr, it is guaranteed that the + ** checkpointer that set nBackfill was not working with a wal-index + ** header newer than that cached in pWal->hdr. If it were, that could + ** cause a problem. The checkpointer could omit to checkpoint + ** a version of page X that lies before pWal->minFrame (call that version + ** A) on the basis that there is a newer version (version B) of the same + ** page later in the wal file. But if version B happens to like past + ** frame pWal->hdr.mxFrame - then the client would incorrectly assume + ** that it can read version A from the database file. However, since + ** we can guarantee that the checkpointer that set nBackfill could not + ** see any pages past pWal->hdr.mxFrame, this problem does not come up. + */ + pWal->minFrame = pInfo->nBackfill+1; + walShmBarrier(pWal); + if( pInfo->aReadMark[mxI]!=mxReadMark + || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) + ){ + walUnlockShared(pWal, WAL_READ_LOCK(mxI)); + return WAL_RETRY; + }else{ + assert( mxReadMark<=pWal->hdr.mxFrame ); + pWal->readLock = (i16)mxI; } return rc; } @@ -2373,7 +2393,7 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ #ifdef SQLITE_ENABLE_SNAPSHOT int bChanged = 0; WalIndexHdr *pSnapshot = pWal->pSnapshot; - if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))){ + if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){ bChanged = 1; } #endif @@ -2388,36 +2408,18 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ #ifdef SQLITE_ENABLE_SNAPSHOT if( rc==SQLITE_OK ){ - if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr)) ){ + if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){ /* At this point the client has a lock on an aReadMark[] slot holding - ** a value equal to or smaller than pSnapshot->mxFrame. This client - ** did not populate the aReadMark[] slot. pWal->hdr is populated with - ** the wal-index header for the snapshot currently at the head of the - ** wal file, which is different from pSnapshot. + ** a value equal to or smaller than pSnapshot->mxFrame. Verify that + ** pSnapshot is still valid before continuing. Reasons why pSnapshot + ** might no longer be valid: ** - ** The presence of the aReadMark[] slot entry makes it very likely - ** that either there is currently another read-transaction open on - ** pSnapshot, or that there has been one more recently than the last - ** checkpoint of any frames greater than pSnapshot->mxFrame was - ** started. There is an exception though: client 1 may have called - ** walTryBeginRead and started to open snapshot pSnapshot, setting - ** the aReadMark[] slot to do so. At the same time, client 2 may - ** have committed a new snapshot to disk and started a checkpoint. - ** In this circumstance client 1 does not end up reading pSnapshot, - ** but may leave the aReadMark[] slot populated. + ** (1) The WAL file has been reset since the snapshot was taken. + ** In this case, the salt will have changed. ** - ** The race condition above is difficult to detect. One approach would - ** be to check the aReadMark[] slot for another client. But this is - ** prone to false-positives from other snapshot clients. And there - ** is no equivalent to xCheckReservedLock() for wal locks. Another - ** approach would be to take the checkpointer lock and check that - ** fewer than pSnapshot->mxFrame frames have been checkpointed. But - ** that does not account for checkpointer processes that failed after - ** checkpointing frames but before updating WalCkptInfo.nBackfill. - ** And it would mean that this function would block on checkpointers - ** and vice versa. - ** - ** TODO: For now, this race condition is ignored. + ** (2) A checkpoint as been attempted that wrote frames past + ** pSnapshot->mxFrame into the database file. Note that the + ** checkpoint need not have completed for this to cause problems. */ volatile WalCkptInfo *pInfo = walCkptInfo(pWal); @@ -2428,8 +2430,8 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ ** overwrite pWal->hdr with *pSnapshot and set *pChanged as appropriate ** for opening the snapshot. Or, if the wal file has been wrapped ** since pSnapshot was written, return SQLITE_BUSY_SNAPSHOT. */ - if( pSnapshot->aSalt[0]==pWal->hdr.aSalt[0] - && pSnapshot->aSalt[1]==pWal->hdr.aSalt[1] + if( memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))==0 + && pSnapshot->mxFrame>=pInfo->nBackfillAttempted ){ memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr)); *pChanged = bChanged; From c9fb38e7adf81cd7ca2b1af4f64bb5787c7dad05 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 10 Dec 2015 03:16:47 +0000 Subject: [PATCH 072/232] Fix spacing typo in comment. No changes to code. FossilOrigin-Name: 3a18526fc2253658dad84c5e600481c8a62efe40 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/wal.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 32f43abbab..a92f8a6ff1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\snBackfillAttempted\sfield\sin\sformerly\sunused\sspace\sin\sWalCkptInfo\sand\nuse\sthat\sfield\sto\sclose\sthe\srace\scondition\son\sopening\sa\ssnapshot. -D 2015-12-10T02:15:03.333 +C Fix\sspacing\stypo\sin\scomment.\s\sNo\schanges\sto\scode. +D 2015-12-10T03:16:47.044 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 115765a38fa4a03d7334b6ba77db0cedae682eb0 +F src/wal.c 964af61902acead7de6e95035d0ce597f7019da9 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1409,7 +1409,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7315f7cbf4179aadda0f1a0baa1526a9b9f9729f -R 70ffd1e2449a67c034eb4185ab7bdad1 -U drh -Z 159fdbba63f7473f88a04e9240766d6d +P cb68e9d0738fc7db7316947b4d2aab91aae819f2 +R 76ea636367cbd8afb53a2670ba03ae31 +U mistachkin +Z 1d7611d28a33701f209bc754328c05f3 diff --git a/manifest.uuid b/manifest.uuid index 028205ec43..d5273835aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cb68e9d0738fc7db7316947b4d2aab91aae819f2 \ No newline at end of file +3a18526fc2253658dad84c5e600481c8a62efe40 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 784f993bfc..0115e06027 100644 --- a/src/wal.c +++ b/src/wal.c @@ -332,7 +332,7 @@ struct WalIndexHdr { ** nBackfillAttempted is the largest value of nBackfill that a checkpoint ** has attempted to achieve. Normally nBackfill==nBackfillAtempted, however ** the nBackfillAttempted is set before any backfilling is done and the -** nBackfill is only set afte rall backfilling completes. So if a checkpoint +** nBackfill is only set after all backfilling completes. So if a checkpoint ** crashes, nBackfillAttempted might be larger than nBackfill. The ** WalIndexHdr.mxFrame must never be less than nBackfillAttempted. ** From ac536e613a0acb84b1df80a836786b06a960f522 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 10 Dec 2015 15:09:17 +0000 Subject: [PATCH 073/232] Move pointer range comparisons into a macro, where they can be dealt with in a more portable way. FossilOrigin-Name: ad3124c834b080aaaf24934d6f08b3601ac3ae53 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/btree.c | 8 +------- src/malloc.c | 4 ++-- src/sqliteInt.h | 15 +++++++++++++++ 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index cc0c4b013d..088aeff321 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\ssimplifications\sto\sthe\sVDBE\scode\sgeneration\slogic\sthat\sflow\sout\nof\sthe\sprevious\scheck-in. -D 2015-12-09T17:23:12.345 +C Move\spointer\srange\scomparisons\sinto\sa\smacro,\swhere\sthey\scan\sbe\sdealt\swith\nin\sa\smore\sportable\sway. +D 2015-12-10T15:09:17.462 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -282,7 +282,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 81d041421359bbffc091c8a95dd0507aa4f09093 +F src/btree.c 450950ce366159c3215736ae43d1062e7c06f741 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b @@ -305,7 +305,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b F src/main.c a950e48920e8c0f0ff82b2b2ccfe11aa89ca11d4 -F src/malloc.c 337bbe9c7d436ef9b7d06b5dd10bbfc8f3025972 +F src/malloc.c 8f787669e79de26efc42272b5797bc00fff527c6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 @@ -344,7 +344,7 @@ F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 1248a78548024bdc8ef5893faa0ff9552b4cceb4 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 5caacf37a776f9d6178e519cb0b5248ca22a3828 +F src/sqliteInt.h d9b64d12231789a5fae72e380da5544ad1a34d9f F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8021b4c8139ba56d6b1e2e26aeec4f9bf77f37c9 -R 9fa6094a1e8a72da130ce9bebe3afcb3 +P 6a5dfe85b519b920ce8c842057767a8793d92236 +R a58d43459fedbad83f2fea42e9df49aa U drh -Z e514ce3bd686c655a7118cedbf26535f +Z 0494ab55e74ae33c389abc3bd2b83951 diff --git a/manifest.uuid b/manifest.uuid index 01a18cf6eb..2355d75154 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a5dfe85b519b920ce8c842057767a8793d92236 \ No newline at end of file +ad3124c834b080aaaf24934d6f08b3601ac3ae53 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 34ce8c3592..1f279b55f6 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7521,13 +7521,7 @@ static int balance_nonroot( ** overflow cell), we can skip updating the pointer map entries. */ if( iOld>=nNew || pNew->pgno!=aPgno[iOld] -#ifdef HAVE_STDINT_H - || (intptr_t)pCell<(intptr_t)aOld - || (intptr_t)pCell>=(intptr_t)&aOld[usableSize] -#else - || pCell=&aOld[usableSize] -#endif + || !SQLITE_WITHIN(pCell,aOld,&aOld[usableSize]) ){ if( !leafCorrection ){ ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc); diff --git a/src/malloc.c b/src/malloc.c index a4968aaa2f..2c493b9320 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -358,7 +358,7 @@ void sqlite3ScratchFree(void *p){ scratchAllocOut--; #endif - if( p>=sqlite3GlobalConfig.pScratch && p=db->lookaside.pStart && plookaside.pEnd; + return SQLITE_WITHIN(p, db->lookaside.pStart, db->lookaside.pEnd); } #else #define isLookaside(A,B) 0 diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0d477dc06f..1f94bad7e6 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -173,6 +173,21 @@ # define SQLITE_PTR_TO_INT(X) ((int)(X)) #endif +/* +** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to +** something between S (inclusive) and E (exclusive). +** +** In other words, S is a buffer and E is a pointer to the first byte after +** the end of buffer S. This macro returns true if P points to something +** contained within the buffer S. +*/ +#if defined(HAVE_STDINT_H) +# define SQLITE_WITHIN(P,S,E) \ + ((uintptr_t)(P)>=(uintptr_h)(S) && (uintptr_t)(P)<(uintptr_t)(E)) +#else +# define SQLITE_WITHIN(P,S,E) ((P)>=(S) && (P)<(E)) +#endif + /* ** A macro to hint to the compiler that a function should not be ** inlined. From 3bf83ccd70bec2af3c47e43ff3c4157356dbbede Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 10 Dec 2015 15:45:15 +0000 Subject: [PATCH 074/232] Have sqlite3_snapshot_open() avoid a race condition by taking a shared CHECKPOINTER lock while checking pInfo->nBackfillAttempted. FossilOrigin-Name: 8084eae0bc4f6513b1147fb890a6b2813f1c0a09 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/wal.c | 41 ++++++++++++++++++++++++++--------------- test/snapshot.test | 13 +++++++------ 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index a92f8a6ff1..e571284281 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sspacing\stypo\sin\scomment.\s\sNo\schanges\sto\scode. -D 2015-12-10T03:16:47.044 +C Have\ssqlite3_snapshot_open()\savoid\sa\srace\scondition\sby\staking\sa\sshared\sCHECKPOINTER\slock\swhile\schecking\spInfo->nBackfillAttempted. +D 2015-12-10T15:45:15.186 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 964af61902acead7de6e95035d0ce597f7019da9 +F src/wal.c 32ee7dc4b689321d1650fba2e937ddc3bccfb06f F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1020,7 +1020,7 @@ F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b -F test/snapshot.test 800e0be4488acb88dd38ff9e9b83edb71d9d5a9d +F test/snapshot.test f91d907460e7acc01d531834d068e1215ccac7e4 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 F test/sort.test 3f492e5b7be1d3f756728d2ff6edf4f6091e84cb @@ -1409,7 +1409,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P cb68e9d0738fc7db7316947b4d2aab91aae819f2 -R 76ea636367cbd8afb53a2670ba03ae31 -U mistachkin -Z 1d7611d28a33701f209bc754328c05f3 +P 3a18526fc2253658dad84c5e600481c8a62efe40 +R 7bb35c02cb12ea2ff304c777229238a5 +U dan +Z 0b9f17bd41106b46c64f60d98c85b1e3 diff --git a/manifest.uuid b/manifest.uuid index d5273835aa..825f8d1181 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3a18526fc2253658dad84c5e600481c8a62efe40 \ No newline at end of file +8084eae0bc4f6513b1147fb890a6b2813f1c0a09 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 0115e06027..0439ed4253 100644 --- a/src/wal.c +++ b/src/wal.c @@ -1217,7 +1217,7 @@ finished: */ pInfo = walCkptInfo(pWal); pInfo->nBackfill = 0; - pInfo->nBackfillAttempted = 0; + pInfo->nBackfillAttempted = pWal->hdr.mxFrame; pInfo->aReadMark[0] = 0; for(i=1; iaReadMark[i] = READMARK_NOT_USED; if( pWal->hdr.mxFrame ) pInfo->aReadMark[1] = pWal->hdr.mxFrame; @@ -1757,7 +1757,6 @@ static int walCheckpoint( ** cannot be backfilled from the WAL. */ mxSafeFrame = pWal->hdr.mxFrame; - pInfo->nBackfillAttempted = mxSafeFrame; mxPage = pWal->hdr.nPage; for(i=1; inBackfill; + pInfo->nBackfillAttempted = mxSafeFrame; + /* Sync the WAL to disk */ if( sync_flags ){ rc = sqlite3OsSync(pWal->pWalFd, sync_flags); @@ -2296,9 +2297,6 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ } if( (pWal->readOnly & WAL_SHM_RDONLY)==0 && (mxReadMarkpSnapshot==0 -#endif ){ for(i=1; ipSnapshot ) return SQLITE_BUSY_SNAPSHOT; -#endif assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 ); return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTLOCK; } @@ -2410,9 +2405,10 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ if( rc==SQLITE_OK ){ if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){ /* At this point the client has a lock on an aReadMark[] slot holding - ** a value equal to or smaller than pSnapshot->mxFrame. Verify that - ** pSnapshot is still valid before continuing. Reasons why pSnapshot - ** might no longer be valid: + ** a value equal to or smaller than pSnapshot->mxFrame, but pWal->hdr + ** is populated with the wal-index header corresponding to the head + ** of the wal file. Verify that pSnapshot is still valid before + ** continuing. Reasons why pSnapshot might no longer be valid: ** ** (1) The WAL file has been reset since the snapshot was taken. ** In this case, the salt will have changed. @@ -2426,10 +2422,22 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ assert( pWal->readLock>0 ); assert( pInfo->aReadMark[pWal->readLock]<=pSnapshot->mxFrame ); - /* Check that the wal file has not been wrapped. Assuming it has not, - ** overwrite pWal->hdr with *pSnapshot and set *pChanged as appropriate - ** for opening the snapshot. Or, if the wal file has been wrapped - ** since pSnapshot was written, return SQLITE_BUSY_SNAPSHOT. */ + /* It is possible that there is a checkpointer thread running + ** concurrent with this code. If this is the case, it may be that the + ** checkpointer has already determined that it will checkpoint + ** snapshot X, where X is later in the wal file than pSnapshot, but + ** has not yet set the pInfo->nBackfillAttempted variable to indicate + ** its intent. To avoid the race condition this leads to, ensure that + ** there is no checkpointer process by taking a shared CKPT lock + ** before checking pInfo->nBackfillAttempted. */ + rc = walLockShared(pWal, WAL_CKPT_LOCK); + + /* Check that the wal file has not been wrapped. Assuming that it has + ** not, also check that no checkpointer has attempted to checkpoint + ** any frames beyond pSnapshot->mxFrame. If either of these conditions + ** are true, return SQLTIE_BUSY_SNAPSHOT. Otherwise, overwrite pWal->hdr + ** with *pSnapshot and set *pChanged as appropriate for opening the + ** snapshot. */ if( memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))==0 && pSnapshot->mxFrame>=pInfo->nBackfillAttempted ){ @@ -2439,6 +2447,9 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ rc = SQLITE_BUSY_SNAPSHOT; } + /* Release the shared CKPT lock obtained above. */ + walUnlockShared(pWal, WAL_CKPT_LOCK); + if( rc!=SQLITE_OK ){ sqlite3WalEndReadTransaction(pWal); } diff --git a/test/snapshot.test b/test/snapshot.test index 5d3758c010..965e10b683 100644 --- a/test/snapshot.test +++ b/test/snapshot.test @@ -57,8 +57,6 @@ do_execsql_test 1.3.2 COMMIT # Check that a simple case works. Reuse the database created by the # block of tests above. # -# UPDATE: This case (2.1) no longer works. 2.2 does. -# do_execsql_test 2.1.0 { BEGIN; SELECT * FROM t1; @@ -75,8 +73,11 @@ do_test 2.1.1 { do_test 2.1.2 { execsql BEGIN - list [catch { sqlite3_snapshot_open db main $snapshot } msg] $msg -} {1 SQLITE_BUSY_SNAPSHOT} + sqlite3_snapshot_open db main $snapshot + execsql { + SELECT * FROM t1; + } +} {1 2 3 4 5 6 7 8} do_test 2.1.3 { sqlite3_snapshot_free $snapshot @@ -99,7 +100,7 @@ do_test 2.2.1 { } } {1 2 3 4 5 6 7 8 9 10 11 12} -do_test 2.1.2 { +do_test 2.2.2 { execsql BEGIN sqlite3_snapshot_open db main $snapshot execsql { @@ -107,7 +108,7 @@ do_test 2.1.2 { } } {1 2 3 4 5 6 7 8 9 10} -do_test 2.1.3 { +do_test 2.2.3 { sqlite3_snapshot_free $snapshot execsql COMMIT execsql COMMIT db2 From 7d15979420c6cf911862945bc07f69a309894fba Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 10 Dec 2015 18:06:21 +0000 Subject: [PATCH 075/232] Add tests to ensure that an sqlite3_snapshot_open() client cannot be tricked into reading a corrupt snapshot even if another process fails mid-checkpoint. FossilOrigin-Name: b908048b6cfa1ee2fe1f7a17bae475ddd9d0376c --- manifest | 13 ++-- manifest.uuid | 2 +- test/snapshot.test | 5 +- test/snapshot_fault.test | 164 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+), 10 deletions(-) create mode 100644 test/snapshot_fault.test diff --git a/manifest b/manifest index e571284281..2b87b9f307 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\ssqlite3_snapshot_open()\savoid\sa\srace\scondition\sby\staking\sa\sshared\sCHECKPOINTER\slock\swhile\schecking\spInfo->nBackfillAttempted. -D 2015-12-10T15:45:15.186 +C Add\stests\sto\sensure\sthat\san\ssqlite3_snapshot_open()\sclient\scannot\sbe\stricked\sinto\sreading\sa\scorrupt\ssnapshot\seven\sif\sanother\sprocess\sfails\smid-checkpoint. +D 2015-12-10T18:06:21.050 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -1020,7 +1020,8 @@ F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b -F test/snapshot.test f91d907460e7acc01d531834d068e1215ccac7e4 +F test/snapshot.test 5631669a133c96aaa228f7233989f6d2d069fb02 +F test/snapshot_fault.test 06472056c516be4610834de4688ea3357e8bde01 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 F test/sort.test 3f492e5b7be1d3f756728d2ff6edf4f6091e84cb @@ -1409,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3a18526fc2253658dad84c5e600481c8a62efe40 -R 7bb35c02cb12ea2ff304c777229238a5 +P 8084eae0bc4f6513b1147fb890a6b2813f1c0a09 +R b7a6ff87063d246e894cc3fd88f3e89f U dan -Z 0b9f17bd41106b46c64f60d98c85b1e3 +Z 1fe7db1e51b0eef5aa529631bb7527d1 diff --git a/manifest.uuid b/manifest.uuid index 825f8d1181..82eea9660d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8084eae0bc4f6513b1147fb890a6b2813f1c0a09 \ No newline at end of file +b908048b6cfa1ee2fe1f7a17bae475ddd9d0376c \ No newline at end of file diff --git a/test/snapshot.test b/test/snapshot.test index 965e10b683..c74a2859fe 100644 --- a/test/snapshot.test +++ b/test/snapshot.test @@ -8,10 +8,9 @@ # May you share freely, never taking more than you give. # #*********************************************************************** -# This file implements regression tests for SQLite library. The -# focus of this file is testing the SELECT statement. +# This file implements regression tests for SQLite library. The focus +# of this file is the sqlite3_snapshot_xxx() APIs. # -# $Id: select1.test,v 1.70 2009/05/28 01:00:56 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/snapshot_fault.test b/test/snapshot_fault.test new file mode 100644 index 0000000000..a7731b8161 --- /dev/null +++ b/test/snapshot_fault.test @@ -0,0 +1,164 @@ +# 2015 December 10 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The focus +# of this file is the sqlite3_snapshot_xxx() APIs. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix snapshot_fault + +#------------------------------------------------------------------------- +# Check that an sqlite3_snapshot_open() client cannot be tricked into +# reading a corrupt snapshot even if a second client fails while +# checkpointing the db. +# +do_faultsim_test 1.0 -prep { + faultsim_delete_and_reopen + sqlite3 db2 test.db + db2 eval { + CREATE TABLE t1(a, b UNIQUE, c UNIQUE); + INSERT INTO t1 VALUES(1, randomblob(500), randomblob(500)); + INSERT INTO t1 VALUES(2, randomblob(500), randomblob(500)); + PRAGMA journal_mode = wal; + INSERT INTO t1 VALUES(3, randomblob(500), randomblob(500)); + BEGIN; + SELECT a FROM t1; + } + set ::snapshot [sqlite3_snapshot_get db2 main] + db2 eval COMMIT + db2 eval { + UPDATE t1 SET b=randomblob(501), c=randomblob(501) WHERE a=1; + INSERT INTO t1 VALUES(4, randomblob(500), randomblob(500)); + INSERT INTO t1 VALUES(5, randomblob(500), randomblob(500)); + INSERT INTO t1 VALUES(6, randomblob(500), randomblob(500)); + } +} -body { + db eval { PRAGMA wal_checkpoint } +} -test { + db2 eval BEGIN + if {[catch { sqlite3_snapshot_open db2 main $::snapshot } msg]} { + if {$msg != "SQLITE_BUSY_SNAPSHOT" && $msg != "SQLITE_BUSY"} { + error "error is $msg" + } + } else { + set res [db2 eval { + SELECT a FROM t1; + PRAGMA integrity_check; + }] + if {$res != "1 2 3 ok"} { error "res is $res" } + } + + sqlite3_snapshot_free $::snapshot +} + +#------------------------------------------------------------------------- +# This test is similar to the previous one. Except, after the +# "PRAGMA wal_checkpoint" command fails the db is closed and reopened +# so as to require wal file recovery. It should not be possible to open +# a snapshot that is part of the body of a recovered wal file. +# +do_faultsim_test 2.0 -prep { + faultsim_delete_and_reopen + db eval { + CREATE TABLE t1(a, b UNIQUE, c UNIQUE); + INSERT INTO t1 VALUES(1, randomblob(500), randomblob(500)); + INSERT INTO t1 VALUES(2, randomblob(500), randomblob(500)); + PRAGMA journal_mode = wal; + INSERT INTO t1 VALUES(3, randomblob(500), randomblob(500)); + BEGIN; + SELECT a FROM t1; + } + set ::snapshot [sqlite3_snapshot_get db main] + db eval COMMIT + + db eval { + UPDATE t1 SET b=randomblob(501), c=randomblob(501) WHERE a=1; + INSERT INTO t1 VALUES(4, randomblob(500), randomblob(500)); + INSERT INTO t1 VALUES(5, randomblob(500), randomblob(500)); + INSERT INTO t1 VALUES(6, randomblob(500), randomblob(500)); + } +} -body { + db eval { PRAGMA wal_checkpoint } +} -test { + + db_save + db close + db_restore_and_reopen + db eval { SELECT * FROM t1 } + + db eval BEGIN + if {[catch { sqlite3_snapshot_open db main $::snapshot } msg]} { + if {$msg != "SQLITE_BUSY_SNAPSHOT" && $msg != "SQLITE_BUSY"} { + error "error is $msg" + } + } else { + # This branch should actually never be taken. But it was useful in + # determining whether or not this test was actually working (by + # running a modified version of SQLite that allowed snapshots to be + # opened following a recovery). + error "TEST HAS FAILED" + + set res [db eval { + SELECT a FROM t1; + PRAGMA integrity_check; + }] + if {$res != "1 2 3 ok"} { error "res is $res" } + } + + sqlite3_snapshot_free $::snapshot +} + +#------------------------------------------------------------------------- +# Test the handling of faults that occur within sqlite3_snapshot_open(). +# +do_faultsim_test 3.0 -prep { + faultsim_delete_and_reopen + db eval { + CREATE TABLE t1(a, b UNIQUE, c UNIQUE); + INSERT INTO t1 VALUES(1, randomblob(500), randomblob(500)); + INSERT INTO t1 VALUES(2, randomblob(500), randomblob(500)); + PRAGMA journal_mode = wal; + INSERT INTO t1 VALUES(3, randomblob(500), randomblob(500)); + BEGIN; + SELECT a FROM t1; + } + set ::snapshot [sqlite3_snapshot_get db main] + db eval COMMIT + db eval { + UPDATE t1 SET b=randomblob(501), c=randomblob(501) WHERE a=1; + INSERT INTO t1 VALUES(4, randomblob(500), randomblob(500)); + INSERT INTO t1 VALUES(5, randomblob(500), randomblob(500)); + INSERT INTO t1 VALUES(6, randomblob(500), randomblob(500)); + BEGIN; + } +} -body { + if { [catch { sqlite3_snapshot_open db main $::snapshot } msg] } { + error $msg + } +} -test { + faultsim_test_result {0 {}} {1 SQLITE_IOERR} \ + {1 SQLITE_IOERR_NOMEM} {1 SQLITE_IOERR_READ} + if {$testrc==0} { + set res [db eval { + SELECT a FROM t1; + PRAGMA integrity_check; + }] + if {$res != "1 2 3 ok"} { error "res is $res" } + } + + sqlite3_snapshot_free $::snapshot +} + + + +finish_test + From a7aeb398362466eca9052c4532f620303003fc67 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 10 Dec 2015 19:11:34 +0000 Subject: [PATCH 076/232] Return SQLITE_BUSY (not SQLITE_BUSY_SNAPSHOT) if sqlite3_snapshot_open() fails to obtain the shared checkpointer lock. FossilOrigin-Name: 5343060bcc6c99029f731f8020d2cba3f405f207 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/wal.c | 33 ++++++++++++++++++--------------- test/snapshot.test | 44 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 2b87b9f307..a3a772f96e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sto\sensure\sthat\san\ssqlite3_snapshot_open()\sclient\scannot\sbe\stricked\sinto\sreading\sa\scorrupt\ssnapshot\seven\sif\sanother\sprocess\sfails\smid-checkpoint. -D 2015-12-10T18:06:21.050 +C Return\sSQLITE_BUSY\s(not\sSQLITE_BUSY_SNAPSHOT)\sif\ssqlite3_snapshot_open()\sfails\sto\sobtain\sthe\sshared\scheckpointer\slock. +D 2015-12-10T19:11:34.013 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 32ee7dc4b689321d1650fba2e937ddc3bccfb06f +F src/wal.c 94576d273e7feeae598188ebec641906a5b93a2f F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1020,7 +1020,7 @@ F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b -F test/snapshot.test 5631669a133c96aaa228f7233989f6d2d069fb02 +F test/snapshot.test 184c7ed21f204a5bd909246560edfac308467609 F test/snapshot_fault.test 06472056c516be4610834de4688ea3357e8bde01 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8084eae0bc4f6513b1147fb890a6b2813f1c0a09 -R b7a6ff87063d246e894cc3fd88f3e89f +P b908048b6cfa1ee2fe1f7a17bae475ddd9d0376c +R 1311c20224293debd3e251bf775d0f5c U dan -Z 1fe7db1e51b0eef5aa529631bb7527d1 +Z ae2ff3e1ce7fc4e495f8fcae9626097f diff --git a/manifest.uuid b/manifest.uuid index 82eea9660d..202cc78fbb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b908048b6cfa1ee2fe1f7a17bae475ddd9d0376c \ No newline at end of file +5343060bcc6c99029f731f8020d2cba3f405f207 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 0439ed4253..e5527029ac 100644 --- a/src/wal.c +++ b/src/wal.c @@ -2432,23 +2432,26 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ ** before checking pInfo->nBackfillAttempted. */ rc = walLockShared(pWal, WAL_CKPT_LOCK); - /* Check that the wal file has not been wrapped. Assuming that it has - ** not, also check that no checkpointer has attempted to checkpoint - ** any frames beyond pSnapshot->mxFrame. If either of these conditions - ** are true, return SQLTIE_BUSY_SNAPSHOT. Otherwise, overwrite pWal->hdr - ** with *pSnapshot and set *pChanged as appropriate for opening the - ** snapshot. */ - if( memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))==0 - && pSnapshot->mxFrame>=pInfo->nBackfillAttempted - ){ - memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr)); - *pChanged = bChanged; - }else{ - rc = SQLITE_BUSY_SNAPSHOT; + if( rc==SQLITE_OK ){ + /* Check that the wal file has not been wrapped. Assuming that it has + ** not, also check that no checkpointer has attempted to checkpoint any + ** frames beyond pSnapshot->mxFrame. If either of these conditions are + ** true, return SQLITE_BUSY_SNAPSHOT. Otherwise, overwrite pWal->hdr + ** with *pSnapshot and set *pChanged as appropriate for opening the + ** snapshot. */ + if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt)) + && pSnapshot->mxFrame>=pInfo->nBackfillAttempted + ){ + memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr)); + *pChanged = bChanged; + }else{ + rc = SQLITE_BUSY_SNAPSHOT; + } + + /* Release the shared CKPT lock obtained above. */ + walUnlockShared(pWal, WAL_CKPT_LOCK); } - /* Release the shared CKPT lock obtained above. */ - walUnlockShared(pWal, WAL_CKPT_LOCK); if( rc!=SQLITE_OK ){ sqlite3WalEndReadTransaction(pWal); diff --git a/test/snapshot.test b/test/snapshot.test index c74a2859fe..564881cae1 100644 --- a/test/snapshot.test +++ b/test/snapshot.test @@ -246,5 +246,49 @@ do_test 4.2.4 { sqlite3_snapshot_free $snapshot } {} +#------------------------------------------------------------------------- +# Check that SQLITE_BUSY is returned if a checkpoint is running when +# sqlite3_snapshot_open() is called. +# +reset_db +db close +testvfs tvfs +sqlite3 db test.db -vfs tvfs + +do_execsql_test 5.1 { + PRAGMA journal_mode = wal; + CREATE TABLE x1(x, xx, xxx); + INSERT INTO x1 VALUES('z', 'zz', 'zzz'); + BEGIN; + SELECT * FROM x1; +} {wal z zz zzz} + +do_test 5.2 { + set ::snapshot [sqlite3_snapshot_get db main] + sqlite3 db2 test.db -vfs tvfs + execsql { + INSERT INTO x1 VALUES('a', 'aa', 'aaa'); + COMMIT; + } +} {} + +set t53 0 +proc write_callback {args} { +breakpoint + do_test 5.3.[incr ::t53] { + execsql BEGIN + list [catch { sqlite3_snapshot_open db main $::snapshot } msg] $msg + } {1 SQLITE_BUSY} + catchsql COMMIT +} + +tvfs filter xWrite +tvfs script write_callback +db2 eval { PRAGMA wal_checkpoint } +db close +db2 close +tvfs delete +sqlite3_snapshot_free $snapshot + finish_test From 745c14eb15d8ce2048e2e9185b3780ddb5671d9b Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 10 Dec 2015 19:44:34 +0000 Subject: [PATCH 077/232] Add tests to snapshot.test. FossilOrigin-Name: f3b743623a4501833478c8a86c0922931955aeb6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/snapshot.test | 29 ++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a3a772f96e..c962225c27 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Return\sSQLITE_BUSY\s(not\sSQLITE_BUSY_SNAPSHOT)\sif\ssqlite3_snapshot_open()\sfails\sto\sobtain\sthe\sshared\scheckpointer\slock. -D 2015-12-10T19:11:34.013 +C Add\stests\sto\ssnapshot.test. +D 2015-12-10T19:44:34.237 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -1020,7 +1020,7 @@ F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b -F test/snapshot.test 184c7ed21f204a5bd909246560edfac308467609 +F test/snapshot.test 62983ac46f05b898d5317a8d1b91a7bd8a355988 F test/snapshot_fault.test 06472056c516be4610834de4688ea3357e8bde01 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b908048b6cfa1ee2fe1f7a17bae475ddd9d0376c -R 1311c20224293debd3e251bf775d0f5c +P 5343060bcc6c99029f731f8020d2cba3f405f207 +R cf3f8934dbec5c5165c0ac82e4a8ba25 U dan -Z ae2ff3e1ce7fc4e495f8fcae9626097f +Z 7e377350f279588c8392c3c3e03a4f17 diff --git a/manifest.uuid b/manifest.uuid index 202cc78fbb..7a16425ff5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5343060bcc6c99029f731f8020d2cba3f405f207 \ No newline at end of file +f3b743623a4501833478c8a86c0922931955aeb6 \ No newline at end of file diff --git a/test/snapshot.test b/test/snapshot.test index 564881cae1..37af5b8e04 100644 --- a/test/snapshot.test +++ b/test/snapshot.test @@ -274,7 +274,6 @@ do_test 5.2 { set t53 0 proc write_callback {args} { -breakpoint do_test 5.3.[incr ::t53] { execsql BEGIN list [catch { sqlite3_snapshot_open db main $::snapshot } msg] $msg @@ -290,5 +289,33 @@ db2 close tvfs delete sqlite3_snapshot_free $snapshot +#------------------------------------------------------------------------- +# Test that sqlite3_snapshot_get() may be called immediately after +# "BEGIN; PRAGMA user_version;". And that sqlite3_snapshot_open() may +# be called after opening the db handle and running the script +# "PRAGMA user_version; BEGIN". +reset_db +do_execsql_test 6.1 { + PRAGMA journal_mode = wal; + CREATE TABLE x1(x, xx, xxx); + INSERT INTO x1 VALUES('z', 'zz', 'zzz'); + BEGIN; + PRAGMA user_version; +} {wal 0} +do_test 6.2 { + set ::snapshot [sqlite3_snapshot_get db main] + execsql { + INSERT INTO x1 VALUES('a', 'aa', 'aaa'); + COMMIT; + } +} {} +do_test 6.3 { + sqlite3 db2 test.db + db2 eval "PRAGMA user_version ; BEGIN" + sqlite3_snapshot_open db2 main $::snapshot + db2 eval { SELECT * FROM x1 } +} {z zz zzz} +sqlite3_snapshot_free $snapshot + finish_test From 7116dc60dc1017472e254a4e475a13c621996e6d Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 10 Dec 2015 20:03:08 +0000 Subject: [PATCH 078/232] Update the sqlite3_snapshot_get() API so that if the caller does not have an open read transaction on the named database, one is automatically opened. FossilOrigin-Name: b9c90f10297d8516a661449e8af898e682c930aa --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/main.c | 9 +++++---- src/sqlite.h.in | 6 ++++-- test/snapshot.test | 41 ++++++++++++++++++++++++++++++----------- 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index c962225c27..8387bc5312 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sto\ssnapshot.test. -D 2015-12-10T19:44:34.237 +C Update\sthe\ssqlite3_snapshot_get()\sAPI\sso\sthat\sif\sthe\scaller\sdoes\snot\shave\san\sopen\sread\stransaction\son\sthe\snamed\sdatabase,\sone\sis\sautomatically\sopened. +D 2015-12-10T20:03:08.672 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -304,7 +304,7 @@ F src/insert.c e1d20ae8979e25519c2670233718676bedcfedc9 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b -F src/main.c 3dc84d9bd722fb16c196a867d39acf86b8f72b70 +F src/main.c 2f33510a6a392c606fe64964e695e55ad124242f F src/malloc.c 337bbe9c7d436ef9b7d06b5dd10bbfc8f3025972 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -341,7 +341,7 @@ F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 -F src/sqlite.h.in 19dea4862ccfcc1a733d0fd18d4744b02a505ac6 +F src/sqlite.h.in fa2c9d85cb144fad389864f9e40c4f59336d31ed F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d F src/sqliteInt.h 5caacf37a776f9d6178e519cb0b5248ca22a3828 @@ -1020,7 +1020,7 @@ F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b -F test/snapshot.test 62983ac46f05b898d5317a8d1b91a7bd8a355988 +F test/snapshot.test bfcf728577d674d85b7da4bc69786ecafd2acebe F test/snapshot_fault.test 06472056c516be4610834de4688ea3357e8bde01 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5343060bcc6c99029f731f8020d2cba3f405f207 -R cf3f8934dbec5c5165c0ac82e4a8ba25 +P f3b743623a4501833478c8a86c0922931955aeb6 +R 50bb5d50d586d96f69cac8095fa25e56 U dan -Z 7e377350f279588c8392c3c3e03a4f17 +Z 07077a92d084d80e6cdd7a283dbdc283 diff --git a/manifest.uuid b/manifest.uuid index 7a16425ff5..3dacbbd066 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f3b743623a4501833478c8a86c0922931955aeb6 \ No newline at end of file +b9c90f10297d8516a661449e8af898e682c930aa \ No newline at end of file diff --git a/src/main.c b/src/main.c index 902954b60d..5b2130511e 100644 --- a/src/main.c +++ b/src/main.c @@ -3891,10 +3891,11 @@ int sqlite3_snapshot_get( iDb = sqlite3FindDbName(db, zDb); if( iDb==0 || iDb>1 ){ Btree *pBt = db->aDb[iDb].pBt; - if( 0!=sqlite3BtreeIsInReadTrans(pBt) - && 0==sqlite3BtreeIsInTrans(pBt) - ){ - rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot); + if( 0==sqlite3BtreeIsInTrans(pBt) ){ + rc = sqlite3BtreeBeginTrans(pBt, 0); + if( rc==SQLITE_OK ){ + rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot); + } } } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 601415b907..8dcf99eb2a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -7883,8 +7883,10 @@ int sqlite3_db_cacheflush(sqlite3*); ** ** The second argument passed to sqlite3_snapshot_get() must be the name ** of a database file attached to the database handle passed as the first. -** The database handle must have an open read transaction on the named -** database, which must be in wal mode. +** The database handle must not have an open write transaction on the named +** database, which must be in wal mode. If the database handle does not +** have an open read transaction on the named file, this function opens +** one. ** ** If successful, sqlite3_snapshot_get() sets *ppSnapshot to point to a new ** snapshot handle that may be used with sqlite3_snapshot_open() and returns diff --git a/test/snapshot.test b/test/snapshot.test index 37af5b8e04..a01ac5a754 100644 --- a/test/snapshot.test +++ b/test/snapshot.test @@ -19,9 +19,8 @@ set testprefix snapshot #------------------------------------------------------------------------- # Check some error conditions in snapshot_get(). It is an error if: # -# 1) snapshot_get() is called on a non-WAL database. -# 2) there is no open read transaction on the database, or -# 3) there is an open write transaction on the database. +# 1) snapshot_get() is called on a non-WAL database, or +# 2) there is an open write transaction on the database. # do_execsql_test 1.0 { CREATE TABLE t1(a, b); @@ -37,15 +36,9 @@ do_execsql_test 1.1.2 COMMIT do_test 1.2.1 { execsql { - PRAGMA journal_mode = wal; - INSERT INTO t1 VALUES(5, 6); - } - list [catch { sqlite3_snapshot_get db main } msg] $msg -} {1 SQLITE_ERROR} - -do_test 1.3.1 { - execsql { + PRAGMA journal_mode = WAL; BEGIN; + INSERT INTO t1 VALUES(5, 6); INSERT INTO t1 VALUES(7, 8); } list [catch { sqlite3_snapshot_get db main } msg] $msg @@ -61,6 +54,7 @@ do_execsql_test 2.1.0 { SELECT * FROM t1; } {1 2 3 4 5 6 7 8} +breakpoint do_test 2.1.1 { set snapshot [sqlite3_snapshot_get db main] execsql { @@ -114,6 +108,31 @@ do_test 2.2.3 { db2 close } {} +do_test 2.3.1 { + execsql { DELETE FROM t1 WHERE a>6 } + set snapshot [sqlite3_snapshot_get db main] + execsql { + INSERT INTO t1 VALUES('a', 'b'); + INSERT INTO t1 VALUES('c', 'd'); + SELECT * FROM t1; + } +} {1 2 3 4 5 6 a b c d} +do_test 2.3.2 { + execsql BEGIN + sqlite3_snapshot_open db main $snapshot + execsql { SELECT * FROM t1 } +} {1 2 3 4 5 6} + +do_test 2.3.3 { + catchsql { + INSERT INTO t1 VALUES('x','y') + } +} {1 {database is locked}} +do_test 2.3.4 { + execsql COMMIT + sqlite3_snapshot_free $snapshot +} {} + #------------------------------------------------------------------------- # Check some errors in sqlite3_snapshot_open(). It is an error if: # From e230a8994e1b0f4d76482e5c04954859e2cd32da Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 10 Dec 2015 22:48:22 +0000 Subject: [PATCH 079/232] Snapshot documentation updates. Comment changes only - no changes to code. FossilOrigin-Name: ef51a398a04963508389ffe2f9d8359c1ec48261 --- manifest | 16 +++--- manifest.uuid | 2 +- src/sqlite.h.in | 142 ++++++++++++++++++++++++++++-------------------- src/wal.c | 6 ++ 4 files changed, 98 insertions(+), 68 deletions(-) diff --git a/manifest b/manifest index 8387bc5312..1988a1e007 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\ssqlite3_snapshot_get()\sAPI\sso\sthat\sif\sthe\scaller\sdoes\snot\shave\san\sopen\sread\stransaction\son\sthe\snamed\sdatabase,\sone\sis\sautomatically\sopened. -D 2015-12-10T20:03:08.672 +C Snapshot\sdocumentation\supdates.\s\sComment\schanges\sonly\s-\sno\schanges\sto\scode. +D 2015-12-10T22:48:22.684 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -341,7 +341,7 @@ F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 -F src/sqlite.h.in fa2c9d85cb144fad389864f9e40c4f59336d31ed +F src/sqlite.h.in e24a1d2e36970ca46beb8002623e1c73eab32063 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d F src/sqliteInt.h 5caacf37a776f9d6178e519cb0b5248ca22a3828 @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 94576d273e7feeae598188ebec641906a5b93a2f +F src/wal.c 4ecd256ad59675472fbf211001b511cb31877a74 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f3b743623a4501833478c8a86c0922931955aeb6 -R 50bb5d50d586d96f69cac8095fa25e56 -U dan -Z 07077a92d084d80e6cdd7a283dbdc283 +P b9c90f10297d8516a661449e8af898e682c930aa +R 359f52ff04c40d68d5a15fc7ff658a21 +U drh +Z f10084cbd288f6e41be166b6d28c4cd6 diff --git a/manifest.uuid b/manifest.uuid index 3dacbbd066..d0158534a5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b9c90f10297d8516a661449e8af898e682c930aa \ No newline at end of file +ef51a398a04963508389ffe2f9d8359c1ec48261 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 8dcf99eb2a..780a702307 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4405,8 +4405,8 @@ unsigned int sqlite3_value_subtype(sqlite3_value*); ** previously obtained from [sqlite3_value_dup()]. ^If V is a NULL pointer ** then sqlite3_value_free(V) is a harmless no-op. */ -SQLITE_EXPERIMENTAL sqlite3_value *sqlite3_value_dup(const sqlite3_value*); -SQLITE_EXPERIMENTAL void sqlite3_value_free(sqlite3_value*); +sqlite3_value *sqlite3_value_dup(const sqlite3_value*); +void sqlite3_value_free(sqlite3_value*); /* ** CAPI3REF: Obtain Aggregate Function Context @@ -7851,85 +7851,109 @@ void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*); /* ** CAPI3REF: Flush caches to disk mid-transaction ** -** If a write-transaction is open when this function is called, any dirty +** ^If a write-transaction is open on [database connection] D when the +** [sqlite3_db_cacheflush(D)] interface invoked, any dirty ** pages in the pager-cache that are not currently in use are written out ** to disk. A dirty page may be in use if a database cursor created by an ** active SQL statement is reading from it, or if it is page 1 of a database -** file (page 1 is always "in use"). Dirty pages are flushed for all -** databases - "main", "temp" and any attached databases. +** file (page 1 is always "in use"). ^The [sqlite3_db_cacheflush(D)] +** interface flushes caches for all schemas - "main", "temp", and +** any [attached] databases. ** -** If this function needs to obtain extra database locks before dirty pages -** can be flushed to disk, it does so. If said locks cannot be obtained +** ^If this function needs to obtain extra database locks before dirty pages +** can be flushed to disk, it does so. ^If those locks cannot be obtained ** immediately and there is a busy-handler callback configured, it is invoked -** in the usual manner. If the required lock still cannot be obtained, then +** in the usual manner. ^If the required lock still cannot be obtained, then ** the database is skipped and an attempt made to flush any dirty pages -** belonging to the next (if any) database. If any databases are skipped +** belonging to the next (if any) database. ^If any databases are skipped ** because locks cannot be obtained, but no other error occurs, this ** function returns SQLITE_BUSY. ** -** If any other error occurs while flushing dirty pages to disk (for +** ^If any other error occurs while flushing dirty pages to disk (for ** example an IO error or out-of-memory condition), then processing is -** abandoned and an SQLite error code returned to the caller immediately. +** abandoned and an SQLite [error code] is returned to the caller immediately. ** -** Otherwise, if no error occurs, SQLITE_OK is returned. +** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK. ** -** This function does not set the database handle error code or message -** returned by the sqlite3_errcode() and sqlite3_errmsg() functions. +** ^This function does not set the database handle error code or message +** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions. */ int sqlite3_db_cacheflush(sqlite3*); /* -** CAPI3REF: Open old database snapshots. +** CAPI3REF: Database Snapshot +** KEYWORDS: {snapshot} +** EXPERIMENTAL ** -** The second argument passed to sqlite3_snapshot_get() must be the name -** of a database file attached to the database handle passed as the first. -** The database handle must not have an open write transaction on the named -** database, which must be in wal mode. If the database handle does not -** have an open read transaction on the named file, this function opens -** one. +** An instance of the snapshot object records the state of a [WAL mode] +** database for some specific point in history. ** -** If successful, sqlite3_snapshot_get() sets *ppSnapshot to point to a new -** snapshot handle that may be used with sqlite3_snapshot_open() and returns -** SQLITE_OK. +** In [WAL mode], multiple [database connections] that are open on the +** same database file can each be reading a different historical version +** of the database file. When a [database connection] begins a read +** transaction, that connection sees an unchanging copy of the database +** as it existed for the point in time when the transaction first started. +** Subsequent changes to the database from other connections are not seen +** by the reader until a new read transaction is started. ** -** If the specified database does not exist, or is not a wal mode database, -** or the database handle does not have an open read transaction on it, -** SQLITE_ERROR is returned. If any other error occurs, for example an IO -** error or an OOM condition, the corresponding SQLite error code is -** returned. +** The sqlite3_snapshot object records state information about an historical +** version of the database file so that it is possible to later open a new read +** transaction that sees that historical version of the database rather than +** the most recent version. ** -** Each successful call to sqlite3_snapshot_get() must be matched by a call -** to sqlite3_snapshot_free() to delete the snapshot handle. Not doing so -** is a memory leak. The results of using a snapshot handle after it has -** been deleted by sqlite3_snapshot_free() are undefined. -** -** Given a snapshot handle, the sqlite3_snapshot_open() API function may be -** used to open a read transaction on the same database snapshot that was -** being read when sqlite3_snapshot_get() was called to obtain it. The -** combination of the first two arguments to sqlite3_snapshot_open() - a -** database handle and the name (e.g. "main") of one of its attached -** databases - must refer to the same database file as that identified by -** the arguments passed to the sqlite3_snapshot_get() call. The database -** handle must not have an open read or write transaction on this database -** file, and must not be in auto-commit mode. -** -** An old database snapshot may only be opened if SQLite is able to -** determine that it is still valid. The only way for an application to -** guarantee that a snapshot remains valid is by holding an open -** read-transaction on it or on an older snapshot of the same database -** file. If SQLite cannot determine that the snapshot identified by the -** snapshot handle, SQLITE_BUSY_SNAPSHOT is returned. -** -** Otherwise, if the read transaction is successfully opened, SQLITE_OK is -** returned. If the named database is not in wal mode or if the database -** handle already has an open read or write transaction on it, or if the -** database handle is in auto-commit mode, SQLITE_ERROR is returned. If -** an OOM or IO error occurs, the associated SQLite error code is returned. +** The constructor for this object is [sqlite3_snapshot_get()]. The +** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer +** to an historical snapshot (if possible). The destructor for +** sqlite3_snapshot objects is [sqlite3_snapshot_free()]. */ typedef struct sqlite3_snapshot sqlite3_snapshot; -int sqlite3_snapshot_get(sqlite3*, const char*, sqlite3_snapshot **ppSnapshot); -void sqlite3_snapshot_free(sqlite3_snapshot*); -int sqlite3_snapshot_open(sqlite3*, const char*, sqlite3_snapshot*); + +/* +** CAPI3REF: Record A Database Snapshot +** EXPERIMENTAL +** +** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a +** new [sqlite3_snapshot] object that records the current state of +** schema S in database connection D. ^On success, the +** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly +** created [sqlite3_snapshot] object into *P and returns SQLITE_OK. +** ^If schema S of [database connection] D is not a [WAL mode] database +** that is in a read transaction, then [sqlite3_snapshot_get(D,S,P)] +** leaves the *P value unchanged and returns an appropriate [error code]. +** +** The [sqlite3_snapshot] object returned from a successful call to +** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()] +** to avoid a memory leak. +*/ +SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(sqlite3*,const char*,sqlite3_snapshot **ppSnapshot); + +/* +** CAPI3REF: Start a read transaction on an historical snapshot +** EXPERIMENTAL +** +** ^The [sqlite3_snapshot_open(D,S,P)] interface attempts to move the +** read transaction that is currently open on schema S of +** [database connection] D so that it refers to historical [snapshot] P. +** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success +** or an appropriate [error code] if it fails. +** +** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be +** the first operation, apart from other sqlite3_snapshot_open() calls, +** following the [BEGIN] that starts a new read transaction. +** ^A [snapshot] will fail to open if it has been overwritten by a +** [checkpoint]. +*/ +SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(sqlite3*,const char*,sqlite3_snapshot*); + +/* +** CAPI3REF: Destroy a snapshot +** EXPERIMENTAL +** +** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P. +** The application must eventually free every [sqlite3_snapshot] object +** using this routine to avoid a memory leak. +*/ +SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*); /* ** Undo the hack that converts floating point types to integer for diff --git a/src/wal.c b/src/wal.c index e5527029ac..bfc5050908 100644 --- a/src/wal.c +++ b/src/wal.c @@ -3269,6 +3269,10 @@ int sqlite3WalHeapMemory(Wal *pWal){ } #ifdef SQLITE_ENABLE_SNAPSHOT +/* Create a snapshot object. The content of a snapshot is opaque to +** every other subsystem, so the WAL module can put whatever it needs +** in the object. +*/ int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){ int rc = SQLITE_OK; WalIndexHdr *pRet; @@ -3286,6 +3290,8 @@ int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){ return rc; } +/* Try to open on pSnapshot when the next read-transaction starts +*/ void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot){ pWal->pSnapshot = (WalIndexHdr*)pSnapshot; } From 71b62fa456178675bb85e3f111e87e39a3defd9a Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Dec 2015 01:22:22 +0000 Subject: [PATCH 080/232] Fix a bad assert related to snapshots. FossilOrigin-Name: 767ee30efa5dd469e3a51d4e44cbe473061819b9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/wal.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1988a1e007..84339a7e31 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Snapshot\sdocumentation\supdates.\s\sComment\schanges\sonly\s-\sno\schanges\sto\scode. -D 2015-12-10T22:48:22.684 +C Fix\sa\sbad\sassert\srelated\sto\ssnapshots. +D 2015-12-11T01:22:22.051 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 4ecd256ad59675472fbf211001b511cb31877a74 +F src/wal.c 9f6568377ace5b49bca27b1331bfa39c932ba07e F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b9c90f10297d8516a661449e8af898e682c930aa -R 359f52ff04c40d68d5a15fc7ff658a21 +P ef51a398a04963508389ffe2f9d8359c1ec48261 +R e1d10abd98dcf1e7229a5f36920c7ecf U drh -Z f10084cbd288f6e41be166b6d28c4cd6 +Z 7fb95d54ba87149061a67ceb88009af9 diff --git a/manifest.uuid b/manifest.uuid index d0158534a5..cf46736bac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ef51a398a04963508389ffe2f9d8359c1ec48261 \ No newline at end of file +767ee30efa5dd469e3a51d4e44cbe473061819b9 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index bfc5050908..504316964d 100644 --- a/src/wal.c +++ b/src/wal.c @@ -2419,7 +2419,7 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ */ volatile WalCkptInfo *pInfo = walCkptInfo(pWal); - assert( pWal->readLock>0 ); + assert( pWal->readLock>0 || pWal->hdr.mxFrame==0 ); assert( pInfo->aReadMark[pWal->readLock]<=pSnapshot->mxFrame ); /* It is possible that there is a checkpointer thread running From c49e960d41c9abb1c553cb527b083b9efc18c389 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Dec 2015 03:16:54 +0000 Subject: [PATCH 081/232] Fix a variable type mismatch problem in the snapshot logic. FossilOrigin-Name: 93fb8010e4999b6b832d63a7c5a152f65d4415a3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/wal.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 84339a7e31..416a40d864 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbad\sassert\srelated\sto\ssnapshots. -D 2015-12-11T01:22:22.051 +C Fix\sa\svariable\stype\smismatch\sproblem\sin\sthe\ssnapshot\slogic. +D 2015-12-11T03:16:54.491 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 9f6568377ace5b49bca27b1331bfa39c932ba07e +F src/wal.c cb709aa42fc11b1ea92a00c8c7e6214de0995fa3 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ef51a398a04963508389ffe2f9d8359c1ec48261 -R e1d10abd98dcf1e7229a5f36920c7ecf +P 767ee30efa5dd469e3a51d4e44cbe473061819b9 +R eb5f4e9ed632ef0781ac556c357a0ce5 U drh -Z 7fb95d54ba87149061a67ceb88009af9 +Z feb7b065ed13d6bdb0be293940a48a66 diff --git a/manifest.uuid b/manifest.uuid index cf46736bac..27b39abfda 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -767ee30efa5dd469e3a51d4e44cbe473061819b9 \ No newline at end of file +93fb8010e4999b6b832d63a7c5a152f65d4415a3 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 504316964d..e4d2cf544c 100644 --- a/src/wal.c +++ b/src/wal.c @@ -2174,7 +2174,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ int mxI; /* Index of largest aReadMark[] value */ int i; /* Loop counter */ int rc = SQLITE_OK; /* Return code */ - int mxFrame; /* Wal frame to lock to */ + u32 mxFrame; /* Wal frame to lock to */ assert( pWal->readLock<0 ); /* Not currently locked */ From 68d28ea4f06d3bff268d6b9ca9c3dc35a3e2a2ae Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Dec 2015 03:20:39 +0000 Subject: [PATCH 082/232] Disable the snapshot test scripts if not compiled with SQLITE_ENABLE_SNAPSHOT. FossilOrigin-Name: 5fd008f0433833e4341d526dcc2387570ffe1fea --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/test_config.c | 6 ++++++ test/snapshot.test | 2 +- test/snapshot_fault.test | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 416a40d864..315698b1df 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\svariable\stype\smismatch\sproblem\sin\sthe\ssnapshot\slogic. -D 2015-12-11T03:16:54.491 +C Disable\sthe\ssnapshot\stest\sscripts\sif\snot\scompiled\swith\sSQLITE_ENABLE_SNAPSHOT. +D 2015-12-11T03:20:39.887 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -363,7 +363,7 @@ F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12 F src/test_backup.c 2e6e6a081870150f20c526a2e9d0d29cda47d803 F src/test_blob.c e5a7a81d61a780da79101aeb1e60d300af169e07 F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f -F src/test_config.c 48850687dd5abc8260e23835632511054ccae172 +F src/test_config.c 0dee90328e3dedf8ba002ee94b6a7e7ea7726fe4 F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_fs.c 993c7eab65bed6add4bb48cca29775e963f710cf @@ -1020,8 +1020,8 @@ F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a F test/skipscan3.test ec5bab3f81c7038b43450e7b3062e04a198bdbb5 F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2 F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b -F test/snapshot.test bfcf728577d674d85b7da4bc69786ecafd2acebe -F test/snapshot_fault.test 06472056c516be4610834de4688ea3357e8bde01 +F test/snapshot.test efc6b4edc5d571161835f9dd8552e181ad1f0ac2 +F test/snapshot_fault.test 25973aeb1b86a280800e0bcf1eb5ce70e9ef57ab F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087 F test/sort.test 3f492e5b7be1d3f756728d2ff6edf4f6091e84cb @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 767ee30efa5dd469e3a51d4e44cbe473061819b9 -R eb5f4e9ed632ef0781ac556c357a0ce5 +P 93fb8010e4999b6b832d63a7c5a152f65d4415a3 +R f04d367372fb1067c3ab40fd75809ec7 U drh -Z feb7b065ed13d6bdb0be293940a48a66 +Z 1fa92043878ab0279cb81464491eddf8 diff --git a/manifest.uuid b/manifest.uuid index 27b39abfda..bf47079e76 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -93fb8010e4999b6b832d63a7c5a152f65d4415a3 \ No newline at end of file +5fd008f0433833e4341d526dcc2387570ffe1fea \ No newline at end of file diff --git a/src/test_config.c b/src/test_config.c index a9ef182e02..30b421e00b 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -143,6 +143,12 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options", "mem5", "0", TCL_GLOBAL_ONLY); #endif +#ifdef SQLITE_ENABLE_SNAPSHOT + Tcl_SetVar2(interp, "sqlite_options", "snapshot", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "snapshot", "0", TCL_GLOBAL_ONLY); +#endif + #ifdef SQLITE_MUTEX_OMIT Tcl_SetVar2(interp, "sqlite_options", "mutex", "0", TCL_GLOBAL_ONLY); #else diff --git a/test/snapshot.test b/test/snapshot.test index a01ac5a754..6e160166c3 100644 --- a/test/snapshot.test +++ b/test/snapshot.test @@ -14,6 +14,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +ifcapable !snapshot {finish_test; return} set testprefix snapshot #------------------------------------------------------------------------- @@ -337,4 +338,3 @@ do_test 6.3 { sqlite3_snapshot_free $snapshot finish_test - diff --git a/test/snapshot_fault.test b/test/snapshot_fault.test index a7731b8161..3ac13daefd 100644 --- a/test/snapshot_fault.test +++ b/test/snapshot_fault.test @@ -14,6 +14,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +ifcapable !snapshot {finish_test; return} set testprefix snapshot_fault #------------------------------------------------------------------------- @@ -161,4 +162,3 @@ do_faultsim_test 3.0 -prep { finish_test - From 5a6e89c644f3dfd9bf085670f7a2c2252f824481 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Dec 2015 03:27:36 +0000 Subject: [PATCH 083/232] Mention that the snapshot interfaces are only available if SQLite is compiled with SQLITE_ENABLE_SNAPSHOT. FossilOrigin-Name: 843c15a552657ca43ff200edb7da7566752d7941 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 21 +++++++++++++++++++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 315698b1df..268c0bf42d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\ssnapshot\stest\sscripts\sif\snot\scompiled\swith\sSQLITE_ENABLE_SNAPSHOT. -D 2015-12-11T03:20:39.887 +C Mention\sthat\sthe\ssnapshot\sinterfaces\sare\sonly\savailable\sif\sSQLite\sis\scompiled\nwith\sSQLITE_ENABLE_SNAPSHOT. +D 2015-12-11T03:27:36.868 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -341,7 +341,7 @@ F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 -F src/sqlite.h.in e24a1d2e36970ca46beb8002623e1c73eab32063 +F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d F src/sqliteInt.h 5caacf37a776f9d6178e519cb0b5248ca22a3828 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 93fb8010e4999b6b832d63a7c5a152f65d4415a3 -R f04d367372fb1067c3ab40fd75809ec7 +P 5fd008f0433833e4341d526dcc2387570ffe1fea +R debac3c9c8655611fddbcca7514e6f4e U drh -Z 1fa92043878ab0279cb81464491eddf8 +Z a48afa3f9104a922fecee9583a7109ec diff --git a/manifest.uuid b/manifest.uuid index bf47079e76..b9d344ad3f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5fd008f0433833e4341d526dcc2387570ffe1fea \ No newline at end of file +843c15a552657ca43ff200edb7da7566752d7941 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 780a702307..be58c7cd1f 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -7924,8 +7924,15 @@ typedef struct sqlite3_snapshot sqlite3_snapshot; ** The [sqlite3_snapshot] object returned from a successful call to ** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()] ** to avoid a memory leak. +** +** The [sqlite3_snapshot_get()] interface is only available when the +** SQLITE_ENABLE_SNAPSHOT compile-time option is used. */ -SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(sqlite3*,const char*,sqlite3_snapshot **ppSnapshot); +SQLITE_EXPERIMENTAL int sqlite3_snapshot_get( + sqlite3 *db, + const char *zSchema, + sqlite3_snapshot **ppSnapshot +); /* ** CAPI3REF: Start a read transaction on an historical snapshot @@ -7942,8 +7949,15 @@ SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(sqlite3*,const char*,sqlite3_snapsh ** following the [BEGIN] that starts a new read transaction. ** ^A [snapshot] will fail to open if it has been overwritten by a ** [checkpoint]. +** +** The [sqlite3_snapshot_open()] interface is only available when the +** SQLITE_ENABLE_SNAPSHOT compile-time option is used. */ -SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(sqlite3*,const char*,sqlite3_snapshot*); +SQLITE_EXPERIMENTAL int sqlite3_snapshot_open( + sqlite3 *db, + const char *zSchema, + sqlite3_snapshot *pSnapshot +); /* ** CAPI3REF: Destroy a snapshot @@ -7952,6 +7966,9 @@ SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(sqlite3*,const char*,sqlite3_snaps ** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P. ** The application must eventually free every [sqlite3_snapshot] object ** using this routine to avoid a memory leak. +** +** The [sqlite3_snapshot_free()] interface is only available when the +** SQLITE_ENABLE_SNAPSHOT compile-time option is used. */ SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*); From 9b810ae8f3f588cae93dc8849a5c92a491746e17 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Dec 2015 04:11:17 +0000 Subject: [PATCH 084/232] Fix a memory allocation bug introduced last week by check-in [a9e819082ba]. The bug only appears on systems where the size of a structure is not always a multiple of 8 - which in practice means only on 32-bit windows systems. FossilOrigin-Name: 96d3e99ffe59b5280b8b7fc269c94a72e15c345b --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8e1978c412..2ac6ff316f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Move\spointer\srange\scomparisons\sinto\sa\smacro,\swhere\sthey\scan\sbe\sdealt\swith\sin\sa\smore\sportable\sway. -D 2015-12-10T17:59:50.898 +C Fix\sa\smemory\sallocation\sbug\sintroduced\slast\sweek\sby\scheck-in\n[a9e819082ba].\s\sThe\sbug\sonly\sappears\son\ssystems\swhere\sthe\ssize\sof\sa\sstructure\nis\snot\salways\sa\smultiple\sof\s8\s-\swhich\sin\spractice\smeans\sonly\son\s32-bit\s\nwindows\ssystems. +D 2015-12-11T04:11:17.453 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -408,7 +408,7 @@ F src/vdbe.c 4d75375fa8bf911aa76ab8383d6f7eea0dec0fda F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c e07b2c8d14064f2094d20d002a2a1082913bbd2a +F src/vdbeaux.c 864b9ec26adca0562a32fb8dee7b0b366304bfd9 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1408,8 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6a5dfe85b519b920ce8c842057767a8793d92236 ad3124c834b080aaaf24934d6f08b3601ac3ae53 -R 75f5679e87cfa35a03ab3e382e1e81d9 -T +closed ad3124c834b080aaaf24934d6f08b3601ac3ae53 +P 05bc4f920ce23da48d1da6cd36a956fd6fd7c862 +R bb8ff31fbee90cb95998ef6668cbcbeb U drh -Z de945a489cd52e6561e642ec19b99047 +Z dbc67560cb8111f117bbc951b94851d2 diff --git a/manifest.uuid b/manifest.uuid index 5ee896243f..1ada9da49b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -05bc4f920ce23da48d1da6cd36a956fd6fd7c862 \ No newline at end of file +96d3e99ffe59b5280b8b7fc269c94a72e15c345b \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 38cd492afa..8361680b74 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1859,6 +1859,7 @@ void sqlite3VdbeMakeReady( nMem = 10; } memset(zCsr, 0, nFree); + nFree -= (zCsr - (u8*)0)&7; zCsr += (zCsr - (u8*)0)&7; assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); p->expired = 0; From 567a43bbc39612cee8a60306292361830a841460 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Dec 2015 13:51:02 +0000 Subject: [PATCH 085/232] Simplified alignment constraints in the memory reuse logic of sqlite3VdbeMakeReady(). FossilOrigin-Name: e998513e442ce1206b12dc28bdc996d7b5f9f94d --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 4 +--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 04d3534b4d..8ac154c64c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sexperimental\ssnapshot\sinterface.\s\sBecause\sit\sis\sexperimental,\sit\sis\nsubject\sto\schange\sor\sremoval\sat\sa\slater\sdate. -D 2015-12-11T12:44:52.505 +C Simplified\salignment\sconstraints\sin\sthe\smemory\sreuse\slogic\sof\nsqlite3VdbeMakeReady(). +D 2015-12-11T13:51:02.921 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -408,7 +408,7 @@ F src/vdbe.c 4d75375fa8bf911aa76ab8383d6f7eea0dec0fda F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 864b9ec26adca0562a32fb8dee7b0b366304bfd9 +F src/vdbeaux.c 68082d9991fc1b8625d34c8b5db1775c9dee426e F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1410,8 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 96d3e99ffe59b5280b8b7fc269c94a72e15c345b 843c15a552657ca43ff200edb7da7566752d7941 -R 1e8a48e65f87836435758a04b37e3926 -T +closed 843c15a552657ca43ff200edb7da7566752d7941 +P 9b124a5a310aec0145495c9980bc0c1308fcca02 +R 8b7bf5c5d9b6c5d6524021fe34935458 U drh -Z f796eddbea3599c0fdbed9d3e73688d6 +Z 8b682652b257be08de396beec767150c diff --git a/manifest.uuid b/manifest.uuid index bcf7d5193b..8c6ba19c4c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b124a5a310aec0145495c9980bc0c1308fcca02 \ No newline at end of file +e998513e442ce1206b12dc28bdc996d7b5f9f94d \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 8361680b74..a266177ac5 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1859,9 +1859,7 @@ void sqlite3VdbeMakeReady( nMem = 10; } memset(zCsr, 0, nFree); - nFree -= (zCsr - (u8*)0)&7; - zCsr += (zCsr - (u8*)0)&7; - assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); + assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) ); p->expired = 0; /* Memory for registers, parameters, cursor, etc, is allocated in two From 0f308f5d47b23093ff4b5333e63bc50d0466ed47 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 11 Dec 2015 14:59:49 +0000 Subject: [PATCH 086/232] Add a new assert() statement to the snapshot-specific part of sqlite3WalBeginReadTrans(). FossilOrigin-Name: d8a12023be32bdc6df18b0a5f38b917799854342 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/wal.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8ac154c64c..b87841c026 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplified\salignment\sconstraints\sin\sthe\smemory\sreuse\slogic\sof\nsqlite3VdbeMakeReady(). -D 2015-12-11T13:51:02.921 +C Add\sa\snew\sassert()\sstatement\sto\sthe\ssnapshot-specific\spart\sof\ssqlite3WalBeginReadTrans(). +D 2015-12-11T14:59:49.435 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -415,7 +415,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c cb709aa42fc11b1ea92a00c8c7e6214de0995fa3 +F src/wal.c 974928c988681c5157202c79dd9f26afaa7b5086 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9b124a5a310aec0145495c9980bc0c1308fcca02 -R 8b7bf5c5d9b6c5d6524021fe34935458 -U drh -Z 8b682652b257be08de396beec767150c +P e998513e442ce1206b12dc28bdc996d7b5f9f94d +R a4790a1ff73d4c37057dc2f097901685 +U dan +Z 708cca6403fc05264746d6ebc901db59 diff --git a/manifest.uuid b/manifest.uuid index 8c6ba19c4c..abbda4cf36 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e998513e442ce1206b12dc28bdc996d7b5f9f94d \ No newline at end of file +d8a12023be32bdc6df18b0a5f38b917799854342 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index e4d2cf544c..4238ea483b 100644 --- a/src/wal.c +++ b/src/wal.c @@ -2442,6 +2442,7 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt)) && pSnapshot->mxFrame>=pInfo->nBackfillAttempted ){ + assert( pWal->readLock>0 ); memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr)); *pChanged = bChanged; }else{ From b1d6b53694cc2a618b3566cbd5e5de24d4e5464b Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 14 Dec 2015 19:42:19 +0000 Subject: [PATCH 087/232] Add a missing memAboutToChange() macro to vdbe.c, the lack of which was causing an assert() to fail incorrectly. Problem found by libfuzzer. FossilOrigin-Name: 1a24791109da607d502ac41f179fe6c1dc46c774 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbe.c | 1 + test/with1.test | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b87841c026..dd22869db1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snew\sassert()\sstatement\sto\sthe\ssnapshot-specific\spart\sof\ssqlite3WalBeginReadTrans(). -D 2015-12-11T14:59:49.435 +C Add\sa\smissing\smemAboutToChange()\smacro\sto\svdbe.c,\sthe\slack\sof\swhich\swas\scausing\san\sassert()\sto\sfail\sincorrectly.\sProblem\sfound\sby\slibfuzzer. +D 2015-12-14T19:42:19.129 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -404,7 +404,7 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 4d75375fa8bf911aa76ab8383d6f7eea0dec0fda +F src/vdbe.c 0bc683e68a71d5151898b6b13cfeb277337335a4 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca @@ -1336,7 +1336,7 @@ F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972 F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d -F test/with1.test 05c8fc7f809f178a8a0519f02c21fe430948c895 +F test/with1.test cef099a491eac9874f2c28bd2dc86394fb3e47b3 F test/with2.test 2b40da883658eb74ad8ad06afabe11a408e7fb87 F test/with3.test 511bacdbe41c49cf34f9fd1bd3245fe1575bca98 F test/withM.test e97f2a8c506ab3ea9eab94e6f6072f6cc924c991 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e998513e442ce1206b12dc28bdc996d7b5f9f94d -R a4790a1ff73d4c37057dc2f097901685 +P d8a12023be32bdc6df18b0a5f38b917799854342 +R 3b6b45a5cba8add1b51b23a25852ed5f U dan -Z 708cca6403fc05264746d6ebc901db59 +Z 6f448ee5f1ec122055dafde44e32aab7 diff --git a/manifest.uuid b/manifest.uuid index abbda4cf36..a64979ed1d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d8a12023be32bdc6df18b0a5f38b917799854342 \ No newline at end of file +1a24791109da607d502ac41f179fe6c1dc46c774 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index f87fddafed..2aeab897a1 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1981,6 +1981,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ */ if( pOp->p5 & SQLITE_STOREP2 ){ pOut = &aMem[pOp->p2]; + memAboutToChange(p, pOut); MemSetTypeFlag(pOut, MEM_Null); REGISTER_TRACE(pOp->p2, pOut); }else{ diff --git a/test/with1.test b/test/with1.test index d98f33dfb0..7345c5ceb3 100644 --- a/test/with1.test +++ b/test/with1.test @@ -975,4 +975,20 @@ do_execsql_test 17.9 { SELECT * FROM x4; } {10 11} +# Added to test a fix to a faulty assert() discovered by libFuzzer. +# +do_execsql_test 18.1 { + WITH xyz(x) AS (VALUES(NULL) UNION SELECT round(1 Date: Tue, 15 Dec 2015 13:50:22 +0000 Subject: [PATCH 088/232] Add the SQLITE_OMIT_PARSER_TRACE compile-time option. FossilOrigin-Name: 2fda43e6e097a4a5510cce7784c31ceedc3d6e6d --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pragma.h | 2 +- tool/mkpragmatab.tcl | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index dd22869db1..047afbbc2e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\smissing\smemAboutToChange()\smacro\sto\svdbe.c,\sthe\slack\sof\swhich\swas\scausing\san\sassert()\sto\sfail\sincorrectly.\sProblem\sfound\sby\slibfuzzer. -D 2015-12-14T19:42:19.129 +C Add\sthe\sSQLITE_OMIT_PARSER_TRACE\scompile-time\soption. +D 2015-12-15T13:50:22.827 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -333,7 +333,7 @@ F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 F src/pcache.h 1ff11adce609ba7de139b6abfabaf9a2bac947b5 F src/pcache1.c 46a110be31a8d9f9b41431733836822ca0dd27ab F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 -F src/pragma.h 3d94aebbebd2089899fecc01909bf2608b39507d +F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 @@ -1372,7 +1372,7 @@ F tool/mkkeywordhash.c 06ec0b78bd4fa68c12d90ef2bdfe76b039133ff8 F tool/mkopcodec.tcl edde8adc42621b5e598127f8cdc6d52cfe21f52b F tool/mkopcodeh.tcl e04177031532b7aa9379ded50e820231ac4abd6e F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e -F tool/mkpragmatab.tcl e94e55d247d4fe3be34f2a4f4edb03fdcd09ce5b +F tool/mkpragmatab.tcl f0d5bb266d1d388cf86fce5ba01a891e95d72d41 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 87240b09c20042999b41d5fabe091b7111287835 F tool/mksqlite3c.tcl b66b4170f693602cd6985aed15d9509fe2f18c84 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d8a12023be32bdc6df18b0a5f38b917799854342 -R 3b6b45a5cba8add1b51b23a25852ed5f -U dan -Z 6f448ee5f1ec122055dafde44e32aab7 +P 1a24791109da607d502ac41f179fe6c1dc46c774 +R 2ba25094d2a2e5d1dff8c5d58f82b94b +U drh +Z de456f26b0f5cdabd2ebff5ccc5fcbaf diff --git a/manifest.uuid b/manifest.uuid index a64979ed1d..e4491ed0af 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1a24791109da607d502ac41f179fe6c1dc46c774 \ No newline at end of file +2fda43e6e097a4a5510cce7784c31ceedc3d6e6d \ No newline at end of file diff --git a/src/pragma.h b/src/pragma.h index 24a6c9d710..81779e9d4a 100644 --- a/src/pragma.h +++ b/src/pragma.h @@ -308,7 +308,7 @@ static const struct sPragmaNames { /* ePragFlag: */ 0, /* iArg: */ 0 }, #endif -#if defined(SQLITE_DEBUG) +#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE) { /* zName: */ "parser_trace", /* ePragTyp: */ PragTyp_PARSER_TRACE, /* ePragFlag: */ 0, diff --git a/tool/mkpragmatab.tcl b/tool/mkpragmatab.tcl index bcd3ed5d86..145a365c54 100644 --- a/tool/mkpragmatab.tcl +++ b/tool/mkpragmatab.tcl @@ -238,7 +238,7 @@ set pragma_def { IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) NAME: parser_trace - IF: defined(SQLITE_DEBUG) + IF: defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE) NAME: case_sensitive_like From 991c5d641372734d930a1e06d991803296bede50 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 15 Dec 2015 19:32:12 +0000 Subject: [PATCH 089/232] Update the mkautoconfamal.sh script to make the building of the sqlite3-autoconf-VERSION.tar.gz package more orthodox. FossilOrigin-Name: 1928f8945b7cdf733129619b7ab02d1addf63478 --- autoconf/config.guess | 1530 ------- autoconf/config.sub | 1773 -------- autoconf/configure.ac | 2 +- autoconf/depcomp | 708 --- autoconf/install-sh | 527 --- autoconf/ltmain.sh | 9655 ---------------------------------------- autoconf/missing | 331 -- manifest | 22 +- manifest.uuid | 2 +- tool/mkautoconfamal.sh | 16 +- 10 files changed, 16 insertions(+), 14550 deletions(-) delete mode 100755 autoconf/config.guess delete mode 100755 autoconf/config.sub delete mode 100755 autoconf/depcomp delete mode 100755 autoconf/install-sh delete mode 100644 autoconf/ltmain.sh delete mode 100755 autoconf/missing diff --git a/autoconf/config.guess b/autoconf/config.guess deleted file mode 100755 index d622a44e55..0000000000 --- a/autoconf/config.guess +++ /dev/null @@ -1,1530 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012 Free Software Foundation, Inc. - -timestamp='2012-02-10' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner. Please send patches (context -# diff format) to and include a ChangeLog -# entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH="x86_64" - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; - esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-gnu - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-gnueabi - else - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-gnu - exit ;; - crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-gnu - exit ;; - frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - i*86:Linux:*:*) - LIBC=gnu - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - or32:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-gnu - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu - exit ;; - x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - i386) - eval $set_cc_for_build - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - UNAME_PROCESSOR="x86_64" - fi - fi ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/autoconf/config.sub b/autoconf/config.sub deleted file mode 100755 index c894da4550..0000000000 --- a/autoconf/config.sub +++ /dev/null @@ -1,1773 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012 Free Software Foundation, Inc. - -timestamp='2012-02-10' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Please send patches to . Submit a context -# diff and a properly formatted GNU ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 \ - | ns16k | ns32k \ - | open8 \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze) - basic_machine=microblaze-xilinx - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i386-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/autoconf/configure.ac b/autoconf/configure.ac index e03dfe289b..8df915e955 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -10,7 +10,7 @@ # AC_PREREQ(2.61) -AC_INIT(sqlite, 3.7.5, http://www.sqlite.org) +AC_INIT(sqlite, --SQLITE-VERSION--, http://www.sqlite.org) AC_CONFIG_SRCDIR([sqlite3.c]) # Use automake. diff --git a/autoconf/depcomp b/autoconf/depcomp deleted file mode 100755 index 25a39e6cd5..0000000000 --- a/autoconf/depcomp +++ /dev/null @@ -1,708 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2012-03-27.16; # UTC - -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, -# 2011, 2012 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -case $1 in - '') - echo "$0: No command. Try '$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: depcomp [--help] [--version] PROGRAM [ARGS] - -Run PROGRAMS ARGS to compile a file, generating dependencies -as side-effects. - -Environment variables: - depmode Dependency tracking mode. - source Source file read by 'PROGRAMS ARGS'. - object Object file output by 'PROGRAMS ARGS'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputting dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit $? - ;; -esac - -# A tabulation character. -tab=' ' -# A newline character. -nl=' -' - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -cygpath_u="cygpath -u -f -" -if test "$depmode" = msvcmsys; then - # This is just like msvisualcpp but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvisualcpp -fi - -if test "$depmode" = msvc7msys; then - # This is just like msvc7 but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvc7 -fi - -if test "$depmode" = xlc; then - # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. - gccflag=-qmakedep=gcc,-MF - depmode=gcc -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. -## Unfortunately, FreeBSD c89 acceptance of flags depends upon -## the command line argument order; so add the flags where they -## appear in depend2.am. Note that the slowdown incurred here -## affects only configure: in makefiles, %FASTDEP% shortcuts this. - for arg - do - case $arg in - -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; - *) set fnord "$@" "$arg" ;; - esac - shift # fnord - shift # $arg - done - "$@" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the "deleted header file" problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' "$nl" < "$tmpdepfile" | -## Some versions of gcc put a space before the ':'. On the theory -## that the space means something, we add a space to the output as -## well. hp depmode also adds that space, but also prefixes the VPATH -## to the object. Take care to not repeat it in the output. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like '#:fec' to the end of the - # dependency line. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr "$nl" ' ' >> "$depfile" - echo >> "$depfile" - - # The second pass generates a dummy entry for each header file. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -xlc) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts '$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.u - tmpdepfile2=$base.u - tmpdepfile3=$dir.libs/$base.u - "$@" -Wc,-M - else - tmpdepfile1=$dir$base.u - tmpdepfile2=$dir$base.u - tmpdepfile3=$dir$base.u - "$@" -M - fi - stat=$? - - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - # Each line is of the form 'foo.o: dependent.h'. - # Do two passes, one to just change these to - # '$object: dependent.h' and one to simply 'dependent.h:'. - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -icc) - # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. - # However on - # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # ICC 7.0 will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - # ICC 7.1 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using '\': - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - # tcc 0.9.26 (FIXME still under development at the moment of writing) - # will emit a similar output, but also prepend the continuation lines - # with horizontal tabulation characters. - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form 'foo.o: dependent.h', - # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. - # Do two passes, one to just change these to - # '$object: dependent.h' and one to simply 'dependent.h:'. - sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ - < "$tmpdepfile" > "$depfile" - sed ' - s/[ '"$tab"'][ '"$tab"']*/ /g - s/^ *// - s/ *\\*$// - s/^[^:]*: *// - /^$/d - /:$/d - s/$/ :/ - ' < "$tmpdepfile" >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp2) - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 - # compilers, which have integrated preprocessors. The correct option - # to use with these is +Maked; it writes dependencies to a file named - # 'foo.d', which lands next to the object file, wherever that - # happens to be. - # Much of this is similar to the tru64 case; see comments there. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir.libs/$base.d - "$@" -Wc,+Maked - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - "$@" +Maked - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" - # Add 'dependent.h:' lines. - sed -ne '2,${ - s/^ *// - s/ \\*$// - s/$/:/ - p - }' "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" "$tmpdepfile2" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in 'foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - # With Tru64 cc, shared objects can also be used to make a - # static library. This mechanism is used in libtool 1.4 series to - # handle both shared and static libraries in a single compilation. - # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. - # - # With libtool 1.5 this exception was removed, and libtool now - # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 - tmpdepfile2=$dir$base.o.d # libtool 1.5 - tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 - tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.o.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - tmpdepfile4=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -msvc7) - if test "$libtool" = yes; then - showIncludes=-Wc,-showIncludes - else - showIncludes=-showIncludes - fi - "$@" $showIncludes > "$tmpdepfile" - stat=$? - grep -v '^Note: including file: ' "$tmpdepfile" - if test "$stat" = 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - # The first sed program below extracts the file names and escapes - # backslashes for cygpath. The second sed program outputs the file - # name when reading, but also accumulates all include files in the - # hold buffer in order to output them again at the end. This only - # works with sed implementations that can handle large buffers. - sed < "$tmpdepfile" -n ' -/^Note: including file: *\(.*\)/ { - s//\1/ - s/\\/\\\\/g - p -}' | $cygpath_u | sort -u | sed -n ' -s/ /\\ /g -s/\(.*\)/'"$tab"'\1 \\/p -s/.\(.*\) \\/\1:/ -H -$ { - s/.*/'"$tab"'/ - G - p -}' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvc7msys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - # Remove '-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for ':' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. - "$@" $dashmflag | - sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' "$nl" < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no eat=no - for arg - do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - if test $eat = yes; then - eat=no - continue - fi - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -arch) - eat=yes ;; - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix=`echo "$object" | sed 's/^.*\././'` - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - # makedepend may prepend the VPATH from the source file name to the object. - # No need to regex-escape $object, excess matching of '.' is harmless. - sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - # Remove '-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - IFS=" " - for arg - do - case "$arg" in - -o) - shift - ;; - $object) - shift - ;; - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E 2>/dev/null | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" - echo "$tab" >> "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvcmsys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/autoconf/install-sh b/autoconf/install-sh deleted file mode 100755 index a9244eb078..0000000000 --- a/autoconf/install-sh +++ /dev/null @@ -1,527 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2011-01-19.21; # UTC - -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. - -nl=' -' -IFS=" "" $nl" - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi - -# Put in absolute file names if you don't have them in your path; -# or use environment vars. - -chgrpprog=${CHGRPPROG-chgrp} -chmodprog=${CHMODPROG-chmod} -chownprog=${CHOWNPROG-chown} -cmpprog=${CMPPROG-cmp} -cpprog=${CPPROG-cp} -mkdirprog=${MKDIRPROG-mkdir} -mvprog=${MVPROG-mv} -rmprog=${RMPROG-rm} -stripprog=${STRIPPROG-strip} - -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - -posix_mkdir= - -# Desired mode of installed file. -mode=0755 - -chgrpcmd= -chmodcmd=$chmodprog -chowncmd= -mvcmd=$mvprog -rmcmd="$rmprog -f" -stripcmd= - -src= -dst= -dir_arg= -dst_arg= - -copy_on_change=false -no_target_directory= - -usage="\ -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE - or: $0 [OPTION]... SRCFILES... DIRECTORY - or: $0 [OPTION]... -t DIRECTORY SRCFILES... - or: $0 [OPTION]... -d DIRECTORIES... - -In the 1st form, copy SRCFILE to DSTFILE. -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. -In the 4th, create DIRECTORIES. - -Options: - --help display this help and exit. - --version display version info and exit. - - -c (ignored) - -C install only if different (preserve the last data modification time) - -d create directories instead of installing files. - -g GROUP $chgrpprog installed files to GROUP. - -m MODE $chmodprog installed files to MODE. - -o USER $chownprog installed files to USER. - -s $stripprog installed files. - -t DIRECTORY install into DIRECTORY. - -T report an error if DSTFILE is a directory. - -Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG - RMPROG STRIPPROG -" - -while test $# -ne 0; do - case $1 in - -c) ;; - - -C) copy_on_change=true;; - - -d) dir_arg=true;; - - -g) chgrpcmd="$chgrpprog $2" - shift;; - - --help) echo "$usage"; exit $?;; - - -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; - - -o) chowncmd="$chownprog $2" - shift;; - - -s) stripcmd=$stripprog;; - - -t) dst_arg=$2 - # Protect names problematic for `test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; - - -T) no_target_directory=true;; - - --version) echo "$0 $scriptversion"; exit $?;; - - --) shift - break;; - - -*) echo "$0: invalid option: $1" >&2 - exit 1;; - - *) break;; - esac - shift -done - -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then - # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dst_arg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dst_arg" - shift # fnord - fi - shift # arg - dst_arg=$arg - # Protect names problematic for `test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - done -fi - -if test $# -eq 0; then - if test -z "$dir_arg"; then - echo "$0: no input file specified." >&2 - exit 1 - fi - # It's OK to call `install-sh -d' without argument. - # This can happen when creating conditional directories. - exit 0 -fi - -if test -z "$dir_arg"; then - do_exit='(exit $ret); exit $ret' - trap "ret=129; $do_exit" 1 - trap "ret=130; $do_exit" 2 - trap "ret=141; $do_exit" 13 - trap "ret=143; $do_exit" 15 - - # Set umask so as not to create temps with too-generous modes. - # However, 'strip' requires both read and write access to temps. - case $mode in - # Optimize common cases. - *644) cp_umask=133;; - *755) cp_umask=22;; - - *[0-7]) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw='% 200' - fi - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; - *) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw=,u+rw - fi - cp_umask=$mode$u_plus_rw;; - esac -fi - -for src -do - # Protect names problematic for `test' and other utilities. - case $src in - -* | [=\(\)!]) src=./$src;; - esac - - if test -n "$dir_arg"; then - dst=$src - dstdir=$dst - test -d "$dstdir" - dstdir_status=$? - else - - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command - # might cause directories to be created, which would be especially bad - # if $src (and thus $dsttmp) contains '*'. - if test ! -f "$src" && test ! -d "$src"; then - echo "$0: $src does not exist." >&2 - exit 1 - fi - - if test -z "$dst_arg"; then - echo "$0: no destination specified." >&2 - exit 1 - fi - dst=$dst_arg - - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. - if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 - fi - dstdir=$dst - dst=$dstdir/`basename "$src"` - dstdir_status=0 - else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - - test -d "$dstdir" - dstdir_status=$? - fi - fi - - obsolete_mkdir_used=false - - if test $dstdir_status != 0; then - case $posix_mkdir in - '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; - esac - - if - $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" - ) - then : - else - - # The umask is ridiculous, or mkdir does not conform to POSIX, - # or it failed possibly due to a race condition. Create the - # directory the slow way, step by step, checking for races as we go. - - case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; - esac - - eval "$initialize_posix_glob" - - oIFS=$IFS - IFS=/ - $posix_glob set -f - set fnord $dstdir - shift - $posix_glob set +f - IFS=$oIFS - - prefixes= - - for d - do - test X"$d" = X && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ - done - - if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true - fi - fi - fi - - if test -n "$dir_arg"; then - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 - else - - # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ - - # Trap to clean up those temp files at exit. - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - - # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && - - # and set any options; do chmod last to preserve setuid bits. - # - # If any of these fail, we abort the whole thing. If we want to - # ignore errors from any of these, just make sure not to ignore - # errors from the above "$doit $cpprog $src $dsttmp" command. - # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && - { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && - { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && - - # If -C, don't bother to copy if it wouldn't change the file. - if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && - set X $old && old=:$2:$4:$5:$6 && - set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - - test "$old" = "$new" && - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 - then - rm -f "$dsttmp" - else - # Rename the file to the real destination. - $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || - - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" - } - fi || exit 1 - - trap '' 0 - fi -done - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/autoconf/ltmain.sh b/autoconf/ltmain.sh deleted file mode 100644 index 6a2f1166a9..0000000000 --- a/autoconf/ltmain.sh +++ /dev/null @@ -1,9655 +0,0 @@ - -# libtool (GNU libtool) 2.4.2 -# Written by Gordon Matzigkeit , 1996 - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# GNU Libtool is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, -# or obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# Usage: $progname [OPTION]... [MODE-ARG]... -# -# Provide generalized library-building support services. -# -# --config show all configuration variables -# --debug enable verbose shell tracing -# -n, --dry-run display commands without modifying any files -# --features display basic configuration information and exit -# --mode=MODE use operation mode MODE -# --preserve-dup-deps don't remove duplicate dependency libraries -# --quiet, --silent don't print informational messages -# --no-quiet, --no-silent -# print informational messages (default) -# --no-warn don't display warning messages -# --tag=TAG use configuration variables from tag TAG -# -v, --verbose print more informational messages than default -# --no-verbose don't print the extra informational messages -# --version print version information -# -h, --help, --help-all print short, long, or detailed help message -# -# MODE must be one of the following: -# -# clean remove files from the build directory -# compile compile a source file into a libtool object -# execute automatically set library path, then run a program -# finish complete the installation of libtool libraries -# install install libraries or executables -# link create a library or an executable -# uninstall remove libraries from an installed directory -# -# MODE-ARGS vary depending on the MODE. When passed as first option, -# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. -# Try `$progname --help --mode=MODE' for a more detailed description of MODE. -# -# When reporting a bug, please describe a test case to reproduce it and -# include the following information: -# -# host-triplet: $host -# shell: $SHELL -# compiler: $LTCC -# compiler flags: $LTCFLAGS -# linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4.2 -# automake: $automake_version -# autoconf: $autoconf_version -# -# Report bugs to . -# GNU libtool home page: . -# General help using GNU software: . - -PROGRAM=libtool -PACKAGE=libtool -VERSION=2.4.2 -TIMESTAMP="" -package_revision=1.3337 - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' -} - -# NLS nuisances: We save the old values to restore during execute mode. -lt_user_locale= -lt_safe_locale= -for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES -do - eval "if test \"\${$lt_var+set}\" = set; then - save_$lt_var=\$$lt_var - $lt_var=C - export $lt_var - lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" - lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" - fi" -done -LC_ALL=C -LANGUAGE=C -export LANGUAGE LC_ALL - -$lt_unset CDPATH - - -# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh -# is ksh but when the shell is invoked as "sh" and the current value of -# the _XPG environment variable is not equal to 1 (one), the special -# positional parameter $0, within a function call, is the name of the -# function. -progpath="$0" - - - -: ${CP="cp -f"} -test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} -: ${MAKE="make"} -: ${MKDIR="mkdir"} -: ${MV="mv -f"} -: ${RM="rm -f"} -: ${SHELL="${CONFIG_SHELL-/bin/sh}"} -: ${Xsed="$SED -e 1s/^X//"} - -# Global variables: -EXIT_SUCCESS=0 -EXIT_FAILURE=1 -EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. -EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. - -exit_status=$EXIT_SUCCESS - -# Make sure IFS has a sensible default -lt_nl=' -' -IFS=" $lt_nl" - -dirname="s,/[^/]*$,," -basename="s,^.*/,," - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} # func_dirname may be replaced by extended shell implementation - - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "${1}" | $SED "$basename"` -} # func_basename may be replaced by extended shell implementation - - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi - func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` -} # func_dirname_and_basename may be replaced by extended shell implementation - - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname may be replaced by extended shell implementation - - -# These SED scripts presuppose an absolute path with a trailing slash. -pathcar='s,^/\([^/]*\).*$,\1,' -pathcdr='s,^/[^/]*,,' -removedotparts=':dotsl - s@/\./@/@g - t dotsl - s,/\.$,/,' -collapseslashes='s@/\{1,\}@/@g' -finalslash='s,/*$,/,' - -# func_normal_abspath PATH -# Remove doubled-up and trailing slashes, "." path components, -# and cancel out any ".." path components in PATH after making -# it an absolute path. -# value returned in "$func_normal_abspath_result" -func_normal_abspath () -{ - # Start from root dir and reassemble the path. - func_normal_abspath_result= - func_normal_abspath_tpath=$1 - func_normal_abspath_altnamespace= - case $func_normal_abspath_tpath in - "") - # Empty path, that just means $cwd. - func_stripname '' '/' "`pwd`" - func_normal_abspath_result=$func_stripname_result - return - ;; - # The next three entries are used to spot a run of precisely - # two leading slashes without using negated character classes; - # we take advantage of case's first-match behaviour. - ///*) - # Unusual form of absolute path, do nothing. - ;; - //*) - # Not necessarily an ordinary path; POSIX reserves leading '//' - # and for example Cygwin uses it to access remote file shares - # over CIFS/SMB, so we conserve a leading double slash if found. - func_normal_abspath_altnamespace=/ - ;; - /*) - # Absolute path, do nothing. - ;; - *) - # Relative path, prepend $cwd. - func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath - ;; - esac - # Cancel out all the simple stuff to save iterations. We also want - # the path to end with a slash for ease of parsing, so make sure - # there is one (and only one) here. - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` - while :; do - # Processed it all yet? - if test "$func_normal_abspath_tpath" = / ; then - # If we ascended to the root using ".." the result may be empty now. - if test -z "$func_normal_abspath_result" ; then - func_normal_abspath_result=/ - fi - break - fi - func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcar"` - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcdr"` - # Figure out what to do with it - case $func_normal_abspath_tcomponent in - "") - # Trailing empty path component, ignore it. - ;; - ..) - # Parent dir; strip last assembled component from result. - func_dirname "$func_normal_abspath_result" - func_normal_abspath_result=$func_dirname_result - ;; - *) - # Actual path component, append it. - func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent - ;; - esac - done - # Restore leading double-slash if one was found on entry. - func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result -} - -# func_relative_path SRCDIR DSTDIR -# generates a relative path from SRCDIR to DSTDIR, with a trailing -# slash if non-empty, suitable for immediately appending a filename -# without needing to append a separator. -# value returned in "$func_relative_path_result" -func_relative_path () -{ - func_relative_path_result= - func_normal_abspath "$1" - func_relative_path_tlibdir=$func_normal_abspath_result - func_normal_abspath "$2" - func_relative_path_tbindir=$func_normal_abspath_result - - # Ascend the tree starting from libdir - while :; do - # check if we have found a prefix of bindir - case $func_relative_path_tbindir in - $func_relative_path_tlibdir) - # found an exact match - func_relative_path_tcancelled= - break - ;; - $func_relative_path_tlibdir*) - # found a matching prefix - func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" - func_relative_path_tcancelled=$func_stripname_result - if test -z "$func_relative_path_result"; then - func_relative_path_result=. - fi - break - ;; - *) - func_dirname $func_relative_path_tlibdir - func_relative_path_tlibdir=${func_dirname_result} - if test "x$func_relative_path_tlibdir" = x ; then - # Have to descend all the way to the root! - func_relative_path_result=../$func_relative_path_result - func_relative_path_tcancelled=$func_relative_path_tbindir - break - fi - func_relative_path_result=../$func_relative_path_result - ;; - esac - done - - # Now calculate path; take care to avoid doubling-up slashes. - func_stripname '' '/' "$func_relative_path_result" - func_relative_path_result=$func_stripname_result - func_stripname '/' '/' "$func_relative_path_tcancelled" - if test "x$func_stripname_result" != x ; then - func_relative_path_result=${func_relative_path_result}/${func_stripname_result} - fi - - # Normalisation. If bindir is libdir, return empty string, - # else relative path ending with a slash; either way, target - # file name can be directly appended. - if test ! -z "$func_relative_path_result"; then - func_stripname './' '' "$func_relative_path_result/" - func_relative_path_result=$func_stripname_result - fi -} - -# The name of this program: -func_dirname_and_basename "$progpath" -progname=$func_basename_result - -# Make sure we have an absolute path for reexecution: -case $progpath in - [\\/]*|[A-Za-z]:\\*) ;; - *[\\/]*) - progdir=$func_dirname_result - progdir=`cd "$progdir" && pwd` - progpath="$progdir/$progname" - ;; - *) - save_IFS="$IFS" - IFS=${PATH_SEPARATOR-:} - for progdir in $PATH; do - IFS="$save_IFS" - test -x "$progdir/$progname" && break - done - IFS="$save_IFS" - test -n "$progdir" || progdir=`pwd` - progpath="$progdir/$progname" - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed="${SED}"' -e 1s/^X//' -sed_quote_subst='s/\([`"$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution that turns a string into a regex matching for the -# string literally. -sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' - -# Sed substitution that converts a w32 file name or path -# which contains forward slashes, into one that contains -# (escaped) backslashes. A very naive implementation. -lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' - -# Re-`\' parameter expansions in output of double_quote_subst that were -# `\'-ed in input to the same. If an odd number of `\' preceded a '$' -# in input to double_quote_subst, that '$' was protected from expansion. -# Since each input `\' is now two `\'s, look for any number of runs of -# four `\'s followed by two `\'s and then a '$'. `\' that '$'. -bs='\\' -bs2='\\\\' -bs4='\\\\\\\\' -dollar='\$' -sed_double_backslash="\ - s/$bs4/&\\ -/g - s/^$bs2$dollar/$bs&/ - s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g - s/\n//g" - -# Standard options: -opt_dry_run=false -opt_help=false -opt_quiet=false -opt_verbose=false -opt_warning=: - -# func_echo arg... -# Echo program name prefixed message, along with the current mode -# name if it has been set yet. -func_echo () -{ - $ECHO "$progname: ${opt_mode+$opt_mode: }$*" -} - -# func_verbose arg... -# Echo program name prefixed message in verbose mode only. -func_verbose () -{ - $opt_verbose && func_echo ${1+"$@"} - - # A bug in bash halts the script if the last line of a function - # fails when set -e is in force, so we need another command to - # work around that: - : -} - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -# func_error arg... -# Echo program name prefixed message to standard error. -func_error () -{ - $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 -} - -# func_warning arg... -# Echo program name prefixed warning message to standard error. -func_warning () -{ - $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 - - # bash bug again: - : -} - -# func_fatal_error arg... -# Echo program name prefixed message to standard error, and exit. -func_fatal_error () -{ - func_error ${1+"$@"} - exit $EXIT_FAILURE -} - -# func_fatal_help arg... -# Echo program name prefixed message to standard error, followed by -# a help hint, and exit. -func_fatal_help () -{ - func_error ${1+"$@"} - func_fatal_error "$help" -} -help="Try \`$progname --help' for more information." ## default - - -# func_grep expression filename -# Check whether EXPRESSION matches any line of FILENAME, without output. -func_grep () -{ - $GREP "$1" "$2" >/dev/null 2>&1 -} - - -# func_mkdir_p directory-path -# Make sure the entire path to DIRECTORY-PATH is available. -func_mkdir_p () -{ - my_directory_path="$1" - my_dir_list= - - if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then - - # Protect directory names starting with `-' - case $my_directory_path in - -*) my_directory_path="./$my_directory_path" ;; - esac - - # While some portion of DIR does not yet exist... - while test ! -d "$my_directory_path"; do - # ...make a list in topmost first order. Use a colon delimited - # list incase some portion of path contains whitespace. - my_dir_list="$my_directory_path:$my_dir_list" - - # If the last portion added has no slash in it, the list is done - case $my_directory_path in */*) ;; *) break ;; esac - - # ...otherwise throw away the child directory and loop - my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` - done - my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` - - save_mkdir_p_IFS="$IFS"; IFS=':' - for my_dir in $my_dir_list; do - IFS="$save_mkdir_p_IFS" - # mkdir can fail with a `File exist' error if two processes - # try to create one of the directories concurrently. Don't - # stop in that case! - $MKDIR "$my_dir" 2>/dev/null || : - done - IFS="$save_mkdir_p_IFS" - - # Bail out if we (or some other process) failed to create a directory. - test -d "$my_directory_path" || \ - func_fatal_error "Failed to create \`$1'" - fi -} - - -# func_mktempdir [string] -# Make a temporary directory that won't clash with other running -# libtool processes, and avoids race conditions if possible. If -# given, STRING is the basename for that directory. -func_mktempdir () -{ - my_template="${TMPDIR-/tmp}/${1-$progname}" - - if test "$opt_dry_run" = ":"; then - # Return a directory name, but don't create it in dry-run mode - my_tmpdir="${my_template}-$$" - else - - # If mktemp works, use that first and foremost - my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` - - if test ! -d "$my_tmpdir"; then - # Failing that, at least try and use $RANDOM to avoid a race - my_tmpdir="${my_template}-${RANDOM-0}$$" - - save_mktempdir_umask=`umask` - umask 0077 - $MKDIR "$my_tmpdir" - umask $save_mktempdir_umask - fi - - # If we're not in dry-run mode, bomb out on failure - test -d "$my_tmpdir" || \ - func_fatal_error "cannot create temporary directory \`$my_tmpdir'" - fi - - $ECHO "$my_tmpdir" -} - - -# func_quote_for_eval arg -# Aesthetically quote ARG to be evaled later. -# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT -# is double-quoted, suitable for a subsequent eval, whereas -# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters -# which are still active within double quotes backslashified. -func_quote_for_eval () -{ - case $1 in - *[\\\`\"\$]*) - func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; - *) - func_quote_for_eval_unquoted_result="$1" ;; - esac - - case $func_quote_for_eval_unquoted_result in - # Double-quote args containing shell metacharacters to delay - # word splitting, command substitution and and variable - # expansion for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" - ;; - *) - func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" - esac -} - - -# func_quote_for_expand arg -# Aesthetically quote ARG to be evaled later; same as above, -# but do not quote variable references. -func_quote_for_expand () -{ - case $1 in - *[\\\`\"]*) - my_arg=`$ECHO "$1" | $SED \ - -e "$double_quote_subst" -e "$sed_double_backslash"` ;; - *) - my_arg="$1" ;; - esac - - case $my_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting and command substitution for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - my_arg="\"$my_arg\"" - ;; - esac - - func_quote_for_expand_result="$my_arg" -} - - -# func_show_eval cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP -# is given, then evaluate it. -func_show_eval () -{ - my_cmd="$1" - my_fail_exp="${2-:}" - - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } - - if ${opt_dry_run-false}; then :; else - eval "$my_cmd" - my_status=$? - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" - fi - fi -} - - -# func_show_eval_locale cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP -# is given, then evaluate it. Use the saved locale for evaluation. -func_show_eval_locale () -{ - my_cmd="$1" - my_fail_exp="${2-:}" - - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } - - if ${opt_dry_run-false}; then :; else - eval "$lt_user_locale - $my_cmd" - my_status=$? - eval "$lt_safe_locale" - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" - fi - fi -} - -# func_tr_sh -# Turn $1 into a string suitable for a shell variable name. -# Result is stored in $func_tr_sh_result. All characters -# not in the set a-zA-Z0-9_ are replaced with '_'. Further, -# if $1 begins with a digit, a '_' is prepended as well. -func_tr_sh () -{ - case $1 in - [0-9]* | *[!a-zA-Z0-9_]*) - func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` - ;; - * ) - func_tr_sh_result=$1 - ;; - esac -} - - -# func_version -# Echo version message to standard output and exit. -func_version () -{ - $opt_debug - - $SED -n '/(C)/!b go - :more - /\./!{ - N - s/\n# / / - b more - } - :go - /^# '$PROGRAM' (GNU /,/# warranty; / { - s/^# // - s/^# *$// - s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ - p - }' < "$progpath" - exit $? -} - -# func_usage -# Echo short help message to standard output and exit. -func_usage () -{ - $opt_debug - - $SED -n '/^# Usage:/,/^# *.*--help/ { - s/^# // - s/^# *$// - s/\$progname/'$progname'/ - p - }' < "$progpath" - echo - $ECHO "run \`$progname --help | more' for full usage" - exit $? -} - -# func_help [NOEXIT] -# Echo long help message to standard output and exit, -# unless 'noexit' is passed as argument. -func_help () -{ - $opt_debug - - $SED -n '/^# Usage:/,/# Report bugs to/ { - :print - s/^# // - s/^# *$// - s*\$progname*'$progname'* - s*\$host*'"$host"'* - s*\$SHELL*'"$SHELL"'* - s*\$LTCC*'"$LTCC"'* - s*\$LTCFLAGS*'"$LTCFLAGS"'* - s*\$LD*'"$LD"'* - s/\$with_gnu_ld/'"$with_gnu_ld"'/ - s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ - p - d - } - /^# .* home page:/b print - /^# General help using/b print - ' < "$progpath" - ret=$? - if test -z "$1"; then - exit $ret - fi -} - -# func_missing_arg argname -# Echo program name prefixed message to standard error and set global -# exit_cmd. -func_missing_arg () -{ - $opt_debug - - func_error "missing argument for $1." - exit_cmd=exit -} - - -# func_split_short_opt shortopt -# Set func_split_short_opt_name and func_split_short_opt_arg shell -# variables after splitting SHORTOPT after the 2nd character. -func_split_short_opt () -{ - my_sed_short_opt='1s/^\(..\).*$/\1/;q' - my_sed_short_rest='1s/^..\(.*\)$/\1/;q' - - func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` - func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` -} # func_split_short_opt may be replaced by extended shell implementation - - -# func_split_long_opt longopt -# Set func_split_long_opt_name and func_split_long_opt_arg shell -# variables after splitting LONGOPT at the `=' sign. -func_split_long_opt () -{ - my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' - my_sed_long_arg='1s/^--[^=]*=//' - - func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` - func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` -} # func_split_long_opt may be replaced by extended shell implementation - -exit_cmd=: - - - - - -magic="%%%MAGIC variable%%%" -magic_exe="%%%MAGIC EXE variable%%%" - -# Global variables. -nonopt= -preserve_args= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" -extracted_archives= -extracted_serial=0 - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "${1}=\$${1}\${2}" -} # func_append may be replaced by extended shell implementation - -# func_append_quoted var value -# Quote VALUE and append to the end of shell variable VAR, separated -# by a space. -func_append_quoted () -{ - func_quote_for_eval "${2}" - eval "${1}=\$${1}\\ \$func_quote_for_eval_result" -} # func_append_quoted may be replaced by extended shell implementation - - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "${@}"` -} # func_arith may be replaced by extended shell implementation - - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` -} # func_len may be replaced by extended shell implementation - - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` -} # func_lo2o may be replaced by extended shell implementation - - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` -} # func_xform may be replaced by extended shell implementation - - -# func_fatal_configuration arg... -# Echo program name prefixed message to standard error, followed by -# a configuration failure hint, and exit. -func_fatal_configuration () -{ - func_error ${1+"$@"} - func_error "See the $PACKAGE documentation for more information." - func_fatal_error "Fatal configuration error." -} - - -# func_config -# Display the configuration for all the tags in this script. -func_config () -{ - re_begincf='^# ### BEGIN LIBTOOL' - re_endcf='^# ### END LIBTOOL' - - # Default configuration. - $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" - - # Now print the configurations for the tags. - for tagname in $taglist; do - $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" - done - - exit $? -} - -# func_features -# Display the features supported by this script. -func_features () -{ - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - - exit $? -} - -# func_enable_tag tagname -# Verify that TAGNAME is valid, and either flag an error and exit, or -# enable the TAGNAME tag. We also add TAGNAME to the global $taglist -# variable here. -func_enable_tag () -{ - # Global variable: - tagname="$1" - - re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" - re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" - sed_extractcf="/$re_begincf/,/$re_endcf/p" - - # Validate tagname. - case $tagname in - *[!-_A-Za-z0-9,/]*) - func_fatal_error "invalid tag name: $tagname" - ;; - esac - - # Don't test for the "default" C tag, as we know it's - # there but not specially marked. - case $tagname in - CC) ;; - *) - if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then - taglist="$taglist $tagname" - - # Evaluate the configuration. Be careful to quote the path - # and the sed script, to avoid splitting on whitespace, but - # also don't use non-portable quotes within backquotes within - # quotes we have to do it in 2 steps: - extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` - eval "$extractedcf" - else - func_error "ignoring unknown tag $tagname" - fi - ;; - esac -} - -# func_check_version_match -# Ensure that we are using m4 macros, and libtool script from the same -# release of libtool. -func_check_version_match () -{ - if test "$package_revision" != "$macro_revision"; then - if test "$VERSION" != "$macro_version"; then - if test -z "$macro_version"; then - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from an older release. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - fi - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, -$progname: but the definition of this LT_INIT comes from revision $macro_revision. -$progname: You should recreate aclocal.m4 with macros from revision $package_revision -$progname: of $PACKAGE $VERSION and run autoconf again. -_LT_EOF - fi - - exit $EXIT_MISMATCH - fi -} - - -# Shorthand for --mode=foo, only valid as the first argument -case $1 in -clean|clea|cle|cl) - shift; set dummy --mode clean ${1+"$@"}; shift - ;; -compile|compil|compi|comp|com|co|c) - shift; set dummy --mode compile ${1+"$@"}; shift - ;; -execute|execut|execu|exec|exe|ex|e) - shift; set dummy --mode execute ${1+"$@"}; shift - ;; -finish|finis|fini|fin|fi|f) - shift; set dummy --mode finish ${1+"$@"}; shift - ;; -install|instal|insta|inst|ins|in|i) - shift; set dummy --mode install ${1+"$@"}; shift - ;; -link|lin|li|l) - shift; set dummy --mode link ${1+"$@"}; shift - ;; -uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) - shift; set dummy --mode uninstall ${1+"$@"}; shift - ;; -esac - - - -# Option defaults: -opt_debug=: -opt_dry_run=false -opt_config=false -opt_preserve_dup_deps=false -opt_features=false -opt_finish=false -opt_help=false -opt_help_all=false -opt_silent=: -opt_warning=: -opt_verbose=: -opt_silent=false -opt_verbose=false - - -# Parse options once, thoroughly. This comes as soon as possible in the -# script to make things like `--version' happen as quickly as we can. -{ - # this just eases exit handling - while test $# -gt 0; do - opt="$1" - shift - case $opt in - --debug|-x) opt_debug='set -x' - func_echo "enabling shell trace mode" - $opt_debug - ;; - --dry-run|--dryrun|-n) - opt_dry_run=: - ;; - --config) - opt_config=: -func_config - ;; - --dlopen|-dlopen) - optarg="$1" - opt_dlopen="${opt_dlopen+$opt_dlopen -}$optarg" - shift - ;; - --preserve-dup-deps) - opt_preserve_dup_deps=: - ;; - --features) - opt_features=: -func_features - ;; - --finish) - opt_finish=: -set dummy --mode finish ${1+"$@"}; shift - ;; - --help) - opt_help=: - ;; - --help-all) - opt_help_all=: -opt_help=': help-all' - ;; - --mode) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_mode="$optarg" -case $optarg in - # Valid mode arguments: - clean|compile|execute|finish|install|link|relink|uninstall) ;; - - # Catch anything else as an error - *) func_error "invalid argument for $opt" - exit_cmd=exit - break - ;; -esac - shift - ;; - --no-silent|--no-quiet) - opt_silent=false -func_append preserve_args " $opt" - ;; - --no-warning|--no-warn) - opt_warning=false -func_append preserve_args " $opt" - ;; - --no-verbose) - opt_verbose=false -func_append preserve_args " $opt" - ;; - --silent|--quiet) - opt_silent=: -func_append preserve_args " $opt" - opt_verbose=false - ;; - --verbose|-v) - opt_verbose=: -func_append preserve_args " $opt" -opt_silent=false - ;; - --tag) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_tag="$optarg" -func_append preserve_args " $opt $optarg" -func_enable_tag "$optarg" - shift - ;; - - -\?|-h) func_usage ;; - --help) func_help ;; - --version) func_version ;; - - # Separate optargs to long options: - --*=*) - func_split_long_opt "$opt" - set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} - shift - ;; - - # Separate non-argument short options: - -\?*|-h*|-n*|-v*) - func_split_short_opt "$opt" - set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} - shift - ;; - - --) break ;; - -*) func_fatal_help "unrecognized option \`$opt'" ;; - *) set dummy "$opt" ${1+"$@"}; shift; break ;; - esac - done - - # Validate options: - - # save first non-option argument - if test "$#" -gt 0; then - nonopt="$opt" - shift - fi - - # preserve --debug - test "$opt_debug" = : || func_append preserve_args " --debug" - - case $host in - *cygwin* | *mingw* | *pw32* | *cegcc*) - # don't eliminate duplications in $postdeps and $predeps - opt_duplicate_compiler_generated_deps=: - ;; - *) - opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps - ;; - esac - - $opt_help || { - # Sanity checks first: - func_check_version_match - - if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - func_fatal_configuration "not configured to build any kind of library" - fi - - # Darwin sucks - eval std_shrext=\"$shrext_cmds\" - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$opt_dlopen" && test "$opt_mode" != execute; then - func_error "unrecognized option \`-dlopen'" - $ECHO "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$progname --help --mode=$opt_mode' for more information." - } - - - # Bail if the options were screwed - $exit_cmd $EXIT_FAILURE -} - - - - -## ----------- ## -## Main. ## -## ----------- ## - -# func_lalib_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_lalib_p () -{ - test -f "$1" && - $SED -e 4q "$1" 2>/dev/null \ - | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 -} - -# func_lalib_unsafe_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. -# This function implements the same check as func_lalib_p without -# resorting to external programs. To this end, it redirects stdin and -# closes it afterwards, without saving the original file descriptor. -# As a safety measure, use it only where a negative result would be -# fatal anyway. Works if `file' does not exist. -func_lalib_unsafe_p () -{ - lalib_p=no - if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then - for lalib_p_l in 1 2 3 4 - do - read lalib_p_line - case "$lalib_p_line" in - \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; - esac - done - exec 0<&5 5<&- - fi - test "$lalib_p" = yes -} - -# func_ltwrapper_script_p file -# True iff FILE is a libtool wrapper script -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_script_p () -{ - func_lalib_p "$1" -} - -# func_ltwrapper_executable_p file -# True iff FILE is a libtool wrapper executable -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_executable_p () -{ - func_ltwrapper_exec_suffix= - case $1 in - *.exe) ;; - *) func_ltwrapper_exec_suffix=.exe ;; - esac - $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 -} - -# func_ltwrapper_scriptname file -# Assumes file is an ltwrapper_executable -# uses $file to determine the appropriate filename for a -# temporary ltwrapper_script. -func_ltwrapper_scriptname () -{ - func_dirname_and_basename "$1" "" "." - func_stripname '' '.exe' "$func_basename_result" - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" -} - -# func_ltwrapper_p file -# True iff FILE is a libtool wrapper script or wrapper executable -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_p () -{ - func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" -} - - -# func_execute_cmds commands fail_cmd -# Execute tilde-delimited COMMANDS. -# If FAIL_CMD is given, eval that upon failure. -# FAIL_CMD may read-access the current command in variable CMD! -func_execute_cmds () -{ - $opt_debug - save_ifs=$IFS; IFS='~' - for cmd in $1; do - IFS=$save_ifs - eval cmd=\"$cmd\" - func_show_eval "$cmd" "${2-:}" - done - IFS=$save_ifs -} - - -# func_source file -# Source FILE, adding directory component if necessary. -# Note that it is not necessary on cygwin/mingw to append a dot to -# FILE even if both FILE and FILE.exe exist: automatic-append-.exe -# behavior happens only for exec(3), not for open(2)! Also, sourcing -# `FILE.' does not work on cygwin managed mounts. -func_source () -{ - $opt_debug - case $1 in - */* | *\\*) . "$1" ;; - *) . "./$1" ;; - esac -} - - -# func_resolve_sysroot PATH -# Replace a leading = in PATH with a sysroot. Store the result into -# func_resolve_sysroot_result -func_resolve_sysroot () -{ - func_resolve_sysroot_result=$1 - case $func_resolve_sysroot_result in - =*) - func_stripname '=' '' "$func_resolve_sysroot_result" - func_resolve_sysroot_result=$lt_sysroot$func_stripname_result - ;; - esac -} - -# func_replace_sysroot PATH -# If PATH begins with the sysroot, replace it with = and -# store the result into func_replace_sysroot_result. -func_replace_sysroot () -{ - case "$lt_sysroot:$1" in - ?*:"$lt_sysroot"*) - func_stripname "$lt_sysroot" '' "$1" - func_replace_sysroot_result="=$func_stripname_result" - ;; - *) - # Including no sysroot. - func_replace_sysroot_result=$1 - ;; - esac -} - -# func_infer_tag arg -# Infer tagged configuration to use if any are available and -# if one wasn't chosen via the "--tag" command line option. -# Only attempt this if the compiler in the base compile -# command doesn't match the default compiler. -# arg is usually of the form 'gcc ...' -func_infer_tag () -{ - $opt_debug - if test -n "$available_tags" && test -z "$tagname"; then - CC_quoted= - for arg in $CC; do - func_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - case $@ in - # Blanks in the command may have been stripped by the calling shell, - # but not from the CC environment variable when configure was run. - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; - # Blanks at the start of $base_compile will cause this to fail - # if we don't check for them as well. - *) - for z in $available_tags; do - if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" - CC_quoted= - for arg in $CC; do - # Double-quote args containing other shell metacharacters. - func_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - case "$@ " in - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) - # The compiler in the base compile command matches - # the one in the tagged configuration. - # Assume this is the tagged configuration we want. - tagname=$z - break - ;; - esac - fi - done - # If $tagname still isn't set, then no tagged configuration - # was found and let the user know that the "--tag" command - # line option must be used. - if test -z "$tagname"; then - func_echo "unable to infer tagged configuration" - func_fatal_error "specify a tag with \`--tag'" -# else -# func_verbose "using $tagname tagged configuration" - fi - ;; - esac - fi -} - - - -# func_write_libtool_object output_name pic_name nonpic_name -# Create a libtool object file (analogous to a ".la" file), -# but don't create it if we're doing a dry run. -func_write_libtool_object () -{ - write_libobj=${1} - if test "$build_libtool_libs" = yes; then - write_lobj=\'${2}\' - else - write_lobj=none - fi - - if test "$build_old_libs" = yes; then - write_oldobj=\'${3}\' - else - write_oldobj=none - fi - - $opt_dry_run || { - cat >${write_libobj}T </dev/null` - if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then - func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | - $SED -e "$lt_sed_naive_backslashify"` - else - func_convert_core_file_wine_to_w32_result= - fi - fi -} -# end: func_convert_core_file_wine_to_w32 - - -# func_convert_core_path_wine_to_w32 ARG -# Helper function used by path conversion functions when $build is *nix, and -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly -# configured wine environment available, with the winepath program in $build's -# $PATH. Assumes ARG has no leading or trailing path separator characters. -# -# ARG is path to be converted from $build format to win32. -# Result is available in $func_convert_core_path_wine_to_w32_result. -# Unconvertible file (directory) names in ARG are skipped; if no directory names -# are convertible, then the result may be empty. -func_convert_core_path_wine_to_w32 () -{ - $opt_debug - # unfortunately, winepath doesn't convert paths, only file names - func_convert_core_path_wine_to_w32_result="" - if test -n "$1"; then - oldIFS=$IFS - IFS=: - for func_convert_core_path_wine_to_w32_f in $1; do - IFS=$oldIFS - func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" - if test -n "$func_convert_core_file_wine_to_w32_result" ; then - if test -z "$func_convert_core_path_wine_to_w32_result"; then - func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" - else - func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" - fi - fi - done - IFS=$oldIFS - fi -} -# end: func_convert_core_path_wine_to_w32 - - -# func_cygpath ARGS... -# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when -# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) -# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or -# (2), returns the Cygwin file name or path in func_cygpath_result (input -# file name or path is assumed to be in w32 format, as previously converted -# from $build's *nix or MSYS format). In case (3), returns the w32 file name -# or path in func_cygpath_result (input file name or path is assumed to be in -# Cygwin format). Returns an empty string on error. -# -# ARGS are passed to cygpath, with the last one being the file name or path to -# be converted. -# -# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH -# environment variable; do not put it in $PATH. -func_cygpath () -{ - $opt_debug - if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then - func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` - if test "$?" -ne 0; then - # on failure, ensure result is empty - func_cygpath_result= - fi - else - func_cygpath_result= - func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" - fi -} -#end: func_cygpath - - -# func_convert_core_msys_to_w32 ARG -# Convert file name or path ARG from MSYS format to w32 format. Return -# result in func_convert_core_msys_to_w32_result. -func_convert_core_msys_to_w32 () -{ - $opt_debug - # awkward: cmd appends spaces to result - func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` -} -#end: func_convert_core_msys_to_w32 - - -# func_convert_file_check ARG1 ARG2 -# Verify that ARG1 (a file name in $build format) was converted to $host -# format in ARG2. Otherwise, emit an error message, but continue (resetting -# func_to_host_file_result to ARG1). -func_convert_file_check () -{ - $opt_debug - if test -z "$2" && test -n "$1" ; then - func_error "Could not determine host file name corresponding to" - func_error " \`$1'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback: - func_to_host_file_result="$1" - fi -} -# end func_convert_file_check - - -# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH -# Verify that FROM_PATH (a path in $build format) was converted to $host -# format in TO_PATH. Otherwise, emit an error message, but continue, resetting -# func_to_host_file_result to a simplistic fallback value (see below). -func_convert_path_check () -{ - $opt_debug - if test -z "$4" && test -n "$3"; then - func_error "Could not determine the host path corresponding to" - func_error " \`$3'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback. This is a deliberately simplistic "conversion" and - # should not be "improved". See libtool.info. - if test "x$1" != "x$2"; then - lt_replace_pathsep_chars="s|$1|$2|g" - func_to_host_path_result=`echo "$3" | - $SED -e "$lt_replace_pathsep_chars"` - else - func_to_host_path_result="$3" - fi - fi -} -# end func_convert_path_check - - -# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG -# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT -# and appending REPL if ORIG matches BACKPAT. -func_convert_path_front_back_pathsep () -{ - $opt_debug - case $4 in - $1 ) func_to_host_path_result="$3$func_to_host_path_result" - ;; - esac - case $4 in - $2 ) func_append func_to_host_path_result "$3" - ;; - esac -} -# end func_convert_path_front_back_pathsep - - -################################################## -# $build to $host FILE NAME CONVERSION FUNCTIONS # -################################################## -# invoked via `$to_host_file_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# Result will be available in $func_to_host_file_result. - - -# func_to_host_file ARG -# Converts the file name ARG from $build format to $host format. Return result -# in func_to_host_file_result. -func_to_host_file () -{ - $opt_debug - $to_host_file_cmd "$1" -} -# end func_to_host_file - - -# func_to_tool_file ARG LAZY -# converts the file name ARG from $build format to toolchain format. Return -# result in func_to_tool_file_result. If the conversion in use is listed -# in (the comma separated) LAZY, no conversion takes place. -func_to_tool_file () -{ - $opt_debug - case ,$2, in - *,"$to_tool_file_cmd",*) - func_to_tool_file_result=$1 - ;; - *) - $to_tool_file_cmd "$1" - func_to_tool_file_result=$func_to_host_file_result - ;; - esac -} -# end func_to_tool_file - - -# func_convert_file_noop ARG -# Copy ARG to func_to_host_file_result. -func_convert_file_noop () -{ - func_to_host_file_result="$1" -} -# end func_convert_file_noop - - -# func_convert_file_msys_to_w32 ARG -# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_file_result. -func_convert_file_msys_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_to_host_file_result="$func_convert_core_msys_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_w32 - - -# func_convert_file_cygwin_to_w32 ARG -# Convert file name ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_file_cygwin_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # because $build is cygwin, we call "the" cygpath in $PATH; no need to use - # LT_CYGPATH in this case. - func_to_host_file_result=`cygpath -m "$1"` - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_cygwin_to_w32 - - -# func_convert_file_nix_to_w32 ARG -# Convert file name ARG from *nix to w32 format. Requires a wine environment -# and a working winepath. Returns result in func_to_host_file_result. -func_convert_file_nix_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_file_wine_to_w32 "$1" - func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_w32 - - -# func_convert_file_msys_to_cygwin ARG -# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_file_msys_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_cygpath -u "$func_convert_core_msys_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_cygwin - - -# func_convert_file_nix_to_cygwin ARG -# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed -# in a wine environment, working winepath, and LT_CYGPATH set. Returns result -# in func_to_host_file_result. -func_convert_file_nix_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. - func_convert_core_file_wine_to_w32 "$1" - func_cygpath -u "$func_convert_core_file_wine_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_cygwin - - -############################################# -# $build to $host PATH CONVERSION FUNCTIONS # -############################################# -# invoked via `$to_host_path_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# The result will be available in $func_to_host_path_result. -# -# Path separators are also converted from $build format to $host format. If -# ARG begins or ends with a path separator character, it is preserved (but -# converted to $host format) on output. -# -# All path conversion functions are named using the following convention: -# file name conversion function : func_convert_file_X_to_Y () -# path conversion function : func_convert_path_X_to_Y () -# where, for any given $build/$host combination the 'X_to_Y' value is the -# same. If conversion functions are added for new $build/$host combinations, -# the two new functions must follow this pattern, or func_init_to_host_path_cmd -# will break. - - -# func_init_to_host_path_cmd -# Ensures that function "pointer" variable $to_host_path_cmd is set to the -# appropriate value, based on the value of $to_host_file_cmd. -to_host_path_cmd= -func_init_to_host_path_cmd () -{ - $opt_debug - if test -z "$to_host_path_cmd"; then - func_stripname 'func_convert_file_' '' "$to_host_file_cmd" - to_host_path_cmd="func_convert_path_${func_stripname_result}" - fi -} - - -# func_to_host_path ARG -# Converts the path ARG from $build format to $host format. Return result -# in func_to_host_path_result. -func_to_host_path () -{ - $opt_debug - func_init_to_host_path_cmd - $to_host_path_cmd "$1" -} -# end func_to_host_path - - -# func_convert_path_noop ARG -# Copy ARG to func_to_host_path_result. -func_convert_path_noop () -{ - func_to_host_path_result="$1" -} -# end func_convert_path_noop - - -# func_convert_path_msys_to_w32 ARG -# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_path_result. -func_convert_path_msys_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # Remove leading and trailing path separator characters from ARG. MSYS - # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; - # and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_msys_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_msys_to_w32 - - -# func_convert_path_cygwin_to_w32 ARG -# Convert path ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_path_cygwin_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_cygwin_to_w32 - - -# func_convert_path_nix_to_w32 ARG -# Convert path ARG from *nix to w32 format. Requires a wine environment and -# a working winepath. Returns result in func_to_host_file_result. -func_convert_path_nix_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_nix_to_w32 - - -# func_convert_path_msys_to_cygwin ARG -# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_path_msys_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_msys_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_msys_to_cygwin - - -# func_convert_path_nix_to_cygwin ARG -# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a -# a wine environment, working winepath, and LT_CYGPATH set. Returns result in -# func_to_host_file_result. -func_convert_path_nix_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # Remove leading and trailing path separator characters from - # ARG. msys behavior is inconsistent here, cygpath turns them - # into '.;' and ';.', and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_nix_to_cygwin - - -# func_mode_compile arg... -func_mode_compile () -{ - $opt_debug - # Get the compilation command and the source file. - base_compile= - srcfile="$nonopt" # always keep a non-empty value in "srcfile" - suppress_opt=yes - suppress_output= - arg_mode=normal - libobj= - later= - pie_flag= - - for arg - do - case $arg_mode in - arg ) - # do not "continue". Instead, add this to base_compile - lastarg="$arg" - arg_mode=normal - ;; - - target ) - libobj="$arg" - arg_mode=normal - continue - ;; - - normal ) - # Accept any command-line options. - case $arg in - -o) - test -n "$libobj" && \ - func_fatal_error "you cannot specify \`-o' more than once" - arg_mode=target - continue - ;; - - -pie | -fpie | -fPIE) - func_append pie_flag " $arg" - continue - ;; - - -shared | -static | -prefer-pic | -prefer-non-pic) - func_append later " $arg" - continue - ;; - - -no-suppress) - suppress_opt=no - continue - ;; - - -Xcompiler) - arg_mode=arg # the next one goes into the "base_compile" arg list - continue # The current "srcfile" will either be retained or - ;; # replaced later. I would guess that would be a bug. - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - func_append_quoted lastarg "$arg" - done - IFS="$save_ifs" - func_stripname ' ' '' "$lastarg" - lastarg=$func_stripname_result - - # Add the arguments to base_compile. - func_append base_compile " $lastarg" - continue - ;; - - *) - # Accept the current argument as the source file. - # The previous "srcfile" becomes the current argument. - # - lastarg="$srcfile" - srcfile="$arg" - ;; - esac # case $arg - ;; - esac # case $arg_mode - - # Aesthetically quote the previous argument. - func_append_quoted base_compile "$lastarg" - done # for arg - - case $arg_mode in - arg) - func_fatal_error "you must specify an argument for -Xcompile" - ;; - target) - func_fatal_error "you must specify a target with \`-o'" - ;; - *) - # Get the name of the library object. - test -z "$libobj" && { - func_basename "$srcfile" - libobj="$func_basename_result" - } - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - case $libobj in - *.[cCFSifmso] | \ - *.ada | *.adb | *.ads | *.asm | \ - *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ - *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) - func_xform "$libobj" - libobj=$func_xform_result - ;; - esac - - case $libobj in - *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; - *) - func_fatal_error "cannot determine name of library object from \`$libobj'" - ;; - esac - - func_infer_tag $base_compile - - for arg in $later; do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - continue - ;; - - -static) - build_libtool_libs=no - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - esac - done - - func_quote_for_eval "$libobj" - test "X$libobj" != "X$func_quote_for_eval_result" \ - && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ - && func_warning "libobj name \`$libobj' may not contain shell special characters." - func_dirname_and_basename "$obj" "/" "" - objname="$func_basename_result" - xdir="$func_dirname_result" - lobj=${xdir}$objdir/$objname - - test -z "$base_compile" && \ - func_fatal_help "you must specify a compilation command" - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $lobj $libobj ${libobj}T" - else - removelist="$lobj $libobj ${libobj}T" - fi - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2* | cegcc*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - else - output_obj= - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - $ECHO "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - func_append removelist " $output_obj" - $ECHO "$srcfile" > "$lockfile" - fi - - $opt_dry_run || $RM $removelist - func_append removelist " $lockfile" - trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 - - func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 - srcfile=$func_to_tool_file_result - func_quote_for_eval "$srcfile" - qsrcfile=$func_quote_for_eval_result - - # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then - # Without this assignment, base_compile gets emptied. - fbsd_hideous_sh_bug=$base_compile - - if test "$pic_mode" != no; then - command="$base_compile $qsrcfile $pic_flag" - else - # Don't build PIC code - command="$base_compile $qsrcfile" - fi - - func_mkdir_p "$xdir$objdir" - - if test -z "$output_obj"; then - # Place PIC objects in $objdir - func_append command " -o $lobj" - fi - - func_show_eval_locale "$command" \ - 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' - - if test "$need_locks" = warn && - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then - $ECHO "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed, then go on to compile the next one - if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then - func_show_eval '$MV "$output_obj" "$lobj"' \ - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' - fi - - # Allow error messages only from the first compilation. - if test "$suppress_opt" = yes; then - suppress_output=' >/dev/null 2>&1' - fi - fi - - # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - if test "$pic_mode" != yes; then - # Don't build PIC code - command="$base_compile $qsrcfile$pie_flag" - else - command="$base_compile $qsrcfile $pic_flag" - fi - if test "$compiler_c_o" = yes; then - func_append command " -o $obj" - fi - - # Suppress compiler output if we already did a PIC compilation. - func_append command "$suppress_output" - func_show_eval_locale "$command" \ - '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' - - if test "$need_locks" = warn && - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then - $ECHO "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed - if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then - func_show_eval '$MV "$output_obj" "$obj"' \ - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' - fi - fi - - $opt_dry_run || { - func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" - - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - removelist=$lockfile - $RM "$lockfile" - fi - } - - exit $EXIT_SUCCESS -} - -$opt_help || { - test "$opt_mode" = compile && func_mode_compile ${1+"$@"} -} - -func_mode_help () -{ - # We need to display help for each of the modes. - case $opt_mode in - "") - # Generic help is extracted from the usage comments - # at the start of this file. - func_help - ;; - - clean) - $ECHO \ -"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - - compile) - $ECHO \ -"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -no-suppress do not suppress compiler output for multiple passes - -prefer-pic try to build PIC objects only - -prefer-non-pic try to build non-PIC objects only - -shared do not build a \`.o' file suitable for static linking - -static only build a \`.o' file suitable for static linking - -Wc,FLAG pass FLAG directly to the compiler - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - - execute) - $ECHO \ -"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - - finish) - $ECHO \ -"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - - install) - $ECHO \ -"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The following components of INSTALL-COMMAND are treated specially: - - -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - - link) - $ECHO \ -"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -bindir BINDIR specify path to binaries directory (for systems where - libraries must be found in the PATH setting at runtime) - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -objectlist FILE Use a list of object files found in FILE to specify objects - -precious-files-regex REGEX - don't remove output files matching REGEX - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -shared only do dynamic linking of libtool libraries - -shrext SUFFIX override the standard shared library file extension - -static do not do any dynamic linking of uninstalled libtool libraries - -static-libtool-libs - do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -weak LIBNAME declare that the target provides the LIBNAME interface - -Wc,FLAG - -Xcompiler FLAG pass linker-specific FLAG directly to the compiler - -Wl,FLAG - -Xlinker FLAG pass linker-specific FLAG directly to the linker - -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - - uninstall) - $ECHO \ -"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - - *) - func_fatal_help "invalid operation mode \`$opt_mode'" - ;; - esac - - echo - $ECHO "Try \`$progname --help' for more information about other modes." -} - -# Now that we've collected a possible --mode arg, show help if necessary -if $opt_help; then - if test "$opt_help" = :; then - func_mode_help - else - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - func_mode_help - done - } | sed -n '1p; 2,$s/^Usage:/ or: /p' - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - echo - func_mode_help - done - } | - sed '1d - /^When reporting/,/^Report/{ - H - d - } - $x - /information about other modes/d - /more detailed .*MODE/d - s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' - fi - exit $? -fi - - -# func_mode_execute arg... -func_mode_execute () -{ - $opt_debug - # The first argument is the command name. - cmd="$nonopt" - test -z "$cmd" && \ - func_fatal_help "you must specify a COMMAND" - - # Handle -dlopen flags immediately. - for file in $opt_dlopen; do - test -f "$file" \ - || func_fatal_help "\`$file' is not a file" - - dir= - case $file in - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$lib' is not a valid libtool archive" - - # Read the libtool library. - dlname= - library_names= - func_source "$file" - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && \ - func_warning "\`$file' was not linked with \`-export-dynamic'" - continue - fi - - func_dirname "$file" "" "." - dir="$func_dirname_result" - - if test -f "$dir/$objdir/$dlname"; then - func_append dir "/$objdir" - else - if test ! -f "$dir/$dlname"; then - func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" - fi - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - func_dirname "$file" "" "." - dir="$func_dirname_result" - ;; - - *) - func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -* | *.la | *.lo ) ;; - *) - # Do a test to see if this is really a libtool program. - if func_ltwrapper_script_p "$file"; then - func_source "$file" - # Transform arg to wrapped name. - file="$progdir/$program" - elif func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - func_source "$func_ltwrapper_scriptname_result" - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - func_append_quoted args "$file" - done - - if test "X$opt_dry_run" = Xfalse; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved environment variables - for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES - do - eval "if test \"\${save_$lt_var+set}\" = set; then - $lt_var=\$save_$lt_var; export $lt_var - else - $lt_unset $lt_var - fi" - done - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" - echo "export $shlibpath_var" - fi - $ECHO "$cmd$args" - exit $EXIT_SUCCESS - fi -} - -test "$opt_mode" = execute && func_mode_execute ${1+"$@"} - - -# func_mode_finish arg... -func_mode_finish () -{ - $opt_debug - libs= - libdirs= - admincmds= - - for opt in "$nonopt" ${1+"$@"} - do - if test -d "$opt"; then - func_append libdirs " $opt" - - elif test -f "$opt"; then - if func_lalib_unsafe_p "$opt"; then - func_append libs " $opt" - else - func_warning "\`$opt' is not a valid libtool archive" - fi - - else - func_fatal_error "invalid argument \`$opt'" - fi - done - - if test -n "$libs"; then - if test -n "$lt_sysroot"; then - sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` - sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" - else - sysroot_cmd= - fi - - # Remove sysroot references - if $opt_dry_run; then - for lib in $libs; do - echo "removing references to $lt_sysroot and \`=' prefixes from $lib" - done - else - tmpdir=`func_mktempdir` - for lib in $libs; do - sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ - > $tmpdir/tmp-la - mv -f $tmpdir/tmp-la $lib - done - ${RM}r "$tmpdir" - fi - fi - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - func_execute_cmds "$finish_cmds" 'admincmds="$admincmds -'"$cmd"'"' - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $opt_dry_run || eval "$cmds" || func_append admincmds " - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - $opt_silent && exit $EXIT_SUCCESS - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - $ECHO " $libdir" - done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - $ECHO " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $ECHO " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo - - echo "See any operating system documentation about shared libraries for" - case $host in - solaris2.[6789]|solaris2.1[0-9]) - echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" - echo "pages." - ;; - *) - echo "more information, such as the ld(1) and ld.so(8) manual pages." - ;; - esac - echo "----------------------------------------------------------------------" - fi - exit $EXIT_SUCCESS -} - -test "$opt_mode" = finish && func_mode_finish ${1+"$@"} - - -# func_mode_install arg... -func_mode_install () -{ - $opt_debug - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - case $nonopt in *shtool*) :;; *) false;; esac; then - # Aesthetically quote it. - func_quote_for_eval "$nonopt" - install_prog="$func_quote_for_eval_result " - arg=$1 - shift - else - install_prog= - arg=$nonopt - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - func_quote_for_eval "$arg" - func_append install_prog "$func_quote_for_eval_result" - install_shared_prog=$install_prog - case " $install_prog " in - *[\\\ /]cp\ *) install_cp=: ;; - *) install_cp=false ;; - esac - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - no_mode=: - for arg - do - arg2= - if test -n "$dest"; then - func_append files " $dest" - dest=$arg - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) - if $install_cp; then :; else - prev=$arg - fi - ;; - -g | -m | -o) - prev=$arg - ;; - -s) - stripme=" -s" - continue - ;; - -*) - ;; - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - if test "x$prev" = x-m && test -n "$install_override_mode"; then - arg2=$install_override_mode - no_mode=false - fi - prev= - else - dest=$arg - continue - fi - ;; - esac - - # Aesthetically quote the argument. - func_quote_for_eval "$arg" - func_append install_prog " $func_quote_for_eval_result" - if test -n "$arg2"; then - func_quote_for_eval "$arg2" - fi - func_append install_shared_prog " $func_quote_for_eval_result" - done - - test -z "$install_prog" && \ - func_fatal_help "you must specify an install program" - - test -n "$prev" && \ - func_fatal_help "the \`$prev' option requires an argument" - - if test -n "$install_override_mode" && $no_mode; then - if $install_cp; then :; else - func_quote_for_eval "$install_override_mode" - func_append install_shared_prog " -m $func_quote_for_eval_result" - fi - fi - - if test -z "$files"; then - if test -z "$dest"; then - func_fatal_help "no file or destination specified" - else - func_fatal_help "you must specify a destination" - fi - fi - - # Strip any trailing slash from the destination. - func_stripname '' '/' "$dest" - dest=$func_stripname_result - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - func_dirname_and_basename "$dest" "" "." - destdir="$func_dirname_result" - destname="$func_basename_result" - - # Not a directory, so check to see that there is only one file specified. - set dummy $files; shift - test "$#" -gt 1 && \ - func_fatal_help "\`$dest' is not a directory" - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - func_fatal_help "\`$destdir' must be an absolute directory name" - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - func_append staticlibs " $file" - ;; - - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$file' is not a valid libtool archive" - - library_names= - old_library= - relink_command= - func_source "$file" - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) func_append current_libdirs " $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) func_append future_libdirs " $libdir" ;; - esac - fi - - func_dirname "$file" "/" "" - dir="$func_dirname_result" - func_append dir "$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. - # At present, this check doesn't affect windows .dll's that - # are installed into $libdir/../bin (currently, that works fine) - # but it's something to keep an eye on. - test "$inst_prefix_dir" = "$destdir" && \ - func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` - fi - - func_warning "relinking \`$file'" - func_show_eval "$relink_command" \ - 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' - fi - - # See the names of the shared library. - set dummy $library_names; shift - if test -n "$1"; then - realname="$1" - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ - 'exit $?' - tstripme="$stripme" - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - case $realname in - *.dll.a) - tstripme="" - ;; - esac - ;; - esac - if test -n "$tstripme" && test -n "$striplib"; then - func_show_eval "$striplib $destdir/$realname" 'exit $?' - fi - - if test "$#" -gt 0; then - # Delete the old symlinks, and create new ones. - # Try `ln -sf' first, because the `ln' binary might depend on - # the symlink we replace! Solaris /bin/ln does not understand -f, - # so we also need to try rm && ln -s. - for linkname - do - test "$linkname" != "$realname" \ - && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - func_execute_cmds "$postinstall_cmds" 'exit $?' - fi - - # Install the pseudo-library for information purposes. - func_basename "$file" - name="$func_basename_result" - instname="$dir/$name"i - func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' - - # Maybe install the static library, too. - test -n "$old_library" && func_append staticlibs " $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - func_lo2o "$destfile" - staticdest=$func_lo2o_result - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - func_fatal_help "cannot copy a libtool object to \`$destfile'" - ;; - esac - - # Install the libtool object if requested. - test -n "$destfile" && \ - func_show_eval "$install_prog $file $destfile" 'exit $?' - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - func_lo2o "$file" - staticobj=$func_lo2o_result - func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' - fi - exit $EXIT_SUCCESS - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" - fi - - # If the file is missing, and there is a .exe on the end, strip it - # because it is most likely a libtool script we actually want to - # install - stripped_ext="" - case $file in - *.exe) - if test ! -f "$file"; then - func_stripname '' '.exe' "$file" - file=$func_stripname_result - stripped_ext=".exe" - fi - ;; - esac - - # Do a test to see if this is really a libtool program. - case $host in - *cygwin* | *mingw*) - if func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - wrapper=$func_ltwrapper_scriptname_result - else - func_stripname '' '.exe' "$file" - wrapper=$func_stripname_result - fi - ;; - *) - wrapper=$file - ;; - esac - if func_ltwrapper_script_p "$wrapper"; then - notinst_deplibs= - relink_command= - - func_source "$wrapper" - - # Check the variables that should have been set. - test -z "$generated_by_libtool_version" && \ - func_fatal_error "invalid libtool wrapper script \`$wrapper'" - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - func_source "$lib" - fi - libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - func_warning "\`$lib' has not been installed in \`$libdir'" - finalize=no - fi - done - - relink_command= - func_source "$wrapper" - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - $opt_dry_run || { - if test "$finalize" = yes; then - tmpdir=`func_mktempdir` - func_basename "$file$stripped_ext" - file="$func_basename_result" - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` - - $opt_silent || { - func_quote_for_expand "$relink_command" - eval "func_echo $func_quote_for_expand_result" - } - if eval "$relink_command"; then : - else - func_error "error: relink \`$file' with the above command before installing it" - $opt_dry_run || ${RM}r "$tmpdir" - continue - fi - file="$outputname" - else - func_warning "cannot relink \`$file'" - fi - } - else - # Install the binary that we compiled earlier. - file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyway - case $install_prog,$host in - */usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - func_stripname '' '.exe' "$destfile" - destfile=$func_stripname_result - ;; - esac - ;; - esac - func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' - $opt_dry_run || if test -n "$outputname"; then - ${RM}r "$tmpdir" - fi - ;; - esac - done - - for file in $staticlibs; do - func_basename "$file" - name="$func_basename_result" - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - - func_show_eval "$install_prog \$file \$oldlib" 'exit $?' - - if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $tool_oldlib" 'exit $?' - fi - - # Do each command in the postinstall commands. - func_execute_cmds "$old_postinstall_cmds" 'exit $?' - done - - test -n "$future_libdirs" && \ - func_warning "remember to run \`$progname --finish$future_libdirs'" - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - $opt_dry_run && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' - else - exit $EXIT_SUCCESS - fi -} - -test "$opt_mode" = install && func_mode_install ${1+"$@"} - - -# func_generate_dlsyms outputname originator pic_p -# Extract symbols from dlprefiles and create ${outputname}S.o with -# a dlpreopen symbol table. -func_generate_dlsyms () -{ - $opt_debug - my_outputname="$1" - my_originator="$2" - my_pic_p="${3-no}" - my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` - my_dlsyms= - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - my_dlsyms="${my_outputname}S.c" - else - func_error "not configured to extract global symbols from dlpreopened files" - fi - fi - - if test -n "$my_dlsyms"; then - case $my_dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${my_outputname}.nm" - - func_show_eval "$RM $nlist ${nlist}S ${nlist}T" - - # Parse the name list into a source file. - func_verbose "creating $output_objdir/$my_dlsyms" - - $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ -/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ -/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) -#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" -#endif - -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#endif - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - func_verbose "generating symbol list for \`$output'" - - $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` - for progfile in $progfiles; do - func_to_tool_file "$progfile" func_convert_file_msys_to_w32 - func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" - $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $opt_dry_run || { - eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - } - fi - - if test -n "$export_symbols_regex"; then - $opt_dry_run || { - eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - } - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$outputname.exp" - $opt_dry_run || { - $RM $export_symbols - eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - case $host in - *cygwin* | *mingw* | *cegcc* ) - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' - eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' - ;; - esac - } - else - $opt_dry_run || { - eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' - eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - case $host in - *cygwin* | *mingw* | *cegcc* ) - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' - eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' - ;; - esac - } - fi - fi - - for dlprefile in $dlprefiles; do - func_verbose "extracting global C symbols from \`$dlprefile'" - func_basename "$dlprefile" - name="$func_basename_result" - case $host in - *cygwin* | *mingw* | *cegcc* ) - # if an import library, we need to obtain dlname - if func_win32_import_lib_p "$dlprefile"; then - func_tr_sh "$dlprefile" - eval "curr_lafile=\$libfile_$func_tr_sh_result" - dlprefile_dlbasename="" - if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then - # Use subshell, to avoid clobbering current variable values - dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` - if test -n "$dlprefile_dlname" ; then - func_basename "$dlprefile_dlname" - dlprefile_dlbasename="$func_basename_result" - else - # no lafile. user explicitly requested -dlpreopen . - $sharedlib_from_linklib_cmd "$dlprefile" - dlprefile_dlbasename=$sharedlib_from_linklib_result - fi - fi - $opt_dry_run || { - if test -n "$dlprefile_dlbasename" ; then - eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' - else - func_warning "Could not compute DLL name from $name" - eval '$ECHO ": $name " >> "$nlist"' - fi - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | - $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" - } - else # not an import lib - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - fi - ;; - *) - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - ;; - esac - done - - $opt_dry_run || { - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $MV "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if $GREP -v "^: " < "$nlist" | - if sort -k 3 /dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then - : - else - $GREP -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' - else - echo '/* NONE */' >> "$output_objdir/$my_dlsyms" - fi - - echo >> "$output_objdir/$my_dlsyms" "\ - -/* The mapping between symbol names and symbols. */ -typedef struct { - const char *name; - void *address; -} lt_dlsymlist; -extern LT_DLSYM_CONST lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[]; -LT_DLSYM_CONST lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[] = -{\ - { \"$my_originator\", (void *) 0 }," - - case $need_lib_prefix in - no) - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" - ;; - *) - eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" - ;; - esac - echo >> "$output_objdir/$my_dlsyms" "\ - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_${my_prefix}_LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - } # !$opt_dry_run - - pic_flag_for_symtable= - case "$compile_command " in - *" -static "*) ;; - *) - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; - *-*-hpux*) - pic_flag_for_symtable=" $pic_flag" ;; - *) - if test "X$my_pic_p" != Xno; then - pic_flag_for_symtable=" $pic_flag" - fi - ;; - esac - ;; - esac - symtab_cflags= - for arg in $LTCFLAGS; do - case $arg in - -pie | -fpie | -fPIE) ;; - *) func_append symtab_cflags " $arg" ;; - esac - done - - # Now compile the dynamic symbol file. - func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' - - # Clean up the generated files. - func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' - - # Transform the symbol file into the correct name. - symfileobj="$output_objdir/${my_outputname}S.$objext" - case $host in - *cygwin* | *mingw* | *cegcc* ) - if test -f "$output_objdir/$my_outputname.def"; then - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - else - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` - fi - ;; - *) - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` - ;; - esac - ;; - *) - func_fatal_error "unknown suffix for \`$my_dlsyms'" - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` - fi -} - -# func_win32_libid arg -# return the library type of file 'arg' -# -# Need a lot of goo to handle *both* DLLs and import libs -# Has to be a shell function in order to 'eat' the argument -# that is supplied when $file_magic_command is called. -# Despite the name, also deal with 64 bit binaries. -func_win32_libid () -{ - $opt_debug - win32_libid_type="unknown" - win32_fileres=`file -L $1 2>/dev/null` - case $win32_fileres in - *ar\ archive\ import\ library*) # definitely import - win32_libid_type="x86 archive import" - ;; - *ar\ archive*) # could be an import, or static - # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then - func_to_tool_file "$1" func_convert_file_msys_to_w32 - win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | - $SED -n -e ' - 1,100{ - / I /{ - s,.*,import, - p - q - } - }'` - case $win32_nmres in - import*) win32_libid_type="x86 archive import";; - *) win32_libid_type="x86 archive static";; - esac - fi - ;; - *DLL*) - win32_libid_type="x86 DLL" - ;; - *executable*) # but shell scripts are "executable" too... - case $win32_fileres in - *MS\ Windows\ PE\ Intel*) - win32_libid_type="x86 DLL" - ;; - esac - ;; - esac - $ECHO "$win32_libid_type" -} - -# func_cygming_dll_for_implib ARG -# -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib () -{ - $opt_debug - sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` -} - -# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs -# -# The is the core of a fallback implementation of a -# platform-specific function to extract the name of the -# DLL associated with the specified import library LIBNAME. -# -# SECTION_NAME is either .idata$6 or .idata$7, depending -# on the platform and compiler that created the implib. -# -# Echos the name of the DLL associated with the -# specified import library. -func_cygming_dll_for_implib_fallback_core () -{ - $opt_debug - match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` - $OBJDUMP -s --section "$1" "$2" 2>/dev/null | - $SED '/^Contents of section '"$match_literal"':/{ - # Place marker at beginning of archive member dllname section - s/.*/====MARK====/ - p - d - } - # These lines can sometimes be longer than 43 characters, but - # are always uninteresting - /:[ ]*file format pe[i]\{,1\}-/d - /^In archive [^:]*:/d - # Ensure marker is printed - /^====MARK====/p - # Remove all lines with less than 43 characters - /^.\{43\}/!d - # From remaining lines, remove first 43 characters - s/^.\{43\}//' | - $SED -n ' - # Join marker and all lines until next marker into a single line - /^====MARK====/ b para - H - $ b para - b - :para - x - s/\n//g - # Remove the marker - s/^====MARK====// - # Remove trailing dots and whitespace - s/[\. \t]*$// - # Print - /./p' | - # we now have a list, one entry per line, of the stringified - # contents of the appropriate section of all members of the - # archive which possess that section. Heuristic: eliminate - # all those which have a first or second character that is - # a '.' (that is, objdump's representation of an unprintable - # character.) This should work for all archives with less than - # 0x302f exports -- but will fail for DLLs whose name actually - # begins with a literal '.' or a single character followed by - # a '.'. - # - # Of those that remain, print the first one. - $SED -e '/^\./d;/^.\./d;q' -} - -# func_cygming_gnu_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is a GNU/binutils-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_gnu_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` - test -n "$func_cygming_gnu_implib_tmp" -} - -# func_cygming_ms_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is an MS-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_ms_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` - test -n "$func_cygming_ms_implib_tmp" -} - -# func_cygming_dll_for_implib_fallback ARG -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# -# This fallback implementation is for use when $DLLTOOL -# does not support the --identify-strict option. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib_fallback () -{ - $opt_debug - if func_cygming_gnu_implib_p "$1" ; then - # binutils import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` - elif func_cygming_ms_implib_p "$1" ; then - # ms-generated import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` - else - # unknown - sharedlib_from_linklib_result="" - fi -} - - -# func_extract_an_archive dir oldlib -func_extract_an_archive () -{ - $opt_debug - f_ex_an_ar_dir="$1"; shift - f_ex_an_ar_oldlib="$1" - if test "$lock_old_archive_extraction" = yes; then - lockfile=$f_ex_an_ar_oldlib.lock - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - fi - func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ - 'stat=$?; rm -f "$lockfile"; exit $stat' - if test "$lock_old_archive_extraction" = yes; then - $opt_dry_run || rm -f "$lockfile" - fi - if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then - : - else - func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" - fi -} - - -# func_extract_archives gentop oldlib ... -func_extract_archives () -{ - $opt_debug - my_gentop="$1"; shift - my_oldlibs=${1+"$@"} - my_oldobjs="" - my_xlib="" - my_xabs="" - my_xdir="" - - for my_xlib in $my_oldlibs; do - # Extract the objects. - case $my_xlib in - [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; - *) my_xabs=`pwd`"/$my_xlib" ;; - esac - func_basename "$my_xlib" - my_xlib="$func_basename_result" - my_xlib_u=$my_xlib - while :; do - case " $extracted_archives " in - *" $my_xlib_u "*) - func_arith $extracted_serial + 1 - extracted_serial=$func_arith_result - my_xlib_u=lt$extracted_serial-$my_xlib ;; - *) break ;; - esac - done - extracted_archives="$extracted_archives $my_xlib_u" - my_xdir="$my_gentop/$my_xlib_u" - - func_mkdir_p "$my_xdir" - - case $host in - *-darwin*) - func_verbose "Extracting $my_xabs" - # Do not bother doing anything if just a dry run - $opt_dry_run || { - darwin_orig_dir=`pwd` - cd $my_xdir || exit $? - darwin_archive=$my_xabs - darwin_curdir=`pwd` - darwin_base_archive=`basename "$darwin_archive"` - darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` - if test -n "$darwin_arches"; then - darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` - darwin_arch= - func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" - for darwin_arch in $darwin_arches ; do - func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" - $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" - cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" - func_extract_an_archive "`pwd`" "${darwin_base_archive}" - cd "$darwin_curdir" - $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" - done # $darwin_arches - ## Okay now we've a bunch of thin objects, gotta fatten them up :) - darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` - darwin_file= - darwin_files= - for darwin_file in $darwin_filelist; do - darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` - $LIPO -create -output "$darwin_file" $darwin_files - done # $darwin_filelist - $RM -rf unfat-$$ - cd "$darwin_orig_dir" - else - cd $darwin_orig_dir - func_extract_an_archive "$my_xdir" "$my_xabs" - fi # $darwin_arches - } # !$opt_dry_run - ;; - *) - func_extract_an_archive "$my_xdir" "$my_xabs" - ;; - esac - my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` - done - - func_extract_archives_result="$my_oldobjs" -} - - -# func_emit_wrapper [arg=no] -# -# Emit a libtool wrapper script on stdout. -# Don't directly open a file because we may want to -# incorporate the script contents within a cygwin/mingw -# wrapper executable. Must ONLY be called from within -# func_mode_link because it depends on a number of variables -# set therein. -# -# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR -# variable will take. If 'yes', then the emitted script -# will assume that the directory in which it is stored is -# the $objdir directory. This is a cygwin/mingw-specific -# behavior. -func_emit_wrapper () -{ - func_emit_wrapper_arg1=${1-no} - - $ECHO "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='$sed_quote_subst' - -# Be Bourne compatible -if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variables: - generated_by_libtool_version='$macro_version' - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$ECHO are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - file=\"\$0\"" - - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` - $ECHO "\ - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - ECHO=\"$qECHO\" - fi - -# Very basic option parsing. These options are (a) specific to -# the libtool wrapper, (b) are identical between the wrapper -# /script/ and the wrapper /executable/ which is used only on -# windows platforms, and (c) all begin with the string "--lt-" -# (application programs are unlikely to have options which match -# this pattern). -# -# There are only two supported options: --lt-debug and -# --lt-dump-script. There is, deliberately, no --lt-help. -# -# The first argument to this parsing function should be the -# script's $0 value, followed by "$@". -lt_option_debug= -func_parse_lt_options () -{ - lt_script_arg0=\$0 - shift - for lt_opt - do - case \"\$lt_opt\" in - --lt-debug) lt_option_debug=1 ;; - --lt-dump-script) - lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` - test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. - lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` - cat \"\$lt_dump_D/\$lt_dump_F\" - exit 0 - ;; - --lt-*) - \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 - exit 1 - ;; - esac - done - - # Print the debug banner immediately: - if test -n \"\$lt_option_debug\"; then - echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 - fi -} - -# Used when --lt-debug. Prints its arguments to stdout -# (redirection is the responsibility of the caller) -func_lt_dump_args () -{ - lt_dump_args_N=1; - for lt_arg - do - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" - lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` - done -} - -# Core function for launching the target application -func_exec_program_core () -{ -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} -" - ;; - - *) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir/\$program\" \${1+\"\$@\"} -" - ;; - esac - $ECHO "\ - \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 - exit 1 -} - -# A function to encapsulate launching the target application -# Strips options in the --lt-* namespace from \$@ and -# launches target application with the remaining arguments. -func_exec_program () -{ - case \" \$* \" in - *\\ --lt-*) - for lt_wr_arg - do - case \$lt_wr_arg in - --lt-*) ;; - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; - esac - shift - done ;; - esac - func_exec_program_core \${1+\"\$@\"} -} - - # Parse options - func_parse_lt_options \"\$0\" \${1+\"\$@\"} - - # Find the directory that this script lives in. - thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` - done - - # Usually 'no', except on cygwin/mingw when embedded into - # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 - if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then - # special case for '.' - if test \"\$thisdir\" = \".\"; then - thisdir=\`pwd\` - fi - # remove .libs from thisdir - case \"\$thisdir\" in - *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; - $objdir ) thisdir=. ;; - esac - fi - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - $ECHO "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $MKDIR \"\$progdir\" - else - $RM \"\$progdir/\$file\" - fi" - - $ECHO "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $ECHO \"\$relink_command_output\" >&2 - $RM \"\$progdir/\$file\" - exit 1 - fi - fi - - $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $RM \"\$progdir/\$program\"; - $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $RM \"\$progdir/\$file\" - fi" - else - $ECHO "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - $ECHO "\ - - if test -f \"\$progdir/\$program\"; then" - - # fixup the dll searchpath if we need to. - # - # Fix the DLL searchpath if we need to. Do this before prepending - # to shlibpath, because on Windows, both are PATH and uninstalled - # libraries must come first. - if test -n "$dllsearchpath"; then - $ECHO "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $ECHO "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 sed - $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` - - export $shlibpath_var -" - fi - - $ECHO "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. - func_exec_program \${1+\"\$@\"} - fi - else - # The program doesn't exist. - \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 - \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 - \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" -} - - -# func_emit_cwrapperexe_src -# emit the source code for a wrapper executable on stdout -# Must ONLY be called from within func_mode_link because -# it depends on a number of variable set therein. -func_emit_cwrapperexe_src () -{ - cat < -#include -#ifdef _MSC_VER -# include -# include -# include -#else -# include -# include -# ifdef __CYGWIN__ -# include -# endif -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -/* declarations of non-ANSI functions */ -#if defined(__MINGW32__) -# ifdef __STRICT_ANSI__ -int _putenv (const char *); -# endif -#elif defined(__CYGWIN__) -# ifdef __STRICT_ANSI__ -char *realpath (const char *, char *); -int putenv (char *); -int setenv (const char *, const char *, int); -# endif -/* #elif defined (other platforms) ... */ -#endif - -/* portability defines, excluding path handling macros */ -#if defined(_MSC_VER) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -# define S_IXUSR _S_IEXEC -# ifndef _INTPTR_T_DEFINED -# define _INTPTR_T_DEFINED -# define intptr_t int -# endif -#elif defined(__MINGW32__) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -#elif defined(__CYGWIN__) -# define HAVE_SETENV -# define FOPEN_WB "wb" -/* #elif defined (other platforms) ... */ -#endif - -#if defined(PATH_MAX) -# define LT_PATHMAX PATH_MAX -#elif defined(MAXPATHLEN) -# define LT_PATHMAX MAXPATHLEN -#else -# define LT_PATHMAX 1024 -#endif - -#ifndef S_IXOTH -# define S_IXOTH 0 -#endif -#ifndef S_IXGRP -# define S_IXGRP 0 -#endif - -/* path handling portability macros */ -#ifndef DIR_SEPARATOR -# define DIR_SEPARATOR '/' -# define PATH_SEPARATOR ':' -#endif - -#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ - defined (__OS2__) -# define HAVE_DOS_BASED_FILE_SYSTEM -# define FOPEN_WB "wb" -# ifndef DIR_SEPARATOR_2 -# define DIR_SEPARATOR_2 '\\' -# endif -# ifndef PATH_SEPARATOR_2 -# define PATH_SEPARATOR_2 ';' -# endif -#endif - -#ifndef DIR_SEPARATOR_2 -# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) -#else /* DIR_SEPARATOR_2 */ -# define IS_DIR_SEPARATOR(ch) \ - (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) -#endif /* DIR_SEPARATOR_2 */ - -#ifndef PATH_SEPARATOR_2 -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) -#else /* PATH_SEPARATOR_2 */ -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) -#endif /* PATH_SEPARATOR_2 */ - -#ifndef FOPEN_WB -# define FOPEN_WB "w" -#endif -#ifndef _O_BINARY -# define _O_BINARY 0 -#endif - -#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) -#define XFREE(stale) do { \ - if (stale) { free ((void *) stale); stale = 0; } \ -} while (0) - -#if defined(LT_DEBUGWRAPPER) -static int lt_debug = 1; -#else -static int lt_debug = 0; -#endif - -const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ - -void *xmalloc (size_t num); -char *xstrdup (const char *string); -const char *base_name (const char *name); -char *find_executable (const char *wrapper); -char *chase_symlinks (const char *pathspec); -int make_executable (const char *path); -int check_executable (const char *path); -char *strendzap (char *str, const char *pat); -void lt_debugprintf (const char *file, int line, const char *fmt, ...); -void lt_fatal (const char *file, int line, const char *message, ...); -static const char *nonnull (const char *s); -static const char *nonempty (const char *s); -void lt_setenv (const char *name, const char *value); -char *lt_extend_str (const char *orig_value, const char *add, int to_end); -void lt_update_exe_path (const char *name, const char *value); -void lt_update_lib_path (const char *name, const char *value); -char **prepare_spawn (char **argv); -void lt_dump_script (FILE *f); -EOF - - cat <= 0) - && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) - return 1; - else - return 0; -} - -int -make_executable (const char *path) -{ - int rval = 0; - struct stat st; - - lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", - nonempty (path)); - if ((!path) || (!*path)) - return 0; - - if (stat (path, &st) >= 0) - { - rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); - } - return rval; -} - -/* Searches for the full path of the wrapper. Returns - newly allocated full path name if found, NULL otherwise - Does not chase symlinks, even on platforms that support them. -*/ -char * -find_executable (const char *wrapper) -{ - int has_slash = 0; - const char *p; - const char *p_next; - /* static buffer for getcwd */ - char tmp[LT_PATHMAX + 1]; - int tmp_len; - char *concat_name; - - lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", - nonempty (wrapper)); - - if ((wrapper == NULL) || (*wrapper == '\0')) - return NULL; - - /* Absolute path? */ -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') - { - concat_name = xstrdup (wrapper); - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } - else - { -#endif - if (IS_DIR_SEPARATOR (wrapper[0])) - { - concat_name = xstrdup (wrapper); - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - } -#endif - - for (p = wrapper; *p; p++) - if (*p == '/') - { - has_slash = 1; - break; - } - if (!has_slash) - { - /* no slashes; search PATH */ - const char *path = getenv ("PATH"); - if (path != NULL) - { - for (p = path; *p; p = p_next) - { - const char *q; - size_t p_len; - for (q = p; *q; q++) - if (IS_PATH_SEPARATOR (*q)) - break; - p_len = q - p; - p_next = (*q == '\0' ? q : q + 1); - if (p_len == 0) - { - /* empty path: current directory */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - tmp_len = strlen (tmp); - concat_name = - XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - } - else - { - concat_name = - XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, p, p_len); - concat_name[p_len] = '/'; - strcpy (concat_name + p_len + 1, wrapper); - } - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } - } - /* not found in PATH; assume curdir */ - } - /* Relative path | not found in path: prepend cwd */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - tmp_len = strlen (tmp); - concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - return NULL; -} - -char * -chase_symlinks (const char *pathspec) -{ -#ifndef S_ISLNK - return xstrdup (pathspec); -#else - char buf[LT_PATHMAX]; - struct stat s; - char *tmp_pathspec = xstrdup (pathspec); - char *p; - int has_symlinks = 0; - while (strlen (tmp_pathspec) && !has_symlinks) - { - lt_debugprintf (__FILE__, __LINE__, - "checking path component for symlinks: %s\n", - tmp_pathspec); - if (lstat (tmp_pathspec, &s) == 0) - { - if (S_ISLNK (s.st_mode) != 0) - { - has_symlinks = 1; - break; - } - - /* search backwards for last DIR_SEPARATOR */ - p = tmp_pathspec + strlen (tmp_pathspec) - 1; - while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) - p--; - if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) - { - /* no more DIR_SEPARATORS left */ - break; - } - *p = '\0'; - } - else - { - lt_fatal (__FILE__, __LINE__, - "error accessing file \"%s\": %s", - tmp_pathspec, nonnull (strerror (errno))); - } - } - XFREE (tmp_pathspec); - - if (!has_symlinks) - { - return xstrdup (pathspec); - } - - tmp_pathspec = realpath (pathspec, buf); - if (tmp_pathspec == 0) - { - lt_fatal (__FILE__, __LINE__, - "could not follow symlinks for %s", pathspec); - } - return xstrdup (tmp_pathspec); -#endif -} - -char * -strendzap (char *str, const char *pat) -{ - size_t len, patlen; - - assert (str != NULL); - assert (pat != NULL); - - len = strlen (str); - patlen = strlen (pat); - - if (patlen <= len) - { - str += len - patlen; - if (strcmp (str, pat) == 0) - *str = '\0'; - } - return str; -} - -void -lt_debugprintf (const char *file, int line, const char *fmt, ...) -{ - va_list args; - if (lt_debug) - { - (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); - va_start (args, fmt); - (void) vfprintf (stderr, fmt, args); - va_end (args); - } -} - -static void -lt_error_core (int exit_status, const char *file, - int line, const char *mode, - const char *message, va_list ap) -{ - fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); - vfprintf (stderr, message, ap); - fprintf (stderr, ".\n"); - - if (exit_status >= 0) - exit (exit_status); -} - -void -lt_fatal (const char *file, int line, const char *message, ...) -{ - va_list ap; - va_start (ap, message); - lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); - va_end (ap); -} - -static const char * -nonnull (const char *s) -{ - return s ? s : "(null)"; -} - -static const char * -nonempty (const char *s) -{ - return (s && !*s) ? "(empty)" : nonnull (s); -} - -void -lt_setenv (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_setenv) setting '%s' to '%s'\n", - nonnull (name), nonnull (value)); - { -#ifdef HAVE_SETENV - /* always make a copy, for consistency with !HAVE_SETENV */ - char *str = xstrdup (value); - setenv (name, str, 1); -#else - int len = strlen (name) + 1 + strlen (value) + 1; - char *str = XMALLOC (char, len); - sprintf (str, "%s=%s", name, value); - if (putenv (str) != EXIT_SUCCESS) - { - XFREE (str); - } -#endif - } -} - -char * -lt_extend_str (const char *orig_value, const char *add, int to_end) -{ - char *new_value; - if (orig_value && *orig_value) - { - int orig_value_len = strlen (orig_value); - int add_len = strlen (add); - new_value = XMALLOC (char, add_len + orig_value_len + 1); - if (to_end) - { - strcpy (new_value, orig_value); - strcpy (new_value + orig_value_len, add); - } - else - { - strcpy (new_value, add); - strcpy (new_value + add_len, orig_value); - } - } - else - { - new_value = xstrdup (add); - } - return new_value; -} - -void -lt_update_exe_path (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (value)); - - if (name && *name && value && *value) - { - char *new_value = lt_extend_str (getenv (name), value, 0); - /* some systems can't cope with a ':'-terminated path #' */ - int len = strlen (new_value); - while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) - { - new_value[len-1] = '\0'; - } - lt_setenv (name, new_value); - XFREE (new_value); - } -} - -void -lt_update_lib_path (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (value)); - - if (name && *name && value && *value) - { - char *new_value = lt_extend_str (getenv (name), value, 0); - lt_setenv (name, new_value); - XFREE (new_value); - } -} - -EOF - case $host_os in - mingw*) - cat <<"EOF" - -/* Prepares an argument vector before calling spawn(). - Note that spawn() does not by itself call the command interpreter - (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : - ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&v); - v.dwPlatformId == VER_PLATFORM_WIN32_NT; - }) ? "cmd.exe" : "command.com"). - Instead it simply concatenates the arguments, separated by ' ', and calls - CreateProcess(). We must quote the arguments since Win32 CreateProcess() - interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a - special way: - - Space and tab are interpreted as delimiters. They are not treated as - delimiters if they are surrounded by double quotes: "...". - - Unescaped double quotes are removed from the input. Their only effect is - that within double quotes, space and tab are treated like normal - characters. - - Backslashes not followed by double quotes are not special. - - But 2*n+1 backslashes followed by a double quote become - n backslashes followed by a double quote (n >= 0): - \" -> " - \\\" -> \" - \\\\\" -> \\" - */ -#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -char ** -prepare_spawn (char **argv) -{ - size_t argc; - char **new_argv; - size_t i; - - /* Count number of arguments. */ - for (argc = 0; argv[argc] != NULL; argc++) - ; - - /* Allocate new argument vector. */ - new_argv = XMALLOC (char *, argc + 1); - - /* Put quoted arguments into the new argument vector. */ - for (i = 0; i < argc; i++) - { - const char *string = argv[i]; - - if (string[0] == '\0') - new_argv[i] = xstrdup ("\"\""); - else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) - { - int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); - size_t length; - unsigned int backslashes; - const char *s; - char *quoted_string; - char *p; - - length = 0; - backslashes = 0; - if (quote_around) - length++; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - length += backslashes + 1; - length++; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - length += backslashes + 1; - - quoted_string = XMALLOC (char, length + 1); - - p = quoted_string; - backslashes = 0; - if (quote_around) - *p++ = '"'; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - { - unsigned int j; - for (j = backslashes + 1; j > 0; j--) - *p++ = '\\'; - } - *p++ = c; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - { - unsigned int j; - for (j = backslashes; j > 0; j--) - *p++ = '\\'; - *p++ = '"'; - } - *p = '\0'; - - new_argv[i] = quoted_string; - } - else - new_argv[i] = (char *) string; - } - new_argv[argc] = NULL; - - return new_argv; -} -EOF - ;; - esac - - cat <<"EOF" -void lt_dump_script (FILE* f) -{ -EOF - func_emit_wrapper yes | - $SED -n -e ' -s/^\(.\{79\}\)\(..*\)/\1\ -\2/ -h -s/\([\\"]\)/\\\1/g -s/$/\\n/ -s/\([^\n]*\).*/ fputs ("\1", f);/p -g -D' - cat <<"EOF" -} -EOF -} -# end: func_emit_cwrapperexe_src - -# func_win32_import_lib_p ARG -# True if ARG is an import lib, as indicated by $file_magic_cmd -func_win32_import_lib_p () -{ - $opt_debug - case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in - *import*) : ;; - *) false ;; - esac -} - -# func_mode_link arg... -func_mode_link () -{ - $opt_debug - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - # It is impossible to link a dll without this setting, and - # we shouldn't force the makefile maintainer to figure out - # which system we are compiling for in order to pass an extra - # flag for every libtool invocation. - # allow_undefined=no - - # FIXME: Unfortunately, there are problems with the above when trying - # to make a dll which has undefined symbols, in which case not - # even a static library is built. For now, we need to specify - # -no-undefined on the libtool link line when we can be certain - # that all symbols are satisfied, otherwise we get a static library. - allow_undefined=yes - ;; - *) - allow_undefined=yes - ;; - esac - libtool_args=$nonopt - base_compile="$nonopt $@" - compile_command=$nonopt - finalize_command=$nonopt - - compile_rpath= - finalize_rpath= - compile_shlibpath= - finalize_shlibpath= - convenience= - old_convenience= - deplibs= - old_deplibs= - compiler_flags= - linker_flags= - dllsearchpath= - lib_search_path=`pwd` - inst_prefix_dir= - new_inherited_linker_flags= - - avoid_version=no - bindir= - dlfiles= - dlprefiles= - dlself=no - export_dynamic=no - export_symbols= - export_symbols_regex= - generated= - libobjs= - ltlibs= - module=no - no_install=no - objs= - non_pic_objects= - precious_files_regex= - prefer_static_libs=no - preload=no - prev= - prevarg= - release= - rpath= - xrpath= - perm_rpath= - temp_rpath= - thread_safe=no - vinfo= - vinfo_number=no - weak_libs= - single_module="${wl}-single_module" - func_infer_tag $base_compile - - # We need to know -static, to get the right output filenames. - for arg - do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - break - ;; - -all-static | -static | -static-libtool-libs) - case $arg in - -all-static) - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - func_warning "complete static linking is impossible in this configuration" - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=yes - ;; - -static) - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=built - ;; - -static-libtool-libs) - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=yes - ;; - esac - build_libtool_libs=no - build_old_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test "$#" -gt 0; do - arg="$1" - shift - func_quote_for_eval "$arg" - qarg=$func_quote_for_eval_unquoted_result - func_append libtool_args " $func_quote_for_eval_result" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - func_append compile_command " @OUTPUT@" - func_append finalize_command " @OUTPUT@" - ;; - esac - - case $prev in - bindir) - bindir="$arg" - prev= - continue - ;; - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - func_append compile_command " @SYMFILE@" - func_append finalize_command " @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - func_append dlfiles " $arg" - else - func_append dlprefiles " $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - test -f "$arg" \ - || func_fatal_error "symbol file \`$arg' does not exist" - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - framework) - case $host in - *-*-darwin*) - case "$deplibs " in - *" $qarg.ltframework "*) ;; - *) func_append deplibs " $qarg.ltframework" # this is fixed later - ;; - esac - ;; - esac - prev= - continue - ;; - inst_prefix) - inst_prefix_dir="$arg" - prev= - continue - ;; - objectlist) - if test -f "$arg"; then - save_arg=$arg - moreargs= - for fil in `cat "$save_arg"` - do -# func_append moreargs " $fil" - arg=$fil - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if func_lalib_unsafe_p "$arg"; then - pic_object= - non_pic_object= - - # Read the .lo file - func_source "$arg" - - if test -z "$pic_object" || - test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" - fi - - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - func_append dlfiles " $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - func_append dlprefiles " $pic_object" - prev= - fi - - # A PIC object. - func_append libobjs " $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - func_append non_pic_objects " $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - else - # If the PIC object exists, use it instead. - # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" - func_append non_pic_objects " $non_pic_object" - fi - else - # Only an error if not doing a dry-run. - if $opt_dry_run; then - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - func_lo2o "$arg" - pic_object=$xdir$objdir/$func_lo2o_result - non_pic_object=$xdir$func_lo2o_result - func_append libobjs " $pic_object" - func_append non_pic_objects " $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - done - else - func_fatal_error "link input file \`$arg' does not exist" - fi - arg=$save_arg - prev= - continue - ;; - precious_regex) - precious_files_regex="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) func_append rpath " $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) func_append xrpath " $arg" ;; - esac - fi - prev= - continue - ;; - shrext) - shrext_cmds="$arg" - prev= - continue - ;; - weak) - func_append weak_libs " $arg" - prev= - continue - ;; - xcclinker) - func_append linker_flags " $qarg" - func_append compiler_flags " $qarg" - prev= - func_append compile_command " $qarg" - func_append finalize_command " $qarg" - continue - ;; - xcompiler) - func_append compiler_flags " $qarg" - prev= - func_append compile_command " $qarg" - func_append finalize_command " $qarg" - continue - ;; - xlinker) - func_append linker_flags " $qarg" - func_append compiler_flags " $wl$qarg" - prev= - func_append compile_command " $wl$qarg" - func_append finalize_command " $wl$qarg" - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n "$prev" - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - # See comment for -static flag below, for more details. - func_append compile_command " $link_static_flag" - func_append finalize_command " $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - func_fatal_error "\`-allow-undefined' must not be used because it is the default" - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -bindir) - prev=bindir - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - func_fatal_error "more than one -exported-symbols argument is not allowed" - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - -framework) - prev=framework - continue - ;; - - -inst-prefix-dir) - prev=inst_prefix - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix* | /*-*-irix*) - func_append compile_command " $arg" - func_append finalize_command " $arg" - ;; - esac - continue - ;; - - -L*) - func_stripname "-L" '' "$arg" - if test -z "$func_stripname_result"; then - if test "$#" -gt 0; then - func_fatal_error "require no space between \`-L' and \`$1'" - else - func_fatal_error "need path for \`-L' option" - fi - fi - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - test -z "$absdir" && \ - func_fatal_error "cannot determine absolute directory name of \`$dir'" - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "* | *" $arg "*) - # Will only happen for absolute or sysroot arguments - ;; - *) - # Preserve sysroot, but never include relative directories - case $dir in - [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; - *) func_append deplibs " -L$dir" ;; - esac - func_append lib_search_path " $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$dir:"*) ;; - ::) dllsearchpath=$dir;; - *) func_append dllsearchpath ":$dir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) func_append dllsearchpath ":$testbindir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C and math libraries are in the System framework - func_append deplibs " System.ltframework" - continue - ;; - *-*-sco3.2v5* | *-*-sco5v6*) - # Causes problems with __ctype - test "X$arg" = "X-lc" && continue - ;; - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) - # Compiler inserts libc in the correct place for threads to work - test "X$arg" = "X-lc" && continue - ;; - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - func_append deplibs " $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - # Tru64 UNIX uses -model [arg] to determine the layout of C++ - # classes, name mangling, and exception handling. - # Darwin uses the -arch flag to determine output architecture. - -model|-arch|-isysroot|--sysroot) - func_append compiler_flags " $arg" - func_append compile_command " $arg" - func_append finalize_command " $arg" - prev=xcompiler - continue - ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - func_append compiler_flags " $arg" - func_append compile_command " $arg" - func_append finalize_command " $arg" - case "$new_inherited_linker_flags " in - *" $arg "*) ;; - * ) func_append new_inherited_linker_flags " $arg" ;; - esac - continue - ;; - - -multi_module) - single_module="${wl}-multi_module" - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) - # The PATH hackery in wrapper scripts is required on Windows - # and Darwin in order for the loader to find any dlls it needs. - func_warning "\`-no-install' is ignored for $host" - func_warning "assuming \`-no-fast-install' instead" - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -objectlist) - prev=objectlist - continue - ;; - - -o) prev=output ;; - - -precious-files-regex) - prev=precious_regex - continue - ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - func_stripname '-R' '' "$arg" - dir=$func_stripname_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - =*) - func_stripname '=' '' "$dir" - dir=$lt_sysroot$func_stripname_result - ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) func_append xrpath " $dir" ;; - esac - continue - ;; - - -shared) - # The effects of -shared are defined in a previous loop. - continue - ;; - - -shrext) - prev=shrext - continue - ;; - - -static | -static-libtool-libs) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - - -version-number) - prev=vinfo - vinfo_number=yes - continue - ;; - - -weak) - prev=weak - continue - ;; - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - func_quote_for_eval "$flag" - func_append arg " $func_quote_for_eval_result" - func_append compiler_flags " $func_quote_for_eval_result" - done - IFS="$save_ifs" - func_stripname ' ' '' "$arg" - arg=$func_stripname_result - ;; - - -Wl,*) - func_stripname '-Wl,' '' "$arg" - args=$func_stripname_result - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - func_quote_for_eval "$flag" - func_append arg " $wl$func_quote_for_eval_result" - func_append compiler_flags " $wl$func_quote_for_eval_result" - func_append linker_flags " $func_quote_for_eval_result" - done - IFS="$save_ifs" - func_stripname ' ' '' "$arg" - arg=$func_stripname_result - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - -XCClinker) - prev=xcclinker - continue - ;; - - # -msg_* for osf cc - -msg_*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - # Flags to be passed through unchanged, with rationale: - # -64, -mips[0-9] enable 64-bit mode for the SGI compiler - # -r[0-9][0-9]* specify processor for the SGI compiler - # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler - # +DA*, +DD* enable 64-bit mode for the HP compiler - # -q* compiler args for the IBM compiler - # -m*, -t[45]*, -txscale* architecture-specific flags for GCC - # -F/path path to uninstalled frameworks, gcc on darwin - # -p, -pg, --coverage, -fprofile-* profiling flags for GCC - # @file GCC response files - # -tp=* Portland pgcc target processor selection - # --sysroot=* for sysroot support - # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization - -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ - -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-flto*|-fwhopr*|-fuse-linker-plugin) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - func_append compile_command " $arg" - func_append finalize_command " $arg" - func_append compiler_flags " $arg" - continue - ;; - - # Some other compiler flag. - -* | +*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - *.$objext) - # A standard object. - func_append objs " $arg" - ;; - - *.lo) - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if func_lalib_unsafe_p "$arg"; then - pic_object= - non_pic_object= - - # Read the .lo file - func_source "$arg" - - if test -z "$pic_object" || - test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" - fi - - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - func_append dlfiles " $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - func_append dlprefiles " $pic_object" - prev= - fi - - # A PIC object. - func_append libobjs " $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - func_append non_pic_objects " $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - else - # If the PIC object exists, use it instead. - # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" - func_append non_pic_objects " $non_pic_object" - fi - else - # Only an error if not doing a dry-run. - if $opt_dry_run; then - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - func_lo2o "$arg" - pic_object=$xdir$objdir/$func_lo2o_result - non_pic_object=$xdir$func_lo2o_result - func_append libobjs " $pic_object" - func_append non_pic_objects " $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - ;; - - *.$libext) - # An archive. - func_append deplibs " $arg" - func_append old_deplibs " $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - func_resolve_sysroot "$arg" - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - func_append dlfiles " $func_resolve_sysroot_result" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - func_append dlprefiles " $func_resolve_sysroot_result" - prev= - else - func_append deplibs " $func_resolve_sysroot_result" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - func_append compile_command " $arg" - func_append finalize_command " $arg" - fi - done # argument parsing loop - - test -n "$prev" && \ - func_fatal_help "the \`$prevarg' option requires an argument" - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - func_append compile_command " $arg" - func_append finalize_command " $arg" - fi - - oldlibs= - # calculate the name of the file, without its directory - func_basename "$output" - outputname="$func_basename_result" - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - func_dirname "$output" "/" "" - output_objdir="$func_dirname_result$objdir" - func_to_tool_file "$output_objdir/" - tool_output_objdir=$func_to_tool_file_result - # Create the object directory. - func_mkdir_p "$output_objdir" - - # Determine the type of output - case $output in - "") - func_fatal_help "you must specify an output file" - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - specialdeplibs= - - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - if $opt_preserve_dup_deps ; then - case "$libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append libs " $deplib" - done - - if test "$linkmode" = lib; then - libs="$predeps $libs $compiler_lib_search_path $postdeps" - - # Compute libraries that are listed more than once in $predeps - # $postdeps and mark them as special (i.e., whose duplicates are - # not to be eliminated). - pre_post_deps= - if $opt_duplicate_compiler_generated_deps; then - for pre_post_dep in $predeps $postdeps; do - case "$pre_post_deps " in - *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; - esac - func_append pre_post_deps " $pre_post_dep" - done - fi - pre_post_deps= - fi - - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - - case $linkmode in - lib) - passes="conv dlpreopen link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - - for pass in $passes; do - # The preopen pass in lib mode reverses $deplibs; put it back here - # so that -L comes before libs that need it for instance... - if test "$linkmode,$pass" = "lib,link"; then - ## FIXME: Find the place where the list is rebuilt in the wrong - ## order, and fix it there properly - tmp_deplibs= - for deplib in $deplibs; do - tmp_deplibs="$deplib $tmp_deplibs" - done - deplibs="$tmp_deplibs" - fi - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan"; then - libs="$deplibs" - deplibs= - fi - if test "$linkmode" = prog; then - case $pass in - dlopen) libs="$dlfiles" ;; - dlpreopen) libs="$dlprefiles" ;; - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; - esac - fi - if test "$linkmode,$pass" = "lib,dlpreopen"; then - # Collect and forward deplibs of preopened libtool libs - for lib in $dlprefiles; do - # Ignore non-libtool-libs - dependency_libs= - func_resolve_sysroot "$lib" - case $lib in - *.la) func_source "$func_resolve_sysroot_result" ;; - esac - - # Collect preopened libtool deplibs, except any this library - # has declared as weak libs - for deplib in $dependency_libs; do - func_basename "$deplib" - deplib_base=$func_basename_result - case " $weak_libs " in - *" $deplib_base "*) ;; - *) func_append deplibs " $deplib" ;; - esac - done - done - libs="$dlprefiles" - fi - if test "$pass" = dlopen; then - # Collect dlpreopened libraries - save_deplibs="$deplibs" - deplibs= - fi - - for deplib in $libs; do - lib= - found=no - case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - func_append compiler_flags " $deplib" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) func_append new_inherited_linker_flags " $deplib" ;; - esac - fi - fi - continue - ;; - -l*) - if test "$linkmode" != lib && test "$linkmode" != prog; then - func_warning "\`-l' is ignored for archives/objects" - continue - fi - func_stripname '-l' '' "$deplib" - name=$func_stripname_result - if test "$linkmode" = lib; then - searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" - else - searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" - fi - for searchdir in $searchdirs; do - for search_ext in .la $std_shrext .so .a; do - # Search the libtool library - lib="$searchdir/lib${name}${search_ext}" - if test -f "$lib"; then - if test "$search_ext" = ".la"; then - found=yes - else - found=no - fi - break 2 - fi - done - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - else # deplib is a libtool library - # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, - # We need to do some special things here, and not later. - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $deplib "*) - if func_lalib_p "$lib"; then - library_names= - old_library= - func_source "$lib" - for l in $old_library $library_names; do - ll="$l" - done - if test "X$ll" = "X$old_library" ; then # only static version available - found=no - func_dirname "$lib" "" "." - ladir="$func_dirname_result" - lib=$ladir/$old_library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - fi - ;; - *) ;; - esac - fi - fi - ;; # -l - *.ltframework) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) func_append new_inherited_linker_flags " $deplib" ;; - esac - fi - fi - continue - ;; - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test "$pass" = conv && continue - newdependency_libs="$deplib $newdependency_libs" - func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" - ;; - prog) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test "$pass" = scan; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" - ;; - *) - func_warning "\`-L' is ignored for archives/objects" - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - func_stripname '-R' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) func_append xrpath " $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) - func_resolve_sysroot "$deplib" - lib=$func_resolve_sysroot_result - ;; - *.$libext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - # Linking convenience modules into shared libraries is allowed, - # but linking other static libraries is non-portable. - case " $dlpreconveniencelibs " in - *" $deplib "*) ;; - *) - valid_a_lib=no - case $deplibs_check_method in - match_pattern*) - set dummy $deplibs_check_method; shift - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ - | $EGREP "$match_pattern_regex" > /dev/null; then - valid_a_lib=yes - fi - ;; - pass_all) - valid_a_lib=yes - ;; - esac - if test "$valid_a_lib" != yes; then - echo - $ECHO "*** Warning: Trying to link with static lib archive $deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because the file extensions .$libext of this argument makes me believe" - echo "*** that it is just a static archive that I should not use here." - else - echo - $ECHO "*** Warning: Linking the shared library $output against the" - $ECHO "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - ;; - esac - continue - ;; - prog) - if test "$pass" != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - elif test "$linkmode" = prog; then - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - func_append newdlprefiles " $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - func_append newdlfiles " $deplib" - fi - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - - if test "$found" = yes || test -f "$lib"; then : - else - func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" - fi - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$lib" \ - || func_fatal_error "\`$lib' is not a valid libtool archive" - - func_dirname "$lib" "" "." - ladir="$func_dirname_result" - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - inherited_linker_flags= - # If the library was installed with an old release of libtool, - # it will not redefine variables installed, or shouldnotlink - installed=yes - shouldnotlink=no - avoidtemprpath= - - - # Read the .la file - func_source "$lib" - - # Convert "-framework foo" to "foo.ltframework" - if test -n "$inherited_linker_flags"; then - tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` - for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do - case " $new_inherited_linker_flags " in - *" $tmp_inherited_linker_flag "*) ;; - *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; - esac - done - fi - dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test "$linkmode" != prog && test "$linkmode" != lib; }; then - test -n "$dlopen" && func_append dlfiles " $dlopen" - test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" - fi - - if test "$pass" = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - func_fatal_error "cannot find name of link library for \`$lib'" - fi - # It is a libtool convenience library, so add in its objects. - func_append convenience " $ladir/$objdir/$old_library" - func_append old_convenience " $ladir/$objdir/$old_library" - elif test "$linkmode" != prog && test "$linkmode" != lib; then - func_fatal_error "\`$lib' is not a convenience library" - fi - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append tmp_libs " $deplib" - done - continue - fi # $pass = conv - - - # Get the name of the library we link against. - linklib= - if test -n "$old_library" && - { test "$prefer_static_libs" = yes || - test "$prefer_static_libs,$installed" = "built,no"; }; then - linklib=$old_library - else - for l in $old_library $library_names; do - linklib="$l" - done - fi - if test -z "$linklib"; then - func_fatal_error "cannot find name of link library for \`$lib'" - fi - - # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - func_fatal_error "cannot -dlopen a convenience library: \`$lib'" - fi - if test -z "$dlname" || - test "$dlopen_support" != yes || - test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. We also need to preload any - # dependent libraries so libltdl's deplib preloader doesn't - # bomb out in the load deplibs phase. - func_append dlprefiles " $lib $dependency_libs" - else - func_append newdlfiles " $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - func_warning "cannot determine absolute directory name of \`$ladir'" - func_warning "passing it literally to the linker, although it might fail" - abs_ladir="$ladir" - fi - ;; - esac - func_basename "$lib" - laname="$func_basename_result" - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - #func_warning "library \`$lib' was moved." - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$lt_sysroot$libdir" - absdir="$lt_sysroot$libdir" - fi - test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes - else - if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then - dir="$ladir" - absdir="$abs_ladir" - # Remove this search path later - func_append notinst_path " $abs_ladir" - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - func_append notinst_path " $abs_ladir" - fi - fi # $installed = yes - func_stripname 'lib' '.la' "$laname" - name=$func_stripname_result - - # This library was specified with -dlpreopen. - if test "$pass" = dlpreopen; then - if test -z "$libdir" && test "$linkmode" = prog; then - func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" - fi - case "$host" in - # special handling for platforms with PE-DLLs. - *cygwin* | *mingw* | *cegcc* ) - # Linker will automatically link against shared library if both - # static and shared are present. Therefore, ensure we extract - # symbols from the import library if a shared library is present - # (otherwise, the dlopen module name will be incorrect). We do - # this by putting the import library name into $newdlprefiles. - # We recover the dlopen module name by 'saving' the la file - # name in a special purpose variable, and (later) extracting the - # dlname from the la file. - if test -n "$dlname"; then - func_tr_sh "$dir/$linklib" - eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" - func_append newdlprefiles " $dir/$linklib" - else - func_append newdlprefiles " $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - func_append dlpreconveniencelibs " $dir/$old_library" - fi - ;; - * ) - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - func_append newdlprefiles " $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - func_append dlpreconveniencelibs " $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - func_append newdlprefiles " $dir/$dlname" - else - func_append newdlprefiles " $dir/$linklib" - fi - ;; - esac - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test "$linkmode" = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" # used for prog,scan pass - fi - continue - fi - - - if test "$linkmode" = prog && test "$pass" != link; then - func_append newlib_search_path " $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" - ;; - esac - # Need to link against all dependency_libs? - if test "$linkalldeplibs" = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append tmp_libs " $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - if test "$linkmode,$pass" = "prog,link"; then - if test -n "$library_names" && - { { test "$prefer_static_libs" = no || - test "$prefer_static_libs,$installed" = "built,yes"; } || - test -z "$old_library"; }; then - # We need to hardcode the library path - if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath:" in - *"$absdir:"*) ;; - *) func_append temp_rpath "$absdir:" ;; - esac - fi - - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) func_append compile_rpath " $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - ;; - esac - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - fi - - link_static=no # Whether the deplib will be linked statically - use_static_libs=$prefer_static_libs - if test "$use_static_libs" = built && test "$installed" = yes; then - use_static_libs=no - fi - if test -n "$library_names" && - { test "$use_static_libs" = no || test -z "$old_library"; }; then - case $host in - *cygwin* | *mingw* | *cegcc*) - # No point in relinking DLLs because paths are not encoded - func_append notinst_deplibs " $lib" - need_relink=no - ;; - *) - if test "$installed" = no; then - func_append notinst_deplibs " $lib" - need_relink=yes - fi - ;; - esac - # This is a shared library - - # Warn about portability, can't link against -module's on some - # systems (darwin). Don't bleat about dlopened modules though! - dlopenmodule="" - for dlpremoduletest in $dlprefiles; do - if test "X$dlpremoduletest" = "X$lib"; then - dlopenmodule="$dlpremoduletest" - break - fi - done - if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then - echo - if test "$linkmode" = prog; then - $ECHO "*** Warning: Linking the executable $output against the loadable module" - else - $ECHO "*** Warning: Linking the shared library $output against the loadable module" - fi - $ECHO "*** $linklib is not portable!" - fi - if test "$linkmode" = lib && - test "$hardcode_into_libs" = yes; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) func_append compile_rpath " $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - ;; - esac - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - shift - realname="$1" - shift - libname=`eval "\\$ECHO \"$libname_spec\""` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin* | mingw* | *cegcc*) - func_arith $current - $age - major=$func_arith_result - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - func_basename "$soroot" - soname="$func_basename_result" - func_stripname 'lib' '.dll' "$soname" - newlib=libimp-$func_stripname_result.a - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - func_verbose "extracting exported symbol list from \`$soname'" - func_execute_cmds "$extract_expsyms_cmds" 'exit $?' - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - func_verbose "generating import library for \`$soname'" - func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n "$old_archive_from_expsyms_cmds" - - if test "$linkmode" = prog || test "$opt_mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - case $host in - *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; - *-*-sysv4*uw2*) add_dir="-L$dir" ;; - *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ - *-*-unixware7*) add_dir="-L$dir" ;; - *-*-darwin* ) - # if the lib is a (non-dlopened) module then we can not - # link against it, someone is ignoring the earlier warnings - if /usr/bin/file -L $add 2> /dev/null | - $GREP ": [^:]* bundle" >/dev/null ; then - if test "X$dlopenmodule" != "X$lib"; then - $ECHO "*** Warning: lib $linklib is a module, not a shared library" - if test -z "$old_library" ; then - echo - echo "*** And there doesn't seem to be a static archive available" - echo "*** The link will probably fail, sorry" - else - add="$dir/$old_library" - fi - elif test -n "$old_library"; then - add="$dir/$old_library" - fi - fi - esac - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$absdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - func_append add_dir " -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - func_fatal_configuration "unsupported hardcode properties" - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) func_append compile_shlibpath "$add_shlibpath:" ;; - esac - fi - if test "$linkmode" = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && - test "$hardcode_minus_L" != yes && - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) func_append finalize_shlibpath "$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$opt_mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) func_append finalize_shlibpath "$libdir:" ;; - esac - add="-l$name" - elif test "$hardcode_automatic" = yes; then - if test -n "$inst_prefix_dir" && - test -f "$inst_prefix_dir$libdir/$linklib" ; then - add="$inst_prefix_dir$libdir/$linklib" - else - add="$libdir/$linklib" - fi - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - func_append add_dir " -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - fi - - if test "$linkmode" = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test "$linkmode" = prog; then - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - echo - $ECHO "*** Warning: This system can not link to static lib archive $lib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - echo "*** But as you try to build a module library, libtool will still create " - echo "*** a static module, that should work as long as the dlopening application" - echo "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test "$linkmode" = lib; then - if test -n "$dependency_libs" && - { test "$hardcode_into_libs" != yes || - test "$build_old_libs" = yes || - test "$link_static" = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) func_stripname '-R' '' "$libdir" - temp_xrpath=$func_stripname_result - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) func_append xrpath " $temp_xrpath";; - esac;; - *) func_append temp_deplibs " $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - func_append newlib_search_path " $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result";; - *) func_resolve_sysroot "$deplib" ;; - esac - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $func_resolve_sysroot_result "*) - func_append specialdeplibs " $func_resolve_sysroot_result" ;; - esac - fi - func_append tmp_libs " $func_resolve_sysroot_result" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - path= - case $deplib in - -L*) path="$deplib" ;; - *.la) - func_resolve_sysroot "$deplib" - deplib=$func_resolve_sysroot_result - func_dirname "$deplib" "" "." - dir=$func_dirname_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - func_warning "cannot determine absolute directory name of \`$dir'" - absdir="$dir" - fi - ;; - esac - if $GREP "^installed=no" $deplib > /dev/null; then - case $host in - *-*-darwin*) - depdepl= - eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` - if test -n "$deplibrary_names" ; then - for tmp in $deplibrary_names ; do - depdepl=$tmp - done - if test -f "$absdir/$objdir/$depdepl" ; then - depdepl="$absdir/$objdir/$depdepl" - darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` - if test -z "$darwin_install_name"; then - darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` - fi - func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" - func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" - path= - fi - fi - ;; - *) - path="-L$absdir/$objdir" - ;; - esac - else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - #test "$absdir" != "$libdir" && \ - # func_warning "\`$deplib' seems to be moved" - - path="-L$absdir" - fi - ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$path $deplibs" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - if test "$pass" = link; then - if test "$linkmode" = "prog"; then - compile_deplibs="$new_inherited_linker_flags $compile_deplibs" - finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" - else - compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - fi - fi - dependency_libs="$newdependency_libs" - if test "$pass" = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test "$pass" != dlopen; then - if test "$pass" != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) func_append lib_search_path " $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - # FIXME: Pedantically, this is the right thing to do, so - # that some nasty dependency loop isn't accidentally - # broken: - #new_libs="$deplib $new_libs" - # Pragmatically, this seems to cause very few problems in - # practice: - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - -R*) ;; - *) - # And here is the reason: when a library appears more - # than once as an explicit dependence of a library, or - # is implicitly linked in more than once by the - # compiler, it is considered special, and multiple - # occurrences thereof are not removed. Compare this - # with having the same library being listed as a - # dependency of multiple other libraries: in this case, - # we know (pedantically, we assume) the library does not - # need to be listed more than once, so we keep only the - # last copy. This is not always right, but it is rare - # enough that we require users that really mean to play - # such unportable linking tricks to link the library - # using -Wl,-lname, so that libtool does not consider it - # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) func_append tmp_libs " $deplib" ;; - esac - ;; - *) func_append tmp_libs " $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - # Last step: remove runtime libs from dependency_libs - # (they stay in deplibs) - tmp_libs= - for i in $dependency_libs ; do - case " $predeps $postdeps $compiler_lib_search_path " in - *" $i "*) - i="" - ;; - esac - if test -n "$i" ; then - func_append tmp_libs " $i" - fi - done - dependency_libs=$tmp_libs - done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" - fi - if test "$linkmode" = prog || test "$linkmode" = lib; then - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for archives" - fi - - case " $deplibs" in - *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for archives" ;; - esac - - test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for archives" - - test -n "$xrpath" && \ - func_warning "\`-R' is ignored for archives" - - test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for archives" - - test -n "$release" && \ - func_warning "\`-release' is ignored for archives" - - test -n "$export_symbols$export_symbols_regex" && \ - func_warning "\`-export-symbols' is ignored for archives" - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - func_append objs "$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - func_stripname 'lib' '.la' "$outputname" - name=$func_stripname_result - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - ;; - *) - test "$module" = no && \ - func_fatal_help "libtool library \`$output' must begin with \`lib'" - - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - func_stripname '' '.la' "$outputname" - name=$func_stripname_result - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - else - func_stripname '' '.la' "$outputname" - libname=$func_stripname_result - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" - else - echo - $ECHO "*** Warning: Linking the shared library $output against the non-libtool" - $ECHO "*** objects $objs is not portable!" - func_append libobjs " $objs" - fi - fi - - test "$dlself" != no && \ - func_warning "\`-dlopen self' is ignored for libtool libraries" - - set dummy $rpath - shift - test "$#" -gt 1 && \ - func_warning "ignoring multiple \`-rpath's for a libtool library" - - install_libdir="$1" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - # Some compilers have problems with a `.al' extension so - # convenience libraries should have the same extension an - # archive normally would. - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for convenience libraries" - - test -n "$release" && \ - func_warning "\`-release' is ignored for convenience libraries" - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - shift - IFS="$save_ifs" - - test -n "$7" && \ - func_fatal_help "too many parameters to \`-version-info'" - - # convert absolute version numbers to libtool ages - # this retains compatibility with .la files and attempts - # to make the code below a bit more comprehensible - - case $vinfo_number in - yes) - number_major="$1" - number_minor="$2" - number_revision="$3" - # - # There are really only two kinds -- those that - # use the current revision as the major version - # and those that subtract age and use age as - # a minor version. But, then there is irix - # which has an extra 1 added just for fun - # - case $version_type in - # correct linux to gnu/linux during the next big refactor - darwin|linux|osf|windows|none) - func_arith $number_major + $number_minor - current=$func_arith_result - age="$number_minor" - revision="$number_revision" - ;; - freebsd-aout|freebsd-elf|qnx|sunos) - current="$number_major" - revision="$number_minor" - age="0" - ;; - irix|nonstopux) - func_arith $number_major + $number_minor - current=$func_arith_result - age="$number_minor" - revision="$number_minor" - lt_irix_increment=no - ;; - esac - ;; - no) - current="$1" - revision="$2" - age="$3" - ;; - esac - - # Check that each of the things are valid numbers. - case $current in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "CURRENT \`$current' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - case $revision in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "REVISION \`$revision' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - case $age in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "AGE \`$age' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - if test "$age" -gt "$current"; then - func_error "AGE \`$age' is greater than the current interface number \`$current'" - func_fatal_error "\`$vinfo' is not valid version information" - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - func_arith $current - $age - major=.$func_arith_result - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - func_arith $current + 1 - minor_current=$func_arith_result - xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current" - ;; - - irix | nonstopux) - if test "X$lt_irix_increment" = "Xno"; then - func_arith $current - $age - else - func_arith $current - $age + 1 - fi - major=$func_arith_result - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test "$loop" -ne 0; do - func_arith $revision - $loop - iface=$func_arith_result - func_arith $loop - 1 - loop=$func_arith_result - verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) # correct to gnu/linux during the next big refactor - func_arith $current - $age - major=.$func_arith_result - versuffix="$major.$age.$revision" - ;; - - osf) - func_arith $current - $age - major=.$func_arith_result - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test "$loop" -ne 0; do - func_arith $current - $loop - iface=$func_arith_result - func_arith $loop - 1 - loop=$func_arith_result - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - func_append verstring ":${current}.0" - ;; - - qnx) - major=".$current" - versuffix=".$current" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - func_arith $current - $age - major=$func_arith_result - versuffix="-$major" - ;; - - *) - func_fatal_configuration "unknown library version type \`$version_type'" - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring= - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - func_warning "undefined symbols not allowed in $host shared libraries" - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - - fi - - func_generate_dlsyms "$libname" "$libname" "yes" - func_append libobjs " $symfileobj" - test "X$libobjs" = "X " && libobjs= - - if test "$opt_mode" != relink; then - # Remove our outputs, but don't remove object files since they - # may have been created when compiling PIC objects. - removelist= - tempremovelist=`$ECHO "$output_objdir/*"` - for p in $tempremovelist; do - case $p in - *.$objext | *.gcno) - ;; - $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) - if test "X$precious_files_regex" != "X"; then - if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 - then - continue - fi - fi - func_append removelist " $p" - ;; - *) ;; - esac - done - test -n "$removelist" && \ - func_show_eval "${RM}r \$removelist" - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - func_append oldlibs " $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - #for path in $notinst_path; do - # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` - # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` - # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` - #done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - func_replace_sysroot "$libdir" - func_append temp_xrpath " -R$func_replace_sysroot_result" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - done - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) func_append dlfiles " $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) func_append dlprefiles " $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - func_append deplibs " System.ltframework" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - ;; - *-*-sco3.2v5* | *-*-sco5v6*) - # Causes problems with __ctype - ;; - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) - # Compiler inserts libc in the correct place for threads to work - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then - func_append deplibs " -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behavior. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $opt_dry_run || $RM conftest.c - cat > conftest.c </dev/null` - $nocaseglob - else - potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` - fi - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null | - $GREP " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | - $SED -e 10q | - $EGREP "$file_magic_regex" > /dev/null; then - func_append newdeplibs " $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $ECHO "*** with $libname but no candidates were found. (...for file magic test)" - else - $ECHO "*** with $libname and none of the candidates passed a file format test" - $ECHO "*** using a file magic. Last file checked: $potlib" - fi - fi - ;; - *) - # Add a -L argument. - func_append newdeplibs " $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method; shift - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - for a_deplib in $deplibs; do - case $a_deplib in - -l*) - func_stripname -l '' "$a_deplib" - name=$func_stripname_result - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $a_deplib "*) - func_append newdeplibs " $a_deplib" - a_deplib="" - ;; - esac - fi - if test -n "$a_deplib" ; then - libname=`eval "\\$ECHO \"$libname_spec\""` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check above in file_magic test - if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ - $EGREP "$match_pattern_regex" > /dev/null; then - func_append newdeplibs " $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" - else - $ECHO "*** with $libname and none of the candidates passed a file format test" - $ECHO "*** using a regex pattern. Last file checked: $potlib" - fi - fi - ;; - *) - # Add a -L argument. - func_append newdeplibs " $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - for i in $predeps $postdeps ; do - # can't use Xsed below, because $i might contain '/' - tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` - done - fi - case $tmp_deplibs in - *[!\ \ ]*) - echo - if test "X$deplibs_check_method" = "Xnone"; then - echo "*** Warning: inter-library dependencies are not supported in this platform." - else - echo "*** Warning: inter-library dependencies are not known to be supported." - fi - echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - ;; - esac - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library with the System framework - newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - echo - echo "*** Warning: libtool could not satisfy all declared inter-library" - $ECHO "*** dependencies of module $libname. Therefore, libtool will create" - echo "*** a static module, that should work as long as the dlopening" - echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - echo "*** The inter-library dependencies that have been dropped here will be" - echo "*** automatically added whenever a program is linked with this library" - echo "*** or is declared to -dlopen it." - - if test "$allow_undefined" = no; then - echo - echo "*** Since this library must not contain undefined symbols," - echo "*** because either the platform does not support them or" - echo "*** it was explicitly requested with -no-undefined," - echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - case $host in - *-*-darwin*) - newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - ;; - esac - - # move library search paths that coincide with paths to not yet - # installed libraries to the beginning of the library search list - new_libs= - for path in $notinst_path; do - case " $new_libs " in - *" -L$path/$objdir "*) ;; - *) - case " $deplibs " in - *" -L$path/$objdir "*) - func_append new_libs " -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) func_append new_libs " $deplib" ;; - esac - ;; - *) func_append new_libs " $deplib" ;; - esac - done - deplibs="$new_libs" - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - # Remove ${wl} instances when linking with ld. - # FIXME: should test the right _cmds variable. - case $archive_cmds in - *\$LD\ *) wl= ;; - esac - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$opt_mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - func_replace_sysroot "$libdir" - libdir=$func_replace_sysroot_result - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append dep_rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) func_append perm_rpath " $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - func_append rpath "$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval shared_ext=\"$shrext_cmds\" - eval library_names=\"$library_names_spec\" - set dummy $library_names - shift - realname="$1" - shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - if test -z "$dlname"; then - dlname=$soname - fi - - lib="$output_objdir/$realname" - linknames= - for link - do - func_append linknames " $link" - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` - test "X$libobjs" = "X " && libobjs= - - delfiles= - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" - export_symbols="$output_objdir/$libname.uexp" - func_append delfiles " $export_symbols" - fi - - orig_export_symbols= - case $host_os in - cygwin* | mingw* | cegcc*) - if test -n "$export_symbols" && test -z "$export_symbols_regex"; then - # exporting using user supplied symfile - if test "x`$SED 1q $export_symbols`" != xEXPORTS; then - # and it's NOT already a .def file. Must figure out - # which of the given symbols are data symbols and tag - # them as such. So, trigger use of export_symbols_cmds. - # export_symbols gets reassigned inside the "prepare - # the list of exported symbols" if statement, so the - # include_expsyms logic still works. - orig_export_symbols="$export_symbols" - export_symbols= - always_export_symbols=yes - fi - fi - ;; - esac - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $opt_dry_run || $RM $export_symbols - cmds=$export_symbols_cmds - save_ifs="$IFS"; IFS='~' - for cmd1 in $cmds; do - IFS="$save_ifs" - # Take the normal branch if the nm_file_list_spec branch - # doesn't work or if tool conversion is not needed. - case $nm_file_list_spec~$to_tool_file_cmd in - *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) - try_normal_branch=yes - eval cmd=\"$cmd1\" - func_len " $cmd" - len=$func_len_result - ;; - *) - try_normal_branch=no - ;; - esac - if test "$try_normal_branch" = yes \ - && { test "$len" -lt "$max_cmd_len" \ - || test "$max_cmd_len" -le -1; } - then - func_show_eval "$cmd" 'exit $?' - skipped_export=false - elif test -n "$nm_file_list_spec"; then - func_basename "$output" - output_la=$func_basename_result - save_libobjs=$libobjs - save_output=$output - output=${output_objdir}/${output_la}.nm - func_to_tool_file "$output" - libobjs=$nm_file_list_spec$func_to_tool_file_result - func_append delfiles " $output" - func_verbose "creating $NM input file list: $output" - for obj in $save_libobjs; do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > "$output" - eval cmd=\"$cmd1\" - func_show_eval "$cmd" 'exit $?' - output=$save_output - libobjs=$save_libobjs - skipped_export=false - else - # The command line is too long to execute in one step. - func_verbose "using reloadable object file for export list..." - skipped_export=: - # Break out early, otherwise skipped_export may be - # set to false by a later but shorter cmd. - break - fi - done - IFS="$save_ifs" - if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' - fi - - if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then - # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" - # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine - # though. Also, the filter scales superlinearly with the number of - # global variables. join(1) would be nice here, but unfortunately - # isn't a blessed tool. - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - func_append delfiles " $export_symbols $output_objdir/$libname.filter" - export_symbols=$output_objdir/$libname.def - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols - fi - - tmp_deplibs= - for test_deplib in $deplibs; do - case " $convenience " in - *" $test_deplib "*) ;; - *) - func_append tmp_deplibs " $test_deplib" - ;; - esac - done - deplibs="$tmp_deplibs" - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec" && - test "$compiler_needs_object" = yes && - test -z "$libobjs"; then - # extract the archives, so we have objects to list. - # TODO: could optimize this to just extract one archive. - whole_archive_flag_spec= - fi - if test -n "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - test "X$libobjs" = "X " && libobjs= - else - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $convenience - func_append libobjs " $func_extract_archives_result" - test "X$libobjs" = "X " && libobjs= - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - func_append linker_flags " $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$opt_mode" = relink; then - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - eval test_cmds=\"$module_expsym_cmds\" - cmds=$module_expsym_cmds - else - eval test_cmds=\"$module_cmds\" - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval test_cmds=\"$archive_expsym_cmds\" - cmds=$archive_expsym_cmds - else - eval test_cmds=\"$archive_cmds\" - cmds=$archive_cmds - fi - fi - - if test "X$skipped_export" != "X:" && - func_len " $test_cmds" && - len=$func_len_result && - test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - : - else - # The command line is too long to link in one step, link piecewise - # or, if using GNU ld and skipped_export is not :, use a linker - # script. - - # Save the value of $output and $libobjs because we want to - # use them later. If we have whole_archive_flag_spec, we - # want to use save_libobjs as it was before - # whole_archive_flag_spec was expanded, because we can't - # assume the linker understands whole_archive_flag_spec. - # This may have to be revisited, in case too many - # convenience libraries get linked in and end up exceeding - # the spec. - if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - fi - save_output=$output - func_basename "$output" - output_la=$func_basename_result - - # Clear the reloadable object creation command queue and - # initialize k to one. - test_cmds= - concat_cmds= - objlist= - last_robj= - k=1 - - if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then - output=${output_objdir}/${output_la}.lnkscript - func_verbose "creating GNU ld script: $output" - echo 'INPUT (' > $output - for obj in $save_libobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - echo ')' >> $output - func_append delfiles " $output" - func_to_tool_file "$output" - output=$func_to_tool_file_result - elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then - output=${output_objdir}/${output_la}.lnk - func_verbose "creating linker input file list: $output" - : > $output - set x $save_libobjs - shift - firstobj= - if test "$compiler_needs_object" = yes; then - firstobj="$1 " - shift - fi - for obj - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - func_append delfiles " $output" - func_to_tool_file "$output" - output=$firstobj\"$file_list_spec$func_to_tool_file_result\" - else - if test -n "$save_libobjs"; then - func_verbose "creating reloadable object files..." - output=$output_objdir/$output_la-${k}.$objext - eval test_cmds=\"$reload_cmds\" - func_len " $test_cmds" - len0=$func_len_result - len=$len0 - - # Loop over the list of objects to be linked. - for obj in $save_libobjs - do - func_len " $obj" - func_arith $len + $func_len_result - len=$func_arith_result - if test "X$objlist" = X || - test "$len" -lt "$max_cmd_len"; then - func_append objlist " $obj" - else - # The command $test_cmds is almost too long, add a - # command to the queue. - if test "$k" -eq 1 ; then - # The first file doesn't have a previous command to add. - reload_objs=$objlist - eval concat_cmds=\"$reload_cmds\" - else - # All subsequent reloadable object files will link in - # the last one created. - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" - fi - last_robj=$output_objdir/$output_la-${k}.$objext - func_arith $k + 1 - k=$func_arith_result - output=$output_objdir/$output_la-${k}.$objext - objlist=" $obj" - func_len " $last_robj" - func_arith $len0 + $func_len_result - len=$func_arith_result - fi - done - # Handle the remaining objects by creating one last - # reloadable object file. All subsequent reloadable object - # files will link in the last one created. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\${concat_cmds}$reload_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" - fi - func_append delfiles " $output" - - else - output= - fi - - if ${skipped_export-false}; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $opt_dry_run || $RM $export_symbols - libobjs=$output - # Append the command to create the export file. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" - fi - fi - - test -n "$save_libobjs" && - func_verbose "creating a temporary reloadable object file: $output" - - # Loop through the commands generated above and execute them. - save_ifs="$IFS"; IFS='~' - for cmd in $concat_cmds; do - IFS="$save_ifs" - $opt_silent || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" - } - $opt_dry_run || eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - ( cd "$output_objdir" && \ - $RM "${realname}T" && \ - $MV "${realname}U" "$realname" ) - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - if test -n "$export_symbols_regex" && ${skipped_export-false}; then - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' - fi - fi - - if ${skipped_export-false}; then - if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' - fi - - if test -n "$orig_export_symbols"; then - # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" - # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine - # though. Also, the filter scales superlinearly with the number of - # global variables. join(1) would be nice here, but unfortunately - # isn't a blessed tool. - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - func_append delfiles " $export_symbols $output_objdir/$libname.filter" - export_symbols=$output_objdir/$libname.def - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols - fi - fi - - libobjs=$output - # Restore the value of output. - output=$save_output - - if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - test "X$libobjs" = "X " && libobjs= - fi - # Expand the library linking commands again to reset the - # value of $libobjs for piecewise linking. - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - cmds=$module_expsym_cmds - else - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - cmds=$archive_expsym_cmds - else - cmds=$archive_cmds - fi - fi - fi - - if test -n "$delfiles"; then - # Append the command to remove temporary files to $cmds. - eval cmds=\"\$cmds~\$RM $delfiles\" - fi - - # Add any objects from preloaded convenience libraries - if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $dlprefiles - func_append libobjs " $func_extract_archives_result" - test "X$libobjs" = "X " && libobjs= - fi - - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $opt_silent || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" - } - $opt_dry_run || eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - ( cd "$output_objdir" && \ - $RM "${realname}T" && \ - $MV "${realname}U" "$realname" ) - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? - - if test -n "$convenience"; then - if test -z "$whole_archive_flag_spec"; then - func_show_eval '${RM}r "$gentop"' - fi - fi - - exit $EXIT_SUCCESS - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for objects" - fi - - case " $deplibs" in - *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for objects" ;; - esac - - test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for objects" - - test -n "$xrpath" && \ - func_warning "\`-R' is ignored for objects" - - test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for objects" - - test -n "$release" && \ - func_warning "\`-release' is ignored for objects" - - case $output in - *.lo) - test -n "$objs$old_deplibs" && \ - func_fatal_error "cannot build library object \`$output' from non-libtool objects" - - libobj=$output - func_lo2o "$libobj" - obj=$func_lo2o_result - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $opt_dry_run || $RM $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec and hope we can get by with - # turning comma into space.. - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" - reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` - else - gentop="$output_objdir/${obj}x" - func_append generated " $gentop" - - func_extract_archives $gentop $convenience - reload_conv_objs="$reload_objs $func_extract_archives_result" - fi - fi - - # If we're not building shared, we need to use non_pic_objs - test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - func_execute_cmds "$reload_cmds" 'exit $?' - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - exit $EXIT_SUCCESS - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - # $show "echo timestamp > $libobj" - # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? - exit $EXIT_SUCCESS - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - func_execute_cmds "$reload_cmds" 'exit $?' - fi - - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - exit $EXIT_SUCCESS - ;; - - prog) - case $host in - *cygwin*) func_stripname '' '.exe' "$output" - output=$func_stripname_result.exe;; - esac - test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for programs" - - test -n "$release" && \ - func_warning "\`-release' is ignored for programs" - - test "$preload" = yes \ - && test "$dlopen_support" = unknown \ - && test "$dlopen_self" = unknown \ - && test "$dlopen_self_static" = unknown && \ - func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` - ;; - esac - - case $host in - *-*-darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - # But is supposedly fixed on 10.4 or later (yay!). - if test "$tagname" = CXX ; then - case ${MACOSX_DEPLOYMENT_TARGET-10.0} in - 10.[0123]) - func_append compile_command " ${wl}-bind_at_load" - func_append finalize_command " ${wl}-bind_at_load" - ;; - esac - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - ;; - esac - - - # move library search paths that coincide with paths to not yet - # installed libraries to the beginning of the library search list - new_libs= - for path in $notinst_path; do - case " $new_libs " in - *" -L$path/$objdir "*) ;; - *) - case " $compile_deplibs " in - *" -L$path/$objdir "*) - func_append new_libs " -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $compile_deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) func_append new_libs " $deplib" ;; - esac - ;; - *) func_append new_libs " $deplib" ;; - esac - done - compile_deplibs="$new_libs" - - - func_append compile_command " $compile_deplibs" - func_append finalize_command " $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) func_append perm_rpath " $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$libdir:"*) ;; - ::) dllsearchpath=$libdir;; - *) func_append dllsearchpath ":$libdir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) func_append dllsearchpath ":$testbindir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) func_append finalize_perm_rpath " $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - fi - - func_generate_dlsyms "$outputname" "@PROGRAM@" "no" - - # template prelinking step - if test -n "$prelink_cmds"; then - func_execute_cmds "$prelink_cmds" 'exit $?' - fi - - wrappers_required=yes - case $host in - *cegcc* | *mingw32ce*) - # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. - wrappers_required=no - ;; - *cygwin* | *mingw* ) - if test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - *) - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - esac - if test "$wrappers_required" = no; then - # Replace the output file specification. - compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - exit_status=0 - func_show_eval "$link_command" 'exit_status=$?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # Delete the generated files. - if test -f "$output_objdir/${outputname}S.${objext}"; then - func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' - fi - - exit $exit_status - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - func_append rpath "$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - func_append rpath "$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $opt_dry_run || $RM $output - # Link the executable and exit - func_show_eval "$link_command" 'exit $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - exit $EXIT_SUCCESS - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - func_warning "this platform does not like uninstalled shared libraries" - func_warning "\`$output' will be relinked during installation" - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname - - func_show_eval "$link_command" 'exit $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output_objdir/$outputname" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # Now create the wrapper script. - func_verbose "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` - fi - - # Only actually do things if not in dry run mode. - $opt_dry_run || { - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) func_stripname '' '.exe' "$output" - output=$func_stripname_result ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) - exeext=.exe - func_stripname '' '.exe' "$outputname" - outputname=$func_stripname_result ;; - *) exeext= ;; - esac - case $host in - *cygwin* | *mingw* ) - func_dirname_and_basename "$output" "" "." - output_name=$func_basename_result - output_path=$func_dirname_result - cwrappersource="$output_path/$objdir/lt-$output_name.c" - cwrapper="$output_path/$output_name.exe" - $RM $cwrappersource $cwrapper - trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 - - func_emit_cwrapperexe_src > $cwrappersource - - # The wrapper executable is built using the $host compiler, - # because it contains $host paths and files. If cross- - # compiling, it, like the target executable, must be - # executed on the $host or under an emulation environment. - $opt_dry_run || { - $LTCC $LTCFLAGS -o $cwrapper $cwrappersource - $STRIP $cwrapper - } - - # Now, create the wrapper script for func_source use: - func_ltwrapper_scriptname $cwrapper - $RM $func_ltwrapper_scriptname_result - trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 - $opt_dry_run || { - # note: this script will not be executed, so do not chmod. - if test "x$build" = "x$host" ; then - $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result - else - func_emit_wrapper no > $func_ltwrapper_scriptname_result - fi - } - ;; - * ) - $RM $output - trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 - - func_emit_wrapper no > $output - chmod +x $output - ;; - esac - } - exit $EXIT_SUCCESS - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save $symfileobj" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$old_deplibs $non_pic_objects" - if test "$preload" = yes && test -f "$symfileobj"; then - func_append oldobjs " $symfileobj" - fi - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $addlibs - func_append oldobjs " $func_extract_archives_result" - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - cmds=$old_archive_from_new_cmds - else - - # Add any objects from preloaded convenience libraries - if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $dlprefiles - func_append oldobjs " $func_extract_archives_result" - fi - - # POSIX demands no paths to be encoded in archives. We have - # to avoid creating archives with duplicate basenames if we - # might have to extract them afterwards, e.g., when creating a - # static archive out of a convenience library, or when linking - # the entirety of a libtool archive into another (currently - # not supported by libtool). - if (for obj in $oldobjs - do - func_basename "$obj" - $ECHO "$func_basename_result" - done | sort | sort -uc >/dev/null 2>&1); then - : - else - echo "copying selected object files to avoid basename conflicts..." - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - func_mkdir_p "$gentop" - save_oldobjs=$oldobjs - oldobjs= - counter=1 - for obj in $save_oldobjs - do - func_basename "$obj" - objbase="$func_basename_result" - case " $oldobjs " in - " ") oldobjs=$obj ;; - *[\ /]"$objbase "*) - while :; do - # Make sure we don't pick an alternate name that also - # overlaps. - newobj=lt$counter-$objbase - func_arith $counter + 1 - counter=$func_arith_result - case " $oldobjs " in - *[\ /]"$newobj "*) ;; - *) if test ! -f "$gentop/$newobj"; then break; fi ;; - esac - done - func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" - func_append oldobjs " $gentop/$newobj" - ;; - *) func_append oldobjs " $obj" ;; - esac - done - fi - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - eval cmds=\"$old_archive_cmds\" - - func_len " $cmds" - len=$func_len_result - if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - cmds=$old_archive_cmds - elif test -n "$archiver_list_spec"; then - func_verbose "using command file archive linking..." - for obj in $oldobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > $output_objdir/$libname.libcmd - func_to_tool_file "$output_objdir/$libname.libcmd" - oldobjs=" $archiver_list_spec$func_to_tool_file_result" - cmds=$old_archive_cmds - else - # the command line is too long to link in one step, link in parts - func_verbose "using piecewise archive linking..." - save_RANLIB=$RANLIB - RANLIB=: - objlist= - concat_cmds= - save_oldobjs=$oldobjs - oldobjs= - # Is there a better way of finding the last object in the list? - for obj in $save_oldobjs - do - last_oldobj=$obj - done - eval test_cmds=\"$old_archive_cmds\" - func_len " $test_cmds" - len0=$func_len_result - len=$len0 - for obj in $save_oldobjs - do - func_len " $obj" - func_arith $len + $func_len_result - len=$func_arith_result - func_append objlist " $obj" - if test "$len" -lt "$max_cmd_len"; then - : - else - # the above command should be used before it gets too long - oldobjs=$objlist - if test "$obj" = "$last_oldobj" ; then - RANLIB=$save_RANLIB - fi - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" - objlist= - len=$len0 - fi - done - RANLIB=$save_RANLIB - oldobjs=$objlist - if test "X$oldobjs" = "X" ; then - eval cmds=\"\$concat_cmds\" - else - eval cmds=\"\$concat_cmds~\$old_archive_cmds\" - fi - fi - fi - func_execute_cmds "$cmds" 'exit $?' - done - - test -n "$generated" && \ - func_show_eval "${RM}r$generated" - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - func_verbose "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` - if test "$hardcode_automatic" = yes ; then - relink_command= - fi - - # Only create the output if not a dry run. - $opt_dry_run || { - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - func_basename "$deplib" - name="$func_basename_result" - func_resolve_sysroot "$deplib" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" - ;; - -L*) - func_stripname -L '' "$deplib" - func_replace_sysroot "$func_stripname_result" - func_append newdependency_libs " -L$func_replace_sysroot_result" - ;; - -R*) - func_stripname -R '' "$deplib" - func_replace_sysroot "$func_stripname_result" - func_append newdependency_libs " -R$func_replace_sysroot_result" - ;; - *) func_append newdependency_libs " $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - - for lib in $dlfiles; do - case $lib in - *.la) - func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" - func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" - ;; - *) func_append newdlfiles " $lib" ;; - esac - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - *.la) - # Only pass preopened files to the pseudo-archive (for - # eventual linking with the app. that links it) if we - # didn't already link the preopened objects directly into - # the library: - func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" - func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" - ;; - esac - done - dlprefiles="$newdlprefiles" - else - newdlfiles= - for lib in $dlfiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - func_append newdlfiles " $abs" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - func_append newdlprefiles " $abs" - done - dlprefiles="$newdlprefiles" - fi - $RM $output - # place dlname in correct position for cygwin - # In fact, it would be nice if we could use this code for all target - # systems that can't hard-code library paths into their executables - # and that have no shared library path variable independent of PATH, - # but it turns out we can't easily determine that from inspecting - # libtool variables, so we have to hard-code the OSs to which it - # applies here; at the moment, that means platforms that use the PE - # object format with DLL files. See the long comment at the top of - # tests/bindir.at for full details. - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) - # If a -bindir argument was supplied, place the dll there. - if test "x$bindir" != x ; - then - func_relative_path "$install_libdir" "$bindir" - tdlname=$func_relative_path_result$dlname - else - # Otherwise fall back on heuristic. - tdlname=../bin/$dlname - fi - ;; - esac - $ECHO > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Linker flags that can not go in dependency_libs. -inherited_linker_flags='$new_inherited_linker_flags' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Names of additional weak libraries provided by this library -weak_library_names='$weak_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Should we warn about portability when linking against -modules? -shouldnotlink=$module - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test "$need_relink" = yes; then - $ECHO >> $output "\ -relink_command=\"$relink_command\"" - fi - done - } - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' - ;; - esac - exit $EXIT_SUCCESS -} - -{ test "$opt_mode" = link || test "$opt_mode" = relink; } && - func_mode_link ${1+"$@"} - - -# func_mode_uninstall arg... -func_mode_uninstall () -{ - $opt_debug - RM="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) func_append RM " $arg"; rmforce=yes ;; - -*) func_append RM " $arg" ;; - *) func_append files " $arg" ;; - esac - done - - test -z "$RM" && \ - func_fatal_help "you must specify an RM program" - - rmdirs= - - for file in $files; do - func_dirname "$file" "" "." - dir="$func_dirname_result" - if test "X$dir" = X.; then - odir="$objdir" - else - odir="$dir/$objdir" - fi - func_basename "$file" - name="$func_basename_result" - test "$opt_mode" = uninstall && odir="$dir" - - # Remember odir for removal later, being careful to avoid duplicates - if test "$opt_mode" = clean; then - case " $rmdirs " in - *" $odir "*) ;; - *) func_append rmdirs " $odir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if { test -L "$file"; } >/dev/null 2>&1 || - { test -h "$file"; } >/dev/null 2>&1 || - test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if func_lalib_p "$file"; then - func_source $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - func_append rmfiles " $odir/$n" - done - test -n "$old_library" && func_append rmfiles " $odir/$old_library" - - case "$opt_mode" in - clean) - case " $library_names " in - *" $dlname "*) ;; - *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; - esac - test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" - ;; - uninstall) - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' - fi - # FIXME: should reinstall the best remaining shared library. - ;; - esac - fi - ;; - - *.lo) - # Possibly a libtool object, so verify it. - if func_lalib_p "$file"; then - - # Read the .lo file - func_source $dir/$name - - # Add PIC object to the list of files to remove. - if test -n "$pic_object" && - test "$pic_object" != none; then - func_append rmfiles " $dir/$pic_object" - fi - - # Add non-PIC object to the list of files to remove. - if test -n "$non_pic_object" && - test "$non_pic_object" != none; then - func_append rmfiles " $dir/$non_pic_object" - fi - fi - ;; - - *) - if test "$opt_mode" = clean ; then - noexename=$name - case $file in - *.exe) - func_stripname '' '.exe' "$file" - file=$func_stripname_result - func_stripname '' '.exe' "$name" - noexename=$func_stripname_result - # $file with .exe has already been added to rmfiles, - # add $file without .exe - func_append rmfiles " $file" - ;; - esac - # Do a test to see if this is a libtool program. - if func_ltwrapper_p "$file"; then - if func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - relink_command= - func_source $func_ltwrapper_scriptname_result - func_append rmfiles " $func_ltwrapper_scriptname_result" - else - relink_command= - func_source $dir/$noexename - fi - - # note $name still contains .exe if it was in $file originally - # as does the version of $file that was added into $rmfiles - func_append rmfiles " $odir/$name $odir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - func_append rmfiles " $odir/lt-$name" - fi - if test "X$noexename" != "X$name" ; then - func_append rmfiles " $odir/lt-${noexename}.c" - fi - fi - fi - ;; - esac - func_show_eval "$RM $rmfiles" 'exit_status=1' - done - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - func_show_eval "rmdir $dir >/dev/null 2>&1" - fi - done - - exit $exit_status -} - -{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && - func_mode_uninstall ${1+"$@"} - -test -z "$opt_mode" && { - help="$generic_help" - func_fatal_help "you must specify a MODE" -} - -test -z "$exec_cmd" && \ - func_fatal_help "invalid operation mode \`$opt_mode'" - -if test -n "$exec_cmd"; then - eval exec "$exec_cmd" - exit $EXIT_FAILURE -fi - -exit $exit_status - - -# The TAGs below are defined such that we never get into a situation -# in which we disable both kinds of libraries. Given conflicting -# choices, we go for a static library, that is the most portable, -# since we can't tell whether shared libraries were disabled because -# the user asked for that or because the platform doesn't support -# them. This is particularly important on AIX, because we don't -# support having both static and shared libraries enabled at the same -# time on that platform, so we default to a shared-only configuration. -# If a disable-shared tag is given, we'll fallback to a static-only -# configuration. But we'll never go from static-only to shared-only. - -# ### BEGIN LIBTOOL TAG CONFIG: disable-shared -build_libtool_libs=no -build_old_libs=yes -# ### END LIBTOOL TAG CONFIG: disable-shared - -# ### BEGIN LIBTOOL TAG CONFIG: disable-static -build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` -# ### END LIBTOOL TAG CONFIG: disable-static - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: -# vi:sw=2 - diff --git a/autoconf/missing b/autoconf/missing deleted file mode 100755 index 86a8fc31e3..0000000000 --- a/autoconf/missing +++ /dev/null @@ -1,331 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. - -scriptversion=2012-01-06.13; # UTC - -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, -# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" - -case $1 in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - yacc create \`y.tab.[ch]', if possible, from existing .[ch] - -Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and -\`g' are ignored when checking the name. - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - -esac - -# normalize program name to check for. -program=`echo "$1" | sed ' - s/^gnu-//; t - s/^gnu//; t - s/^g//; t'` - -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). This is about non-GNU programs, so use $1 not -# $program. -case $1 in - lex*|yacc*) - # Not GNU programs, they don't have --version. - ;; - - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case $program in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case $f in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te*) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison*|yacc*) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if test $# -ne 1; then - eval LASTARG=\${$#} - case $LASTARG in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if test ! -f y.tab.h; then - echo >y.tab.h - fi - if test ! -f y.tab.c; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex*|flex*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if test $# -ne 1; then - eval LASTARG=\${$#} - case $LASTARG in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if test ! -f lex.yy.c; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit $? - fi - ;; - - makeinfo*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/manifest b/manifest index 047afbbc2e..efae6ad270 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_OMIT_PARSER_TRACE\scompile-time\soption. -D 2015-12-15T13:50:22.827 +C Update\sthe\smkautoconfamal.sh\sscript\sto\smake\sthe\sbuilding\sof\sthe\ssqlite3-autoconf-VERSION.tar.gz\spackage\smore\sorthodox. +D 2015-12-15T19:32:12.783 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -13,13 +13,7 @@ F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am 089e5ecdb5761e64ea1013ded02feb4d8b29927d F autoconf/README 14458f1046c118efa721aadec5f227e876d3cd38 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 -F autoconf/config.guess 94cc57e2a3fdb9c235b362ace86d77e89d188cad x -F autoconf/config.sub 1efb390a8fb4bfafd74783a15a8fb5311c84300e x -F autoconf/configure.ac 9a65da17e440466f9842288163f16f9b21298129 -F autoconf/depcomp 0b26f101e3bc9fd1ff0be1da9fb4a82371142f92 x -F autoconf/install-sh 06ee6336e63bb845c8439d777c32eb2eccc4fbf1 x -F autoconf/ltmain.sh 7a658a24028f02331c1d2446562758083c5eadd1 -F autoconf/missing d7c9981a81af13370d4ed152b24c0a82b7028585 x +F autoconf/configure.ac 82c628c68f0f204d57343dc345b6dbd1789fb1bd F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -1367,7 +1361,7 @@ F tool/lemon.c 799e73e19a33b8dd7767a7fa34618ed2a9c2397d F tool/lempar.c 3ec1463a034b37d87d782be5f6b8b10a3b1ecbe7 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c eef612f8adf4d0993dafed0416064cf50d5d33c6 -F tool/mkautoconfamal.sh 4bdf61548a143e5977bd86ab93d68b694d10c8fa +F tool/mkautoconfamal.sh 5a5441280b509d2bb3bdc71bfb63781b0d570373 F tool/mkkeywordhash.c 06ec0b78bd4fa68c12d90ef2bdfe76b039133ff8 F tool/mkopcodec.tcl edde8adc42621b5e598127f8cdc6d52cfe21f52b F tool/mkopcodeh.tcl e04177031532b7aa9379ded50e820231ac4abd6e @@ -1410,7 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1a24791109da607d502ac41f179fe6c1dc46c774 -R 2ba25094d2a2e5d1dff8c5d58f82b94b -U drh -Z de456f26b0f5cdabd2ebff5ccc5fcbaf +P 2fda43e6e097a4a5510cce7784c31ceedc3d6e6d +R 2c1a16b79c40a6fe71483b1b5fbca8f8 +U dan +Z ec87a5f2f4b0ee8998a460274f87b17f diff --git a/manifest.uuid b/manifest.uuid index e4491ed0af..2cc60c5945 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2fda43e6e097a4a5510cce7784c31ceedc3d6e6d \ No newline at end of file +1928f8945b7cdf733129619b7ab02d1addf63478 \ No newline at end of file diff --git a/tool/mkautoconfamal.sh b/tool/mkautoconfamal.sh index d78d681816..9f44152e36 100644 --- a/tool/mkautoconfamal.sh +++ b/tool/mkautoconfamal.sh @@ -43,20 +43,16 @@ cp $TOP/sqlite3.1 $TMPSPACE cp $TOP/sqlite3.pc.in $TMPSPACE cp $TOP/src/shell.c $TMPSPACE -chmod 755 $TMPSPACE/install-sh -chmod 755 $TMPSPACE/missing -chmod 755 $TMPSPACE/depcomp -chmod 755 $TMPSPACE/config.sub -chmod 755 $TMPSPACE/config.guess - cat $TMPSPACE/configure.ac | -sed "s/AC_INIT(sqlite, .*, http:\/\/www.sqlite.org)/AC_INIT(sqlite, $VERSION, http:\/\/www.sqlite.org)/" > $TMPSPACE/tmp +sed "s/--SQLITE-VERSION--/$VERSION/" > $TMPSPACE/tmp mv $TMPSPACE/tmp $TMPSPACE/configure.ac cd $TMPSPACE -aclocal -autoconf -automake --add-missing +autoreconf -i +#libtoolize +#aclocal +#autoconf +#automake --add-missing mkdir -p tea/generic echo "#ifdef USE_SYSTEM_SQLITE" > tea/generic/tclsqlite3.c From 8b0ba7b0b86a3c629e2c1f5c978e1829c7f3a59f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 16 Dec 2015 13:07:35 +0000 Subject: [PATCH 090/232] Make greater use of the SQLITE_WITHIN macro. FossilOrigin-Name: f2fc3aede55c8fa0351697f9f5ce4e544334c9af --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/btree.c | 4 ++-- src/pcache1.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index efae6ad270..249e331ec1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\smkautoconfamal.sh\sscript\sto\smake\sthe\sbuilding\sof\sthe\ssqlite3-autoconf-VERSION.tar.gz\spackage\smore\sorthodox. -D 2015-12-15T19:32:12.783 +C Make\sgreater\suse\sof\sthe\sSQLITE_WITHIN\smacro. +D 2015-12-16T13:07:35.753 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -276,7 +276,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 450950ce366159c3215736ae43d1062e7c06f741 +F src/btree.c 84ede51e371a11c3dbb3e24ccc5e3e99594a6c00 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b @@ -325,7 +325,7 @@ F src/pager.h bf25005b4656cd805af43487c3139fca9678d0cc F src/parse.y 23737e649c26ce327603799e57f5c2ff50e5e6ba F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 F src/pcache.h 1ff11adce609ba7de139b6abfabaf9a2bac947b5 -F src/pcache1.c 46a110be31a8d9f9b41431733836822ca0dd27ab +F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051 F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 @@ -1404,7 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2fda43e6e097a4a5510cce7784c31ceedc3d6e6d -R 2c1a16b79c40a6fe71483b1b5fbca8f8 -U dan -Z ec87a5f2f4b0ee8998a460274f87b17f +P 1928f8945b7cdf733129619b7ab02d1addf63478 +R 66e8a449a1ea9e4af724bc52e4baa50a +U drh +Z dcd4ad4bd65fd6c947db9b3e37840361 diff --git a/manifest.uuid b/manifest.uuid index 2cc60c5945..d77b5aa4be 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1928f8945b7cdf733129619b7ab02d1addf63478 \ No newline at end of file +f2fc3aede55c8fa0351697f9f5ce4e544334c9af \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 1f279b55f6..4e384e2c4f 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6470,7 +6470,7 @@ static int rebuildPage( pData = pEnd; for(i=0; iaData && pCellapCell[i]; - if( pCell>=pStart && pCell=pcache1.pStart && p Date: Wed, 16 Dec 2015 21:09:53 +0000 Subject: [PATCH 091/232] Fix compiler warning seen with MSVC. FossilOrigin-Name: 18a4c0540bf4f02335e9e9def1f2b0d4d784ef08 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/vdbe.c | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 249e331ec1..a6a443ee80 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sgreater\suse\sof\sthe\sSQLITE_WITHIN\smacro. -D 2015-12-16T13:07:35.753 +C Fix\scompiler\swarning\sseen\swith\sMSVC. +D 2015-12-16T21:09:53.083 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -398,7 +398,7 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 0bc683e68a71d5151898b6b13cfeb277337335a4 +F src/vdbe.c 984c2be6691d3f67deb2e6747c2132150d776f32 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca @@ -1404,7 +1404,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1928f8945b7cdf733129619b7ab02d1addf63478 -R 66e8a449a1ea9e4af724bc52e4baa50a -U drh -Z dcd4ad4bd65fd6c947db9b3e37840361 +P f2fc3aede55c8fa0351697f9f5ce4e544334c9af +R 454ea4523afc8cf1e644fcd8a292a415 +T *branch * msvcWarn +T *sym-msvcWarn * +T -sym-trunk * +U mistachkin +Z 09fa8646fa5564b4cacb5dabca0e4ae2 diff --git a/manifest.uuid b/manifest.uuid index d77b5aa4be..f03db546f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f2fc3aede55c8fa0351697f9f5ce4e544334c9af \ No newline at end of file +18a4c0540bf4f02335e9e9def1f2b0d4d784ef08 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 2aeab897a1..894758a01c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2524,6 +2524,8 @@ case OP_Column: { rc = SQLITE_CORRUPT_BKPT; goto op_column_error; } + }else{ + VVA_ONLY( t = 0; ) /* Only needed by assert() statements */ } /* If after trying to extract new entries from the header, nHdrParsed is From 8ccdef6be492dd2b1561ec4305ad5e749ada30e3 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 16 Dec 2015 22:06:52 +0000 Subject: [PATCH 092/232] Fix some more harmless compiler warnings. FossilOrigin-Name: 18f531e1cf3c8bb986d912c9c5e3f5698360c93e --- ext/fts3/tool/fts3view.c | 2 +- manifest | 23 ++++++++++------------- manifest.uuid | 2 +- mptest/mptest.c | 6 +++--- src/test8.c | 10 +++++----- src/test_loadext.c | 2 +- tool/showdb.c | 8 ++++---- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/ext/fts3/tool/fts3view.c b/ext/fts3/tool/fts3view.c index 6dada352b3..a8d7981af0 100644 --- a/ext/fts3/tool/fts3view.c +++ b/ext/fts3/tool/fts3view.c @@ -398,7 +398,7 @@ static void showSegmentStats(sqlite3 *db, const char *zTab){ if( sqlite3_step(pStmt)==SQLITE_ROW && (nLeaf = sqlite3_column_int(pStmt, 0))>0 ){ - int nIdx = sqlite3_column_int(pStmt, 5); + nIdx = sqlite3_column_int(pStmt, 5); sqlite3_int64 sz; printf("For level %d:\n", i); printf(" Number of indexes...................... %9d\n", nIdx); diff --git a/manifest b/manifest index a6a443ee80..076eea4893 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompiler\swarning\sseen\swith\sMSVC. -D 2015-12-16T21:09:53.083 +C Fix\ssome\smore\sharmless\scompiler\swarnings. +D 2015-12-16T22:06:52.804 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -90,7 +90,7 @@ F ext/fts3/fts3_unicode2.c c3d01968d497bd7001e7dc774ba75b372738c057 F ext/fts3/fts3_write.c f442223e4a1914dc1fc12b65af7e4f2c255fa47c F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 -F ext/fts3/tool/fts3view.c 8e53d0190a7b3443764bbd32ad47be2bd852026d +F ext/fts3/tool/fts3view.c 5d78b668f4e9598af9147f8999632599fb0d9dd5 F ext/fts3/unicode/CaseFolding.txt 8c678ca52ecc95e16bc7afc2dbf6fc9ffa05db8c F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 @@ -263,7 +263,7 @@ F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 F mptest/crash02.subtest f4ef05adcd15d60e5d2bd654204f2c008b519df8 -F mptest/mptest.c e7b499cb0cf8c3de65eaf24dec9b36daa4e013e4 +F mptest/mptest.c 0d3f2eb8e373cb692ab362a6dddedd53e0978502 F mptest/multiwrite01.test dab5c5f8f9534971efce679152c5146da265222d F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b @@ -350,7 +350,7 @@ F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e F src/test5.c 5a34feec76d9b3a86aab30fd4f6cc9c48cbab4c1 F src/test6.c 41cacf3b0dd180823919bf9e1fbab287c9266723 F src/test7.c 9c89a4f1ed6bb13af0ed805b8d782bd83fcd57e3 -F src/test8.c b3a416298dab54537d5aec68697a8b31f5ddf69c +F src/test8.c fa262391d3edea6490a71bfaa8fed477ccbbac75 F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8 F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12 @@ -367,7 +367,7 @@ F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32 F src/test_intarray.c 870124b95ec4c645d4eb84f15efb7133528fb1a5 F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa -F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4 +F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd F src/test_malloc.c 96df9381a1ff1f6d3805ff7231b9baf1386aaabf F src/test_multiplex.c 6a088d8d9d4aad4bec45dd8878af11b15900702d F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 @@ -1380,7 +1380,7 @@ F tool/replace.tcl 7727c60a04299b65a92f5e1590896fea0f25b9e0 F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 F tool/run-speed-test.sh 0ae485af4fe9f826e2b494be8c81f8ca9e222a4a -F tool/showdb.c d4476e000a64eca9f5e2c2f68741e747b9778e8d +F tool/showdb.c 82dca79a999b2701c62417636345e9974151fdad F tool/showjournal.c 5bad7ae8784a43d2b270d953060423b8bd480818 F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68 F tool/showstat4.c bda40d6e395df7edb6e9ea630784d3d762c35b4b @@ -1404,10 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f2fc3aede55c8fa0351697f9f5ce4e544334c9af -R 454ea4523afc8cf1e644fcd8a292a415 -T *branch * msvcWarn -T *sym-msvcWarn * -T -sym-trunk * +P 18a4c0540bf4f02335e9e9def1f2b0d4d784ef08 +R 06de55492a4df78b9664135b3d4b8e56 U mistachkin -Z 09fa8646fa5564b4cacb5dabca0e4ae2 +Z 864a907ebf41c0671e45c9ca5fad89fc diff --git a/manifest.uuid b/manifest.uuid index f03db546f9..1112c6c5f0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -18a4c0540bf4f02335e9e9def1f2b0d4d784ef08 \ No newline at end of file +18f531e1cf3c8bb986d912c9c5e3f5698360c93e \ No newline at end of file diff --git a/mptest/mptest.c b/mptest/mptest.c index 5a9c8bf6b4..b29ebdc9e1 100644 --- a/mptest/mptest.c +++ b/mptest/mptest.c @@ -422,9 +422,9 @@ static void stringAppend(String *p, const char *z, int n){ if( n<0 ) n = (int)strlen(z); if( p->n+n>=p->nAlloc ){ int nAlloc = p->nAlloc*2 + n + 100; - char *z = sqlite3_realloc(p->z, nAlloc); - if( z==0 ) fatalError("out of memory"); - p->z = z; + char *zNew = sqlite3_realloc(p->z, nAlloc); + if( zNew==0 ) fatalError("out of memory"); + p->z = zNew; p->nAlloc = nAlloc; } memcpy(p->z+p->n, z, n); diff --git a/src/test8.c b/src/test8.c index 3e506e36b4..fb781ac8fd 100644 --- a/src/test8.c +++ b/src/test8.c @@ -863,7 +863,7 @@ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ iCol = pConstraint->iColumn; if( iCol<0 || pVtab->aIndex[iCol] ){ - char *zCol = iCol>=0 ? pVtab->aCol[iCol] : "rowid"; + char *zNewCol = iCol>=0 ? pVtab->aCol[iCol] : "rowid"; char *zOp = 0; useIdx = 1; switch( pConstraint->op ){ @@ -895,9 +895,9 @@ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ } if( zOp[0]=='L' ){ zNew = sqlite3_mprintf(" %s %s LIKE (SELECT '%%'||?||'%%')", - zSep, zCol); + zSep, zNewCol); } else { - zNew = sqlite3_mprintf(" %s %s %s ?", zSep, zCol, zOp); + zNew = sqlite3_mprintf(" %s %s %s ?", zSep, zNewCol, zOp); } string_concat(&zQuery, zNew, 1, &rc); @@ -915,9 +915,9 @@ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ pIdxInfo->aOrderBy->iColumn<0 || pVtab->aIndex[pIdxInfo->aOrderBy->iColumn]) ){ int iCol = pIdxInfo->aOrderBy->iColumn; - char *zCol = iCol>=0 ? pVtab->aCol[iCol] : "rowid"; + char *zNewCol = iCol>=0 ? pVtab->aCol[iCol] : "rowid"; char *zDir = pIdxInfo->aOrderBy->desc?"DESC":"ASC"; - zNew = sqlite3_mprintf(" ORDER BY %s %s", zCol, zDir); + zNew = sqlite3_mprintf(" ORDER BY %s %s", zNewCol, zDir); string_concat(&zQuery, zNew, 1, &rc); pIdxInfo->orderByConsumed = 1; } diff --git a/src/test_loadext.c b/src/test_loadext.c index 5a1f46da9c..6404a69714 100644 --- a/src/test_loadext.c +++ b/src/test_loadext.c @@ -34,7 +34,7 @@ static void statusFunc( int argc, sqlite3_value **argv ){ - int op, mx, cur, resetFlag, rc; + int op = 0, mx, cur, resetFlag, rc; if( sqlite3_value_type(argv[0])==SQLITE_INTEGER ){ op = sqlite3_value_int(argv[0]); }else if( sqlite3_value_type(argv[0])==SQLITE_TEXT ){ diff --git a/tool/showdb.c b/tool/showdb.c index 38b92f1f7d..06cd36cd2c 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -1152,10 +1152,10 @@ int main(int argc, char **argv){ }else if( zLeft && zLeft[0]=='t' ){ int detail = 0; int recursive = 0; - int i; - for(i=1; zLeft[i]; i++){ - if( zLeft[i]=='r' ) recursive = 1; - if( zLeft[i]=='d' ) detail = 1; + int j; + for(j=1; zLeft[j]; j++){ + if( zLeft[j]=='r' ) recursive = 1; + if( zLeft[j]=='d' ) detail = 1; } decode_trunk_page(iStart, detail, recursive); continue; From b9becaa2688209838c0f952feef99c9cfb434390 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 16 Dec 2015 23:30:30 +0000 Subject: [PATCH 093/232] Fix even more harmless compiler warnings. FossilOrigin-Name: 1d0e6aa119da8e15d35508f5d75ffc729979da92 --- Makefile.msc | 2 +- ext/fts5/fts5_expr.c | 2 +- ext/fts5/fts5_hash.c | 2 +- ext/fts5/fts5_index.c | 19 ++++++++++--------- ext/fts5/fts5_main.c | 2 +- ext/fts5/fts5_tokenize.c | 2 +- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 5c72001532..aa2bd9a2f1 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -50,7 +50,7 @@ API_ARMOR = 0 !IFNDEF NO_WARN !IF $(USE_FULLWARN)!=0 NO_WARN = -wd4054 -wd4055 -wd4100 -wd4127 -wd4130 -wd4152 -wd4189 -wd4206 -NO_WARN = $(NO_WARN) -wd4210 -wd4232 -wd4244 -wd4305 -wd4306 -wd4702 -wd4706 +NO_WARN = $(NO_WARN) -wd4210 -wd4232 -wd4305 -wd4306 -wd4702 -wd4706 !ENDIF !ENDIF diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 59deda6137..eb167b4407 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -430,7 +430,7 @@ static int fts5ExprPhraseIsMatch( } if( rc!=SQLITE_OK ) goto ismatch_out; sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]); - aIter[i].bFlag = bFlag; + aIter[i].bFlag = (u8)bFlag; if( aIter[i].bEof ) goto ismatch_out; } diff --git a/ext/fts5/fts5_hash.c b/ext/fts5/fts5_hash.c index e1b5bcdf81..f184957af6 100644 --- a/ext/fts5/fts5_hash.c +++ b/ext/fts5/fts5_hash.c @@ -190,7 +190,7 @@ static void fts5HashAddPoslistSize(Fts5HashEntry *p){ assert( p->bDel==0 || p->bDel==1 ); if( nPos<=127 ){ - pPtr[p->iSzPoslist] = nPos; + pPtr[p->iSzPoslist] = (u8)nPos; }else{ int nByte = sqlite3Fts5GetVarintLen((u32)nPos); memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz); diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index b7374f9805..c11abda5ba 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -2393,7 +2393,7 @@ static int fts5MultiIterDoCompare(Fts5IndexIter *pIter, int iOut){ } } - pRes->iFirst = iRes; + pRes->iFirst = (u16)iRes; return 0; } @@ -2560,7 +2560,7 @@ static int fts5MultiIterAdvanceRowid( pIter->iSwitchRowid = pOther->iRowid; } } - pRes->iFirst = (pNew - pIter->aSeg); + pRes->iFirst = (u16)(pNew - pIter->aSeg); if( i==1 ) break; pOther = &pIter->aSeg[ pIter->aFirst[i ^ 0x0001].iFirst ]; @@ -2711,7 +2711,7 @@ static void fts5MultiIterNew( *ppOut = pNew = fts5MultiIterAlloc(p, nSeg); if( pNew==0 ) return; pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC)); - pNew->bSkipEmpty = bSkipEmpty; + pNew->bSkipEmpty = (u8)bSkipEmpty; pNew->pStruct = pStruct; fts5StructureRef(pStruct); @@ -3174,7 +3174,7 @@ static void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){ /* Set the szLeaf header field. */ assert( 0==fts5GetU16(&pPage->buf.p[2]) ); - fts5PutU16(&pPage->buf.p[2], pPage->buf.n); + fts5PutU16(&pPage->buf.p[2], (u16)pPage->buf.n); if( pWriter->bFirstTermInPage ){ /* No term was written to this page. */ @@ -3306,7 +3306,7 @@ static void fts5WriteAppendRowid( ** rowid-pointer in the page-header. Also append a value to the dlidx ** buffer, in case a doclist-index is required. */ if( pWriter->bFirstRowidInPage ){ - fts5PutU16(pPage->buf.p, pPage->buf.n); + fts5PutU16(pPage->buf.p, (u16)pPage->buf.n); fts5WriteDlidxAppend(p, pWriter, iRowid); } @@ -3464,7 +3464,7 @@ static void fts5TrimSegments(Fts5Index *p, Fts5IndexIter *pIter){ fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff, &pData->p[iOff]); if( p->rc==SQLITE_OK ){ /* Set the szLeaf field */ - fts5PutU16(&buf.p[2], buf.n); + fts5PutU16(&buf.p[2], (u16)buf.n); } /* Set up the new page-index array */ @@ -3830,7 +3830,7 @@ static void fts5FlushOneHash(Fts5Index *p){ iRowid += iDelta; if( writer.bFirstRowidInPage ){ - fts5PutU16(&pBuf->p[0], pBuf->n); /* first rowid on page */ + fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */ pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid); writer.bFirstRowidInPage = 0; fts5WriteDlidxAppend(p, &writer, iRowid); @@ -4627,7 +4627,8 @@ int sqlite3Fts5IndexWrite( int nByte = fts5IndexCharlenToBytelen(pToken, nToken, pConfig->aPrefix[i]); if( nByte ){ rc = sqlite3Fts5HashWrite(p->pHash, - p->iWriteRowid, iCol, iPos, FTS5_MAIN_PREFIX+i+1, pToken, nByte + p->iWriteRowid, iCol, iPos, (char)(FTS5_MAIN_PREFIX+i+1), pToken, + nByte ); } } @@ -4677,7 +4678,7 @@ int sqlite3Fts5IndexQuery( if( iIdx<=pConfig->nPrefix ){ Fts5Structure *pStruct = fts5StructureRead(p); - buf.p[0] = FTS5_MAIN_PREFIX + iIdx; + buf.p[0] = (u8)(FTS5_MAIN_PREFIX + iIdx); if( pStruct ){ fts5MultiIterNew(p, pStruct, 1, flags, buf.p, nToken+1, -1, 0, &pRet); fts5StructureRelease(pStruct); diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 9390cb6cb2..cf2c748c4c 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -588,7 +588,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ struct Constraint *pC = &aConstraint[i]; if( pC->iConsIndex>=0 ){ pInfo->aConstraintUsage[pC->iConsIndex].argvIndex = iNext++; - pInfo->aConstraintUsage[pC->iConsIndex].omit = pC->omit; + pInfo->aConstraintUsage[pC->iConsIndex].omit = (unsigned char)pC->omit; } } diff --git a/ext/fts5/fts5_tokenize.c b/ext/fts5/fts5_tokenize.c index 44b154e4c5..1df7ba9e35 100644 --- a/ext/fts5/fts5_tokenize.c +++ b/ext/fts5/fts5_tokenize.c @@ -256,7 +256,7 @@ static int fts5UnicodeAddExceptions( int bToken; READ_UTF8(zCsr, zTerm, iCode); if( iCode<128 ){ - p->aTokenChar[iCode] = bTokenChars; + p->aTokenChar[iCode] = (unsigned char)bTokenChars; }else{ bToken = sqlite3Fts5UnicodeIsalnum(iCode); assert( (bToken==0 || bToken==1) ); diff --git a/manifest b/manifest index 076eea4893..e1a1e29ca8 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Fix\ssome\smore\sharmless\scompiler\swarnings. -D 2015-12-16T22:06:52.804 +C Fix\seven\smore\sharmless\scompiler\swarnings. +D 2015-12-16T23:30:30.339 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d +F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 8b9d3ac6f1962f94e06ba05462422a544f9c4e36 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -101,14 +101,14 @@ F ext/fts5/fts5Int.h acf968e43d57b6b1caf7554d34ec35d6ed3b4fe8 F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 1e49512a535045e621246dc7f4f65f3593fa0fc2 F ext/fts5/fts5_config.c 0ee66188609a62342e9f9aeefa3c3e44518a4dd6 -F ext/fts5/fts5_expr.c 28b15c9ae296204bc0a2e5cf7a667d840a9d2900 -F ext/fts5/fts5_hash.c a9d4c1efebc2a91d26ad7ebdfcbf2678ceac405f -F ext/fts5/fts5_index.c b622a0a70f57a96469e6828da2dd70e0872aeb37 -F ext/fts5/fts5_main.c 7581280ee242785477df67402f2853c66f77d45b +F ext/fts5/fts5_expr.c 80075fa45091bad42100c4a5c4f2efc83e43e3af +F ext/fts5/fts5_hash.c 25838d525e97f8662ff3504be94d0bad24f9a37e +F ext/fts5/fts5_index.c 578f46697080f11a1e26cd45a1c039c043a3111d +F ext/fts5/fts5_main.c ef04699949ab8e42d590ae30188afef7ad58776e F ext/fts5/fts5_storage.c 9ea3d92178743758b6c54d9fe8836bbbdcc92e3b F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf -F ext/fts5/fts5_tokenize.c 12c5d925286491a71bb3dad7c8924ce9cfd18320 +F ext/fts5/fts5_tokenize.c 618efe033bceb80c521b1e9ddfd9fee85fb5946e F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 @@ -1404,7 +1404,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 18a4c0540bf4f02335e9e9def1f2b0d4d784ef08 -R 06de55492a4df78b9664135b3d4b8e56 +P 18f531e1cf3c8bb986d912c9c5e3f5698360c93e +R d6064250d2ceb34ab73cc0f26f2d0c34 U mistachkin -Z 864a907ebf41c0671e45c9ca5fad89fc +Z 5f6aca95d2219a9c4d159221e399907b diff --git a/manifest.uuid b/manifest.uuid index 1112c6c5f0..f64ade7fc1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -18f531e1cf3c8bb986d912c9c5e3f5698360c93e \ No newline at end of file +1d0e6aa119da8e15d35508f5d75ffc729979da92 \ No newline at end of file From 1db0a72be23771498ebd1a18c897056a98bd8fc8 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 17 Dec 2015 14:18:21 +0000 Subject: [PATCH 094/232] Fix the spellfix1_scriptcode() function to ignore whitespace and punctuation, and to recognize hebrew and arabic scripts. FossilOrigin-Name: 7adfa4a5794e47f97491c08abeaaac90e826b331 --- ext/misc/spellfix.c | 10 +++++++++- manifest | 14 +++++++------- manifest.uuid | 2 +- test/spellfix3.test | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 test/spellfix3.test diff --git a/ext/misc/spellfix.c b/ext/misc/spellfix.c index 0515b7bc6c..c0da6b339b 100644 --- a/ext/misc/spellfix.c +++ b/ext/misc/spellfix.c @@ -1717,17 +1717,23 @@ static void scriptCodeSqlFunc( # define SCRIPT_LATIN 0x0001 # define SCRIPT_CYRILLIC 0x0002 # define SCRIPT_GREEK 0x0004 +# define SCRIPT_HEBREW 0x0008 +# define SCRIPT_ARABIC 0x0010 while( nIn>0 ){ c = utf8Read(zIn, nIn, &sz); zIn += sz; nIn -= sz; - if( c<0x02af ){ + if( c<0x02af && (c>=0x80 || midClass[c&0x7f]=0x0400 && c<=0x04ff ){ scriptMask |= SCRIPT_CYRILLIC; }else if( c>=0x0386 && c<=0x03ce ){ scriptMask |= SCRIPT_GREEK; + }else if( c>=0x0590 && c<=0x05ff ){ + scriptMask |= SCRIPT_HEBREW; + }else if( c>=0x0600 && c<=0x06ff ){ + scriptMask |= SCRIPT_ARABIC; } } switch( scriptMask ){ @@ -1735,6 +1741,8 @@ static void scriptCodeSqlFunc( case SCRIPT_LATIN: res = 215; break; case SCRIPT_CYRILLIC: res = 220; break; case SCRIPT_GREEK: res = 200; break; + case SCRIPT_HEBREW: res = 125; break; + case SCRIPT_ARABIC: res = 160; break; default: res = 998; break; } sqlite3_result_int(context, res); diff --git a/manifest b/manifest index df0b61a31c..799ac619df 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sfor\sharmless\scompiler\swarnings. -D 2015-12-17T13:28:50.207 +C Fix\sthe\sspellfix1_scriptcode()\sfunction\sto\signore\swhitespace\sand\spunctuation,\nand\sto\srecognize\shebrew\sand\sarabic\sscripts. +D 2015-12-17T14:18:21.904 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -198,7 +198,7 @@ F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a F ext/misc/series.c b8fb7befd85b3a9b4a10e701b30b2b79ca92b6d4 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 -F ext/misc/spellfix.c b9065af7ab1f2597b505a8aa9892620866d502fc +F ext/misc/spellfix.c df6efb90eb668d1860c9b59e4320e985e46dffa7 F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e @@ -1035,6 +1035,7 @@ F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b F test/speedtest1.c f8bf04214e7b5f745feea99f7bde68b1c4870666 F test/spellfix.test 0597065ff57042df1f138e6a2611ae19c2698135 F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 +F test/spellfix3.test f7bf7b3482971473d32b6b00f6944c5c066cff97 F test/sqldiff1.test 8f6bc7c6a5b3585d350d779c6078869ba402f8f5 F test/sqllimits1.test a74ee2a3740b9f9c2437c246d8fb77354862a142 F test/sqllog.test a8faa2df39610a037dd372ed872d124260d32953 @@ -1404,8 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f2fc3aede55c8fa0351697f9f5ce4e544334c9af 1d0e6aa119da8e15d35508f5d75ffc729979da92 -R d6064250d2ceb34ab73cc0f26f2d0c34 -T +closed 1d0e6aa119da8e15d35508f5d75ffc729979da92 +P 85ebd46c701e0a094a4690cd8f1d0cbae9aa257c +R 70cdc580d7d9b92b032d33f5e0d50f2e U drh -Z 55d4a7733cfc9336492f45b410da6806 +Z 6d4b5ed9cd1870281d7d851922f323d8 diff --git a/manifest.uuid b/manifest.uuid index d3a2a6c2c5..eebc618153 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -85ebd46c701e0a094a4690cd8f1d0cbae9aa257c \ No newline at end of file +7adfa4a5794e47f97491c08abeaaac90e826b331 \ No newline at end of file diff --git a/test/spellfix3.test b/test/spellfix3.test new file mode 100644 index 0000000000..ce002edd4f --- /dev/null +++ b/test/spellfix3.test @@ -0,0 +1,43 @@ +# 2015-12-17 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix spellfix3 + +ifcapable !vtab { finish_test ; return } + +load_static_extension db spellfix + +do_execsql_test 100 { + SELECT spellfix1_scriptcode('And God said, “Let there be light”'); +} {215} +do_execsql_test 110 { + SELECT spellfix1_scriptcode('Бог сказал: "Да будет свет"'); +} {220} +do_execsql_test 120 { + SELECT spellfix1_scriptcode('και ειπεν ο θεος γενηθητω φως και εγενετο φως'); +} {200} +do_execsql_test 130 { + SELECT spellfix1_scriptcode('וַיֹּ֥אמֶר אֱלֹהִ֖ים יְהִ֣י א֑וֹר וַֽיְהִי־אֽוֹר׃'); +} {125} +do_execsql_test 140 { + SELECT spellfix1_scriptcode('فِي ذَلِكَ الوَقتِ، قالَ اللهُ: لِيَكُنْ نُورٌ. فَصَارَ نُورٌ.'); +} {160} +do_execsql_test 200 { + SELECT spellfix1_scriptcode('+3.14159'); +} {999} +do_execsql_test 210 { + SELECT spellfix1_scriptcode('And God said: "Да будет свет"'); +} {998} + +finish_test From b12dc84fbb12b6137175ce6ed4a72c7927ffc466 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 17 Dec 2015 20:36:13 +0000 Subject: [PATCH 095/232] Add the "offsets=0" option to fts5, to create a smaller index without term offset information. A few things are currently broken on this branch. FossilOrigin-Name: 40b5bbf02a824ca73b33aa4ae1c7d5f65b7cda10 --- ext/fts5/fts5Int.h | 10 ++++- ext/fts5/fts5_buffer.c | 74 ++++++++++++++++++++++++++++++++++ ext/fts5/fts5_config.c | 12 +++++- ext/fts5/fts5_hash.c | 30 +++++++++----- ext/fts5/fts5_index.c | 56 +++++++++++++++++++++---- ext/fts5/fts5_storage.c | 46 +++++++++++++++------ ext/fts5/test/fts5offsets.test | 59 +++++++++++++++++++++++++++ manifest | 28 +++++++------ manifest.uuid | 2 +- 9 files changed, 272 insertions(+), 45 deletions(-) create mode 100644 ext/fts5/test/fts5offsets.test diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 83a71723ff..436ae0712e 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -151,6 +151,7 @@ struct Fts5Config { char *zContent; /* content table */ char *zContentRowid; /* "content_rowid=" option value */ int bColumnsize; /* "columnsize=" option value (dflt==1) */ + int bOffsets; /* "offsets=" option value (dflt==1) */ char *zContentExprlist; Fts5Tokenizer *pTok; fts5_tokenizer *pTokApi; @@ -292,6 +293,13 @@ char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn); /* Character set tests (like isspace(), isalpha() etc.) */ int sqlite3Fts5IsBareword(char t); + +/* Bucket of terms object used by the integrity-check in offsets=0 mode. */ +typedef struct Fts5Termset Fts5Termset; +int sqlite3Fts5TermsetNew(Fts5Termset**); +int sqlite3Fts5TermsetAdd(Fts5Termset*, const char*, int, int *pbPresent); +void sqlite3Fts5TermsetFree(Fts5Termset*); + /* ** End of interface to code in fts5_buffer.c. **************************************************************************/ @@ -492,7 +500,7 @@ typedef struct Fts5Hash Fts5Hash; /* ** Create a hash table, free a hash table. */ -int sqlite3Fts5HashNew(Fts5Hash**, int *pnSize); +int sqlite3Fts5HashNew(Fts5Config*, Fts5Hash**, int *pnSize); void sqlite3Fts5HashFree(Fts5Hash*); int sqlite3Fts5HashWrite( diff --git a/ext/fts5/fts5_buffer.c b/ext/fts5/fts5_buffer.c index e9aab4622a..7e3e137996 100644 --- a/ext/fts5/fts5_buffer.c +++ b/ext/fts5/fts5_buffer.c @@ -292,3 +292,77 @@ int sqlite3Fts5IsBareword(char t){ } +/************************************************************************* +*/ +typedef struct Fts5TermsetEntry Fts5TermsetEntry; +struct Fts5TermsetEntry { + char *pTerm; + int nTerm; + Fts5TermsetEntry *pNext; +}; + +struct Fts5Termset { + Fts5TermsetEntry *apHash[512]; +}; + +int sqlite3Fts5TermsetNew(Fts5Termset **pp){ + int rc = SQLITE_OK; + *pp = sqlite3Fts5MallocZero(&rc, sizeof(Fts5Termset)); + return rc; +} + +int sqlite3Fts5TermsetAdd( + Fts5Termset *p, + const char *pTerm, int nTerm, + int *pbPresent +){ + int rc = SQLITE_OK; + int i; + int hash = 13; + Fts5TermsetEntry *pEntry; + + /* Calculate a hash value for this term */ + for(i=0; iapHash); + + *pbPresent = 0; + for(pEntry=p->apHash[hash]; pEntry; pEntry=pEntry->pNext){ + if( pEntry->nTerm==nTerm && memcmp(pEntry->pTerm, pTerm, nTerm)==0 ){ + *pbPresent = 1; + break; + } + } + + if( pEntry==0 ){ + pEntry = sqlite3Fts5MallocZero(&rc, sizeof(Fts5TermsetEntry) + nTerm); + if( pEntry ){ + pEntry->pTerm = (char*)&pEntry[1]; + pEntry->nTerm = nTerm; + memcpy(pEntry->pTerm, pTerm, nTerm); + pEntry->pNext = p->apHash[hash]; + p->apHash[hash] = pEntry; + } + } + + return rc; +} + +void sqlite3Fts5TermsetFree(Fts5Termset *p){ + if( p ){ + int i; + for(i=0; iapHash); i++){ + Fts5TermsetEntry *pEntry = p->apHash[i]; + while( pEntry ){ + Fts5TermsetEntry *pDel = pEntry; + pEntry = pEntry->pNext; + sqlite3_free(pDel); + } + } + sqlite3_free(p); + } +} + + + diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index 6b0e2b28b6..b72fd9b745 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -14,7 +14,6 @@ */ - #include "fts5Int.h" #define FTS5_DEFAULT_PAGE_SIZE 4050 @@ -345,6 +344,16 @@ static int fts5ConfigParseSpecial( return rc; } + if( sqlite3_strnicmp("offsets", zCmd, nCmd)==0 ){ + if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\0' ){ + *pzErr = sqlite3_mprintf("malformed offsets=... directive"); + rc = SQLITE_ERROR; + }else{ + pConfig->bOffsets = (zArg[0]=='1'); + } + return rc; + } + *pzErr = sqlite3_mprintf("unrecognized option: \"%.*s\"", nCmd, zCmd); return SQLITE_ERROR; } @@ -500,6 +509,7 @@ int sqlite3Fts5ConfigParse( pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1); pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1); pRet->bColumnsize = 1; + pRet->bOffsets = 1; #ifdef SQLITE_DEBUG pRet->bPrefixIndex = 1; #endif diff --git a/ext/fts5/fts5_hash.c b/ext/fts5/fts5_hash.c index f184957af6..dc5adadc8e 100644 --- a/ext/fts5/fts5_hash.c +++ b/ext/fts5/fts5_hash.c @@ -26,6 +26,7 @@ typedef struct Fts5HashEntry Fts5HashEntry; struct Fts5Hash { + int bOffsets; /* Copy of Fts5Config.bOffsets */ int *pnByte; /* Pointer to bytes counter */ int nEntry; /* Number of entries currently in hash */ int nSlot; /* Size of aSlot[] array */ @@ -79,7 +80,7 @@ struct Fts5HashEntry { /* ** Allocate a new hash table. */ -int sqlite3Fts5HashNew(Fts5Hash **ppNew, int *pnByte){ +int sqlite3Fts5HashNew(Fts5Config *pConfig, Fts5Hash **ppNew, int *pnByte){ int rc = SQLITE_OK; Fts5Hash *pNew; @@ -90,6 +91,7 @@ int sqlite3Fts5HashNew(Fts5Hash **ppNew, int *pnByte){ int nByte; memset(pNew, 0, sizeof(Fts5Hash)); pNew->pnByte = pnByte; + pNew->bOffsets = pConfig->bOffsets; pNew->nSlot = 1024; nByte = sizeof(Fts5HashEntry*) * pNew->nSlot; @@ -214,6 +216,7 @@ int sqlite3Fts5HashWrite( Fts5HashEntry *p; u8 *pPtr; int nIncr = 0; /* Amount to increment (*pHash->pnByte) by */ + int bNew = pHash->bOffsets; /* If non-delete entry should be written */ /* Attempt to locate an existing hash entry */ iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken); @@ -250,6 +253,7 @@ int sqlite3Fts5HashWrite( p->iSzPoslist = p->nData; p->nData += 1; p->iRowid = iRowid; + p->iCol = (pHash->bOffsets-1); p->pHashNext = pHash->aSlot[iHash]; pHash->aSlot[iHash] = p; pHash->nEntry++; @@ -286,24 +290,32 @@ int sqlite3Fts5HashWrite( p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid); p->iSzPoslist = p->nData; p->nData += 1; - p->iCol = 0; + p->iCol = (pHash->bOffsets-1); p->iPos = 0; p->iRowid = iRowid; + bNew = 1; } if( iCol>=0 ){ /* Append a new column value, if necessary */ assert( iCol>=p->iCol ); if( iCol!=p->iCol ){ - pPtr[p->nData++] = 0x01; - p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iCol); - p->iCol = iCol; - p->iPos = 0; + if( pHash->bOffsets==0 ){ + bNew = 1; + p->iCol = iPos = iCol; + }else{ + pPtr[p->nData++] = 0x01; + p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iCol); + p->iCol = iCol; + p->iPos = 0; + } } - /* Append the new position offset */ - p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iPos - p->iPos + 2); - p->iPos = iPos; + /* Append the new position offset, if necessary */ + if( bNew ){ + p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iPos - p->iPos + 2); + p->iPos = iPos; + } }else{ /* This is a delete. Set the delete flag. */ p->bDel = 1; diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index c11abda5ba..bf765d0556 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4001,6 +4001,14 @@ struct PoslistCallbackCtx { int eState; /* See above */ }; +typedef struct PoslistOffsetsCtx PoslistOffsetsCtx; +struct PoslistOffsetsCtx { + Fts5Buffer *pBuf; /* Append to this buffer */ + Fts5Colset *pColset; /* Restrict matches to this column */ + int iRead; + int iWrite; +}; + /* ** TODO: Make this more efficient! */ @@ -4012,6 +4020,28 @@ static int fts5IndexColsetTest(Fts5Colset *pColset, int iCol){ return 0; } +static void fts5PoslistOffsetsCallback( + Fts5Index *p, + void *pContext, + const u8 *pChunk, int nChunk +){ + PoslistOffsetsCtx *pCtx = (PoslistOffsetsCtx*)pContext; + assert_nc( nChunk>=0 ); + if( nChunk>0 ){ + int i = 0; + while( iiRead - 2; + pCtx->iRead = iVal; + if( fts5IndexColsetTest(pCtx->pColset, iVal) ){ + fts5BufferSafeAppendVarint(pCtx->pBuf, iVal + 2 - pCtx->iWrite); + pCtx->iWrite = iVal; + } + } + } +} + static void fts5PoslistFilterCallback( Fts5Index *p, void *pContext, @@ -4079,12 +4109,20 @@ static void fts5SegiterPoslist( if( pColset==0 ){ fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback); }else{ - PoslistCallbackCtx sCtx; - sCtx.pBuf = pBuf; - sCtx.pColset = pColset; - sCtx.eState = fts5IndexColsetTest(pColset, 0); - assert( sCtx.eState==0 || sCtx.eState==1 ); - fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistFilterCallback); + if( p->pConfig->bOffsets==0 ){ + PoslistOffsetsCtx sCtx; + memset(&sCtx, 0, sizeof(sCtx)); + sCtx.pBuf = pBuf; + sCtx.pColset = pColset; + fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistOffsetsCallback); + }else{ + PoslistCallbackCtx sCtx; + sCtx.pBuf = pBuf; + sCtx.pColset = pColset; + assert( sCtx.eState==0 || sCtx.eState==1 ); + sCtx.eState = fts5IndexColsetTest(pColset, 0); + fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistFilterCallback); + } } } } @@ -4446,7 +4484,7 @@ int sqlite3Fts5IndexBeginWrite(Fts5Index *p, int bDelete, i64 iRowid){ /* Allocate the hash table if it has not already been allocated */ if( p->pHash==0 ){ - p->rc = sqlite3Fts5HashNew(&p->pHash, &p->nPendingData); + p->rc = sqlite3Fts5HashNew(p->pConfig, &p->pHash, &p->nPendingData); } /* Flush the hash table to disk if required */ @@ -4804,7 +4842,9 @@ int sqlite3Fts5IterPoslist( Fts5SegIter *pSeg = &pIter->aSeg[ pIter->aFirst[1].iFirst ]; assert( pIter->pIndex->rc==SQLITE_OK ); *piRowid = pSeg->iRowid; - if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf ){ + if( pIter->pIndex->pConfig->bOffsets + && pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf + ){ u8 *pPos = &pSeg->pLeaf->p[pSeg->iLeafOffset]; if( pColset==0 || pIter->bFiltered ){ *pn = pSeg->nPos; diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 5fd5dc51a2..c84b213fdf 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -825,6 +825,7 @@ struct Fts5IntegrityCtx { int iCol; int szCol; u64 cksum; + Fts5Termset *pTermset; Fts5Config *pConfig; }; @@ -832,21 +833,33 @@ struct Fts5IntegrityCtx { ** Tokenization callback used by integrity check. */ static int fts5StorageIntegrityCallback( - void *pContext, /* Pointer to Fts5InsertCtx object */ + void *pContext, /* Pointer to Fts5IntegrityCtx object */ int tflags, const char *pToken, /* Buffer containing token */ int nToken, /* Size of token in bytes */ int iStart, /* Start offset of token */ int iEnd /* End offset of token */ ){ + int rc = SQLITE_OK; Fts5IntegrityCtx *pCtx = (Fts5IntegrityCtx*)pContext; if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){ pCtx->szCol++; } - pCtx->cksum ^= sqlite3Fts5IndexCksum( - pCtx->pConfig, pCtx->iRowid, pCtx->iCol, pCtx->szCol-1, pToken, nToken - ); - return SQLITE_OK; + + if( pCtx->pTermset ){ + int bPresent = 0; + rc = sqlite3Fts5TermsetAdd(pCtx->pTermset, pToken, nToken, &bPresent); + if( rc==SQLITE_OK && bPresent==0 ){ + pCtx->cksum ^= sqlite3Fts5IndexCksum( + pCtx->pConfig, pCtx->iRowid, 0, pCtx->iCol, pToken, nToken + ); + } + }else{ + pCtx->cksum ^= sqlite3Fts5IndexCksum( + pCtx->pConfig, pCtx->iRowid, pCtx->iCol, pCtx->szCol-1, pToken, nToken + ); + } + return rc; } /* @@ -886,17 +899,24 @@ int sqlite3Fts5StorageIntegrity(Fts5Storage *p){ if( pConfig->abUnindexed[i] ) continue; ctx.iCol = i; ctx.szCol = 0; - rc = sqlite3Fts5Tokenize(pConfig, - FTS5_TOKENIZE_DOCUMENT, - (const char*)sqlite3_column_text(pScan, i+1), - sqlite3_column_bytes(pScan, i+1), - (void*)&ctx, - fts5StorageIntegrityCallback - ); - if( pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){ + if( pConfig->bOffsets==0 ){ + rc = sqlite3Fts5TermsetNew(&ctx.pTermset); + } + if( rc==SQLITE_OK ){ + rc = sqlite3Fts5Tokenize(pConfig, + FTS5_TOKENIZE_DOCUMENT, + (const char*)sqlite3_column_text(pScan, i+1), + sqlite3_column_bytes(pScan, i+1), + (void*)&ctx, + fts5StorageIntegrityCallback + ); + } + if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){ rc = FTS5_CORRUPT; } aTotalSize[i] += ctx.szCol; + sqlite3Fts5TermsetFree(ctx.pTermset); + ctx.pTermset = 0; } if( rc!=SQLITE_OK ) break; } diff --git a/ext/fts5/test/fts5offsets.test b/ext/fts5/test/fts5offsets.test new file mode 100644 index 0000000000..cd9bfa0054 --- /dev/null +++ b/ext/fts5/test/fts5offsets.test @@ -0,0 +1,59 @@ +# 2015 December 18 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# This file implements regression tests for SQLite library. The +# focus of this script is testing the FTS5 module. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5offsets + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, offsets=0); + + INSERT INTO t1 VALUES('h d g', 'j b b g b', 'i e i d h g g'); -- 1 + INSERT INTO t1 VALUES('h j d', 'j h d a h', 'f d d g g f b'); -- 2 + INSERT INTO t1 VALUES('j c i', 'f f h e f', 'c j i j c h f'); -- 3 + INSERT INTO t1 VALUES('e g g', 'g e d h i', 'e d b e g d c'); -- 4 + INSERT INTO t1 VALUES('b c c', 'd i h a f', 'd i j f a b c'); -- 5 + INSERT INTO t1 VALUES('e d e', 'b c j g d', 'a i f d h b d'); -- 6 + INSERT INTO t1 VALUES('g h e', 'b c d i d', 'e f c i f i c'); -- 7 + INSERT INTO t1 VALUES('c f j', 'j j i e a', 'h a c f d h e'); -- 8 + INSERT INTO t1 VALUES('a h i', 'c i a f a', 'c f d h g d g'); -- 9 + INSERT INTO t1 VALUES('j g g', 'e f e f f', 'h j b i c g e'); -- 10 +} + +do_execsql_test 1.1 { + INSERT INTO t1(t1) VALUES('integrity-check'); +} + +foreach {tn match res} { + 1 "a:a" {9} + 2 "b:g" {1 4 6} + 3 "c:h" {1 3 6 8 9 10} +} { + do_execsql_test 1.2.$tn.1 { + SELECT rowid FROM t1($match); + } $res + + do_execsql_test 1.2.$tn.2 { + SELECT rowid FROM t1($match || '*'); + } $res +} + +finish_test + diff --git a/manifest b/manifest index 799ac619df..8e1565e355 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sspellfix1_scriptcode()\sfunction\sto\signore\swhitespace\sand\spunctuation,\nand\sto\srecognize\shebrew\sand\sarabic\sscripts. -D 2015-12-17T14:18:21.904 +C Add\sthe\s"offsets=0"\soption\sto\sfts5,\sto\screate\sa\ssmaller\sindex\swithout\sterm\soffset\sinformation.\sA\sfew\sthings\sare\scurrently\sbroken\son\sthis\sbranch. +D 2015-12-17T20:36:13.853 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -97,15 +97,15 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 8b9a13b309b180e9fb88ea5666c0d8d73c6102d9 -F ext/fts5/fts5Int.h acf968e43d57b6b1caf7554d34ec35d6ed3b4fe8 +F ext/fts5/fts5Int.h 4e1bb66d8e607bf38e881eb455cdf36cc3fa9e42 F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 -F ext/fts5/fts5_buffer.c 1e49512a535045e621246dc7f4f65f3593fa0fc2 -F ext/fts5/fts5_config.c 0ee66188609a62342e9f9aeefa3c3e44518a4dd6 +F ext/fts5/fts5_buffer.c 389d377d04f6e622644c3343ab5e511f6646de36 +F ext/fts5/fts5_config.c ba5248a05c28ec6a6fdf2599a86e9fd67e5c61e2 F ext/fts5/fts5_expr.c 80075fa45091bad42100c4a5c4f2efc83e43e3af -F ext/fts5/fts5_hash.c 25838d525e97f8662ff3504be94d0bad24f9a37e -F ext/fts5/fts5_index.c 578f46697080f11a1e26cd45a1c039c043a3111d +F ext/fts5/fts5_hash.c d4a6b52faca0134cc7bcc880f03a257a0dec2636 +F ext/fts5/fts5_index.c 53b3a8f1c9c1f6e5e896b6dc0a7ad26c2eea23a2 F ext/fts5/fts5_main.c ef04699949ab8e42d590ae30188afef7ad58776e -F ext/fts5/fts5_storage.c 9ea3d92178743758b6c54d9fe8836bbbdcc92e3b +F ext/fts5/fts5_storage.c 0dc37a6183e1061e255f23971198d8878159d4ef F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf F ext/fts5/fts5_tokenize.c 618efe033bceb80c521b1e9ddfd9fee85fb5946e @@ -156,6 +156,7 @@ F ext/fts5/test/fts5integrity.test 87db5d4e7da0ce04a1dcba5ba91658673c997a65 F ext/fts5/test/fts5matchinfo.test 2163b0013e824bba65499da9e34ea4da41349cc2 F ext/fts5/test/fts5merge.test 8f3cdba2ec9c5e7e568246e81b700ad37f764367 F ext/fts5/test/fts5near.test b214cddb1c1f1bddf45c75af768f20145f7e71cc +F ext/fts5/test/fts5offsets.test 09fc61d553ae4e985afc0146ec77f3439503fc6b F ext/fts5/test/fts5onepass.test 7ed9608e258132cb8d55e7c479b08676ad68810c F ext/fts5/test/fts5optimize.test 42741e7c085ee0a1276140a752d4407d97c2c9f5 F ext/fts5/test/fts5phrase.test f6d1d464da5beb25dc56277aa4f1d6102f0d9a2f @@ -1405,7 +1406,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 85ebd46c701e0a094a4690cd8f1d0cbae9aa257c -R 70cdc580d7d9b92b032d33f5e0d50f2e -U drh -Z 6d4b5ed9cd1870281d7d851922f323d8 +P 7adfa4a5794e47f97491c08abeaaac90e826b331 +R a68b4412544bee6f6bc95a23674c55d4 +T *branch * fts5-offsets +T *sym-fts5-offsets * +T -sym-trunk * +U dan +Z a51f39853c3a5371cd0ec3358f50f2d7 diff --git a/manifest.uuid b/manifest.uuid index eebc618153..b6243ea89e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7adfa4a5794e47f97491c08abeaaac90e826b331 \ No newline at end of file +40b5bbf02a824ca73b33aa4ae1c7d5f65b7cda10 \ No newline at end of file From 45ac1c70b30d151cbcceb9ffa5ad1b3be38ce919 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 18 Dec 2015 03:59:16 +0000 Subject: [PATCH 096/232] Reduce the size of the CellInfo object from 32 to 24 bytes on 64-bit machines. FossilOrigin-Name: 7850715406458a61cff9eba5ad915f61f6d99482 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/btree.c | 33 ++++++++++++++------------------- src/btreeInt.h | 1 - 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/manifest b/manifest index 799ac619df..20d4d08510 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sspellfix1_scriptcode()\sfunction\sto\signore\swhitespace\sand\spunctuation,\nand\sto\srecognize\shebrew\sand\sarabic\sscripts. -D 2015-12-17T14:18:21.904 +C Reduce\sthe\ssize\sof\sthe\sCellInfo\sobject\sfrom\s32\sto\s24\sbytes\son\s64-bit\smachines. +D 2015-12-18T03:59:16.912 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -276,9 +276,9 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 84ede51e371a11c3dbb3e24ccc5e3e99594a6c00 +F src/btree.c 5ac3f868d4f20a67f0f00a1014940f902b511558 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 -F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 +F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f @@ -1405,7 +1405,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 85ebd46c701e0a094a4690cd8f1d0cbae9aa257c -R 70cdc580d7d9b92b032d33f5e0d50f2e +P 7adfa4a5794e47f97491c08abeaaac90e826b331 +R 235be975857692987ba30e4b3c7418db +T *branch * optimize-cellinfo +T *sym-optimize-cellinfo * +T -sym-trunk * U drh -Z 6d4b5ed9cd1870281d7d851922f323d8 +Z cc2df912aa2ee31453d3047ea3468b1b diff --git a/manifest.uuid b/manifest.uuid index eebc618153..b71ad0f19e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7adfa4a5794e47f97491c08abeaaac90e826b331 \ No newline at end of file +7850715406458a61cff9eba5ad915f61f6d99482 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 4e384e2c4f..df9455bc5b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1051,8 +1051,7 @@ static SQLITE_NOINLINE void btreeParseCellAdjustSizeForOverflow( }else{ pInfo->nLocal = (u16)minLocal; } - pInfo->iOverflow = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell); - pInfo->nSize = pInfo->iOverflow + 4; + pInfo->nSize = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell) + 4; } /* @@ -1084,7 +1083,6 @@ static void btreeParseCellPtrNoPayload( pInfo->nSize = 4 + getVarint(&pCell[4], (u64*)&pInfo->nKey); pInfo->nPayload = 0; pInfo->nLocal = 0; - pInfo->iOverflow = 0; pInfo->pPayload = 0; return; } @@ -1154,7 +1152,6 @@ static void btreeParseCellPtr( pInfo->nSize = nPayload + (u16)(pIter - pCell); if( pInfo->nSize<4 ) pInfo->nSize = 4; pInfo->nLocal = (u16)nPayload; - pInfo->iOverflow = 0; }else{ btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo); } @@ -1193,7 +1190,6 @@ static void btreeParseCellPtrIndex( pInfo->nSize = nPayload + (u16)(pIter - pCell); if( pInfo->nSize<4 ) pInfo->nSize = 4; pInfo->nLocal = (u16)nPayload; - pInfo->iOverflow = 0; }else{ btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo); } @@ -1309,8 +1305,8 @@ static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){ if( *pRC ) return; assert( pCell!=0 ); pPage->xParseCell(pPage, pCell, &info); - if( info.iOverflow ){ - Pgno ovfl = get4byte(&pCell[info.iOverflow]); + if( info.nLocalpBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC); } } @@ -3348,11 +3344,11 @@ static int modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){ if( eType==PTRMAP_OVERFLOW1 ){ CellInfo info; pPage->xParseCell(pPage, pCell, &info); - if( info.iOverflow - && pCell+info.iOverflow+3<=pPage->aData+pPage->maskPage - && iFrom==get4byte(&pCell[info.iOverflow]) + if( info.nLocalaData+pPage->maskPage + && iFrom==get4byte(pCell+info.nSize-4) ){ - put4byte(&pCell[info.iOverflow], iTo); + put4byte(pCell+info.nSize-4, iTo); break; } }else{ @@ -5994,13 +5990,13 @@ static int clearCell( assert( sqlite3_mutex_held(pPage->pBt->mutex) ); pPage->xParseCell(pPage, pCell, &info); *pnSize = info.nSize; - if( info.iOverflow==0 ){ + if( info.nLocal==info.nPayload ){ return SQLITE_OK; /* No overflow pages. Return without doing anything */ } - if( pCell+info.iOverflow+3 > pPage->aData+pPage->maskPage ){ + if( pCell+info.nSize-1 > pPage->aData+pPage->maskPage ){ return SQLITE_CORRUPT_BKPT; /* Cell extends past end of page */ } - ovflPgno = get4byte(&pCell[info.iOverflow]); + ovflPgno = get4byte(pCell + info.nSize - 4); assert( pBt->usableSize > 4 ); ovflPageSize = pBt->usableSize - 4; nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize; @@ -6149,7 +6145,6 @@ static int fillInCell( assert( info.nKey==nKey ); assert( *pnSize == info.nSize ); assert( spaceLeft == info.nLocal ); - assert( pPrior == &pCell[info.iOverflow] ); } #endif @@ -6859,8 +6854,8 @@ static int ptrmapCheckPages(MemPage **apPage, int nPage){ z = findCell(pPage, j); pPage->xParseCell(pPage, z, &info); - if( info.iOverflow ){ - Pgno ovfl = get4byte(&z[info.iOverflow]); + if( info.nLocalpgno && e==PTRMAP_OVERFLOW1 ); } @@ -9166,9 +9161,9 @@ static int checkTreePage( if( info.nPayload>info.nLocal ){ int nPage; /* Number of pages on the overflow chain */ Pgno pgnoOvfl; /* First page of the overflow chain */ - assert( pc + info.iOverflow <= usableSize ); + assert( pc + info.nSize - 4 <= usableSize ); nPage = (info.nPayload - info.nLocal + usableSize - 5)/(usableSize - 4); - pgnoOvfl = get4byte(&pCell[info.iOverflow]); + pgnoOvfl = get4byte(&pCell[info.nSize - 4]); #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->autoVacuum ){ checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage); diff --git a/src/btreeInt.h b/src/btreeInt.h index e43ff1210a..a196e18a28 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -470,7 +470,6 @@ struct CellInfo { u8 *pPayload; /* Pointer to the start of payload */ u32 nPayload; /* Bytes of payload */ u16 nLocal; /* Amount of payload held locally, not on overflow */ - u16 iOverflow; /* Offset to overflow page number. Zero if no overflow */ u16 nSize; /* Size of the cell content on the main b-tree page */ }; From d319b8c1438de286caa9a2aa74938bb788430111 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 18 Dec 2015 16:29:47 +0000 Subject: [PATCH 097/232] Micro-optimizations and comment fixes on the mem5.c memory allocator module. FossilOrigin-Name: 8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/mem5.c | 29 ++++++++++------------------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index 799ac619df..fa04e7372c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sspellfix1_scriptcode()\sfunction\sto\signore\swhitespace\sand\spunctuation,\nand\sto\srecognize\shebrew\sand\sarabic\sscripts. -D 2015-12-17T14:18:21.904 +C Micro-optimizations\sand\scomment\sfixes\son\sthe\smem5.c\smemory\sallocator\smodule. +D 2015-12-18T16:29:47.912 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -304,7 +304,7 @@ F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a -F src/mem5.c 5c267678ba9f745a2ee58102a9f482d64a58577a +F src/mem5.c 262055c242fa7db59c5f07ad77fdc4e97888c054 F src/memjournal.c 3eb2c0b51adbd869cb6a44780323f05fa904dc85 F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 85ebd46c701e0a094a4690cd8f1d0cbae9aa257c -R 70cdc580d7d9b92b032d33f5e0d50f2e +P 7adfa4a5794e47f97491c08abeaaac90e826b331 +R 1b3cde8c2a6658c08ed08e4868245c5a U drh -Z 6d4b5ed9cd1870281d7d851922f323d8 +Z 526b8930cb4e95afc320a389b1027b99 diff --git a/manifest.uuid b/manifest.uuid index eebc618153..51cf94b6da 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7adfa4a5794e47f97491c08abeaaac90e826b331 \ No newline at end of file +8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b \ No newline at end of file diff --git a/src/mem5.c b/src/mem5.c index b34a04e8b6..49bebca093 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -25,7 +25,7 @@ ** ** This memory allocator uses the following algorithm: ** -** 1. All memory allocations sizes are rounded up to a power of 2. +** 1. All memory allocation sizes are rounded up to a power of 2. ** ** 2. If two adjacent free blocks are the halves of a larger block, ** then the two blocks are coalesced into the single larger block. @@ -117,7 +117,7 @@ static SQLITE_WSD struct Mem5Global { /* ** Lists of free blocks. aiFreelist[0] is a list of free blocks of ** size mem5.szAtom. aiFreelist[1] holds blocks of size szAtom*2. - ** and so forth. + ** aiFreelist[2] holds free blocks of size szAtom*4. And so forth. */ int aiFreelist[LOGMAX+1]; @@ -183,9 +183,7 @@ static void memsys5Link(int i, int iLogsize){ } /* -** If the STATIC_MEM mutex is not already held, obtain it now. The mutex -** will already be held (obtained by code in malloc.c) if -** sqlite3GlobalConfig.bMemStat is true. +** Obtain or release the mutex needed to access global data structures. */ static void memsys5Enter(void){ sqlite3_mutex_enter(mem5.mutex); @@ -195,9 +193,8 @@ static void memsys5Leave(void){ } /* -** Return the size of an outstanding allocation, in bytes. The -** size returned omits the 8-byte header overhead. This only -** works for chunks that are currently checked out. +** Return the size of an outstanding allocation, in bytes. +** This only works for chunks that are currently checked out. */ static int memsys5Size(void *p){ int iSize, i; @@ -230,16 +227,12 @@ static void *memsys5MallocUnsafe(int nByte){ /* Keep track of the maximum allocation request. Even unfulfilled ** requests are counted */ if( (u32)nByte>mem5.maxRequest ){ + /* Abort if the requested allocation size is larger than the largest + ** power of two that we can represent using 32-bit signed integers. */ + if( nByte > 0x40000000 ) return 0; mem5.maxRequest = nByte; } - /* Abort if the requested allocation size is larger than the largest - ** power of two that we can represent using 32-bit signed integers. - */ - if( nByte > 0x40000000 ){ - return 0; - } - /* Round nByte up to the next valid power of two */ for(iFullSz=mem5.szAtom,iLogsize=0; iFullSz Date: Fri, 18 Dec 2015 19:07:14 +0000 Subject: [PATCH 098/232] Fix a problem with prefix queries on fts5 offsets=0 tables. FossilOrigin-Name: ad0987d83c252dd8d6a69321893629d7be805c28 --- ext/fts5/fts5_expr.c | 19 ++++++++++++++----- ext/fts5/fts5_index.c | 11 +++++++---- ext/fts5/test/fts5offsets.test | 12 +++++++++++- manifest | 19 ++++++++----------- manifest.uuid | 2 +- 5 files changed, 41 insertions(+), 22 deletions(-) diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index eb167b4407..b7bc13b289 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -1805,11 +1805,20 @@ Fts5ExprNode *sqlite3Fts5ParseNode( for(iPhrase=0; iPhrasenPhrase; iPhrase++){ pNear->apPhrase[iPhrase]->pNode = pRet; } - if( pNear->nPhrase==1 - && pNear->apPhrase[0]->nTerm==1 - && pNear->apPhrase[0]->aTerm[0].pSynonym==0 - ){ - pRet->eType = FTS5_TERM; + if( pNear->nPhrase==1 && pNear->apPhrase[0]->nTerm==1 ){ + if( pNear->apPhrase[0]->aTerm[0].pSynonym==0 ){ + pRet->eType = FTS5_TERM; + } + }else if( pParse->pConfig->bOffsets==0 ){ + assert( pParse->rc==SQLITE_OK ); + pParse->rc = SQLITE_ERROR; + assert( pParse->zErr==0 ); + pParse->zErr = sqlite3_mprintf( + "fts5: %s queries are not supported (offsets=0)", + pNear->nPhrase==1 ? "phrase": "NEAR" + ); + sqlite3_free(pRet); + pRet = 0; } }else{ fts5ExprAddChildren(pRet, pLeft); diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index bf765d0556..5aa87d500f 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4119,8 +4119,8 @@ static void fts5SegiterPoslist( PoslistCallbackCtx sCtx; sCtx.pBuf = pBuf; sCtx.pColset = pColset; - assert( sCtx.eState==0 || sCtx.eState==1 ); sCtx.eState = fts5IndexColsetTest(pColset, 0); + assert( sCtx.eState==0 || sCtx.eState==1 ); fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistFilterCallback); } } @@ -4192,8 +4192,8 @@ static int fts5AppendPoslist( assert( fts5MultiIterEof(p, pMulti)==0 ); assert( pSeg->nPos>0 ); if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+9+9) ){ - - if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf + if( p->pConfig->bOffsets + && pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf && (pColset==0 || pColset->nCol==1) ){ const u8 *pPos = &pSeg->pLeaf->p[pSeg->iLeafOffset]; @@ -4238,13 +4238,13 @@ static int fts5AppendPoslist( } } } - } } return 0; } + static void fts5DoclistIterNext(Fts5DoclistIter *pIter){ u8 *p = pIter->aPoslist + pIter->nSize + pIter->nPoslist; @@ -4390,6 +4390,9 @@ static void fts5MergePrefixLists( } } +/* +** Swap the contents of buffer *p1 with that of *p2. +*/ static void fts5BufferSwap(Fts5Buffer *p1, Fts5Buffer *p2){ Fts5Buffer tmp = *p1; *p1 = *p2; diff --git a/ext/fts5/test/fts5offsets.test b/ext/fts5/test/fts5offsets.test index cd9bfa0054..405824abf9 100644 --- a/ext/fts5/test/fts5offsets.test +++ b/ext/fts5/test/fts5offsets.test @@ -22,9 +22,11 @@ ifcapable !fts5 { } +#-------------------------------------------------------------------------- +# Simple tests. +# do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, offsets=0); - INSERT INTO t1 VALUES('h d g', 'j b b g b', 'i e i d h g g'); -- 1 INSERT INTO t1 VALUES('h j d', 'j h d a h', 'f d d g g f b'); -- 2 INSERT INTO t1 VALUES('j c i', 'f f h e f', 'c j i j c h f'); -- 3 @@ -55,5 +57,13 @@ foreach {tn match res} { } $res } +do_catchsql_test 1.3.1 { + SELECT rowid FROM t1('h + d'); +} {1 {fts5: phrase queries are not supported (offsets=0)}} + +do_catchsql_test 1.3.2 { + SELECT rowid FROM t1('NEAR(h d)'); +} {1 {fts5: NEAR queries are not supported (offsets=0)}} + finish_test diff --git a/manifest b/manifest index 8e1565e355..1beb3af7bd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"offsets=0"\soption\sto\sfts5,\sto\screate\sa\ssmaller\sindex\swithout\sterm\soffset\sinformation.\sA\sfew\sthings\sare\scurrently\sbroken\son\sthis\sbranch. -D 2015-12-17T20:36:13.853 +C Fix\sa\sproblem\swith\sprefix\squeries\son\sfts5\soffsets=0\stables. +D 2015-12-18T19:07:14.984 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -101,9 +101,9 @@ F ext/fts5/fts5Int.h 4e1bb66d8e607bf38e881eb455cdf36cc3fa9e42 F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 389d377d04f6e622644c3343ab5e511f6646de36 F ext/fts5/fts5_config.c ba5248a05c28ec6a6fdf2599a86e9fd67e5c61e2 -F ext/fts5/fts5_expr.c 80075fa45091bad42100c4a5c4f2efc83e43e3af +F ext/fts5/fts5_expr.c 3b2c7ac54e6c03e732751a6a4bf9ced8f408e2a2 F ext/fts5/fts5_hash.c d4a6b52faca0134cc7bcc880f03a257a0dec2636 -F ext/fts5/fts5_index.c 53b3a8f1c9c1f6e5e896b6dc0a7ad26c2eea23a2 +F ext/fts5/fts5_index.c d862dc84c54133d902893a6a7992699cd5272c48 F ext/fts5/fts5_main.c ef04699949ab8e42d590ae30188afef7ad58776e F ext/fts5/fts5_storage.c 0dc37a6183e1061e255f23971198d8878159d4ef F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd @@ -156,7 +156,7 @@ F ext/fts5/test/fts5integrity.test 87db5d4e7da0ce04a1dcba5ba91658673c997a65 F ext/fts5/test/fts5matchinfo.test 2163b0013e824bba65499da9e34ea4da41349cc2 F ext/fts5/test/fts5merge.test 8f3cdba2ec9c5e7e568246e81b700ad37f764367 F ext/fts5/test/fts5near.test b214cddb1c1f1bddf45c75af768f20145f7e71cc -F ext/fts5/test/fts5offsets.test 09fc61d553ae4e985afc0146ec77f3439503fc6b +F ext/fts5/test/fts5offsets.test 8410ec485d652da168c138b3d39e7418ff8406bf F ext/fts5/test/fts5onepass.test 7ed9608e258132cb8d55e7c479b08676ad68810c F ext/fts5/test/fts5optimize.test 42741e7c085ee0a1276140a752d4407d97c2c9f5 F ext/fts5/test/fts5phrase.test f6d1d464da5beb25dc56277aa4f1d6102f0d9a2f @@ -1406,10 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7adfa4a5794e47f97491c08abeaaac90e826b331 -R a68b4412544bee6f6bc95a23674c55d4 -T *branch * fts5-offsets -T *sym-fts5-offsets * -T -sym-trunk * +P 40b5bbf02a824ca73b33aa4ae1c7d5f65b7cda10 +R 3f45bfddac5bb4e5875c9115c2804e36 U dan -Z a51f39853c3a5371cd0ec3358f50f2d7 +Z 1ef5385fc9e0304197471eb155fb346c diff --git a/manifest.uuid b/manifest.uuid index b6243ea89e..af1abb33df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -40b5bbf02a824ca73b33aa4ae1c7d5f65b7cda10 \ No newline at end of file +ad0987d83c252dd8d6a69321893629d7be805c28 \ No newline at end of file From 1c75c9d7f16f5852c012f5fc8fce00840f72b308 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 21 Dec 2015 15:22:13 +0000 Subject: [PATCH 099/232] Ensure that the Expr objects that describe indexed expressions are not modified by code generation. Fix for an assert() problem found by Jon Metzman using AFL. FossilOrigin-Name: 34073ce87d88a02313217023ae92e15939192cd9 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/expr.c | 16 ++++++++++++++-- src/insert.c | 2 +- src/sqliteInt.h | 1 + test/indexexpr1.test | 16 ++++++++++++++++ 6 files changed, 42 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index fa04e7372c..e171b344af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Micro-optimizations\sand\scomment\sfixes\son\sthe\smem5.c\smemory\sallocator\smodule. -D 2015-12-18T16:29:47.912 +C Ensure\sthat\sthe\sExpr\sobjects\sthat\sdescribe\sindexed\sexpressions\sare\snot\smodified\nby\scode\sgeneration.\s\sFix\sfor\san\sassert()\sproblem\sfound\sby\sJon\sMetzman\susing\sAFL. +D 2015-12-21T15:22:13.811 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -286,7 +286,7 @@ F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c ccb93d7b7e1ac5d187c9b153bae145933f93ee5c +F src/expr.c 414f4c6b016c4494bfb11713da79f27966871d91 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 F src/func.c fe50a9ab977acc0bb0fcd46741e0071fa388888e @@ -294,7 +294,7 @@ F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c e1d20ae8979e25519c2670233718676bedcfedc9 +F src/insert.c 4622e544a6f054b8f36bb06ae85f4aa09fcd6b5b F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b @@ -338,7 +338,7 @@ F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h beb4a63b94428f52a3d7c7af2ba8bdc7d4682a03 +F src/sqliteInt.h 5a2770eb1fdf3542b9c5ac3fd87836f0d46e1b08 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -787,7 +787,7 @@ F test/index5.test 8621491915800ec274609e42e02a97d67e9b13e7 F test/index6.test 7102ec371414c42dfb1d5ca37eb4519aa9edc23a F test/index7.test 9c6765a74fc3fcde7aebc5b3bd40d98df14a527c F test/indexedby.test 9c4cd331224e57f79fbf411ae245e6272d415985 -F test/indexexpr1.test bbb52b5d5717d9f23853826963b0af5110009366 +F test/indexexpr1.test cb71b6586177b840e28110dd952178bb2bdfedc2 F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 F test/insert.test 38742b5e9601c8f8d76e9b7555f7270288c2d371 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7adfa4a5794e47f97491c08abeaaac90e826b331 -R 1b3cde8c2a6658c08ed08e4868245c5a +P 8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b +R e0404c0cd537e70ac5aa95195290d5e7 U drh -Z 526b8930cb4e95afc320a389b1027b99 +Z ae8c1424b866e12742c6a5c15035540f diff --git a/manifest.uuid b/manifest.uuid index 51cf94b6da..9837f3d4d4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b \ No newline at end of file +34073ce87d88a02313217023ae92e15939192cd9 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 8f6377e664..5c67de1297 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2468,7 +2468,7 @@ void sqlite3ExprCodeLoadIndexColumn( assert( pIdx->aColExpr ); assert( pIdx->aColExpr->nExpr>iIdxCol ); pParse->iSelfTab = iTabCur; - sqlite3ExprCode(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut); + sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut); }else{ sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur, iTabCol, regOut); @@ -3321,13 +3321,25 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){ sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target); }else{ inReg = sqlite3ExprCodeTarget(pParse, pExpr, target); - assert( pParse->pVdbe || pParse->db->mallocFailed ); + assert( pParse->pVdbe!=0 || pParse->db->mallocFailed ); if( inReg!=target && pParse->pVdbe ){ sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target); } } } +/* +** Make a transient copy of expression pExpr and then code it using +** sqlite3ExprCode(). This routine works just like sqlite3ExprCode() +** except that the input expression is guaranteed to be unchanged. +*/ +void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){ + sqlite3 *db = pParse->db; + pExpr = sqlite3ExprDup(db, pExpr, 0); + if( !db->mallocFailed ) sqlite3ExprCode(pParse, pExpr, target); + sqlite3ExprDelete(db, pExpr); +} + /* ** Generate code that will evaluate expression pExpr and store the ** results in register target. The results are guaranteed to appear diff --git a/src/insert.c b/src/insert.c index 52769e9c4f..7ac2a2559d 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1408,7 +1408,7 @@ void sqlite3GenerateConstraintChecks( int x; if( iField==XN_EXPR ){ pParse->ckBase = regNewData+1; - sqlite3ExprCode(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i); + sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i); pParse->ckBase = 0; VdbeComment((v, "%s column %d", pIdx->zName, i)); }else{ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4249ef768a..a328aff013 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3461,6 +3461,7 @@ void sqlite3ExprCacheRemove(Parse*, int, int); void sqlite3ExprCacheClear(Parse*); void sqlite3ExprCacheAffinityChange(Parse*, int, int); void sqlite3ExprCode(Parse*, Expr*, int); +void sqlite3ExprCodeCopy(Parse*, Expr*, int); void sqlite3ExprCodeFactorable(Parse*, Expr*, int); void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8); int sqlite3ExprCodeTemp(Parse*, Expr*, int*); diff --git a/test/indexexpr1.test b/test/indexexpr1.test index 89bea1877f..a8a74f259e 100644 --- a/test/indexexpr1.test +++ b/test/indexexpr1.test @@ -307,5 +307,21 @@ do_catchsql_test indexexpr1-910 { INSERT INTO t9(a,b,c,d) VALUES(5,6,7,-8); } {1 {UNIQUE constraint failed: index 't9x1'}} +# Test cases derived from a NEVER() maro failure discovered by +# Jonathan Metzman using AFL +# +do_execsql_test indexexpr1-1000 { + DROP TABLE IF EXISTS t0; + CREATE TABLE t0(a,b,t); + CREATE INDEX i ON t0(a in(0,1)); + INSERT INTO t0 VALUES(0,1,2),(2,3,4),(5,6,7); + UPDATE t0 SET b=99 WHERE (a in(0,1))=0; + SELECT *, '|' FROM t0 ORDER BY +a; +} {0 1 2 | 2 99 4 | 5 99 7 |} +do_execsql_test indexexpr1-1010 { + UPDATE t0 SET b=88 WHERE (a in(0,1))=1; + SELECT *, '|' FROM t0 ORDER BY +a; +} {0 88 2 | 2 99 4 | 5 99 7 |} + finish_test From 159fd77e0f6ea30171b64471036d73d721f1271a Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 21 Dec 2015 18:45:09 +0000 Subject: [PATCH 100/232] Fix an fts5 integrity-check problem that affects offsets=0 tables with prefix indexes. FossilOrigin-Name: 609a0bc7f34e6dae74ce756aff920f3df78fe828 --- ext/fts5/fts5Int.h | 2 +- ext/fts5/fts5_buffer.c | 57 ++++++++++++++++++++-------------- ext/fts5/fts5_index.c | 49 +++++++++-------------------- ext/fts5/fts5_storage.c | 41 +++++++++++++++++------- ext/fts5/test/fts5ad.test | 16 ++++++++++ ext/fts5/test/fts5auto.test | 1 - ext/fts5/test/fts5offsets.test | 16 +++++++++- ext/fts5/test/fts5simple.test | 12 ++++++- manifest | 26 ++++++++-------- manifest.uuid | 2 +- 10 files changed, 133 insertions(+), 89 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 436ae0712e..3016f4be04 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -297,7 +297,7 @@ int sqlite3Fts5IsBareword(char t); /* Bucket of terms object used by the integrity-check in offsets=0 mode. */ typedef struct Fts5Termset Fts5Termset; int sqlite3Fts5TermsetNew(Fts5Termset**); -int sqlite3Fts5TermsetAdd(Fts5Termset*, const char*, int, int *pbPresent); +int sqlite3Fts5TermsetAdd(Fts5Termset*, int, const char*, int, int *pbPresent); void sqlite3Fts5TermsetFree(Fts5Termset*); /* diff --git a/ext/fts5/fts5_buffer.c b/ext/fts5/fts5_buffer.c index 7e3e137996..251a543c5a 100644 --- a/ext/fts5/fts5_buffer.c +++ b/ext/fts5/fts5_buffer.c @@ -298,6 +298,7 @@ typedef struct Fts5TermsetEntry Fts5TermsetEntry; struct Fts5TermsetEntry { char *pTerm; int nTerm; + int iIdx; /* Index (main or aPrefix[] entry) */ Fts5TermsetEntry *pNext; }; @@ -313,36 +314,44 @@ int sqlite3Fts5TermsetNew(Fts5Termset **pp){ int sqlite3Fts5TermsetAdd( Fts5Termset *p, + int iIdx, const char *pTerm, int nTerm, int *pbPresent ){ int rc = SQLITE_OK; - int i; - int hash = 13; - Fts5TermsetEntry *pEntry; - - /* Calculate a hash value for this term */ - for(i=0; iapHash); - *pbPresent = 0; - for(pEntry=p->apHash[hash]; pEntry; pEntry=pEntry->pNext){ - if( pEntry->nTerm==nTerm && memcmp(pEntry->pTerm, pTerm, nTerm)==0 ){ - *pbPresent = 1; - break; - } - } + if( p ){ + int i; + int hash; + Fts5TermsetEntry *pEntry; - if( pEntry==0 ){ - pEntry = sqlite3Fts5MallocZero(&rc, sizeof(Fts5TermsetEntry) + nTerm); - if( pEntry ){ - pEntry->pTerm = (char*)&pEntry[1]; - pEntry->nTerm = nTerm; - memcpy(pEntry->pTerm, pTerm, nTerm); - pEntry->pNext = p->apHash[hash]; - p->apHash[hash] = pEntry; + /* Calculate a hash value for this term */ + hash = 104 + iIdx; + for(i=0; iapHash); + + for(pEntry=p->apHash[hash]; pEntry; pEntry=pEntry->pNext){ + if( pEntry->iIdx==iIdx + && pEntry->nTerm==nTerm + && memcmp(pEntry->pTerm, pTerm, nTerm)==0 + ){ + *pbPresent = 1; + break; + } + } + + if( pEntry==0 ){ + pEntry = sqlite3Fts5MallocZero(&rc, sizeof(Fts5TermsetEntry) + nTerm); + if( pEntry ){ + pEntry->pTerm = (char*)&pEntry[1]; + pEntry->nTerm = nTerm; + pEntry->iIdx = iIdx; + memcpy(pEntry->pTerm, pTerm, nTerm); + pEntry->pNext = p->apHash[hash]; + p->apHash[hash] = pEntry; + } } } diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 5aa87d500f..bcd81843b7 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4373,7 +4373,9 @@ static void fts5MergePrefixLists( sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1,&iPos1); } } - p->rc = sqlite3Fts5PoslistWriterAppend(&tmp, &writer, iNew); + if( iNew!=writer.iPrev || tmp.n==0 ){ + p->rc = sqlite3Fts5PoslistWriterAppend(&tmp, &writer, iNew); + } } /* WRITEPOSLISTSIZE */ @@ -4608,7 +4610,11 @@ int sqlite3Fts5IndexClose(Fts5Index *p){ ** size. Return the number of bytes in the nChar character prefix of the ** buffer, or 0 if there are less than nChar characters in total. */ -static int fts5IndexCharlenToBytelen(const char *p, int nByte, int nChar){ +static int sqlite3Fts5IndexCharlenToBytelen( + const char *p, + int nByte, + int nChar +){ int n = 0; int i; for(i=0; inPrefix && rc==SQLITE_OK; i++){ - int nByte = fts5IndexCharlenToBytelen(pToken, nToken, pConfig->aPrefix[i]); + const int nChar = pConfig->aPrefix[i]; + int nByte = sqlite3Fts5IndexCharlenToBytelen(pToken, nToken, nChar); if( nByte ){ rc = sqlite3Fts5HashWrite(p->pHash, p->iWriteRowid, iCol, iPos, (char)(FTS5_MAIN_PREFIX+i+1), pToken, @@ -4983,7 +4990,7 @@ int sqlite3Fts5IndexLoadConfig(Fts5Index *p){ /* ** Return a simple checksum value based on the arguments. */ -static u64 fts5IndexEntryCksum( +u64 sqlite3Fts5IndexEntryCksum( i64 iRowid, int iCol, int iPos, @@ -5071,7 +5078,7 @@ static int fts5QueryCksum( ){ int iCol = FTS5_POS2COLUMN(sReader.iPos); int iOff = FTS5_POS2OFFSET(sReader.iPos); - cksum ^= fts5IndexEntryCksum(rowid, iCol, iOff, iIdx, z, n); + cksum ^= sqlite3Fts5IndexEntryCksum(rowid, iCol, iOff, iIdx, z, n); } rc = sqlite3Fts5IterNext(pIdxIter); } @@ -5370,7 +5377,7 @@ static void fts5IndexIntegrityCheckSegment( /* ** Run internal checks to ensure that the FTS index (a) is internally ** consistent and (b) contains entries for which the XOR of the checksums -** as calculated by fts5IndexEntryCksum() is cksum. +** as calculated by sqlite3Fts5IndexEntryCksum() is cksum. ** ** Return SQLITE_CORRUPT if any of the internal checks fail, or if the ** checksum does not match. Return SQLITE_OK if all checks pass without @@ -5434,7 +5441,7 @@ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ while( 0==sqlite3Fts5PoslistNext64(poslist.p, poslist.n, &iOff, &iPos) ){ int iCol = FTS5_POS2COLUMN(iPos); int iTokOff = FTS5_POS2OFFSET(iPos); - cksum2 ^= fts5IndexEntryCksum(iRowid, iCol, iTokOff, -1, z, n); + cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, iCol, iTokOff, -1, z, n); } } fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3); @@ -5450,34 +5457,6 @@ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ return fts5IndexReturn(p); } - -/* -** Calculate and return a checksum that is the XOR of the index entry -** checksum of all entries that would be generated by the token specified -** by the final 5 arguments. -*/ -u64 sqlite3Fts5IndexCksum( - Fts5Config *pConfig, /* Configuration object */ - i64 iRowid, /* Document term appears in */ - int iCol, /* Column term appears in */ - int iPos, /* Position term appears in */ - const char *pTerm, int nTerm /* Term at iPos */ -){ - u64 ret = 0; /* Return value */ - int iIdx; /* For iterating through indexes */ - - ret = fts5IndexEntryCksum(iRowid, iCol, iPos, 0, pTerm, nTerm); - - for(iIdx=0; iIdxnPrefix; iIdx++){ - int nByte = fts5IndexCharlenToBytelen(pTerm, nTerm, pConfig->aPrefix[iIdx]); - if( nByte ){ - ret ^= fts5IndexEntryCksum(iRowid, iCol, iPos, iIdx+1, pTerm, nByte); - } - } - - return ret; -} - /************************************************************************* ************************************************************************** ** Below this point is the implementation of the fts5_decode() scalar diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index c84b213fdf..65429edbd9 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -829,6 +829,7 @@ struct Fts5IntegrityCtx { Fts5Config *pConfig; }; + /* ** Tokenization callback used by integrity check. */ @@ -840,25 +841,41 @@ static int fts5StorageIntegrityCallback( int iStart, /* Start offset of token */ int iEnd /* End offset of token */ ){ - int rc = SQLITE_OK; Fts5IntegrityCtx *pCtx = (Fts5IntegrityCtx*)pContext; + Fts5Termset *pTermset = pCtx->pTermset; + int bPresent; + int ii; + int rc = SQLITE_OK; + int iPos; + int iCol; + if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){ pCtx->szCol++; } - if( pCtx->pTermset ){ - int bPresent = 0; - rc = sqlite3Fts5TermsetAdd(pCtx->pTermset, pToken, nToken, &bPresent); - if( rc==SQLITE_OK && bPresent==0 ){ - pCtx->cksum ^= sqlite3Fts5IndexCksum( - pCtx->pConfig, pCtx->iRowid, 0, pCtx->iCol, pToken, nToken - ); - } - }else{ - pCtx->cksum ^= sqlite3Fts5IndexCksum( - pCtx->pConfig, pCtx->iRowid, pCtx->iCol, pCtx->szCol-1, pToken, nToken + iPos = pTermset ? pCtx->iCol : pCtx->szCol-1; + iCol = pTermset ? 0 : pCtx->iCol; + + rc = sqlite3Fts5TermsetAdd(pTermset, 0, pToken, nToken, &bPresent); + if( rc==SQLITE_OK && bPresent==0 ){ + pCtx->cksum ^= sqlite3Fts5IndexEntryCksum( + pCtx->iRowid, iCol, iPos, 0, pToken, nToken ); } + + for(ii=0; rc==SQLITE_OK && iipConfig->nPrefix; ii++){ + const int nChar = pCtx->pConfig->aPrefix[ii]; + int nByte = sqlite3Fts5IndexCharlenToBytelen(pToken, nToken, nChar); + if( nByte ){ + rc = sqlite3Fts5TermsetAdd(pTermset, ii+1, pToken, nByte, &bPresent); + if( bPresent==0 ){ + pCtx->cksum ^= sqlite3Fts5IndexEntryCksum( + pCtx->iRowid, iCol, iPos, ii+1, pToken, nByte + ); + } + } + } + return rc; } diff --git a/ext/fts5/test/fts5ad.test b/ext/fts5/test/fts5ad.test index 3881c7e161..a9fc568133 100644 --- a/ext/fts5/test/fts5ad.test +++ b/ext/fts5/test/fts5ad.test @@ -74,6 +74,22 @@ foreach {T create} { BEGIN; } + 6 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b, offsets=0); + INSERT INTO t1(t1, rank) VALUES('pgsz', 32); + } + + 7 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b, offsets=0, prefix="1,2,3,4,5"); + INSERT INTO t1(t1, rank) VALUES('pgsz', 32); + } + + 8 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b, offsets=0, prefix="1,2,3,4,5"); + INSERT INTO t1(t1, rank) VALUES('pgsz', 32); + BEGIN; + } + } { do_test $T.1 { diff --git a/ext/fts5/test/fts5auto.test b/ext/fts5/test/fts5auto.test index 771a0b64d8..6efaa9cb7c 100644 --- a/ext/fts5/test/fts5auto.test +++ b/ext/fts5/test/fts5auto.test @@ -369,7 +369,6 @@ foreach {tn expr} { } { -breakpoint do_auto_test 4.$tn yy {c1 c2 c3} $expr } diff --git a/ext/fts5/test/fts5offsets.test b/ext/fts5/test/fts5offsets.test index 405824abf9..b70bee3b53 100644 --- a/ext/fts5/test/fts5offsets.test +++ b/ext/fts5/test/fts5offsets.test @@ -21,7 +21,6 @@ ifcapable !fts5 { return } - #-------------------------------------------------------------------------- # Simple tests. # @@ -65,5 +64,20 @@ do_catchsql_test 1.3.2 { SELECT rowid FROM t1('NEAR(h d)'); } {1 {fts5: NEAR queries are not supported (offsets=0)}} +#------------------------------------------------------------------------- +# integrity-check with both offsets= and prefix= options. +# +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE t2 USING fts5(a, offsets=0, prefix="1"); + INSERT INTO t2(a) VALUES('aa ab'); +} + +#db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM t2_data} {puts $r} + +breakpoint +do_execsql_test 2.1 { + INSERT INTO t2(t2) VALUES('integrity-check'); +} + finish_test diff --git a/ext/fts5/test/fts5simple.test b/ext/fts5/test/fts5simple.test index 27a1aee08b..870a912bb1 100644 --- a/ext/fts5/test/fts5simple.test +++ b/ext/fts5/test/fts5simple.test @@ -18,7 +18,7 @@ ifcapable !fts5 { finish_test return } - + #------------------------------------------------------------------------- # set doc "x x [string repeat {y } 50]z z" @@ -350,6 +350,16 @@ do_execsql_test 4.1 { SELECT rowid, x, x1 FROM x1 WHERE x1 MATCH '*reads' } {0 {} 4} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 15.0 { + CREATE VIRTUAL TABLE x2 USING fts5(x, prefix=1); + INSERT INTO x2 VALUES('ab'); +} + +do_execsql_test 15.1 { + INSERT INTO x2(x2) VALUES('integrity-check'); +} finish_test diff --git a/manifest b/manifest index 1beb3af7bd..34b04180c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sprefix\squeries\son\sfts5\soffsets=0\stables. -D 2015-12-18T19:07:14.984 +C Fix\san\sfts5\sintegrity-check\sproblem\sthat\saffects\soffsets=0\stables\swith\sprefix\sindexes. +D 2015-12-21T18:45:09.329 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -97,15 +97,15 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 8b9a13b309b180e9fb88ea5666c0d8d73c6102d9 -F ext/fts5/fts5Int.h 4e1bb66d8e607bf38e881eb455cdf36cc3fa9e42 +F ext/fts5/fts5Int.h e71739ed0b816758f1f77baaccca1b4a9064c4dc F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 -F ext/fts5/fts5_buffer.c 389d377d04f6e622644c3343ab5e511f6646de36 +F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c ba5248a05c28ec6a6fdf2599a86e9fd67e5c61e2 F ext/fts5/fts5_expr.c 3b2c7ac54e6c03e732751a6a4bf9ced8f408e2a2 F ext/fts5/fts5_hash.c d4a6b52faca0134cc7bcc880f03a257a0dec2636 -F ext/fts5/fts5_index.c d862dc84c54133d902893a6a7992699cd5272c48 +F ext/fts5/fts5_index.c 1d1939afbc434907993d7e9a0c631be630d5b0dc F ext/fts5/fts5_main.c ef04699949ab8e42d590ae30188afef7ad58776e -F ext/fts5/fts5_storage.c 0dc37a6183e1061e255f23971198d8878159d4ef +F ext/fts5/fts5_storage.c 14e0bb6549a66da54adf4fa1564edbf24647cb22 F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf F ext/fts5/fts5_tokenize.c 618efe033bceb80c521b1e9ddfd9fee85fb5946e @@ -118,7 +118,7 @@ F ext/fts5/test/fts5_common.tcl 51f7ef3af444b89c6f6ce3896a0ac349ff4e996d F ext/fts5/test/fts5aa.test 2c553eea4dab4bc5a75928f56729277c7bc1d206 F ext/fts5/test/fts5ab.test 6fe3a56731d15978afbb74ae51b355fc9310f2ad F ext/fts5/test/fts5ac.test 9737992d08c56bfd4803e933744d2d764e23795c -F ext/fts5/test/fts5ad.test e3dfb150fce971b4fd832498c29f56924d451b63 +F ext/fts5/test/fts5ad.test 21d87b12c7ec83b4ec48816d24503443dffb10a1 F ext/fts5/test/fts5ae.test 0a9984fc3479f89f8c63d9848d6ed0c465dfcebe F ext/fts5/test/fts5af.test c2501ec2b61d6b179c305f5d2b8782ab3d4f832a F ext/fts5/test/fts5ag.test ec3e119b728196620a31507ef503c455a7a73505 @@ -128,7 +128,7 @@ F ext/fts5/test/fts5aj.test 05b569f5c16ea3098fb1984eec5cf50dbdaae5d8 F ext/fts5/test/fts5ak.test 7b8c5df96df599293f920b7e5521ebc79f647592 F ext/fts5/test/fts5al.test a1b7b6393376bc2adc216527a28f5ae5594069df F ext/fts5/test/fts5alter.test 6022c61467a82aa11c70822ccad22b328dcf0d04 -F ext/fts5/test/fts5auto.test caa5bcf917db11944655a2a9bd38c67c520376ca +F ext/fts5/test/fts5auto.test 2a6241673657b340427f521528f7809ddaa02a9e F ext/fts5/test/fts5aux.test 8c687c948cc98e9a94be014df7d518acc1b3b74f F ext/fts5/test/fts5auxdata.test 141a7cbffcceb1bd2799b4b29c183ff8780d586e F ext/fts5/test/fts5bigpl.test 04ee0d7eebbebf17c31f5a0b5c5f9494eac3a0cb @@ -156,7 +156,7 @@ F ext/fts5/test/fts5integrity.test 87db5d4e7da0ce04a1dcba5ba91658673c997a65 F ext/fts5/test/fts5matchinfo.test 2163b0013e824bba65499da9e34ea4da41349cc2 F ext/fts5/test/fts5merge.test 8f3cdba2ec9c5e7e568246e81b700ad37f764367 F ext/fts5/test/fts5near.test b214cddb1c1f1bddf45c75af768f20145f7e71cc -F ext/fts5/test/fts5offsets.test 8410ec485d652da168c138b3d39e7418ff8406bf +F ext/fts5/test/fts5offsets.test 1a2d53c34a896d2038b839df2178410c45977671 F ext/fts5/test/fts5onepass.test 7ed9608e258132cb8d55e7c479b08676ad68810c F ext/fts5/test/fts5optimize.test 42741e7c085ee0a1276140a752d4407d97c2c9f5 F ext/fts5/test/fts5phrase.test f6d1d464da5beb25dc56277aa4f1d6102f0d9a2f @@ -169,7 +169,7 @@ F ext/fts5/test/fts5rank.test 7e9e64eac7245637f6f2033aec4b292aaf611aab F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 -F ext/fts5/test/fts5simple.test 9bded45827b4ab8933c87b7b3bcc3cd47f7378a4 +F ext/fts5/test/fts5simple.test a599b7577bc3827a9a678add3b43d8b818b93456 F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 F ext/fts5/test/fts5unicode.test fbef8d8a3b4b88470536cc57604a82ca52e51841 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 40b5bbf02a824ca73b33aa4ae1c7d5f65b7cda10 -R 3f45bfddac5bb4e5875c9115c2804e36 +P ad0987d83c252dd8d6a69321893629d7be805c28 +R f519655f5c64b0aca45be5b21174cea1 U dan -Z 1ef5385fc9e0304197471eb155fb346c +Z 77d1a35391efdb0fe1eff3fc97431cfb diff --git a/manifest.uuid b/manifest.uuid index af1abb33df..32831e991d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ad0987d83c252dd8d6a69321893629d7be805c28 \ No newline at end of file +609a0bc7f34e6dae74ce756aff920f3df78fe828 \ No newline at end of file From 8f9ced636f61773bc67a1405d3ed89b1d22356fb Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 22 Dec 2015 18:54:16 +0000 Subject: [PATCH 101/232] Updates so that fts5 API functions xInst, xPhraseFirst and xPhraseNext work with the offsets=0 option. FossilOrigin-Name: 69bffc1632c8a8f3bfe5bf92607e64fed982e48c --- ext/fts5/fts5.h | 10 +++- ext/fts5/fts5_main.c | 16 +++++++ ext/fts5/fts5_tcl.c | 31 +++++++++++++ ext/fts5/fts5_test_mi.c | 2 +- ext/fts5/test/fts5_common.tcl | 13 ++++++ ext/fts5/test/fts5offsets.test | 85 +++++++++++++++++++++++++++++++++- manifest | 22 ++++----- manifest.uuid | 2 +- 8 files changed, 165 insertions(+), 16 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index 5f528af793..400b7c7885 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -110,6 +110,12 @@ struct Fts5PhraseIter { ** should be greater than or equal to zero and smaller than the value ** output by xInstCount(). ** +** Usually, output parameter *piPhrase is set to the phrase number, *piCol +** to the column in which it occurs and *piOff the token offset of the +** first token of the phrase. The exception is if the table was created +** with the offsets=0 option specified. In this case *piOff is always +** set to -1. +** ** Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) ** if an error occurs. ** @@ -196,7 +202,7 @@ struct Fts5PhraseIter { ** Fts5PhraseIter iter; ** int iCol, iOff; ** for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff); -** iOff>=0; +** iCol>=0; ** pApi->xPhraseNext(pFts, &iter, &iCol, &iOff) ** ){ ** // An instance of phrase iPhrase at offset iOff of column iCol @@ -210,7 +216,7 @@ struct Fts5PhraseIter { ** See xPhraseFirst above. */ struct Fts5ExtensionApi { - int iVersion; /* Currently always set to 1 */ + int iVersion; /* Currently always set to 2 */ void *(*xUserData)(Fts5Context*); diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index cf2c748c4c..1d0b4c219e 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -309,6 +309,13 @@ static int fts5IsContentless(Fts5Table *pTab){ return pTab->pConfig->eContent==FTS5_CONTENT_NONE; } +/* +** Return true if pTab is an offsetless table. +*/ +static int fts5IsOffsetless(Fts5Table *pTab){ + return pTab->pConfig->bOffsets==0; +} + /* ** Delete a virtual table handle allocated by fts5InitVtab(). */ @@ -1749,6 +1756,10 @@ static int fts5ApiInst( ){ if( iIdx<0 || iIdx>=pCsr->nInstCount ){ rc = SQLITE_RANGE; + }else if( fts5IsOffsetless((Fts5Table*)pCsr->base.pVtab) ){ + *piPhrase = pCsr->aInst[iIdx*3]; + *piCol = pCsr->aInst[iIdx*3 + 2]; + *piOff = -1; }else{ *piPhrase = pCsr->aInst[iIdx*3]; *piCol = pCsr->aInst[iIdx*3 + 1]; @@ -1914,6 +1925,11 @@ static void fts5ApiPhraseNext( if( pIter->a>=pIter->b ){ *piCol = -1; *piOff = -1; + }else if( fts5IsOffsetless((Fts5Table*)(((Fts5Cursor*)pCtx)->base.pVtab)) ){ + int iVal; + pIter->a += fts5GetVarint32(pIter->a, iVal); + *piCol += (iVal-2); + *piOff = -1; }else{ int iVal; pIter->a += fts5GetVarint32(pIter->a, iVal); diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index b470c557d3..bf815eab81 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -235,6 +235,7 @@ static int xF5tApi( { "xGetAuxdata", 1, "CLEAR" }, /* 13 */ { "xSetAuxdataInt", 1, "INTEGER" }, /* 14 */ { "xGetAuxdataInt", 1, "CLEAR" }, /* 15 */ + { "xPhraseForeach", 4, "IPHRASE COLVAR OFFVAR SCRIPT" }, /* 16 */ { 0, 0, 0} }; @@ -431,6 +432,36 @@ static int xF5tApi( break; } + CASE(16, "xPhraseForeach") { + int iPhrase; + int iCol; + int iOff; + const char *zColvar; + const char *zOffvar; + Tcl_Obj *pScript = objv[5]; + Fts5PhraseIter iter; + + if( Tcl_GetIntFromObj(interp, objv[2], &iPhrase) ) return TCL_ERROR; + zColvar = Tcl_GetString(objv[3]); + zOffvar = Tcl_GetString(objv[4]); + + for(p->pApi->xPhraseFirst(p->pFts, iPhrase, &iter, &iCol, &iOff); + iCol>=0; + p->pApi->xPhraseNext(p->pFts, &iter, &iCol, &iOff) + ){ + Tcl_SetVar2Ex(interp, zColvar, 0, Tcl_NewIntObj(iCol), 0); + Tcl_SetVar2Ex(interp, zOffvar, 0, Tcl_NewIntObj(iOff), 0); + rc = Tcl_EvalObjEx(interp, pScript, 0); + if( rc==TCL_CONTINUE ) rc = TCL_OK; + if( rc!=TCL_OK ){ + if( rc==TCL_BREAK ) rc = TCL_OK; + break; + } + } + + break; + } + default: assert( 0 ); break; diff --git a/ext/fts5/fts5_test_mi.c b/ext/fts5/fts5_test_mi.c index 355f23330d..fb4a2102b4 100644 --- a/ext/fts5/fts5_test_mi.c +++ b/ext/fts5/fts5_test_mi.c @@ -134,7 +134,7 @@ static int fts5MatchinfoXCb( int iPrev = -1; for(pApi->xPhraseFirst(pFts, 0, &iter, &iCol, &iOff); - iOff>=0; + iCol>=0; pApi->xPhraseNext(pFts, &iter, &iCol, &iOff) ){ aOut[iCol*3+1]++; diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index 2c64b3b9a4..74e84ab234 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -28,6 +28,18 @@ proc fts5_test_poslist {cmd} { set res } +proc fts5_test_poslist2 {cmd} { + set res [list] + + for {set i 0} {$i < [$cmd xPhraseCount]} {incr i} { + $cmd xPhraseForeach $i c o { + lappend res $i.$c.$o + } + } + + set res +} + proc fts5_test_columnsize {cmd} { set res [list] for {set i 0} {$i < [$cmd xColumnCount]} {incr i} { @@ -113,6 +125,7 @@ proc fts5_aux_test_functions {db} { fts5_test_columntext fts5_test_columntotalsize fts5_test_poslist + fts5_test_poslist2 fts5_test_tokenize fts5_test_rowcount fts5_test_all diff --git a/ext/fts5/test/fts5offsets.test b/ext/fts5/test/fts5offsets.test index b70bee3b53..2f2674fabe 100644 --- a/ext/fts5/test/fts5offsets.test +++ b/ext/fts5/test/fts5offsets.test @@ -74,10 +74,93 @@ do_execsql_test 2.0 { #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM t2_data} {puts $r} -breakpoint do_execsql_test 2.1 { INSERT INTO t2(t2) VALUES('integrity-check'); } +#------------------------------------------------------------------------- +# Check that the xInstCount, xInst, xPhraseFirst and xPhraseNext APIs +# work with offsets=0 tables. +# +set data { + 1 {abb aca aca} {aba bab aab aac caa} {abc cbc ccb bcc bab ccb aca} + 2 {bca aca acb} {ccb bcc bca aab bcc} {bab aaa aac cbb bba aca abc} + 3 {cca abc cab} {aab aba bcc cac baa} {bab cbb acb aba aab ccc cca} + 4 {ccb bcb aba} {aba bbb bcc cac bbb} {cbb aaa bca bcc aab cac aca} + 5 {bca bbc cac} {aba cbb cac cca aca} {cab acb cbc ccb cac bbb bcb} + 6 {acc bba cba} {bab bbc bbb bcb aca} {bca ccc cbb aca bac ccc ccb} + 7 {aba bab aaa} {abb bca aac bcb bcc} {bcb bbc aba aaa cba abc acc} + 8 {cab aba aaa} {ccb aca caa bbc bcc} {aaa abc ccb bbb cac cca abb} + 9 {bcb bab bac} {bcb cba cac bbb abc} {aba aca cbb acb abb ccc ccb} + 10 {aba aab ccc} {abc ccc bcc cab bbb} {aab bcc cbb ccc aaa bac baa} + 11 {bab acb cba} {aac cab cab bca cbc} {aab cbc aac baa ccb acc cac} + 12 {ccc cbb cbc} {aaa aab bcc aac bbc} {cbc cbc bac bac ccc bbc acc} + 13 {cab bbc abc} {bbb bab bba aca bab} {baa bbb aab bbb ccb bbb ccc} + 14 {bbc cab caa} {acb aac abb cba acc} {cba bba bba acb abc abb baa} + 15 {aba cca bcc} {aaa acb abc aab ccb} {cca bcb acc aaa caa cca cbc} + 16 {bcb bba aba} {cbc acb cab caa ccb} {aac aaa bbc cab cca cba abc} + 17 {caa cbb acc} {ccb bcb bca aaa bcc} {bbb aca bcb bca cbc cbc cca} + 18 {cbb bbc aac} {ccc bbc aaa aab baa} {cab cab cac cca bbc abc bbc} + 19 {ccc acc aaa} {aab cbb bca cca caa} {bcb aca aca cab acc bac bcc} + 20 {aab ccc bcb} {bbc cbb bbc aaa bcc} {cbc aab ccc aaa bcb bac cbc} + 21 {aba cab ccc} {bbc cbc cba acc bbb} {acc aab aac acb aca bca acb} + 22 {bcb bca baa} {cca bbc aca ccb cbb} {aab abc bbc aaa cab bcc bcc} + 23 {cac cbb caa} {bbc aba bbb bcc ccb} {bbc bbb cab bbc cac abb acc} + 24 {ccb acb caa} {cab bba cac bbc aac} {aac bca abc cab bca cab bcb} + 25 {bbb aca bca} {bcb acc ccc cac aca} {ccc acb acc cac cac bba bbc} + 26 {bab acc caa} {caa cab cac bac aca} {aba cac caa acc bac ccc aaa} + 27 {bca bca aaa} {ccb aca bca aaa baa} {bab acc aaa cca cba cca bac} + 28 {ccb cac cac} {bca abb bba bbc baa} {aca ccb aac cab ccc cab caa} + 29 {abc bca cab} {cac cbc cbb ccc bcc} {bcc aaa aaa acc aac cac aac} + 30 {aca acc acb} {aab aac cbb caa acb} {acb bbc bbc acc cbb bbc aac} + 31 {aba aca baa} {aca bcc cab bab acb} {bcc acb baa bcb bbc acc aba} + 32 {abb cbc caa} {cba abb bbb cbb aca} {bac aca caa cac caa ccb bbc} + 33 {bcc bcb bcb} {cca cab cbc abb bab} {caa bbc aac bbb cab cba aaa} + 34 {caa cab acc} {ccc ccc bcc acb bcc} {bac bba aca bcb bba bcb cac} + 35 {bac bcb cba} {bcc acb bbc cba bab} {abb cbb abc abc bac acc cbb} + 36 {cab bab ccb} {bca bba bab cca acc} {acc aab bcc bac acb cbb caa} + 37 {aca cbc cab} {bba aac aca aac aaa} {baa cbb cba aba cab bca bcb} + 38 {acb aab baa} {baa bab bca bbc bbb} {abc baa acc aba cab baa cac} + 39 {bcb aac cba} {bcb baa caa cac bbc} {cbc ccc bab ccb bbb caa aba} + 40 {cba ccb abc} {cbb caa cba aac bab} {cbb bbb bca bbb bac cac bca} +} +foreach {tn tbl} { + 1 { CREATE VIRTUAL TABLE t3 USING fts5(x, y, z, offsets=0) } +} { + reset_db + fts5_aux_test_functions db + execsql $tbl + foreach {id x y z} $data { + execsql { INSERT INTO t3(rowid, x, y, z) VALUES($id, $x, $y, $z) } + } + foreach {tn2 expr} { + 1 aaa 2 ccc 3 bab 4 aac + 5 aa* 6 cc* 7 ba* 8 aa* + 9 a* 10 b* 11 c* + } { + + set res [list] + foreach {id x y z} $data { + if {[lsearch [concat $x $y $z] $expr]>=0} { + lappend res $id + set inst [list] + if {[lsearch $x $expr]>=0} { lappend inst 0.0.-1 } + if {[lsearch $y $expr]>=0} { lappend inst 0.1.-1 } + if {[lsearch $z $expr]>=0} { lappend inst 0.2.-1 } + lappend res $inst + } + } + + do_execsql_test 3.$tn.$tn2.1 { + SELECT rowid, fts5_test_poslist(t3) FROM t3($expr) + } $res + + do_execsql_test 3.$tn.$tn2.2 { + SELECT rowid, fts5_test_poslist2(t3) FROM t3($expr) + } $res + } + +} + finish_test diff --git a/manifest b/manifest index 34b04180c1..d02d515584 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sfts5\sintegrity-check\sproblem\sthat\saffects\soffsets=0\stables\swith\sprefix\sindexes. -D 2015-12-21T18:45:09.329 +C Updates\sso\sthat\sfts5\sAPI\sfunctions\sxInst,\sxPhraseFirst\sand\sxPhraseNext\swork\swith\sthe\soffsets=0\soption. +D 2015-12-22T18:54:16.763 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -96,7 +96,7 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 -F ext/fts5/fts5.h 8b9a13b309b180e9fb88ea5666c0d8d73c6102d9 +F ext/fts5/fts5.h 7d6785c75afe23239dad9cbaffc6fc55803feb4b F ext/fts5/fts5Int.h e71739ed0b816758f1f77baaccca1b4a9064c4dc F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 @@ -104,17 +104,17 @@ F ext/fts5/fts5_config.c ba5248a05c28ec6a6fdf2599a86e9fd67e5c61e2 F ext/fts5/fts5_expr.c 3b2c7ac54e6c03e732751a6a4bf9ced8f408e2a2 F ext/fts5/fts5_hash.c d4a6b52faca0134cc7bcc880f03a257a0dec2636 F ext/fts5/fts5_index.c 1d1939afbc434907993d7e9a0c631be630d5b0dc -F ext/fts5/fts5_main.c ef04699949ab8e42d590ae30188afef7ad58776e +F ext/fts5/fts5_main.c b7d6540c63f347908d8ee937ca8a7987130c84b3 F ext/fts5/fts5_storage.c 14e0bb6549a66da54adf4fa1564edbf24647cb22 -F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd -F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf +F ext/fts5/fts5_tcl.c c3cfff5f727b3d02f73c5717413d637b18b960f2 +F ext/fts5/fts5_test_mi.c c9c8cf455c49ded156a234e0de1c8ba9be85e5c3 F ext/fts5/fts5_tokenize.c 618efe033bceb80c521b1e9ddfd9fee85fb5946e F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl 51f7ef3af444b89c6f6ce3896a0ac349ff4e996d +F ext/fts5/test/fts5_common.tcl 4a23a75f31dbb96c03c2840fae1bf85b4f64f062 F ext/fts5/test/fts5aa.test 2c553eea4dab4bc5a75928f56729277c7bc1d206 F ext/fts5/test/fts5ab.test 6fe3a56731d15978afbb74ae51b355fc9310f2ad F ext/fts5/test/fts5ac.test 9737992d08c56bfd4803e933744d2d764e23795c @@ -156,7 +156,7 @@ F ext/fts5/test/fts5integrity.test 87db5d4e7da0ce04a1dcba5ba91658673c997a65 F ext/fts5/test/fts5matchinfo.test 2163b0013e824bba65499da9e34ea4da41349cc2 F ext/fts5/test/fts5merge.test 8f3cdba2ec9c5e7e568246e81b700ad37f764367 F ext/fts5/test/fts5near.test b214cddb1c1f1bddf45c75af768f20145f7e71cc -F ext/fts5/test/fts5offsets.test 1a2d53c34a896d2038b839df2178410c45977671 +F ext/fts5/test/fts5offsets.test 7d32df518f6513131c14ce985006c3ac5873e79f F ext/fts5/test/fts5onepass.test 7ed9608e258132cb8d55e7c479b08676ad68810c F ext/fts5/test/fts5optimize.test 42741e7c085ee0a1276140a752d4407d97c2c9f5 F ext/fts5/test/fts5phrase.test f6d1d464da5beb25dc56277aa4f1d6102f0d9a2f @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ad0987d83c252dd8d6a69321893629d7be805c28 -R f519655f5c64b0aca45be5b21174cea1 +P 609a0bc7f34e6dae74ce756aff920f3df78fe828 +R 3d59533357e77f6a30434e9a4ea67f85 U dan -Z 77d1a35391efdb0fe1eff3fc97431cfb +Z ae770209a83bcb452cb39fda88b8ef75 diff --git a/manifest.uuid b/manifest.uuid index 32831e991d..07c12c4bf0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -609a0bc7f34e6dae74ce756aff920f3df78fe828 \ No newline at end of file +69bffc1632c8a8f3bfe5bf92607e64fed982e48c \ No newline at end of file From caeca516a7df7ca63e662006f34a1b968a20b369 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 23 Dec 2015 10:54:48 +0000 Subject: [PATCH 102/232] Enhance the 'utc' modifier on date/time functions so that if the LHS is already known to be in UTC, the modifier becomes a no-op. This is not an incompatibility because the behavior is documented as "undefined" in that scenario. FossilOrigin-Name: b910a3d53769689d9212a06f974ccce54844bbe4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/date.c | 21 ++++++++++++++------- test/date.test | 9 +++++++++ 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index e171b344af..078eaef167 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthe\sExpr\sobjects\sthat\sdescribe\sindexed\sexpressions\sare\snot\smodified\nby\scode\sgeneration.\s\sFix\sfor\san\sassert()\sproblem\sfound\sby\sJon\sMetzman\susing\sAFL. -D 2015-12-21T15:22:13.811 +C Enhance\sthe\s'utc'\smodifier\son\sdate/time\sfunctions\sso\sthat\sif\sthe\sLHS\sis\nalready\sknown\sto\sbe\sin\sUTC,\sthe\smodifier\sbecomes\sa\sno-op.\s\sThis\sis\snot\san\nincompatibility\sbecause\sthe\sbehavior\sis\sdocumented\sas\s"undefined"\sin\sthat\nscenario. +D 2015-12-23T10:54:48.693 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -283,7 +283,7 @@ F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 -F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 +F src/date.c e4655393bb403fa310eef66cc4583d75d4d7fd93 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c 414f4c6b016c4494bfb11713da79f27966871d91 @@ -563,7 +563,7 @@ F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 432811b62bd5ffb812729f49bba3b9ad687550bb -F test/date.test 42973251b9429f2c41b77eb98a7b0b0ba2d3b2c0 +F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 F test/dbstatus2.test 10418e62b3db5dca070f0c3eef3ea13946f339c2 F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b -R e0404c0cd537e70ac5aa95195290d5e7 +P 34073ce87d88a02313217023ae92e15939192cd9 +R fb37875a5634d72cf8280c2958a6e17e U drh -Z ae8c1424b866e12742c6a5c15035540f +Z 5e4e9bf785bd86d0086510037196235b diff --git a/manifest.uuid b/manifest.uuid index 9837f3d4d4..c74bd62134 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -34073ce87d88a02313217023ae92e15939192cd9 \ No newline at end of file +b910a3d53769689d9212a06f974ccce54844bbe4 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 8a66eae900..3d7604ab45 100644 --- a/src/date.c +++ b/src/date.c @@ -65,6 +65,7 @@ struct DateTime { char validHMS; /* True (1) if h,m,s are valid */ char validJD; /* True (1) if iJD is valid */ char validTZ; /* True (1) if tz is valid */ + char tzSet; /* Timezone was set explicitly */ }; @@ -158,6 +159,7 @@ static int parseTimezone(const char *zDate, DateTime *p){ p->tz = sgn*(nMn + nHr*60); zulu_time: while( sqlite3Isspace(*zDate) ){ zDate++; } + p->tzSet = 1; return *zDate!=0; } @@ -590,13 +592,18 @@ static int parseModifier(sqlite3_context *pCtx, const char *zMod, DateTime *p){ } #ifndef SQLITE_OMIT_LOCALTIME else if( strcmp(z, "utc")==0 ){ - sqlite3_int64 c1; - computeJD(p); - c1 = localtimeOffset(p, pCtx, &rc); - if( rc==SQLITE_OK ){ - p->iJD -= c1; - clearYMD_HMS_TZ(p); - p->iJD += c1 - localtimeOffset(p, pCtx, &rc); + if( p->tzSet==0 ){ + sqlite3_int64 c1; + computeJD(p); + c1 = localtimeOffset(p, pCtx, &rc); + if( rc==SQLITE_OK ){ + p->iJD -= c1; + clearYMD_HMS_TZ(p); + p->iJD += c1 - localtimeOffset(p, pCtx, &rc); + } + p->tzSet = 1; + }else{ + rc = SQLITE_OK; } } #endif diff --git a/test/date.test b/test/date.test index b1d1c677c1..2f48b111e6 100644 --- a/test/date.test +++ b/test/date.test @@ -336,6 +336,15 @@ if {$tzoffset_new==4} { datetest 6.8.1 {datetime('2006-04-02 02:00:00','utc')} {2006-04-02 06:00:00} datetest 6.8.2 {datetime('2007-03-11 02:00:00','utc')} {2007-03-11 06:00:00} + # The 'utc' modifier is a no-op if the LHS is known to already be in UTC + datetest 6.9.1 {datetime('2015-12-23 12:00:00','utc')} {2015-12-23 17:00:00} + datetest 6.9.2 {datetime('2015-12-23 12:00:00z','utc')} {2015-12-23 12:00:00} + datetest 6.9.3 {datetime('2015-12-23 12:00:00-03:00','utc')} \ + {2015-12-23 15:00:00} + datetest 6.9.4 {datetime('2015-12-23 12:00:00','utc','utc','utc')} \ + {2015-12-23 17:00:00} + + datetest 6.10 {datetime('2000-01-01 12:00:00','localtime')} \ {2000-01-01 07:00:00} datetest 6.11 {datetime('1969-01-01 12:00:00','localtime')} \ From 3e6a1411300a1d0251369b5cf156b1f745895dcf Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 23 Dec 2015 16:42:27 +0000 Subject: [PATCH 103/232] Fix some harmless gcc compiler warnings. Mostly in fts5, but also two in the core code. FossilOrigin-Name: 5d44d4a6cf5c6b983cbd846d9bc34251df8f4bc5 --- ext/fts5/fts5_aux.c | 2 +- ext/fts5/fts5_expr.c | 6 +++--- ext/fts5/fts5_main.c | 4 ++-- ext/fts5/fts5_storage.c | 2 +- ext/fts5/fts5_tokenize.c | 2 +- manifest | 26 +++++++++++++------------- manifest.uuid | 2 +- src/expr.c | 2 +- src/mutex_unix.c | 2 ++ 9 files changed, 25 insertions(+), 23 deletions(-) diff --git a/ext/fts5/fts5_aux.c b/ext/fts5/fts5_aux.c index 928a26a8bb..011064d405 100644 --- a/ext/fts5/fts5_aux.c +++ b/ext/fts5/fts5_aux.c @@ -544,7 +544,7 @@ int sqlite3Fts5AuxInit(fts5_api *pApi){ int rc = SQLITE_OK; /* Return code */ int i; /* To iterate through builtin functions */ - for(i=0; rc==SQLITE_OK && ixCreateFunction(pApi, aBuiltin[i].zFunc, aBuiltin[i].pUserData, diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index eb167b4407..a747a64c9b 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -407,7 +407,7 @@ static int fts5ExprPhraseIsMatch( /* If the aStatic[] array is not large enough, allocate a large array ** using sqlite3_malloc(). This approach could be improved upon. */ - if( pPhrase->nTerm>(sizeof(aStatic) / sizeof(aStatic[0])) ){ + if( pPhrase->nTerm>(int)ArraySize(aStatic) ){ int nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm; aIter = (Fts5PoslistReader*)sqlite3_malloc(nByte); if( !aIter ) return SQLITE_NOMEM; @@ -543,7 +543,7 @@ static int fts5ExprNearIsMatch(int *pRc, Fts5ExprNearset *pNear){ /* If the aStatic[] array is not large enough, allocate a large array ** using sqlite3_malloc(). This approach could be improved upon. */ - if( pNear->nPhrase>(sizeof(aStatic) / sizeof(aStatic[0])) ){ + if( pNear->nPhrase>(int)ArraySize(aStatic) ){ int nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase; a = (Fts5NearTrimmer*)sqlite3Fts5MallocZero(&rc, nByte); }else{ @@ -2190,7 +2190,7 @@ int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){ int rc = SQLITE_OK; void *pCtx = (void*)pGlobal; - for(i=0; rc==SQLITE_OK && i<(sizeof(aFunc) / sizeof(aFunc[0])); i++){ + for(i=0; rc==SQLITE_OK && i<(int)ArraySize(aFunc); i++){ struct Fts5ExprFunc *p = &aFunc[i]; rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0); } diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index cf2c748c4c..70912de4f8 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -537,7 +537,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ for(i=0; inConstraint; i++){ struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; int j; - for(j=0; jiColumn==aColMap[pC->iCol] && p->op & pC->op ){ if( p->usable ){ @@ -584,7 +584,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ /* Assign argvIndex values to each constraint in use. */ iNext = 1; - for(i=0; iiConsIndex>=0 ){ pInfo->aConstraintUsage[pC->iConsIndex].argvIndex = iNext++; diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 5fd5dc51a2..13297c1509 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -338,7 +338,7 @@ int sqlite3Fts5StorageClose(Fts5Storage *p){ int i; /* Finalize all SQL statements */ - for(i=0; iaStmt); i++){ + for(i=0; i<(int)ArraySize(p->aStmt); i++){ sqlite3_finalize(p->aStmt[i]); } diff --git a/ext/fts5/fts5_tokenize.c b/ext/fts5/fts5_tokenize.c index 1df7ba9e35..e60183c095 100644 --- a/ext/fts5/fts5_tokenize.c +++ b/ext/fts5/fts5_tokenize.c @@ -1220,7 +1220,7 @@ int sqlite3Fts5TokenizerInit(fts5_api *pApi){ int rc = SQLITE_OK; /* Return code */ int i; /* To iterate through builtin functions */ - for(i=0; rc==SQLITE_OK && ixCreateTokenizer(pApi, aBuiltin[i].zName, (void*)pApi, diff --git a/manifest b/manifest index 078eaef167..0c1d15f84d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\s'utc'\smodifier\son\sdate/time\sfunctions\sso\sthat\sif\sthe\sLHS\sis\nalready\sknown\sto\sbe\sin\sUTC,\sthe\smodifier\sbecomes\sa\sno-op.\s\sThis\sis\snot\san\nincompatibility\sbecause\sthe\sbehavior\sis\sdocumented\sas\s"undefined"\sin\sthat\nscenario. -D 2015-12-23T10:54:48.693 +C Fix\ssome\sharmless\sgcc\scompiler\swarnings.\sMostly\sin\sfts5,\sbut\salso\stwo\sin\sthe\score\scode. +D 2015-12-23T16:42:27.781 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -98,17 +98,17 @@ F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 8b9a13b309b180e9fb88ea5666c0d8d73c6102d9 F ext/fts5/fts5Int.h acf968e43d57b6b1caf7554d34ec35d6ed3b4fe8 -F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 +F ext/fts5/fts5_aux.c 2dafc3aee0c70d643140c77d8d70daffa51a9e9e F ext/fts5/fts5_buffer.c 1e49512a535045e621246dc7f4f65f3593fa0fc2 F ext/fts5/fts5_config.c 0ee66188609a62342e9f9aeefa3c3e44518a4dd6 -F ext/fts5/fts5_expr.c 80075fa45091bad42100c4a5c4f2efc83e43e3af +F ext/fts5/fts5_expr.c 8228aca3e9af626a1ca9b093d4d24b4f2488ad23 F ext/fts5/fts5_hash.c 25838d525e97f8662ff3504be94d0bad24f9a37e F ext/fts5/fts5_index.c 578f46697080f11a1e26cd45a1c039c043a3111d -F ext/fts5/fts5_main.c ef04699949ab8e42d590ae30188afef7ad58776e -F ext/fts5/fts5_storage.c 9ea3d92178743758b6c54d9fe8836bbbdcc92e3b +F ext/fts5/fts5_main.c e11b525778e6fce416d916bfa96926bd1ce4616d +F ext/fts5/fts5_storage.c 57c636d87cbb829d6147c8c8bf78fa53b9ebb526 F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf -F ext/fts5/fts5_tokenize.c 618efe033bceb80c521b1e9ddfd9fee85fb5946e +F ext/fts5/fts5_tokenize.c 504984ac6993323247221eebe3cd55bead01b5f8 F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 @@ -286,7 +286,7 @@ F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c e4655393bb403fa310eef66cc4583d75d4d7fd93 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c 414f4c6b016c4494bfb11713da79f27966871d91 +F src/expr.c 38790e65d1219f2b7dc26458f39a5252fe7c60cd F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 F src/func.c fe50a9ab977acc0bb0fcd46741e0071fa388888e @@ -310,7 +310,7 @@ F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85 F src/mutex_noop.c 9d4309c075ba9cc7249e19412d3d62f7f94839c4 -F src/mutex_unix.c fc54f25b2a750d53b32512a4a728cec28039ae2a +F src/mutex_unix.c 27bb6cc49485ee46711a6580ab7b3f1402211d23 F src/mutex_w32.c 5e6fe1c298fb5a8a15aaed4161d5759311431c17 F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7 F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 34073ce87d88a02313217023ae92e15939192cd9 -R fb37875a5634d72cf8280c2958a6e17e -U drh -Z 5e4e9bf785bd86d0086510037196235b +P b910a3d53769689d9212a06f974ccce54844bbe4 +R 5ab375194afd22e61de829d90abd4fea +U dan +Z 1812011a4512993ca315aa42f142cb2e diff --git a/manifest.uuid b/manifest.uuid index c74bd62134..47ad4e4422 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b910a3d53769689d9212a06f974ccce54844bbe4 \ No newline at end of file +5d44d4a6cf5c6b983cbd846d9bc34251df8f4bc5 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 5c67de1297..d8d36afa54 100644 --- a/src/expr.c +++ b/src/expr.c @@ -888,7 +888,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ assert( ExprHasProperty(p, EP_Reduced)==0 ); memcpy(zAlloc, p, nNewSize); }else{ - int nSize = exprStructSize(p); + u32 nSize = (u32)exprStructSize(p); memcpy(zAlloc, p, nSize); if( nSize Date: Thu, 24 Dec 2015 14:53:27 +0000 Subject: [PATCH 104/232] Avoid a harmless compiler warning on systems where the byteorder cannot be determined at compile-time. FossilOrigin-Name: 7c7b7f26306b6aa6ff35b871ad756f43f5db9838 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqliteInt.h | 10 +++++----- src/utf.c | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 0c1d15f84d..0bcc78c649 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\sharmless\sgcc\scompiler\swarnings.\sMostly\sin\sfts5,\sbut\salso\stwo\sin\sthe\score\scode. -D 2015-12-23T16:42:27.781 +C Avoid\sa\sharmless\scompiler\swarning\son\ssystems\swhere\sthe\sbyteorder\scannot\nbe\sdetermined\sat\scompile-time. +D 2015-12-24T14:53:27.528 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -338,7 +338,7 @@ F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 5a2770eb1fdf3542b9c5ac3fd87836f0d46e1b08 +F src/sqliteInt.h 6e0c1082268e99aa337de1547df32b220e812fb3 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -395,7 +395,7 @@ F src/tokenize.c 5606871a377f390af7040ec3c12e0d183512d785 F src/treeview.c 78842e90c1f71269e7a73a1d4221b6fe360bab66 F src/trigger.c de3ed31ad3218a20d7d7e18bf1b3b734e78bda66 F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 -F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c +F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 F src/vdbe.c 984c2be6691d3f67deb2e6747c2132150d776f32 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b910a3d53769689d9212a06f974ccce54844bbe4 -R 5ab375194afd22e61de829d90abd4fea -U dan -Z 1812011a4512993ca315aa42f142cb2e +P 5d44d4a6cf5c6b983cbd846d9bc34251df8f4bc5 +R c0120dd70eca82393527f5b4b745caa6 +U drh +Z 6af8ad4397eb3ff04028cb96b6439a6e diff --git a/manifest.uuid b/manifest.uuid index 47ad4e4422..6d6b0b7302 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d44d4a6cf5c6b983cbd846d9bc34251df8f4bc5 \ No newline at end of file +7c7b7f26306b6aa6ff35b871ad756f43f5db9838 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index a328aff013..18d20b1068 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -692,11 +692,6 @@ typedef INT16_TYPE LogEst; ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined ** at run-time. */ -#ifdef SQLITE_AMALGAMATION -const int sqlite3one = 1; -#else -extern const int sqlite3one; -#endif #if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ @@ -714,6 +709,11 @@ extern const int sqlite3one; # define SQLITE_UTF16NATIVE SQLITE_UTF16BE #endif #if !defined(SQLITE_BYTEORDER) +# ifdef SQLITE_AMALGAMATION + const int sqlite3one = 1; +# else + extern const int sqlite3one; +# endif # define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */ # define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0) # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1) diff --git a/src/utf.c b/src/utf.c index 25f4dadf0c..ee367c1399 100644 --- a/src/utf.c +++ b/src/utf.c @@ -37,13 +37,13 @@ #include #include "vdbeInt.h" -#ifndef SQLITE_AMALGAMATION +#if !defined(SQLITE_AMALGAMATION) && SQLITE_BYTEORDER==0 /* ** The following constant value is used by the SQLITE_BIGENDIAN and ** SQLITE_LITTLEENDIAN macros. */ const int sqlite3one = 1; -#endif /* SQLITE_AMALGAMATION */ +#endif /* SQLITE_AMALGAMATION && SQLITE_BYTEORDER==0 */ /* ** This lookup table is used to help decode the first byte of From 9f44deed93ea3b94e661d9fcafff41d5d8afa0de Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 28 Dec 2015 19:55:00 +0000 Subject: [PATCH 105/232] Change the name of the offsets=0 option to "detail=column". Have the xInst, xPhraseFirst and other API functions work by parsing the original text for detail=column tables. FossilOrigin-Name: 228b4d10e38f7d70e1b008c3c9b4a1ae3e32e30d --- ext/fts5/fts5Int.h | 10 ++- ext/fts5/fts5_config.c | 45 ++++++++-- ext/fts5/fts5_expr.c | 87 ++++++++++++++++++- ext/fts5/fts5_hash.c | 20 +++-- ext/fts5/fts5_index.c | 33 +++---- ext/fts5/fts5_main.c | 77 +++++++++++----- ext/fts5/fts5_storage.c | 2 +- ext/fts5/test/fts5_common.tcl | 18 +++- ext/fts5/test/fts5ac.test | 80 ++++++++++++----- ext/fts5/test/fts5ad.test | 6 +- .../{fts5offsets.test => fts5detail.test} | 87 ++++++++++++++----- manifest | 32 +++---- manifest.uuid | 2 +- 13 files changed, 379 insertions(+), 120 deletions(-) rename ext/fts5/test/{fts5offsets.test => fts5detail.test} (76%) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 3016f4be04..a0f69bee21 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -151,7 +151,7 @@ struct Fts5Config { char *zContent; /* content table */ char *zContentRowid; /* "content_rowid=" option value */ int bColumnsize; /* "columnsize=" option value (dflt==1) */ - int bOffsets; /* "offsets=" option value (dflt==1) */ + int eDetail; /* FTS5_DETAIL_XXX value */ char *zContentExprlist; Fts5Tokenizer *pTok; fts5_tokenizer *pTokApi; @@ -180,6 +180,9 @@ struct Fts5Config { #define FTS5_CONTENT_NONE 1 #define FTS5_CONTENT_EXTERNAL 2 +#define FTS5_DETAIL_FULL 0 +#define FTS5_DETAIL_NONE 1 +#define FTS5_DETAIL_COLUMNS 2 @@ -637,6 +640,11 @@ int sqlite3Fts5ExprPhraseCount(Fts5Expr*); int sqlite3Fts5ExprPhraseSize(Fts5Expr*, int iPhrase); int sqlite3Fts5ExprPoslist(Fts5Expr*, int, const u8 **); +Fts5PoslistWriter *sqlite3Fts5ExprClearPoslists(Fts5Expr*); +int sqlite3Fts5ExprPopulatePoslists( + Fts5Config*, Fts5Expr*, Fts5PoslistWriter*, int, const char*, int +); + int sqlite3Fts5ExprClonePhrase(Fts5Config*, Fts5Expr*, int, Fts5Expr**); /******************************************* diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index b72fd9b745..fd6da7f11e 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -194,6 +194,33 @@ void sqlite3Fts5Dequote(char *z){ } } + +struct Fts5Enum { + const char *zName; + int eVal; +}; +typedef struct Fts5Enum Fts5Enum; + +static int fts5ConfigSetEnum( + const Fts5Enum *aEnum, + const char *zEnum, + int *peVal +){ + int nEnum = strlen(zEnum); + int i; + int iVal = -1; + + for(i=0; aEnum[i].zName; i++){ + if( sqlite3_strnicmp(aEnum[i].zName, zEnum, nEnum)==0 ){ + if( iVal>=0 ) return SQLITE_ERROR; + iVal = aEnum[i].eVal; + } + } + + *peVal = iVal; + return iVal<0 ? SQLITE_ERROR : SQLITE_OK; +} + /* ** Parse a "special" CREATE VIRTUAL TABLE directive and update ** configuration object pConfig as appropriate. @@ -344,12 +371,16 @@ static int fts5ConfigParseSpecial( return rc; } - if( sqlite3_strnicmp("offsets", zCmd, nCmd)==0 ){ - if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\0' ){ - *pzErr = sqlite3_mprintf("malformed offsets=... directive"); - rc = SQLITE_ERROR; - }else{ - pConfig->bOffsets = (zArg[0]=='1'); + if( sqlite3_strnicmp("detail", zCmd, nCmd)==0 ){ + const Fts5Enum aDetail[] = { + { "none", FTS5_DETAIL_NONE }, + { "full", FTS5_DETAIL_FULL }, + { "columns", FTS5_DETAIL_COLUMNS }, + { 0, 0 } + }; + + if( rc = fts5ConfigSetEnum(aDetail, zArg, &pConfig->eDetail) ){ + *pzErr = sqlite3_mprintf("malformed detail=... directive"); } return rc; } @@ -509,7 +540,7 @@ int sqlite3Fts5ConfigParse( pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1); pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1); pRet->bColumnsize = 1; - pRet->bOffsets = 1; + pRet->eDetail = FTS5_DETAIL_FULL; #ifdef SQLITE_DEBUG pRet->bPrefixIndex = 1; #endif diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index b7bc13b289..5a5a0652ee 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -1744,6 +1744,15 @@ void sqlite3Fts5ParseSetColset( Fts5ExprNearset *pNear, Fts5Colset *pColset ){ + if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){ + pParse->rc = SQLITE_ERROR; + pParse->zErr = sqlite3_mprintf( + "fts5: column queries are not supported (detail=none)" + ); + sqlite3_free(pColset); + return; + } + if( pNear ){ pNear->pColset = pColset; }else{ @@ -1809,12 +1818,12 @@ Fts5ExprNode *sqlite3Fts5ParseNode( if( pNear->apPhrase[0]->aTerm[0].pSynonym==0 ){ pRet->eType = FTS5_TERM; } - }else if( pParse->pConfig->bOffsets==0 ){ + }else if( pParse->pConfig->eDetail!=FTS5_DETAIL_FULL ){ assert( pParse->rc==SQLITE_OK ); pParse->rc = SQLITE_ERROR; assert( pParse->zErr==0 ); pParse->zErr = sqlite3_mprintf( - "fts5: %s queries are not supported (offsets=0)", + "fts5: %s queries are not supported (detail!=full)", pNear->nPhrase==1 ? "phrase": "NEAR" ); sqlite3_free(pRet); @@ -1932,6 +1941,9 @@ static char *fts5ExprPrintTcl( for(iTerm=0; zRet && iTermnTerm; iTerm++){ char *zTerm = pPhrase->aTerm[iTerm].zTerm; zRet = fts5PrintfAppend(zRet, "%s%s", iTerm==0?"":" ", zTerm); + if( pPhrase->aTerm[iTerm].bPrefix ){ + zRet = fts5PrintfAppend(zRet, "*"); + } } if( zRet ) zRet = fts5PrintfAppend(zRet, "}"); @@ -2244,3 +2256,74 @@ int sqlite3Fts5ExprPoslist(Fts5Expr *pExpr, int iPhrase, const u8 **pa){ } return nRet; } + +Fts5PoslistWriter *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr){ + int i; + Fts5PoslistWriter *pRet; + for(i=0; inPhrase; i++){ + Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist; + assert( pExpr->apExprPhrase[i]->nTerm==1 ); + pBuf->n = 0; + } + pRet = sqlite3_malloc(sizeof(Fts5PoslistWriter)*pExpr->nPhrase); + if( pRet ){ + memset(pRet, 0, sizeof(Fts5PoslistWriter)*pExpr->nPhrase); + } + return pRet; +} + +struct Fts5ExprCtx { + Fts5Expr *pExpr; + Fts5PoslistWriter *aWriter; + i64 iOff; +}; +typedef struct Fts5ExprCtx Fts5ExprCtx; + +static int fts5ExprPopulatePoslistsCb( + void *pCtx, /* Copy of 2nd argument to xTokenize() */ + int tflags, /* Mask of FTS5_TOKEN_* flags */ + const char *pToken, /* Pointer to buffer containing token */ + int nToken, /* Size of token in bytes */ + int iStart, /* Byte offset of token within input text */ + int iEnd /* Byte offset of end of token within input text */ +){ + Fts5ExprCtx *p = (Fts5ExprCtx*)pCtx; + Fts5Expr *pExpr = p->pExpr; + int i; + + if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++; + for(i=0; inPhrase; i++){ + Fts5ExprTerm *pTerm; + for(pTerm=&pExpr->apExprPhrase[i]->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){ + int nTerm = strlen(pTerm->zTerm); + if( (nTerm==nToken || (nTermbPrefix)) + && memcmp(pTerm->zTerm, pToken, nTerm)==0 + ){ + int rc = sqlite3Fts5PoslistWriterAppend( + &pExpr->apExprPhrase[i]->poslist, &p->aWriter[i], p->iOff + ); + if( rc ) return rc; + break; + } + } + } + return SQLITE_OK; +} + +int sqlite3Fts5ExprPopulatePoslists( + Fts5Config *pConfig, + Fts5Expr *pExpr, + Fts5PoslistWriter *aWriter, + int iCol, + const char *z, int n +){ + Fts5ExprCtx sCtx; + sCtx.pExpr = pExpr; + sCtx.aWriter = aWriter; + sCtx.iOff = (((i64)iCol) << 32) - 1; + + return sqlite3Fts5Tokenize(pConfig, + FTS5_TOKENIZE_AUX, z, n, (void*)&sCtx, fts5ExprPopulatePoslistsCb + ); +} + diff --git a/ext/fts5/fts5_hash.c b/ext/fts5/fts5_hash.c index dc5adadc8e..a9f1c13ede 100644 --- a/ext/fts5/fts5_hash.c +++ b/ext/fts5/fts5_hash.c @@ -26,7 +26,7 @@ typedef struct Fts5HashEntry Fts5HashEntry; struct Fts5Hash { - int bOffsets; /* Copy of Fts5Config.bOffsets */ + int eDetail; /* Copy of Fts5Config.eDetail */ int *pnByte; /* Pointer to bytes counter */ int nEntry; /* Number of entries currently in hash */ int nSlot; /* Size of aSlot[] array */ @@ -91,7 +91,7 @@ int sqlite3Fts5HashNew(Fts5Config *pConfig, Fts5Hash **ppNew, int *pnByte){ int nByte; memset(pNew, 0, sizeof(Fts5Hash)); pNew->pnByte = pnByte; - pNew->bOffsets = pConfig->bOffsets; + pNew->eDetail = pConfig->eDetail; pNew->nSlot = 1024; nByte = sizeof(Fts5HashEntry*) * pNew->nSlot; @@ -216,7 +216,9 @@ int sqlite3Fts5HashWrite( Fts5HashEntry *p; u8 *pPtr; int nIncr = 0; /* Amount to increment (*pHash->pnByte) by */ - int bNew = pHash->bOffsets; /* If non-delete entry should be written */ + int bNew; /* If non-delete entry should be written */ + + bNew = (pHash->eDetail==FTS5_DETAIL_FULL); /* Attempt to locate an existing hash entry */ iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken); @@ -253,7 +255,7 @@ int sqlite3Fts5HashWrite( p->iSzPoslist = p->nData; p->nData += 1; p->iRowid = iRowid; - p->iCol = (pHash->bOffsets-1); + p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1); p->pHashNext = pHash->aSlot[iHash]; pHash->aSlot[iHash] = p; pHash->nEntry++; @@ -290,7 +292,7 @@ int sqlite3Fts5HashWrite( p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid); p->iSzPoslist = p->nData; p->nData += 1; - p->iCol = (pHash->bOffsets-1); + p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1); p->iPos = 0; p->iRowid = iRowid; bNew = 1; @@ -300,14 +302,14 @@ int sqlite3Fts5HashWrite( /* Append a new column value, if necessary */ assert( iCol>=p->iCol ); if( iCol!=p->iCol ){ - if( pHash->bOffsets==0 ){ - bNew = 1; - p->iCol = iPos = iCol; - }else{ + if( pHash->eDetail==FTS5_DETAIL_FULL ){ pPtr[p->nData++] = 0x01; p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iCol); p->iCol = iCol; p->iPos = 0; + }else{ + bNew = 1; + p->iCol = iPos = iCol; } } diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index bcd81843b7..836a6d2c99 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4109,19 +4109,19 @@ static void fts5SegiterPoslist( if( pColset==0 ){ fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback); }else{ - if( p->pConfig->bOffsets==0 ){ - PoslistOffsetsCtx sCtx; - memset(&sCtx, 0, sizeof(sCtx)); - sCtx.pBuf = pBuf; - sCtx.pColset = pColset; - fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistOffsetsCallback); - }else{ + if( p->pConfig->eDetail==FTS5_DETAIL_FULL ){ PoslistCallbackCtx sCtx; sCtx.pBuf = pBuf; sCtx.pColset = pColset; sCtx.eState = fts5IndexColsetTest(pColset, 0); assert( sCtx.eState==0 || sCtx.eState==1 ); fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistFilterCallback); + }else{ + PoslistOffsetsCtx sCtx; + memset(&sCtx, 0, sizeof(sCtx)); + sCtx.pBuf = pBuf; + sCtx.pColset = pColset; + fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistOffsetsCallback); } } } @@ -4192,7 +4192,7 @@ static int fts5AppendPoslist( assert( fts5MultiIterEof(p, pMulti)==0 ); assert( pSeg->nPos>0 ); if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+9+9) ){ - if( p->pConfig->bOffsets + if( p->pConfig->eDetail==FTS5_DETAIL_FULL && pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf && (pColset==0 || pColset->nCol==1) ){ @@ -4850,9 +4850,11 @@ int sqlite3Fts5IterPoslist( i64 *piRowid /* OUT: Current rowid */ ){ Fts5SegIter *pSeg = &pIter->aSeg[ pIter->aFirst[1].iFirst ]; + int eDetail = pIter->pIndex->pConfig->eDetail; + assert( pIter->pIndex->rc==SQLITE_OK ); *piRowid = pSeg->iRowid; - if( pIter->pIndex->pConfig->bOffsets + if( eDetail==FTS5_DETAIL_FULL && pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf ){ u8 *pPos = &pSeg->pLeaf->p[pSeg->iLeafOffset]; @@ -4871,7 +4873,9 @@ int sqlite3Fts5IterPoslist( }else{ fts5BufferZero(&pIter->poslist); fts5SegiterPoslist(pIter->pIndex, pSeg, pColset, &pIter->poslist); - *pp = pIter->poslist.p; + if( eDetail==FTS5_DETAIL_FULL ){ + *pp = pIter->poslist.p; + } *pn = pIter->poslist.n; } return fts5IndexReturn(pIter->pIndex); @@ -5062,17 +5066,15 @@ static int fts5QueryCksum( ){ u64 cksum = *pCksum; Fts5IndexIter *pIdxIter = 0; + Fts5Buffer buf = {0, 0, 0}; int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIdxIter); while( rc==SQLITE_OK && 0==sqlite3Fts5IterEof(pIdxIter) ){ - i64 dummy; - const u8 *pPos; - int nPos; i64 rowid = sqlite3Fts5IterRowid(pIdxIter); - rc = sqlite3Fts5IterPoslist(pIdxIter, 0, &pPos, &nPos, &dummy); + rc = sqlite3Fts5IterPoslistBuffer(pIdxIter, &buf); if( rc==SQLITE_OK ){ Fts5PoslistReader sReader; - for(sqlite3Fts5PoslistReaderInit(pPos, nPos, &sReader); + for(sqlite3Fts5PoslistReaderInit(buf.p, buf.n, &sReader); sReader.bEof==0; sqlite3Fts5PoslistReaderNext(&sReader) ){ @@ -5084,6 +5086,7 @@ static int fts5QueryCksum( } } sqlite3Fts5IterClose(pIdxIter); + fts5BufferFree(&buf); *pCksum = cksum; return rc; diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 1d0b4c219e..51c3f57cff 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -226,6 +226,7 @@ struct Fts5Cursor { #define FTS5CSR_EOF 0x08 #define FTS5CSR_FREE_ZRANK 0x10 #define FTS5CSR_REQUIRE_RESEEK 0x20 +#define FTS5CSR_REQUIRE_POSLIST 0x40 #define BitFlagAllTest(x,y) (((x) & (y))==(y)) #define BitFlagTest(x,y) (((x) & (y))!=0) @@ -313,7 +314,7 @@ static int fts5IsContentless(Fts5Table *pTab){ ** Return true if pTab is an offsetless table. */ static int fts5IsOffsetless(Fts5Table *pTab){ - return pTab->pConfig->bOffsets==0; + return pTab->pConfig->eDetail!=FTS5_DETAIL_FULL; } /* @@ -646,6 +647,7 @@ static void fts5CsrNewrow(Fts5Cursor *pCsr){ FTS5CSR_REQUIRE_CONTENT | FTS5CSR_REQUIRE_DOCSIZE | FTS5CSR_REQUIRE_INST + | FTS5CSR_REQUIRE_POSLIST ); } @@ -1603,6 +1605,8 @@ static int fts5RollbackMethod(sqlite3_vtab *pVtab){ return rc; } +static int fts5CsrPoslist(Fts5Cursor*, int, const u8**); + static void *fts5ApiUserData(Fts5Context *pCtx){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; return pCsr->pAux->pUserData; @@ -1652,8 +1656,53 @@ static int fts5ApiPhraseSize(Fts5Context *pCtx, int iPhrase){ return sqlite3Fts5ExprPhraseSize(pCsr->pExpr, iPhrase); } +static int fts5ApiColumnText( + Fts5Context *pCtx, + int iCol, + const char **pz, + int *pn +){ + int rc = SQLITE_OK; + Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; + if( fts5IsContentless((Fts5Table*)(pCsr->base.pVtab)) ){ + *pz = 0; + *pn = 0; + }else{ + rc = fts5SeekCursor(pCsr, 0); + if( rc==SQLITE_OK ){ + *pz = (const char*)sqlite3_column_text(pCsr->pStmt, iCol+1); + *pn = sqlite3_column_bytes(pCsr->pStmt, iCol+1); + } + } + return rc; +} + static int fts5CsrPoslist(Fts5Cursor *pCsr, int iPhrase, const u8 **pa){ int n; + int rc = SQLITE_OK; + + if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){ + Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig; + if( pConfig->eDetail!=FTS5_DETAIL_FULL ){ + Fts5PoslistWriter *aWriter; + int i; +assert( pCsr->pSorter==0 ); /* fixme */ + aWriter = sqlite3Fts5ExprClearPoslists(pCsr->pExpr); + if( aWriter==0 ) rc = SQLITE_NOMEM; + for(i=0; inCol && rc==SQLITE_OK; i++){ + int n; const char *z; + rc = fts5ApiColumnText((Fts5Context*)pCsr, i, &z, &n); + if( rc==SQLITE_OK ){ + rc = sqlite3Fts5ExprPopulatePoslists( + pConfig, pCsr->pExpr, aWriter, i, z, n + ); + } + } + sqlite3_free(aWriter); + } + CsrFlagClear(pCsr, FTS5CSR_REQUIRE_POSLIST); + } + if( pCsr->pSorter ){ Fts5Sorter *pSorter = pCsr->pSorter; int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]); @@ -1756,10 +1805,12 @@ static int fts5ApiInst( ){ if( iIdx<0 || iIdx>=pCsr->nInstCount ){ rc = SQLITE_RANGE; +#if 0 }else if( fts5IsOffsetless((Fts5Table*)pCsr->base.pVtab) ){ *piPhrase = pCsr->aInst[iIdx*3]; *piCol = pCsr->aInst[iIdx*3 + 2]; *piOff = -1; +#endif }else{ *piPhrase = pCsr->aInst[iIdx*3]; *piCol = pCsr->aInst[iIdx*3 + 1]; @@ -1773,27 +1824,6 @@ static sqlite3_int64 fts5ApiRowid(Fts5Context *pCtx){ return fts5CursorRowid((Fts5Cursor*)pCtx); } -static int fts5ApiColumnText( - Fts5Context *pCtx, - int iCol, - const char **pz, - int *pn -){ - int rc = SQLITE_OK; - Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; - if( fts5IsContentless((Fts5Table*)(pCsr->base.pVtab)) ){ - *pz = 0; - *pn = 0; - }else{ - rc = fts5SeekCursor(pCsr, 0); - if( rc==SQLITE_OK ){ - *pz = (const char*)sqlite3_column_text(pCsr->pStmt, iCol+1); - *pn = sqlite3_column_bytes(pCsr->pStmt, iCol+1); - } - } - return rc; -} - static int fts5ColumnSizeCb( void *pContext, /* Pointer to int */ int tflags, @@ -1925,11 +1955,13 @@ static void fts5ApiPhraseNext( if( pIter->a>=pIter->b ){ *piCol = -1; *piOff = -1; +#if 0 }else if( fts5IsOffsetless((Fts5Table*)(((Fts5Cursor*)pCtx)->base.pVtab)) ){ int iVal; pIter->a += fts5GetVarint32(pIter->a, iVal); *piCol += (iVal-2); *piOff = -1; +#endif }else{ int iVal; pIter->a += fts5GetVarint32(pIter->a, iVal); @@ -1982,7 +2014,6 @@ static const Fts5ExtensionApi sFts5Api = { fts5ApiPhraseNext, }; - /* ** Implementation of API function xQueryPhrase(). */ diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 65429edbd9..fe3ce829a1 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -916,7 +916,7 @@ int sqlite3Fts5StorageIntegrity(Fts5Storage *p){ if( pConfig->abUnindexed[i] ) continue; ctx.iCol = i; ctx.szCol = 0; - if( pConfig->bOffsets==0 ){ + if( pConfig->eDetail!=FTS5_DETAIL_FULL ){ rc = sqlite3Fts5TermsetNew(&ctx.pTermset); } if( rc==SQLITE_OK ){ diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index 74e84ab234..30b191e299 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -239,7 +239,21 @@ proc nearset {aCol args} { set iFirst [expr $iFL - $O(-near) - [llength $p]] for {set i $iFirst} {$i <= $iFL} {incr i} { - if {[lrange $col $i [expr $i+$nPm1]] == $p} { lappend B($iPhrase) $i } + set lCand [lrange $col $i [expr $i+$nPm1]] + + set bMatch 1 + foreach tok $p term $lCand { + if {[string match $tok $term]==0} { + #puts "$tok $term failed" + set bMatch 0 + } + } + if {$bMatch} { + #puts "match at $i" + lappend B($iPhrase) $i + } + + #if {$lCand == $p} { lappend B($iPhrase) $i } } if {[llength $B($iPhrase)] == 0} break } @@ -265,7 +279,7 @@ proc nearset {aCol args} { incr counter } - #puts $res + #puts "$aCol -> $res" sort_poslist $res } diff --git a/ext/fts5/test/fts5ac.test b/ext/fts5/test/fts5ac.test index 0de4848145..cc10cece09 100644 --- a/ext/fts5/test/fts5ac.test +++ b/ext/fts5/test/fts5ac.test @@ -130,7 +130,7 @@ set data { # # CREATE VIRTUAL TABLE xy USING fts5(x, y); # -# Assuming the table contains the same records as stored int the global +# Assuming the table contains the same records as stored in the global # $::data array (see above), this function returns a list containing one # element for each match in the dataset. The elements are themselves lists # formatted as follows: @@ -175,30 +175,22 @@ proc matchdata {bPos expr {bAsc 1}} { # End of test code #------------------------------------------------------------------------- -proc fts5_test_poslist {cmd} { - set res [list] - for {set i 0} {$i < [$cmd xInstCount]} {incr i} { - lappend res [string map {{ } .} [$cmd xInst $i]] - } - set res -} - foreach {tn2 sql} { 1 {} 2 {BEGIN} } { reset_db - sqlite3_fts5_create_function db fts5_test_poslist fts5_test_poslist + fts5_aux_test_functions db - do_execsql_test 1.0 { + do_execsql_test 1.$tn2.0 { CREATE VIRTUAL TABLE xx USING fts5(x,y); INSERT INTO xx(xx, rank) VALUES('pgsz', 32); } execsql $sql - do_test $tn2.1.1 { + do_test 1.$tn2.1.1 { foreach {id x y} $data { execsql { INSERT INTO xx(rowid, x, y) VALUES($id, $x, $y) } } @@ -224,7 +216,7 @@ foreach {tn2 sql} { set expr "\"$phrase\"" set res [matchdata 1 $expr] - do_execsql_test $tn2.1.2.$tn.[llength $res] { + do_execsql_test 1.$tn2.1.2.$tn.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res } @@ -246,7 +238,7 @@ foreach {tn2 sql} { 3.1 { a AND b AND c } } { set res [matchdata 1 $expr] - do_execsql_test $tn2.2.$tn.[llength $res] { + do_execsql_test 1.$tn2.2.$tn.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res } @@ -275,7 +267,7 @@ foreach {tn2 sql} { 4.4 {{"y" y}:b} } { set res [matchdata 1 $expr] - do_execsql_test $tn2.3.$tn.[llength $res] { + do_execsql_test 1.$tn2.3.$tn.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res } @@ -296,7 +288,7 @@ foreach {tn2 sql} { 9 { y : NEAR(r c) } } { set res [matchdata 1 $expr] - do_execsql_test $tn2.4.1.$tn.[llength $res] { + do_execsql_test 1.$tn2.4.1.$tn.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res } @@ -307,14 +299,14 @@ foreach {tn2 sql} { foreach {tn expr tclexpr} { 1 {a b} {AND [N $x -- {a}] [N $x -- {b}]} } { - do_execsql_test $tn2.5.$tn { + do_execsql_test 1.$tn2.5.$tn { SELECT fts5_expr_tcl($expr, 'N $x') } [list $tclexpr] } #------------------------------------------------------------------------- # - do_execsql_test $tn2.6.integrity { + do_execsql_test 1.$tn2.6.integrity { INSERT INTO xx(xx) VALUES('integrity-check'); } #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM xx_data} {puts $r} @@ -346,14 +338,62 @@ foreach {tn2 sql} { 19 { c NOT b OR a AND d } } { set res [matchdata 0 $expr $bAsc] - do_execsql_test $tn2.6.$bAsc.$tn.[llength $res] $sql $res + do_execsql_test 1.$tn2.6.$bAsc.$tn.[llength $res] $sql $res } } } -do_execsql_test 3.1 { +do_execsql_test 2.1 { SELECT fts5_expr_tcl('a AND b'); } {{AND [nearset -- {a}] [nearset -- {b}]}} +# Some tests for detail=col tables and detail=none. +# +foreach {tn2 sql} { + 1 { + CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=col); + } + 2 { + CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=col); + BEGIN; + } + 3 { + CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=none); + BEGIN; + } + 4 { + CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=none); + } +} { + reset_db + fts5_aux_test_functions db + + execsql $sql + + do_execsql_test 3.$tn2.0 { + INSERT INTO xx(xx, rank) VALUES('pgsz', 32); + } + + + do_test 3.$tn2.1.1 { + foreach {id x y} $data { + execsql { INSERT INTO xx(rowid, x, y) VALUES($id, $x, $y) } + } + execsql { INSERT INTO xx(xx) VALUES('integrity-check') } + } {} + + foreach {tn q} { + 1 "o" 2 "b" 3 "e" 4 "m" 5 "l" 6 "a" 7 "b" 8 "c" 9 "no" 10 "L" + 11 "o a" 12 "c AND d" 13 "o OR a" 12 "c OR d" + } { + set res [matchdata 1 $q] + + do_execsql_test 3.$tn2.1.2.$tn.[llength $res] { + SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $q + } $res + } + +} + finish_test diff --git a/ext/fts5/test/fts5ad.test b/ext/fts5/test/fts5ad.test index a9fc568133..cc86a6b2eb 100644 --- a/ext/fts5/test/fts5ad.test +++ b/ext/fts5/test/fts5ad.test @@ -75,17 +75,17 @@ foreach {T create} { } 6 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, offsets=0); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=col); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); } 7 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, offsets=0, prefix="1,2,3,4,5"); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=col, prefix="1,2,3,4,5"); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); } 8 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, offsets=0, prefix="1,2,3,4,5"); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=col, prefix="1,2,3,4,5"); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); BEGIN; } diff --git a/ext/fts5/test/fts5offsets.test b/ext/fts5/test/fts5detail.test similarity index 76% rename from ext/fts5/test/fts5offsets.test rename to ext/fts5/test/fts5detail.test index 2f2674fabe..59f4b0e3c3 100644 --- a/ext/fts5/test/fts5offsets.test +++ b/ext/fts5/test/fts5detail.test @@ -13,7 +13,7 @@ # source [file join [file dirname [info script]] fts5_common.tcl] -set testprefix fts5offsets +set testprefix fts5detail # If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { @@ -21,11 +21,13 @@ ifcapable !fts5 { return } +fts5_aux_test_functions db + #-------------------------------------------------------------------------- # Simple tests. # do_execsql_test 1.0 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, offsets=0); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, detail=col); INSERT INTO t1 VALUES('h d g', 'j b b g b', 'i e i d h g g'); -- 1 INSERT INTO t1 VALUES('h j d', 'j h d a h', 'f d d g g f b'); -- 2 INSERT INTO t1 VALUES('j c i', 'f f h e f', 'c j i j c h f'); -- 3 @@ -58,17 +60,18 @@ foreach {tn match res} { do_catchsql_test 1.3.1 { SELECT rowid FROM t1('h + d'); -} {1 {fts5: phrase queries are not supported (offsets=0)}} +} {1 {fts5: phrase queries are not supported (detail!=full)}} do_catchsql_test 1.3.2 { SELECT rowid FROM t1('NEAR(h d)'); -} {1 {fts5: NEAR queries are not supported (offsets=0)}} +} {1 {fts5: NEAR queries are not supported (detail!=full)}} + #------------------------------------------------------------------------- -# integrity-check with both offsets= and prefix= options. +# integrity-check with both detail= and prefix= options. # do_execsql_test 2.0 { - CREATE VIRTUAL TABLE t2 USING fts5(a, offsets=0, prefix="1"); + CREATE VIRTUAL TABLE t2 USING fts5(a, detail=col, prefix="1"); INSERT INTO t2(a) VALUES('aa ab'); } @@ -78,9 +81,17 @@ do_execsql_test 2.1 { INSERT INTO t2(t2) VALUES('integrity-check'); } +do_execsql_test 2.2 { + SELECT fts5_test_poslist(t2) FROM t2('aa'); +} {0.0.0} + +set ::pc 0 +#puts [nearset {{ax bx cx}} -pc ::pc -near 10 -- b*] +#exit + #------------------------------------------------------------------------- # Check that the xInstCount, xInst, xPhraseFirst and xPhraseNext APIs -# work with offsets=0 tables. +# work with detail=col tables. # set data { 1 {abb aca aca} {aba bab aab aac caa} {abc cbc ccb bcc bab ccb aca} @@ -124,9 +135,42 @@ set data { 39 {bcb aac cba} {bcb baa caa cac bbc} {cbc ccc bab ccb bbb caa aba} 40 {cba ccb abc} {cbb caa cba aac bab} {cbb bbb bca bbb bac cac bca} } + +set data { + 1 {abb aca aca} {aba bab aab aac caa} {abc cbc ccb bcc bab ccb aca} +} + +proc matchdata {expr {bAsc 1}} { + + set tclexpr [db one { + SELECT fts5_expr_tcl($expr, 'nearset $cols -pc ::pc', 'x', 'y', 'z') + }] + set res [list] + + #puts "$expr -> $tclexpr" + foreach {id x y z} $::data { + set cols [list $x $y $z] + set ::pc 0 + #set hits [lsort -command instcompare [eval $tclexpr]] + set hits [eval $tclexpr] + if {[llength $hits]>0} { + lappend res [list $id $hits] + } + } + + if {$bAsc} { + set res [lsort -integer -increasing -index 0 $res] + } else { + set res [lsort -integer -decreasing -index 0 $res] + } + + return [concat {*}$res] +} + foreach {tn tbl} { - 1 { CREATE VIRTUAL TABLE t3 USING fts5(x, y, z, offsets=0) } + 1 { CREATE VIRTUAL TABLE t3 USING fts5(x, y, z, detail=col) } } { +#break reset_db fts5_aux_test_functions db execsql $tbl @@ -139,17 +183,7 @@ foreach {tn tbl} { 9 a* 10 b* 11 c* } { - set res [list] - foreach {id x y z} $data { - if {[lsearch [concat $x $y $z] $expr]>=0} { - lappend res $id - set inst [list] - if {[lsearch $x $expr]>=0} { lappend inst 0.0.-1 } - if {[lsearch $y $expr]>=0} { lappend inst 0.1.-1 } - if {[lsearch $z $expr]>=0} { lappend inst 0.2.-1 } - lappend res $inst - } - } + set res [matchdata $expr] do_execsql_test 3.$tn.$tn2.1 { SELECT rowid, fts5_test_poslist(t3) FROM t3($expr) @@ -159,8 +193,21 @@ foreach {tn tbl} { SELECT rowid, fts5_test_poslist2(t3) FROM t3($expr) } $res } - } +#------------------------------------------------------------------------- +# Simple tests for detail=none tables. +# +breakpoint +do_execsql_test 4.0 { + CREATE VIRTUAL TABLE t4 USING fts5(a, b, c, detail=none); + INSERT INTO t4 VALUES('a b c', 'b c d', 'e f g'); + INSERT INTO t4 VALUES('1 2 3', '4 5 6', '7 8 9'); +} + +do_catchsql_test 4.1 { + SELECT * FROM t4('a:a') +} {1 {fts5: column queries are not supported (detail=none)}} + finish_test diff --git a/manifest b/manifest index d02d515584..050615992a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updates\sso\sthat\sfts5\sAPI\sfunctions\sxInst,\sxPhraseFirst\sand\sxPhraseNext\swork\swith\sthe\soffsets=0\soption. -D 2015-12-22T18:54:16.763 +C Change\sthe\sname\sof\sthe\soffsets=0\soption\sto\s"detail=column".\sHave\sthe\sxInst,\sxPhraseFirst\sand\sother\sAPI\sfunctions\swork\sby\sparsing\sthe\soriginal\stext\sfor\sdetail=column\stables. +D 2015-12-28T19:55:00.739 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -97,15 +97,15 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 7d6785c75afe23239dad9cbaffc6fc55803feb4b -F ext/fts5/fts5Int.h e71739ed0b816758f1f77baaccca1b4a9064c4dc +F ext/fts5/fts5Int.h 7328cfa7b0151e34bb3715d404d732c6d49d5361 F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 -F ext/fts5/fts5_config.c ba5248a05c28ec6a6fdf2599a86e9fd67e5c61e2 -F ext/fts5/fts5_expr.c 3b2c7ac54e6c03e732751a6a4bf9ced8f408e2a2 -F ext/fts5/fts5_hash.c d4a6b52faca0134cc7bcc880f03a257a0dec2636 -F ext/fts5/fts5_index.c 1d1939afbc434907993d7e9a0c631be630d5b0dc -F ext/fts5/fts5_main.c b7d6540c63f347908d8ee937ca8a7987130c84b3 -F ext/fts5/fts5_storage.c 14e0bb6549a66da54adf4fa1564edbf24647cb22 +F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 +F ext/fts5/fts5_expr.c c9522ae99f862ddb318ea69998a02147d2a00c8d +F ext/fts5/fts5_hash.c 8b510868502ec31119409fc7022edc37c27b5c40 +F ext/fts5/fts5_index.c 24e81d8f2ce92f50eb19c15bffd5ada4ec91d8de +F ext/fts5/fts5_main.c a71db65929e150031c5a195e3c782e773deb55a6 +F ext/fts5/fts5_storage.c 076a3356536a8831eb6e554195171d5c249cd179 F ext/fts5/fts5_tcl.c c3cfff5f727b3d02f73c5717413d637b18b960f2 F ext/fts5/fts5_test_mi.c c9c8cf455c49ded156a234e0de1c8ba9be85e5c3 F ext/fts5/fts5_tokenize.c 618efe033bceb80c521b1e9ddfd9fee85fb5946e @@ -114,11 +114,11 @@ F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl 4a23a75f31dbb96c03c2840fae1bf85b4f64f062 +F ext/fts5/test/fts5_common.tcl 27f941596e241e25b4bd64c2446ae91dd4cb138c F ext/fts5/test/fts5aa.test 2c553eea4dab4bc5a75928f56729277c7bc1d206 F ext/fts5/test/fts5ab.test 6fe3a56731d15978afbb74ae51b355fc9310f2ad -F ext/fts5/test/fts5ac.test 9737992d08c56bfd4803e933744d2d764e23795c -F ext/fts5/test/fts5ad.test 21d87b12c7ec83b4ec48816d24503443dffb10a1 +F ext/fts5/test/fts5ac.test 5dea9e119ed39e0923b423dc2b3eaaef2ec3abd3 +F ext/fts5/test/fts5ad.test 0fd1a5bcb5dcc76a639bd26f27e2641034a508a3 F ext/fts5/test/fts5ae.test 0a9984fc3479f89f8c63d9848d6ed0c465dfcebe F ext/fts5/test/fts5af.test c2501ec2b61d6b179c305f5d2b8782ab3d4f832a F ext/fts5/test/fts5ag.test ec3e119b728196620a31507ef503c455a7a73505 @@ -139,6 +139,7 @@ F ext/fts5/test/fts5content.test 9a952c95518a14182dc3b59e3c8fa71cda82a4e1 F ext/fts5/test/fts5corrupt.test c2ad090192708150d50d961278df10ae7a4b8b62 F ext/fts5/test/fts5corrupt2.test 26c0a39dd9ff73207e6229f83b50b21d37c7658c F ext/fts5/test/fts5corrupt3.test a2b537c120bdd43c79c42fe2438d7b8c81fe5599 +F ext/fts5/test/fts5detail.test 71babe633c68c6c5153b2fe1be81a97e953ca485 w ext/fts5/test/fts5offsets.test F ext/fts5/test/fts5dlidx.test ecba5e62ea8b26c33829961602069c546228046d F ext/fts5/test/fts5doclist.test 8edb5b57e5f144030ed74ec00ef6fa4294fed79b F ext/fts5/test/fts5ea.test b01e3a18cdfabbff8104a96a5242a06a68a998a0 @@ -156,7 +157,6 @@ F ext/fts5/test/fts5integrity.test 87db5d4e7da0ce04a1dcba5ba91658673c997a65 F ext/fts5/test/fts5matchinfo.test 2163b0013e824bba65499da9e34ea4da41349cc2 F ext/fts5/test/fts5merge.test 8f3cdba2ec9c5e7e568246e81b700ad37f764367 F ext/fts5/test/fts5near.test b214cddb1c1f1bddf45c75af768f20145f7e71cc -F ext/fts5/test/fts5offsets.test 7d32df518f6513131c14ce985006c3ac5873e79f F ext/fts5/test/fts5onepass.test 7ed9608e258132cb8d55e7c479b08676ad68810c F ext/fts5/test/fts5optimize.test 42741e7c085ee0a1276140a752d4407d97c2c9f5 F ext/fts5/test/fts5phrase.test f6d1d464da5beb25dc56277aa4f1d6102f0d9a2f @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 609a0bc7f34e6dae74ce756aff920f3df78fe828 -R 3d59533357e77f6a30434e9a4ea67f85 +P 69bffc1632c8a8f3bfe5bf92607e64fed982e48c +R bce3f221a6a9e036b503a3a5522049ea U dan -Z ae770209a83bcb452cb39fda88b8ef75 +Z 73bb0a8c75a5e4585189e64532bdf9a9 diff --git a/manifest.uuid b/manifest.uuid index 07c12c4bf0..a1ac4a70e8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -69bffc1632c8a8f3bfe5bf92607e64fed982e48c \ No newline at end of file +228b4d10e38f7d70e1b008c3c9b4a1ae3e32e30d \ No newline at end of file From 9a3a5275cd9ac4aa6c3c5f63cf289a1aa63d5514 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 29 Dec 2015 19:35:03 +0000 Subject: [PATCH 106/232] Add the xPhraseFirstColumn() and xPhraseNextColumn() API functions to fts5. For iterating through the set of columns that contain intances of a phrase. FossilOrigin-Name: 8c30605bcd0a78a5015948171145bc6f640b8358 --- ext/fts5/fts5.h | 7 ++- ext/fts5/fts5Int.h | 4 ++ ext/fts5/fts5_expr.c | 22 ++++++++ ext/fts5/fts5_index.c | 11 ++++ ext/fts5/fts5_main.c | 75 ++++++++++++++++++++++--- ext/fts5/fts5_tcl.c | 27 +++++++++ ext/fts5/test/fts5_common.tcl | 11 ++++ ext/fts5/test/fts5ac.test | 101 ++++++++++++++++++++++++++-------- manifest | 28 +++++----- manifest.uuid | 2 +- 10 files changed, 241 insertions(+), 47 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index 400b7c7885..990c3f2f0d 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -216,7 +216,7 @@ struct Fts5PhraseIter { ** See xPhraseFirst above. */ struct Fts5ExtensionApi { - int iVersion; /* Currently always set to 2 */ + int iVersion; /* Currently always set to 3 */ void *(*xUserData)(Fts5Context*); @@ -246,8 +246,11 @@ struct Fts5ExtensionApi { int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*)); void *(*xGetAuxdata)(Fts5Context*, int bClear); - void (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*); + int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*); void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff); + + int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*); + void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); }; /* diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index a0f69bee21..4ef99ebae1 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -447,6 +447,8 @@ int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge); int sqlite3Fts5IndexLoadConfig(Fts5Index *p); +int sqlite3Fts5IterCollist(Fts5IndexIter*, const u8 **, int*); + /* ** End of interface to code in fts5_index.c. **************************************************************************/ @@ -647,6 +649,8 @@ int sqlite3Fts5ExprPopulatePoslists( int sqlite3Fts5ExprClonePhrase(Fts5Config*, Fts5Expr*, int, Fts5Expr**); +int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *); + /******************************************* ** The fts5_expr.c API above this point is used by the other hand-written ** C code in this module. The interfaces below this point are called by diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 5a5a0652ee..ebd767a617 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -2327,3 +2327,25 @@ int sqlite3Fts5ExprPopulatePoslists( ); } +/* +** This function is only called for detail=columns tables. +*/ +int sqlite3Fts5ExprPhraseCollist( + Fts5Expr *pExpr, + int iPhrase, + const u8 **ppCollist, + int *pnCollist +){ + Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase]; + Fts5ExprNode *pNode = pPhrase->pNode; + assert( iPhrase>=0 && iPhrasenPhrase ); + + if( pNode->bEof==0 && pNode->iRowid==pExpr->pRoot->iRowid ){ + sqlite3Fts5IterCollist(pPhrase->aTerm[0].pIter, ppCollist, pnCollist); + }else{ + *ppCollist = 0; + *pnCollist = 0; + } + return SQLITE_OK; +} + diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 836a6d2c99..34caa45072 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4881,6 +4881,17 @@ int sqlite3Fts5IterPoslist( return fts5IndexReturn(pIter->pIndex); } +int sqlite3Fts5IterCollist( + Fts5IndexIter *pIter, + const u8 **pp, /* OUT: Pointer to position-list data */ + int *pn /* OUT: Size of position-list in bytes */ +){ + assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_COLUMNS ); + *pp = pIter->poslist.p; + *pn = pIter->poslist.n; + return SQLITE_OK; +} + /* ** This function is similar to sqlite3Fts5IterPoslist(), except that it ** copies the position list into the buffer supplied as the second diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 51c3f57cff..cd43308513 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1955,13 +1955,6 @@ static void fts5ApiPhraseNext( if( pIter->a>=pIter->b ){ *piCol = -1; *piOff = -1; -#if 0 - }else if( fts5IsOffsetless((Fts5Table*)(((Fts5Cursor*)pCtx)->base.pVtab)) ){ - int iVal; - pIter->a += fts5GetVarint32(pIter->a, iVal); - *piCol += (iVal-2); - *piOff = -1; -#endif }else{ int iVal; pIter->a += fts5GetVarint32(pIter->a, iVal); @@ -1975,7 +1968,7 @@ static void fts5ApiPhraseNext( } } -static void fts5ApiPhraseFirst( +static int fts5ApiPhraseFirst( Fts5Context *pCtx, int iPhrase, Fts5PhraseIter *pIter, @@ -1989,6 +1982,70 @@ static void fts5ApiPhraseFirst( fts5ApiPhraseNext(pCtx, pIter, piCol, piOff); } +static void fts5ApiPhraseNextColumn( + Fts5Context *pCtx, + Fts5PhraseIter *pIter, + int *piCol +){ + Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; + Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig; + + if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ + if( pIter->a>=pIter->b ){ + *piCol = -1; + }else{ + int iIncr; + pIter->a += fts5GetVarint32(&pIter->a[0], iIncr); + *piCol += (iIncr-2); + } + }else{ + while( 1 ){ + int dummy; + if( pIter->a>=pIter->b ){ + *piCol = -1; + return; + } + if( pIter->a[0]==0x01 ) break; + pIter->a += fts5GetVarint32(pIter->a, dummy); + } + pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol); + } +} + +static int fts5ApiPhraseFirstColumn( + Fts5Context *pCtx, + int iPhrase, + Fts5PhraseIter *pIter, + int *piCol +){ + int rc = SQLITE_OK; + Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; + Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig; + + if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ + int n; + rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n); + if( rc==SQLITE_OK ){ + pIter->b = &pIter->a[n]; + *piCol = 0; + fts5ApiPhraseNextColumn(pCtx, pIter, piCol); + } + }else{ + int n = fts5CsrPoslist(pCsr, iPhrase, &pIter->a); + pIter->b = &pIter->a[n]; + if( n<=0 ){ + *piCol = -1; + }else if( pIter->a[0]==0x01 ){ + pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol); + }else{ + *piCol = 0; + } + } + + return rc; +} + + static int fts5ApiQueryPhrase(Fts5Context*, int, void*, int(*)(const Fts5ExtensionApi*, Fts5Context*, void*) ); @@ -2012,6 +2069,8 @@ static const Fts5ExtensionApi sFts5Api = { fts5ApiGetAuxdata, fts5ApiPhraseFirst, fts5ApiPhraseNext, + fts5ApiPhraseFirstColumn, + fts5ApiPhraseNextColumn, }; /* diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index bf815eab81..4a331a59f4 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -236,6 +236,7 @@ static int xF5tApi( { "xSetAuxdataInt", 1, "INTEGER" }, /* 14 */ { "xGetAuxdataInt", 1, "CLEAR" }, /* 15 */ { "xPhraseForeach", 4, "IPHRASE COLVAR OFFVAR SCRIPT" }, /* 16 */ + { "xPhraseColumnForeach", 3, "IPHRASE COLVAR SCRIPT" }, /* 17 */ { 0, 0, 0} }; @@ -462,6 +463,32 @@ static int xF5tApi( break; } + CASE(17, "xPhraseColumnForeach") { + int iPhrase; + int iCol; + const char *zColvar; + Tcl_Obj *pScript = objv[4]; + Fts5PhraseIter iter; + + if( Tcl_GetIntFromObj(interp, objv[2], &iPhrase) ) return TCL_ERROR; + zColvar = Tcl_GetString(objv[3]); + + for(p->pApi->xPhraseFirstColumn(p->pFts, iPhrase, &iter, &iCol); + iCol>=0; + p->pApi->xPhraseNextColumn(p->pFts, &iter, &iCol) + ){ + Tcl_SetVar2Ex(interp, zColvar, 0, Tcl_NewIntObj(iCol), 0); + rc = Tcl_EvalObjEx(interp, pScript, 0); + if( rc==TCL_CONTINUE ) rc = TCL_OK; + if( rc!=TCL_OK ){ + if( rc==TCL_BREAK ) rc = TCL_OK; + break; + } + } + + break; + } + default: assert( 0 ); break; diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index 30b191e299..64af5c59b3 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -40,6 +40,16 @@ proc fts5_test_poslist2 {cmd} { set res } +proc fts5_test_collist {cmd} { + set res [list] + + for {set i 0} {$i < [$cmd xPhraseCount]} {incr i} { + $cmd xPhraseColumnForeach $i c { lappend res $i.$c } + } + + set res +} + proc fts5_test_columnsize {cmd} { set res [list] for {set i 0} {$i < [$cmd xColumnCount]} {incr i} { @@ -126,6 +136,7 @@ proc fts5_aux_test_functions {db} { fts5_test_columntotalsize fts5_test_poslist fts5_test_poslist2 + fts5_test_collist fts5_test_tokenize fts5_test_rowcount fts5_test_all diff --git a/ext/fts5/test/fts5ac.test b/ext/fts5/test/fts5ac.test index cc10cece09..ff2affcce1 100644 --- a/ext/fts5/test/fts5ac.test +++ b/ext/fts5/test/fts5ac.test @@ -131,16 +131,17 @@ set data { # CREATE VIRTUAL TABLE xy USING fts5(x, y); # # Assuming the table contains the same records as stored in the global -# $::data array (see above), this function returns a list containing one -# element for each match in the dataset. The elements are themselves lists -# formatted as follows: +# $::data array (see above), this function returns a list containing two +# elements for each matching row in the dataset. The first element of each +# pair is the rowid. The second is a list of phrase matches, where each +# phrase match is of the form: # -# { ...} +# .. # -# where each element is a list of phrase matches in the -# same form as returned by auxiliary scalar function fts5_test(). +# The list of phrase matches is in the same format as that returned by the +# fts5_test_poslist() auxiliary scalara function. # -proc matchdata {bPos expr {bAsc 1}} { +proc poslist_data {bPos expr {bAsc 1}} { set tclexpr [db one { SELECT fts5_expr_tcl($expr, 'nearset $cols -pc ::pc', 'x', 'y') @@ -168,13 +169,43 @@ proc matchdata {bPos expr {bAsc 1}} { set res [lsort -integer -decreasing -index 0 $res] } - return [concat {*}$res] + set res [concat {*}$res] + return $res +} + +proc collist_elem_compare {a b} { + foreach {a1 a2} [split $a .] {} + foreach {b1 b2} [split $b .] {} + + if {$a1==$b1} { + return [expr $a2 - $b2] + } + return [expr $a1 - $b1] +} + +proc poslist2collist {poslist} { + set res [list] + foreach h $poslist { + regexp {(.*)\.[1234567890]+} $h -> cand + lappend res $cand + } + set res [lsort -command collist_elem_compare -unique $res] + return $res +} + +proc collist_data {expr} { + set res [list] + foreach {rowid poslist} [poslist_data 1 $expr] { + lappend res $rowid [poslist2collist $poslist] + } + set res } # # End of test code #------------------------------------------------------------------------- +if 0 { foreach {tn2 sql} { 1 {} @@ -214,11 +245,16 @@ foreach {tn2 sql} { 10 "L O O L V V K" } { set expr "\"$phrase\"" - set res [matchdata 1 $expr] + set res [poslist_data 1 $expr] - do_execsql_test 1.$tn2.1.2.$tn.[llength $res] { + do_execsql_test 1.$tn2.1.2.$tn.p.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res + + set res [collist_data $expr] + do_execsql_test 1.$tn2.1.2.$tn.c.[llength $res] { + SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr + } $res } #------------------------------------------------------------------------- @@ -237,10 +273,15 @@ foreach {tn2 sql} { 3.1 { a AND b AND c } } { - set res [matchdata 1 $expr] - do_execsql_test 1.$tn2.2.$tn.[llength $res] { + set res [poslist_data 1 $expr] + do_execsql_test 1.$tn2.2.$tn.c.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res + + set res [collist_data $expr] + do_execsql_test 1.$tn2.2.$tn.c.[llength $res] { + SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr + } $res } #------------------------------------------------------------------------- @@ -266,10 +307,15 @@ foreach {tn2 sql} { 4.3 {{x "x"}:b} 4.4 {{"y" y}:b} } { - set res [matchdata 1 $expr] - do_execsql_test 1.$tn2.3.$tn.[llength $res] { + set res [poslist_data 1 $expr] + do_execsql_test 1.$tn2.3.$tn.p.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res + + set res [collist_data $expr] + do_execsql_test 1.$tn2.3.$tn.c.[llength $res] { + SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr + } $res } #------------------------------------------------------------------------- @@ -287,10 +333,15 @@ foreach {tn2 sql} { 8 { x : NEAR(r c) } 9 { y : NEAR(r c) } } { - set res [matchdata 1 $expr] - do_execsql_test 1.$tn2.4.1.$tn.[llength $res] { + set res [poslist_data 1 $expr] + do_execsql_test 1.$tn2.4.1.$tn.p.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res + + set res [collist_data $expr] + do_execsql_test 1.$tn2.4.1.$tn.c.[llength $res] { + SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr + } $res } do_test $tn2.4.1 { nearset {{a b c}} -- a } {0.0.0} @@ -337,7 +388,7 @@ foreach {tn2 sql} { 18 { c NOT (b OR a) } 19 { c NOT b OR a AND d } } { - set res [matchdata 0 $expr $bAsc] + set res [poslist_data 0 $expr $bAsc] do_execsql_test 1.$tn2.6.$bAsc.$tn.[llength $res] $sql $res } } @@ -347,6 +398,9 @@ do_execsql_test 2.1 { SELECT fts5_expr_tcl('a AND b'); } {{AND [nearset -- {a}] [nearset -- {b}]}} +} +#set data [lrange $data 0 5] + # Some tests for detail=col tables and detail=none. # foreach {tn2 sql} { @@ -374,7 +428,6 @@ foreach {tn2 sql} { INSERT INTO xx(xx, rank) VALUES('pgsz', 32); } - do_test 3.$tn2.1.1 { foreach {id x y} $data { execsql { INSERT INTO xx(rowid, x, y) VALUES($id, $x, $y) } @@ -384,13 +437,17 @@ foreach {tn2 sql} { foreach {tn q} { 1 "o" 2 "b" 3 "e" 4 "m" 5 "l" 6 "a" 7 "b" 8 "c" 9 "no" 10 "L" - 11 "o a" 12 "c AND d" 13 "o OR a" 12 "c OR d" + 11 "o a" 12 "c AND d" 13 "o OR a" 14 "c OR d" } { - set res [matchdata 1 $q] - - do_execsql_test 3.$tn2.1.2.$tn.[llength $res] { + set res [poslist_data 1 $q] + do_execsql_test 3.$tn2.1.2.$tn.p.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $q } $res + + set res [collist_data $q] + do_execsql_test 3.$tn2.1.2.$tn.c.[llength $res] { + SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $q + } $res } } diff --git a/manifest b/manifest index 050615992a..8b22a0fdc2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sname\sof\sthe\soffsets=0\soption\sto\s"detail=column".\sHave\sthe\sxInst,\sxPhraseFirst\sand\sother\sAPI\sfunctions\swork\sby\sparsing\sthe\soriginal\stext\sfor\sdetail=column\stables. -D 2015-12-28T19:55:00.739 +C Add\sthe\sxPhraseFirstColumn()\sand\sxPhraseNextColumn()\sAPI\sfunctions\sto\sfts5.\sFor\siterating\sthrough\sthe\sset\sof\scolumns\sthat\scontain\sintances\sof\sa\sphrase. +D 2015-12-29T19:35:03.765 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -96,17 +96,17 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 -F ext/fts5/fts5.h 7d6785c75afe23239dad9cbaffc6fc55803feb4b -F ext/fts5/fts5Int.h 7328cfa7b0151e34bb3715d404d732c6d49d5361 +F ext/fts5/fts5.h 88fec577a2148f34df75930dc2b0c45b0bad72c3 +F ext/fts5/fts5Int.h ab5f6f1f65652310a644d97d12aeabf8ab5ed17e F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 -F ext/fts5/fts5_expr.c c9522ae99f862ddb318ea69998a02147d2a00c8d +F ext/fts5/fts5_expr.c 08ee4f342a2b1fd82a5dccd0b9b3cde4921a8be5 F ext/fts5/fts5_hash.c 8b510868502ec31119409fc7022edc37c27b5c40 -F ext/fts5/fts5_index.c 24e81d8f2ce92f50eb19c15bffd5ada4ec91d8de -F ext/fts5/fts5_main.c a71db65929e150031c5a195e3c782e773deb55a6 +F ext/fts5/fts5_index.c ca8310eaa286e6c1e4c4581a420b7c3a1ec6302c +F ext/fts5/fts5_main.c 23f3912ff44172859c771eb55cb57778fd662e89 F ext/fts5/fts5_storage.c 076a3356536a8831eb6e554195171d5c249cd179 -F ext/fts5/fts5_tcl.c c3cfff5f727b3d02f73c5717413d637b18b960f2 +F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb F ext/fts5/fts5_test_mi.c c9c8cf455c49ded156a234e0de1c8ba9be85e5c3 F ext/fts5/fts5_tokenize.c 618efe033bceb80c521b1e9ddfd9fee85fb5946e F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c @@ -114,10 +114,10 @@ F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl 27f941596e241e25b4bd64c2446ae91dd4cb138c +F ext/fts5/test/fts5_common.tcl f923471d572d1e283b7d6985ce3cda62dae6fd45 F ext/fts5/test/fts5aa.test 2c553eea4dab4bc5a75928f56729277c7bc1d206 F ext/fts5/test/fts5ab.test 6fe3a56731d15978afbb74ae51b355fc9310f2ad -F ext/fts5/test/fts5ac.test 5dea9e119ed39e0923b423dc2b3eaaef2ec3abd3 +F ext/fts5/test/fts5ac.test 1d2a10d4c13dcfd326287f51df3b7d90761c212c F ext/fts5/test/fts5ad.test 0fd1a5bcb5dcc76a639bd26f27e2641034a508a3 F ext/fts5/test/fts5ae.test 0a9984fc3479f89f8c63d9848d6ed0c465dfcebe F ext/fts5/test/fts5af.test c2501ec2b61d6b179c305f5d2b8782ab3d4f832a @@ -139,7 +139,7 @@ F ext/fts5/test/fts5content.test 9a952c95518a14182dc3b59e3c8fa71cda82a4e1 F ext/fts5/test/fts5corrupt.test c2ad090192708150d50d961278df10ae7a4b8b62 F ext/fts5/test/fts5corrupt2.test 26c0a39dd9ff73207e6229f83b50b21d37c7658c F ext/fts5/test/fts5corrupt3.test a2b537c120bdd43c79c42fe2438d7b8c81fe5599 -F ext/fts5/test/fts5detail.test 71babe633c68c6c5153b2fe1be81a97e953ca485 w ext/fts5/test/fts5offsets.test +F ext/fts5/test/fts5detail.test 71babe633c68c6c5153b2fe1be81a97e953ca485 F ext/fts5/test/fts5dlidx.test ecba5e62ea8b26c33829961602069c546228046d F ext/fts5/test/fts5doclist.test 8edb5b57e5f144030ed74ec00ef6fa4294fed79b F ext/fts5/test/fts5ea.test b01e3a18cdfabbff8104a96a5242a06a68a998a0 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 69bffc1632c8a8f3bfe5bf92607e64fed982e48c -R bce3f221a6a9e036b503a3a5522049ea +P 228b4d10e38f7d70e1b008c3c9b4a1ae3e32e30d +R 9b7a210ea600814406fb8e0040363d54 U dan -Z 73bb0a8c75a5e4585189e64532bdf9a9 +Z 50bb7fa01e78a4726d7b3d5426b2a1ed diff --git a/manifest.uuid b/manifest.uuid index a1ac4a70e8..f3ee4608cf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -228b4d10e38f7d70e1b008c3c9b4a1ae3e32e30d \ No newline at end of file +8c30605bcd0a78a5015948171145bc6f640b8358 \ No newline at end of file From ff135ae4c33040e3f5f22b2a1bfe51a06cfa9424 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 30 Dec 2015 01:07:02 +0000 Subject: [PATCH 107/232] Add the json_group_array() and json_group_object() aggregate functions to the JSON1 extension. FossilOrigin-Name: 7f386a9332237100a345035ca213327e21d95855 --- ext/misc/json1.c | 112 +++++++++++++++++++++++++++++++++++++++++++++- manifest | 13 +++--- manifest.uuid | 2 +- test/json103.test | 65 +++++++++++++++++++++++++++ 4 files changed, 184 insertions(+), 8 deletions(-) create mode 100644 test/json103.test diff --git a/ext/misc/json1.c b/ext/misc/json1.c index 61d013ea4b..0bd0baff12 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -1181,7 +1181,7 @@ static void jsonTest1Func( #endif /* SQLITE_DEBUG */ /**************************************************************************** -** SQL function implementations +** Scalar SQL function implementations ****************************************************************************/ /* @@ -1514,6 +1514,102 @@ static void jsonValidFunc( sqlite3_result_int(ctx, rc); } + +/**************************************************************************** +** Aggregate SQL function implementations +****************************************************************************/ +/* +** json_group_array(VALUE) +** +** Return a JSON array composed of all values in the aggregate. +*/ +static void jsonArrayStep( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + JsonString *pStr; + pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); + if( pStr ){ + if( pStr->zBuf==0 ){ + jsonInit(pStr, ctx); + jsonAppendChar(pStr, '['); + }else{ + jsonAppendChar(pStr, ','); + pStr->pCtx = ctx; + } + jsonAppendValue(pStr, argv[0]); + } +} +static void jsonArrayFinal(sqlite3_context *ctx){ + JsonString *pStr; + pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); + if( pStr ){ + pStr->pCtx = ctx; + jsonAppendChar(pStr, ']'); + if( pStr->bErr ){ + sqlite3_result_error_nomem(ctx); + if( !pStr->bStatic ) sqlite3_free(pStr->zBuf); + }else{ + sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, + pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); + pStr->bStatic = 1; + } + }else{ + sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC); + } + sqlite3_result_subtype(ctx, JSON_SUBTYPE); +} + +/* +** json_group_obj(NAME,VALUE) +** +** Return a JSON object composed of all names and values in the aggregate. +*/ +static void jsonObjectStep( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + JsonString *pStr; + const char *z; + u32 n; + pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); + if( pStr ){ + if( pStr->zBuf==0 ){ + jsonInit(pStr, ctx); + jsonAppendChar(pStr, '{'); + }else{ + jsonAppendChar(pStr, ','); + pStr->pCtx = ctx; + } + z = (const char*)sqlite3_value_text(argv[0]); + n = (u32)sqlite3_value_bytes(argv[0]); + jsonAppendString(pStr, z, n); + jsonAppendChar(pStr, ':'); + jsonAppendValue(pStr, argv[1]); + } +} +static void jsonObjectFinal(sqlite3_context *ctx){ + JsonString *pStr; + pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); + if( pStr ){ + jsonAppendChar(pStr, '}'); + if( pStr->bErr ){ + sqlite3_result_error_nomem(ctx); + if( !pStr->bStatic ) sqlite3_free(pStr->zBuf); + }else{ + sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, + pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); + pStr->bStatic = 1; + } + }else{ + sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC); + } + sqlite3_result_subtype(ctx, JSON_SUBTYPE); +} + + #ifndef SQLITE_OMIT_VIRTUALTABLE /**************************************************************************** ** The json_each virtual table @@ -2012,6 +2108,15 @@ int sqlite3Json1Init(sqlite3 *db){ { "json_test1", 1, 0, jsonTest1Func }, #endif }; + static const struct { + const char *zName; + int nArg; + void (*xStep)(sqlite3_context*,int,sqlite3_value**); + void (*xFinal)(sqlite3_context*); + } aAgg[] = { + { "json_group_array", 1, jsonArrayStep, jsonArrayFinal }, + { "json_group_object", 2, jsonObjectStep, jsonObjectFinal }, + }; #ifndef SQLITE_OMIT_VIRTUALTABLE static const struct { const char *zName; @@ -2027,6 +2132,11 @@ int sqlite3Json1Init(sqlite3 *db){ (void*)&aFunc[i].flag, aFunc[i].xFunc, 0, 0); } + for(i=0; i Date: Wed, 30 Dec 2015 13:36:57 +0000 Subject: [PATCH 108/232] Enhance the command-line shell to handle MBCS characters on input and output. FossilOrigin-Name: a0a08b8c0bbd4d71955261f6b7e997701ca68e18 --- manifest | 15 +++-- manifest.uuid | 2 +- src/shell.c | 173 +++++++++++++++++++++++++++++++++----------------- 3 files changed, 124 insertions(+), 66 deletions(-) diff --git a/manifest b/manifest index 20c9426af8..7af5edf4d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sjson_group_array()\sand\sjson_group_object()\saggregate\sfunctions\sto\nthe\sJSON1\sextension. -D 2015-12-30T01:07:02.009 +C Enhance\sthe\scommand-line\sshell\sto\shandle\sMBCS\scharacters\son\sinput\sand\soutput. +D 2015-12-30T13:36:57.561 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -334,7 +334,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f -F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 +F src/shell.c ace08b69cd9702143cf87b5bd20b744a56f832fd F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d @@ -1406,7 +1406,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7c7b7f26306b6aa6ff35b871ad756f43f5db9838 -R 9a71d4f0e52af46677f6902fe927abd2 +P 7f386a9332237100a345035ca213327e21d95855 +R 5acb3019b0f92c56ad605906cb883a23 +T *branch * mbcs-shell +T *sym-mbcs-shell * +T -sym-trunk * U drh -Z d3d1e4137b6ba95a64ac245c7769bfd5 +Z 2dbfb8e7ec032a3367036522c7c27bf6 diff --git a/manifest.uuid b/manifest.uuid index 9a8ba9a337..e3eb9a8dac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7f386a9332237100a345035ca213327e21d95855 \ No newline at end of file +a0a08b8c0bbd4d71955261f6b7e997701ca68e18 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index ff1336a4b7..a6d75176c2 100644 --- a/src/shell.c +++ b/src/shell.c @@ -329,6 +329,13 @@ static int bail_on_error = 0; */ static int stdin_is_interactive = 1; +/* +** On Windows systems we have to know if standard output is a console +** in order to translate UTF-8 into MBCS. The following variable is +** true if translation is required. +*/ +static int stdout_is_console = 1; + /* ** The following is the open SQLite database. We make a pointer ** to this database a static variable so that it can be accessed @@ -430,6 +437,16 @@ static void shellstaticFunc( } +/* +** Compute a string length that is limited to what can be stored in +** lower 30 bits of a 32-bit signed integer. +*/ +static int strlen30(const char *z){ + const char *z2 = z; + while( *z2 ){ z2++; } + return 0x3fffffff & (int)(z2 - z); +} + /* ** This routine reads a line of text from FILE in, stores ** the text in memory obtained from malloc() and returns a pointer @@ -465,6 +482,26 @@ static char *local_getline(char *zLine, FILE *in){ break; } } +#if defined(_WIN32) || defined(WIN32) + /* For interactive input on Windows systems, translate the + ** multi-byte characterset characters into UTF-8. */ + if( stdin_is_interactive ){ + extern char *sqlite3_win32_mbcs_to_utf8(const char*); + char *zTrans = sqlite3_win32_mbcs_to_utf8(zLine); + if( zTrans ){ + int nTrans = strlen30(zTrans)+1; + if( nTrans>nLine ){ + zLine = realloc(zLine, nTrans); + if( zLine==0 ){ + sqlite3_free(zTrans); + return 0; + } + } + memcpy(zLine, zTrans, nTrans); + sqlite3_free(zTrans); + } + } +#endif /* defined(_WIN32) || defined(WIN32) */ return zLine; } @@ -502,6 +539,31 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){ return zResult; } +/* +** Render output like fprintf(). Except, if the output is going to the +** console and if this is running on a Windows machine, translate the +** output from UTF-8 into MBCS. +*/ +#if defined(_WIN32) || defined(WIN32) +void utf8_printf(FILE *out, const char *zFormat, ...){ + va_list ap; + va_start(ap, zFormat); + if( stdout_is_console && out==stdout ){ + extern char *sqlite3_win32_utf8_to_mbcs(const char*); + char *z1 = sqlite3_vmprintf(zFormat, ap); + char *z2 = sqlite3_win32_utf8_to_mbcs(z1); + sqlite3_free(z1); + fputs(z2, out); + sqlite3_free(z2); + }else{ + vfprintf(out, zFormat, ap); + } + va_end(ap); +} +#else +# define utf8_printf fprintf +#endif + /* ** Shell output mode information from before ".explain on", ** saved so that it can be restored by ".explain off" @@ -607,16 +669,6 @@ static const char *modeDescr[] = { */ #define ArraySize(X) (int)(sizeof(X)/sizeof(X[0])) -/* -** Compute a string length that is limited to what can be stored in -** lower 30 bits of a 32-bit signed integer. -*/ -static int strlen30(const char *z){ - const char *z2 = z; - while( *z2 ){ z2++; } - return 0x3fffffff & (int)(z2 - z); -} - /* ** A callback for the sqlite3_log() interface. */ @@ -649,7 +701,7 @@ static void output_quoted_string(FILE *out, const char *z){ if( z[i]=='\'' ) nSingle++; } if( nSingle==0 ){ - fprintf(out,"'%s'",z); + utf8_printf(out,"'%s'",z); }else{ fprintf(out,"'"); while( *z ){ @@ -658,10 +710,10 @@ static void output_quoted_string(FILE *out, const char *z){ fprintf(out,"''"); z++; }else if( z[i]=='\'' ){ - fprintf(out,"%.*s''",i,z); + utf8_printf(out,"%.*s''",i,z); z += i+1; }else{ - fprintf(out,"%s",z); + utf8_printf(out,"%s",z); break; } } @@ -717,7 +769,7 @@ static void output_html_string(FILE *out, const char *z){ && z[i]!='\''; i++){} if( i>0 ){ - fprintf(out,"%.*s",i,z); + utf8_printf(out,"%.*s",i,z); } if( z[i]=='<' ){ fprintf(out,"<"); @@ -768,7 +820,7 @@ static const char needCsvQuote[] = { static void output_csv(ShellState *p, const char *z, int bSep){ FILE *out = p->out; if( z==0 ){ - fprintf(out,"%s",p->nullValue); + utf8_printf(out,"%s",p->nullValue); }else{ int i; int nSep = strlen30(p->colSeparator); @@ -788,11 +840,11 @@ static void output_csv(ShellState *p, const char *z, int bSep){ } putc('"', out); }else{ - fprintf(out, "%s", z); + utf8_printf(out, "%s", z); } } if( bSep ){ - fprintf(p->out, "%s", p->colSeparator); + utf8_printf(p->out, "%s", p->colSeparator); } } @@ -830,9 +882,9 @@ static int shell_callback( int len = strlen30(azCol[i] ? azCol[i] : ""); if( len>w ) w = len; } - if( p->cnt++>0 ) fprintf(p->out, "%s", p->rowSeparator); + if( p->cnt++>0 ) utf8_printf(p->out, "%s", p->rowSeparator); for(i=0; iout,"%*s = %s%s", w, azCol[i], + utf8_printf(p->out,"%*s = %s%s", w, azCol[i], azArg[i] ? azArg[i] : p->nullValue, p->rowSeparator); } break; @@ -858,10 +910,10 @@ static int shell_callback( } if( p->showHeader ){ if( w<0 ){ - fprintf(p->out,"%*.*s%s",-w,-w,azCol[i], + utf8_printf(p->out,"%*.*s%s",-w,-w,azCol[i], i==nArg-1 ? p->rowSeparator : " "); }else{ - fprintf(p->out,"%-*.*s%s",w,w,azCol[i], + utf8_printf(p->out,"%-*.*s%s",w,w,azCol[i], i==nArg-1 ? p->rowSeparator : " "); } } @@ -875,7 +927,8 @@ static int shell_callback( }else{ w = 10; } - fprintf(p->out,"%-*.*s%s",w,w,"-----------------------------------" + fprintf(p->out,"%-*.*s%s",w,w, + "----------------------------------------------------------" "----------------------------------------------------------", i==nArg-1 ? p->rowSeparator : " "); } @@ -899,11 +952,11 @@ static int shell_callback( p->iIndent++; } if( w<0 ){ - fprintf(p->out,"%*.*s%s",-w,-w, + utf8_printf(p->out,"%*.*s%s",-w,-w, azArg[i] ? azArg[i] : p->nullValue, i==nArg-1 ? p->rowSeparator : " "); }else{ - fprintf(p->out,"%-*.*s%s",w,w, + utf8_printf(p->out,"%-*.*s%s",w,w, azArg[i] ? azArg[i] : p->nullValue, i==nArg-1 ? p->rowSeparator : " "); } @@ -914,7 +967,7 @@ static int shell_callback( case MODE_List: { if( p->cnt++==0 && p->showHeader ){ for(i=0; iout,"%s%s",azCol[i], + utf8_printf(p->out,"%s%s",azCol[i], i==nArg-1 ? p->rowSeparator : p->colSeparator); } } @@ -922,13 +975,13 @@ static int shell_callback( for(i=0; inullValue; - fprintf(p->out, "%s", z); + utf8_printf(p->out, "%s", z); if( iout, "%s", p->colSeparator); + utf8_printf(p->out, "%s", p->colSeparator); }else if( p->mode==MODE_Semi ){ - fprintf(p->out, ";%s", p->rowSeparator); + utf8_printf(p->out, ";%s", p->rowSeparator); }else{ - fprintf(p->out, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); } } break; @@ -957,16 +1010,16 @@ static int shell_callback( if( p->cnt++==0 && p->showHeader ){ for(i=0; iout,azCol[i] ? azCol[i] : ""); - if(iout, "%s", p->colSeparator); + if(iout, "%s", p->colSeparator); } - fprintf(p->out, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); } if( azArg==0 ) break; for(i=0; iout, azArg[i] ? azArg[i] : p->nullValue); - if(iout, "%s", p->colSeparator); + if(iout, "%s", p->colSeparator); } - fprintf(p->out, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); break; } case MODE_Csv: { @@ -975,13 +1028,13 @@ static int shell_callback( for(i=0; iout, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); } if( nArg>0 ){ for(i=0; iout, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); } setTextMode(p->out); break; @@ -989,12 +1042,12 @@ static int shell_callback( case MODE_Insert: { p->cnt++; if( azArg==0 ) break; - fprintf(p->out,"INSERT INTO %s",p->zDestTable); + utf8_printf(p->out,"INSERT INTO %s",p->zDestTable); if( p->showHeader ){ fprintf(p->out,"("); for(i=0; i0 ? ",": ""; - fprintf(p->out, "%s%s", zSep, azCol[i]); + utf8_printf(p->out, "%s%s", zSep, azCol[i]); } fprintf(p->out,")"); } @@ -1008,14 +1061,14 @@ static int shell_callback( output_quoted_string(p->out, azArg[i]); }else if( aiType && (aiType[i]==SQLITE_INTEGER || aiType[i]==SQLITE_FLOAT) ){ - fprintf(p->out,"%s%s",zSep, azArg[i]); + utf8_printf(p->out,"%s%s",zSep, azArg[i]); }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){ const void *pBlob = sqlite3_column_blob(p->pStmt, i); int nBlob = sqlite3_column_bytes(p->pStmt, i); if( zSep[0] ) fprintf(p->out,"%s",zSep); output_hex_blob(p->out, pBlob, nBlob); }else if( isNumber(azArg[i], 0) ){ - fprintf(p->out,"%s%s",zSep, azArg[i]); + utf8_printf(p->out,"%s%s",zSep, azArg[i]); }else{ if( zSep[0] ) fprintf(p->out,"%s",zSep); output_quoted_string(p->out, azArg[i]); @@ -1027,17 +1080,17 @@ static int shell_callback( case MODE_Ascii: { if( p->cnt++==0 && p->showHeader ){ for(i=0; i0 ) fprintf(p->out, "%s", p->colSeparator); - fprintf(p->out,"%s",azCol[i] ? azCol[i] : ""); + if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator); + utf8_printf(p->out,"%s",azCol[i] ? azCol[i] : ""); } - fprintf(p->out, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); } if( azArg==0 ) break; for(i=0; i0 ) fprintf(p->out, "%s", p->colSeparator); - fprintf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue); + if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator); + utf8_printf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue); } - fprintf(p->out, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); break; } } @@ -1167,13 +1220,13 @@ static int run_table_dump_query( nResult = sqlite3_column_count(pSelect); while( rc==SQLITE_ROW ){ if( zFirstRow ){ - fprintf(p->out, "%s", zFirstRow); + utf8_printf(p->out, "%s", zFirstRow); zFirstRow = 0; } z = (const char*)sqlite3_column_text(pSelect, 0); - fprintf(p->out, "%s", z); + utf8_printf(p->out, "%s", z); for(i=1; iout, ",%s", sqlite3_column_text(pSelect, i)); + utf8_printf(p->out, ",%s", sqlite3_column_text(pSelect, i)); } if( z==0 ) z = ""; while( z[0] && (z[0]!='-' || z[1]!='-') ) z++; @@ -1361,7 +1414,7 @@ static void display_scanstats( sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit); sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst); sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain); - fprintf(pArg->out, "Loop %2d: %s\n", n, zExplain); + utf8_printf(pArg->out, "Loop %2d: %s\n", n, zExplain); rEstLoop *= rEst; fprintf(pArg->out, " nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n", @@ -1522,7 +1575,7 @@ static int shell_exec( /* echo the sql statement if echo on */ if( pArg && pArg->echoOn ){ const char *zStmtSql = sqlite3_sql(pStmt); - fprintf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql); + utf8_printf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql); } /* Show the EXPLAIN QUERY PLAN if .eqp is on */ @@ -1536,7 +1589,7 @@ static int shell_exec( fprintf(pArg->out,"--EQP-- %d,", sqlite3_column_int(pExplain, 0)); fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1)); fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2)); - fprintf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3)); + utf8_printf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3)); } } sqlite3_finalize(pExplain); @@ -1677,11 +1730,11 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){ "INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)" "VALUES('table','%q','%q',0,'%q');", zTable, zTable, zSql); - fprintf(p->out, "%s\n", zIns); + utf8_printf(p->out, "%s\n", zIns); sqlite3_free(zIns); return 0; }else{ - fprintf(p->out, "%s;\n", zSql); + utf8_printf(p->out, "%s;\n", zSql); } if( strcmp(zType, "table")==0 ){ @@ -2126,7 +2179,7 @@ static void sql_trace_callback(void *pArg, const char *z){ if( f ){ int i = (int)strlen(z); while( i>0 && z[i-1]==';' ){ i--; } - fprintf(f, "%.*s;\n", i, z); + utf8_printf(f, "%.*s;\n", i, z); } } @@ -2609,7 +2662,7 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){ char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab); int val = db_int(p, zSql); sqlite3_free(zSql); - fprintf(p->out, "%-20s %d\n", aQuery[i].zName, val); + utf8_printf(p->out, "%-20s %d\n", aQuery[i].zName, val); } sqlite3_free(zSchemaTab); return 0; @@ -3449,7 +3502,7 @@ static int do_meta_command(char *zLine, ShellState *p){ int i; for(i=1; i1 ) fprintf(p->out, " "); - fprintf(p->out, "%s", azArg[i]); + utf8_printf(p->out, "%s", azArg[i]); } fprintf(p->out, "\n"); }else @@ -3643,7 +3696,7 @@ static int do_meta_command(char *zLine, ShellState *p){ int i, v; for(i=1; iout, "%s: %d 0x%x\n", azArg[i], v, v); + utf8_printf(p->out, "%s: %d 0x%x\n", azArg[i], v, v); } } if( strncmp(azArg[0]+9, "integer", n-9)==0 ){ @@ -3652,7 +3705,7 @@ static int do_meta_command(char *zLine, ShellState *p){ char zBuf[200]; v = integerValue(azArg[i]); sqlite3_snprintf(sizeof(zBuf),zBuf,"%s: %lld 0x%llx\n", azArg[i],v,v); - fprintf(p->out, "%s", zBuf); + utf8_printf(p->out, "%s", zBuf); } } }else @@ -3826,7 +3879,8 @@ static int do_meta_command(char *zLine, ShellState *p){ for(i=0; iout, "%s%-*s", zSp, maxlen, azResult[j] ? azResult[j]:""); + utf8_printf(p->out, "%s%-*s", zSp, maxlen, + azResult[j] ? azResult[j]:""); } fprintf(p->out, "\n"); } @@ -4547,6 +4601,7 @@ int SQLITE_CDECL main(int argc, char **argv){ Argv0 = argv[0]; main_init(&data); stdin_is_interactive = isatty(0); + stdout_is_console = isatty(1); /* Make sure we have a valid signal handler early, before anything ** else is done. From 31d175dde485bc4b6b573ef8ca8218378468e926 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 30 Dec 2015 14:06:22 +0000 Subject: [PATCH 109/232] Remove unnecessary tests from the LIKE pattern matcher. Slightly faster and slightly smaller, and it should also now works with EBCDIC. FossilOrigin-Name: 0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 20c9426af8..e2ed7e0ab2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sjson_group_array()\sand\sjson_group_object()\saggregate\sfunctions\sto\nthe\sJSON1\sextension. -D 2015-12-30T01:07:02.009 +C Remove\sunnecessary\stests\sfrom\sthe\sLIKE\spattern\smatcher.\s\sSlightly\sfaster\sand\nslightly\ssmaller,\sand\sit\sshould\salso\snow\sworks\swith\sEBCDIC. +D 2015-12-30T14:06:22.463 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -289,7 +289,7 @@ F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c 38790e65d1219f2b7dc26458f39a5252fe7c60cd F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 -F src/func.c fe50a9ab977acc0bb0fcd46741e0071fa388888e +F src/func.c cf5e10af9125b245f1b962e8ba4d520a37818795 F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7c7b7f26306b6aa6ff35b871ad756f43f5db9838 -R 9a71d4f0e52af46677f6902fe927abd2 +P 7f386a9332237100a345035ca213327e21d95855 +R 7d1c2a289a785f636ce602a7472437a7 U drh -Z d3d1e4137b6ba95a64ac245c7769bfd5 +Z 72bb50259efca9e2c772b83f9c123827 diff --git a/manifest.uuid b/manifest.uuid index 9a8ba9a337..fbd1be6203 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7f386a9332237100a345035ca213327e21d95855 \ No newline at end of file +0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 3fbd2b736b..ad4cf73c31 100644 --- a/src/func.c +++ b/src/func.c @@ -747,7 +747,7 @@ static int patternCompare( } c2 = Utf8Read(zString); if( c==c2 ) continue; - if( noCase && c<0x80 && c2<0x80 && sqlite3Tolower(c)==sqlite3Tolower(c2) ){ + if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) ){ continue; } if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue; From 0472af91ec58d0d61101fb9f93970b774e25313a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 30 Dec 2015 15:18:16 +0000 Subject: [PATCH 110/232] Simplification to the xfer-optimization logic. FossilOrigin-Name: f35ba018da843897acca58f70541b940598bc271 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/insert.c | 18 ++---------------- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index e2ed7e0ab2..ca0b8299dc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunnecessary\stests\sfrom\sthe\sLIKE\spattern\smatcher.\s\sSlightly\sfaster\sand\nslightly\ssmaller,\sand\sit\sshould\salso\snow\sworks\swith\sEBCDIC. -D 2015-12-30T14:06:22.463 +C Simplification\sto\sthe\sxfer-optimization\slogic. +D 2015-12-30T15:18:16.130 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -294,7 +294,7 @@ F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 4622e544a6f054b8f36bb06ae85f4aa09fcd6b5b +F src/insert.c 756ae3281e465e5d489a3409ccb4f1041069d530 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7f386a9332237100a345035ca213327e21d95855 -R 7d1c2a289a785f636ce602a7472437a7 +P 0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 +R 5e4c4e8e37aad85efb78266b71a902b5 U drh -Z 72bb50259efca9e2c772b83f9c123827 +Z 91b12f25ba51396a818d59a327f065c9 diff --git a/manifest.uuid b/manifest.uuid index fbd1be6203..3a118b9b08 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 \ No newline at end of file +f35ba018da843897acca58f70541b940598bc271 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 7ac2a2559d..858bcf27af 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1709,20 +1709,6 @@ int sqlite3_xferopt_count; #ifndef SQLITE_OMIT_XFER_OPT -/* -** Check to collation names to see if they are compatible. -*/ -static int xferCompatibleCollation(const char *z1, const char *z2){ - if( z1==0 ){ - return z2==0; - } - if( z2==0 ){ - return 0; - } - return sqlite3StrICmp(z1, z2)==0; -} - - /* ** Check to see if index pSrc is compatible as a source of data ** for index pDest in an insert transfer optimization. The rules @@ -1758,7 +1744,7 @@ static int xferCompatibleIndex(Index *pDest, Index *pSrc){ if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){ return 0; /* Different sort orders */ } - if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){ + if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){ return 0; /* Different collating sequences */ } } @@ -1919,7 +1905,7 @@ static int xferOptimization( if( pDestCol->affinity!=pSrcCol->affinity ){ return 0; /* Affinity must be the same on all columns */ } - if( !xferCompatibleCollation(pDestCol->zColl, pSrcCol->zColl) ){ + if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){ return 0; /* Collating sequence must be the same on all columns */ } if( pDestCol->notNull && !pSrcCol->notNull ){ From f19aa5fa6f1cf6bcb11759a663bc44b10de87c49 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 30 Dec 2015 16:51:20 +0000 Subject: [PATCH 111/232] Changes to the way that the default BINARY collating sequence is recorded result in a slightly smaller and slightly faster executable. More work could be done to make this cleaner. FossilOrigin-Name: 2081d75767dc590b4c8457e5f8e5f18ba5f8eaa7 --- manifest | 26 +++++++++++++------------- manifest.uuid | 2 +- src/build.c | 17 ++++++++--------- src/fkey.c | 6 ++---- src/global.c | 5 +++++ src/insert.c | 7 ++++--- src/main.c | 11 +++++------ src/sqliteInt.h | 3 ++- src/where.c | 8 ++++---- src/whereInt.h | 2 +- 10 files changed, 45 insertions(+), 42 deletions(-) diff --git a/manifest b/manifest index ca0b8299dc..d2e54f9d90 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sto\sthe\sxfer-optimization\slogic. -D 2015-12-30T15:18:16.130 +C Changes\sto\sthe\sway\sthat\sthe\sdefault\sBINARY\scollating\ssequence\sis\srecorded\nresult\sin\sa\sslightly\ssmaller\sand\sslightly\sfaster\sexecutable.\s\sMore\swork\scould\nbe\sdone\sto\smake\sthis\scleaner. +D 2015-12-30T16:51:20.187 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -279,7 +279,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 84ede51e371a11c3dbb3e24ccc5e3e99594a6c00 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 -F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b +F src/build.c 5a8611a01cbf67c736d81304e054ec361ef8963d F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -288,17 +288,17 @@ F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c 38790e65d1219f2b7dc26458f39a5252fe7c60cd F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 +F src/fkey.c e18b3dff7d47c7bcac5ac4fc178a89b9fd322b44 F src/func.c cf5e10af9125b245f1b962e8ba4d520a37818795 -F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9 +F src/global.c bd5a0af3f30b0c01be6db756c626cd3c33a3d260 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 756ae3281e465e5d489a3409ccb4f1041069d530 +F src/insert.c 6b45cc86967da11aa024d034745f93f66d53f650 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b -F src/main.c 2f33510a6a392c606fe64964e695e55ad124242f +F src/main.c b9641a4f650230bfc5dbb0bebf7b33ff4d27586a F src/malloc.c 8f787669e79de26efc42272b5797bc00fff527c6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -338,7 +338,7 @@ F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 6e0c1082268e99aa337de1547df32b220e812fb3 +F src/sqliteInt.h 526c8514d0cb0768d014d04445c6eebd1d0b1a2c F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -412,8 +412,8 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 974928c988681c5157202c79dd9f26afaa7b5086 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba -F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 -F src/whereInt.h e20801d89e34de1912bb6a3babb30c390da27add +F src/where.c c6d3d2f6af57d574a7365ee2b225a5024f2a6bec +F src/whereInt.h 78b6b4de94db84aecbdc07fe3e38f648eb391e9a F src/wherecode.c dfbfe198e418b01f208b489e088edd230c91a4e7 F src/whereexpr.c eebba8340c90de73b3d3bbe8c43b84559b8e6e2c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 -R 5e4c4e8e37aad85efb78266b71a902b5 +P f35ba018da843897acca58f70541b940598bc271 +R 73bd359208653598962819ad055e1d11 U drh -Z 91b12f25ba51396a818d59a327f065c9 +Z 53e385ce34cbe66e9c94953f6b43b3a2 diff --git a/manifest.uuid b/manifest.uuid index 3a118b9b08..9d879ff1c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f35ba018da843897acca58f70541b940598bc271 \ No newline at end of file +2081d75767dc590b4c8457e5f8e5f18ba5f8eaa7 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 765196f821..5d6201a533 100644 --- a/src/build.c +++ b/src/build.c @@ -1635,7 +1635,7 @@ static int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){ zExtra = sqlite3DbMallocZero(db, nByte); if( zExtra==0 ) return SQLITE_NOMEM; memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn); - pIdx->azColl = (char**)zExtra; + pIdx->azColl = (const char**)zExtra; zExtra += sizeof(char*)*N; memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn); pIdx->aiColumn = (i16*)zExtra; @@ -1816,7 +1816,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ if( !hasColumn(pPk->aiColumn, j, i) ){ assert( jnColumn ); pPk->aiColumn[j] = i; - pPk->azColl[j] = "BINARY"; + pPk->azColl[j] = sqlite3StrBINARY; j++; } } @@ -2866,7 +2866,7 @@ Index *sqlite3AllocateIndexObject( p = sqlite3DbMallocZero(db, nByte + nExtra); if( p ){ char *pExtra = ((char*)p)+ROUND8(sizeof(Index)); - p->azColl = (char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol); + p->azColl = (const char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol); p->aiRowLogEst = (LogEst*)pExtra; pExtra += sizeof(LogEst)*(nCol+1); p->aiColumn = (i16*)pExtra; pExtra += sizeof(i16)*nCol; p->aSortOrder = (u8*)pExtra; @@ -3143,7 +3143,7 @@ Index *sqlite3CreateIndex( for(i=0, pListItem=pList->a; inExpr; i++, pListItem++){ Expr *pCExpr; /* The i-th index expression */ int requestedSortOrder; /* ASC or DESC on the i-th expression */ - char *zColl; /* Collation sequence name */ + const char *zColl; /* Collation sequence name */ sqlite3StringToId(pListItem->pExpr); sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0); @@ -3189,7 +3189,7 @@ Index *sqlite3CreateIndex( }else if( j>=0 ){ zColl = pTab->aCol[j].zColl; } - if( !zColl ) zColl = "BINARY"; + if( !zColl ) zColl = sqlite3StrBINARY; if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){ goto exit_create_index; } @@ -3218,7 +3218,7 @@ Index *sqlite3CreateIndex( assert( i==pIndex->nColumn ); }else{ pIndex->aiColumn[i] = XN_ROWID; - pIndex->azColl[i] = "BINARY"; + pIndex->azColl[i] = sqlite3StrBINARY; } sqlite3DefaultRowEst(pIndex); if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex); @@ -4342,9 +4342,8 @@ KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){ if( pKey ){ assert( sqlite3KeyInfoIsWriteable(pKey) ); for(i=0; iazColl[i]; - assert( zColl!=0 ); - pKey->aColl[i] = strcmp(zColl,"BINARY")==0 ? 0 : + const char *zColl = pIdx->azColl[i]; + pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 : sqlite3LocateCollSeq(pParse, zColl); pKey->aSortOrder[i] = pIdx->aSortOrder[i]; } diff --git a/src/fkey.c b/src/fkey.c index b55e2a9813..2abd06c693 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -249,7 +249,7 @@ int sqlite3FkLocateIndex( int i, j; for(i=0; iaiColumn[i]; /* Index of column in parent tbl */ - char *zDfltColl; /* Def. collation for column */ + const char *zDfltColl; /* Def. collation for column */ char *zIdxCol; /* Name of indexed column */ if( iCol<0 ) break; /* No foreign keys against expression indexes */ @@ -258,9 +258,7 @@ int sqlite3FkLocateIndex( ** the default collation sequence for the column, this index is ** unusable. Bail out early in this case. */ zDfltColl = pParent->aCol[iCol].zColl; - if( !zDfltColl ){ - zDfltColl = "BINARY"; - } + if( !zDfltColl ) zDfltColl = sqlite3StrBINARY; if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break; zIdxCol = pParent->aCol[iCol].zName; diff --git a/src/global.c b/src/global.c index ef4fe56ae1..64966b35d7 100644 --- a/src/global.c +++ b/src/global.c @@ -260,3 +260,8 @@ int sqlite3PendingByte = 0x40000000; ** the vdbe.c file. */ const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER; + +/* +** Name of the default collating sequence +*/ +const char sqlite3StrBINARY[] = "BINARY"; diff --git a/src/insert.c b/src/insert.c index 858bcf27af..3e4aac8f4d 100644 --- a/src/insert.c +++ b/src/insert.c @@ -2052,9 +2052,10 @@ static int xferOptimization( ** a VACUUM command. In that case keys may not be written in strictly ** sorted order. */ for(i=0; inColumn; i++){ - char *zColl = pSrcIdx->azColl[i]; - assert( zColl!=0 ); - if( sqlite3_stricmp("BINARY", zColl) ) break; + const char *zColl = pSrcIdx->azColl[i]; + assert( sqlite3_stricmp(sqlite3StrBINARY, zColl)!=0 + || sqlite3StrBINARY==zColl ); + if( sqlite3_stricmp(sqlite3StrBINARY, zColl) ) break; } if( i==pSrcIdx->nColumn ){ idxInsFlags = OPFLAG_USESEEKRESULT; diff --git a/src/main.c b/src/main.c index 5b2130511e..8b75e71500 100644 --- a/src/main.c +++ b/src/main.c @@ -2829,9 +2829,9 @@ static int openDatabase( ** EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating ** functions: */ - createCollation(db, "BINARY", SQLITE_UTF8, 0, binCollFunc, 0); - createCollation(db, "BINARY", SQLITE_UTF16BE, 0, binCollFunc, 0); - createCollation(db, "BINARY", SQLITE_UTF16LE, 0, binCollFunc, 0); + createCollation(db, sqlite3StrBINARY, SQLITE_UTF8, 0, binCollFunc, 0); + createCollation(db, sqlite3StrBINARY, SQLITE_UTF16BE, 0, binCollFunc, 0); + createCollation(db, sqlite3StrBINARY, SQLITE_UTF16LE, 0, binCollFunc, 0); createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0); createCollation(db, "RTRIM", SQLITE_UTF8, (void*)1, binCollFunc, 0); if( db->mallocFailed ){ @@ -2840,7 +2840,7 @@ static int openDatabase( /* EVIDENCE-OF: R-08308-17224 The default collating function for all ** strings is BINARY. */ - db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0); + db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0); assert( db->pDfltColl!=0 ); /* Parse the filename/URI argument. */ @@ -3340,7 +3340,7 @@ int sqlite3_table_column_metadata( primarykey = 1; } if( !zCollSeq ){ - zCollSeq = "BINARY"; + zCollSeq = sqlite3StrBINARY; } error_out: @@ -3948,4 +3948,3 @@ void sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){ sqlite3_free(pSnapshot); } #endif /* SQLITE_ENABLE_SNAPSHOT */ - diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 18d20b1068..99a42d152d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1932,7 +1932,7 @@ struct Index { Index *pNext; /* The next index associated with the same table */ Schema *pSchema; /* Schema containing this index */ u8 *aSortOrder; /* for each column: True==DESC, False==ASC */ - char **azColl; /* Array of collation sequence names for index */ + const char **azColl; /* Array of collation sequence names for index */ Expr *pPartIdxWhere; /* WHERE clause for partial indices */ ExprList *aColExpr; /* Column expressions */ int tnum; /* DB Page containing root of this index */ @@ -3699,6 +3699,7 @@ int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **); void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); #ifndef SQLITE_AMALGAMATION extern const unsigned char sqlite3OpcodeProperty[]; +extern const char sqlite3StrBINARY[]; extern const unsigned char sqlite3UpperToLower[]; extern const unsigned char sqlite3CtypeMap[]; extern const Token sqlite3IntTokens[]; diff --git a/src/where.c b/src/where.c index 7d68664598..e86e26ef1a 100644 --- a/src/where.c +++ b/src/where.c @@ -718,7 +718,7 @@ static void constructAutomaticIndex( idxCols |= cMask; pIdx->aiColumn[n] = pTerm->u.leftColumn; pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); - pIdx->azColl[n] = pColl ? pColl->zName : "BINARY"; + pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY; n++; } } @@ -730,20 +730,20 @@ static void constructAutomaticIndex( for(i=0; iaiColumn[n] = i; - pIdx->azColl[n] = "BINARY"; + pIdx->azColl[n] = sqlite3StrBINARY; n++; } } if( pSrc->colUsed & MASKBIT(BMS-1) ){ for(i=BMS-1; inCol; i++){ pIdx->aiColumn[n] = i; - pIdx->azColl[n] = "BINARY"; + pIdx->azColl[n] = sqlite3StrBINARY; n++; } } assert( n==nKeyCol ); pIdx->aiColumn[n] = XN_ROWID; - pIdx->azColl[n] = "BINARY"; + pIdx->azColl[n] = sqlite3StrBINARY; /* Create the automatic index */ assert( pLevel->iIdxCur>=0 ); diff --git a/src/whereInt.h b/src/whereInt.h index 63d2d71cb4..1a189980ef 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -288,7 +288,7 @@ struct WhereTerm { struct WhereScan { WhereClause *pOrigWC; /* Original, innermost WhereClause */ WhereClause *pWC; /* WhereClause currently being scanned */ - char *zCollName; /* Required collating sequence, if not NULL */ + const char *zCollName; /* Required collating sequence, if not NULL */ Expr *pIdxExpr; /* Search for this index expression */ char idxaff; /* Must match this affinity, if zCollName!=NULL */ unsigned char nEquiv; /* Number of entries in aEquiv[] */ From d11e397b2c0aa6e53209cc46dcf3929252c98243 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 30 Dec 2015 19:58:57 +0000 Subject: [PATCH 112/232] Updates to fts5 to support detail=none mode. As of this commit, many cases are still broken. FossilOrigin-Name: ac8f4cf0cede6bcbe47eeefb85d80a27e9278212 --- ext/fts5/fts5_hash.c | 166 ++++++++++++++++++++------------- ext/fts5/fts5_index.c | 143 +++++++++++++++++++++++----- ext/fts5/test/fts5simple2.test | 75 +++++++++++++++ manifest | 15 +-- manifest.uuid | 2 +- 5 files changed, 309 insertions(+), 92 deletions(-) create mode 100644 ext/fts5/test/fts5simple2.test diff --git a/ext/fts5/fts5_hash.c b/ext/fts5/fts5_hash.c index a9f1c13ede..50ca082711 100644 --- a/ext/fts5/fts5_hash.c +++ b/ext/fts5/fts5_hash.c @@ -63,6 +63,7 @@ struct Fts5HashEntry { int iSzPoslist; /* Offset of space for 4-byte poslist size */ int nData; /* Total bytes of data (incl. structure) */ u8 bDel; /* Set delete-flag @ iSzPoslist */ + u8 bContent; /* Set content-flag (detail=none mode) */ int iCol; /* Column of last value written */ int iPos; /* Position of last value written */ @@ -184,26 +185,46 @@ static int fts5HashResize(Fts5Hash *pHash){ return SQLITE_OK; } -static void fts5HashAddPoslistSize(Fts5HashEntry *p){ +static void fts5HashAddPoslistSize(Fts5Hash *pHash, Fts5HashEntry *p){ if( p->iSzPoslist ){ u8 *pPtr = (u8*)p; - int nSz = (p->nData - p->iSzPoslist - 1); /* Size in bytes */ - int nPos = nSz*2 + p->bDel; /* Value of nPos field */ - - assert( p->bDel==0 || p->bDel==1 ); - if( nPos<=127 ){ - pPtr[p->iSzPoslist] = (u8)nPos; + if( pHash->eDetail==FTS5_DETAIL_NONE ){ + assert( p->nData==p->iSzPoslist ); + if( p->bDel ){ + pPtr[p->nData++] = 0x00; + if( p->bContent ){ + pPtr[p->nData++] = 0x00; + } + } }else{ - int nByte = sqlite3Fts5GetVarintLen((u32)nPos); - memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz); - sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos); - p->nData += (nByte-1); + int nSz = (p->nData - p->iSzPoslist - 1); /* Size in bytes */ + int nPos = nSz*2 + p->bDel; /* Value of nPos field */ + + assert( p->bDel==0 || p->bDel==1 ); + if( nPos<=127 ){ + pPtr[p->iSzPoslist] = (u8)nPos; + }else{ + int nByte = sqlite3Fts5GetVarintLen((u32)nPos); + memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz); + sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos); + p->nData += (nByte-1); + } } - p->bDel = 0; + p->iSzPoslist = 0; + p->bDel = 0; + p->bContent = 0; } } +/* +** Add an entry to the in-memory hash table. The key is the concatenation +** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos). +** +** (bByte || pToken) -> (iRowid,iCol,iPos) +** +** Or, if iCol is negative, then the value is a delete marker. +*/ int sqlite3Fts5HashWrite( Fts5Hash *pHash, i64 iRowid, /* Rowid for this entry */ @@ -233,15 +254,18 @@ int sqlite3Fts5HashWrite( /* If an existing hash entry cannot be found, create a new one. */ if( p==0 ){ + /* Figure out how much space to allocate */ int nByte = FTS5_HASHENTRYSIZE + (nToken+1) + 1 + 64; if( nByte<128 ) nByte = 128; + /* Grow the Fts5Hash.aSlot[] array if necessary. */ if( (pHash->nEntry*2)>=pHash->nSlot ){ int rc = fts5HashResize(pHash); if( rc!=SQLITE_OK ) return rc; iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken); } + /* Allocate new Fts5HashEntry and add it to the hash table. */ p = (Fts5HashEntry*)sqlite3_malloc(nByte); if( !p ) return SQLITE_NOMEM; memset(p, 0, FTS5_HASHENTRYSIZE); @@ -251,79 +275,95 @@ int sqlite3Fts5HashWrite( assert( iHash==fts5HashKey(pHash->nSlot, (u8*)p->zKey, nToken+1) ); p->zKey[nToken+1] = '\0'; p->nData = nToken+1 + 1 + FTS5_HASHENTRYSIZE; - p->nData += sqlite3Fts5PutVarint(&((u8*)p)[p->nData], iRowid); - p->iSzPoslist = p->nData; - p->nData += 1; - p->iRowid = iRowid; - p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1); p->pHashNext = pHash->aSlot[iHash]; pHash->aSlot[iHash] = p; pHash->nEntry++; - nIncr += p->nData; - } - /* Check there is enough space to append a new entry. Worst case scenario - ** is: - ** - ** + 9 bytes for a new rowid, - ** + 4 byte reserved for the "poslist size" varint. - ** + 1 byte for a "new column" byte, - ** + 3 bytes for a new column number (16-bit max) as a varint, - ** + 5 bytes for the new position offset (32-bit max). - */ - if( (p->nAlloc - p->nData) < (9 + 4 + 1 + 3 + 5) ){ - int nNew = p->nAlloc * 2; - Fts5HashEntry *pNew; - Fts5HashEntry **pp; - pNew = (Fts5HashEntry*)sqlite3_realloc(p, nNew); - if( pNew==0 ) return SQLITE_NOMEM; - pNew->nAlloc = nNew; - for(pp=&pHash->aSlot[iHash]; *pp!=p; pp=&(*pp)->pHashNext); - *pp = pNew; - p = pNew; + /* Add the first rowid field to the hash-entry */ + p->nData += sqlite3Fts5PutVarint(&((u8*)p)[p->nData], iRowid); + p->iRowid = iRowid; + + p->iSzPoslist = p->nData; + if( pHash->eDetail!=FTS5_DETAIL_NONE ){ + p->nData += 1; + p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1); + } + + nIncr += p->nData; + }else{ + + /* Appending to an existing hash-entry. Check that there is enough + ** space to append the largest possible new entry. Worst case scenario + ** is: + ** + ** + 9 bytes for a new rowid, + ** + 4 byte reserved for the "poslist size" varint. + ** + 1 byte for a "new column" byte, + ** + 3 bytes for a new column number (16-bit max) as a varint, + ** + 5 bytes for the new position offset (32-bit max). + */ + if( (p->nAlloc - p->nData) < (9 + 4 + 1 + 3 + 5) ){ + int nNew = p->nAlloc * 2; + Fts5HashEntry *pNew; + Fts5HashEntry **pp; + pNew = (Fts5HashEntry*)sqlite3_realloc(p, nNew); + if( pNew==0 ) return SQLITE_NOMEM; + pNew->nAlloc = nNew; + for(pp=&pHash->aSlot[iHash]; *pp!=p; pp=&(*pp)->pHashNext); + *pp = pNew; + p = pNew; + } + nIncr -= p->nData; } + assert( (p->nAlloc - p->nData) >= (9 + 4 + 1 + 3 + 5) ); + pPtr = (u8*)p; - nIncr -= p->nData; /* If this is a new rowid, append the 4-byte size field for the previous ** entry, and the new rowid for this entry. */ if( iRowid!=p->iRowid ){ - fts5HashAddPoslistSize(p); + fts5HashAddPoslistSize(pHash, p); p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid); - p->iSzPoslist = p->nData; - p->nData += 1; - p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1); - p->iPos = 0; p->iRowid = iRowid; bNew = 1; + p->iSzPoslist = p->nData; + if( pHash->eDetail!=FTS5_DETAIL_NONE ){ + p->nData += 1; + p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1); + p->iPos = 0; + } } if( iCol>=0 ){ - /* Append a new column value, if necessary */ - assert( iCol>=p->iCol ); - if( iCol!=p->iCol ){ - if( pHash->eDetail==FTS5_DETAIL_FULL ){ - pPtr[p->nData++] = 0x01; - p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iCol); - p->iCol = iCol; - p->iPos = 0; - }else{ - bNew = 1; - p->iCol = iPos = iCol; + if( pHash->eDetail==FTS5_DETAIL_NONE ){ + p->bContent = 1; + }else{ + /* Append a new column value, if necessary */ + assert( iCol>=p->iCol ); + if( iCol!=p->iCol ){ + if( pHash->eDetail==FTS5_DETAIL_FULL ){ + pPtr[p->nData++] = 0x01; + p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iCol); + p->iCol = iCol; + p->iPos = 0; + }else{ + bNew = 1; + p->iCol = iPos = iCol; + } } - } - /* Append the new position offset, if necessary */ - if( bNew ){ - p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iPos - p->iPos + 2); - p->iPos = iPos; + /* Append the new position offset, if necessary */ + if( bNew ){ + p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iPos - p->iPos + 2); + p->iPos = iPos; + } } }else{ /* This is a delete. Set the delete flag. */ p->bDel = 1; } - nIncr += p->nData; + nIncr += p->nData; *pHash->pnByte += nIncr; return SQLITE_OK; } @@ -437,7 +477,7 @@ int sqlite3Fts5HashQuery( } if( p ){ - fts5HashAddPoslistSize(p); + fts5HashAddPoslistSize(pHash, p); *ppDoclist = (const u8*)&p->zKey[nTerm+1]; *pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1); }else{ @@ -473,7 +513,7 @@ void sqlite3Fts5HashScanEntry( Fts5HashEntry *p; if( (p = pHash->pScan) ){ int nTerm = (int)strlen(p->zKey); - fts5HashAddPoslistSize(p); + fts5HashAddPoslistSize(pHash, p); *pzTerm = p->zKey; *ppDoclist = (const u8*)&p->zKey[nTerm+1]; *pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1); diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 34caa45072..e85fb70311 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -452,7 +452,8 @@ struct Fts5SegIter { Fts5Buffer term; /* Current term */ i64 iRowid; /* Current rowid */ int nPos; /* Number of bytes in current position list */ - int bDel; /* True if the delete flag is set */ + u8 bDel; /* True if the delete flag is set */ + // u8 bContent; /* True if has content (detail=none mode) */ }; /* @@ -466,7 +467,6 @@ struct Fts5SegIter { #define FTS5_SEGITER_ONETERM 0x01 #define FTS5_SEGITER_REVERSE 0x02 - /* ** Argument is a pointer to an Fts5Data structure that contains a leaf ** page. This macro evaluates to true if the leaf contains no terms, or @@ -1492,13 +1492,28 @@ static int fts5GetPoslistSize(const u8 *p, int *pnSz, int *pbDel){ static void fts5SegIterLoadNPos(Fts5Index *p, Fts5SegIter *pIter){ if( p->rc==SQLITE_OK ){ int iOff = pIter->iLeafOffset; /* Offset to read at */ - int nSz; ASSERT_SZLEAF_OK(pIter->pLeaf); - fts5FastGetVarint32(pIter->pLeaf->p, iOff, nSz); - pIter->bDel = (nSz & 0x0001); - pIter->nPos = nSz>>1; + if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){ + pIter->bDel = 0; + pIter->nPos = 1; + if( iOffpLeaf->szLeaf && pIter->pLeaf->p[iOff]==0 ){ + pIter->bDel = 1; + iOff++; + if( iOffpLeaf->szLeaf && pIter->pLeaf->p[iOff]==0 ){ + pIter->nPos = 1; + iOff++; + }else{ + pIter->nPos = 0; + } + } + }else{ + int nSz; + fts5FastGetVarint32(pIter->pLeaf->p, iOff, nSz); + pIter->bDel = (nSz & 0x0001); + pIter->nPos = nSz>>1; + assert_nc( pIter->nPos>=0 ); + } pIter->iLeafOffset = iOff; - assert_nc( pIter->nPos>=0 ); } } @@ -1758,7 +1773,11 @@ static void fts5SegIterNext( int n = pLeaf->szLeaf; ASSERT_SZLEAF_OK(pLeaf); - iOff = pIter->iLeafOffset + pIter->nPos; + if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){ + iOff = pIter->iLeafOffset; + }else{ + iOff = pIter->iLeafOffset + pIter->nPos; + } if( iOffrc==SQLITE_OK ); fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz); pIter->bDel = (nSz & 0x0001); pIter->nPos = nSz>>1; assert_nc( pIter->nPos>=0 ); +#endif + fts5SegIterLoadNPos(p, pIter); } } } @@ -4165,6 +4191,16 @@ static int fts5IndexExtractCol( return p - (*pa); } +static int fts5AppendRowid( + Fts5Index *p, + i64 iDelta, + Fts5IndexIter *pMulti, + Fts5Colset *pColset, + Fts5Buffer *pBuf +){ + fts5BufferAppendVarint(&p->rc, pBuf, iDelta); + return 0; +} /* ** Iterator pMulti currently points to a valid entry (not EOF). This @@ -4305,6 +4341,67 @@ static void fts5MergeAppendDocid( (iLastRowid) = (iRowid); \ } +/* +** Swap the contents of buffer *p1 with that of *p2. +*/ +static void fts5BufferSwap(Fts5Buffer *p1, Fts5Buffer *p2){ + Fts5Buffer tmp = *p1; + *p1 = *p2; + *p2 = tmp; +} + +static void fts5NextRowid(Fts5Buffer *pBuf, int *piOff, i64 *piRowid){ + int i = *piOff; + if( i>=pBuf->n ){ + *piOff = -1; + }else{ + u64 iVal; + *piOff = i + sqlite3Fts5GetVarint(&pBuf->p[i], &iVal); + *piRowid += iVal; + } +} + +/* +** This is the equivalent of fts5MergePrefixLists() for detail=none mode. +** In this case the buffers consist of a delta-encoded list of rowids only. +*/ +static void fts5MergeRowidLists( + Fts5Index *p, /* FTS5 backend object */ + Fts5Buffer *p1, /* First list to merge */ + Fts5Buffer *p2 /* Second list to merge */ +){ + int i1 = 0; + int i2 = 0; + i64 iRowid1 = 0; + i64 iRowid2 = 0; + i64 iOut = 0; + + Fts5Buffer out; + memset(&out, 0, sizeof(out)); + sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n); + if( p->rc ) return; + + fts5NextRowid(p1, &i1, &iRowid1); + fts5NextRowid(p1, &i2, &iRowid2); + while( i1>=0 || i2>=0 ){ + if( i1>=0 && (i2<0 || iRowid1=0 && iRowid1==iRowid2 ){ + fts5NextRowid(p1, &i1, &iRowid1); + } + } + } + + fts5BufferSwap(&out, p1); + fts5BufferFree(&out); +} + /* ** Buffers p1 and p2 contain doclists. This function merges the content ** of the two doclists together and sets buffer p1 to the result before @@ -4392,15 +4489,6 @@ static void fts5MergePrefixLists( } } -/* -** Swap the contents of buffer *p1 with that of *p2. -*/ -static void fts5BufferSwap(Fts5Buffer *p1, Fts5Buffer *p2){ - Fts5Buffer tmp = *p1; - *p1 = *p2; - *p2 = tmp; -} - static void fts5SetupPrefixIter( Fts5Index *p, /* Index to read from */ int bDesc, /* True for "ORDER BY rowid DESC" */ @@ -4413,6 +4501,16 @@ static void fts5SetupPrefixIter( Fts5Buffer *aBuf; const int nBuf = 32; + void (*xMerge)(Fts5Index*, Fts5Buffer*, Fts5Buffer*); + int (*xAppend)(Fts5Index*, i64, Fts5IndexIter*, Fts5Colset*, Fts5Buffer*); + if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){ + xMerge = fts5MergeRowidLists; + xAppend = fts5AppendRowid; + }else{ + xMerge = fts5MergePrefixLists; + xAppend = fts5AppendPoslist; + } + aBuf = (Fts5Buffer*)fts5IdxMalloc(p, sizeof(Fts5Buffer)*nBuf); pStruct = fts5StructureRead(p); @@ -4445,21 +4543,21 @@ static void fts5SetupPrefixIter( fts5BufferSwap(&doclist, &aBuf[i]); fts5BufferZero(&doclist); }else{ - fts5MergePrefixLists(p, &doclist, &aBuf[i]); + xMerge(p, &doclist, &aBuf[i]); fts5BufferZero(&aBuf[i]); } } iLastRowid = 0; } - if( !fts5AppendPoslist(p, iRowid-iLastRowid, p1, pColset, &doclist) ){ + if( !xAppend(p, iRowid-iLastRowid, p1, pColset, &doclist) ){ iLastRowid = iRowid; } } for(i=0; irc==SQLITE_OK ){ - fts5MergePrefixLists(p, &doclist, &aBuf[i]); + xMerge(p, &doclist, &aBuf[i]); } fts5BufferFree(&aBuf[i]); } @@ -4854,6 +4952,9 @@ int sqlite3Fts5IterPoslist( assert( pIter->pIndex->rc==SQLITE_OK ); *piRowid = pSeg->iRowid; + if( eDetail==FTS5_DETAIL_NONE ){ + *pn = pSeg->nPos; + }else if( eDetail==FTS5_DETAIL_FULL && pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf ){ diff --git a/ext/fts5/test/fts5simple2.test b/ext/fts5/test/fts5simple2.test new file mode 100644 index 0000000000..883b27e024 --- /dev/null +++ b/ext/fts5/test/fts5simple2.test @@ -0,0 +1,75 @@ +# 2015 September 05 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5simple2 + +# If SQLITE_ENABLE_FTS5 is defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none); + INSERT INTO t1 VALUES('a b c'); +} +do_execsql_test 1.1 { + SELECT rowid FROM t1('c a b') +} {1} + +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none); + BEGIN; + INSERT INTO t1 VALUES('b c d'); + INSERT INTO t1 VALUES('b c d'); + COMMIT; +} +do_execsql_test 2.1 { + SELECT rowid FROM t1('b c d') +} {1 2} + +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 3.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none); + BEGIN; + INSERT INTO t1 VALUES('b c d'); + INSERT INTO t1 VALUES('b c d'); +} +do_execsql_test 3.1 { + SELECT rowid FROM t1('b c d'); COMMIT; +} {1 2} + +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 4.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none); + BEGIN; + INSERT INTO t1 VALUES('a1 b1 c1'); + INSERT INTO t1 VALUES('a2 b2 c2'); + INSERT INTO t1 VALUES('a3 b3 c3'); + COMMIT; +} +breakpoint +do_execsql_test 4.1 { + SELECT rowid FROM t1('b*'); +} {1 2 3} + + +finish_test + diff --git a/manifest b/manifest index 8b22a0fdc2..64a15ecd6d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sxPhraseFirstColumn()\sand\sxPhraseNextColumn()\sAPI\sfunctions\sto\sfts5.\sFor\siterating\sthrough\sthe\sset\sof\scolumns\sthat\scontain\sintances\sof\sa\sphrase. -D 2015-12-29T19:35:03.765 +C Updates\sto\sfts5\sto\ssupport\sdetail=none\smode.\sAs\sof\sthis\scommit,\smany\scases\sare\sstill\sbroken. +D 2015-12-30T19:58:57.068 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -102,8 +102,8 @@ F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 F ext/fts5/fts5_expr.c 08ee4f342a2b1fd82a5dccd0b9b3cde4921a8be5 -F ext/fts5/fts5_hash.c 8b510868502ec31119409fc7022edc37c27b5c40 -F ext/fts5/fts5_index.c ca8310eaa286e6c1e4c4581a420b7c3a1ec6302c +F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 +F ext/fts5/fts5_index.c 94dec3c322e9179fb0dd3239d6fe9555b9c621ec F ext/fts5/fts5_main.c 23f3912ff44172859c771eb55cb57778fd662e89 F ext/fts5/fts5_storage.c 076a3356536a8831eb6e554195171d5c249cd179 F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb @@ -170,6 +170,7 @@ F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 F ext/fts5/test/fts5simple.test a599b7577bc3827a9a678add3b43d8b818b93456 +F ext/fts5/test/fts5simple2.test 70b98039c8a73341bb4a632adb3018e1017e3beb F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 F ext/fts5/test/fts5unicode.test fbef8d8a3b4b88470536cc57604a82ca52e51841 @@ -1406,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 228b4d10e38f7d70e1b008c3c9b4a1ae3e32e30d -R 9b7a210ea600814406fb8e0040363d54 +P 8c30605bcd0a78a5015948171145bc6f640b8358 +R 393cc400b4b232cee04e2e069dffc8fe U dan -Z 50bb7fa01e78a4726d7b3d5426b2a1ed +Z c9f782e6b3f3ae84d42c40bf56b4157b diff --git a/manifest.uuid b/manifest.uuid index f3ee4608cf..aecac29523 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c30605bcd0a78a5015948171145bc6f640b8358 \ No newline at end of file +ac8f4cf0cede6bcbe47eeefb85d80a27e9278212 \ No newline at end of file From e5520e2f0648268bfd1ff3677fc83752150de34a Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 31 Dec 2015 04:34:26 +0000 Subject: [PATCH 113/232] Small size and performance optimization to the VDBE comparison opcodes. FossilOrigin-Name: 7a0b9413fa94d3f4fa9751ddf9b213a1238954f1 --- manifest | 17 ++++++++--------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- src/vdbe.c | 13 ++++++------- src/vdbeaux.c | 2 +- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 4fb51ec6d3..63b6375876 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reduce\sthe\ssize\sof\sthe\sCellInfo\sobject\sfrom\s32\sto\s24\sbytes\son\s64-bit\smachines,\nfor\sa\ssmall\sperformance\sincrease\sand\slibrary\ssize\sreduction. -D 2015-12-30T18:18:46.481 +C Small\ssize\sand\sperformance\soptimization\sto\sthe\sVDBE\scomparison\sopcodes. +D 2015-12-31T04:34:26.528 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -338,7 +338,7 @@ F src/shell.c ace08b69cd9702143cf87b5bd20b744a56f832fd F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 526c8514d0cb0768d014d04445c6eebd1d0b1a2c +F src/sqliteInt.h d68c05b69767224eea116f07793a531286946776 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -398,11 +398,11 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 984c2be6691d3f67deb2e6747c2132150d776f32 +F src/vdbe.c 39d7628bb8eed10a5378adcf97cca6dce7829a8f F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 68082d9991fc1b8625d34c8b5db1775c9dee426e +F src/vdbeaux.c ca523180c128dc6c64894efc61eb14374117c864 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,8 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3d81dfe3bc5ca9588b7796769d9be7a182f38b1c 7850715406458a61cff9eba5ad915f61f6d99482 -R 53c67154b7bbcd33ca0c18e39c81df1f -T +closed 7850715406458a61cff9eba5ad915f61f6d99482 +P 6a4cfc7ab62046eb718ce59eff6b632f239312ac +R 38bdbc546325a042578b5eb533fe5e2f U drh -Z f674907b91bbe0647e025dbc39f72b55 +Z 5aa34f553c2d2033c492b62e2956faac diff --git a/manifest.uuid b/manifest.uuid index 4b77ee57d3..7de58c7d75 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a4cfc7ab62046eb718ce59eff6b632f239312ac \ No newline at end of file +7a0b9413fa94d3f4fa9751ddf9b213a1238954f1 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 99a42d152d..299fe8647d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1522,7 +1522,7 @@ struct Column { char *zColl; /* Collating sequence. If NULL, use the default */ u8 notNull; /* An OE_ code for handling a NOT NULL constraint */ char affinity; /* One of the SQLITE_AFF_... values */ - u8 szEst; /* Estimated size of this column. INT==1 */ + u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */ u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */ }; diff --git a/src/vdbe.c b/src/vdbe.c index 894758a01c..5021720c54 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1996,21 +1996,21 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ /* Neither operand is NULL. Do a comparison. */ affinity = pOp->p5 & SQLITE_AFF_MASK; if( affinity>=SQLITE_AFF_NUMERIC ){ - if( (pIn1->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ + if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ applyNumericAffinity(pIn1,0); } - if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ + if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ applyNumericAffinity(pIn3,0); } }else if( affinity==SQLITE_AFF_TEXT ){ - if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){ + if( (flags1 & MEM_Str)==0 && (flags1 & (MEM_Int|MEM_Real))!=0 ){ testcase( pIn1->flags & MEM_Int ); testcase( pIn1->flags & MEM_Real ); sqlite3VdbeMemStringify(pIn1, encoding, 1); testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); } - if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){ + if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){ testcase( pIn3->flags & MEM_Int ); testcase( pIn3->flags & MEM_Real ); sqlite3VdbeMemStringify(pIn3, encoding, 1); @@ -2019,15 +2019,14 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ } } assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); - if( pIn1->flags & MEM_Zero ){ + if( flags1 & MEM_Zero ){ sqlite3VdbeMemExpandBlob(pIn1); flags1 &= ~MEM_Zero; } - if( pIn3->flags & MEM_Zero ){ + if( flags3 & MEM_Zero ){ sqlite3VdbeMemExpandBlob(pIn3); flags3 &= ~MEM_Zero; } - if( db->mallocFailed ) goto no_mem; res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl); } switch( pOp->opcode ){ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index a266177ac5..10353e839f 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3748,7 +3748,7 @@ int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){ return -1; } - assert( pMem1->enc==pMem2->enc ); + assert( pMem1->enc==pMem2->enc || pMem1->db->mallocFailed ); assert( pMem1->enc==SQLITE_UTF8 || pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE ); From e6110505c91d8f1f6b6e34c069bc8fdd4a104c99 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 31 Dec 2015 15:34:03 +0000 Subject: [PATCH 114/232] Fix harmless compiler warnings associated with SQLITE_ENABLE_HIDDEN_COLUMNS. FossilOrigin-Name: 9c392c1019ee15f27c8e05b41246d2844f91f6c0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 4 ++-- src/sqliteInt.h | 6 +++++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 63b6375876..74fac31c3e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\ssize\sand\sperformance\soptimization\sto\sthe\sVDBE\scomparison\sopcodes. -D 2015-12-31T04:34:26.528 +C Fix\sharmless\scompiler\swarnings\sassociated\swith\sSQLITE_ENABLE_HIDDEN_COLUMNS. +D 2015-12-31T15:34:03.678 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -279,7 +279,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 5ac3f868d4f20a67f0f00a1014940f902b511558 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 -F src/build.c 5a8611a01cbf67c736d81304e054ec361ef8963d +F src/build.c 249e9605fc423feeca0316e7018df04da8c345d5 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -338,7 +338,7 @@ F src/shell.c ace08b69cd9702143cf87b5bd20b744a56f832fd F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h d68c05b69767224eea116f07793a531286946776 +F src/sqliteInt.h 92f83ab4612141f95cdd663ea55fa4528f3f8c2a F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6a4cfc7ab62046eb718ce59eff6b632f239312ac -R 38bdbc546325a042578b5eb533fe5e2f +P 7a0b9413fa94d3f4fa9751ddf9b213a1238954f1 +R 793126e19a875ee34b3c925c6d9cf329 U drh -Z 5aa34f553c2d2033c492b62e2956faac +Z 7a54e045f07d4dcaeff2de7160303dce diff --git a/manifest.uuid b/manifest.uuid index 7de58c7d75..6672b8e8dd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7a0b9413fa94d3f4fa9751ddf9b213a1238954f1 \ No newline at end of file +9c392c1019ee15f27c8e05b41246d2844f91f6c0 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 5d6201a533..553e249fa4 100644 --- a/src/build.c +++ b/src/build.c @@ -1047,15 +1047,15 @@ begin_table_error: /* Set properties of a table column based on the (magical) ** name of the column. */ -void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ #if SQLITE_ENABLE_HIDDEN_COLUMNS +void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){ pCol->colFlags |= COLFLAG_HIDDEN; }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){ pTab->tabFlags |= TF_OOOHidden; } -#endif } +#endif /* diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 299fe8647d..e1fe6dae79 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3348,7 +3348,11 @@ void sqlite3OpenMasterTable(Parse *, int); Index *sqlite3PrimaryKeyIndex(Table*); i16 sqlite3ColumnOfIndex(Index*, i16); void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); -void sqlite3ColumnPropertiesFromName(Table*, Column*); +#if SQLITE_ENABLE_HIDDEN_COLUMNS + void sqlite3ColumnPropertiesFromName(Table*, Column*); +#else +# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */ +#endif void sqlite3AddColumn(Parse*,Token*); void sqlite3AddNotNull(Parse*, int); void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); From 841243156ff222587f59e1572ffe0f8b20bb42bb Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 31 Dec 2015 17:36:58 +0000 Subject: [PATCH 115/232] Fix some problems with fts5 detail=none tables. Some still remain. FossilOrigin-Name: 6a6f7bc40d6b4c8a4a254a9098c9d2f31fde69ca --- ext/fts5/fts5_index.c | 51 ++++++++++++++++++------- ext/fts5/test/fts5simple2.test | 70 +++++++++++++++++++++++++++++++++- manifest | 14 +++---- manifest.uuid | 2 +- 4 files changed, 114 insertions(+), 23 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index e85fb70311..3f342195f0 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -1630,6 +1630,7 @@ static void fts5SegIterInit( ** byte of the position list content associated with said rowid. */ static void fts5SegIterReverseInitPage(Fts5Index *p, Fts5SegIter *pIter){ + int eDetail = p->pConfig->eDetail; int n = pIter->pLeaf->szLeaf; int i = pIter->iLeafOffset; u8 *a = pIter->pLeaf->p; @@ -1645,12 +1646,18 @@ static void fts5SegIterReverseInitPage(Fts5Index *p, Fts5SegIter *pIter){ int nPos; int bDummy; - i += fts5GetPoslistSize(&a[i], &nPos, &bDummy); - i += nPos; + if( eDetail==FTS5_DETAIL_NONE ){ + /* todo */ + + }else{ + i += fts5GetPoslistSize(&a[i], &nPos, &bDummy); + i += nPos; + } if( i>=n ) break; i += fts5GetVarint(&a[i], (u64*)&iDelta); pIter->iRowid += iDelta; + /* If necessary, grow the pIter->aRowidOffset[] array. */ if( iRowidOffset>=pIter->nRowidOffset ){ int nNew = pIter->nRowidOffset + 8; int *aNew = (int*)sqlite3_realloc(pIter->aRowidOffset, nNew*sizeof(int)); @@ -1754,8 +1761,10 @@ static void fts5SegIterNext( pIter->iRowidOffset--; pIter->iLeafOffset = iOff = pIter->aRowidOffset[pIter->iRowidOffset]; - iOff += fts5GetPoslistSize(&a[iOff], &nPos, &bDummy); - iOff += nPos; + if( p->pConfig->eDetail!=FTS5_DETAIL_NONE ){ + iOff += fts5GetPoslistSize(&a[iOff], &nPos, &bDummy); + iOff += nPos; + } fts5GetVarint(&a[iOff], (u64*)&iDelta); pIter->iRowid -= iDelta; fts5SegIterLoadNPos(p, pIter); @@ -1893,6 +1902,7 @@ static void fts5SegIterNext( ** the doclist. */ static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){ + int eDetail = p->pConfig->eDetail; Fts5DlidxIter *pDlidx = pIter->pDlidx; Fts5Data *pLast = 0; int pgnoLast = 0; @@ -1907,7 +1917,9 @@ static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){ /* Currently, Fts5SegIter.iLeafOffset points to the first byte of ** position-list content for the current rowid. Back it up so that it ** points to the start of the position-list size field. */ - pIter->iLeafOffset -= sqlite3Fts5GetVarintLen(pIter->nPos*2+pIter->bDel); + if( eDetail!=FTS5_DETAIL_NONE ){ + pIter->iLeafOffset -= sqlite3Fts5GetVarintLen(pIter->nPos*2+pIter->bDel); + } /* If this condition is true then the largest rowid for the current ** term may not be stored on the current page. So search forward to @@ -2895,6 +2907,9 @@ static void fts5ChunkIterate( int pgno = pSeg->iLeafPgno; int pgnoSave = 0; + /* This function does notmwork with detail=none databases. */ + assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE ); + if( (pSeg->flags & FTS5_SEGITER_REVERSE)==0 ){ pgnoSave = pgno+1; } @@ -3318,8 +3333,7 @@ static void fts5WriteAppendTerm( static void fts5WriteAppendRowid( Fts5Index *p, Fts5SegWriter *pWriter, - i64 iRowid, - int nPos + i64 iRowid ){ if( p->rc==SQLITE_OK ){ Fts5PageWriter *pPage = &pWriter->writer; @@ -3346,8 +3360,6 @@ static void fts5WriteAppendRowid( pWriter->iPrevRowid = iRowid; pWriter->bFirstRowidInDoclist = 0; pWriter->bFirstRowidInPage = 0; - - fts5BufferAppendVarint(&p->rc, &pPage->buf, nPos); } } @@ -3543,6 +3555,7 @@ static void fts5IndexMergeLevel( Fts5StructureSegment *pSeg; /* Output segment */ Fts5Buffer term; int bOldest; /* True if the output segment is the oldest */ + int eDetail = p->pConfig->eDetail; assert( iLvlnLevel ); assert( pLvl->nMerge<=pLvl->nSeg ); @@ -3612,11 +3625,21 @@ static void fts5IndexMergeLevel( /* Append the rowid to the output */ /* WRITEPOSLISTSIZE */ - nPos = pSegIter->nPos*2 + pSegIter->bDel; - fts5WriteAppendRowid(p, &writer, fts5MultiIterRowid(pIter), nPos); + fts5WriteAppendRowid(p, &writer, fts5MultiIterRowid(pIter)); - /* Append the position-list data to the output */ - fts5ChunkIterate(p, pSegIter, (void*)&writer, fts5MergeChunkCallback); + if( eDetail==FTS5_DETAIL_NONE ){ + if( pSegIter->bDel ){ + fts5BufferAppendVarint(&p->rc, &writer.writer.buf, 0); + if( pSegIter->nPos>0 ){ + fts5BufferAppendVarint(&p->rc, &writer.writer.buf, 0); + } + } + }else{ + /* Append the position-list data to the output */ + nPos = pSegIter->nPos*2 + pSegIter->bDel; + fts5BufferAppendVarint(&p->rc, &writer.writer.buf, nPos); + fts5ChunkIterate(p, pSegIter, (void*)&writer, fts5MergeChunkCallback); + } } /* Flush the last leaf page to disk. Set the output segment b-tree height @@ -4382,7 +4405,7 @@ static void fts5MergeRowidLists( if( p->rc ) return; fts5NextRowid(p1, &i1, &iRowid1); - fts5NextRowid(p1, &i2, &iRowid2); + fts5NextRowid(p2, &i2, &iRowid2); while( i1>=0 || i2>=0 ){ if( i1>=0 && (i2<0 || iRowid1 Date: Thu, 31 Dec 2015 18:39:14 +0000 Subject: [PATCH 116/232] Fix the fts5 integrity-check code so that it works with detail=none tables. FossilOrigin-Name: 3a1df69e58e5830da1dff158eedbe3817743f58f --- ext/fts5/fts5_index.c | 45 +++++++++++++++++---------- ext/fts5/fts5_storage.c | 33 +++++++++++++++++--- ext/fts5/test/fts5simple2.test | 56 ++++++++++++++++++++++++---------- manifest | 16 +++++----- manifest.uuid | 2 +- 5 files changed, 106 insertions(+), 46 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 3f342195f0..ef27d73c31 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -5199,6 +5199,7 @@ static int fts5QueryCksum( int flags, /* Flags for Fts5IndexQuery */ u64 *pCksum /* IN/OUT: Checksum value */ ){ + int eDetail = p->pConfig->eDetail; u64 cksum = *pCksum; Fts5IndexIter *pIdxIter = 0; Fts5Buffer buf = {0, 0, 0}; @@ -5206,17 +5207,24 @@ static int fts5QueryCksum( while( rc==SQLITE_OK && 0==sqlite3Fts5IterEof(pIdxIter) ){ i64 rowid = sqlite3Fts5IterRowid(pIdxIter); - rc = sqlite3Fts5IterPoslistBuffer(pIdxIter, &buf); - if( rc==SQLITE_OK ){ - Fts5PoslistReader sReader; - for(sqlite3Fts5PoslistReaderInit(buf.p, buf.n, &sReader); - sReader.bEof==0; - sqlite3Fts5PoslistReaderNext(&sReader) - ){ - int iCol = FTS5_POS2COLUMN(sReader.iPos); - int iOff = FTS5_POS2OFFSET(sReader.iPos); - cksum ^= sqlite3Fts5IndexEntryCksum(rowid, iCol, iOff, iIdx, z, n); + + if( eDetail==FTS5_DETAIL_NONE ){ + cksum ^= sqlite3Fts5IndexEntryCksum(rowid, 0, 0, iIdx, z, n); + }else{ + rc = sqlite3Fts5IterPoslistBuffer(pIdxIter, &buf); + if( rc==SQLITE_OK ){ + Fts5PoslistReader sReader; + for(sqlite3Fts5PoslistReaderInit(buf.p, buf.n, &sReader); + sReader.bEof==0; + sqlite3Fts5PoslistReaderNext(&sReader) + ){ + int iCol = FTS5_POS2COLUMN(sReader.iPos); + int iOff = FTS5_POS2OFFSET(sReader.iPos); + cksum ^= sqlite3Fts5IndexEntryCksum(rowid, iCol, iOff, iIdx, z, n); + } } + } + if( rc==SQLITE_OK ){ rc = sqlite3Fts5IterNext(pIdxIter); } } @@ -5523,6 +5531,7 @@ static void fts5IndexIntegrityCheckSegment( ** occurs. */ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ + int eDetail = p->pConfig->eDetail; u64 cksum2 = 0; /* Checksum based on contents of indexes */ Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */ Fts5IndexIter *pIter; /* Used to iterate through entire index */ @@ -5574,12 +5583,16 @@ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ /* If this is a new term, query for it. Update cksum3 with the results. */ fts5TestTerm(p, &term, z, n, cksum2, &cksum3); - poslist.n = 0; - fts5SegiterPoslist(p, &pIter->aSeg[pIter->aFirst[1].iFirst] , 0, &poslist); - while( 0==sqlite3Fts5PoslistNext64(poslist.p, poslist.n, &iOff, &iPos) ){ - int iCol = FTS5_POS2COLUMN(iPos); - int iTokOff = FTS5_POS2OFFSET(iPos); - cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, iCol, iTokOff, -1, z, n); + if( eDetail==FTS5_DETAIL_NONE ){ + cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, 0, 0, -1, z, n); + }else{ + poslist.n = 0; + fts5SegiterPoslist(p, &pIter->aSeg[pIter->aFirst[1].iFirst], 0, &poslist); + while( 0==sqlite3Fts5PoslistNext64(poslist.p, poslist.n, &iOff, &iPos) ){ + int iCol = FTS5_POS2COLUMN(iPos); + int iTokOff = FTS5_POS2OFFSET(iPos); + cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, iCol, iTokOff, -1, z, n); + } } } fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3); diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index fe3ce829a1..f047fd99dc 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -853,8 +853,23 @@ static int fts5StorageIntegrityCallback( pCtx->szCol++; } - iPos = pTermset ? pCtx->iCol : pCtx->szCol-1; - iCol = pTermset ? 0 : pCtx->iCol; + switch( pCtx->pConfig->eDetail ){ + case FTS5_DETAIL_FULL: + iPos = pCtx->szCol-1; + iCol = pCtx->iCol; + break; + + case FTS5_DETAIL_COLUMNS: + iPos = pCtx->iCol; + iCol = 0; + break; + + default: + assert( pCtx->pConfig->eDetail==FTS5_DETAIL_NONE ); + iPos = 0; + iCol = 0; + break; + } rc = sqlite3Fts5TermsetAdd(pTermset, 0, pToken, nToken, &bPresent); if( rc==SQLITE_OK && bPresent==0 ){ @@ -912,11 +927,14 @@ int sqlite3Fts5StorageIntegrity(Fts5Storage *p){ if( pConfig->bColumnsize ){ rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize); } + if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){ + rc = sqlite3Fts5TermsetNew(&ctx.pTermset); + } for(i=0; rc==SQLITE_OK && inCol; i++){ if( pConfig->abUnindexed[i] ) continue; ctx.iCol = i; ctx.szCol = 0; - if( pConfig->eDetail!=FTS5_DETAIL_FULL ){ + if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ rc = sqlite3Fts5TermsetNew(&ctx.pTermset); } if( rc==SQLITE_OK ){ @@ -932,9 +950,14 @@ int sqlite3Fts5StorageIntegrity(Fts5Storage *p){ rc = FTS5_CORRUPT; } aTotalSize[i] += ctx.szCol; - sqlite3Fts5TermsetFree(ctx.pTermset); - ctx.pTermset = 0; + if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ + sqlite3Fts5TermsetFree(ctx.pTermset); + ctx.pTermset = 0; + } } + sqlite3Fts5TermsetFree(ctx.pTermset); + ctx.pTermset = 0; + if( rc!=SQLITE_OK ) break; } rc2 = sqlite3_reset(pScan); diff --git a/ext/fts5/test/fts5simple2.test b/ext/fts5/test/fts5simple2.test index 259aff0953..f99ea6112e 100644 --- a/ext/fts5/test/fts5simple2.test +++ b/ext/fts5/test/fts5simple2.test @@ -109,35 +109,59 @@ do_execsql_test 7.0 { INSERT INTO t1 VALUES('a1 b2'); COMMIT; } -do_execsql_test 7.0.4 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC } {2 1} -do_execsql_test 7.0.5 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC } {2 1} +do_execsql_test 7.1 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC } {2 1} +do_execsql_test 7.2 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC } {2 1} #------------------------------------------------------------------------- # reset_db -do_execsql_test 7.0 { +do_execsql_test 8.0 { CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none); INSERT INTO t1 VALUES('a1 b1 c1'); INSERT INTO t1 VALUES('a2 b2 c2'); INSERT INTO t1 VALUES('a1 b1 c1'); } -do_execsql_test 7.0.1 { SELECT rowid FROM t1('b*') } {1 2 3} -do_execsql_test 7.0.2 { SELECT rowid FROM t1('a1') } {1 3} -do_execsql_test 7.0.3 { SELECT rowid FROM t1('c2') } {2} +do_execsql_test 8.0.1 { SELECT rowid FROM t1('b*') } {1 2 3} +do_execsql_test 8.0.2 { SELECT rowid FROM t1('a1') } {1 3} +do_execsql_test 8.0.3 { SELECT rowid FROM t1('c2') } {2} -do_execsql_test 7.0.4 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC } {3 2 1} -do_execsql_test 7.0.5 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC } {3 1} -do_execsql_test 7.0.7 { SELECT rowid FROM t1('c2') ORDER BY rowid DESC } {2} +do_execsql_test 8.0.4 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC } {3 2 1} +do_execsql_test 8.0.5 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC } {3 1} +do_execsql_test 8.0.8 { SELECT rowid FROM t1('c2') ORDER BY rowid DESC } {2} -do_execsql_test 7.1.0 { INSERT INTO t1(t1) VALUES('optimize') } +do_execsql_test 8.1.0 { INSERT INTO t1(t1) VALUES('optimize') } -do_execsql_test 7.1.1 { SELECT rowid FROM t1('b*') } {1 2 3} -do_execsql_test 7.1.2 { SELECT rowid FROM t1('a1') } {1 3} -do_execsql_test 7.1.3 { SELECT rowid FROM t1('c2') } {2} +do_execsql_test 8.1.1 { SELECT rowid FROM t1('b*') } {1 2 3} +do_execsql_test 8.1.2 { SELECT rowid FROM t1('a1') } {1 3} +do_execsql_test 8.1.3 { SELECT rowid FROM t1('c2') } {2} -do_execsql_test 7.2.1 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC} {3 2 1} -do_execsql_test 7.2.2 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC} {3 1} -do_execsql_test 7.2.3 { SELECT rowid FROM t1('c2') ORDER BY rowid DESC} {2} +do_execsql_test 8.2.1 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC} {3 2 1} +do_execsql_test 8.2.2 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC} {3 1} +do_execsql_test 8.2.3 { SELECT rowid FROM t1('c2') ORDER BY rowid DESC} {2} + +#-------------------------------------------------------------------------- +# +reset_db +do_execsql_test 9.0.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none); + INSERT INTO t1 VALUES('a1 b1 c1'); + INSERT INTO t1 VALUES('a2 b2 c2'); + INSERT INTO t1 VALUES('a1 b1 c1'); +} +do_execsql_test 9.0.1 { + INSERT INTO t1(t1) VALUES('integrity-check'); +} {} + +reset_db +do_execsql_test 9.1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=none); + INSERT INTO t1 VALUES('a1 b1 c1', 'x y z'); + INSERT INTO t1 VALUES('a2 b2 c2', '1 2 3'); + INSERT INTO t1 VALUES('a1 b1 c1', 'x 2 z'); +} +do_execsql_test 9.2.1 { + INSERT INTO t1(t1) VALUES('integrity-check'); +} {} finish_test diff --git a/manifest b/manifest index dc56eb5d2c..c173c4014d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\sproblems\swith\sfts5\sdetail=none\stables.\sSome\sstill\sremain. -D 2015-12-31T17:36:58.906 +C Fix\sthe\sfts5\sintegrity-check\scode\sso\sthat\sit\sworks\swith\sdetail=none\stables. +D 2015-12-31T18:39:14.423 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -103,9 +103,9 @@ F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 F ext/fts5/fts5_expr.c 08ee4f342a2b1fd82a5dccd0b9b3cde4921a8be5 F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 -F ext/fts5/fts5_index.c 40eac312bdcb67552fe6dc2e0a4bad67d9273e3d +F ext/fts5/fts5_index.c a7cfe8e88621b473d749268f918b54b81a067c2e F ext/fts5/fts5_main.c 23f3912ff44172859c771eb55cb57778fd662e89 -F ext/fts5/fts5_storage.c 076a3356536a8831eb6e554195171d5c249cd179 +F ext/fts5/fts5_storage.c 771dd0fda3ee513e32937a386dc2a4aa2d9ea64e F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb F ext/fts5/fts5_test_mi.c c9c8cf455c49ded156a234e0de1c8ba9be85e5c3 F ext/fts5/fts5_tokenize.c 618efe033bceb80c521b1e9ddfd9fee85fb5946e @@ -170,7 +170,7 @@ F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 F ext/fts5/test/fts5simple.test a599b7577bc3827a9a678add3b43d8b818b93456 -F ext/fts5/test/fts5simple2.test 9b1e4c44fc63bd0cbb3ea639cd0ad9fa764849bf +F ext/fts5/test/fts5simple2.test a1a9f9c443f8852f412ee9658ef667086ccb74d7 F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 F ext/fts5/test/fts5unicode.test fbef8d8a3b4b88470536cc57604a82ca52e51841 @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ac8f4cf0cede6bcbe47eeefb85d80a27e9278212 -R 4d80cd94292f49ff63b2b342f7b40c82 +P 6a6f7bc40d6b4c8a4a254a9098c9d2f31fde69ca +R 70fdbbf97fa363362bfe1572d2790ec2 U dan -Z 84b26c5644e7f6dfb95a54fd72f26ecc +Z 9907fb7300f9e53b05e209bde8721940 diff --git a/manifest.uuid b/manifest.uuid index bcbd354a20..7093688530 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a6f7bc40d6b4c8a4a254a9098c9d2f31fde69ca \ No newline at end of file +3a1df69e58e5830da1dff158eedbe3817743f58f \ No newline at end of file From 5905f86b338500b3360342871d6aaf5fcd48f612 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 31 Dec 2015 19:04:42 +0000 Subject: [PATCH 117/232] Fix harmless compiler warning seen with MSVC. FossilOrigin-Name: 98ec778daac835d9ae103f6460b7d897981a5dd6 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 74fac31c3e..3b002abdc1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sassociated\swith\sSQLITE_ENABLE_HIDDEN_COLUMNS. -D 2015-12-31T15:34:03.678 +C Fix\sharmless\scompiler\swarning\sseen\swith\sMSVC. +D 2015-12-31T19:04:42.799 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -279,7 +279,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 5ac3f868d4f20a67f0f00a1014940f902b511558 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 -F src/build.c 249e9605fc423feeca0316e7018df04da8c345d5 +F src/build.c 1c9fb552148ee8f9234435a38833f8fca2081a71 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7a0b9413fa94d3f4fa9751ddf9b213a1238954f1 -R 793126e19a875ee34b3c925c6d9cf329 -U drh -Z 7a54e045f07d4dcaeff2de7160303dce +P 9c392c1019ee15f27c8e05b41246d2844f91f6c0 +R 55161c92d22f1816c3b9c126a24128f9 +U mistachkin +Z b7a8bb994d81380f55ad5f17330fd4b6 diff --git a/manifest.uuid b/manifest.uuid index 6672b8e8dd..60606fbdfc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9c392c1019ee15f27c8e05b41246d2844f91f6c0 \ No newline at end of file +98ec778daac835d9ae103f6460b7d897981a5dd6 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 553e249fa4..ffefead9db 100644 --- a/src/build.c +++ b/src/build.c @@ -444,7 +444,7 @@ static void freeIndex(sqlite3 *db, Index *p){ sqlite3ExprDelete(db, p->pPartIdxWhere); sqlite3ExprListDelete(db, p->aColExpr); sqlite3DbFree(db, p->zColAff); - if( p->isResized ) sqlite3DbFree(db, p->azColl); + if( p->isResized ) sqlite3DbFree(db, (void *)p->azColl); #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 sqlite3_free(p->aiRowEst); #endif From aae280ef8b69b38a56aabdd322d59fc8686c7b82 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 31 Dec 2015 19:06:24 +0000 Subject: [PATCH 118/232] In the shell, use utf8_printf() when any string formatting is present and raw_printf() otherwise. FossilOrigin-Name: 8cf01fff232d15d3c7b7b62b2d890d983e1945f2 --- manifest | 12 +- manifest.uuid | 2 +- src/shell.c | 535 ++++++++++++++++++++++++++------------------------ 3 files changed, 286 insertions(+), 263 deletions(-) diff --git a/manifest b/manifest index 3b002abdc1..3c7f5db48d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning\sseen\swith\sMSVC. -D 2015-12-31T19:04:42.799 +C In\sthe\sshell,\suse\sutf8_printf()\swhen\sany\sstring\sformatting\sis\spresent\sand\sraw_printf()\sotherwise. +D 2015-12-31T19:06:24.721 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -334,7 +334,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f -F src/shell.c ace08b69cd9702143cf87b5bd20b744a56f832fd +F src/shell.c 8d152e833c3b79825978deb83175234749c5cdf3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9c392c1019ee15f27c8e05b41246d2844f91f6c0 -R 55161c92d22f1816c3b9c126a24128f9 +P 98ec778daac835d9ae103f6460b7d897981a5dd6 +R cd1e993dc14f9af3b107557468145aaf U mistachkin -Z b7a8bb994d81380f55ad5f17330fd4b6 +Z 770ade254ba97d3649a2f5b30f5d6fd8 diff --git a/manifest.uuid b/manifest.uuid index 60606fbdfc..4302de3a4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -98ec778daac835d9ae103f6460b7d897981a5dd6 \ No newline at end of file +8cf01fff232d15d3c7b7b62b2d890d983e1945f2 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index a6d75176c2..ecb591a32a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -382,7 +382,7 @@ static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){ va_start(ap, zFormat); z = sqlite3_vmprintf(zFormat, ap); va_end(ap); - fprintf(iotrace, "%s", z); + utf8_printf(iotrace, "%s", z); sqlite3_free(z); } #endif @@ -548,7 +548,7 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){ void utf8_printf(FILE *out, const char *zFormat, ...){ va_list ap; va_start(ap, zFormat); - if( stdout_is_console && out==stdout ){ + if( stdout_is_console && (out==stdout || out==stderr) ){ extern char *sqlite3_win32_utf8_to_mbcs(const char*); char *z1 = sqlite3_vmprintf(zFormat, ap); char *z2 = sqlite3_win32_utf8_to_mbcs(z1); @@ -560,10 +560,18 @@ void utf8_printf(FILE *out, const char *zFormat, ...){ } va_end(ap); } -#else +#elif !defined(utf8_printf) # define utf8_printf fprintf #endif +/* +** Render output like fprintf(). This should not be used on anything that +** includes string formatting (e.g. "%s"). +*/ +#if !defined(raw_printf) +# define raw_printf fprintf +#endif + /* ** Shell output mode information from before ".explain on", ** saved so that it can be restored by ".explain off" @@ -675,7 +683,7 @@ static const char *modeDescr[] = { static void shellLog(void *pArg, int iErrCode, const char *zMsg){ ShellState *p = (ShellState*)pArg; if( p->pLog==0 ) return; - fprintf(p->pLog, "(%d) %s\n", iErrCode, zMsg); + utf8_printf(p->pLog, "(%d) %s\n", iErrCode, zMsg); fflush(p->pLog); } @@ -685,9 +693,9 @@ static void shellLog(void *pArg, int iErrCode, const char *zMsg){ static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){ int i; char *zBlob = (char *)pBlob; - fprintf(out,"X'"); - for(i=0; i' ){ - fprintf(out,">"); + raw_printf(out,">"); }else if( z[i]=='\"' ){ - fprintf(out,"""); + raw_printf(out,"""); }else if( z[i]=='\'' ){ - fprintf(out,"'"); + raw_printf(out,"'"); }else{ break; } @@ -927,7 +935,7 @@ static int shell_callback( }else{ w = 10; } - fprintf(p->out,"%-*.*s%s",w,w, + utf8_printf(p->out,"%-*.*s%s",w,w, "----------------------------------------------------------" "----------------------------------------------------------", i==nArg-1 ? p->rowSeparator : " "); @@ -947,7 +955,7 @@ static int shell_callback( } if( i==1 && p->aiIndent && p->pStmt ){ if( p->iIndentnIndent ){ - fprintf(p->out, "%*.s", p->aiIndent[p->iIndent], ""); + utf8_printf(p->out, "%*.s", p->aiIndent[p->iIndent], ""); } p->iIndent++; } @@ -988,22 +996,22 @@ static int shell_callback( } case MODE_Html: { if( p->cnt++==0 && p->showHeader ){ - fprintf(p->out,""); + raw_printf(p->out,""); for(i=0; iout,""); + raw_printf(p->out,""); output_html_string(p->out, azCol[i]); - fprintf(p->out,"\n"); + raw_printf(p->out,"\n"); } - fprintf(p->out,"\n"); + raw_printf(p->out,"\n"); } if( azArg==0 ) break; - fprintf(p->out,""); + raw_printf(p->out,""); for(i=0; iout,""); + raw_printf(p->out,""); output_html_string(p->out, azArg[i] ? azArg[i] : p->nullValue); - fprintf(p->out,"\n"); + raw_printf(p->out,"\n"); } - fprintf(p->out,"\n"); + raw_printf(p->out,"\n"); break; } case MODE_Tcl: { @@ -1044,20 +1052,20 @@ static int shell_callback( if( azArg==0 ) break; utf8_printf(p->out,"INSERT INTO %s",p->zDestTable); if( p->showHeader ){ - fprintf(p->out,"("); + raw_printf(p->out,"("); for(i=0; i0 ? ",": ""; utf8_printf(p->out, "%s%s", zSep, azCol[i]); } - fprintf(p->out,")"); + raw_printf(p->out,")"); } - fprintf(p->out," VALUES("); + raw_printf(p->out," VALUES("); for(i=0; i0 ? ",": ""; if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){ - fprintf(p->out,"%sNULL",zSep); + utf8_printf(p->out,"%sNULL",zSep); }else if( aiType && aiType[i]==SQLITE_TEXT ){ - if( zSep[0] ) fprintf(p->out,"%s",zSep); + if( zSep[0] ) utf8_printf(p->out,"%s",zSep); output_quoted_string(p->out, azArg[i]); }else if( aiType && (aiType[i]==SQLITE_INTEGER || aiType[i]==SQLITE_FLOAT) ){ @@ -1065,16 +1073,16 @@ static int shell_callback( }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){ const void *pBlob = sqlite3_column_blob(p->pStmt, i); int nBlob = sqlite3_column_bytes(p->pStmt, i); - if( zSep[0] ) fprintf(p->out,"%s",zSep); + if( zSep[0] ) utf8_printf(p->out,"%s",zSep); output_hex_blob(p->out, pBlob, nBlob); }else if( isNumber(azArg[i], 0) ){ utf8_printf(p->out,"%s%s",zSep, azArg[i]); }else{ - if( zSep[0] ) fprintf(p->out,"%s",zSep); + if( zSep[0] ) utf8_printf(p->out,"%s",zSep); output_quoted_string(p->out, azArg[i]); } } - fprintf(p->out,");\n"); + raw_printf(p->out,");\n"); break; } case MODE_Ascii: { @@ -1131,7 +1139,7 @@ static void set_table_name(ShellState *p, const char *zName){ if( needQuote ) n += 2; z = p->zDestTable = malloc( n+1 ); if( z==0 ){ - fprintf(stderr,"Error: out of memory\n"); + raw_printf(stderr,"Error: out of memory\n"); exit(1); } n = 0; @@ -1212,7 +1220,8 @@ static int run_table_dump_query( const char *z; rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0); if( rc!=SQLITE_OK || !pSelect ){ - fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); + utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, + sqlite3_errmsg(p->db)); if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++; return rc; } @@ -1231,15 +1240,16 @@ static int run_table_dump_query( if( z==0 ) z = ""; while( z[0] && (z[0]!='-' || z[1]!='-') ) z++; if( z[0] ){ - fprintf(p->out, "\n;\n"); + raw_printf(p->out, "\n;\n"); }else{ - fprintf(p->out, ";\n"); + raw_printf(p->out, ";\n"); } rc = sqlite3_step(pSelect); } rc = sqlite3_finalize(pSelect); if( rc!=SQLITE_OK ){ - fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); + utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, + sqlite3_errmsg(p->db)); if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++; } return rc; @@ -1274,52 +1284,53 @@ static int display_stats( iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, + raw_printf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", + raw_printf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", iCur, iHiwtr); if( pArg->shellFlgs & SHFLG_Pagecache ){ iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, + raw_printf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr); } iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, + raw_printf(pArg->out, "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr); if( pArg->shellFlgs & SHFLG_Scratch ){ iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", + raw_printf(pArg->out, + "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr); } iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, + raw_printf(pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Largest Allocation: %d bytes\n", + raw_printf(pArg->out, "Largest Allocation: %d bytes\n", iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Largest Pcache Allocation: %d bytes\n", + raw_printf(pArg->out, "Largest Pcache Allocation: %d bytes\n", iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Largest Scratch Allocation: %d bytes\n", + raw_printf(pArg->out, "Largest Scratch Allocation: %d bytes\n", iHiwtr); #ifdef YYTRACKMAXSTACKDEPTH iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", + raw_printf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr); #endif } @@ -1329,48 +1340,55 @@ static int display_stats( iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", + raw_printf(pArg->out, + "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr); sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr); + raw_printf(pArg->out, "Successful lookaside attempts: %d\n", + iHiwtr); sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr); + raw_printf(pArg->out, "Lookaside failures due to size: %d\n", + iHiwtr); sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr); + raw_printf(pArg->out, "Lookaside failures due to OOM: %d\n", + iHiwtr); } iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Pager Heap Usage: %d bytes\n",iCur); + raw_printf(pArg->out, "Pager Heap Usage: %d bytes\n", + iCur); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1); - fprintf(pArg->out, "Page cache hits: %d\n", iCur); + raw_printf(pArg->out, "Page cache hits: %d\n", iCur); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1); - fprintf(pArg->out, "Page cache misses: %d\n", iCur); + raw_printf(pArg->out, "Page cache misses: %d\n", iCur); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1); - fprintf(pArg->out, "Page cache writes: %d\n", iCur); + raw_printf(pArg->out, "Page cache writes: %d\n", iCur); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Schema Heap Usage: %d bytes\n",iCur); + raw_printf(pArg->out, "Schema Heap Usage: %d bytes\n", + iCur); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n",iCur); + raw_printf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", + iCur); } if( pArg && pArg->out && db && pArg->pStmt ){ iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, bReset); - fprintf(pArg->out, "Fullscan Steps: %d\n", iCur); + raw_printf(pArg->out, "Fullscan Steps: %d\n", iCur); iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset); - fprintf(pArg->out, "Sort Operations: %d\n", iCur); + raw_printf(pArg->out, "Sort Operations: %d\n", iCur); iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset); - fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur); + raw_printf(pArg->out, "Autoindex Inserts: %d\n", iCur); iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset); - fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur); + raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur); } /* Do not remove this machine readable comment: extra-stats-output-here */ @@ -1390,7 +1408,7 @@ static void display_scanstats( UNUSED_PARAMETER(pArg); #else int i, k, n, mx; - fprintf(pArg->out, "-------- scanstats --------\n"); + raw_printf(pArg->out, "-------- scanstats --------\n"); mx = 0; for(k=0; k<=mx; k++){ double rEstLoop = 1.0; @@ -1408,7 +1426,7 @@ static void display_scanstats( if( iSid!=k ) continue; if( n==0 ){ rEstLoop = (double)nLoop; - if( k>0 ) fprintf(pArg->out, "-------- subquery %d -------\n", k); + if( k>0 ) raw_printf(pArg->out, "-------- subquery %d -------\n", k); } n++; sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit); @@ -1416,13 +1434,13 @@ static void display_scanstats( sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain); utf8_printf(pArg->out, "Loop %2d: %s\n", n, zExplain); rEstLoop *= rEst; - fprintf(pArg->out, + raw_printf(pArg->out, " nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n", nLoop, nVisit, (sqlite3_int64)(rEstLoop+0.5), rEst ); } } - fprintf(pArg->out, "---------------------------\n"); + raw_printf(pArg->out, "---------------------------\n"); #endif } @@ -1586,9 +1604,9 @@ static int shell_exec( rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0); if( rc==SQLITE_OK ){ while( sqlite3_step(pExplain)==SQLITE_ROW ){ - fprintf(pArg->out,"--EQP-- %d,", sqlite3_column_int(pExplain, 0)); - fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1)); - fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2)); + raw_printf(pArg->out,"--EQP-- %d,",sqlite3_column_int(pExplain, 0)); + raw_printf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1)); + raw_printf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2)); utf8_printf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3)); } } @@ -1717,13 +1735,13 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){ if( strcmp(zTable, "sqlite_sequence")==0 ){ zPrepStmt = "DELETE FROM sqlite_sequence;\n"; }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){ - fprintf(p->out, "ANALYZE sqlite_master;\n"); + raw_printf(p->out, "ANALYZE sqlite_master;\n"); }else if( strncmp(zTable, "sqlite_", 7)==0 ){ return 0; }else if( strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){ char *zIns; if( !p->writableSchema ){ - fprintf(p->out, "PRAGMA writable_schema=ON;\n"); + raw_printf(p->out, "PRAGMA writable_schema=ON;\n"); p->writableSchema = 1; } zIns = sqlite3_mprintf( @@ -1811,9 +1829,9 @@ static int run_schema_dump_query( if( rc==SQLITE_CORRUPT ){ char *zQ2; int len = strlen30(zQuery); - fprintf(p->out, "/****** CORRUPTION ERROR *******/\n"); + raw_printf(p->out, "/****** CORRUPTION ERROR *******/\n"); if( zErr ){ - fprintf(p->out, "/****** %s ******/\n", zErr); + utf8_printf(p->out, "/****** %s ******/\n", zErr); sqlite3_free(zErr); zErr = 0; } @@ -1822,7 +1840,7 @@ static int run_schema_dump_query( sqlite3_snprintf(len+100, zQ2, "%s ORDER BY rowid DESC", zQuery); rc = sqlite3_exec(p->db, zQ2, dump_callback, p, &zErr); if( rc ){ - fprintf(p->out, "/****** ERROR: %s ******/\n", zErr); + utf8_printf(p->out, "/****** ERROR: %s ******/\n", zErr); }else{ rc = SQLITE_CORRUPT; } @@ -1987,7 +2005,7 @@ static void open_db(ShellState *p, int keepAlive){ shellstaticFunc, 0, 0); } if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){ - fprintf(stderr,"Error: unable to open database \"%s\": %s\n", + utf8_printf(stderr,"Error: unable to open database \"%s\": %s\n", p->zDbFilename, sqlite3_errmsg(p->db)); if( keepAlive ) return; exit(1); @@ -2137,7 +2155,7 @@ static int booleanValue(char *zArg){ if( sqlite3_stricmp(zArg, "off")==0 || sqlite3_stricmp(zArg,"no")==0 ){ return 0; } - fprintf(stderr, "ERROR: Not a boolean value: \"%s\". Assuming \"no\".\n", + utf8_printf(stderr, "ERROR: Not a boolean value: \"%s\". Assuming \"no\".\n", zArg); return 0; } @@ -2165,7 +2183,7 @@ static FILE *output_file_open(const char *zFile){ }else{ f = fopen(zFile, "wb"); if( f==0 ){ - fprintf(stderr, "Error: cannot open \"%s\"\n", zFile); + utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile); } } return f; @@ -2214,7 +2232,7 @@ static void import_append_char(ImportCtx *p, int c){ p->nAlloc += p->nAlloc + 100; p->z = sqlite3_realloc64(p->z, p->nAlloc); if( p->z==0 ){ - fprintf(stderr, "out of memory\n"); + raw_printf(stderr, "out of memory\n"); exit(1); } } @@ -2268,11 +2286,11 @@ static char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){ break; } if( pc==cQuote && c!='\r' ){ - fprintf(stderr, "%s:%d: unescaped %c character\n", + utf8_printf(stderr, "%s:%d: unescaped %c character\n", p->zFile, p->nLine, cQuote); } if( c==EOF ){ - fprintf(stderr, "%s:%d: unterminated %c-quoted field\n", + utf8_printf(stderr, "%s:%d: unterminated %c-quoted field\n", p->zFile, startLine, cQuote); p->cTerm = c; break; @@ -2354,7 +2372,7 @@ static void tryToCloneData( zQuery = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable); rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); if( rc ){ - fprintf(stderr, "Error %d: %s on [%s]\n", + utf8_printf(stderr, "Error %d: %s on [%s]\n", sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zQuery); goto end_data_xfer; @@ -2362,7 +2380,7 @@ static void tryToCloneData( n = sqlite3_column_count(pQuery); zInsert = sqlite3_malloc64(200 + nTable + n*3); if( zInsert==0 ){ - fprintf(stderr, "out of memory\n"); + raw_printf(stderr, "out of memory\n"); goto end_data_xfer; } sqlite3_snprintf(200+nTable,zInsert, @@ -2375,7 +2393,7 @@ static void tryToCloneData( memcpy(zInsert+i, ");", 3); rc = sqlite3_prepare_v2(newDb, zInsert, -1, &pInsert, 0); if( rc ){ - fprintf(stderr, "Error %d: %s on [%s]\n", + utf8_printf(stderr, "Error %d: %s on [%s]\n", sqlite3_extended_errcode(newDb), sqlite3_errmsg(newDb), zQuery); goto end_data_xfer; @@ -2412,7 +2430,7 @@ static void tryToCloneData( } /* End for */ rc = sqlite3_step(pInsert); if( rc!=SQLITE_OK && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ - fprintf(stderr, "Error %d: %s\n", sqlite3_extended_errcode(newDb), + utf8_printf(stderr, "Error %d: %s\n", sqlite3_extended_errcode(newDb), sqlite3_errmsg(newDb)); } sqlite3_reset(pInsert); @@ -2429,7 +2447,7 @@ static void tryToCloneData( zTable); rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); if( rc ){ - fprintf(stderr, "Warning: cannot step \"%s\" backwards", zTable); + utf8_printf(stderr, "Warning: cannot step \"%s\" backwards", zTable); break; } } /* End for(k=0...) */ @@ -2465,7 +2483,7 @@ static void tryToCloneSchema( " WHERE %s", zWhere); rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); if( rc ){ - fprintf(stderr, "Error: (%d) %s on [%s]\n", + utf8_printf(stderr, "Error: (%d) %s on [%s]\n", sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zQuery); goto end_schema_xfer; @@ -2476,7 +2494,7 @@ static void tryToCloneSchema( printf("%s... ", zName); fflush(stdout); sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg); if( zErrMsg ){ - fprintf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); + utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); sqlite3_free(zErrMsg); zErrMsg = 0; } @@ -2492,7 +2510,7 @@ static void tryToCloneSchema( " WHERE %s ORDER BY rowid DESC", zWhere); rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); if( rc ){ - fprintf(stderr, "Error: (%d) %s on [%s]\n", + utf8_printf(stderr, "Error: (%d) %s on [%s]\n", sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zQuery); goto end_schema_xfer; @@ -2503,7 +2521,7 @@ static void tryToCloneSchema( printf("%s... ", zName); fflush(stdout); sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg); if( zErrMsg ){ - fprintf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); + utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); sqlite3_free(zErrMsg); zErrMsg = 0; } @@ -2527,12 +2545,12 @@ static void tryToClone(ShellState *p, const char *zNewDb){ int rc; sqlite3 *newDb = 0; if( access(zNewDb,0)==0 ){ - fprintf(stderr, "File \"%s\" already exists.\n", zNewDb); + utf8_printf(stderr, "File \"%s\" already exists.\n", zNewDb); return; } rc = sqlite3_open(zNewDb, &newDb); if( rc ){ - fprintf(stderr, "Cannot create output database: %s\n", + utf8_printf(stderr, "Cannot create output database: %s\n", sqlite3_errmsg(newDb)); }else{ sqlite3_exec(p->db, "PRAGMA writable_schema=ON;", 0, 0, 0); @@ -2629,27 +2647,27 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){ } i = pFile->pMethods->xRead(pFile, aHdr, 100, 0); if( i!=SQLITE_OK ){ - fprintf(stderr, "unable to read database header\n"); + raw_printf(stderr, "unable to read database header\n"); return 1; } i = get2byteInt(aHdr+16); if( i==1 ) i = 65536; - fprintf(p->out, "%-20s %d\n", "database page size:", i); - fprintf(p->out, "%-20s %d\n", "write format:", aHdr[18]); - fprintf(p->out, "%-20s %d\n", "read format:", aHdr[19]); - fprintf(p->out, "%-20s %d\n", "reserved bytes:", aHdr[20]); + utf8_printf(p->out, "%-20s %d\n", "database page size:", i); + utf8_printf(p->out, "%-20s %d\n", "write format:", aHdr[18]); + utf8_printf(p->out, "%-20s %d\n", "read format:", aHdr[19]); + utf8_printf(p->out, "%-20s %d\n", "reserved bytes:", aHdr[20]); for(i=0; iout, "%-20s %u", aField[i].zName, val); + utf8_printf(p->out, "%-20s %u", aField[i].zName, val); switch( ofst ){ case 56: { - if( val==1 ) fprintf(p->out, " (utf8)"); - if( val==2 ) fprintf(p->out, " (utf16le)"); - if( val==3 ) fprintf(p->out, " (utf16be)"); + if( val==1 ) raw_printf(p->out, " (utf8)"); + if( val==2 ) raw_printf(p->out, " (utf16le)"); + if( val==3 ) raw_printf(p->out, " (utf16be)"); } } - fprintf(p->out, "\n"); + raw_printf(p->out, "\n"); } if( zDb==0 ){ zSchemaTab = sqlite3_mprintf("main.sqlite_master"); @@ -2673,7 +2691,7 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){ */ static int shellDatabaseError(sqlite3 *db){ const char *zErr = sqlite3_errmsg(db); - fprintf(stderr, "Error: %s\n", zErr); + utf8_printf(stderr, "Error: %s\n", zErr); return 1; } @@ -2681,7 +2699,7 @@ static int shellDatabaseError(sqlite3 *db){ ** Print an out-of-memory message to stderr and return 1. */ static int shellNomemError(void){ - fprintf(stderr, "Error: out of memory\n"); + raw_printf(stderr, "Error: out of memory\n"); return 1; } @@ -2741,7 +2759,7 @@ static int do_meta_command(char *zLine, ShellState *p){ while( z[0]=='-' ) z++; /* No options to process at this time */ { - fprintf(stderr, "unknown option: %s\n", azArg[j]); + utf8_printf(stderr, "unknown option: %s\n", azArg[j]); return 1; } }else if( zDestFile==0 ){ @@ -2750,25 +2768,25 @@ static int do_meta_command(char *zLine, ShellState *p){ zDb = zDestFile; zDestFile = azArg[j]; }else{ - fprintf(stderr, "too many arguments to .backup\n"); + raw_printf(stderr, "too many arguments to .backup\n"); return 1; } } if( zDestFile==0 ){ - fprintf(stderr, "missing FILENAME argument on .backup\n"); + raw_printf(stderr, "missing FILENAME argument on .backup\n"); return 1; } if( zDb==0 ) zDb = "main"; rc = sqlite3_open(zDestFile, &pDest); if( rc!=SQLITE_OK ){ - fprintf(stderr, "Error: cannot open \"%s\"\n", zDestFile); + utf8_printf(stderr, "Error: cannot open \"%s\"\n", zDestFile); sqlite3_close(pDest); return 1; } open_db(p, 0); pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb); if( pBackup==0 ){ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); sqlite3_close(pDest); return 1; } @@ -2777,7 +2795,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( rc==SQLITE_DONE ){ rc = 0; }else{ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); rc = 1; } sqlite3_close(pDest); @@ -2787,7 +2805,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ bail_on_error = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .bail on|off\n"); + raw_printf(stderr, "Usage: .bail on|off\n"); rc = 1; } }else @@ -2800,7 +2818,7 @@ static int do_meta_command(char *zLine, ShellState *p){ setTextMode(p->out); } }else{ - fprintf(stderr, "Usage: .binary on|off\n"); + raw_printf(stderr, "Usage: .binary on|off\n"); rc = 1; } }else @@ -2816,7 +2834,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ p->countChanges = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .changes on|off\n"); + raw_printf(stderr, "Usage: .changes on|off\n"); rc = 1; } }else @@ -2825,7 +2843,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ tryToClone(p, azArg[1]); }else{ - fprintf(stderr, "Usage: .clone FILENAME\n"); + raw_printf(stderr, "Usage: .clone FILENAME\n"); rc = 1; } }else @@ -2843,7 +2861,7 @@ static int do_meta_command(char *zLine, ShellState *p){ data.cnt = 0; sqlite3_exec(p->db, "PRAGMA database_list; ", callback, &data, &zErrMsg); if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); + utf8_printf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; } @@ -2859,12 +2877,12 @@ static int do_meta_command(char *zLine, ShellState *p){ ** which causes immediate foreign key constraints to be violated. ** So disable foreign-key constraint enforcement to prevent problems. */ if( nArg!=1 && nArg!=2 ){ - fprintf(stderr, "Usage: .dump ?LIKE-PATTERN?\n"); + raw_printf(stderr, "Usage: .dump ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; } - fprintf(p->out, "PRAGMA foreign_keys=OFF;\n"); - fprintf(p->out, "BEGIN TRANSACTION;\n"); + raw_printf(p->out, "PRAGMA foreign_keys=OFF;\n"); + raw_printf(p->out, "BEGIN TRANSACTION;\n"); p->writableSchema = 0; sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0); p->nErr = 0; @@ -2899,19 +2917,19 @@ static int do_meta_command(char *zLine, ShellState *p){ } } if( p->writableSchema ){ - fprintf(p->out, "PRAGMA writable_schema=OFF;\n"); + raw_printf(p->out, "PRAGMA writable_schema=OFF;\n"); p->writableSchema = 0; } sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0); sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0); - fprintf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n"); + raw_printf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n"); }else if( c=='e' && strncmp(azArg[0], "echo", n)==0 ){ if( nArg==2 ){ p->echoOn = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .echo on|off\n"); + raw_printf(stderr, "Usage: .echo on|off\n"); rc = 1; } }else @@ -2920,7 +2938,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ p->autoEQP = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .eqp on|off\n"); + raw_printf(stderr, "Usage: .eqp on|off\n"); rc = 1; } }else @@ -2970,7 +2988,7 @@ static int do_meta_command(char *zLine, ShellState *p){ char *zErrMsg = 0; int doStats = 0; if( nArg!=1 ){ - fprintf(stderr, "Usage: .fullschema\n"); + raw_printf(stderr, "Usage: .fullschema\n"); rc = 1; goto meta_command_exit; } @@ -2997,9 +3015,9 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_finalize(pStmt); } if( doStats==0 ){ - fprintf(p->out, "/* No STAT tables available */\n"); + raw_printf(p->out, "/* No STAT tables available */\n"); }else{ - fprintf(p->out, "ANALYZE sqlite_master;\n"); + raw_printf(p->out, "ANALYZE sqlite_master;\n"); sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_master'", callback, &data, &zErrMsg); data.mode = MODE_Insert; @@ -3012,7 +3030,7 @@ static int do_meta_command(char *zLine, ShellState *p){ data.zDestTable = "sqlite_stat4"; shell_exec(p->db, "SELECT * FROM sqlite_stat4", shell_callback, &data, &zErrMsg); - fprintf(p->out, "ANALYZE sqlite_master;\n"); + raw_printf(p->out, "ANALYZE sqlite_master;\n"); } }else @@ -3020,13 +3038,13 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ p->showHeader = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .headers on|off\n"); + raw_printf(stderr, "Usage: .headers on|off\n"); rc = 1; } }else if( c=='h' && strncmp(azArg[0], "help", n)==0 ){ - fprintf(p->out, "%s", zHelp); + utf8_printf(p->out, "%s", zHelp); }else if( c=='i' && strncmp(azArg[0], "import", n)==0 ){ @@ -3044,7 +3062,7 @@ static int do_meta_command(char *zLine, ShellState *p){ int (SQLITE_CDECL *xCloser)(FILE*); /* Func to close file */ if( nArg!=3 ){ - fprintf(stderr, "Usage: .import FILE TABLE\n"); + raw_printf(stderr, "Usage: .import FILE TABLE\n"); goto meta_command_exit; } zFile = azArg[1]; @@ -3054,17 +3072,18 @@ static int do_meta_command(char *zLine, ShellState *p){ open_db(p, 0); nSep = strlen30(p->colSeparator); if( nSep==0 ){ - fprintf(stderr, "Error: non-null column separator required for import\n"); + raw_printf(stderr, + "Error: non-null column separator required for import\n"); return 1; } if( nSep>1 ){ - fprintf(stderr, "Error: multi-character column separators not allowed" + raw_printf(stderr, "Error: multi-character column separators not allowed" " for import\n"); return 1; } nSep = strlen30(p->rowSeparator); if( nSep==0 ){ - fprintf(stderr, "Error: non-null row separator required for import\n"); + raw_printf(stderr, "Error: non-null row separator required for import\n"); return 1; } if( nSep==2 && p->mode==MODE_Csv && strcmp(p->rowSeparator, SEP_CrLf)==0 ){ @@ -3076,7 +3095,7 @@ static int do_meta_command(char *zLine, ShellState *p){ nSep = strlen30(p->rowSeparator); } if( nSep>1 ){ - fprintf(stderr, "Error: multi-character row separators not allowed" + raw_printf(stderr, "Error: multi-character row separators not allowed" " for import\n"); return 1; } @@ -3084,7 +3103,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sCtx.nLine = 1; if( sCtx.zFile[0]=='|' ){ #ifdef SQLITE_OMIT_POPEN - fprintf(stderr, "Error: pipes are not supported in this OS\n"); + raw_printf(stderr, "Error: pipes are not supported in this OS\n"); return 1; #else sCtx.in = popen(sCtx.zFile+1, "r"); @@ -3101,14 +3120,14 @@ static int do_meta_command(char *zLine, ShellState *p){ xRead = csv_read_one_field; } if( sCtx.in==0 ){ - fprintf(stderr, "Error: cannot open \"%s\"\n", zFile); + utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile); return 1; } sCtx.cColSep = p->colSeparator[0]; sCtx.cRowSep = p->rowSeparator[0]; zSql = sqlite3_mprintf("SELECT * FROM %s", zTable); if( zSql==0 ){ - fprintf(stderr, "Error: out of memory\n"); + raw_printf(stderr, "Error: out of memory\n"); xCloser(sCtx.in); return 1; } @@ -3127,14 +3146,14 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_free(zCreate); sqlite3_free(sCtx.z); xCloser(sCtx.in); - fprintf(stderr,"%s: empty file\n", sCtx.zFile); + utf8_printf(stderr,"%s: empty file\n", sCtx.zFile); return 1; } zCreate = sqlite3_mprintf("%z\n)", zCreate); rc = sqlite3_exec(p->db, zCreate, 0, 0, 0); sqlite3_free(zCreate); if( rc ){ - fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable, + utf8_printf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable, sqlite3_errmsg(p->db)); sqlite3_free(sCtx.z); xCloser(sCtx.in); @@ -3145,7 +3164,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_free(zSql); if( rc ){ if (pStmt) sqlite3_finalize(pStmt); - fprintf(stderr,"Error: %s\n", sqlite3_errmsg(p->db)); + utf8_printf(stderr,"Error: %s\n", sqlite3_errmsg(p->db)); xCloser(sCtx.in); return 1; } @@ -3155,7 +3174,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nCol==0 ) return 0; /* no columns, no error */ zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 ); if( zSql==0 ){ - fprintf(stderr, "Error: out of memory\n"); + raw_printf(stderr, "Error: out of memory\n"); xCloser(sCtx.in); return 1; } @@ -3170,7 +3189,7 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rc ){ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); if (pStmt) sqlite3_finalize(pStmt); xCloser(sCtx.in); return 1; @@ -3194,7 +3213,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( p->mode==MODE_Ascii && (z==0 || z[0]==0) && i==0 ) break; sqlite3_bind_text(pStmt, i+1, z, -1, SQLITE_TRANSIENT); if( idb)); + utf8_printf(stderr, "%s:%d: INSERT failed: %s\n", sCtx.zFile, + startLine, sqlite3_errmsg(p->db)); } } }while( sCtx.cTerm!=EOF ); @@ -3257,16 +3276,17 @@ static int do_meta_command(char *zLine, ShellState *p){ ); zShellStatic = 0; }else{ - fprintf(stderr, "Usage: .indexes ?LIKE-PATTERN?\n"); + raw_printf(stderr, "Usage: .indexes ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; } if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); + utf8_printf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; }else if( rc != SQLITE_OK ){ - fprintf(stderr,"Error: querying sqlite_master and sqlite_temp_master\n"); + raw_printf(stderr, + "Error: querying sqlite_master and sqlite_temp_master\n"); rc = 1; } }else @@ -3284,7 +3304,7 @@ static int do_meta_command(char *zLine, ShellState *p){ }else{ iotrace = fopen(azArg[1], "w"); if( iotrace==0 ){ - fprintf(stderr, "Error: cannot open \"%s\"\n", azArg[1]); + utf8_printf(stderr, "Error: cannot open \"%s\"\n", azArg[1]); sqlite3IoTrace = 0; rc = 1; }else{ @@ -3319,7 +3339,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_limit(p->db, aLimit[i].limitCode, -1)); } }else if( nArg>3 ){ - fprintf(stderr, "Usage: .limit NAME ?NEW-VALUE?\n"); + raw_printf(stderr, "Usage: .limit NAME ?NEW-VALUE?\n"); rc = 1; goto meta_command_exit; }else{ @@ -3330,14 +3350,14 @@ static int do_meta_command(char *zLine, ShellState *p){ if( iLimit<0 ){ iLimit = i; }else{ - fprintf(stderr, "ambiguous limit: \"%s\"\n", azArg[1]); + utf8_printf(stderr, "ambiguous limit: \"%s\"\n", azArg[1]); rc = 1; goto meta_command_exit; } } } if( iLimit<0 ){ - fprintf(stderr, "unknown limit: \"%s\"\n" + utf8_printf(stderr, "unknown limit: \"%s\"\n" "enter \".limits\" with no arguments for a list.\n", azArg[1]); rc = 1; @@ -3357,7 +3377,7 @@ static int do_meta_command(char *zLine, ShellState *p){ const char *zFile, *zProc; char *zErrMsg = 0; if( nArg<2 ){ - fprintf(stderr, "Usage: .load FILE ?ENTRYPOINT?\n"); + raw_printf(stderr, "Usage: .load FILE ?ENTRYPOINT?\n"); rc = 1; goto meta_command_exit; } @@ -3366,7 +3386,7 @@ static int do_meta_command(char *zLine, ShellState *p){ open_db(p, 0); rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg); if( rc!=SQLITE_OK ){ - fprintf(stderr, "Error: %s\n", zErrMsg); + utf8_printf(stderr, "Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; } @@ -3375,7 +3395,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='l' && strncmp(azArg[0], "log", n)==0 ){ if( nArg!=2 ){ - fprintf(stderr, "Usage: .log FILENAME\n"); + raw_printf(stderr, "Usage: .log FILENAME\n"); rc = 1; }else{ const char *zFile = azArg[1]; @@ -3414,7 +3434,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit); sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record); }else { - fprintf(stderr,"Error: mode should be one of: " + raw_printf(stderr, "Error: mode should be one of: " "ascii column csv html insert line list tabs tcl\n"); rc = 1; } @@ -3425,7 +3445,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_snprintf(sizeof(p->nullValue), p->nullValue, "%.*s", (int)ArraySize(p->nullValue)-1, azArg[1]); }else{ - fprintf(stderr, "Usage: .nullvalue STRING\n"); + raw_printf(stderr, "Usage: .nullvalue STRING\n"); rc = 1; } }else @@ -3454,13 +3474,13 @@ static int do_meta_command(char *zLine, ShellState *p){ ){ const char *zFile = nArg>=2 ? azArg[1] : "stdout"; if( nArg>2 ){ - fprintf(stderr, "Usage: .%s FILE\n", azArg[0]); + utf8_printf(stderr, "Usage: .%s FILE\n", azArg[0]); rc = 1; goto meta_command_exit; } if( n>1 && strncmp(azArg[0], "once", n)==0 ){ if( nArg<2 ){ - fprintf(stderr, "Usage: .once FILE\n"); + raw_printf(stderr, "Usage: .once FILE\n"); rc = 1; goto meta_command_exit; } @@ -3471,13 +3491,13 @@ static int do_meta_command(char *zLine, ShellState *p){ output_reset(p); if( zFile[0]=='|' ){ #ifdef SQLITE_OMIT_POPEN - fprintf(stderr,"Error: pipes are not supported in this OS\n"); + raw_printf(stderr, "Error: pipes are not supported in this OS\n"); rc = 1; p->out = stdout; #else p->out = popen(zFile + 1, "w"); if( p->out==0 ){ - fprintf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1); + utf8_printf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1); p->out = stdout; rc = 1; }else{ @@ -3488,7 +3508,7 @@ static int do_meta_command(char *zLine, ShellState *p){ p->out = output_file_open(zFile); if( p->out==0 ){ if( strcmp(zFile,"off")!=0 ){ - fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile); + utf8_printf(stderr,"Error: cannot write to \"%s\"\n", zFile); } p->out = stdout; rc = 1; @@ -3501,10 +3521,10 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='p' && n>=3 && strncmp(azArg[0], "print", n)==0 ){ int i; for(i=1; i1 ) fprintf(p->out, " "); + if( i>1 ) raw_printf(p->out, " "); utf8_printf(p->out, "%s", azArg[i]); } - fprintf(p->out, "\n"); + raw_printf(p->out, "\n"); }else if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){ @@ -3523,13 +3543,13 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 ){ FILE *alt; if( nArg!=2 ){ - fprintf(stderr, "Usage: .read FILE\n"); + raw_printf(stderr, "Usage: .read FILE\n"); rc = 1; goto meta_command_exit; } alt = fopen(azArg[1], "rb"); if( alt==0 ){ - fprintf(stderr,"Error: cannot open \"%s\"\n", azArg[1]); + utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]); rc = 1; }else{ rc = process_input(p, alt); @@ -3551,20 +3571,20 @@ static int do_meta_command(char *zLine, ShellState *p){ zSrcFile = azArg[2]; zDb = azArg[1]; }else{ - fprintf(stderr, "Usage: .restore ?DB? FILE\n"); + raw_printf(stderr, "Usage: .restore ?DB? FILE\n"); rc = 1; goto meta_command_exit; } rc = sqlite3_open(zSrcFile, &pSrc); if( rc!=SQLITE_OK ){ - fprintf(stderr, "Error: cannot open \"%s\"\n", zSrcFile); + utf8_printf(stderr, "Error: cannot open \"%s\"\n", zSrcFile); sqlite3_close(pSrc); return 1; } open_db(p, 0); pBackup = sqlite3_backup_init(p->db, zDb, pSrc, "main"); if( pBackup==0 ){ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); sqlite3_close(pSrc); return 1; } @@ -3579,10 +3599,10 @@ static int do_meta_command(char *zLine, ShellState *p){ if( rc==SQLITE_DONE ){ rc = 0; }else if( rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){ - fprintf(stderr, "Error: source database is busy\n"); + raw_printf(stderr, "Error: source database is busy\n"); rc = 1; }else{ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); rc = 1; } sqlite3_close(pSrc); @@ -3593,10 +3613,10 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ p->scanstatsOn = booleanValue(azArg[1]); #ifndef SQLITE_ENABLE_STMT_SCANSTATUS - fprintf(stderr, "Warning: .scanstats not available in this build.\n"); + raw_printf(stderr, "Warning: .scanstats not available in this build.\n"); #endif }else{ - fprintf(stderr, "Usage: .scanstats on|off\n"); + raw_printf(stderr, "Usage: .scanstats on|off\n"); rc = 1; } }else @@ -3663,16 +3683,16 @@ static int do_meta_command(char *zLine, ShellState *p){ callback, &data, &zErrMsg ); }else{ - fprintf(stderr, "Usage: .schema ?LIKE-PATTERN?\n"); + raw_printf(stderr, "Usage: .schema ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; } if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); + utf8_printf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; }else if( rc != SQLITE_OK ){ - fprintf(stderr,"Error: querying schema information\n"); + raw_printf(stderr,"Error: querying schema information\n"); rc = 1; }else{ rc = 0; @@ -3713,7 +3733,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='s' && strncmp(azArg[0], "separator", n)==0 ){ if( nArg<2 || nArg>3 ){ - fprintf(stderr, "Usage: .separator COL ?ROW?\n"); + raw_printf(stderr, "Usage: .separator COL ?ROW?\n"); rc = 1; } if( nArg>=2 ){ @@ -3732,7 +3752,7 @@ static int do_meta_command(char *zLine, ShellState *p){ char *zCmd; int i, x; if( nArg<2 ){ - fprintf(stderr, "Usage: .system COMMAND\n"); + raw_printf(stderr, "Usage: .system COMMAND\n"); rc = 1; goto meta_command_exit; } @@ -3743,45 +3763,45 @@ static int do_meta_command(char *zLine, ShellState *p){ } x = system(zCmd); sqlite3_free(zCmd); - if( x ) fprintf(stderr, "System command returns %d\n", x); + if( x ) raw_printf(stderr, "System command returns %d\n", x); }else if( c=='s' && strncmp(azArg[0], "show", n)==0 ){ int i; if( nArg!=1 ){ - fprintf(stderr, "Usage: .show\n"); + raw_printf(stderr, "Usage: .show\n"); rc = 1; goto meta_command_exit; } - fprintf(p->out,"%12.12s: %s\n","echo", p->echoOn ? "on" : "off"); - fprintf(p->out,"%12.12s: %s\n","eqp", p->autoEQP ? "on" : "off"); - fprintf(p->out,"%9.9s: %s\n","explain", p->normalMode.valid ? "on" :"off"); - fprintf(p->out,"%12.12s: %s\n","headers", p->showHeader ? "on" : "off"); - fprintf(p->out,"%12.12s: %s\n","mode", modeDescr[p->mode]); - fprintf(p->out,"%12.12s: ", "nullvalue"); + utf8_printf(p->out, "%12.12s: %s\n","echo", p->echoOn ? "on" : "off"); + utf8_printf(p->out, "%12.12s: %s\n","eqp", p->autoEQP ? "on" : "off"); + utf8_printf(p->out,"%9.9s: %s\n","explain",p->normalMode.valid?"on":"off"); + utf8_printf(p->out,"%12.12s: %s\n","headers", p->showHeader ? "on" : "off"); + utf8_printf(p->out, "%12.12s: %s\n","mode", modeDescr[p->mode]); + utf8_printf(p->out, "%12.12s: ", "nullvalue"); output_c_string(p->out, p->nullValue); - fprintf(p->out, "\n"); - fprintf(p->out,"%12.12s: %s\n","output", + raw_printf(p->out, "\n"); + utf8_printf(p->out,"%12.12s: %s\n","output", strlen30(p->outfile) ? p->outfile : "stdout"); - fprintf(p->out,"%12.12s: ", "colseparator"); + utf8_printf(p->out,"%12.12s: ", "colseparator"); output_c_string(p->out, p->colSeparator); - fprintf(p->out, "\n"); - fprintf(p->out,"%12.12s: ", "rowseparator"); + raw_printf(p->out, "\n"); + utf8_printf(p->out,"%12.12s: ", "rowseparator"); output_c_string(p->out, p->rowSeparator); - fprintf(p->out, "\n"); - fprintf(p->out,"%12.12s: %s\n","stats", p->statsOn ? "on" : "off"); - fprintf(p->out,"%12.12s: ","width"); + raw_printf(p->out, "\n"); + utf8_printf(p->out, "%12.12s: %s\n","stats", p->statsOn ? "on" : "off"); + utf8_printf(p->out, "%12.12s: ", "width"); for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) { - fprintf(p->out,"%d ",p->colWidth[i]); + raw_printf(p->out, "%d ", p->colWidth[i]); } - fprintf(p->out,"\n"); + raw_printf(p->out, "\n"); }else if( c=='s' && strncmp(azArg[0], "stats", n)==0 ){ if( nArg==2 ){ p->statsOn = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .stats on|off\n"); + raw_printf(stderr, "Usage: .stats on|off\n"); rc = 1; } }else @@ -3882,7 +3902,7 @@ static int do_meta_command(char *zLine, ShellState *p){ utf8_printf(p->out, "%s%-*s", zSp, maxlen, azResult[j] ? azResult[j]:""); } - fprintf(p->out, "\n"); + raw_printf(p->out, "\n"); } } @@ -3925,7 +3945,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( testctrl<0 ){ testctrl = aCtrl[i].ctrlCode; }else{ - fprintf(stderr, "ambiguous option name: \"%s\"\n", azArg[1]); + utf8_printf(stderr, "ambiguous option name: \"%s\"\n", azArg[1]); testctrl = -1; break; } @@ -3933,7 +3953,7 @@ static int do_meta_command(char *zLine, ShellState *p){ } if( testctrl<0 ) testctrl = (int)integerValue(azArg[1]); if( (testctrlSQLITE_TESTCTRL_LAST) ){ - fprintf(stderr,"Error: invalid testctrl option: %s\n", azArg[1]); + utf8_printf(stderr,"Error: invalid testctrl option: %s\n", azArg[1]); }else{ switch(testctrl){ @@ -3943,9 +3963,9 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==3 ){ int opt = (int)strtol(azArg[2], 0, 0); rc2 = sqlite3_test_control(testctrl, p->db, opt); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { - fprintf(stderr,"Error: testctrl %s takes a single int option\n", + utf8_printf(stderr,"Error: testctrl %s takes a single int option\n", azArg[1]); } break; @@ -3957,9 +3977,10 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_BYTEORDER: if( nArg==2 ){ rc2 = sqlite3_test_control(testctrl); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { - fprintf(stderr,"Error: testctrl %s takes no options\n", azArg[1]); + utf8_printf(stderr,"Error: testctrl %s takes no options\n", + azArg[1]); } break; @@ -3968,9 +3989,9 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==3 ){ unsigned int opt = (unsigned int)integerValue(azArg[2]); rc2 = sqlite3_test_control(testctrl, opt); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { - fprintf(stderr,"Error: testctrl %s takes a single unsigned" + utf8_printf(stderr,"Error: testctrl %s takes a single unsigned" " int option\n", azArg[1]); } break; @@ -3982,9 +4003,9 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==3 ){ int opt = booleanValue(azArg[2]); rc2 = sqlite3_test_control(testctrl, opt); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { - fprintf(stderr,"Error: testctrl %s takes a single int option\n", + utf8_printf(stderr,"Error: testctrl %s takes a single int option\n", azArg[1]); } break; @@ -3995,10 +4016,11 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==3 ){ const char *opt = azArg[2]; rc2 = sqlite3_test_control(testctrl, opt); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { - fprintf(stderr,"Error: testctrl %s takes a single char * option\n", - azArg[1]); + utf8_printf(stderr, + "Error: testctrl %s takes a single char * option\n", + azArg[1]); } break; #endif @@ -4009,9 +4031,9 @@ static int do_meta_command(char *zLine, ShellState *p){ azArg[2], integerValue(azArg[3]), integerValue(azArg[4])); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); }else{ - fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n"); + raw_printf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n"); } break; @@ -4020,8 +4042,9 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: case SQLITE_TESTCTRL_SCRATCHMALLOC: default: - fprintf(stderr,"Error: CLI support for testctrl %s not implemented\n", - azArg[1]); + utf8_printf(stderr, + "Error: CLI support for testctrl %s not implemented\n", + azArg[1]); break; } } @@ -4036,11 +4059,11 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ enableTimer = booleanValue(azArg[1]); if( enableTimer && !HAS_TIMER ){ - fprintf(stderr, "Error: timer not available on this system.\n"); + raw_printf(stderr, "Error: timer not available on this system.\n"); enableTimer = 0; } }else{ - fprintf(stderr, "Usage: .timer on|off\n"); + raw_printf(stderr, "Usage: .timer on|off\n"); rc = 1; } }else @@ -4048,7 +4071,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='t' && strncmp(azArg[0], "trace", n)==0 ){ open_db(p, 0); if( nArg!=2 ){ - fprintf(stderr, "Usage: .trace FILE|off\n"); + raw_printf(stderr, "Usage: .trace FILE|off\n"); rc = 1; goto meta_command_exit; } @@ -4066,26 +4089,26 @@ static int do_meta_command(char *zLine, ShellState *p){ #if SQLITE_USER_AUTHENTICATION if( c=='u' && strncmp(azArg[0], "user", n)==0 ){ if( nArg<2 ){ - fprintf(stderr, "Usage: .user SUBCOMMAND ...\n"); + raw_printf(stderr, "Usage: .user SUBCOMMAND ...\n"); rc = 1; goto meta_command_exit; } open_db(p, 0); if( strcmp(azArg[1],"login")==0 ){ if( nArg!=4 ){ - fprintf(stderr, "Usage: .user login USER PASSWORD\n"); + raw_printf(stderr, "Usage: .user login USER PASSWORD\n"); rc = 1; goto meta_command_exit; } rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3], (int)strlen(azArg[3])); if( rc ){ - fprintf(stderr, "Authentication failed for user %s\n", azArg[2]); + utf8_printf(stderr, "Authentication failed for user %s\n", azArg[2]); rc = 1; } }else if( strcmp(azArg[1],"add")==0 ){ if( nArg!=5 ){ - fprintf(stderr, "Usage: .user add USER PASSWORD ISADMIN\n"); + raw_printf(stderr, "Usage: .user add USER PASSWORD ISADMIN\n"); rc = 1; goto meta_command_exit; } @@ -4093,12 +4116,12 @@ static int do_meta_command(char *zLine, ShellState *p){ azArg[3], (int)strlen(azArg[3]), booleanValue(azArg[4])); if( rc ){ - fprintf(stderr, "User-Add failed: %d\n", rc); + raw_printf(stderr, "User-Add failed: %d\n", rc); rc = 1; } }else if( strcmp(azArg[1],"edit")==0 ){ if( nArg!=5 ){ - fprintf(stderr, "Usage: .user edit USER PASSWORD ISADMIN\n"); + raw_printf(stderr, "Usage: .user edit USER PASSWORD ISADMIN\n"); rc = 1; goto meta_command_exit; } @@ -4106,22 +4129,22 @@ static int do_meta_command(char *zLine, ShellState *p){ azArg[3], (int)strlen(azArg[3]), booleanValue(azArg[4])); if( rc ){ - fprintf(stderr, "User-Edit failed: %d\n", rc); + raw_printf(stderr, "User-Edit failed: %d\n", rc); rc = 1; } }else if( strcmp(azArg[1],"delete")==0 ){ if( nArg!=3 ){ - fprintf(stderr, "Usage: .user delete USER\n"); + raw_printf(stderr, "Usage: .user delete USER\n"); rc = 1; goto meta_command_exit; } rc = sqlite3_user_delete(p->db, azArg[2]); if( rc ){ - fprintf(stderr, "User-Delete failed: %d\n", rc); + raw_printf(stderr, "User-Delete failed: %d\n", rc); rc = 1; } }else{ - fprintf(stderr, "Usage: .user login|add|edit|delete ...\n"); + raw_printf(stderr, "Usage: .user login|add|edit|delete ...\n"); rc = 1; goto meta_command_exit; } @@ -4129,7 +4152,7 @@ static int do_meta_command(char *zLine, ShellState *p){ #endif /* SQLITE_USER_AUTHENTICATION */ if( c=='v' && strncmp(azArg[0], "version", n)==0 ){ - fprintf(p->out, "SQLite %s %s\n" /*extra-version-info*/, + utf8_printf(p->out, "SQLite %s %s\n" /*extra-version-info*/, sqlite3_libversion(), sqlite3_sourceid()); }else @@ -4139,10 +4162,10 @@ static int do_meta_command(char *zLine, ShellState *p){ if( p->db ){ sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFS_POINTER, &pVfs); if( pVfs ){ - fprintf(p->out, "vfs.zName = \"%s\"\n", pVfs->zName); - fprintf(p->out, "vfs.iVersion = %d\n", pVfs->iVersion); - fprintf(p->out, "vfs.szOsFile = %d\n", pVfs->szOsFile); - fprintf(p->out, "vfs.mxPathname = %d\n", pVfs->mxPathname); + utf8_printf(p->out, "vfs.zName = \"%s\"\n", pVfs->zName); + raw_printf(p->out, "vfs.iVersion = %d\n", pVfs->iVersion); + raw_printf(p->out, "vfs.szOsFile = %d\n", pVfs->szOsFile); + raw_printf(p->out, "vfs.mxPathname = %d\n", pVfs->mxPathname); } } }else @@ -4153,7 +4176,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( p->db ){ sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFSNAME, &zVfsName); if( zVfsName ){ - fprintf(p->out, "%s\n", zVfsName); + utf8_printf(p->out, "%s\n", zVfsName); sqlite3_free(zVfsName); } } @@ -4175,7 +4198,7 @@ static int do_meta_command(char *zLine, ShellState *p){ }else { - fprintf(stderr, "Error: unknown command or invalid arguments: " + utf8_printf(stderr, "Error: unknown command or invalid arguments: " " \"%s\". Enter \".help\" for help\n", azArg[0]); rc = 1; } @@ -4310,7 +4333,7 @@ static int process_input(ShellState *p, FILE *in){ nAlloc = nSql+nLine+100; zSql = realloc(zSql, nAlloc); if( zSql==0 ){ - fprintf(stderr, "Error: out of memory\n"); + raw_printf(stderr, "Error: out of memory\n"); exit(1); } } @@ -4344,15 +4367,15 @@ static int process_input(ShellState *p, FILE *in){ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "Error:"); } if( zErrMsg!=0 ){ - fprintf(stderr, "%s %s\n", zPrefix, zErrMsg); + utf8_printf(stderr, "%s %s\n", zPrefix, zErrMsg); sqlite3_free(zErrMsg); zErrMsg = 0; }else{ - fprintf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db)); + utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db)); } errCnt++; }else if( p->countChanges ){ - fprintf(p->out, "changes: %3d total_changes: %d\n", + raw_printf(p->out, "changes: %3d total_changes: %d\n", sqlite3_changes(p->db), sqlite3_total_changes(p->db)); } nSql = 0; @@ -4367,7 +4390,7 @@ static int process_input(ShellState *p, FILE *in){ } if( nSql ){ if( !_all_whitespace(zSql) ){ - fprintf(stderr, "Error: incomplete SQL: %s\n", zSql); + utf8_printf(stderr, "Error: incomplete SQL: %s\n", zSql); errCnt++; } } @@ -4458,7 +4481,7 @@ static void process_sqliterc( if (sqliterc == NULL) { home_dir = find_home_dir(); if( home_dir==0 ){ - fprintf(stderr, "-- warning: cannot find home directory;" + raw_printf(stderr, "-- warning: cannot find home directory;" " cannot read ~/.sqliterc\n"); return; } @@ -4469,7 +4492,7 @@ static void process_sqliterc( in = fopen(sqliterc,"rb"); if( in ){ if( stdin_is_interactive ){ - fprintf(stderr,"-- Loading resources from %s\n",sqliterc); + utf8_printf(stderr,"-- Loading resources from %s\n",sqliterc); } process_input(p,in); fclose(in); @@ -4516,14 +4539,14 @@ static const char zOptions[] = #endif ; static void usage(int showDetail){ - fprintf(stderr, + utf8_printf(stderr, "Usage: %s [OPTIONS] FILENAME [SQL]\n" "FILENAME is the name of an SQLite database. A new database is created\n" "if the file does not previously exist.\n", Argv0); if( showDetail ){ - fprintf(stderr, "OPTIONS include:\n%s", zOptions); + utf8_printf(stderr, "OPTIONS include:\n%s", zOptions); }else{ - fprintf(stderr, "Use the -help option for additional information\n"); + raw_printf(stderr, "Use the -help option for additional information\n"); } exit(1); } @@ -4571,7 +4594,7 @@ static void printBold(const char *zText){ */ static char *cmdline_option_value(int argc, char **argv, int i){ if( i==argc ){ - fprintf(stderr, "%s: Error: missing argument to %s\n", + utf8_printf(stderr, "%s: Error: missing argument to %s\n", argv[0], argv[argc-1]); exit(1); } @@ -4591,7 +4614,7 @@ int SQLITE_CDECL main(int argc, char **argv){ #if USE_SYSTEM_SQLITE+0!=1 if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){ - fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", + utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", sqlite3_sourceid(), SQLITE_SOURCE_ID); exit(1); } @@ -4640,7 +4663,7 @@ int SQLITE_CDECL main(int argc, char **argv){ nCmd++; azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd); if( azCmd==0 ){ - fprintf(stderr, "out of memory\n"); + raw_printf(stderr, "out of memory\n"); exit(1); } azCmd[nCmd-1] = z; @@ -4722,7 +4745,7 @@ int SQLITE_CDECL main(int argc, char **argv){ if( pVfs ){ sqlite3_vfs_register(pVfs, 1); }else{ - fprintf(stderr, "no such VFS: \"%s\"\n", argv[i]); + utf8_printf(stderr, "no such VFS: \"%s\"\n", argv[i]); exit(1); } } @@ -4732,7 +4755,7 @@ int SQLITE_CDECL main(int argc, char **argv){ data.zDbFilename = ":memory:"; warnInmemoryDb = argc==1; #else - fprintf(stderr,"%s: Error: no database filename specified\n", Argv0); + utf8_printf(stderr,"%s: Error: no database filename specified\n", Argv0); return 1; #endif } @@ -4854,16 +4877,16 @@ int SQLITE_CDECL main(int argc, char **argv){ open_db(&data, 0); rc = shell_exec(data.db, z, shell_callback, &data, &zErrMsg); if( zErrMsg!=0 ){ - fprintf(stderr,"Error: %s\n", zErrMsg); + utf8_printf(stderr,"Error: %s\n", zErrMsg); if( bail_on_error ) return rc!=0 ? rc : 1; }else if( rc!=0 ){ - fprintf(stderr,"Error: unable to process SQL \"%s\"\n", z); + utf8_printf(stderr,"Error: unable to process SQL \"%s\"\n", z); if( bail_on_error ) return rc; } } }else{ - fprintf(stderr,"%s: Error: unknown option: %s\n", Argv0, z); - fprintf(stderr,"Use -help for a list of options.\n"); + utf8_printf(stderr,"%s: Error: unknown option: %s\n", Argv0, z); + raw_printf(stderr,"Use -help for a list of options.\n"); return 1; } } @@ -4881,10 +4904,10 @@ int SQLITE_CDECL main(int argc, char **argv){ open_db(&data, 0); rc = shell_exec(data.db, azCmd[i], shell_callback, &data, &zErrMsg); if( zErrMsg!=0 ){ - fprintf(stderr,"Error: %s\n", zErrMsg); + utf8_printf(stderr,"Error: %s\n", zErrMsg); return rc!=0 ? rc : 1; }else if( rc!=0 ){ - fprintf(stderr,"Error: unable to process SQL: %s\n", azCmd[i]); + utf8_printf(stderr,"Error: unable to process SQL: %s\n", azCmd[i]); return rc; } } From bdfa1b94e9a459159f063a5cd5d79ea738cc3a38 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 31 Dec 2015 22:29:36 +0000 Subject: [PATCH 119/232] Fix the ieee754.test module so that it works both on systems that report infinity as "inf" and as "Inf". FossilOrigin-Name: d41d4d7396fba60895535f21c438f8c75e7b2097 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/ieee754.test | 16 ++++++++++------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 3c7f5db48d..777a162846 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sshell,\suse\sutf8_printf()\swhen\sany\sstring\sformatting\sis\spresent\sand\sraw_printf()\sotherwise. -D 2015-12-31T19:06:24.721 +C Fix\sthe\sieee754.test\smodule\sso\sthat\sit\sworks\sboth\son\ssystems\sthat\sreport\ninfinity\sas\s"inf"\sand\sas\s"Inf". +D 2015-12-31T22:29:36.133 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -761,7 +761,7 @@ F test/hexlit.test d7b0a5f41123df1e43985b91b8b2e70f95282d21 F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711 F test/hook.test 162d7cef7a2d2b04839fe14402934e6a1b79442f F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4 -F test/ieee754.test 118b665a97a8df0e8f2fbdb07d113e596f4a6b53 +F test/ieee754.test 806fc0ce7f305f57e3331eaceeddcfec9339e607 F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 F test/in.test 61a24ae38d4b64ec69f06ccdf022992f68a98176 F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 98ec778daac835d9ae103f6460b7d897981a5dd6 -R cd1e993dc14f9af3b107557468145aaf -U mistachkin -Z 770ade254ba97d3649a2f5b30f5d6fd8 +P 8cf01fff232d15d3c7b7b62b2d890d983e1945f2 +R 1c5d971ba298f5f3c5fb001aa5fe882d +U drh +Z d166bbddc4f1202c8b662a343755f966 diff --git a/manifest.uuid b/manifest.uuid index 4302de3a4a..80841183f5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8cf01fff232d15d3c7b7b62b2d890d983e1945f2 \ No newline at end of file +d41d4d7396fba60895535f21c438f8c75e7b2097 \ No newline at end of file diff --git a/test/ieee754.test b/test/ieee754.test index c0bf9d7995..bf0676429b 100644 --- a/test/ieee754.test +++ b/test/ieee754.test @@ -43,12 +43,16 @@ foreach {id float rep} { } } -do_execsql_test ieee754-110 { - SELECT ieee754(1,1024), ieee754(4503599627370495,972); -} {Inf 1.79769313486232e+308} -do_execsql_test ieee754-111 { - SELECT ieee754(-1,1024), ieee754(-4503599627370495,972); -} {-Inf -1.79769313486232e+308} +do_test ieee754-110 { + string tolower [ + db eval {SELECT ieee754(1,1024), ieee754(4503599627370495,972);} + ] +} {inf 1.79769313486232e+308} +do_test ieee754-111 { + string tolower [ + db eval {SELECT ieee754(-1,1024), ieee754(-4503599627370495,972);} + ] +} {-inf -1.79769313486232e+308} do_execsql_test ieee754-112 { SELECT ieee754(4503599627370495,973) is null; } {1} From 2307926ea9c6f5da271c6662b3441d6765366bbb Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Jan 2016 00:15:59 +0000 Subject: [PATCH 120/232] Remove unreachable branches from the new JSON aggregate functions. FossilOrigin-Name: 6e30f8c6c3af9b0df39783888a1479f88271f989 --- ext/misc/json1.c | 4 ++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/misc/json1.c b/ext/misc/json1.c index 0bd0baff12..3707516660 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -1549,7 +1549,7 @@ static void jsonArrayFinal(sqlite3_context *ctx){ jsonAppendChar(pStr, ']'); if( pStr->bErr ){ sqlite3_result_error_nomem(ctx); - if( !pStr->bStatic ) sqlite3_free(pStr->zBuf); + assert( pStr->bStatic ); }else{ sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); @@ -1597,7 +1597,7 @@ static void jsonObjectFinal(sqlite3_context *ctx){ jsonAppendChar(pStr, '}'); if( pStr->bErr ){ sqlite3_result_error_nomem(ctx); - if( !pStr->bStatic ) sqlite3_free(pStr->zBuf); + assert( pStr->bStatic ); }else{ sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); diff --git a/manifest b/manifest index 777a162846..5325ac3c14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sieee754.test\smodule\sso\sthat\sit\sworks\sboth\son\ssystems\sthat\sreport\ninfinity\sas\s"inf"\sand\sas\s"Inf". -D 2015-12-31T22:29:36.133 +C Remove\sunreachable\sbranches\sfrom\sthe\snew\sJSON\saggregate\sfunctions. +D 2016-01-01T00:15:59.486 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -191,7 +191,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c -F ext/misc/json1.c b7ed42db00f7429c0f0b5068209c95c41b531596 +F ext/misc/json1.c 7b1155f520d5e8ec1c005d978ac675e8a7f2688a F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8cf01fff232d15d3c7b7b62b2d890d983e1945f2 -R 1c5d971ba298f5f3c5fb001aa5fe882d +P d41d4d7396fba60895535f21c438f8c75e7b2097 +R 2a5f60ea0e38c7e7f43524504946739d U drh -Z d166bbddc4f1202c8b662a343755f966 +Z 26d827cb451c91d1af0425a029635f07 diff --git a/manifest.uuid b/manifest.uuid index 80841183f5..f52f04dccd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d41d4d7396fba60895535f21c438f8c75e7b2097 \ No newline at end of file +6e30f8c6c3af9b0df39783888a1479f88271f989 \ No newline at end of file From a660caf2f01c99ef48085c731e200b5a2fa575b5 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Jan 2016 03:37:44 +0000 Subject: [PATCH 121/232] Fix an assert() that might be false for a corrupt database. FossilOrigin-Name: 68360cd2211b7ab25dd4ca55a2e82e31f51f2976 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5325ac3c14..b08341888c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunreachable\sbranches\sfrom\sthe\snew\sJSON\saggregate\sfunctions. -D 2016-01-01T00:15:59.486 +C Fix\san\sassert()\sthat\smight\sbe\sfalse\sfor\sa\scorrupt\sdatabase. +D 2016-01-01T03:37:44.301 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -276,7 +276,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 5ac3f868d4f20a67f0f00a1014940f902b511558 +F src/btree.c 4d3452b2a3daf875490ac4f0a278da7f85fabe12 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 F src/build.c 1c9fb552148ee8f9234435a38833f8fca2081a71 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d41d4d7396fba60895535f21c438f8c75e7b2097 -R 2a5f60ea0e38c7e7f43524504946739d +P 6e30f8c6c3af9b0df39783888a1479f88271f989 +R 6e164f424e8aa8f067cc3a49970e615a U drh -Z 26d827cb451c91d1af0425a029635f07 +Z 284865b0f74f185e26863aa2df0b68aa diff --git a/manifest.uuid b/manifest.uuid index f52f04dccd..7d85a2b67d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6e30f8c6c3af9b0df39783888a1479f88271f989 \ No newline at end of file +68360cd2211b7ab25dd4ca55a2e82e31f51f2976 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index df9455bc5b..f5feff8a4c 100644 --- a/src/btree.c +++ b/src/btree.c @@ -8221,7 +8221,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, int bPreserve){ if( rc==SQLITE_OK ){ if( bSkipnext ){ - assert( bPreserve && pCur->iPage==iCellDepth ); + assert( bPreserve && (pCur->iPage==iCellDepth || CORRUPT_DB) ); assert( pPage==pCur->apPage[pCur->iPage] ); assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell ); pCur->eState = CURSOR_SKIPNEXT; From 3c19bb60d108a48a6b9ddf7f84bf085edc7e8e17 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Jan 2016 16:26:22 +0000 Subject: [PATCH 122/232] Avoid misaligned memory allocations on Sparc in sqlite3VdbeMakeReady(). FossilOrigin-Name: a304e34675404aee860fcc97fa4ffcc57c014812 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 5 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index b08341888c..7e83b58a5a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sassert()\sthat\smight\sbe\sfalse\sfor\sa\scorrupt\sdatabase. -D 2016-01-01T03:37:44.301 +C Avoid\smisaligned\smemory\sallocations\son\sSparc\sin\ssqlite3VdbeMakeReady(). +D 2016-01-01T16:26:22.999 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -402,7 +402,7 @@ F src/vdbe.c 39d7628bb8eed10a5378adcf97cca6dce7829a8f F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c ca523180c128dc6c64894efc61eb14374117c864 +F src/vdbeaux.c 2a25e57e140a3cdef14dc11912c174cf6eb9d5a6 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6e30f8c6c3af9b0df39783888a1479f88271f989 -R 6e164f424e8aa8f067cc3a49970e615a +P 68360cd2211b7ab25dd4ca55a2e82e31f51f2976 +R be44c4e5edec4a82a16bfbdbf7214b99 U drh -Z 284865b0f74f185e26863aa2df0b68aa +Z f1917e9fad1e2726446c5b64d14d6919 diff --git a/manifest.uuid b/manifest.uuid index 7d85a2b67d..940d1e52e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -68360cd2211b7ab25dd4ca55a2e82e31f51f2976 \ No newline at end of file +a304e34675404aee860fcc97fa4ffcc57c014812 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 10353e839f..9c35fc12d9 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1849,9 +1849,8 @@ void sqlite3VdbeMakeReady( /* Allocate space for memory registers, SQL variables, VDBE cursors and ** an array to marshal SQL function arguments in. */ - zCsr = (u8*)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ - assert( pParse->nOpAlloc*sizeof(Op) <= 0x7fffff00 ); - nFree = (pParse->nOpAlloc - p->nOp)*sizeof(p->aOp[0]); /* Available space */ + zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ + nFree = sqlite3_msize(p->aOp) - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); From bd57308eef5dfaf99b0d242caaac0f69067b4e61 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Jan 2016 16:42:09 +0000 Subject: [PATCH 123/232] Remember the size of the Vdbe.aOp[] array in bytes, to avoid unnecessary calls to sqlite3_msize(). FossilOrigin-Name: 3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 1 + src/vdbeaux.c | 8 +++++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 7e83b58a5a..677f2d0a83 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\smisaligned\smemory\sallocations\son\sSparc\sin\ssqlite3VdbeMakeReady(). -D 2016-01-01T16:26:22.999 +C Remember\sthe\ssize\sof\sthe\sVdbe.aOp[]\sarray\sin\sbytes,\sto\savoid\sunnecessary\ncalls\sto\ssqlite3_msize(). +D 2016-01-01T16:42:09.017 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -338,7 +338,7 @@ F src/shell.c 8d152e833c3b79825978deb83175234749c5cdf3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 92f83ab4612141f95cdd663ea55fa4528f3f8c2a +F src/sqliteInt.h 30f7e8957ed7d244be027be72ded385154c635df F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -402,7 +402,7 @@ F src/vdbe.c 39d7628bb8eed10a5378adcf97cca6dce7829a8f F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 2a25e57e140a3cdef14dc11912c174cf6eb9d5a6 +F src/vdbeaux.c 66b546a1da82dfa6e67985ae0442ba5fd9efe0ff F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 68360cd2211b7ab25dd4ca55a2e82e31f51f2976 -R be44c4e5edec4a82a16bfbdbf7214b99 +P a304e34675404aee860fcc97fa4ffcc57c014812 +R 4471a4984cac341d5421a7094690c1b8 U drh -Z f1917e9fad1e2726446c5b64d14d6919 +Z 73de58c32dddcab1338ba5f059ee0a34 diff --git a/manifest.uuid b/manifest.uuid index 940d1e52e4..85183cd86a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a304e34675404aee860fcc97fa4ffcc57c014812 \ No newline at end of file +3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index e1fe6dae79..53f0709645 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2732,6 +2732,7 @@ struct Parse { int nSet; /* Number of sets used so far */ int nOnce; /* Number of OP_Once instructions so far */ int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */ + int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */ int iFixedOp; /* Never back out opcodes iFixedOp-1 or earlier */ int ckBase; /* Base register of data during check constraints */ int iSelfTab; /* Table of an index whose exprs are being coded */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 9c35fc12d9..7d547e5830 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -35,6 +35,7 @@ Vdbe *sqlite3VdbeCreate(Parse *pParse){ assert( pParse->aLabel==0 ); assert( pParse->nLabel==0 ); assert( pParse->nOpAlloc==0 ); + assert( pParse->szOpAlloc==0 ); return p; } @@ -124,7 +125,8 @@ static int growOpArray(Vdbe *v, int nOp){ assert( nNew>=(p->nOpAlloc+nOp) ); pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op)); if( pNew ){ - p->nOpAlloc = sqlite3DbMallocSize(p->db, pNew)/sizeof(Op); + p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew); + p->nOpAlloc = p->szOpAlloc/sizeof(Op); v->aOp = pNew; } return (pNew ? SQLITE_OK : SQLITE_NOMEM); @@ -1849,8 +1851,8 @@ void sqlite3VdbeMakeReady( /* Allocate space for memory registers, SQL variables, VDBE cursors and ** an array to marshal SQL function arguments in. */ - zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ - nFree = sqlite3_msize(p->aOp) - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ + zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ + nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); From 9abe841e9e7cdd4736001ab45f2d7b879ba716be Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 2 Jan 2016 05:00:31 +0000 Subject: [PATCH 124/232] Fix a (harmless) typo in an #ifdef for SQLITE_ENABLE_CURSOR_HINTS FossilOrigin-Name: 2047d2deabf2021ea05d620c3dd4919448027b11 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 677f2d0a83..517a481aea 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remember\sthe\ssize\sof\sthe\sVdbe.aOp[]\sarray\sin\sbytes,\sto\savoid\sunnecessary\ncalls\sto\ssqlite3_msize(). -D 2016-01-01T16:42:09.017 +C Fix\sa\s(harmless)\stypo\sin\san\s#ifdef\sfor\sSQLITE_ENABLE_CURSOR_HINTS +D 2016-01-02T05:00:31.568 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -398,7 +398,7 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 39d7628bb8eed10a5378adcf97cca6dce7829a8f +F src/vdbe.c 638c20bae996d8037a114294016768b6bc8ebc14 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a304e34675404aee860fcc97fa4ffcc57c014812 -R 4471a4984cac341d5421a7094690c1b8 +P 3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc +R 5906d6b78129d8858a23ea4c57fad965 U drh -Z 73de58c32dddcab1338ba5f059ee0a34 +Z 4843af3fcc8c5413e769bb1983160a44 diff --git a/manifest.uuid b/manifest.uuid index 85183cd86a..2fbf3ac886 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc \ No newline at end of file +2047d2deabf2021ea05d620c3dd4919448027b11 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 5021720c54..c8fc6ff45b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3402,7 +3402,7 @@ open_cursor_set_hints: assert( OPFLAG_BULKCSR==BTREE_BULKLOAD ); assert( OPFLAG_SEEKEQ==BTREE_SEEK_EQ ); testcase( pOp->p5 & OPFLAG_BULKCSR ); -#ifdef SQLITE_ENABLE_CURSOR_HINT +#ifdef SQLITE_ENABLE_CURSOR_HINTS testcase( pOp->p2 & OPFLAG_SEEKEQ ); #endif sqlite3BtreeCursorHintFlags(pCur->uc.pCursor, From fe0c3cfee154f8f5f24c10535507f4d8885a3c5c Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 2 Jan 2016 19:01:56 +0000 Subject: [PATCH 125/232] Changes to run many fts5 tests with detail=none and detail=col tables as well as the default detail=full. Also fixes for the bugs uncovered by running said tests. FossilOrigin-Name: 6322a1d984e7946735bace8a069ef24b31754b3b --- ext/fts5/fts5Int.h | 1 + ext/fts5/fts5_expr.c | 62 +++++++++++++ ext/fts5/fts5_index.c | 128 +++++++++++++++++---------- ext/fts5/fts5_main.c | 76 +++++++++++----- ext/fts5/test/fts5_common.tcl | 27 ++++++ ext/fts5/test/fts5aa.test | 60 +++++++------ ext/fts5/test/fts5ab.test | 28 +++--- ext/fts5/test/fts5ac.test | 154 +++++++++++++-------------------- ext/fts5/test/fts5ad.test | 32 +++---- ext/fts5/test/fts5ae.test | 52 ++++++----- ext/fts5/test/fts5af.test | 56 ++++++------ ext/fts5/test/fts5detail.test | 31 ++++++- ext/fts5/test/fts5simple2.test | 106 +++++++++++++++++++++++ manifest | 36 ++++---- manifest.uuid | 2 +- 15 files changed, 567 insertions(+), 284 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 4ef99ebae1..c369687042 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -646,6 +646,7 @@ Fts5PoslistWriter *sqlite3Fts5ExprClearPoslists(Fts5Expr*); int sqlite3Fts5ExprPopulatePoslists( Fts5Config*, Fts5Expr*, Fts5PoslistWriter*, int, const char*, int ); +void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64); int sqlite3Fts5ExprClonePhrase(Fts5Config*, Fts5Expr*, int, Fts5Expr**); diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index ebd767a617..0a74c7884a 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -2327,6 +2327,68 @@ int sqlite3Fts5ExprPopulatePoslists( ); } +static void fts5ExprClearPoslists(Fts5ExprNode *pNode){ + if( pNode->eType==FTS5_TERM || pNode->eType==FTS5_STRING ){ + pNode->pNear->apPhrase[0]->poslist.n = 0; + }else{ + int i; + for(i=0; inChild; i++){ + fts5ExprClearPoslists(pNode->apChild[i]); + } + } +} + +static int fts5ExprCheckPoslists(Fts5ExprNode *pNode, i64 iRowid){ + if( pNode ){ + pNode->iRowid = iRowid; + pNode->bEof = 0; + switch( pNode->eType ){ + case FTS5_TERM: + case FTS5_STRING: + return (pNode->pNear->apPhrase[0]->poslist.n>0); + + case FTS5_AND: { + int i; + for(i=0; inChild; i++){ + if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid)==0 ){ + fts5ExprClearPoslists(pNode); + return 0; + } + } + return 1; + } + + case FTS5_OR: { + int i; + int bRet = 0; + for(i=0; inChild; i++){ + if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid) ){ + bRet = 1; + } + } + if( bRet==0 ){ + fts5ExprClearPoslists(pNode); + } + return bRet; + } + + default: { + assert( pNode->eType==FTS5_NOT ); + if( 0==fts5ExprCheckPoslists(pNode->apChild[0], iRowid) + || 0!=fts5ExprCheckPoslists(pNode->apChild[1], iRowid) + ){ + fts5ExprClearPoslists(pNode); + return 0; + } + return 1; + } + } + } +} +void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){ + fts5ExprCheckPoslists(pExpr->pRoot, iRowid); +} + /* ** This function is only called for detail=columns tables. */ diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index ef27d73c31..49d8638f33 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -1494,12 +1494,13 @@ static void fts5SegIterLoadNPos(Fts5Index *p, Fts5SegIter *pIter){ int iOff = pIter->iLeafOffset; /* Offset to read at */ ASSERT_SZLEAF_OK(pIter->pLeaf); if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){ + int iEod = MIN(pIter->iEndofDoclist, pIter->pLeaf->szLeaf); pIter->bDel = 0; pIter->nPos = 1; - if( iOffpLeaf->szLeaf && pIter->pLeaf->p[iOff]==0 ){ + if( iOffpLeaf->p[iOff]==0 ){ pIter->bDel = 1; iOff++; - if( iOffpLeaf->szLeaf && pIter->pLeaf->p[iOff]==0 ){ + if( iOffpLeaf->p[iOff]==0 ){ pIter->nPos = 1; iOff++; }else{ @@ -1643,13 +1644,16 @@ static void fts5SegIterReverseInitPage(Fts5Index *p, Fts5SegIter *pIter){ ASSERT_SZLEAF_OK(pIter->pLeaf); while( 1 ){ i64 iDelta = 0; - int nPos; - int bDummy; if( eDetail==FTS5_DETAIL_NONE ){ /* todo */ - + if( iiEndofDoclist = iOff; bNewTerm = 1; } - if( iOff>=pLeaf->szLeaf ){ + assert_nc( iOffszLeaf + || p->pConfig->eDetail==FTS5_DETAIL_NONE + ); + if( iOff>pLeaf->szLeaf ){ p->rc = FTS5_CORRUPT; return; } @@ -1896,6 +1903,11 @@ static void fts5SegIterNext( #define SWAPVAL(T, a, b) { T tmp; tmp=a; a=b; b=tmp; } +#define fts5IndexSkipVarint(a, iOff) { \ + int iEnd = iOff+9; \ + while( (a[iOff++] & 0x80) && iOffiLeafOffset -= sqlite3Fts5GetVarintLen(pIter->nPos*2+pIter->bDel); } +#else + int iPoslist; + if( pIter->iTermLeafPgno==pIter->iLeafPgno ){ + iPoslist = pIter->iTermLeafOffset; + }else{ + iPoslist = 4; + } + fts5IndexSkipVarint(pLeaf->p, iPoslist); + assert( eDetail==FTS5_DETAIL_NONE || iPoslist==( + pIter->iLeafOffset - sqlite3Fts5GetVarintLen(pIter->nPos*2+pIter->bDel) + )); + pIter->iLeafOffset = iPoslist; +#endif /* If this condition is true then the largest rowid for the current ** term may not be stored on the current page. So search forward to @@ -2003,11 +2029,6 @@ static void fts5SegIterLoadDlidx(Fts5Index *p, Fts5SegIter *pIter){ pIter->pDlidx = fts5DlidxIterInit(p, bRev, iSeg, pIter->iTermLeafPgno); } -#define fts5IndexSkipVarint(a, iOff) { \ - int iEnd = iOff+9; \ - while( (a[iOff++] & 0x80) && iOffpConfig->pgsz; - + int eDetail = p->pConfig->eDetail; Fts5StructureSegment *pSeg; /* New segment within pStruct */ Fts5Buffer *pBuf; /* Buffer in which to assemble leaf page */ Fts5Buffer *pPgidx; /* Buffer in which to assemble pgidx */ @@ -3870,12 +3891,7 @@ static void fts5FlushOneHash(Fts5Index *p){ ** loop iterates through the poslists that make up the current ** doclist. */ while( p->rc==SQLITE_OK && iOffn<=pBuf->nSpace ); - if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ - /* The entire poslist will fit on the current leaf. So copy - ** it in one go. */ - fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy); - }else{ - /* The entire poslist will not fit on this leaf. So it needs - ** to be broken into sections. The only qualification being - ** that each varint must be stored contiguously. */ - const u8 *pPoslist = &pDoclist[iOff]; - int iPos = 0; - while( p->rc==SQLITE_OK ){ - int nSpace = pgsz - pBuf->n - pPgidx->n; - int n = 0; - if( (nCopy - iPos)<=nSpace ){ - n = nCopy - iPos; - }else{ - n = fts5PoslistPrefix(&pPoslist[iPos], nSpace); + if( eDetail==FTS5_DETAIL_NONE ){ + if( iOffp[pBuf->n++] = 0; + iOff++; + if( iOffp[pBuf->n++] = 0; + iOff++; } - assert( n>0 ); - fts5BufferSafeAppendBlob(pBuf, &pPoslist[iPos], n); - iPos += n; - if( (pBuf->n + pPgidx->n)>=pgsz ){ - fts5WriteFlushLeaf(p, &writer); - } - if( iPos>=nCopy ) break; } + if( (pBuf->n + pPgidx->n)>=pgsz ){ + fts5WriteFlushLeaf(p, &writer); + } + }else{ + int bDummy; + int nPos; + int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy); + nCopy += nPos; + if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ + /* The entire poslist will fit on the current leaf. So copy + ** it in one go. */ + fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy); + }else{ + /* The entire poslist will not fit on this leaf. So it needs + ** to be broken into sections. The only qualification being + ** that each varint must be stored contiguously. */ + const u8 *pPoslist = &pDoclist[iOff]; + int iPos = 0; + while( p->rc==SQLITE_OK ){ + int nSpace = pgsz - pBuf->n - pPgidx->n; + int n = 0; + if( (nCopy - iPos)<=nSpace ){ + n = nCopy - iPos; + }else{ + n = fts5PoslistPrefix(&pPoslist[iPos], nSpace); + } + assert( n>0 ); + fts5BufferSafeAppendBlob(pBuf, &pPoslist[iPos], n); + iPos += n; + if( (pBuf->n + pPgidx->n)>=pgsz ){ + fts5WriteFlushLeaf(p, &writer); + } + if( iPos>=nCopy ) break; + } + } + iOff += nCopy; } - iOff += nCopy; } } @@ -4408,16 +4442,18 @@ static void fts5MergeRowidLists( fts5NextRowid(p2, &i2, &iRowid2); while( i1>=0 || i2>=0 ){ if( i1>=0 && (i2<0 || iRowid1iOut ); fts5BufferSafeAppendVarint(&out, iRowid1 - iOut); iOut = iRowid1; fts5NextRowid(p1, &i1, &iRowid1); }else{ + assert( iOut==0 || iRowid2>iOut ); fts5BufferSafeAppendVarint(&out, iRowid2 - iOut); iOut = iRowid2; - fts5NextRowid(p2, &i2, &iRowid2); if( i1>=0 && iRowid1==iRowid2 ){ fts5NextRowid(p1, &i1, &iRowid1); } + fts5NextRowid(p2, &i2, &iRowid2); } } @@ -5217,7 +5253,7 @@ static int fts5QueryCksum( for(sqlite3Fts5PoslistReaderInit(buf.p, buf.n, &sReader); sReader.bEof==0; sqlite3Fts5PoslistReaderNext(&sReader) - ){ + ){ int iCol = FTS5_POS2COLUMN(sReader.iPos); int iOff = FTS5_POS2OFFSET(sReader.iPos); cksum ^= sqlite3Fts5IndexEntryCksum(rowid, iCol, iOff, iIdx, z, n); @@ -5584,7 +5620,9 @@ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){ fts5TestTerm(p, &term, z, n, cksum2, &cksum3); if( eDetail==FTS5_DETAIL_NONE ){ - cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, 0, 0, -1, z, n); + if( 0==fts5MultiIterIsEmpty(p, pIter) ){ + cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, 0, 0, -1, z, n); + } }else{ poslist.n = 0; fts5SegiterPoslist(p, &pIter->aSeg[pIter->aFirst[1].iFirst], 0, &poslist); diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index cd43308513..95d72ebbc1 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -730,15 +730,18 @@ static int fts5SorterNext(Fts5Cursor *pCsr){ nBlob = sqlite3_column_bytes(pSorter->pStmt, 1); aBlob = a = sqlite3_column_blob(pSorter->pStmt, 1); - for(i=0; i<(pSorter->nIdx-1); i++){ - int iVal; - a += fts5GetVarint32(a, iVal); - iOff += iVal; - pSorter->aIdx[i] = iOff; + /* nBlob==0 in detail=none mode. */ + if( nBlob>0 ){ + for(i=0; i<(pSorter->nIdx-1); i++){ + int iVal; + a += fts5GetVarint32(a, iVal); + iOff += iVal; + pSorter->aIdx[i] = iOff; + } + pSorter->aIdx[i] = &aBlob[nBlob] - a; + pSorter->aPoslist = a; } - pSorter->aIdx[i] = &aBlob[nBlob] - a; - pSorter->aPoslist = a; fts5CsrNewrow(pCsr); } @@ -1678,15 +1681,15 @@ static int fts5ApiColumnText( } static int fts5CsrPoslist(Fts5Cursor *pCsr, int iPhrase, const u8 **pa){ + Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig; int n; int rc = SQLITE_OK; if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){ - Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig; + if( pConfig->eDetail!=FTS5_DETAIL_FULL ){ Fts5PoslistWriter *aWriter; int i; -assert( pCsr->pSorter==0 ); /* fixme */ aWriter = sqlite3Fts5ExprClearPoslists(pCsr->pExpr); if( aWriter==0 ) rc = SQLITE_NOMEM; for(i=0; inCol && rc==SQLITE_OK; i++){ @@ -1699,11 +1702,14 @@ assert( pCsr->pSorter==0 ); /* fixme */ } } sqlite3_free(aWriter); + if( pCsr->pSorter ){ + sqlite3Fts5ExprCheckPoslists(pCsr->pExpr, pCsr->pSorter->iRowid); + } } CsrFlagClear(pCsr, FTS5CSR_REQUIRE_POSLIST); } - if( pCsr->pSorter ){ + if( pCsr->pSorter && pConfig->eDetail==FTS5_DETAIL_FULL ){ Fts5Sorter *pSorter = pCsr->pSorter; int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]); n = pSorter->aIdx[iPhrase] - i1; @@ -2204,20 +2210,46 @@ static int fts5PoslistBlob(sqlite3_context *pCtx, Fts5Cursor *pCsr){ Fts5Buffer val; memset(&val, 0, sizeof(Fts5Buffer)); + switch( ((Fts5Table*)(pCsr->base.pVtab))->pConfig->eDetail ){ + case FTS5_DETAIL_FULL: - /* Append the varints */ - for(i=0; i<(nPhrase-1); i++){ - const u8 *dummy; - int nByte = sqlite3Fts5ExprPoslist(pCsr->pExpr, i, &dummy); - sqlite3Fts5BufferAppendVarint(&rc, &val, nByte); - } + /* Append the varints */ + for(i=0; i<(nPhrase-1); i++){ + const u8 *dummy; + int nByte = sqlite3Fts5ExprPoslist(pCsr->pExpr, i, &dummy); + sqlite3Fts5BufferAppendVarint(&rc, &val, nByte); + } - /* Append the position lists */ - for(i=0; ipExpr, i, &pPoslist); - sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist); + /* Append the position lists */ + for(i=0; ipExpr, i, &pPoslist); + sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist); + } + break; + + case FTS5_DETAIL_COLUMNS: + + /* Append the varints */ + for(i=0; rc==SQLITE_OK && i<(nPhrase-1); i++){ + const u8 *dummy; + int nByte; + rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &dummy, &nByte); + sqlite3Fts5BufferAppendVarint(&rc, &val, nByte); + } + + /* Append the position lists */ + for(i=0; rc==SQLITE_OK && ipExpr, i, &pPoslist, &nPoslist); + sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist); + } + break; + + default: + break; } sqlite3_result_blob(pCtx, val.p, val.n, sqlite3_free); diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index 64af5c59b3..3bcd33dcfc 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -365,3 +365,30 @@ proc fts5_tokenize_split {text} { set ret } +#------------------------------------------------------------------------- +# +proc foreach_detail_mode {prefix script} { + set saved $::testprefix + foreach d [list full col none] { + set s [string map [list %DETAIL% $d] $script] + set ::detail $d + set ::testprefix "$prefix-$d" + reset_db + uplevel $s + unset ::detail + } + set ::testprefix $saved +} + +proc detail_check {} { + if {$::detail != "none" && $::detail!="full" && $::detail!="col"} { + error "not in foreach_detail_mode {...} block" + } +} +proc detail_is_none {} { detail_check ; expr {$::detail == "none"} } +proc detail_is_col {} { detail_check ; expr {$::detail == "col" } } +proc detail_is_full {} { detail_check ; expr {$::detail == "full"} } + + + + diff --git a/ext/fts5/test/fts5aa.test b/ext/fts5/test/fts5aa.test index 59b8ab86d1..e00bcfcdcc 100644 --- a/ext/fts5/test/fts5aa.test +++ b/ext/fts5/test/fts5aa.test @@ -21,6 +21,8 @@ ifcapable !fts5 { return } +foreach_detail_mode $::testprefix { + do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts5(a, b, c); SELECT name, sql FROM sqlite_master; @@ -41,9 +43,9 @@ do_execsql_test 1.1 { #------------------------------------------------------------------------- # -reset_db + do_execsql_test 2.0 { - CREATE VIRTUAL TABLE t1 USING fts5(x,y); + CREATE VIRTUAL TABLE t1 USING fts5(x, y, detail=%DETAIL%); } do_execsql_test 2.1 { INSERT INTO t1 VALUES('a b c', 'd e f'); @@ -66,11 +68,12 @@ do_execsql_test 2.4 { INSERT INTO t1(t1) VALUES('integrity-check'); } + #------------------------------------------------------------------------- # reset_db do_execsql_test 3.0 { - CREATE VIRTUAL TABLE t1 USING fts5(x,y); + CREATE VIRTUAL TABLE t1 USING fts5(x,y, detail=%DETAIL%); } foreach {i x y} { 1 {g f d b f} {h h e i a} @@ -93,7 +96,7 @@ foreach {i x y} { # reset_db do_execsql_test 4.0 { - CREATE VIRTUAL TABLE t1 USING fts5(x,y); + CREATE VIRTUAL TABLE t1 USING fts5(x,y, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); } foreach {i x y} { @@ -117,7 +120,7 @@ foreach {i x y} { # reset_db do_execsql_test 5.0 { - CREATE VIRTUAL TABLE t1 USING fts5(x,y); + CREATE VIRTUAL TABLE t1 USING fts5(x,y, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); } foreach {i x y} { @@ -141,7 +144,7 @@ foreach {i x y} { # reset_db do_execsql_test 6.0 { - CREATE VIRTUAL TABLE t1 USING fts5(x,y); + CREATE VIRTUAL TABLE t1 USING fts5(x,y, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); } @@ -276,7 +279,7 @@ for {set i 1} {$i <= 10} {incr i} { # reset_db do_execsql_test 10.0 { - CREATE VIRTUAL TABLE t1 USING fts5(x,y); + CREATE VIRTUAL TABLE t1 USING fts5(x,y, detail=%DETAIL%); } set d10 { 1 {g f d b f} {h h e i a} @@ -309,19 +312,19 @@ do_execsql_test 10.4.2 { INSERT INTO t1(t1) VALUES('integrity-check') } #------------------------------------------------------------------------- # do_catchsql_test 11.1 { - CREATE VIRTUAL TABLE t2 USING fts5(a, b, c, rank); + CREATE VIRTUAL TABLE t2 USING fts5(a, b, c, rank, detail=%DETAIL%); } {1 {reserved fts5 column name: rank}} do_catchsql_test 11.2 { - CREATE VIRTUAL TABLE rank USING fts5(a, b, c); + CREATE VIRTUAL TABLE rank USING fts5(a, b, c, detail=%DETAIL%); } {1 {reserved fts5 table name: rank}} do_catchsql_test 11.3 { - CREATE VIRTUAL TABLE t2 USING fts5(a, b, c, rowid); + CREATE VIRTUAL TABLE t2 USING fts5(a, b, c, rowid, detail=%DETAIL%); } {1 {reserved fts5 column name: rowid}} #------------------------------------------------------------------------- # do_execsql_test 12.1 { - CREATE VIRTUAL TABLE t2 USING fts5(x,y); + CREATE VIRTUAL TABLE t2 USING fts5(x,y, detail=%DETAIL%); } {} do_catchsql_test 12.2 { @@ -337,7 +340,7 @@ do_test 12.3 { # reset_db do_execsql_test 13.1 { - CREATE VIRTUAL TABLE t1 USING fts5(x); + CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%); INSERT INTO t1(rowid, x) VALUES(1, 'o n e'), (2, 't w o'); } {} @@ -361,7 +364,7 @@ do_execsql_test 13.6 { # reset_db do_execsql_test 14.1 { - CREATE VIRTUAL TABLE t1 USING fts5(x, y); + CREATE VIRTUAL TABLE t1 USING fts5(x, y, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); WITH d(x,y) AS ( SELECT NULL, 'xyz xyz xyz xyz xyz xyz' @@ -371,6 +374,10 @@ do_execsql_test 14.1 { INSERT INTO t1 SELECT * FROM d LIMIT 200; } +do_execsql_test 15.x { + INSERT INTO t1(t1) VALUES('integrity-check'); +} + do_test 14.2 { set nRow 0 db eval { SELECT * FROM t1 WHERE t1 MATCH 'xyz' } { @@ -433,7 +440,7 @@ do_catchsql_test 16.2 { # reset_db do_execsql_test 17.1 { - CREATE VIRTUAL TABLE b2 USING fts5(x); + CREATE VIRTUAL TABLE b2 USING fts5(x, detail=%DETAIL%); INSERT INTO b2 VALUES('a'); INSERT INTO b2 VALUES('b'); INSERT INTO b2 VALUES('c'); @@ -447,18 +454,20 @@ do_test 17.2 { set res } {{a b c} {a b c} {a b c}} -reset_db -do_execsql_test 18.1 { - CREATE VIRTUAL TABLE c2 USING fts5(x, y); - INSERT INTO c2 VALUES('x x x', 'x x x'); - SELECT rowid FROM c2 WHERE c2 MATCH 'y:x'; -} {1} +if {[string match n* %DETAIL%]==0} { + reset_db + do_execsql_test 17.3 { + CREATE VIRTUAL TABLE c2 USING fts5(x, y, detail=%DETAIL%); + INSERT INTO c2 VALUES('x x x', 'x x x'); + SELECT rowid FROM c2 WHERE c2 MATCH 'y:x'; + } {1} +} #------------------------------------------------------------------------- # reset_db do_execsql_test 17.1 { - CREATE VIRTUAL TABLE uio USING fts5(ttt); + CREATE VIRTUAL TABLE uio USING fts5(ttt, detail=%DETAIL%); INSERT INTO uio VALUES(NULL); INSERT INTO uio SELECT NULL FROM uio; INSERT INTO uio SELECT NULL FROM uio; @@ -505,8 +514,8 @@ do_execsql_test 17.9 { #-------------------------------------------------------------------- # do_execsql_test 18.1 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b); - CREATE VIRTUAL TABLE t2 USING fts5(c, d); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); + CREATE VIRTUAL TABLE t2 USING fts5(c, d, detail=%DETAIL%); INSERT INTO t1 VALUES('abc*', NULL); INSERT INTO t2 VALUES(1, 'abcdefg'); } @@ -522,7 +531,7 @@ do_execsql_test 18.3 { # reset_db do_execsql_test 19.0 { - CREATE VIRTUAL TABLE temp.t1 USING fts5(x); + CREATE VIRTUAL TABLE temp.t1 USING fts5(x, detail=%DETAIL%); INSERT INTO t1 VALUES('x y z'); INSERT INTO t1 VALUES('w x 1'); SELECT rowid FROM t1 WHERE t1 MATCH 'x'; @@ -533,7 +542,7 @@ do_execsql_test 19.0 { # reset_db do_execsql_test 20.0 { - CREATE VIRTUAL TABLE temp.tmp USING fts5(x); + CREATE VIRTUAL TABLE temp.tmp USING fts5(x, detail=%DETAIL%); } set ::ids [list \ 0 [expr 1<<36] [expr 2<<36] [expr 1<<43] [expr 2<<43] @@ -545,6 +554,7 @@ do_test 20.1 { execsql { SELECT rowid FROM tmp WHERE tmp MATCH 'y' } } $::ids +} finish_test diff --git a/ext/fts5/test/fts5ab.test b/ext/fts5/test/fts5ab.test index 0746e64326..95da2cd2eb 100644 --- a/ext/fts5/test/fts5ab.test +++ b/ext/fts5/test/fts5ab.test @@ -22,8 +22,10 @@ ifcapable !fts5 { return } +foreach_detail_mode $testprefix { + do_execsql_test 1.0 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); INSERT INTO t1 VALUES('hello', 'world'); INSERT INTO t1 VALUES('one two', 'three four'); INSERT INTO t1(rowid, a, b) VALUES(45, 'forty', 'five'); @@ -57,7 +59,7 @@ do_execsql_test 1.6 { reset_db do_execsql_test 2.1 { - CREATE VIRTUAL TABLE t1 USING fts5(x); + CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); INSERT INTO t1 VALUES('one'); INSERT INTO t1 VALUES('two'); @@ -159,7 +161,7 @@ foreach {tn expr res} { # do_execsql_test 4.0 { - CREATE VIRTUAL TABLE s1 USING fts5(x); + CREATE VIRTUAL TABLE s1 USING fts5(x, detail=%DETAIL%); } foreach {tn doc} [list \ 1 [string repeat {a x } 1500000] \ @@ -172,8 +174,14 @@ do_execsql_test 4.3 { SELECT rowid FROM s1 WHERE s1 MATCH 'x' } {1 2} -do_execsql_test 4.4 { - SELECT rowid FROM s1 WHERE s1 MATCH '"a x"' +if {[detail_is_full]} { + do_execsql_test 4.4 { + SELECT rowid FROM s1 WHERE s1 MATCH '"a x"' + } {1 2} +} + +do_execsql_test 4.5 { + SELECT rowid FROM s1 WHERE s1 MATCH 'a x' } {1 2} #------------------------------------------------------------------------- @@ -182,7 +190,7 @@ do_execsql_test 4.4 { # (L-2) is larger than it. # do_execsql_test 5.0 { - CREATE VIRTUAL TABLE s2 USING fts5(x); + CREATE VIRTUAL TABLE s2 USING fts5(x, detail=%DETAIL%); INSERT INTO s2(s2, rank) VALUES('pgsz', 32); INSERT INTO s2(s2, rank) VALUES('automerge', 0); } @@ -222,7 +230,7 @@ do_test 5.2 { do_test 5.3 { execsql { DROP TABLE s2; - CREATE VIRTUAL TABLE s2 USING fts5(x); + CREATE VIRTUAL TABLE s2 USING fts5(x, detail=%DETAIL%); INSERT INTO s2(s2, rank) VALUES('pgsz', 32); INSERT INTO s2(s2, rank) VALUES('automerge', 0); } @@ -241,7 +249,7 @@ do_test 5.4 { #------------------------------------------------------------------------- # do_execsql_test 6.0 { - CREATE VIRTUAL TABLE s3 USING fts5(x); + CREATE VIRTUAL TABLE s3 USING fts5(x, detail=%DETAIL%); BEGIN; INSERT INTO s3 VALUES('a b c'); INSERT INTO s3 VALUES('A B C'); @@ -276,13 +284,13 @@ do_test 6.4 { #------------------------------------------------------------------------- # set doc [string repeat "a b c " 500] -breakpoint do_execsql_test 7.0 { - CREATE VIRTUAL TABLE x1 USING fts5(x); + CREATE VIRTUAL TABLE x1 USING fts5(x, detail=%DETAIL%); INSERT INTO x1(x1, rank) VALUES('pgsz', 32); INSERT INTO x1 VALUES($doc); } +} ;# foreach_detail_mode... finish_test diff --git a/ext/fts5/test/fts5ac.test b/ext/fts5/test/fts5ac.test index ff2affcce1..c3163147cb 100644 --- a/ext/fts5/test/fts5ac.test +++ b/ext/fts5/test/fts5ac.test @@ -22,6 +22,8 @@ ifcapable !fts5 { return } +foreach_detail_mode $testprefix { + set data { 0 {p o q e z k z p n f y u z y n y} {l o o l v v k} 1 {p k h h p y l l h i p v n} {p p l u r i f a j g e r r x w} @@ -205,8 +207,6 @@ proc collist_data {expr} { # End of test code #------------------------------------------------------------------------- -if 0 { - foreach {tn2 sql} { 1 {} 2 {BEGIN} @@ -215,7 +215,7 @@ foreach {tn2 sql} { fts5_aux_test_functions db do_execsql_test 1.$tn2.0 { - CREATE VIRTUAL TABLE xx USING fts5(x,y); + CREATE VIRTUAL TABLE xx USING fts5(x,y, detail=%DETAIL%); INSERT INTO xx(xx, rank) VALUES('pgsz', 32); } @@ -228,31 +228,55 @@ foreach {tn2 sql} { execsql { INSERT INTO xx(xx) VALUES('integrity-check') } } {} - #------------------------------------------------------------------------- - # Test phrase queries. + # The following work with all detail= modes. # - foreach {tn phrase} { - 1 "o" - 2 "b q" - 3 "e a e" - 4 "m d g q q b k b w f q q p p" - 5 "l o o l v v k" - 6 "a" - 7 "b" - 8 "c" - 9 "no" - 10 "L O O L V V K" + foreach {tn expr} { + 1 "a AND b" + 2 "a OR b" + 3 "o" + 4 "b q" + 5 "e a e" + 6 "m d g q q b k b w f q q p p" + 7 "l o o l v v k" + 8 "a" + 9 "b" + 10 "c" + 11 "no" + 12 "L O O L V V K" + 13 "a AND b AND c" } { - set expr "\"$phrase\"" set res [poslist_data 1 $expr] - - do_execsql_test 1.$tn2.1.2.$tn.p.[llength $res] { + do_execsql_test 1.$tn2.1.$tn.p.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res set res [collist_data $expr] - do_execsql_test 1.$tn2.1.2.$tn.c.[llength $res] { + do_execsql_test 1.$tn2.1.$tn.c.[llength $res] { + SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr + } $res + } + + if {[detail_is_none] || [detail_is_col]} continue + + #------------------------------------------------------------------------- + # Test phrase queries. + # + foreach {tn expr} { + 1 "b + q" + 2 "e + a + e" + 3 "m + d + g + q + q + b + k + b + w + f + q + q + p + p" + 4 "l + o + o + l + v + v + k" + 5 "L + O + O + L + V + V + K" + } { + set res [poslist_data 1 $expr] + + do_execsql_test 1.$tn2.2.$tn.p.[llength $res] { + SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr + } $res + + set res [collist_data $expr] + do_execsql_test 1.$tn2.2.$tn.c.[llength $res] { SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr } $res } @@ -261,25 +285,21 @@ foreach {tn2 sql} { # Test some AND and OR queries. # foreach {tn expr} { - 1.1 "a AND b" - 1.2 "a+b AND c" - 1.3 "d+c AND u" - 1.4 "d+c AND u+d" + 1.1 "a+b AND c" + 1.2 "d+c AND u" + 1.3 "d+c AND u+d" - 2.1 "a OR b" - 2.2 "a+b OR c" - 2.3 "d+c OR u" - 2.4 "d+c OR u+d" - - 3.1 { a AND b AND c } + 2.1 "a+b OR c" + 2.2 "d+c OR u" + 2.3 "d+c OR u+d" } { set res [poslist_data 1 $expr] - do_execsql_test 1.$tn2.2.$tn.c.[llength $res] { + do_execsql_test 1.$tn2.3.$tn.c.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res set res [collist_data $expr] - do_execsql_test 1.$tn2.2.$tn.c.[llength $res] { + do_execsql_test 1.$tn2.3.$tn.c.[llength $res] { SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr } $res } @@ -308,12 +328,12 @@ foreach {tn2 sql} { 4.4 {{"y" y}:b} } { set res [poslist_data 1 $expr] - do_execsql_test 1.$tn2.3.$tn.p.[llength $res] { + do_execsql_test 1.$tn2.4.$tn.p.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res set res [collist_data $expr] - do_execsql_test 1.$tn2.3.$tn.c.[llength $res] { + do_execsql_test 1.$tn2.4.$tn.c.[llength $res] { SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr } $res } @@ -334,12 +354,12 @@ foreach {tn2 sql} { 9 { y : NEAR(r c) } } { set res [poslist_data 1 $expr] - do_execsql_test 1.$tn2.4.1.$tn.p.[llength $res] { + do_execsql_test 1.$tn2.5.1.$tn.p.[llength $res] { SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr } $res set res [collist_data $expr] - do_execsql_test 1.$tn2.4.1.$tn.c.[llength $res] { + do_execsql_test 1.$tn2.5.1.$tn.c.[llength $res] { SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr } $res } @@ -350,14 +370,14 @@ foreach {tn2 sql} { foreach {tn expr tclexpr} { 1 {a b} {AND [N $x -- {a}] [N $x -- {b}]} } { - do_execsql_test 1.$tn2.5.$tn { + do_execsql_test 1.$tn2.6.$tn { SELECT fts5_expr_tcl($expr, 'N $x') } [list $tclexpr] } #------------------------------------------------------------------------- # - do_execsql_test 1.$tn2.6.integrity { + do_execsql_test 1.$tn2.7.integrity { INSERT INTO xx(xx) VALUES('integrity-check'); } #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM xx_data} {puts $r} @@ -389,68 +409,18 @@ foreach {tn2 sql} { 19 { c NOT b OR a AND d } } { set res [poslist_data 0 $expr $bAsc] - do_execsql_test 1.$tn2.6.$bAsc.$tn.[llength $res] $sql $res + do_execsql_test 1.$tn2.7.$bAsc.$tn.[llength $res] $sql $res } } } +} + do_execsql_test 2.1 { SELECT fts5_expr_tcl('a AND b'); } {{AND [nearset -- {a}] [nearset -- {b}]}} -} -#set data [lrange $data 0 5] - -# Some tests for detail=col tables and detail=none. -# -foreach {tn2 sql} { - 1 { - CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=col); - } - 2 { - CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=col); - BEGIN; - } - 3 { - CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=none); - BEGIN; - } - 4 { - CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=none); - } -} { - reset_db - fts5_aux_test_functions db - - execsql $sql - - do_execsql_test 3.$tn2.0 { - INSERT INTO xx(xx, rank) VALUES('pgsz', 32); - } - - do_test 3.$tn2.1.1 { - foreach {id x y} $data { - execsql { INSERT INTO xx(rowid, x, y) VALUES($id, $x, $y) } - } - execsql { INSERT INTO xx(xx) VALUES('integrity-check') } - } {} - - foreach {tn q} { - 1 "o" 2 "b" 3 "e" 4 "m" 5 "l" 6 "a" 7 "b" 8 "c" 9 "no" 10 "L" - 11 "o a" 12 "c AND d" 13 "o OR a" 14 "c OR d" - } { - set res [poslist_data 1 $q] - do_execsql_test 3.$tn2.1.2.$tn.p.[llength $res] { - SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $q - } $res - - set res [collist_data $q] - do_execsql_test 3.$tn2.1.2.$tn.c.[llength $res] { - SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $q - } $res - } - -} +finish_test finish_test diff --git a/ext/fts5/test/fts5ad.test b/ext/fts5/test/fts5ad.test index cc86a6b2eb..b875354534 100644 --- a/ext/fts5/test/fts5ad.test +++ b/ext/fts5/test/fts5ad.test @@ -22,8 +22,12 @@ ifcapable !fts5 { return } +foreach_detail_mode $testprefix { + +if {[detail_is_none]==0} continue + do_execsql_test 1.0 { - CREATE VIRTUAL TABLE yy USING fts5(x, y); + CREATE VIRTUAL TABLE yy USING fts5(x, y, detail=%DETAIL%); INSERT INTO yy VALUES('Changes the result to be', 'the list of all matching'); INSERT INTO yy VALUES('indices (or all matching', 'values if -inline is'); INSERT INTO yy VALUES('specified as well.) If', 'indices are returned, the'); @@ -53,39 +57,23 @@ foreach {tn match res} { foreach {T create} { 2 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); } 3 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix=1,2,3,4,5); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix="1,2,3,4", detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); } 4 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); BEGIN; } 5 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix=1,2,3,4,5); - INSERT INTO t1(t1, rank) VALUES('pgsz', 32); - BEGIN; - } - - 6 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=col); - INSERT INTO t1(t1, rank) VALUES('pgsz', 32); - } - - 7 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=col, prefix="1,2,3,4,5"); - INSERT INTO t1(t1, rank) VALUES('pgsz', 32); - } - - 8 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=col, prefix="1,2,3,4,5"); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix="1,2,3,4", detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); BEGIN; } @@ -251,5 +239,7 @@ foreach {T create} { catchsql COMMIT } +} + finish_test diff --git a/ext/fts5/test/fts5ae.test b/ext/fts5/test/fts5ae.test index ded73d472f..5153306d19 100644 --- a/ext/fts5/test/fts5ae.test +++ b/ext/fts5/test/fts5ae.test @@ -22,8 +22,10 @@ ifcapable !fts5 { return } +foreach_detail_mode $testprefix { + do_execsql_test 1.0 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); } @@ -55,7 +57,7 @@ fts5_aux_test_functions db #------------------------------------------------------------------------- # do_execsql_test 2.0 { - CREATE VIRTUAL TABLE t2 USING fts5(x, y); + CREATE VIRTUAL TABLE t2 USING fts5(x, y, detail=%DETAIL%); INSERT INTO t2 VALUES('u t l w w m s', 'm f m o l t k o p e'); INSERT INTO t2 VALUES('f g q e l n d m z x q', 'z s i i i m f w w f n g p'); } @@ -76,31 +78,35 @@ do_execsql_test 2.2 { 2 {1.0.2 1.0.10} } -do_execsql_test 2.3 { - SELECT rowid, fts5_test_poslist(t2) FROM t2 - WHERE t2 MATCH 'y:o' ORDER BY rowid; -} { - 1 {0.1.3 0.1.7} +if {[detail_is_full]} { + do_execsql_test 2.3 { + SELECT rowid, fts5_test_poslist(t2) FROM t2 + WHERE t2 MATCH 'y:o' ORDER BY rowid; + } { + 1 {0.1.3 0.1.7} + } } #------------------------------------------------------------------------- # do_execsql_test 3.0 { - CREATE VIRTUAL TABLE t3 USING fts5(x, y); + CREATE VIRTUAL TABLE t3 USING fts5(x, y, detail=%DETAIL%); INSERT INTO t3 VALUES( 'j f h o x x a z g b a f a m i b', 'j z c z y x w t'); INSERT INTO t3 VALUES( 'r c', ''); } -do_execsql_test 3.1 { - SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'NEAR(a b)'; -} { - 1 {0.0.6 1.0.9 0.0.10 0.0.12 1.0.15} -} +if {[detail_is_full]} { + do_execsql_test 3.1 { + SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'NEAR(a b)'; + } { + 1 {0.0.6 1.0.9 0.0.10 0.0.12 1.0.15} + } -do_execsql_test 3.2 { - SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'NEAR(r c)'; -} { - 2 {0.0.0 1.0.1} + do_execsql_test 3.2 { + SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'NEAR(r c)'; + } { + 2 {0.0.0 1.0.1} + } } do_execsql_test 3.3 { @@ -116,7 +122,7 @@ do_execsql_test 3.3 { #------------------------------------------------------------------------- # do_execsql_test 4.0 { - CREATE VIRTUAL TABLE t4 USING fts5(x, y); + CREATE VIRTUAL TABLE t4 USING fts5(x, y, detail=%DETAIL%); INSERT INTO t4 VALUES('k x j r m a d o i z j', 'r t t t f e b r x i v j v g o'); } @@ -134,7 +140,7 @@ reset_db fts5_aux_test_functions db do_execsql_test 5.1 { - CREATE VIRTUAL TABLE t5 USING fts5(x, y); + CREATE VIRTUAL TABLE t5 USING fts5(x, y, detail=%DETAIL%); INSERT INTO t5 VALUES('a b c d', 'e f g h i j'); INSERT INTO t5 VALUES('', 'a'); INSERT INTO t5 VALUES('a', ''); @@ -182,7 +188,7 @@ do_execsql_test 5.5 { reset_db fts5_aux_test_functions db do_execsql_test 6.1 { - CREATE VIRTUAL TABLE t6 USING fts5(x, y); + CREATE VIRTUAL TABLE t6 USING fts5(x, y, detail=%DETAIL%); INSERT INTO t6 VALUES('There are more', 'things in heaven and earth'); INSERT INTO t6 VALUES(', Horatio, Than are', 'dreamt of in your philosophy.'); } @@ -200,7 +206,7 @@ do_execsql_test 6.2 { reset_db fts5_aux_test_functions db do_execsql_test 7.1 { - CREATE VIRTUAL TABLE t7 USING fts5(x, y); + CREATE VIRTUAL TABLE t7 USING fts5(x, y, detail=%DETAIL%); } do_test 7.2 { foreach {x y} { @@ -240,7 +246,7 @@ do_execsql_test 7.4 { #------------------------------------------------------------------------- # do_test 8.1 { - execsql { CREATE VIRTUAL TABLE t8 USING fts5(x, y) } + execsql { CREATE VIRTUAL TABLE t8 USING fts5(x, y, detail=%DETAIL%) } foreach {rowid x y} { 0 {A o} {o o o C o o o o o o o o} 1 {o o B} {o o o C C o o o o o o o} @@ -300,5 +306,7 @@ foreach {tn q cnt} { } $cnt } +} + finish_test diff --git a/ext/fts5/test/fts5af.test b/ext/fts5/test/fts5af.test index 8c50f84866..d6b2241568 100644 --- a/ext/fts5/test/fts5af.test +++ b/ext/fts5/test/fts5af.test @@ -24,9 +24,10 @@ ifcapable !fts5 { return } +foreach_detail_mode $testprefix { do_execsql_test 1.0 { - CREATE VIRTUAL TABLE t1 USING fts5(x, y); + CREATE VIRTUAL TABLE t1 USING fts5(x, y, detail=%DETAIL%); } proc do_snippet_test {tn doc match res} { @@ -111,34 +112,37 @@ foreach {tn doc res} { do_snippet_test 1.$tn $doc X $res } -foreach {tn doc res} { - 1.1 {X Y o o o o o} {[X Y] o o o o o} - 1.2 {o X Y o o o o} {o [X Y] o o o o} - 1.3 {o o X Y o o o} {o o [X Y] o o o} - 1.4 {o o o X Y o o} {o o o [X Y] o o} - 1.5 {o o o o X Y o} {o o o o [X Y] o} - 1.6 {o o o o o X Y} {o o o o o [X Y]} +if {[detail_is_full]} { + foreach {tn doc res} { + 1.1 {X Y o o o o o} {[X Y] o o o o o} + 1.2 {o X Y o o o o} {o [X Y] o o o o} + 1.3 {o o X Y o o o} {o o [X Y] o o o} + 1.4 {o o o X Y o o} {o o o [X Y] o o} + 1.5 {o o o o X Y o} {o o o o [X Y] o} + 1.6 {o o o o o X Y} {o o o o o [X Y]} - 2.1 {X Y o o o o o o} {[X Y] o o o o o...} - 2.2 {o X Y o o o o o} {o [X Y] o o o o...} - 2.3 {o o X Y o o o o} {o o [X Y] o o o...} - 2.4 {o o o X Y o o o} {...o o [X Y] o o o} - 2.5 {o o o o X Y o o} {...o o o [X Y] o o} - 2.6 {o o o o o X Y o} {...o o o o [X Y] o} - 2.7 {o o o o o o X Y} {...o o o o o [X Y]} + 2.1 {X Y o o o o o o} {[X Y] o o o o o...} + 2.2 {o X Y o o o o o} {o [X Y] o o o o...} + 2.3 {o o X Y o o o o} {o o [X Y] o o o...} + 2.4 {o o o X Y o o o} {...o o [X Y] o o o} + 2.5 {o o o o X Y o o} {...o o o [X Y] o o} + 2.6 {o o o o o X Y o} {...o o o o [X Y] o} + 2.7 {o o o o o o X Y} {...o o o o o [X Y]} - 3.1 {X Y o o o o o o o} {[X Y] o o o o o...} - 3.2 {o X Y o o o o o o} {o [X Y] o o o o...} - 3.3 {o o X Y o o o o o} {o o [X Y] o o o...} - 3.4 {o o o X Y o o o o} {...o o [X Y] o o o...} - 3.5 {o o o o X Y o o o} {...o o [X Y] o o o} - 3.6 {o o o o o X Y o o} {...o o o [X Y] o o} - 3.7 {o o o o o o X Y o} {...o o o o [X Y] o} - 3.8 {o o o o o o o X Y} {...o o o o o [X Y]} - -} { - do_snippet_test 2.$tn $doc "X + Y" $res + 3.1 {X Y o o o o o o o} {[X Y] o o o o o...} + 3.2 {o X Y o o o o o o} {o [X Y] o o o o...} + 3.3 {o o X Y o o o o o} {o o [X Y] o o o...} + 3.4 {o o o X Y o o o o} {...o o [X Y] o o o...} + 3.5 {o o o o X Y o o o} {...o o [X Y] o o o} + 3.6 {o o o o o X Y o o} {...o o o [X Y] o o} + 3.7 {o o o o o o X Y o} {...o o o o [X Y] o} + 3.8 {o o o o o o o X Y} {...o o o o o [X Y]} + } { + do_snippet_test 2.$tn $doc "X + Y" $res + } } +} ;# foreach_detail_mode + finish_test diff --git a/ext/fts5/test/fts5detail.test b/ext/fts5/test/fts5detail.test index 59f4b0e3c3..5bdd14424e 100644 --- a/ext/fts5/test/fts5detail.test +++ b/ext/fts5/test/fts5detail.test @@ -169,8 +169,8 @@ proc matchdata {expr {bAsc 1}} { foreach {tn tbl} { 1 { CREATE VIRTUAL TABLE t3 USING fts5(x, y, z, detail=col) } + 2 { CREATE VIRTUAL TABLE t3 USING fts5(x, y, z, detail=none) } } { -#break reset_db fts5_aux_test_functions db execsql $tbl @@ -198,7 +198,6 @@ foreach {tn tbl} { #------------------------------------------------------------------------- # Simple tests for detail=none tables. # -breakpoint do_execsql_test 4.0 { CREATE VIRTUAL TABLE t4 USING fts5(a, b, c, detail=none); INSERT INTO t4 VALUES('a b c', 'b c d', 'e f g'); @@ -209,5 +208,33 @@ do_catchsql_test 4.1 { SELECT * FROM t4('a:a') } {1 {fts5: column queries are not supported (detail=none)}} +#------------------------------------------------------------------------- +# Test that for the same content detail=none uses less space than +# detail=col, and that detail=col uses less space than detail=full +# +reset_db +do_test 5.1 { + foreach {tbl detail} {t1 none t2 col t3 full} { + execsql "CREATE VIRTUAL TABLE $tbl USING fts5(x, y, z, detail=$detail)" + foreach {rowid x y z} $::data { + execsql "INSERT INTO $tbl (rowid, x, y, z) VALUES(\$rowid, \$x, \$y, \$z)" + } + } +} {} + +do_execsql_test 5.2 { + SELECT + (SELECT sum(length(block)) from t1_data) < + (SELECT sum(length(block)) from t2_data) +} {1} + +do_execsql_test 5.3 { + SELECT + (SELECT sum(length(block)) from t2_data) < + (SELECT sum(length(block)) from t3_data) +} {1} + + + finish_test diff --git a/ext/fts5/test/fts5simple2.test b/ext/fts5/test/fts5simple2.test index f99ea6112e..bb76250e9f 100644 --- a/ext/fts5/test/fts5simple2.test +++ b/ext/fts5/test/fts5simple2.test @@ -19,6 +19,8 @@ ifcapable !fts5 { return } +if 1 { + do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none); INSERT INTO t1 VALUES('a b c'); @@ -163,5 +165,109 @@ do_execsql_test 9.2.1 { INSERT INTO t1(t1) VALUES('integrity-check'); } {} +#-------------------------------------------------------------------------- +# +reset_db +do_execsql_test 10.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none); + INSERT INTO t1 VALUES('b1'); + INSERT INTO t1 VALUES('b1'); + DELETE FROM t1 WHERE rowid=1; +} + +do_execsql_test 10.1 { + SELECT rowid FROM t1('b1'); +} {2} + +do_execsql_test 10.2 { + SELECT rowid FROM t1('b1') ORDER BY rowid DESC; +} {2} + +do_execsql_test 10.3 { + INSERT INTO t1(t1) VALUES('integrity-check'); +} {} + +#-------------------------------------------------------------------------- +# +reset_db +do_execsql_test 11.1 { + CREATE VIRTUAL TABLE t1 USING fts5(x, y, detail=none); + INSERT INTO t1(t1, rank) VALUES('pgsz', 32); + WITH d(x,y) AS ( + SELECT NULL, 'xyz' UNION ALL SELECT NULL, 'xyz' FROM d + ) + INSERT INTO t1 SELECT * FROM d LIMIT 23; +} + +#db eval { SELECT rowid AS r, quote(block) AS b FROM t1_data } { puts "$r: $b" } +do_execsql_test 11.2 { + SELECT rowid FROM t1; +} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23} + +do_execsql_test 11.3 { + SELECT rowid FROM t1('xyz'); +} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23} + +do_execsql_test 11.4 { + INSERT INTO t1(t1) VALUES('integrity-check'); +} + +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 12.0 { + CREATE VIRTUAL TABLE yy USING fts5(x, detail=none); + INSERT INTO yy VALUES('in if'); + INSERT INTO yy VALUES('if'); +} {} + +do_execsql_test 12.1 { + SELECT rowid FROM yy('i*'); +} {1 2} + +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 13.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, prefix=1, detail=none); +} {} +foreach {rowid a} { + 0 {f} + 1 {u} + 2 {k} + 3 {a} + 4 {a} + 5 {u} + 6 {u} + 7 {u} + 8 {f} + 9 {f} + 10 {a} + 11 {p} + 12 {f} + 13 {u} + 14 {a} + 15 {a} +} { + do_execsql_test 13.1.$rowid { + INSERT INTO t1(rowid, a) VALUES($rowid, $a); + } +} + +} + +#------------------------------------------------------------------------- +# +reset_db +fts5_aux_test_functions db +do_execsql_test 14.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none); + INSERT INTO t1 VALUES('a b c d'); +} {} + +do_execsql_test 14.1 { + SELECT fts5_test_poslist(t1) FROM t1('b') ORDER BY rank; +} {0.0.1} + finish_test diff --git a/manifest b/manifest index c173c4014d..ce2b5eb30f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sfts5\sintegrity-check\scode\sso\sthat\sit\sworks\swith\sdetail=none\stables. -D 2015-12-31T18:39:14.423 +C Changes\sto\srun\smany\sfts5\stests\swith\sdetail=none\sand\sdetail=col\stables\sas\swell\sas\sthe\sdefault\sdetail=full.\sAlso\sfixes\sfor\sthe\sbugs\suncovered\sby\srunning\ssaid\stests. +D 2016-01-02T19:01:56.026 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -97,14 +97,14 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 88fec577a2148f34df75930dc2b0c45b0bad72c3 -F ext/fts5/fts5Int.h ab5f6f1f65652310a644d97d12aeabf8ab5ed17e +F ext/fts5/fts5Int.h cff7dd3131ba0db6f699df97237bf993f22c1a1f F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 -F ext/fts5/fts5_expr.c 08ee4f342a2b1fd82a5dccd0b9b3cde4921a8be5 +F ext/fts5/fts5_expr.c 898e0bb53280b2c4c2702a2dc08dec731c7b32fe F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 -F ext/fts5/fts5_index.c a7cfe8e88621b473d749268f918b54b81a067c2e -F ext/fts5/fts5_main.c 23f3912ff44172859c771eb55cb57778fd662e89 +F ext/fts5/fts5_index.c 8665393f8be3ae9ed4f1033d7ce0b805108fb95c +F ext/fts5/fts5_main.c f33439bde2e1023888e9b7f16e463e42fe4c00c5 F ext/fts5/fts5_storage.c 771dd0fda3ee513e32937a386dc2a4aa2d9ea64e F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb F ext/fts5/fts5_test_mi.c c9c8cf455c49ded156a234e0de1c8ba9be85e5c3 @@ -114,13 +114,13 @@ F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl f923471d572d1e283b7d6985ce3cda62dae6fd45 -F ext/fts5/test/fts5aa.test 2c553eea4dab4bc5a75928f56729277c7bc1d206 -F ext/fts5/test/fts5ab.test 6fe3a56731d15978afbb74ae51b355fc9310f2ad -F ext/fts5/test/fts5ac.test 1d2a10d4c13dcfd326287f51df3b7d90761c212c -F ext/fts5/test/fts5ad.test 0fd1a5bcb5dcc76a639bd26f27e2641034a508a3 -F ext/fts5/test/fts5ae.test 0a9984fc3479f89f8c63d9848d6ed0c465dfcebe -F ext/fts5/test/fts5af.test c2501ec2b61d6b179c305f5d2b8782ab3d4f832a +F ext/fts5/test/fts5_common.tcl fefb4ceb27d02b431f69045a7ac0061a80d97824 +F ext/fts5/test/fts5aa.test 4abbc14eb2d9d6d46a53ab008151512871d54ebc +F ext/fts5/test/fts5ab.test 30325a89453280160106be411bba3acf138e6d1b +F ext/fts5/test/fts5ac.test 9a3c5eb052a5e8c871d56d3d0f144e5fdcf075c2 +F ext/fts5/test/fts5ad.test 049f7511a79c155d2d8dfd2ddcfeb640c50ad0dc +F ext/fts5/test/fts5ae.test 612dcb51f4069226791ff14c17dbfb3138c56f20 +F ext/fts5/test/fts5af.test be858a96b1f5de66ba6d64f0021bd8b2408e126c F ext/fts5/test/fts5ag.test ec3e119b728196620a31507ef503c455a7a73505 F ext/fts5/test/fts5ah.test e592c4978622dbc4de552cd0f9395df60ac5d54c F ext/fts5/test/fts5ai.test f20e53bbf0c55bc596f1fd47f2740dae028b8f37 @@ -139,7 +139,7 @@ F ext/fts5/test/fts5content.test 9a952c95518a14182dc3b59e3c8fa71cda82a4e1 F ext/fts5/test/fts5corrupt.test c2ad090192708150d50d961278df10ae7a4b8b62 F ext/fts5/test/fts5corrupt2.test 26c0a39dd9ff73207e6229f83b50b21d37c7658c F ext/fts5/test/fts5corrupt3.test a2b537c120bdd43c79c42fe2438d7b8c81fe5599 -F ext/fts5/test/fts5detail.test 71babe633c68c6c5153b2fe1be81a97e953ca485 +F ext/fts5/test/fts5detail.test 4e971d28e7336c61ab916fc287900355dab7054d F ext/fts5/test/fts5dlidx.test ecba5e62ea8b26c33829961602069c546228046d F ext/fts5/test/fts5doclist.test 8edb5b57e5f144030ed74ec00ef6fa4294fed79b F ext/fts5/test/fts5ea.test b01e3a18cdfabbff8104a96a5242a06a68a998a0 @@ -170,7 +170,7 @@ F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 F ext/fts5/test/fts5simple.test a599b7577bc3827a9a678add3b43d8b818b93456 -F ext/fts5/test/fts5simple2.test a1a9f9c443f8852f412ee9658ef667086ccb74d7 +F ext/fts5/test/fts5simple2.test d453e3ca100e08078a46b12547417891b326240a F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 F ext/fts5/test/fts5unicode.test fbef8d8a3b4b88470536cc57604a82ca52e51841 @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6a6f7bc40d6b4c8a4a254a9098c9d2f31fde69ca -R 70fdbbf97fa363362bfe1572d2790ec2 +P 3a1df69e58e5830da1dff158eedbe3817743f58f +R 584d5f1c8b7a15ac2eae2ab1ffe71c4a U dan -Z 9907fb7300f9e53b05e209bde8721940 +Z cff9ad15204445a84003e93595871343 diff --git a/manifest.uuid b/manifest.uuid index 7093688530..4a0bbbdcd0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3a1df69e58e5830da1dff158eedbe3817743f58f \ No newline at end of file +6322a1d984e7946735bace8a069ef24b31754b3b \ No newline at end of file From 573d88e8ed091fd3ace6f6f87458d06dc45e9e6f Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 3 Jan 2016 11:17:04 +0000 Subject: [PATCH 126/232] Add the number of cores used and the name of the host computer to the summary at the end of releasetest.tcl. FossilOrigin-Name: cd3ae0f14c6b28b328b208431d0effcb7b062ec6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/releasetest.tcl | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 517a481aea..394319edbf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\s(harmless)\stypo\sin\san\s#ifdef\sfor\sSQLITE_ENABLE_CURSOR_HINTS -D 2016-01-02T05:00:31.568 +C Add\sthe\snumber\sof\scores\sused\sand\sthe\sname\sof\sthe\shost\scomputer\sto\sthe\nsummary\sat\sthe\send\sof\sreleasetest.tcl. +D 2016-01-03T11:17:04.115 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -947,7 +947,7 @@ F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl 622f2381b217facdf429584a5c292cc1fc47e7c0 +F test/releasetest.tcl f84ff16fef79ee5d328eee7c48da084a775d101c F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc -R 5906d6b78129d8858a23ea4c57fad965 +P 2047d2deabf2021ea05d620c3dd4919448027b11 +R ea21a9ede315d15a7b1dfcf0bcd428e9 U drh -Z 4843af3fcc8c5413e769bb1983160a44 +Z a5cb2210a915d9603f738ab23bc99890 diff --git a/manifest.uuid b/manifest.uuid index 2fbf3ac886..72d55b1f12 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2047d2deabf2021ea05d620c3dd4919448027b11 \ No newline at end of file +cd3ae0f14c6b28b328b208431d0effcb7b062ec6 \ No newline at end of file diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 7f53fd1523..8cf7a76fb8 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -830,8 +830,8 @@ proc process_options {argv} { } default { - PUTSERR stderr "" - PUTSERR stderr [string trim $::USAGE_MESSAGE] + PUTSERR "" + PUTSERR [string trim $::USAGE_MESSAGE] exit -1 } } @@ -945,6 +945,8 @@ proc main {argv} { set min [expr {($elapsetime/60)%60}] set sec [expr {$elapsetime%60}] set etime [format (%02d:%02d:%02d) $hr $min $sec] + if {$::JOBS>1} {append etime " $::JOBS cores"} + if {[catch {exec hostname} HNAME]==0} {append etime " on $HNAME"} PUTS [string repeat * 79] incr ::NERRCASE $::NERR PUTS "$::NERRCASE failures out of $::NTESTCASE tests in $etime" From 41d0ba72aeb274578ea3f06437d363a0ae5377ce Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 3 Jan 2016 11:27:47 +0000 Subject: [PATCH 127/232] Fix a premature reference to utf8_printf in shell.c. FossilOrigin-Name: 76f5efa68728d899a63a74f2528dfd0c497aa5f0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 394319edbf..218d499932 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\snumber\sof\scores\sused\sand\sthe\sname\sof\sthe\shost\scomputer\sto\sthe\nsummary\sat\sthe\send\sof\sreleasetest.tcl. -D 2016-01-03T11:17:04.115 +C Fix\sa\spremature\sreference\sto\sutf8_printf\sin\sshell.c. +D 2016-01-03T11:27:47.410 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -334,7 +334,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f -F src/shell.c 8d152e833c3b79825978deb83175234749c5cdf3 +F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2047d2deabf2021ea05d620c3dd4919448027b11 -R ea21a9ede315d15a7b1dfcf0bcd428e9 +P cd3ae0f14c6b28b328b208431d0effcb7b062ec6 +R 17c9e71fcd959bf7c676bff4a8176b10 U drh -Z a5cb2210a915d9603f738ab23bc99890 +Z cf0da92d1077e771f4727b72b37c0046 diff --git a/manifest.uuid b/manifest.uuid index 72d55b1f12..1130aa9c0e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd3ae0f14c6b28b328b208431d0effcb7b062ec6 \ No newline at end of file +76f5efa68728d899a63a74f2528dfd0c497aa5f0 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index ecb591a32a..b7a7abcd33 100644 --- a/src/shell.c +++ b/src/shell.c @@ -382,7 +382,7 @@ static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){ va_start(ap, zFormat); z = sqlite3_vmprintf(zFormat, ap); va_end(ap); - utf8_printf(iotrace, "%s", z); + fprintf(iotrace, "%s", z); sqlite3_free(z); } #endif From dc0b1f1c29e949a6145ed0e548846ba42b64d729 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 3 Jan 2016 18:07:57 +0000 Subject: [PATCH 128/232] Bug fix: the conflict resolution behavior for the implied NOT NULL constraint on the PRIMARY KEY of a WITHOUT ROWID table should be ABORT. FossilOrigin-Name: e30062e9f6cae980150dda7df440b36dfdcb7bbe --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/build.c | 2 +- test/conflict2.test | 8 ++++---- test/without_rowid5.test | 6 +++++- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 218d499932..584914720e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spremature\sreference\sto\sutf8_printf\sin\sshell.c. -D 2016-01-03T11:27:47.410 +C Bug\sfix:\sthe\sconflict\sresolution\sbehavior\sfor\sthe\simplied\sNOT\sNULL\sconstraint\non\sthe\sPRIMARY\sKEY\sof\sa\sWITHOUT\sROWID\stable\sshould\sbe\sABORT. +D 2016-01-03T18:07:57.631 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -279,7 +279,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 4d3452b2a3daf875490ac4f0a278da7f85fabe12 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 -F src/build.c 1c9fb552148ee8f9234435a38833f8fca2081a71 +F src/build.c d8006e9030c61b9495d0b2f724edd3fcdae16930 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -524,7 +524,7 @@ F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1 F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/conflict.test 841bcf7cabbfca39c577eb8411ea8601843b46a8 -F test/conflict2.test 0d3af4fb534fa1bd020c79960bb56e4d52655f09 +F test/conflict2.test 0f0e810aef6739650d7f442164975e932cf18afc F test/conflict3.test dec0634c0f31dec9a4b01c63063e939f0cd21b6b F test/contrib01.test 2a1cbc0f2f48955d7d073f725765da6fbceda6b4 F test/corrupt.test 141c39ea650c1365e85a49e402fa05cb9617fb97 @@ -1340,7 +1340,7 @@ F test/without_rowid1.test 1a7b9bd51b899928d327052df9741d2fe8dbe701 F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99 F test/without_rowid3.test aad4f9d383e199349b6c7e508a778f7dff5dff79 F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a -F test/without_rowid5.test 61256715b686359df48ca1742db50cc7e3e7b862 +F test/without_rowid5.test 89b1c587bd92a0590e440da33e7666bf4891572a F test/without_rowid6.test 1f99644e6508447fb050f73697350c7ceca3392e F test/wordcount.c 2a0a6c0d0e8e8bbbac1f06d72a6791828c37c0cf F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P cd3ae0f14c6b28b328b208431d0effcb7b062ec6 -R 17c9e71fcd959bf7c676bff4a8176b10 +P 76f5efa68728d899a63a74f2528dfd0c497aa5f0 +R 478df71a9631f4b73fcefbae5de2f355 U drh -Z cf0da92d1077e771f4727b72b37c0046 +Z 2ce3cb02ff6782c368c437352328d0d1 diff --git a/manifest.uuid b/manifest.uuid index 1130aa9c0e..c0ad5b411d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76f5efa68728d899a63a74f2528dfd0c497aa5f0 \ No newline at end of file +e30062e9f6cae980150dda7df440b36dfdcb7bbe \ No newline at end of file diff --git a/src/build.c b/src/build.c index ffefead9db..63e3004657 100644 --- a/src/build.c +++ b/src/build.c @@ -1774,7 +1774,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ ** do not enforce this for imposter tables.) */ if( !db->init.imposterTable ){ for(i=0; iaCol[pPk->aiColumn[i]].notNull = 1; + pTab->aCol[pPk->aiColumn[i]].notNull = OE_Abort; } pPk->uniqNotNull = 1; } diff --git a/test/conflict2.test b/test/conflict2.test index 8419f1a3ff..e8880635f1 100644 --- a/test/conflict2.test +++ b/test/conflict2.test @@ -289,11 +289,11 @@ do_test conflict2-6.0 { # foreach {i conf1 cmd t0 t1 t2 t3 t4} { 1 {} UPDATE 1 {6 7 8 9} 1 0 1 - 2 REPLACE UPDATE 0 {7 6 9} 1 0 0 - 3 IGNORE UPDATE 0 {6 7 3 9} 1 0 0 - 4 FAIL UPDATE 1 {6 7 3 4} 1 0 0 + 2 REPLACE UPDATE 0 {7 6 9} 1 1 0 + 3 IGNORE UPDATE 0 {6 7 3 9} 1 1 0 + 4 FAIL UPDATE 1 {6 7 3 4} 1 1 0 5 ABORT UPDATE 1 {1 2 3 4} 1 0 1 - 6 ROLLBACK UPDATE 1 {1 2 3 4} 0 0 0 + 6 ROLLBACK UPDATE 1 {1 2 3 4} 0 1 0 7 REPLACE {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 8 IGNORE {UPDATE OR REPLACE} 0 {7 6 9} 1 0 1 9 FAIL {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 diff --git a/test/without_rowid5.test b/test/without_rowid5.test index d163d9c1bc..31a440ad87 100644 --- a/test/without_rowid5.test +++ b/test/without_rowid5.test @@ -132,9 +132,13 @@ do_execsql_test without_rowid5-5.1 { INSERT INTO ipk VALUES('rival','bonus'); -- ok to insert non-integer key SELECT * FROM ipk; } {rival bonus} -do_catchsql_test without_rowid5-5.2 { +do_catchsql_test without_rowid5-5.2a { + BEGIN; INSERT INTO ipk VALUES(NULL,'sample'); -- no automatic generation of keys } {1 {NOT NULL constraint failed: ipk.key}} +do_execsql_test without_rowid5-5.2b { + ROLLBACK; +} {} # EVIDENCE-OF: R-33142-02092 AUTOINCREMENT does not work on WITHOUT # ROWID tables. From 7f10579a82a158b71ca3fd05c241c5ebb9cb3fee Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 01:08:50 +0000 Subject: [PATCH 129/232] Add releasetest.tcl cases for SQLITE_LIKE_DOESNT_MATCH_BLOB and for SQLITE_ENABLE_CURSOR_HINTS. FossilOrigin-Name: f300c35efa5f7383b2a74b1c9466c243c17815e4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/cursorhint.test | 12 ++++++------ test/releasetest.tcl | 2 ++ 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 584914720e..00ec784d9b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bug\sfix:\sthe\sconflict\sresolution\sbehavior\sfor\sthe\simplied\sNOT\sNULL\sconstraint\non\sthe\sPRIMARY\sKEY\sof\sa\sWITHOUT\sROWID\stable\sshould\sbe\sABORT. -D 2016-01-03T18:07:57.631 +C Add\sreleasetest.tcl\scases\sfor\sSQLITE_LIKE_DOESNT_MATCH_BLOB\sand\nfor\sSQLITE_ENABLE_CURSOR_HINTS. +D 2016-01-04T01:08:50.342 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -562,7 +562,7 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 -F test/cursorhint.test 432811b62bd5ffb812729f49bba3b9ad687550bb +F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 F test/dbstatus2.test 10418e62b3db5dca070f0c3eef3ea13946f339c2 @@ -947,7 +947,7 @@ F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl f84ff16fef79ee5d328eee7c48da084a775d101c +F test/releasetest.tcl 975449bf742b8bb9025208292208af816a1fcb58 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 76f5efa68728d899a63a74f2528dfd0c497aa5f0 -R 478df71a9631f4b73fcefbae5de2f355 +P e30062e9f6cae980150dda7df440b36dfdcb7bbe +R 60c0d617eaaaa3eb60de4d61ace77f3f U drh -Z 2ce3cb02ff6782c368c437352328d0d1 +Z bf759b86247c24cfa4d33f391ba06db6 diff --git a/manifest.uuid b/manifest.uuid index c0ad5b411d..6624b9ab92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e30062e9f6cae980150dda7df440b36dfdcb7bbe \ No newline at end of file +f300c35efa5f7383b2a74b1c9466c243c17815e4 \ No newline at end of file diff --git a/test/cursorhint.test b/test/cursorhint.test index 69bc248cd7..ae86120fa8 100644 --- a/test/cursorhint.test +++ b/test/cursorhint.test @@ -46,10 +46,10 @@ proc p4_of_opcode {db opcode sql} { # Run EXPLAIN on $sql. Return a list of P5 values for all $opcode # opcodes that contain regexp $comment in their comment # -proc p5_of_opcode {db opcode comment sql} { +proc p5_of_opcode {db opcode sql} { set res {} $db eval "EXPLAIN $sql" x { - if {$x(opcode)==$opcode && [regexp $comment $x(comment)]} { + if {$x(opcode)==$opcode} { lappend res $x(p5) } } @@ -66,7 +66,7 @@ do_test 1.1 { } } {{EQ(r[1],c0)}} do_test 1.2 { - p5_of_opcode db OpenRead . { + p5_of_opcode db OpenRead { SELECT * FROM t1 CROSS JOIN t2 WHERE a=x } } {00 00} @@ -79,7 +79,7 @@ do_test 2.1 { } } {{EQ(c0,r[1])}} do_test 2.2 { - p5_of_opcode db OpenRead . { + p5_of_opcode db OpenRead { SELECT * FROM t2 CROSS JOIN t1 WHERE a=x } } {00 00} @@ -114,7 +114,7 @@ do_test 4.1desc { } } {GT(c0,11)} do_test 4.2 { - p5_of_opcode db OpenRead . { + p5_of_opcode db OpenRead { SELECT * FROM t1 WHERE b>11; } } {02 00} @@ -129,7 +129,7 @@ do_test 4.3desc { } } {} do_test 4.4 { - p5_of_opcode db OpenRead . { + p5_of_opcode db OpenRead { SELECT c FROM t1 WHERE b<11; } } {00} diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 8cf7a76fb8..bb902eec3e 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -86,6 +86,8 @@ array set ::Configs [strip_comments { -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 -DSQLITE_ENABLE_STMT_SCANSTATUS + -DSQLITE_LIKE_DOESNT_MATCH_BLOBS + -DSQLITE_ENABLE_CURSOR_HINTS --enable-json1 } "Check-Symbols" { From 9fbc885afcbf09b90322bab8f0daf613df2fa26b Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 03:48:46 +0000 Subject: [PATCH 130/232] Fix a harmless compiler warning. FossilOrigin-Name: 4b404a99aa9bfa6cfe8998f5dc1f84f8be20b840 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 00ec784d9b..39fe0a1326 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sreleasetest.tcl\scases\sfor\sSQLITE_LIKE_DOESNT_MATCH_BLOB\sand\nfor\sSQLITE_ENABLE_CURSOR_HINTS. -D 2016-01-04T01:08:50.342 +C Fix\sa\sharmless\scompiler\swarning. +D 2016-01-04T03:48:46.399 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -398,7 +398,7 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 638c20bae996d8037a114294016768b6bc8ebc14 +F src/vdbe.c 6ac8e5d808d48afc369316e147c191102f0584c1 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e30062e9f6cae980150dda7df440b36dfdcb7bbe -R 60c0d617eaaaa3eb60de4d61ace77f3f +P f300c35efa5f7383b2a74b1c9466c243c17815e4 +R a3643a709add89c526ff9d85846c177f U drh -Z bf759b86247c24cfa4d33f391ba06db6 +Z 723a886ae851aa4686263a1002cc64d8 diff --git a/manifest.uuid b/manifest.uuid index 6624b9ab92..44b7d4d4a2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f300c35efa5f7383b2a74b1c9466c243c17815e4 \ No newline at end of file +4b404a99aa9bfa6cfe8998f5dc1f84f8be20b840 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index c8fc6ff45b..5acb3b3137 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2524,7 +2524,7 @@ case OP_Column: { goto op_column_error; } }else{ - VVA_ONLY( t = 0; ) /* Only needed by assert() statements */ + t = 0; } /* If after trying to extract new entries from the header, nHdrParsed is From 6044bf8bf3c5cada8e985a6fefa3aededbc19dea Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 04:28:11 +0000 Subject: [PATCH 131/232] Limit the length of sqlite3_mprintf() output to 2^30 bytes, even if SQLITE_MAX_LENGTH is set larger at compile-time. FossilOrigin-Name: d655a665acfae676d30e90e3731f483bee6acc63 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/printf.c | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 39fe0a1326..6b8109daa6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning. -D 2016-01-04T03:48:46.399 +C Limit\sthe\slength\sof\ssqlite3_mprintf()\soutput\sto\s2^30\sbytes,\seven\sif\nSQLITE_MAX_LENGTH\sis\sset\slarger\sat\scompile-time. +D 2016-01-04T04:28:11.861 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -329,7 +329,7 @@ F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051 F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 -F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 +F src/printf.c 79265c0b36bca9b8582592a4f3fa73a1cc1cfa2f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f300c35efa5f7383b2a74b1c9466c243c17815e4 -R a3643a709add89c526ff9d85846c177f +P 4b404a99aa9bfa6cfe8998f5dc1f84f8be20b840 +R 3d16cb95a338f71bf305a9aee47b6af1 U drh -Z 723a886ae851aa4686263a1002cc64d8 +Z b5d1ace2d67c86c8eec357e62ba7f839 diff --git a/manifest.uuid b/manifest.uuid index 44b7d4d4a2..7a3a9597af 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4b404a99aa9bfa6cfe8998f5dc1f84f8be20b840 \ No newline at end of file +d655a665acfae676d30e90e3731f483bee6acc63 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 969950c154..fed9acd736 100644 --- a/src/printf.c +++ b/src/printf.c @@ -965,7 +965,12 @@ char *sqlite3_vmprintf(const char *zFormat, va_list ap){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif +#if SQLITE_MAX_LENGTH<0x40000000 sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH); +#else + sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), 0x3fffffff); +#endif + sqlite3VXPrintf(&acc, 0, zFormat, ap); z = sqlite3StrAccumFinish(&acc); return z; From 5a60c7d1428ab0540b888228dc86f566519cbe67 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 04:41:13 +0000 Subject: [PATCH 132/232] Adjust the vtabH.test module to ignore files in the root directory of Windows machines that contain the "$" character. FossilOrigin-Name: 73e3355004b8b7ce2e1bb937725f429795528a4f --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/vtabH.test | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 6b8109daa6..d08d409a94 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Limit\sthe\slength\sof\ssqlite3_mprintf()\soutput\sto\s2^30\sbytes,\seven\sif\nSQLITE_MAX_LENGTH\sis\sset\slarger\sat\scompile-time. -D 2016-01-04T04:28:11.861 +C Adjust\sthe\svtabH.test\smodule\sto\signore\sfiles\sin\sthe\sroot\sdirectory\sof\sWindows\nmachines\sthat\scontain\sthe\s"$"\scharacter. +D 2016-01-04T04:41:13.895 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -1274,7 +1274,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test f77296bbf55675b72817cc10fbbcb236ac986abf +F test/vtabH.test 0def52cbcf8d68793d982329a72d70cef8308e35 F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4b404a99aa9bfa6cfe8998f5dc1f84f8be20b840 -R 3d16cb95a338f71bf305a9aee47b6af1 +P d655a665acfae676d30e90e3731f483bee6acc63 +R 0d20e16c42f612598f302d493261df54 U drh -Z b5d1ace2d67c86c8eec357e62ba7f839 +Z 4891b25ab1f0ba8193051c36d1d029ea diff --git a/manifest.uuid b/manifest.uuid index 7a3a9597af..7e2cd0ba52 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d655a665acfae676d30e90e3731f483bee6acc63 \ No newline at end of file +73e3355004b8b7ce2e1bb937725f429795528a4f \ No newline at end of file diff --git a/test/vtabH.test b/test/vtabH.test index 7973819bd1..606c8f1da1 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -147,13 +147,13 @@ if {1} { set res [list] foreach p [lrange [list_root_files] 0 4] { if {$::tcl_platform(platform) eq "windows"} { - lappend res $p + if {![regexp {\$} $p]} {lappend res $p} } else { lappend res "/$p" } } do_execsql_test 3.1 { - SELECT path FROM fstree LIMIT 5; + SELECT path FROM fstree WHERE path NOT GLOB '*$*' LIMIT 5; } $res # Read all entries in the current directory. From cc54f43442076f01ccda13db4fc576cd468817f6 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 04:44:31 +0000 Subject: [PATCH 133/232] Improved comment on the vtabH-3.1 test. FossilOrigin-Name: 22abe08038cc7b66cbc25e733246d210197c9215 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/vtabH.test | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index d08d409a94..7763520f01 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sthe\svtabH.test\smodule\sto\signore\sfiles\sin\sthe\sroot\sdirectory\sof\sWindows\nmachines\sthat\scontain\sthe\s"$"\scharacter. -D 2016-01-04T04:41:13.895 +C Improved\scomment\son\sthe\svtabH-3.1\stest. +D 2016-01-04T04:44:31.090 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -1274,7 +1274,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test 0def52cbcf8d68793d982329a72d70cef8308e35 +F test/vtabH.test 7a21f18546cb9ab38df009e718300c40b552bb2b F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d655a665acfae676d30e90e3731f483bee6acc63 -R 0d20e16c42f612598f302d493261df54 +P 73e3355004b8b7ce2e1bb937725f429795528a4f +R add896a0a928f0a416eb15bec81a6801 U drh -Z 4891b25ab1f0ba8193051c36d1d029ea +Z 9b39ca76b9261d7edc0d476f6827134f diff --git a/manifest.uuid b/manifest.uuid index 7e2cd0ba52..3bbab58916 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -73e3355004b8b7ce2e1bb937725f429795528a4f \ No newline at end of file +22abe08038cc7b66cbc25e733246d210197c9215 \ No newline at end of file diff --git a/test/vtabH.test b/test/vtabH.test index 606c8f1da1..c15ab87de8 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -142,7 +142,9 @@ if {1} { } } - # Read the first 5 entries from the root directory. + # Read the first 5 entries from the root directory. Except, ignore + # files that contain the "$" character in their names as these are + # special files on some Windows platforms. # set res [list] foreach p [lrange [list_root_files] 0 4] { From fa385edff34587e544690236dc9bf47114c3d333 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 12:07:27 +0000 Subject: [PATCH 134/232] A new approach to very large sqlite3_mprintf() strings: Back out the [d655a665] check-in and instead make the size fields in StrAccum unsigned. Strings generated by sqlite3_mprintf() can now be as large as 2^31-1 bytes. FossilOrigin-Name: 7adb789f45698e5569b840d23f3f9488db3ed109 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/printf.c | 5 ----- src/sqliteInt.h | 6 +++--- test/analyzeF.test | 5 +---- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 7763520f01..5d4a5d2f79 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\scomment\son\sthe\svtabH-3.1\stest. -D 2016-01-04T04:44:31.090 +C A\snew\sapproach\sto\svery\slarge\ssqlite3_mprintf()\sstrings:\s\sBack\sout\sthe\n[d655a665]\scheck-in\sand\sinstead\smake\sthe\ssize\sfields\sin\sStrAccum\sunsigned.\nStrings\sgenerated\sby\ssqlite3_mprintf()\scan\snow\sbe\sas\slarge\sas\s2^31-1\sbytes. +D 2016-01-04T12:07:27.503 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -329,7 +329,7 @@ F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051 F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 -F src/printf.c 79265c0b36bca9b8582592a4f3fa73a1cc1cfa2f +F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -338,7 +338,7 @@ F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 30f7e8957ed7d244be027be72ded385154c635df +F src/sqliteInt.h f97614d43833bae0ed6c51ac8e550f0099a1d0ba F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -441,7 +441,7 @@ F test/analyzeB.test 8bf35ee0a548aea831bf56762cb8e7fdb1db083d F test/analyzeC.test 555a6cc388b9818b6eda6df816f01ce0a75d3a93 F test/analyzeD.test 08f9d0bee4e118a66fff3a32d02dbe0ee0a2b594 F test/analyzeE.test 8684e8ac5722fb97c251887ad97e5d496a98af1d -F test/analyzeF.test 7ccd7a04f7d3061bde1a8a4dacc4792edccf6bf2 +F test/analyzeF.test 5d1fe1024ba2dfea3c18bede8c1ccef8aba1ab34 F test/analyzer1.test 498e2ff4b62740c2751c3a2f8b744fe26689fae9 F test/async.test 1d0e056ba1bb9729283a0f22718d3a25e82c277b F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 73e3355004b8b7ce2e1bb937725f429795528a4f -R add896a0a928f0a416eb15bec81a6801 +P 22abe08038cc7b66cbc25e733246d210197c9215 +R 50b92b9e9c9cae33b4950afbfcff914c U drh -Z 9b39ca76b9261d7edc0d476f6827134f +Z 208fc2f95f59628c3ac39711f08181ab diff --git a/manifest.uuid b/manifest.uuid index 3bbab58916..982d15ab22 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -22abe08038cc7b66cbc25e733246d210197c9215 \ No newline at end of file +7adb789f45698e5569b840d23f3f9488db3ed109 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index fed9acd736..969950c154 100644 --- a/src/printf.c +++ b/src/printf.c @@ -965,12 +965,7 @@ char *sqlite3_vmprintf(const char *zFormat, va_list ap){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif -#if SQLITE_MAX_LENGTH<0x40000000 sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH); -#else - sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), 0x3fffffff); -#endif - sqlite3VXPrintf(&acc, 0, zFormat, ap); z = sqlite3StrAccumFinish(&acc); return z; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 53f0709645..c01bbc7869 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2964,9 +2964,9 @@ struct StrAccum { sqlite3 *db; /* Optional database for lookaside. Can be NULL */ char *zBase; /* A base allocation. Not from malloc. */ char *zText; /* The string collected so far */ - int nChar; /* Length of the string so far */ - int nAlloc; /* Amount of space allocated in zText */ - int mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */ + u32 nChar; /* Length of the string so far */ + u32 nAlloc; /* Amount of space allocated in zText */ + u32 mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */ u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */ u8 bMalloced; /* zText points to allocated space */ }; diff --git a/test/analyzeF.test b/test/analyzeF.test index 670d178a81..3cbc5f47be 100644 --- a/test/analyzeF.test +++ b/test/analyzeF.test @@ -106,7 +106,7 @@ do_catchsql_test 4.1 { } {1 {error one}} do_catchsql_test 4.2 { - SELECT * FROM t1 WHERE x = zeroblob(2000000000) AND y = 4; + SELECT * FROM t1 WHERE x = zeroblob(2200000000) AND y = 4; } {1 {string or blob too big}} sqlite3_limit db SQLITE_LIMIT_LENGTH 1000000 @@ -122,6 +122,3 @@ do_catchsql_test 4.4 { finish_test - - - From 4b4da16344ccb0235df07a5e686d5baf4a888eff Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 13:06:53 +0000 Subject: [PATCH 135/232] Fix the conflict2.test module which was broken by check-in [e30062e9f6c]. FossilOrigin-Name: b779ca8a7580e2a0bb1176316c4540867b635229 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/conflict2.test | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 5d4a5d2f79..1628852800 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C A\snew\sapproach\sto\svery\slarge\ssqlite3_mprintf()\sstrings:\s\sBack\sout\sthe\n[d655a665]\scheck-in\sand\sinstead\smake\sthe\ssize\sfields\sin\sStrAccum\sunsigned.\nStrings\sgenerated\sby\ssqlite3_mprintf()\scan\snow\sbe\sas\slarge\sas\s2^31-1\sbytes. -D 2016-01-04T12:07:27.503 +C Fix\sthe\sconflict2.test\smodule\swhich\swas\sbroken\sby\scheck-in\s[e30062e9f6c]. +D 2016-01-04T13:06:53.893 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -524,7 +524,7 @@ F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1 F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/conflict.test 841bcf7cabbfca39c577eb8411ea8601843b46a8 -F test/conflict2.test 0f0e810aef6739650d7f442164975e932cf18afc +F test/conflict2.test a82dd3b9b41fceb5dd6ff0707c5c7ffba208d538 F test/conflict3.test dec0634c0f31dec9a4b01c63063e939f0cd21b6b F test/contrib01.test 2a1cbc0f2f48955d7d073f725765da6fbceda6b4 F test/corrupt.test 141c39ea650c1365e85a49e402fa05cb9617fb97 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 22abe08038cc7b66cbc25e733246d210197c9215 -R 50b92b9e9c9cae33b4950afbfcff914c +P 7adb789f45698e5569b840d23f3f9488db3ed109 +R 16019d64036d1aa36ba8b50ba392c4e8 U drh -Z 208fc2f95f59628c3ac39711f08181ab +Z 8bde812e449e210a56672af13ac69445 diff --git a/manifest.uuid b/manifest.uuid index 982d15ab22..fa6d00eef8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7adb789f45698e5569b840d23f3f9488db3ed109 \ No newline at end of file +b779ca8a7580e2a0bb1176316c4540867b635229 \ No newline at end of file diff --git a/test/conflict2.test b/test/conflict2.test index e8880635f1..6496913849 100644 --- a/test/conflict2.test +++ b/test/conflict2.test @@ -289,11 +289,11 @@ do_test conflict2-6.0 { # foreach {i conf1 cmd t0 t1 t2 t3 t4} { 1 {} UPDATE 1 {6 7 8 9} 1 0 1 - 2 REPLACE UPDATE 0 {7 6 9} 1 1 0 - 3 IGNORE UPDATE 0 {6 7 3 9} 1 1 0 - 4 FAIL UPDATE 1 {6 7 3 4} 1 1 0 + 2 REPLACE UPDATE 0 {7 6 9} 1 0 1 + 3 IGNORE UPDATE 0 {6 7 3 9} 1 0 1 + 4 FAIL UPDATE 1 {6 7 3 4} 1 0 1 5 ABORT UPDATE 1 {1 2 3 4} 1 0 1 - 6 ROLLBACK UPDATE 1 {1 2 3 4} 0 1 0 + 6 ROLLBACK UPDATE 1 {1 2 3 4} 0 0 1 7 REPLACE {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 8 IGNORE {UPDATE OR REPLACE} 0 {7 6 9} 1 0 1 9 FAIL {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 From 5af10196912b7aae7a848fd06b54405d738d128b Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 4 Jan 2016 16:19:51 +0000 Subject: [PATCH 136/232] Update more fts5 tests to run in detail=none and detail=column modes as well as the default detail=full. FossilOrigin-Name: 3fcf3b1e24483b2cd1c1710f053ed8403e09106d --- ext/fts5/test/fts5ag.test | 21 +++++--- ext/fts5/test/fts5ah.test | 46 +++++++++++----- ext/fts5/test/fts5ai.test | 5 +- ext/fts5/test/fts5ak.test | 107 ++++++++++++++++++++------------------ ext/fts5/test/fts5al.test | 59 ++++++++++++--------- manifest | 20 +++---- manifest.uuid | 2 +- 7 files changed, 152 insertions(+), 108 deletions(-) diff --git a/ext/fts5/test/fts5ag.test b/ext/fts5/test/fts5ag.test index 42a588f56c..de126a25f0 100644 --- a/ext/fts5/test/fts5ag.test +++ b/ext/fts5/test/fts5ag.test @@ -33,8 +33,10 @@ ifcapable !fts5 { # ... WHERE fts MATCH ? ORDER BY rank [ASC|DESC] # +foreach_detail_mode $testprefix { + do_execsql_test 1.0 { - CREATE VIRTUAL TABLE t1 USING fts5(x, y, z); + CREATE VIRTUAL TABLE t1 USING fts5(x, y, z, detail=%DETAIL%); } do_test 1.1 { @@ -119,19 +121,24 @@ foreach {tn expr} { 2.3 c 2.4 d - 2.5 {"m m"} - 2.6 {e + s} - 3.0 {a AND b} 3.1 {a OR b} 3.2 {b OR c AND d} - 3.3 {NEAR(c d)} } { do_fts5ag_test $tn $expr - - if {[set_test_counter errors]} break } +if {[detail_is_full]} { + foreach {tn expr} { + 4.1 {"m m"} + 4.2 {e + s} + 4.3 {NEAR(c d)} + } { + do_fts5ag_test $tn $expr + } +} + +} ;# foreach_detail_mode finish_test diff --git a/ext/fts5/test/fts5ah.test b/ext/fts5/test/fts5ah.test index 6d7e39f793..b7beb5655b 100644 --- a/ext/fts5/test/fts5ah.test +++ b/ext/fts5/test/fts5ah.test @@ -21,12 +21,16 @@ ifcapable !fts5 { return } +foreach_detail_mode $testprefix { + #------------------------------------------------------------------------- # This file contains tests for very large doclists. # +set Y [list] +set W [list] do_test 1.0 { - execsql { CREATE VIRTUAL TABLE t1 USING fts5(a) } + execsql { CREATE VIRTUAL TABLE t1 USING fts5(a, detail=%DETAIL%) } execsql { INSERT INTO t1(t1, rank) VALUES('pgsz', 128) } set v {w w w w w w w w w w w w w w w w w w w w} execsql { INSERT INTO t1(rowid, a) VALUES(0, $v) } @@ -70,7 +74,12 @@ do_test 1.4 { set nRead [reads] execsql { SELECT rowid FROM t1 WHERE t1 MATCH 'x' } set nReadX [expr [reads] - $nRead] - expr $nReadX>1000 + #puts -nonewline "(nReadX=$nReadX)" + if {[detail_is_full]} { set expect 1000 } + if {[detail_is_col]} { set expect 250 } + if {[detail_is_none]} { set expect 80 } + + expr $nReadX>$expect } {1} do_test 1.5 { @@ -87,17 +96,22 @@ foreach {tn q res} " 3 { SELECT rowid FROM t1 WHERE t1 MATCH 'x AND w' } [list $W] 4 { SELECT rowid FROM t1 WHERE t1 MATCH 'y AND x' } [list $Y] " { + if {[detail_is_full]==0 && ($tn==1 || $tn==2)} continue + + if {[detail_is_full]} { set ratio 8 } + if {[detail_is_col]} { set ratio 4 } + if {[detail_is_none]} { set ratio 2 } do_test 1.6.$tn.1 { set n [execsql_reads $q] #puts -nonewline "(n=$n nReadX=$nReadX)" - expr {$n < ($nReadX / 8)} + expr {$n < ($nReadX / $ratio)} } {1} do_test 1.6.$tn.2 { set n [execsql_reads "$q ORDER BY rowid DESC"] #puts -nonewline "(n=$n nReadX=$nReadX)" - expr {$n < ($nReadX / 8)} + expr {$n < ($nReadX / $ratio)} } {1} do_execsql_test 1.6.$tn.3 $q [lsort -int -incr $res] @@ -109,21 +123,26 @@ foreach {tn q res} " # number of pages loaded from disk. # foreach {tn fraction tail cnt} { - 1 0.6 {rowid > 5000} 5000 - 2 0.2 {rowid > 9000} 1000 - 3 0.2 {rowid < 1000} 999 - 4 0.2 {rowid BETWEEN 4000 AND 5000} 1001 - 5 0.6 {rowid >= 5000} 5001 - 6 0.2 {rowid >= 9000} 1001 - 7 0.2 {rowid <= 1000} 1000 - 8 0.6 {rowid > '5000'} 5000 - 9 0.2 {rowid > '9000'} 1000 + 1 0.6 {rowid > 5000} 5000 + 2 0.2 {rowid > 9000} 1000 + 3 0.2 {rowid < 1000} 999 + 4 0.2 {rowid BETWEEN 4000 AND 5000} 1001 + 5 0.6 {rowid >= 5000} 5001 + 6 0.2 {rowid >= 9000} 1001 + 7 0.2 {rowid <= 1000} 1000 + 8 0.6 {rowid > '5000'} 5000 + 9 0.2 {rowid > '9000'} 1000 10 0.1 {rowid = 444} 1 } { set q "SELECT rowid FROM t1 WHERE t1 MATCH 'x' AND $tail" set n [execsql_reads $q] set ret [llength [execsql $q]] + # Because the position lists for 'x' are quite long in this db, the + # advantage is a bit smaller in detail=none mode. Update $fraction to + # reflect this. + if {[detail_is_none] && $fraction<0.5} { set fraction [expr $fraction*2] } + do_test "1.7.$tn.asc.(n=$n ret=$ret)" { expr {$n < ($fraction*$nReadX) && $ret==$cnt} } {1} @@ -143,6 +162,7 @@ do_execsql_test 1.8.2 { SELECT count(*) FROM t1 WHERE t1 MATCH 'x' AND rowid < 'text'; } {10000} +} ;# foreach_detail_mode #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM t1_data} {puts $r} diff --git a/ext/fts5/test/fts5ai.test b/ext/fts5/test/fts5ai.test index 63c46fd042..e32c806c46 100644 --- a/ext/fts5/test/fts5ai.test +++ b/ext/fts5/test/fts5ai.test @@ -23,8 +23,10 @@ ifcapable !fts5 { return } +foreach_detail_mode $testprefix { + do_execsql_test 1.0 { - CREATE VIRTUAL TABLE t1 USING fts5(a); + CREATE VIRTUAL TABLE t1 USING fts5(a, detail=%DETAIL%); } {} do_execsql_test 1.1 { @@ -49,6 +51,7 @@ do_execsql_test 1.1 { do_execsql_test 1.2 { INSERT INTO t1(t1) VALUES('integrity-check'); } +} finish_test diff --git a/ext/fts5/test/fts5ak.test b/ext/fts5/test/fts5ak.test index 4eb28324c9..0f699a601f 100644 --- a/ext/fts5/test/fts5ak.test +++ b/ext/fts5/test/fts5ak.test @@ -23,8 +23,10 @@ ifcapable !fts5 { return } +foreach_detail_mode $testprefix { + do_execsql_test 1.1 { - CREATE VIRTUAL TABLE ft1 USING fts5(x); + CREATE VIRTUAL TABLE ft1 USING fts5(x, detail=%DETAIL%); INSERT INTO ft1 VALUES('i d d a g i b g d d'); INSERT INTO ft1 VALUES('h d b j c c g a c a'); INSERT INTO ft1 VALUES('e j a e f h b f h h'); @@ -35,6 +37,9 @@ do_execsql_test 1.1 { INSERT INTO ft1 VALUES('i c c f a d g h j e'); INSERT INTO ft1 VALUES('i d i g c d c h b f'); INSERT INTO ft1 VALUES('g d a e h a b c f j'); + + CREATE VIRTUAL TABLE ft2 USING fts5(x, detail=%DETAIL%); + INSERT INTO ft2 VALUES('a b c d e f g h i j'); } do_execsql_test 1.2 { @@ -49,19 +54,6 @@ do_execsql_test 1.2 { } do_execsql_test 1.3 { - SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'h + d'; -} { - {[h d] b j c c g a c a} - {j f [h d] g h i b d f} -} - -do_execsql_test 1.4 { - SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'd + d'; -} { - {i [d d] a g i b g [d d]} -} - -do_execsql_test 1.5 { SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'e e e' } { {[e] j a [e] f h b f h h} @@ -72,57 +64,71 @@ do_execsql_test 1.5 { {g d a [e] h a b c f j} } -do_execsql_test 1.6 { - SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'd + d d + d'; -} { - {i [d d] a g i b g [d d]} -} - -do_execsql_test 2.1 { - CREATE VIRTUAL TABLE ft2 USING fts5(x); - INSERT INTO ft2 VALUES('a b c d e f g h i j'); -} - -do_execsql_test 2.2 { - SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d c+d+e' -} {{a [b c d e] f g h i j}} - -do_execsql_test 2.3 { - SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d e+f+g' -} { - {a [b c d] [e f g] h i j} -} - -do_execsql_test 2.4 { - SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d c' -} { - {a [b c d] e f g h i j} -} - -do_execsql_test 2.5 { - SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c c+d+e' -} { - {a [b c d e] f g h i j} -} - -do_execsql_test 2.6.1 { +do_execsql_test 1.4 { SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'f d' } { {a b c [d] e [f] g h i j} } -do_execsql_test 2.6.2 { +do_execsql_test 1.5 { SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'd f' } { {a b c [d] e [f] g h i j} } +#------------------------------------------------------------------------- +# Tests below this point require detail=full. +#------------------------------------------------------------------------- +if {[detail_is_full]==0} continue + + +do_execsql_test 2.1 { + SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'h + d'; +} { + {[h d] b j c c g a c a} + {j f [h d] g h i b d f} +} + +do_execsql_test 2.2 { + SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'd + d'; +} { + {i [d d] a g i b g [d d]} +} + +do_execsql_test 2.3 { + SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'd + d d + d'; +} { + {i [d d] a g i b g [d d]} +} + +do_execsql_test 2.4 { + SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d c+d+e' +} {{a [b c d e] f g h i j}} + +do_execsql_test 2.5 { + SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d e+f+g' +} { + {a [b c d] [e f g] h i j} +} + +do_execsql_test 2.6 { + SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d c' +} { + {a [b c d] e f g h i j} +} + +do_execsql_test 2.7 { + SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c c+d+e' +} { + {a [b c d e] f g h i j} +} + #------------------------------------------------------------------------- # The example from the docs. # do_execsql_test 3.1 { -- Assuming this: - CREATE VIRTUAL TABLE ft USING fts5(a); + CREATE VIRTUAL TABLE ft USING fts5(a, detail=%DETAIL%); INSERT INTO ft VALUES('a b c x c d e'); INSERT INTO ft VALUES('a b c c d e'); INSERT INTO ft VALUES('a b c d e'); @@ -138,6 +144,7 @@ do_execsql_test 3.1 { {[a b c d e]} } +} finish_test diff --git a/ext/fts5/test/fts5al.test b/ext/fts5/test/fts5al.test index b8f8c6ebcd..c0dd2117dd 100644 --- a/ext/fts5/test/fts5al.test +++ b/ext/fts5/test/fts5al.test @@ -23,8 +23,10 @@ ifcapable !fts5 { return } +foreach_detail_mode $testprefix { + do_execsql_test 1.1 { - CREATE VIRTUAL TABLE ft1 USING fts5(x); + CREATE VIRTUAL TABLE ft1 USING fts5(x, detail=%DETAIL%); SELECT * FROM ft1_config; } {version 4} @@ -83,7 +85,7 @@ foreach {tn defn} { # do_execsql_test 3.1 { - CREATE VIRTUAL TABLE t1 USING fts5(x); + CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%); INSERT INTO t1 VALUES('q w e r t y'); INSERT INTO t1 VALUES('y t r e w q'); } @@ -122,11 +124,13 @@ do_execsql_test 3.4.1 { {{0 0 5}} } -do_execsql_test 3.4.2 { - SELECT insttest(t1) FROM t1 WHERE t1 MATCH 'r+e OR w' -} { - {{1 0 1}} - {{0 0 2} {1 0 4}} +if {[detail_is_full]} { + do_execsql_test 3.4.2 { + SELECT insttest(t1) FROM t1 WHERE t1 MATCH 'r+e OR w' + } { + {{1 0 1}} + {{0 0 2} {1 0 4}} + } } proc coltest {cmd} { @@ -149,7 +153,7 @@ do_execsql_test 3.5.1 { # do_execsql_test 4.0 { - CREATE VIRTUAL TABLE t2 USING fts5(a, b); + CREATE VIRTUAL TABLE t2 USING fts5(a, b, detail=%DETAIL%); INSERT INTO t2 VALUES('a s h g s b j m r h', 's b p a d b b a o e'); INSERT INTO t2 VALUES('r h n t a g r d d i', 'l d n j r c f t o q'); INSERT INTO t2 VALUES('q k n i k c a a e m', 'c h n j p g s c i t'); @@ -218,24 +222,26 @@ proc rowidplus {cmd ival} { } sqlite3_fts5_create_function db rowidplus rowidplus -do_execsql_test 4.2.1 { - INSERT INTO t2(t2, rank) VALUES('rank', 'rowidplus(100) '); - SELECT rowid, rank FROM t2 WHERE t2 MATCH 'o + q + g' -} { - 10 110 -} -do_execsql_test 4.2.2 { - INSERT INTO t2(t2, rank) VALUES('rank', 'rowidplus(111) '); - SELECT rowid, rank FROM t2 WHERE t2 MATCH 'o + q + g' -} { - 10 121 -} +if {[detail_is_full]} { + do_execsql_test 4.2.1 { + INSERT INTO t2(t2, rank) VALUES('rank', 'rowidplus(100) '); + SELECT rowid, rank FROM t2 WHERE t2 MATCH 'o + q + g' + } { + 10 110 + } + do_execsql_test 4.2.2 { + INSERT INTO t2(t2, rank) VALUES('rank', 'rowidplus(111) '); + SELECT rowid, rank FROM t2 WHERE t2 MATCH 'o + q + g' + } { + 10 121 + } -do_execsql_test 4.2.3 { - SELECT rowid, rank FROM t2 - WHERE t2 MATCH 'o + q + g' AND rank MATCH 'rowidplus(112)' -} { - 10 122 + do_execsql_test 4.2.3 { + SELECT rowid, rank FROM t2 + WHERE t2 MATCH 'o + q + g' AND rank MATCH 'rowidplus(112)' + } { + 10 122 + } } proc rowidmod {cmd imod} { @@ -243,7 +249,7 @@ proc rowidmod {cmd imod} { } sqlite3_fts5_create_function db rowidmod rowidmod do_execsql_test 4.3.1 { - CREATE VIRTUAL TABLE t3 USING fts5(x); + CREATE VIRTUAL TABLE t3 USING fts5(x, detail=%DETAIL%); INSERT INTO t3 VALUES('a one'); INSERT INTO t3 VALUES('a two'); INSERT INTO t3 VALUES('a three'); @@ -287,6 +293,7 @@ do_catchsql_test 4.4.4 { SELECT *, rank FROM t3 WHERE t3 MATCH 'a' AND rank MATCH NULL } {1 {parse error in rank function: }} +} ;# foreach_detail_mode finish_test diff --git a/manifest b/manifest index ce2b5eb30f..ff5d797e2d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sto\srun\smany\sfts5\stests\swith\sdetail=none\sand\sdetail=col\stables\sas\swell\sas\sthe\sdefault\sdetail=full.\sAlso\sfixes\sfor\sthe\sbugs\suncovered\sby\srunning\ssaid\stests. -D 2016-01-02T19:01:56.026 +C Update\smore\sfts5\stests\sto\srun\sin\sdetail=none\sand\sdetail=column\smodes\sas\swell\sas\sthe\sdefault\sdetail=full. +D 2016-01-04T16:19:51.421 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -121,12 +121,12 @@ F ext/fts5/test/fts5ac.test 9a3c5eb052a5e8c871d56d3d0f144e5fdcf075c2 F ext/fts5/test/fts5ad.test 049f7511a79c155d2d8dfd2ddcfeb640c50ad0dc F ext/fts5/test/fts5ae.test 612dcb51f4069226791ff14c17dbfb3138c56f20 F ext/fts5/test/fts5af.test be858a96b1f5de66ba6d64f0021bd8b2408e126c -F ext/fts5/test/fts5ag.test ec3e119b728196620a31507ef503c455a7a73505 -F ext/fts5/test/fts5ah.test e592c4978622dbc4de552cd0f9395df60ac5d54c -F ext/fts5/test/fts5ai.test f20e53bbf0c55bc596f1fd47f2740dae028b8f37 +F ext/fts5/test/fts5ag.test 27180de76c03036be75ee80b93d8c5f540014071 +F ext/fts5/test/fts5ah.test dfb7897711dbcda1dacb038aec310daca139fcf5 +F ext/fts5/test/fts5ai.test 3909d0b949b2afcaae4d5795cd79153da75381df F ext/fts5/test/fts5aj.test 05b569f5c16ea3098fb1984eec5cf50dbdaae5d8 -F ext/fts5/test/fts5ak.test 7b8c5df96df599293f920b7e5521ebc79f647592 -F ext/fts5/test/fts5al.test a1b7b6393376bc2adc216527a28f5ae5594069df +F ext/fts5/test/fts5ak.test fb26389985407826f6076bb9f382c67d3db6b5d9 +F ext/fts5/test/fts5al.test 18c277f5986df0a3d9071dfd7128afeb16fe9d5d F ext/fts5/test/fts5alter.test 6022c61467a82aa11c70822ccad22b328dcf0d04 F ext/fts5/test/fts5auto.test 2a6241673657b340427f521528f7809ddaa02a9e F ext/fts5/test/fts5aux.test 8c687c948cc98e9a94be014df7d518acc1b3b74f @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3a1df69e58e5830da1dff158eedbe3817743f58f -R 584d5f1c8b7a15ac2eae2ab1ffe71c4a +P 6322a1d984e7946735bace8a069ef24b31754b3b +R 32e8694f89e6ec744ed1fb193a76a532 U dan -Z cff9ad15204445a84003e93595871343 +Z 780f62d5b61ae786fb811bd6c42602f7 diff --git a/manifest.uuid b/manifest.uuid index 4a0bbbdcd0..3f2a04cfe4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6322a1d984e7946735bace8a069ef24b31754b3b \ No newline at end of file +3fcf3b1e24483b2cd1c1710f053ed8403e09106d \ No newline at end of file From 211bd3a20a50305837d48374d1ced88710511d52 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 4 Jan 2016 19:12:00 +0000 Subject: [PATCH 137/232] Fix an OOM handling problem in fts5 detail=none and detail=col modes. Also a bug in the xInst() API when used with detail=col and column filtering expressions. Update the matchinfo() test function so that 'b' is fast with detail=col tables. FossilOrigin-Name: ee38f9dff5e9239c541515cd8a1aa3d81fdc0ae9 --- ext/fts5/fts5Int.h | 5 +- ext/fts5/fts5_expr.c | 55 ++++++++++---- ext/fts5/fts5_main.c | 121 +++++++++++++++++-------------- ext/fts5/fts5_test_mi.c | 27 +++++-- ext/fts5/test/fts5ac.test | 72 +++++++++--------- ext/fts5/test/fts5fault8.test | 49 +++++++++++++ ext/fts5/test/fts5matchinfo.test | 80 ++++++++++++-------- manifest | 23 +++--- manifest.uuid | 2 +- 9 files changed, 279 insertions(+), 155 deletions(-) create mode 100644 ext/fts5/test/fts5fault8.test diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index c369687042..b853bb3a43 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -642,9 +642,10 @@ int sqlite3Fts5ExprPhraseCount(Fts5Expr*); int sqlite3Fts5ExprPhraseSize(Fts5Expr*, int iPhrase); int sqlite3Fts5ExprPoslist(Fts5Expr*, int, const u8 **); -Fts5PoslistWriter *sqlite3Fts5ExprClearPoslists(Fts5Expr*); +typedef struct Fts5PoslistPopulator Fts5PoslistPopulator; +Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*); int sqlite3Fts5ExprPopulatePoslists( - Fts5Config*, Fts5Expr*, Fts5PoslistWriter*, int, const char*, int + Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int ); void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64); diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 0a74c7884a..ae00a12c82 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -2257,28 +2257,44 @@ int sqlite3Fts5ExprPoslist(Fts5Expr *pExpr, int iPhrase, const u8 **pa){ return nRet; } -Fts5PoslistWriter *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr){ - int i; - Fts5PoslistWriter *pRet; - for(i=0; inPhrase; i++){ - Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist; - assert( pExpr->apExprPhrase[i]->nTerm==1 ); - pBuf->n = 0; - } - pRet = sqlite3_malloc(sizeof(Fts5PoslistWriter)*pExpr->nPhrase); +struct Fts5PoslistPopulator { + Fts5PoslistWriter writer; + int bOk; /* True if ok to populate */ +}; + +Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr){ + Fts5PoslistPopulator *pRet; + pRet = sqlite3_malloc(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase); if( pRet ){ - memset(pRet, 0, sizeof(Fts5PoslistWriter)*pExpr->nPhrase); + int i; + memset(pRet, 0, sizeof(Fts5PoslistPopulator)*pExpr->nPhrase); + for(i=0; inPhrase; i++){ + Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist; + assert( pExpr->apExprPhrase[i]->nTerm==1 ); + pBuf->n = 0; + } } return pRet; } struct Fts5ExprCtx { Fts5Expr *pExpr; - Fts5PoslistWriter *aWriter; + Fts5PoslistPopulator *aPopulator; i64 iOff; }; typedef struct Fts5ExprCtx Fts5ExprCtx; +/* +** TODO: Make this more efficient! +*/ +static int fts5ExprColsetTest(Fts5Colset *pColset, int iCol){ + int i; + for(i=0; inCol; i++){ + if( pColset->aiCol[i]==iCol ) return 1; + } + return 0; +} + static int fts5ExprPopulatePoslistsCb( void *pCtx, /* Copy of 2nd argument to xTokenize() */ int tflags, /* Mask of FTS5_TOKEN_* flags */ @@ -2294,13 +2310,14 @@ static int fts5ExprPopulatePoslistsCb( if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++; for(i=0; inPhrase; i++){ Fts5ExprTerm *pTerm; + if( p->aPopulator[i].bOk==0 ) continue; for(pTerm=&pExpr->apExprPhrase[i]->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){ int nTerm = strlen(pTerm->zTerm); if( (nTerm==nToken || (nTermbPrefix)) && memcmp(pTerm->zTerm, pToken, nTerm)==0 ){ int rc = sqlite3Fts5PoslistWriterAppend( - &pExpr->apExprPhrase[i]->poslist, &p->aWriter[i], p->iOff + &pExpr->apExprPhrase[i]->poslist, &p->aPopulator[i].writer, p->iOff ); if( rc ) return rc; break; @@ -2313,15 +2330,25 @@ static int fts5ExprPopulatePoslistsCb( int sqlite3Fts5ExprPopulatePoslists( Fts5Config *pConfig, Fts5Expr *pExpr, - Fts5PoslistWriter *aWriter, + Fts5PoslistPopulator *aPopulator, int iCol, const char *z, int n ){ + int i; Fts5ExprCtx sCtx; sCtx.pExpr = pExpr; - sCtx.aWriter = aWriter; + sCtx.aPopulator = aPopulator; sCtx.iOff = (((i64)iCol) << 32) - 1; + for(i=0; inPhrase; i++){ + Fts5Colset *pColset = pExpr->apExprPhrase[i]->pNode->pNear->pColset; + if( pColset && 0==fts5ExprColsetTest(pColset, iCol) ){ + aPopulator[i].bOk = 0; + }else{ + aPopulator[i].bOk = 1; + } + } + return sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_AUX, z, n, (void*)&sCtx, fts5ExprPopulatePoslistsCb ); diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 95d72ebbc1..99c9eb05db 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1608,7 +1608,7 @@ static int fts5RollbackMethod(sqlite3_vtab *pVtab){ return rc; } -static int fts5CsrPoslist(Fts5Cursor*, int, const u8**); +static int fts5CsrPoslist(Fts5Cursor*, int, const u8**, int*); static void *fts5ApiUserData(Fts5Context *pCtx){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; @@ -1680,28 +1680,32 @@ static int fts5ApiColumnText( return rc; } -static int fts5CsrPoslist(Fts5Cursor *pCsr, int iPhrase, const u8 **pa){ +static int fts5CsrPoslist( + Fts5Cursor *pCsr, + int iPhrase, + const u8 **pa, + int *pn +){ Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig; - int n; int rc = SQLITE_OK; if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){ if( pConfig->eDetail!=FTS5_DETAIL_FULL ){ - Fts5PoslistWriter *aWriter; + Fts5PoslistPopulator *aPopulator; int i; - aWriter = sqlite3Fts5ExprClearPoslists(pCsr->pExpr); - if( aWriter==0 ) rc = SQLITE_NOMEM; + aPopulator = sqlite3Fts5ExprClearPoslists(pCsr->pExpr); + if( aPopulator==0 ) rc = SQLITE_NOMEM; for(i=0; inCol && rc==SQLITE_OK; i++){ int n; const char *z; rc = fts5ApiColumnText((Fts5Context*)pCsr, i, &z, &n); if( rc==SQLITE_OK ){ rc = sqlite3Fts5ExprPopulatePoslists( - pConfig, pCsr->pExpr, aWriter, i, z, n + pConfig, pCsr->pExpr, aPopulator, i, z, n ); } } - sqlite3_free(aWriter); + sqlite3_free(aPopulator); if( pCsr->pSorter ){ sqlite3Fts5ExprCheckPoslists(pCsr->pExpr, pCsr->pSorter->iRowid); } @@ -1712,12 +1716,13 @@ static int fts5CsrPoslist(Fts5Cursor *pCsr, int iPhrase, const u8 **pa){ if( pCsr->pSorter && pConfig->eDetail==FTS5_DETAIL_FULL ){ Fts5Sorter *pSorter = pCsr->pSorter; int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]); - n = pSorter->aIdx[iPhrase] - i1; + *pn = pSorter->aIdx[iPhrase] - i1; *pa = &pSorter->aPoslist[i1]; }else{ - n = sqlite3Fts5ExprPoslist(pCsr->pExpr, iPhrase, pa); + *pn = sqlite3Fts5ExprPoslist(pCsr->pExpr, iPhrase, pa); } - return n; + + return rc; } /* @@ -1742,43 +1747,46 @@ static int fts5CacheInstArray(Fts5Cursor *pCsr){ int i; /* Initialize all iterators */ - for(i=0; i=pCsr->nInstAlloc ){ - pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32; - aInst = (int*)sqlite3_realloc( - pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3 - ); - if( aInst ){ - pCsr->aInst = aInst; - }else{ - rc = SQLITE_NOMEM; - break; + nInst++; + if( nInst>=pCsr->nInstAlloc ){ + pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32; + aInst = (int*)sqlite3_realloc( + pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3 + ); + if( aInst ){ + pCsr->aInst = aInst; + }else{ + rc = SQLITE_NOMEM; + break; + } } - } - aInst = &pCsr->aInst[3 * (nInst-1)]; - aInst[0] = iBest; - aInst[1] = FTS5_POS2COLUMN(aIter[iBest].iPos); - aInst[2] = FTS5_POS2OFFSET(aIter[iBest].iPos); - sqlite3Fts5PoslistReaderNext(&aIter[iBest]); + aInst = &pCsr->aInst[3 * (nInst-1)]; + aInst[0] = iBest; + aInst[1] = FTS5_POS2COLUMN(aIter[iBest].iPos); + aInst[2] = FTS5_POS2OFFSET(aIter[iBest].iPos); + sqlite3Fts5PoslistReaderNext(&aIter[iBest]); + } } pCsr->nInstCount = nInst; @@ -1981,11 +1989,15 @@ static int fts5ApiPhraseFirst( int *piCol, int *piOff ){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; - int n = fts5CsrPoslist(pCsr, iPhrase, &pIter->a); - pIter->b = &pIter->a[n]; - *piCol = 0; - *piOff = 0; - fts5ApiPhraseNext(pCtx, pIter, piCol, piOff); + int n; + int rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n); + if( rc==SQLITE_OK ){ + pIter->b = &pIter->a[n]; + *piCol = 0; + *piOff = 0; + fts5ApiPhraseNext(pCtx, pIter, piCol, piOff); + } + return rc; } static void fts5ApiPhraseNextColumn( @@ -2037,14 +2049,17 @@ static int fts5ApiPhraseFirstColumn( fts5ApiPhraseNextColumn(pCtx, pIter, piCol); } }else{ - int n = fts5CsrPoslist(pCsr, iPhrase, &pIter->a); - pIter->b = &pIter->a[n]; - if( n<=0 ){ - *piCol = -1; - }else if( pIter->a[0]==0x01 ){ - pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol); - }else{ - *piCol = 0; + int n; + rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n); + if( rc==SQLITE_OK ){ + pIter->b = &pIter->a[n]; + if( n<=0 ){ + *piCol = -1; + }else if( pIter->a[0]==0x01 ){ + pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol); + }else{ + *piCol = 0; + } } } diff --git a/ext/fts5/fts5_test_mi.c b/ext/fts5/fts5_test_mi.c index fb4a2102b4..28331773c0 100644 --- a/ext/fts5/fts5_test_mi.c +++ b/ext/fts5/fts5_test_mi.c @@ -211,18 +211,31 @@ static int fts5MatchinfoLocalCb( int rc = SQLITE_OK; switch( f ){ - case 'b': + case 'b': { + int iPhrase; + int nInt = ((p->nCol + 31) / 32) * p->nPhrase; + for(i=0; inPhrase; iPhrase++){ + Fts5PhraseIter iter; + int iCol; + for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol); + iCol>=0; + pApi->xPhraseNextColumn(pFts, &iter, &iCol) + ){ + aOut[iPhrase * ((p->nCol+31)/32) + iCol/32] |= ((u32)1 << iCol%32); + } + } + + break; + } + case 'x': case 'y': { int nMul = (f=='x' ? 3 : 1); int iPhrase; - if( f=='b' ){ - int nInt = ((p->nCol + 31) / 32) * p->nPhrase; - for(i=0; inCol*p->nPhrase); i++) aOut[i*nMul] = 0; - } + for(i=0; i<(p->nCol*p->nPhrase); i++) aOut[i*nMul] = 0; for(iPhrase=0; iPhrasenPhrase; iPhrase++){ Fts5PhraseIter iter; diff --git a/ext/fts5/test/fts5ac.test b/ext/fts5/test/fts5ac.test index c3163147cb..692929167b 100644 --- a/ext/fts5/test/fts5ac.test +++ b/ext/fts5/test/fts5ac.test @@ -257,7 +257,43 @@ foreach {tn2 sql} { } $res } - if {[detail_is_none] || [detail_is_col]} continue + if {[detail_is_none]} continue + + #------------------------------------------------------------------------- + # Queries on a specific column. + # + foreach {tn expr} { + 1.1 "x:a" + 1.2 "y:a" + 1.3 "x:b" + 1.4 "y:b" + 2.1 "{x}:a" + 2.2 "{y}:a" + 2.3 "{x}:b" + 2.4 "{y}:b" + + 3.1 "{x y}:a" + 3.2 "{y x}:a" + 3.3 "{x x}:b" + 3.4 "{y y}:b" + + 4.1 {{"x" "y"}:a} + 4.2 {{"y" x}:a} + 4.3 {{x "x"}:b} + 4.4 {{"y" y}:b} + } { + set res [poslist_data 1 $expr] + do_execsql_test 1.$tn2.4.$tn.p.[llength $res] { + SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr + } $res + + set res [collist_data $expr] + do_execsql_test 1.$tn2.4.$tn.c.[llength $res] { + SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr + } $res + } + + if {[detail_is_col]} continue #------------------------------------------------------------------------- # Test phrase queries. @@ -304,40 +340,6 @@ foreach {tn2 sql} { } $res } - #------------------------------------------------------------------------- - # Queries on a specific column. - # - foreach {tn expr} { - 1.1 "x:a" - 1.2 "y:a" - 1.3 "x:b" - 1.4 "y:b" - 2.1 "{x}:a" - 2.2 "{y}:a" - 2.3 "{x}:b" - 2.4 "{y}:b" - - 3.1 "{x y}:a" - 3.2 "{y x}:a" - 3.3 "{x x}:b" - 3.4 "{y y}:b" - - 4.1 {{"x" "y"}:a} - 4.2 {{"y" x}:a} - 4.3 {{x "x"}:b} - 4.4 {{"y" y}:b} - } { - set res [poslist_data 1 $expr] - do_execsql_test 1.$tn2.4.$tn.p.[llength $res] { - SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr - } $res - - set res [collist_data $expr] - do_execsql_test 1.$tn2.4.$tn.c.[llength $res] { - SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr - } $res - } - #------------------------------------------------------------------------- # Some NEAR queries. # diff --git a/ext/fts5/test/fts5fault8.test b/ext/fts5/test/fts5fault8.test new file mode 100644 index 0000000000..01a1876955 --- /dev/null +++ b/ext/fts5/test/fts5fault8.test @@ -0,0 +1,49 @@ +# 2015 September 3 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# +# This file is focused on OOM errors. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +source $testdir/malloc_common.tcl +set testprefix fts5fault8 + +# If SQLITE_ENABLE_FTS3 is defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +foreach_detail_mode $testprefix { + +if {[detail_is_none]==0} continue + +fts5_aux_test_functions db +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); + INSERT INTO t1 VALUES('a b c d', '1 2 3 4'); + INSERT INTO t1 VALUES('a b a b', NULL); + INSERT INTO t1 VALUES(NULL, '1 2 1 2'); +} + +do_faultsim_test 1 -faults oom-t* -body { + execsql { + SELECT rowid, fts5_test_poslist(t1) FROM t1 WHERE t1 MATCH 'b OR 2' + } +} -test { + faultsim_test_result {0 {1 {0.0.1 1.1.1} 2 {0.0.1 0.0.3} 3 {1.1.1 1.1.3}}} \ + {1 SQLITE_NOMEM} +} + +} + +finish_test + diff --git a/ext/fts5/test/fts5matchinfo.test b/ext/fts5/test/fts5matchinfo.test index 21f9b003e7..06f4550b47 100644 --- a/ext/fts5/test/fts5matchinfo.test +++ b/ext/fts5/test/fts5matchinfo.test @@ -16,6 +16,8 @@ set testprefix fts5matchinfo # If SQLITE_ENABLE_FTS5 is not defined, omit this file. ifcapable !fts5 { finish_test ; return } +foreach_detail_mode $testprefix { + proc mit {blob} { set scan(littleEndian) i* set scan(bigEndian) I* @@ -27,7 +29,7 @@ db func mit mit sqlite3_fts5_register_matchinfo db do_execsql_test 1.0 { - CREATE VIRTUAL TABLE t1 USING fts5(content); + CREATE VIRTUAL TABLE t1 USING fts5(content, detail=%DETAIL%); } do_execsql_test 1.1 { @@ -41,7 +43,7 @@ do_execsql_test 1.1 { # Now create an FTS4 table that does not specify matchinfo=fts3. # do_execsql_test 1.2 { - CREATE VIRTUAL TABLE t2 USING fts5(content); + CREATE VIRTUAL TABLE t2 USING fts5(content, detail=%DETAIL%); INSERT INTO t2 SELECT * FROM t1; SELECT mit(matchinfo(t2)) FROM t2 WHERE t2 MATCH 'I'; } {{1 1 1 2 2} {1 1 1 2 2}} @@ -149,9 +151,17 @@ proc normalize2 {list_of_lists} { return $res } +# Similar to [do_matchinfo_test], except that this is a no-op if the FTS5 +# mode is not detail=full. +# +proc do_matchinfo_p_test {tn tbl expr results} { + if {[detail_is_full]} { + uplevel [list do_matchinfo_test $tn $tbl $expr $results] + } +} do_execsql_test 4.1.0 { - CREATE VIRTUAL TABLE t4 USING fts5(x, y); + CREATE VIRTUAL TABLE t4 USING fts5(x, y, detail=%DETAIL%); INSERT INTO t4 VALUES('a b c d e', 'f g h i j'); INSERT INTO t4 VALUES('f g h i j', 'a b c d e'); } @@ -185,7 +195,7 @@ do_matchinfo_test 4.1.1 t4 {t4 MATCH 'a b c'} { xpxsscplax - } -do_matchinfo_test 4.1.2 t4 {t4 MATCH '"g h i"'} { +do_matchinfo_p_test 4.1.2 t4 {t4 MATCH '"g h i"'} { p {1 1} c {2 2} x { @@ -203,8 +213,8 @@ do_matchinfo_test 4.1.2 t4 {t4 MATCH '"g h i"'} { } do_matchinfo_test 4.1.3 t4 {t4 MATCH 'a b'} { s {{2 0} {0 2}} } -do_matchinfo_test 4.1.4 t4 {t4 MATCH '"a b" c'} { s {{2 0} {0 2}} } -do_matchinfo_test 4.1.5 t4 {t4 MATCH 'a "b c"'} { s {{2 0} {0 2}} } +do_matchinfo_p_test 4.1.4 t4 {t4 MATCH '"a b" c'} { s {{2 0} {0 2}} } +do_matchinfo_p_test 4.1.5 t4 {t4 MATCH 'a "b c"'} { s {{2 0} {0 2}} } do_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'} { s {{1 0} {0 1}} } do_matchinfo_test 4.1.7 t4 {t4 MATCH 'f OR abcd'} { x { @@ -220,7 +230,7 @@ do_matchinfo_test 4.1.8 t4 {t4 MATCH 'f NOT abcd'} { } do_execsql_test 4.2.0 { - CREATE VIRTUAL TABLE t5 USING fts5(content); + CREATE VIRTUAL TABLE t5 USING fts5(content, detail=%DETAIL%); INSERT INTO t5 VALUES('a a a a a'); INSERT INTO t5 VALUES('a b a b a'); INSERT INTO t5 VALUES('c b c b c'); @@ -233,7 +243,7 @@ do_matchinfo_test 4.2.1 t5 {t5 MATCH 'a a'} { do_matchinfo_test 4.2.2 t5 {t5 MATCH 'a b'} { s {2} } do_matchinfo_test 4.2.3 t5 {t5 MATCH 'a b a'} { s {3} } do_matchinfo_test 4.2.4 t5 {t5 MATCH 'a a a'} { s {3 1} } -do_matchinfo_test 4.2.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} } +do_matchinfo_p_test 4.2.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} } do_matchinfo_test 4.2.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1} } do_execsql_test 4.3.0 "INSERT INTO t5 VALUES('x y [string repeat {b } 50000]')"; @@ -250,7 +260,7 @@ if 0 { do_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'} { s {2} } do_matchinfo_test 4.3.3 t5 {t5 MATCH 'a b a'} { s {3} } do_matchinfo_test 4.3.4 t5 {t5 MATCH 'a a a'} { s {3 1} } -do_matchinfo_test 4.3.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} } +do_matchinfo_p_test 4.3.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} } do_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1 1} } do_execsql_test 4.4.0.1 { INSERT INTO t5(t5) VALUES('optimize') } @@ -260,10 +270,10 @@ do_matchinfo_test 4.4.1 t5 {t5 MATCH 'a a'} { s {2 1} } do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} } do_matchinfo_test 4.4.3 t5 {t5 MATCH 'a b a'} { s {3} } do_matchinfo_test 4.4.4 t5 {t5 MATCH 'a a a'} { s {3 1} } -do_matchinfo_test 4.4.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} } +do_matchinfo_p_test 4.4.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} } do_execsql_test 4.5.0 { - CREATE VIRTUAL TABLE t6 USING fts5(a, b, c); + CREATE VIRTUAL TABLE t6 USING fts5(a, b, c, detail=%DETAIL%); INSERT INTO t6 VALUES('a', 'b', 'c'); } do_matchinfo_test 4.5.1 t6 {t6 MATCH 'a b c'} { s {{1 1 1}} } @@ -274,7 +284,7 @@ do_matchinfo_test 4.5.1 t6 {t6 MATCH 'a b c'} { s {{1 1 1}} } # use the full-text index (i.e. lookup by rowid or full-table scan). # do_execsql_test 7.1 { - CREATE VIRTUAL TABLE t10 USING fts5(content); + CREATE VIRTUAL TABLE t10 USING fts5(content, detail=%DETAIL%); INSERT INTO t10 VALUES('first record'); INSERT INTO t10 VALUES('second record'); } @@ -299,7 +309,7 @@ do_execsql_test 7.4 { # SELECT sum(length(content)) < count(*) FROM fts4table; # do_execsql_test 8.1 { - CREATE VIRTUAL TABLE t11 USING fts5(content); + CREATE VIRTUAL TABLE t11 USING fts5(content, detail=%DETAIL%); INSERT INTO t11(t11, rank) VALUES('pgsz', 32); INSERT INTO t11 VALUES('quitealongstringoftext'); INSERT INTO t11 VALUES('anotherquitealongstringoftext'); @@ -318,22 +328,24 @@ do_execsql_test 8.3 { #------------------------------------------------------------------------- -do_execsql_test 9.1 { - CREATE VIRTUAL TABLE t12 USING fts5(content); - INSERT INTO t12 VALUES('a b c d'); - SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a'; -} {{0 1 1 0 1 1 1 1 1}} -do_execsql_test 9.2 { - INSERT INTO t12 VALUES('a d c d'); - SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a'; -} { - {0 2 2 0 3 2 1 2 2} {1 2 2 1 3 2 1 2 2} -} -do_execsql_test 9.3 { - INSERT INTO t12 VALUES('a d d a'); - SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a'; -} { - {0 4 3 0 5 3 1 4 3} {1 4 3 1 5 3 1 4 3} {2 4 3 2 5 3 2 4 3} +if {[detail_is_full]} { + do_execsql_test 9.1 { + CREATE VIRTUAL TABLE t12 USING fts5(content, detail=%DETAIL%); + INSERT INTO t12 VALUES('a b c d'); + SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a'; + } {{0 1 1 0 1 1 1 1 1}} + do_execsql_test 9.2 { + INSERT INTO t12 VALUES('a d c d'); + SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a'; + } { + {0 2 2 0 3 2 1 2 2} {1 2 2 1 3 2 1 2 2} + } + do_execsql_test 9.3 { + INSERT INTO t12 VALUES('a d d a'); + SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a'; + } { + {0 4 3 0 5 3 1 4 3} {1 4 3 1 5 3 1 4 3} {2 4 3 2 5 3 2 4 3} + } } #--------------------------------------------------------------------------- @@ -341,7 +353,7 @@ do_execsql_test 9.3 { # do_execsql_test 10.1 { DROP TABLE t10; - CREATE VIRTUAL TABLE t10 USING fts5(idx, value); + CREATE VIRTUAL TABLE t10 USING fts5(idx, value, detail=%DETAIL%); INSERT INTO t10 values (1, 'one'),(2, 'two'),(3, 'three'); SELECT t10.rowid, t10.* FROM t10 @@ -358,7 +370,7 @@ do_execsql_test 10.1 { reset_db sqlite3_fts5_register_matchinfo db do_execsql_test 11.0 { - CREATE VIRTUAL TABLE tt USING fts5(x, y); + CREATE VIRTUAL TABLE tt USING fts5(x, y, detail=%DETAIL%); INSERT INTO tt VALUES('c d a c d d', 'e a g b d a'); -- 1 INSERT INTO tt VALUES('c c g a e b', 'c g d g e c'); -- 2 INSERT INTO tt VALUES('b e f d e g', 'b a c b c g'); -- 3 @@ -410,6 +422,8 @@ foreach {tn expr res} { } } { + + if {[string match *:* $expr] && [detail_is_none]} continue do_execsql_test 11.1.$tn.1 { SELECT rowid, mit(matchinfo(tt, 'y')) FROM tt WHERE tt MATCH $expr } $res @@ -443,7 +457,7 @@ db func mit mit do_test 12.0 { set cols [list] for {set i 0} {$i < 50} {incr i} { lappend cols "c$i" } - execsql "CREATE VIRTUAL TABLE tt USING fts5([join $cols ,])" + execsql "CREATE VIRTUAL TABLE tt USING fts5([join $cols ,], detail=%DETAIL%)" } {} do_execsql_test 12.1 { @@ -451,5 +465,7 @@ do_execsql_test 12.1 { SELECT mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH 'abc'; } [list [list [expr 1<<4] [expr 1<<(45-32)]]] +} ;# foreach_detail_mode + finish_test diff --git a/manifest b/manifest index ff5d797e2d..25592e2931 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\smore\sfts5\stests\sto\srun\sin\sdetail=none\sand\sdetail=column\smodes\sas\swell\sas\sthe\sdefault\sdetail=full. -D 2016-01-04T16:19:51.421 +C Fix\san\sOOM\shandling\sproblem\sin\sfts5\sdetail=none\sand\sdetail=col\smodes.\sAlso\sa\sbug\sin\sthe\sxInst()\sAPI\swhen\sused\swith\sdetail=col\sand\scolumn\sfiltering\sexpressions.\sUpdate\sthe\smatchinfo()\stest\sfunction\sso\sthat\s'b'\sis\sfast\swith\sdetail=col\stables. +D 2016-01-04T19:12:00.230 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -97,17 +97,17 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 88fec577a2148f34df75930dc2b0c45b0bad72c3 -F ext/fts5/fts5Int.h cff7dd3131ba0db6f699df97237bf993f22c1a1f +F ext/fts5/fts5Int.h 10608c346cccf7dd1da4d6b46f7921949072ed60 F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 -F ext/fts5/fts5_expr.c 898e0bb53280b2c4c2702a2dc08dec731c7b32fe +F ext/fts5/fts5_expr.c 3fe372518c0191230971321048e10930952dad5b F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 F ext/fts5/fts5_index.c 8665393f8be3ae9ed4f1033d7ce0b805108fb95c -F ext/fts5/fts5_main.c f33439bde2e1023888e9b7f16e463e42fe4c00c5 +F ext/fts5/fts5_main.c 15c8b702e28d032224a6fc2b6a9c03ba2e4deeb1 F ext/fts5/fts5_storage.c 771dd0fda3ee513e32937a386dc2a4aa2d9ea64e F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb -F ext/fts5/fts5_test_mi.c c9c8cf455c49ded156a234e0de1c8ba9be85e5c3 +F ext/fts5/fts5_test_mi.c 1ec66ffdf7632077fbd773b7a6df5153272ec070 F ext/fts5/fts5_tokenize.c 618efe033bceb80c521b1e9ddfd9fee85fb5946e F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 @@ -117,7 +117,7 @@ F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl fefb4ceb27d02b431f69045a7ac0061a80d97824 F ext/fts5/test/fts5aa.test 4abbc14eb2d9d6d46a53ab008151512871d54ebc F ext/fts5/test/fts5ab.test 30325a89453280160106be411bba3acf138e6d1b -F ext/fts5/test/fts5ac.test 9a3c5eb052a5e8c871d56d3d0f144e5fdcf075c2 +F ext/fts5/test/fts5ac.test 30707d2972e5f485f7bdef019f3041782edabfb3 F ext/fts5/test/fts5ad.test 049f7511a79c155d2d8dfd2ddcfeb640c50ad0dc F ext/fts5/test/fts5ae.test 612dcb51f4069226791ff14c17dbfb3138c56f20 F ext/fts5/test/fts5af.test be858a96b1f5de66ba6d64f0021bd8b2408e126c @@ -151,10 +151,11 @@ F ext/fts5/test/fts5fault4.test 4864f2b5c2c083440dbe85aff60897bc1aa04603 F ext/fts5/test/fts5fault5.test f2b8645053d48982e8979749e93994c43011c118 F ext/fts5/test/fts5fault6.test 9682664d679643ac6736e90c225526cc84073cda F ext/fts5/test/fts5fault7.test 01be274bfc8d9bf22451a3bf5892e9399d044f1b +F ext/fts5/test/fts5fault8.test aeb4717b7b293678bc4d2f3c0159206a525375d9 F ext/fts5/test/fts5full.test 6f6143af0c6700501d9fd597189dfab1555bb741 F ext/fts5/test/fts5hash.test 7cf4607b8657c383f0b520668a99971e95d8b139 F ext/fts5/test/fts5integrity.test 87db5d4e7da0ce04a1dcba5ba91658673c997a65 -F ext/fts5/test/fts5matchinfo.test 2163b0013e824bba65499da9e34ea4da41349cc2 +F ext/fts5/test/fts5matchinfo.test 86569026d20f1ed748236587ce798de8a96615f1 F ext/fts5/test/fts5merge.test 8f3cdba2ec9c5e7e568246e81b700ad37f764367 F ext/fts5/test/fts5near.test b214cddb1c1f1bddf45c75af768f20145f7e71cc F ext/fts5/test/fts5onepass.test 7ed9608e258132cb8d55e7c479b08676ad68810c @@ -1407,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6322a1d984e7946735bace8a069ef24b31754b3b -R 32e8694f89e6ec744ed1fb193a76a532 +P 3fcf3b1e24483b2cd1c1710f053ed8403e09106d +R 133d47de041747f0d7e918f07a474874 U dan -Z 780f62d5b61ae786fb811bd6c42602f7 +Z 4f94b859477e06c41fefb0b71cc6e55e diff --git a/manifest.uuid b/manifest.uuid index 3f2a04cfe4..1f4ad7217a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3fcf3b1e24483b2cd1c1710f053ed8403e09106d \ No newline at end of file +ee38f9dff5e9239c541515cd8a1aa3d81fdc0ae9 \ No newline at end of file From 11e3e538d672188c95430b7277b1e238533c5ee1 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 23:43:47 +0000 Subject: [PATCH 138/232] Fix a corner case in the opcode-array reuse logic where the number of bytes of reusable space might be computed to be a negative number, due to unusual system alignment restrictions and rounding error. FossilOrigin-Name: 1aa530144643582658c8c1dd66548662f950efe3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 9 ++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 1628852800..ac0852705f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sconflict2.test\smodule\swhich\swas\sbroken\sby\scheck-in\s[e30062e9f6c]. -D 2016-01-04T13:06:53.893 +C Fix\sa\scorner\scase\sin\sthe\sopcode-array\sreuse\slogic\swhere\sthe\snumber\sof\sbytes\sof\nreusable\sspace\smight\sbe\scomputed\sto\sbe\sa\snegative\snumber,\sdue\sto\sunusual\nsystem\salignment\srestrictions\sand\srounding\serror. +D 2016-01-04T23:43:47.141 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -402,7 +402,7 @@ F src/vdbe.c 6ac8e5d808d48afc369316e147c191102f0584c1 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 66b546a1da82dfa6e67985ae0442ba5fd9efe0ff +F src/vdbeaux.c 141ee231ad190240d0d1ee133c9ea28eecd55824 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7adb789f45698e5569b840d23f3f9488db3ed109 -R 16019d64036d1aa36ba8b50ba392c4e8 +P b779ca8a7580e2a0bb1176316c4540867b635229 +R 3b3e1e83b8e4867e299c87ba108024a8 U drh -Z 8bde812e449e210a56672af13ac69445 +Z b5772777614dc8e4c77919f902a0659c diff --git a/manifest.uuid b/manifest.uuid index fa6d00eef8..bc138403e1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b779ca8a7580e2a0bb1176316c4540867b635229 \ No newline at end of file +1aa530144643582658c8c1dd66548662f950efe3 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 7d547e5830..de7f482126 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1848,18 +1848,21 @@ void sqlite3VdbeMakeReady( */ nMem += nCursor; - /* Allocate space for memory registers, SQL variables, VDBE cursors and - ** an array to marshal SQL function arguments in. + /* zCsr will initially point to nFree bytes of unused space at the + ** end of the opcode array, p->aOp. The computation of nFree is + ** conservative - it might be smaller than the true number of free + ** bytes, but never larger. nFree might be negative. But the allocation + ** loop will still function correctly. */ zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ + if( nFree>0 ) memset(zCsr, 0, nFree); resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); if( pParse->explain && nMem<10 ){ nMem = 10; } - memset(zCsr, 0, nFree); assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) ); p->expired = 0; From 98486c046f1d245b5ffa1df8a850e349e4e25154 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 5 Jan 2016 01:48:29 +0000 Subject: [PATCH 139/232] Permit the 'test_fs' test module to be compiled and used on MinGW. FossilOrigin-Name: ac27f38eef7a241d56124c263d9f8c91f372a77f --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/test_fs.c | 13 +++++++++++-- test/vtabH.test | 28 ++++++---------------------- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/manifest b/manifest index ac0852705f..40d0611359 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scorner\scase\sin\sthe\sopcode-array\sreuse\slogic\swhere\sthe\snumber\sof\sbytes\sof\nreusable\sspace\smight\sbe\scomputed\sto\sbe\sa\snegative\snumber,\sdue\sto\sunusual\nsystem\salignment\srestrictions\sand\srounding\serror. -D 2016-01-04T23:43:47.141 +C Permit\sthe\s'test_fs'\stest\smodule\sto\sbe\scompiled\sand\sused\son\sMinGW. +D 2016-01-05T01:48:29.005 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -360,7 +360,7 @@ F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f F src/test_config.c 0dee90328e3dedf8ba002ee94b6a7e7ea7726fe4 F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc -F src/test_fs.c 993c7eab65bed6add4bb48cca29775e963f710cf +F src/test_fs.c a61f54247fdb843761d709879c3bcd1989b2050c F src/test_func.c 0d9c25956152adefee8881c6fadc8354793764d0 F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32 @@ -1274,7 +1274,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test 7a21f18546cb9ab38df009e718300c40b552bb2b +F test/vtabH.test 492ba03dcb7bb8fedcc53f258c410d04013adbc9 F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b779ca8a7580e2a0bb1176316c4540867b635229 -R 3b3e1e83b8e4867e299c87ba108024a8 -U drh -Z b5772777614dc8e4c77919f902a0659c +P 1aa530144643582658c8c1dd66548662f950efe3 +R 6490ec858048a3d7899751e10a44fa21 +U mistachkin +Z b205e33bbbedd23793ff52ce1287fb1d diff --git a/manifest.uuid b/manifest.uuid index bc138403e1..515a791f4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1aa530144643582658c8c1dd66548662f950efe3 \ No newline at end of file +ac27f38eef7a241d56124c263d9f8c91f372a77f \ No newline at end of file diff --git a/src/test_fs.c b/src/test_fs.c index ab6bed8a95..45db0b53b8 100644 --- a/src/test_fs.c +++ b/src/test_fs.c @@ -70,7 +70,7 @@ #include #include -#if SQLITE_OS_UNIX +#if SQLITE_OS_UNIX || defined(__MINGW_H) # include # include # ifndef DIRENT @@ -79,7 +79,9 @@ #endif #if SQLITE_OS_WIN # include -# include "test_windirent.h" +# if !defined(__MINGW_H) +# include "test_windirent.h" +# endif # ifndef S_ISREG # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) # endif @@ -231,7 +233,14 @@ static int fsdirNext(sqlite3_vtab_cursor *cur){ if( pCsr->pDir ){ struct DIRENT *pRes = 0; +#if defined(__MINGW_H) + pRes = readdir(pCsr->pDir); + if( pRes!=0 ){ + memcpy(&pCsr->entry, pRes, sizeof(struct DIRENT)); + } +#else readdir_r(pCsr->pDir, &pCsr->entry, &pRes); +#endif if( pRes==0 ){ closedir(pCsr->pDir); pCsr->pDir = 0; diff --git a/test/vtabH.test b/test/vtabH.test index c15ab87de8..7bd542e05b 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -32,12 +32,12 @@ do_execsql_test 1.0 { foreach {tn sql expect} { 1 "SELECT * FROM e6 WHERE b LIKE 'abc'" { - xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b like ?} + xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b like ?} xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} abc } 2 "SELECT * FROM e6 WHERE b GLOB 'abc'" { - xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b glob ?} + xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b glob ?} xFilter {SELECT rowid, a, b FROM 't6' WHERE b glob ?} abc } } { @@ -115,7 +115,7 @@ if {1} { SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db'; SELECT name FROM fsdir WHERE dir = '.' AND name = '.' } {test.db .} - + proc list_root_files {} { if {$::tcl_platform(platform) eq "windows"} { set res [list] @@ -142,22 +142,6 @@ if {1} { } } - # Read the first 5 entries from the root directory. Except, ignore - # files that contain the "$" character in their names as these are - # special files on some Windows platforms. - # - set res [list] - foreach p [lrange [list_root_files] 0 4] { - if {$::tcl_platform(platform) eq "windows"} { - if {![regexp {\$} $p]} {lappend res $p} - } else { - lappend res "/$p" - } - } - do_execsql_test 3.1 { - SELECT path FROM fstree WHERE path NOT GLOB '*$*' LIMIT 5; - } $res - # Read all entries in the current directory. # proc contents {pattern} { @@ -175,7 +159,7 @@ if {1} { do_execsql_test 3.2 { SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1 } [lsort $res] - + # Add some sub-directories and files to the current directory. # do_test 3.3 { @@ -183,7 +167,7 @@ if {1} { foreach {path sz} { subdir/x1.txt 143 subdir/x2.txt 153 - } { + } { set dir [file dirname $path] catch { file mkdir $dir } set fd [open $path w] @@ -191,7 +175,7 @@ if {1} { close $fd } } {} - + set pwd [pwd] do_execsql_test 3.5 { SELECT path, size FROM fstree WHERE path GLOB $pwd || '/subdir/*' ORDER BY 1 From 0816905cddf7f545301f14abf6554e30ead246cc Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Jan 2016 03:39:25 +0000 Subject: [PATCH 140/232] Another attempt to get reuse of excess opcode array space working correctly on all architectures and platforms. FossilOrigin-Name: 2f8583748abab1e15029d3a8693ba9a66c978c2b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 17 +++++++++++------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 40d0611359..c2c3d233a0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Permit\sthe\s'test_fs'\stest\smodule\sto\sbe\scompiled\sand\sused\son\sMinGW. -D 2016-01-05T01:48:29.005 +C Another\sattempt\sto\sget\sreuse\sof\sexcess\sopcode\sarray\sspace\sworking\scorrectly\non\sall\sarchitectures\sand\splatforms. +D 2016-01-05T03:39:25.682 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -402,7 +402,7 @@ F src/vdbe.c 6ac8e5d808d48afc369316e147c191102f0584c1 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 141ee231ad190240d0d1ee133c9ea28eecd55824 +F src/vdbeaux.c 3308a07a6b0b64e22e83cbcc76773eaf330b056a F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1aa530144643582658c8c1dd66548662f950efe3 -R 6490ec858048a3d7899751e10a44fa21 -U mistachkin -Z b205e33bbbedd23793ff52ce1287fb1d +P ac27f38eef7a241d56124c263d9f8c91f372a77f +R 60123ea1ef3684554ab03afc4196be5d +U drh +Z f77bc5a04736277ef260f43c3525df33 diff --git a/manifest.uuid b/manifest.uuid index 515a791f4f..ea174478b6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac27f38eef7a241d56124c263d9f8c91f372a77f \ No newline at end of file +2f8583748abab1e15029d3a8693ba9a66c978c2b \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index de7f482126..dbbb2a6ccb 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1851,19 +1851,24 @@ void sqlite3VdbeMakeReady( /* zCsr will initially point to nFree bytes of unused space at the ** end of the opcode array, p->aOp. The computation of nFree is ** conservative - it might be smaller than the true number of free - ** bytes, but never larger. nFree might be negative. But the allocation - ** loop will still function correctly. + ** bytes, but never larger. nFree must be a multiple of 8 - it is + ** rounded down if is not. */ - zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ - nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ - if( nFree>0 ) memset(zCsr, 0, nFree); + n = ROUND8(sizeof(Op)*p->nOp); /* Bytes of opcode space used */ + zCsr = &((u8*)p->aOp)[n]; /* Unused opcode space */ + assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); + nFree = ROUNDDOWN8(pParse->szOpAlloc - n); /* Bytes of unused space */ + assert( nFree>=0 ); + if( nFree>0 ){ + memset(zCsr, 0, nFree); + assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) ); + } resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); if( pParse->explain && nMem<10 ){ nMem = 10; } - assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) ); p->expired = 0; /* Memory for registers, parameters, cursor, etc, is allocated in two From 9d4c9824da4d23e1b40678f84a542ce5d93d0b97 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Jan 2016 03:39:52 +0000 Subject: [PATCH 141/232] Always use -DSQLITE_ENABLE_MEMSYS5 for fuzzcheck so that the --limit-mem option will work. FossilOrigin-Name: a855697719e288c908ddb7950d32fd17ef546509 --- Makefile.in | 2 +- Makefile.msc | 2 +- main.mk | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index d06b3ca49d..1fe49d6789 100644 --- a/Makefile.in +++ b/Makefile.in @@ -550,7 +550,7 @@ TESTOPTS = --verbose=file --output=test-out.txt # SHELL_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1 -FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 +FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. diff --git a/Makefile.msc b/Makefile.msc index aa2bd9a2f1..92561a8a32 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1218,7 +1218,7 @@ FUZZDATA = \ # SHELL_COMPILE_OPTS = -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 FUZZERSHELL_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -FUZZCHECK_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 +FUZZCHECK_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 # Standard options to testfixture # diff --git a/main.mk b/main.mk index 398bb9d149..e6ca1acbd6 100644 --- a/main.mk +++ b/main.mk @@ -460,7 +460,7 @@ TESTOPTS = --verbose=file --output=test-out.txt # SHELL_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1 -FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 +FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. diff --git a/manifest b/manifest index c2c3d233a0..2cff2948a6 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Another\sattempt\sto\sget\sreuse\sof\sexcess\sopcode\sarray\sspace\sworking\scorrectly\non\sall\sarchitectures\sand\splatforms. -D 2016-01-05T03:39:25.682 -F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d +C Always\suse\s-DSQLITE_ENABLE_MEMSYS5\sfor\sfuzzcheck\sso\sthat\sthe\s--limit-mem\noption\swill\swork. +D 2016-01-05T03:39:52.336 +F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 +F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 8b9d3ac6f1962f94e06ba05462422a544f9c4e36 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -257,7 +257,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk ed77cbb97848c8dae1ab928245432f74b0580162 +F main.mk 20e46c09ac8732a74a9e2d55e8d90257d97eb844 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ac27f38eef7a241d56124c263d9f8c91f372a77f -R 60123ea1ef3684554ab03afc4196be5d +P 2f8583748abab1e15029d3a8693ba9a66c978c2b +R 658872c8eaad4f517adfb9642371bf29 U drh -Z f77bc5a04736277ef260f43c3525df33 +Z 68ad1defdc3264df127031e5fb4da721 diff --git a/manifest.uuid b/manifest.uuid index ea174478b6..a1640cccc8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f8583748abab1e15029d3a8693ba9a66c978c2b \ No newline at end of file +a855697719e288c908ddb7950d32fd17ef546509 \ No newline at end of file From 10e1535dee1085a602c09e7847532e61057c7e4d Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 5 Jan 2016 21:04:35 +0000 Subject: [PATCH 142/232] Rationalize and extend some fts5 test code. Fix bugs revealed by the same. FossilOrigin-Name: fd217fdb396cf22278a496de0e9dec7902ba8b1f --- ext/fts5/fts5Int.h | 3 +- ext/fts5/fts5_expr.c | 34 +++- ext/fts5/fts5_main.c | 5 +- ext/fts5/test/fts5_common.tcl | 113 +++++++++++++ ext/fts5/test/fts5ac.test | 291 +++++++++++++--------------------- ext/fts5/test/fts5auto.test | 41 +---- ext/fts5/test/fts5simple.test | 21 +++ manifest | 24 +-- manifest.uuid | 2 +- 9 files changed, 299 insertions(+), 235 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index b853bb3a43..1a3d57ca26 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -643,11 +643,12 @@ int sqlite3Fts5ExprPhraseSize(Fts5Expr*, int iPhrase); int sqlite3Fts5ExprPoslist(Fts5Expr*, int, const u8 **); typedef struct Fts5PoslistPopulator Fts5PoslistPopulator; -Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*); +Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int); int sqlite3Fts5ExprPopulatePoslists( Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int ); void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64); +void sqlite3Fts5ExprClearEof(Fts5Expr*); int sqlite3Fts5ExprClonePhrase(Fts5Config*, Fts5Expr*, int, Fts5Expr**); diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index ae00a12c82..9988c557b4 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -1218,6 +1218,9 @@ static int fts5ExprNodeNextMatch( } pNode->bEof = p1->bEof; pNode->iRowid = p1->iRowid; + if( p1->bEof ){ + fts5ExprNodeZeroPoslist(p2); + } break; } } @@ -2260,9 +2263,10 @@ int sqlite3Fts5ExprPoslist(Fts5Expr *pExpr, int iPhrase, const u8 **pa){ struct Fts5PoslistPopulator { Fts5PoslistWriter writer; int bOk; /* True if ok to populate */ + int bMiss; }; -Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr){ +Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){ Fts5PoslistPopulator *pRet; pRet = sqlite3_malloc(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase); if( pRet ){ @@ -2270,8 +2274,15 @@ Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr){ memset(pRet, 0, sizeof(Fts5PoslistPopulator)*pExpr->nPhrase); for(i=0; inPhrase; i++){ Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist; + Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode; assert( pExpr->apExprPhrase[i]->nTerm==1 ); - pBuf->n = 0; + if( bLive && + (pBuf->n==0 || pNode->iRowid!=pExpr->pRoot->iRowid || pNode->bEof) + ){ + pRet[i].bMiss = 1; + }else{ + pBuf->n = 0; + } } } return pRet; @@ -2341,8 +2352,11 @@ int sqlite3Fts5ExprPopulatePoslists( sCtx.iOff = (((i64)iCol) << 32) - 1; for(i=0; inPhrase; i++){ - Fts5Colset *pColset = pExpr->apExprPhrase[i]->pNode->pNear->pColset; - if( pColset && 0==fts5ExprColsetTest(pColset, iCol) ){ + Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode; + Fts5Colset *pColset = pNode->pNear->pColset; + if( (pColset && 0==fts5ExprColsetTest(pColset, iCol)) + || aPopulator[i].bMiss + ){ aPopulator[i].bOk = 0; }else{ aPopulator[i].bOk = 1; @@ -2412,10 +2426,22 @@ static int fts5ExprCheckPoslists(Fts5ExprNode *pNode, i64 iRowid){ } } } + void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){ fts5ExprCheckPoslists(pExpr->pRoot, iRowid); } +static void fts5ExprClearEof(Fts5ExprNode *pNode){ + int i; + for(i=0; inChild; i++){ + fts5ExprClearEof(pNode->apChild[i]); + } + pNode->bEof = 0; +} +void sqlite3Fts5ExprClearEof(Fts5Expr *pExpr){ + fts5ExprClearEof(pExpr->pRoot); +} + /* ** This function is only called for detail=columns tables. */ diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 99c9eb05db..7f6f6dacef 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1179,6 +1179,7 @@ static int fts5FilterMethod( pCsr->ePlan = FTS5_PLAN_SOURCE; pCsr->pExpr = pTab->pSortCsr->pExpr; rc = fts5CursorFirst(pTab, pCsr, bDesc); + sqlite3Fts5ExprClearEof(pCsr->pExpr); }else if( pMatch ){ const char *zExpr = (const char*)sqlite3_value_text(apVal[0]); if( zExpr==0 ) zExpr = ""; @@ -1688,13 +1689,14 @@ static int fts5CsrPoslist( ){ Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig; int rc = SQLITE_OK; + int bLive = (pCsr->pSorter==0); if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){ if( pConfig->eDetail!=FTS5_DETAIL_FULL ){ Fts5PoslistPopulator *aPopulator; int i; - aPopulator = sqlite3Fts5ExprClearPoslists(pCsr->pExpr); + aPopulator = sqlite3Fts5ExprClearPoslists(pCsr->pExpr, bLive); if( aPopulator==0 ) rc = SQLITE_NOMEM; for(i=0; inCol && rc==SQLITE_OK; i++){ int n; const char *z; @@ -1706,6 +1708,7 @@ static int fts5CsrPoslist( } } sqlite3_free(aPopulator); + if( pCsr->pSorter ){ sqlite3Fts5ExprCheckPoslists(pCsr->pExpr, pCsr->pSorter->iRowid); } diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index 3bcd33dcfc..aadf148716 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -390,5 +390,118 @@ proc detail_is_col {} { detail_check ; expr {$::detail == "col" } } proc detail_is_full {} { detail_check ; expr {$::detail == "full"} } +#------------------------------------------------------------------------- +# Convert a poslist of the type returned by fts5_test_poslist() to a +# collist as returned by fts5_test_collist(). +# +proc fts5_poslist2collist {poslist} { + set res [list] + foreach h $poslist { + regexp {(.*)\.[1234567890]+} $h -> cand + lappend res $cand + } + set res [lsort -command fts5_collist_elem_compare -unique $res] + return $res +} + +# Comparison function used by fts5_poslist2collist to sort collist entries. +# +proc fts5_collist_elem_compare {a b} { + foreach {a1 a2} [split $a .] {} + foreach {b1 b2} [split $b .] {} + + if {$a1==$b1} { return [expr $a2 - $b2] } + return [expr $a1 - $b1] +} +#-------------------------------------------------------------------------- +# Construct and return a tcl list equivalent to that returned by the SQL +# query executed against database handle [db]: +# +# SELECT +# rowid, +# fts5_test_poslist($tbl), +# fts5_test_collist($tbl) +# FROM $tbl('$expr') +# ORDER BY rowid $order; +# +proc fts5_query_data {expr tbl {order ASC}} { + + # Figure out the set of columns in the FTS5 table. This routine does + # not handle tables with UNINDEXED columns, but if it did, it would + # have to be here. + db eval "PRAGMA table_info = $tbl" x { lappend lCols $x(name) } + + set cols "" + foreach e $lCols { append cols ", '$e'" } + set tclexpr [db one [subst -novar { + SELECT fts5_expr_tcl( $expr, 'nearset $cols -pc ::pc' [set cols] ) + }]] + + set res [list] + db eval "SELECT rowid, * FROM $tbl ORDER BY rowid $order" x { + set cols [list] + foreach col $lCols { lappend cols $x($col) } + + set ::pc 0 + set rowdata [eval $tclexpr] + if {$rowdata != ""} { + lappend res $x(rowid) $rowdata [fts5_poslist2collist $rowdata] + } + } + + set res +} + +#------------------------------------------------------------------------- +# Similar to [fts5_query_data], but omit the collist field. +# +proc fts5_poslist_data {expr tbl {order ASC}} { + set res [list] + foreach {rowid poslist collist} [fts5_query_data $expr $tbl $order] { + lappend res $rowid $poslist + } + set res +} + +#------------------------------------------------------------------------- +# +proc nearset_rf {aCol args} { + set idx [lsearch -exact $args --] + if {$idx != [llength $args]-2 || [llength [lindex $args end]]!=1} { + set ::expr_not_ok 1 + } + list +} + +proc nearset_rc {aCol args} { + nearset_rf $aCol {*}$args + if {[lsearch $args -col]>=0} { + set ::expr_not_ok 1 + } + list +} + +proc fts5_expr_ok {expr tbl} { + + if {![detail_is_full]} { + set nearset "nearset_rc" + if {[detail_is_col]} { set nearset "nearset_rf" } + + set ::expr_not_ok 0 + db eval "PRAGMA table_info = $tbl" x { lappend lCols $x(name) } + + set cols "" + foreach e $lCols { append cols ", '$e'" } + set ::pc 0 + set tclexpr [db one [subst -novar { + SELECT fts5_expr_tcl( $expr, '[set nearset] $cols -pc ::pc' [set cols] ) + }]] + eval $tclexpr + if {$::expr_not_ok} { return 0 } + } + + return 1 +} + diff --git a/ext/fts5/test/fts5ac.test b/ext/fts5/test/fts5ac.test index 692929167b..f53f5a4622 100644 --- a/ext/fts5/test/fts5ac.test +++ b/ext/fts5/test/fts5ac.test @@ -211,6 +211,7 @@ foreach {tn2 sql} { 1 {} 2 {BEGIN} } { +if {[detail_is_full]} continue reset_db fts5_aux_test_functions db @@ -228,191 +229,114 @@ foreach {tn2 sql} { execsql { INSERT INTO xx(xx) VALUES('integrity-check') } } {} - #------------------------------------------------------------------------- - # The following work with all detail= modes. - # - foreach {tn expr} { - 1 "a AND b" - 2 "a OR b" - 3 "o" - 4 "b q" - 5 "e a e" - 6 "m d g q q b k b w f q q p p" - 7 "l o o l v v k" - 8 "a" - 9 "b" - 10 "c" - 11 "no" - 12 "L O O L V V K" - 13 "a AND b AND c" - } { - set res [poslist_data 1 $expr] - do_execsql_test 1.$tn2.1.$tn.p.[llength $res] { - SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr - } $res - - set res [collist_data $expr] - do_execsql_test 1.$tn2.1.$tn.c.[llength $res] { - SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr - } $res - } - - if {[detail_is_none]} continue - - #------------------------------------------------------------------------- - # Queries on a specific column. - # - foreach {tn expr} { - 1.1 "x:a" - 1.2 "y:a" - 1.3 "x:b" - 1.4 "y:b" - 2.1 "{x}:a" - 2.2 "{y}:a" - 2.3 "{x}:b" - 2.4 "{y}:b" - - 3.1 "{x y}:a" - 3.2 "{y x}:a" - 3.3 "{x x}:b" - 3.4 "{y y}:b" - - 4.1 {{"x" "y"}:a} - 4.2 {{"y" x}:a} - 4.3 {{x "x"}:b} - 4.4 {{"y" y}:b} - } { - set res [poslist_data 1 $expr] - do_execsql_test 1.$tn2.4.$tn.p.[llength $res] { - SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr - } $res - - set res [collist_data $expr] - do_execsql_test 1.$tn2.4.$tn.c.[llength $res] { - SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr - } $res - } - - if {[detail_is_col]} continue - - #------------------------------------------------------------------------- - # Test phrase queries. - # - foreach {tn expr} { - 1 "b + q" - 2 "e + a + e" - 3 "m + d + g + q + q + b + k + b + w + f + q + q + p + p" - 4 "l + o + o + l + v + v + k" - 5 "L + O + O + L + V + V + K" - } { - set res [poslist_data 1 $expr] - - do_execsql_test 1.$tn2.2.$tn.p.[llength $res] { - SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr - } $res - - set res [collist_data $expr] - do_execsql_test 1.$tn2.2.$tn.c.[llength $res] { - SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr - } $res - } - - #------------------------------------------------------------------------- - # Test some AND and OR queries. - # - foreach {tn expr} { - 1.1 "a+b AND c" - 1.2 "d+c AND u" - 1.3 "d+c AND u+d" - - 2.1 "a+b OR c" - 2.2 "d+c OR u" - 2.3 "d+c OR u+d" - } { - set res [poslist_data 1 $expr] - do_execsql_test 1.$tn2.3.$tn.c.[llength $res] { - SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr - } $res - - set res [collist_data $expr] - do_execsql_test 1.$tn2.3.$tn.c.[llength $res] { - SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr - } $res - } - - #------------------------------------------------------------------------- - # Some NEAR queries. - # - foreach {tn expr} { - 1 "NEAR(a b)" - 2 "NEAR(r c)" - 2 { NEAR(r c, 5) } - 3 { NEAR(r c, 3) } - 4 { NEAR(r c, 2) } - 5 { NEAR(r c, 0) } - 6 { NEAR(a b c) } - 7 { NEAR(a b c, 8) } - 8 { x : NEAR(r c) } - 9 { y : NEAR(r c) } - } { - set res [poslist_data 1 $expr] - do_execsql_test 1.$tn2.5.1.$tn.p.[llength $res] { - SELECT rowid, fts5_test_poslist(xx) FROM xx WHERE xx match $expr - } $res - - set res [collist_data $expr] - do_execsql_test 1.$tn2.5.1.$tn.c.[llength $res] { - SELECT rowid, fts5_test_collist(xx) FROM xx WHERE xx match $expr - } $res - } - - do_test $tn2.4.1 { nearset {{a b c}} -- a } {0.0.0} - do_test $tn2.4.2 { nearset {{a b c}} -- c } {0.0.2} - - foreach {tn expr tclexpr} { - 1 {a b} {AND [N $x -- {a}] [N $x -- {b}]} - } { - do_execsql_test 1.$tn2.6.$tn { - SELECT fts5_expr_tcl($expr, 'N $x') - } [list $tclexpr] - } #------------------------------------------------------------------------- # - do_execsql_test 1.$tn2.7.integrity { + do_execsql_test 1.$tn2.integrity { INSERT INTO xx(xx) VALUES('integrity-check'); } - #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM xx_data} {puts $r} - foreach {bAsc sql} { - 1 {SELECT rowid FROM xx WHERE xx MATCH $expr} - 0 {SELECT rowid FROM xx WHERE xx MATCH $expr ORDER BY rowid DESC} + + #------------------------------------------------------------------------- + # + foreach {tn expr} { + 1.2 "a OR b" + 1.1 "a AND b" + 1.3 "o" + 1.4 "b q" + 1.5 "e a e" + 1.6 "m d g q q b k b w f q q p p" + 1.7 "l o o l v v k" + 1.8 "a" + 1.9 "b" + 1.10 "c" + 1.11 "no" + 1.12 "L O O L V V K" + 1.13 "a AND b AND c" + 1.14 "x:a" + + 2.1 "x:a" + 2.2 "y:a" + 2.3 "x:b" + 2.4 "y:b" + + 3.1 "{x}:a" + 3.2 "{y}:a" + 3.3 "{x}:b" + 3.4 "{y}:b" + + 4.1 "{x y}:a" + 4.2 "{y x}:a" + 4.3 "{x x}:b" + 4.4 "{y y}:b" + + 5.1 {{"x" "y"}:a} + 5.2 {{"y" x}:a} + 5.3 {{x "x"}:b} + 5.4 {{"y" y}:b} + + 6.1 "b + q" + 6.2 "e + a + e" + 6.3 "m + d + g + q + q + b + k + b + w + f + q + q + p + p" + 6.4 "l + o + o + l + v + v + k" + 6.5 "L + O + O + L + V + V + K" + + 7.1 "a+b AND c" + 7.2 "d+c AND u" + 7.3 "d+c AND u+d" + 7.4 "a+b OR c" + 7.5 "d+c OR u" + 7.6 "d+c OR u+d" + + 8.1 "NEAR(a b)" + 8.2 "NEAR(r c)" + 8.2 { NEAR(r c, 5) } + 8.3 { NEAR(r c, 3) } + 8.4 { NEAR(r c, 2) } + 8.5 { NEAR(r c, 0) } + 8.6 { NEAR(a b c) } + 8.7 { NEAR(a b c, 8) } + 8.8 { x : NEAR(r c) } + 8.9 { y : NEAR(r c) } + + 9.1 { NEAR(r c) } + 9.2 { NEAR(r c, 5) } + 9.3 { NEAR(r c, 3) } + 9.4 { NEAR(r c, 2) } + 9.5 { NEAR(r c, 0) } + 9.6 { NEAR(a b c) } + 9.7 { NEAR(a b c, 8) } + 9.8 { x : NEAR(r c) } + 9.9 { y : NEAR(r c) } + 9.10 { x : "r c" } + 9.11 { y : "r c" } + 9.12 { a AND b } + 9.13 { a AND b AND c } + 9.14a { a } + 9.14b { a OR b } + 9.15 { a OR b AND c } + 9.16 { c AND b OR a } + 9.17 { c AND (b OR a) } + 9.18 { c NOT (b OR a) } + 9.19 { (c NOT b) OR (a AND d) } } { - foreach {tn expr} { - 0.1 x - 1 { NEAR(r c) } - 2 { NEAR(r c, 5) } - 3 { NEAR(r c, 3) } - 4 { NEAR(r c, 2) } - 5 { NEAR(r c, 0) } - 6 { NEAR(a b c) } - 7 { NEAR(a b c, 8) } - 8 { x : NEAR(r c) } - 9 { y : NEAR(r c) } - 10 { x : "r c" } - 11 { y : "r c" } - 12 { a AND b } - 13 { a AND b AND c } - 14a { a } - 14b { a OR b } - 15 { a OR b AND c } - 16 { c AND b OR a } - 17 { c AND (b OR a) } - 18 { c NOT (b OR a) } - 19 { c NOT b OR a AND d } - } { - set res [poslist_data 0 $expr $bAsc] - do_execsql_test 1.$tn2.7.$bAsc.$tn.[llength $res] $sql $res + + if {[fts5_expr_ok $expr xx]==0} { + do_test 1.$tn2.$tn.OMITTED { list } [list] + continue } + + set res [fts5_query_data $expr xx] + do_execsql_test 1.$tn2.$tn.[llength $res].asc { + SELECT rowid, fts5_test_poslist(xx), fts5_test_collist(xx) + FROM xx WHERE xx match $expr + } $res + + + set res [fts5_query_data $expr xx DESC] + do_execsql_test 1.$tn2.$tn.[llength $res].desc { + SELECT rowid, fts5_test_poslist(xx), fts5_test_collist(xx) + FROM xx WHERE xx match $expr ORDER BY 1 DESC + } $res } } @@ -422,7 +346,16 @@ do_execsql_test 2.1 { SELECT fts5_expr_tcl('a AND b'); } {{AND [nearset -- {a}] [nearset -- {b}]}} -finish_test +do_test 2.2.1 { nearset {{a b c}} -- a } {0.0.0} +do_test 2.2.2 { nearset {{a b c}} -- c } {0.0.2} + +foreach {tn expr tclexpr} { + 1 {a b} {AND [N $x -- {a}] [N $x -- {b}]} +} { + do_execsql_test 2.3.$tn { + SELECT fts5_expr_tcl($expr, 'N $x') + } [list $tclexpr] +} finish_test diff --git a/ext/fts5/test/fts5auto.test b/ext/fts5/test/fts5auto.test index 6efaa9cb7c..218b3f4862 100644 --- a/ext/fts5/test/fts5auto.test +++ b/ext/fts5/test/fts5auto.test @@ -22,7 +22,6 @@ ifcapable !fts5 { return } - set data { -4026076 {n x w k b p x b n t t d s} {f j j s p j o} @@ -232,37 +231,9 @@ do_execsql_test 1.0 { fts5_aux_test_functions db -proc matchdata {expr tbl collist {order ASC}} { - - set cols "" - foreach e $collist { - append cols ", '$e'" - } - - set tclexpr [db one [subst -novar { - SELECT fts5_expr_tcl( - $expr, 'nearset $cols -pc ::pc' [set cols] - ) - }]] - set res [list] - - db eval "SELECT rowid, * FROM $tbl ORDER BY rowid $order" x { - set cols [list] - foreach col $x(*) { - if {$col != "rowid"} { lappend cols $x($col) } - } - # set cols [list $a $b $c $d $e $f] - set ::pc 0 - set rowdata [eval $tclexpr] - if {$rowdata != ""} { lappend res $x(rowid) $rowdata } - } - - set res -} - -proc do_auto_test {tn tbl cols expr} { +proc do_auto_test {tn tbl expr} { foreach order {asc desc} { - set res [matchdata $expr $tbl $cols $order] + set res [fts5_poslist_data $expr $tbl $order] set testname "$tn.[string range $order 0 0].rows=[expr [llength $res]/2]" set ::autotest_expr $expr @@ -271,8 +242,6 @@ proc do_auto_test {tn tbl cols expr} { WHERE [set tbl] MATCH $::autotest_expr ORDER BY rowid [set order] }] $res } - - } #------------------------------------------------------------------------- @@ -332,7 +301,7 @@ for {set fold 0} {$fold < 3} {incr fold} { C.1 { a OR (b AND "b c") } C.2 { a OR (b AND "z c") } } { - do_auto_test 3.$fold.$tn tt {a b c d e f} $expr + do_auto_test 3.$fold.$tn tt $expr } } @@ -366,10 +335,8 @@ foreach {tn expr} { 4 {c1 : x} 5 {c2 : x} 6 {c3 : x} 7 {c1 : y} 8 {c2 : y} 9 {c3 : y} 10 {c1 : z} 11 {c2 : z} 12 {c3 : z} - - } { - do_auto_test 4.$tn yy {c1 c2 c3} $expr + do_auto_test 4.$tn yy $expr } diff --git a/ext/fts5/test/fts5simple.test b/ext/fts5/test/fts5simple.test index 870a912bb1..e29c13117c 100644 --- a/ext/fts5/test/fts5simple.test +++ b/ext/fts5/test/fts5simple.test @@ -19,6 +19,8 @@ ifcapable !fts5 { return } + if 1 { + #------------------------------------------------------------------------- # set doc "x x [string repeat {y } 50]z z" @@ -361,5 +363,24 @@ do_execsql_test 15.1 { INSERT INTO x2(x2) VALUES('integrity-check'); } +} + +#------------------------------------------------------------------------- +foreach_detail_mode $testprefix { + reset_db + fts5_aux_test_functions db + do_execsql_test 16.0 { + CREATE VIRTUAL TABLE x3 USING fts5(x, detail=%DETAIL%); + INSERT INTO x3 VALUES('a b c d e f'); + } + do_execsql_test 16.1 { + SELECT fts5_test_poslist(x3) FROM x3('(a NOT b) OR c'); + } {2.0.2} + + do_execsql_test 16.1 { + SELECT fts5_test_poslist(x3) FROM x3('a OR c'); + } {{0.0.0 1.0.2}} +} + finish_test diff --git a/manifest b/manifest index 25592e2931..0ccb6b20cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sOOM\shandling\sproblem\sin\sfts5\sdetail=none\sand\sdetail=col\smodes.\sAlso\sa\sbug\sin\sthe\sxInst()\sAPI\swhen\sused\swith\sdetail=col\sand\scolumn\sfiltering\sexpressions.\sUpdate\sthe\smatchinfo()\stest\sfunction\sso\sthat\s'b'\sis\sfast\swith\sdetail=col\stables. -D 2016-01-04T19:12:00.230 +C Rationalize\sand\sextend\ssome\sfts5\stest\scode.\sFix\sbugs\srevealed\sby\sthe\ssame. +D 2016-01-05T21:04:35.294 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -97,14 +97,14 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 88fec577a2148f34df75930dc2b0c45b0bad72c3 -F ext/fts5/fts5Int.h 10608c346cccf7dd1da4d6b46f7921949072ed60 +F ext/fts5/fts5Int.h 3918045ebceb1d600c9c1c1b460489ff0c788e96 F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 -F ext/fts5/fts5_expr.c 3fe372518c0191230971321048e10930952dad5b +F ext/fts5/fts5_expr.c 1aa0f5d597a22789172efe138659271fccb3cf19 F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 F ext/fts5/fts5_index.c 8665393f8be3ae9ed4f1033d7ce0b805108fb95c -F ext/fts5/fts5_main.c 15c8b702e28d032224a6fc2b6a9c03ba2e4deeb1 +F ext/fts5/fts5_main.c cd5f6f0bf868a19e8f8ef01c7b4b86dd152f0bc7 F ext/fts5/fts5_storage.c 771dd0fda3ee513e32937a386dc2a4aa2d9ea64e F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb F ext/fts5/fts5_test_mi.c 1ec66ffdf7632077fbd773b7a6df5153272ec070 @@ -114,10 +114,10 @@ F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl fefb4ceb27d02b431f69045a7ac0061a80d97824 +F ext/fts5/test/fts5_common.tcl c9169fe40bf751e1b311271df31aec15732b26c0 F ext/fts5/test/fts5aa.test 4abbc14eb2d9d6d46a53ab008151512871d54ebc F ext/fts5/test/fts5ab.test 30325a89453280160106be411bba3acf138e6d1b -F ext/fts5/test/fts5ac.test 30707d2972e5f485f7bdef019f3041782edabfb3 +F ext/fts5/test/fts5ac.test 63f669ad7381b0c29556da6de41eefdbb007e810 F ext/fts5/test/fts5ad.test 049f7511a79c155d2d8dfd2ddcfeb640c50ad0dc F ext/fts5/test/fts5ae.test 612dcb51f4069226791ff14c17dbfb3138c56f20 F ext/fts5/test/fts5af.test be858a96b1f5de66ba6d64f0021bd8b2408e126c @@ -128,7 +128,7 @@ F ext/fts5/test/fts5aj.test 05b569f5c16ea3098fb1984eec5cf50dbdaae5d8 F ext/fts5/test/fts5ak.test fb26389985407826f6076bb9f382c67d3db6b5d9 F ext/fts5/test/fts5al.test 18c277f5986df0a3d9071dfd7128afeb16fe9d5d F ext/fts5/test/fts5alter.test 6022c61467a82aa11c70822ccad22b328dcf0d04 -F ext/fts5/test/fts5auto.test 2a6241673657b340427f521528f7809ddaa02a9e +F ext/fts5/test/fts5auto.test 401c20e89f1114d733b94809be1e6f893e16c09e F ext/fts5/test/fts5aux.test 8c687c948cc98e9a94be014df7d518acc1b3b74f F ext/fts5/test/fts5auxdata.test 141a7cbffcceb1bd2799b4b29c183ff8780d586e F ext/fts5/test/fts5bigpl.test 04ee0d7eebbebf17c31f5a0b5c5f9494eac3a0cb @@ -170,7 +170,7 @@ F ext/fts5/test/fts5rank.test 7e9e64eac7245637f6f2033aec4b292aaf611aab F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 -F ext/fts5/test/fts5simple.test a599b7577bc3827a9a678add3b43d8b818b93456 +F ext/fts5/test/fts5simple.test 2bc6451cbe887a9215f5b14ae307c70d850344c9 F ext/fts5/test/fts5simple2.test d453e3ca100e08078a46b12547417891b326240a F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3fcf3b1e24483b2cd1c1710f053ed8403e09106d -R 133d47de041747f0d7e918f07a474874 +P ee38f9dff5e9239c541515cd8a1aa3d81fdc0ae9 +R 6eca7a3ddda49a17d0ee2479d97ee402 U dan -Z 4f94b859477e06c41fefb0b71cc6e55e +Z 551e607b90efc1e18e4dc205bbcdae9f diff --git a/manifest.uuid b/manifest.uuid index 1f4ad7217a..49ed937a10 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ee38f9dff5e9239c541515cd8a1aa3d81fdc0ae9 \ No newline at end of file +fd217fdb396cf22278a496de0e9dec7902ba8b1f \ No newline at end of file From f062d676ef28e51ec9567cf3a4fd896005e7667b Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 Jan 2016 10:17:26 +0000 Subject: [PATCH 143/232] Fix a problem with the xPhraseFirstColumn() API in detail=col mode. Remove some unused test code from fts5ac.test. FossilOrigin-Name: a4e55f73b3c81e28b917395089c0201f9a2c9178 --- ext/fts5/fts5_expr.c | 5 ++- ext/fts5/test/fts5ac.test | 81 --------------------------------------- manifest | 14 +++---- manifest.uuid | 2 +- 4 files changed, 12 insertions(+), 90 deletions(-) diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 9988c557b4..c0dd0ec066 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -2455,7 +2455,10 @@ int sqlite3Fts5ExprPhraseCollist( Fts5ExprNode *pNode = pPhrase->pNode; assert( iPhrase>=0 && iPhrasenPhrase ); - if( pNode->bEof==0 && pNode->iRowid==pExpr->pRoot->iRowid ){ + if( pNode->bEof==0 + && pNode->iRowid==pExpr->pRoot->iRowid + && pPhrase->poslist.n>0 + ){ sqlite3Fts5IterCollist(pPhrase->aTerm[0].pIter, ppCollist, pnCollist); }else{ *ppCollist = 0; diff --git a/ext/fts5/test/fts5ac.test b/ext/fts5/test/fts5ac.test index f53f5a4622..00b1328867 100644 --- a/ext/fts5/test/fts5ac.test +++ b/ext/fts5/test/fts5ac.test @@ -127,91 +127,10 @@ set data { 99 {r c v w i v h a t a c v c r e} {h h u m g o f b a e o} } -# Argument $expr is an FTS5 match expression designed to be executed against -# an FTS5 table with the following schema: -# -# CREATE VIRTUAL TABLE xy USING fts5(x, y); -# -# Assuming the table contains the same records as stored in the global -# $::data array (see above), this function returns a list containing two -# elements for each matching row in the dataset. The first element of each -# pair is the rowid. The second is a list of phrase matches, where each -# phrase match is of the form: -# -# .. -# -# The list of phrase matches is in the same format as that returned by the -# fts5_test_poslist() auxiliary scalara function. -# -proc poslist_data {bPos expr {bAsc 1}} { - - set tclexpr [db one { - SELECT fts5_expr_tcl($expr, 'nearset $cols -pc ::pc', 'x', 'y') - }] - set res [list] - - #puts $tclexpr - foreach {id x y} $::data { - set cols [list $x $y] - set ::pc 0 - #set hits [lsort -command instcompare [eval $tclexpr]] - set hits [eval $tclexpr] - if {[llength $hits]>0} { - if {$bPos} { - lappend res [list $id $hits] - } else { - lappend res $id - } - } - } - - if {$bAsc} { - set res [lsort -integer -increasing -index 0 $res] - } else { - set res [lsort -integer -decreasing -index 0 $res] - } - - set res [concat {*}$res] - return $res -} - -proc collist_elem_compare {a b} { - foreach {a1 a2} [split $a .] {} - foreach {b1 b2} [split $b .] {} - - if {$a1==$b1} { - return [expr $a2 - $b2] - } - return [expr $a1 - $b1] -} - -proc poslist2collist {poslist} { - set res [list] - foreach h $poslist { - regexp {(.*)\.[1234567890]+} $h -> cand - lappend res $cand - } - set res [lsort -command collist_elem_compare -unique $res] - return $res -} - -proc collist_data {expr} { - set res [list] - foreach {rowid poslist} [poslist_data 1 $expr] { - lappend res $rowid [poslist2collist $poslist] - } - set res -} - -# -# End of test code -#------------------------------------------------------------------------- - foreach {tn2 sql} { 1 {} 2 {BEGIN} } { -if {[detail_is_full]} continue reset_db fts5_aux_test_functions db diff --git a/manifest b/manifest index 0ccb6b20cc..e95f7f880f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rationalize\sand\sextend\ssome\sfts5\stest\scode.\sFix\sbugs\srevealed\sby\sthe\ssame. -D 2016-01-05T21:04:35.294 +C Fix\sa\sproblem\swith\sthe\sxPhraseFirstColumn()\sAPI\sin\sdetail=col\smode.\sRemove\ssome\sunused\stest\scode\sfrom\sfts5ac.test. +D 2016-01-06T10:17:26.540 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -101,7 +101,7 @@ F ext/fts5/fts5Int.h 3918045ebceb1d600c9c1c1b460489ff0c788e96 F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 -F ext/fts5/fts5_expr.c 1aa0f5d597a22789172efe138659271fccb3cf19 +F ext/fts5/fts5_expr.c 5d5dd3044c1a39ace6ddd1034961fd5278ffce2d F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 F ext/fts5/fts5_index.c 8665393f8be3ae9ed4f1033d7ce0b805108fb95c F ext/fts5/fts5_main.c cd5f6f0bf868a19e8f8ef01c7b4b86dd152f0bc7 @@ -117,7 +117,7 @@ F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl c9169fe40bf751e1b311271df31aec15732b26c0 F ext/fts5/test/fts5aa.test 4abbc14eb2d9d6d46a53ab008151512871d54ebc F ext/fts5/test/fts5ab.test 30325a89453280160106be411bba3acf138e6d1b -F ext/fts5/test/fts5ac.test 63f669ad7381b0c29556da6de41eefdbb007e810 +F ext/fts5/test/fts5ac.test d5073ca7bd2d9fe8aab0c82c6c75a7e4b0d70ced F ext/fts5/test/fts5ad.test 049f7511a79c155d2d8dfd2ddcfeb640c50ad0dc F ext/fts5/test/fts5ae.test 612dcb51f4069226791ff14c17dbfb3138c56f20 F ext/fts5/test/fts5af.test be858a96b1f5de66ba6d64f0021bd8b2408e126c @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ee38f9dff5e9239c541515cd8a1aa3d81fdc0ae9 -R 6eca7a3ddda49a17d0ee2479d97ee402 +P fd217fdb396cf22278a496de0e9dec7902ba8b1f +R fb939ae0b5d34f9dd8275713b2d3d9d0 U dan -Z 551e607b90efc1e18e4dc205bbcdae9f +Z ffed0e3dee313fbcc0c638ddfdf4d418 diff --git a/manifest.uuid b/manifest.uuid index 49ed937a10..57c2bbbbf5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd217fdb396cf22278a496de0e9dec7902ba8b1f \ No newline at end of file +a4e55f73b3c81e28b917395089c0201f9a2c9178 \ No newline at end of file From 02a59fab74794a70fe3e41744c646467067bcdb0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Jan 2016 11:01:07 +0000 Subject: [PATCH 144/232] Version 3.10.0 FossilOrigin-Name: fd0a50f0797d154fefff724624f00548b5320566 --- manifest | 11 +++++++---- manifest.uuid | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/manifest b/manifest index 2cff2948a6..84ab4c9e57 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Always\suse\s-DSQLITE_ENABLE_MEMSYS5\sfor\sfuzzcheck\sso\sthat\sthe\s--limit-mem\noption\swill\swork. -D 2016-01-05T03:39:52.336 +C Version\s3.10.0 +D 2016-01-06T11:01:07.739 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -1406,7 +1406,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2f8583748abab1e15029d3a8693ba9a66c978c2b +P a855697719e288c908ddb7950d32fd17ef546509 R 658872c8eaad4f517adfb9642371bf29 +T +bgcolor * #d0c0ff +T +sym-release * +T +sym-version-3.10.0 * U drh -Z 68ad1defdc3264df127031e5fb4da721 +Z 024a1b2bbd235a427c0ebcd39a99300a diff --git a/manifest.uuid b/manifest.uuid index a1640cccc8..01d9768cad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a855697719e288c908ddb7950d32fd17ef546509 \ No newline at end of file +fd0a50f0797d154fefff724624f00548b5320566 \ No newline at end of file From 8d52c3b7671b478c744b05dd3d8f0ccde8fb135f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Jan 2016 15:54:53 +0000 Subject: [PATCH 145/232] Disable the --limit-mem option on fuzzcheck unless the SQLITE_ENABLE_MEMSYS5 or SQLITE_ENABLE_MEMSYS3 compile-time options are used. FossilOrigin-Name: 55a11fd627eaf046b3783622b2925399a50a65b4 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- test/fuzzcheck.c | 5 +++++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 84ab4c9e57..d238fa51c2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.10.0 -D 2016-01-06T11:01:07.739 +C Disable\sthe\s--limit-mem\soption\son\sfuzzcheck\sunless\sthe\sSQLITE_ENABLE_MEMSYS5\sor\nSQLITE_ENABLE_MEMSYS3\scompile-time\soptions\sare\sused. +D 2016-01-06T15:54:53.139 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -749,7 +749,7 @@ F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1 F test/fuzz3.test 53fabcd5f0f430f8b221282f6c12c4d0903c21eb F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26 -F test/fuzzcheck.c ccdcdc28579b2c9744696bca8726bdbd729eea11 +F test/fuzzcheck.c 3309d793165ca61a9996271cb799694839348f9a F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664 F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -1406,10 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a855697719e288c908ddb7950d32fd17ef546509 -R 658872c8eaad4f517adfb9642371bf29 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.10.0 * +P fd0a50f0797d154fefff724624f00548b5320566 +R 87a59d21671d8eb854da54e44c1cb06d U drh -Z 024a1b2bbd235a427c0ebcd39a99300a +Z 6b66decd394482c2ac340e90e8473c2f diff --git a/manifest.uuid b/manifest.uuid index 01d9768cad..6cc9954870 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd0a50f0797d154fefff724624f00548b5320566 \ No newline at end of file +55a11fd627eaf046b3783622b2925399a50a65b4 \ No newline at end of file diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index 6d9c745528..03776f1e70 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -865,8 +865,13 @@ int main(int argc, char **argv){ return 0; }else if( strcmp(z,"limit-mem")==0 ){ +#if !defined(SQLITE_ENABLE_MEMSYS3) && !defined(SQLITE_ENABLE_MEMSYS5) + fatalError("the %s option requires -DSQLITE_ENABLE_MEMSYS5 or _MEMSYS3", + argv[i]); +#else if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); nMem = integerValue(argv[++i]); +#endif }else if( strcmp(z,"limit-vdbe")==0 ){ vdbeLimitFlag = 1; From 4364e5c9f760cc6335cc49de9257e1de8c7e1424 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 Jan 2016 18:53:57 +0000 Subject: [PATCH 146/232] Fix an fts5 problem involving detail=none, "ORDER BY rowid DESC" and deleted items. Also add tests to verify that the documented operator precedences are correct. FossilOrigin-Name: 8d05cfd48db1462dfd3efd502d53bd33214403fb --- ext/fts5/fts5_index.c | 8 ++++---- ext/fts5/test/fts5dlidx.test | 25 +++++++++++++----------- ext/fts5/test/fts5eb.test | 9 +++++++++ ext/fts5/test/fts5simple2.test | 35 ++++++++++++++++++++++++++++++++-- manifest | 18 ++++++++--------- manifest.uuid | 2 +- 6 files changed, 70 insertions(+), 27 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 49d8638f33..ef673085c6 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -1764,14 +1764,14 @@ static void fts5SegIterNext( i64 iDelta; pIter->iRowidOffset--; - pIter->iLeafOffset = iOff = pIter->aRowidOffset[pIter->iRowidOffset]; + pIter->iLeafOffset = pIter->aRowidOffset[pIter->iRowidOffset]; + fts5SegIterLoadNPos(p, pIter); + iOff = pIter->iLeafOffset; if( p->pConfig->eDetail!=FTS5_DETAIL_NONE ){ - iOff += fts5GetPoslistSize(&a[iOff], &nPos, &bDummy); - iOff += nPos; + iOff += pIter->nPos; } fts5GetVarint(&a[iOff], (u64*)&iDelta); pIter->iRowid -= iDelta; - fts5SegIterLoadNPos(p, pIter); }else{ fts5SegIterReverseNewPage(p, pIter); } diff --git a/ext/fts5/test/fts5dlidx.test b/ext/fts5/test/fts5dlidx.test index 5a03c6989b..232b5021f1 100644 --- a/ext/fts5/test/fts5dlidx.test +++ b/ext/fts5/test/fts5dlidx.test @@ -26,7 +26,7 @@ if { $tcl_platform(wordSize)<8 } { return } -if 1 { +foreach_detail_mode $testprefix { proc do_fb_test {tn sql res} { set res2 [lsort -integer -decr $res] @@ -34,7 +34,7 @@ proc do_fb_test {tn sql res} { uplevel [list do_execsql_test $tn.2 "$sql ORDER BY rowid DESC" $res2] } -# This test populates the FTS5 table containing $nEntry entries. Rows are +# This test populates the FTS5 table with $nEntry entries. Rows are # numbered from 0 to ($nEntry-1). The rowid for row $i is: # # ($iFirst + $i*$nStep) @@ -77,10 +77,12 @@ proc do_dlidx_test1 {tn spc1 spc2 nEntry iFirst nStep} { do_fb_test $tn.4.1 { SELECT rowid FROM t1 WHERE t1 MATCH 'a AND y' } $ydoc do_fb_test $tn.4.2 { SELECT rowid FROM t1 WHERE t1 MATCH 'y AND a' } $ydoc - do_fb_test $tn.5.1 { - SELECT rowid FROM t1 WHERE t1 MATCH 'a + b + c + x' } $xdoc - do_fb_test $tn.5.2 { - SELECT rowid FROM t1 WHERE t1 MATCH 'b + c + x + y' } $ydoc + if {[detail_is_full]} { + do_fb_test $tn.5.1 { + SELECT rowid FROM t1 WHERE t1 MATCH 'a + b + c + x' } $xdoc + do_fb_test $tn.5.2 { + SELECT rowid FROM t1 WHERE t1 MATCH 'b + c + x + y' } $ydoc + } } @@ -90,7 +92,7 @@ foreach {tn pgsz} { } { do_execsql_test $tn.0 { DROP TABLE IF EXISTS t1; - CREATE VIRTUAL TABLE t1 USING fts5(x); + CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', $pgsz); } @@ -107,7 +109,7 @@ proc do_dlidx_test2 {tn nEntry iFirst nStep} { execsql { BEGIN; DROP TABLE IF EXISTS t1; - CREATE VIRTUAL TABLE t1 USING fts5(x); + CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 64); INSERT INTO t1 VALUES('b a'); @@ -130,8 +132,6 @@ proc do_dlidx_test2 {tn nEntry iFirst nStep} { do_dlidx_test2 2.1 [expr 20] [expr 1<<57] [expr (1<<57) + 128] -} - #-------------------------------------------------------------------- # reset_db @@ -158,7 +158,7 @@ proc rnddoc {} { db func rnddoc rnddoc do_execsql_test 3.1 { - CREATE VIRTUAL TABLE abc USING fts5(a); + CREATE VIRTUAL TABLE abc USING fts5(a, detail=%DETAIL%); INSERT INTO abc(abc, rank) VALUES('pgsz', 32); INSERT INTO abc VALUES ( rnddoc() ); @@ -192,6 +192,9 @@ foreach v $vocab { } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} } +} ;# foreach_detail_mode + + finish_test diff --git a/ext/fts5/test/fts5eb.test b/ext/fts5/test/fts5eb.test index 55c4b15cf3..8205396047 100644 --- a/ext/fts5/test/fts5eb.test +++ b/ext/fts5/test/fts5eb.test @@ -42,6 +42,15 @@ foreach {tn expr res} { 10 {abc + "" + def} {"abc" + "def"} 11 {abc "" def} {"abc" AND "def"} 12 {r+e OR w} {"r" + "e" OR "w"} + + 13 {a AND b NOT c} {"a" AND ("b" NOT "c")} + 14 {a OR b NOT c} {"a" OR ("b" NOT "c")} + 15 {a NOT b AND c} {("a" NOT "b") AND "c"} + 16 {a NOT b OR c} {("a" NOT "b") OR "c"} + + 17 {a AND b OR c} {("a" AND "b") OR "c"} + 18 {a OR b AND c} {"a" OR ("b" AND "c")} + } { do_execsql_test 1.$tn {SELECT fts5_expr($expr)} [list $res] } diff --git a/ext/fts5/test/fts5simple2.test b/ext/fts5/test/fts5simple2.test index bb76250e9f..c61970e154 100644 --- a/ext/fts5/test/fts5simple2.test +++ b/ext/fts5/test/fts5simple2.test @@ -254,8 +254,6 @@ foreach {rowid a} { } } -} - #------------------------------------------------------------------------- # reset_db @@ -269,5 +267,38 @@ do_execsql_test 14.1 { SELECT fts5_test_poslist(t1) FROM t1('b') ORDER BY rank; } {0.0.1} +} + +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 15.1 { + CREATE VIRTUAL TABLE t1 USING fts5(x, detail=none); + BEGIN; + INSERT INTO t1(rowid, x) VALUES(1, 'sqlite'); + INSERT INTO t1(rowid, x) VALUES(2, 'sqlite'); + COMMIT; +} {} + +do_test 15.1 { + execsql { INSERT INTO t1(t1) VALUES('integrity-check') } +} {} + +do_test 15.2 { + execsql { DELETE FROM t1 } +} {} + +do_execsql_test 15.3.1 { + SELECT rowid FROM t1('sqlite'); +} {} + +do_execsql_test 15.3.2 { + SELECT rowid FROM t1('sqlite') ORDER BY rowid DESC; +} {} + +do_test 15.4 { + execsql { INSERT INTO t1(t1) VALUES('integrity-check') } +} {} + finish_test diff --git a/manifest b/manifest index e95f7f880f..39b91273fa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sthe\sxPhraseFirstColumn()\sAPI\sin\sdetail=col\smode.\sRemove\ssome\sunused\stest\scode\sfrom\sfts5ac.test. -D 2016-01-06T10:17:26.540 +C Fix\san\sfts5\sproblem\sinvolving\sdetail=none,\s"ORDER\sBY\srowid\sDESC"\sand\sdeleted\sitems.\sAlso\sadd\stests\sto\sverify\sthat\sthe\sdocumented\soperator\sprecedences\sare\scorrect. +D 2016-01-06T18:53:57.055 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -103,7 +103,7 @@ F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 F ext/fts5/fts5_expr.c 5d5dd3044c1a39ace6ddd1034961fd5278ffce2d F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 -F ext/fts5/fts5_index.c 8665393f8be3ae9ed4f1033d7ce0b805108fb95c +F ext/fts5/fts5_index.c 04fe098ffab66d9424ba4e7c0b88ce7c98748cb1 F ext/fts5/fts5_main.c cd5f6f0bf868a19e8f8ef01c7b4b86dd152f0bc7 F ext/fts5/fts5_storage.c 771dd0fda3ee513e32937a386dc2a4aa2d9ea64e F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb @@ -140,10 +140,10 @@ F ext/fts5/test/fts5corrupt.test c2ad090192708150d50d961278df10ae7a4b8b62 F ext/fts5/test/fts5corrupt2.test 26c0a39dd9ff73207e6229f83b50b21d37c7658c F ext/fts5/test/fts5corrupt3.test a2b537c120bdd43c79c42fe2438d7b8c81fe5599 F ext/fts5/test/fts5detail.test 4e971d28e7336c61ab916fc287900355dab7054d -F ext/fts5/test/fts5dlidx.test ecba5e62ea8b26c33829961602069c546228046d +F ext/fts5/test/fts5dlidx.test 13871a14641017ae42f6f1055a8067bafd44cb3d F ext/fts5/test/fts5doclist.test 8edb5b57e5f144030ed74ec00ef6fa4294fed79b F ext/fts5/test/fts5ea.test b01e3a18cdfabbff8104a96a5242a06a68a998a0 -F ext/fts5/test/fts5eb.test 3e5869af2008cbc4ad03a175a0b6f6e58134cd43 +F ext/fts5/test/fts5eb.test 021aa80b7ac09b964249aa32ced9ee908703e4aa F ext/fts5/test/fts5fault1.test 4b39c47ca3544615daa8a2f733b911fa08022c77 F ext/fts5/test/fts5fault2.test 28c36c843bb39ae855ba79827417ecc37f114341 F ext/fts5/test/fts5fault3.test d6e9577d4312e331a913c72931bf131704efc8f3 @@ -171,7 +171,7 @@ F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 F ext/fts5/test/fts5simple.test 2bc6451cbe887a9215f5b14ae307c70d850344c9 -F ext/fts5/test/fts5simple2.test d453e3ca100e08078a46b12547417891b326240a +F ext/fts5/test/fts5simple2.test 843f1f7fe439ff32bf74f4fd6430632f9636ef3a F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 F ext/fts5/test/fts5unicode.test fbef8d8a3b4b88470536cc57604a82ca52e51841 @@ -1408,7 +1408,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fd217fdb396cf22278a496de0e9dec7902ba8b1f -R fb939ae0b5d34f9dd8275713b2d3d9d0 +P a4e55f73b3c81e28b917395089c0201f9a2c9178 +R 0d0b45c96327e08ac49c0cd0bf01187b U dan -Z ffed0e3dee313fbcc0c638ddfdf4d418 +Z 1ffb33ee956b9f5de9322a26ad6982ed diff --git a/manifest.uuid b/manifest.uuid index 57c2bbbbf5..1b603ff0f2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a4e55f73b3c81e28b917395089c0201f9a2c9178 \ No newline at end of file +8d05cfd48db1462dfd3efd502d53bd33214403fb \ No newline at end of file From 7c230dd99c1395982a9a4b75d6b4ef2eb75c3f77 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 6 Jan 2016 19:43:26 +0000 Subject: [PATCH 147/232] Fix a test script problem caused by a change in constraint handling within the core. FossilOrigin-Name: 625695b3d7d4eae7536b5f761b96cd7519ac6ada --- ext/fts5/test/fts5aa.test | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/fts5/test/fts5aa.test b/ext/fts5/test/fts5aa.test index e00bcfcdcc..fdcf08398d 100644 --- a/ext/fts5/test/fts5aa.test +++ b/ext/fts5/test/fts5aa.test @@ -424,11 +424,11 @@ do_execsql_test 16.1 { } proc funk {} { + db eval { UPDATE n1_config SET v=50 WHERE k='version' } set fd [db incrblob main n1_data block 10] fconfigure $fd -encoding binary -translation binary puts -nonewline $fd "\x44\x45" close $fd - db eval { UPDATE n1_config SET v=50 WHERE k='version' } } db func funk funk diff --git a/manifest b/manifest index b6ae4ac818..efcebbdb14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\slatest\strunk\schanges\sinto\sthis\sbranch. -D 2016-01-06T19:35:52.285 +C Fix\sa\stest\sscript\sproblem\scaused\sby\sa\schange\sin\sconstraint\shandling\swithin\sthe\score. +D 2016-01-06T19:43:26.257 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -115,7 +115,7 @@ F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl c9169fe40bf751e1b311271df31aec15732b26c0 -F ext/fts5/test/fts5aa.test 4abbc14eb2d9d6d46a53ab008151512871d54ebc +F ext/fts5/test/fts5aa.test 7e814df4a0e6c22a6fe2d84f210fdc0b5068a084 F ext/fts5/test/fts5ab.test 30325a89453280160106be411bba3acf138e6d1b F ext/fts5/test/fts5ac.test d5073ca7bd2d9fe8aab0c82c6c75a7e4b0d70ced F ext/fts5/test/fts5ad.test 049f7511a79c155d2d8dfd2ddcfeb640c50ad0dc @@ -1409,7 +1409,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8d05cfd48db1462dfd3efd502d53bd33214403fb 55a11fd627eaf046b3783622b2925399a50a65b4 -R cf1317de6526e81224b7c381ca0d373b +P e7dcd013516723941c2fb78ecdc96806d49d310b +R dce0c272fbae692a97296955b7b2c775 U dan -Z 2530c4785808f691eed775076fac89d0 +Z 318fda862dd5c3483c784e4e425f0506 diff --git a/manifest.uuid b/manifest.uuid index d32e744eb2..298843ae92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e7dcd013516723941c2fb78ecdc96806d49d310b \ No newline at end of file +625695b3d7d4eae7536b5f761b96cd7519ac6ada \ No newline at end of file From 72bf6a3e9c45ef8e60336bf1e7d1ed64254b0677 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Jan 2016 02:06:55 +0000 Subject: [PATCH 148/232] Add the "sqlite3 -sourceid" command in the TCL interface. Use that command and others to output additional information about the test configuration at the conclusion of a TCL test. FossilOrigin-Name: 4f80440bf566959306f6ca8cbb1fd29d138ee38b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/tclsqlite.c | 4 ++++ test/tester.tcl | 8 +++++++- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d238fa51c2..c28c217ff1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\s--limit-mem\soption\son\sfuzzcheck\sunless\sthe\sSQLITE_ENABLE_MEMSYS5\sor\nSQLITE_ENABLE_MEMSYS3\scompile-time\soptions\sare\sused. -D 2016-01-06T15:54:53.139 +C Add\sthe\s"sqlite3\s-sourceid"\scommand\sin\sthe\sTCL\sinterface.\s\sUse\sthat\scommand\sand\nothers\sto\soutput\sadditional\sinformation\sabout\sthe\stest\sconfiguration\sat\sthe\s\nconclusion\sof\sa\sTCL\stest. +D 2016-01-07T02:06:55.894 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -342,7 +342,7 @@ F src/sqliteInt.h f97614d43833bae0ed6c51ac8e550f0099a1d0ba F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e -F src/tclsqlite.c d9439b6a910985b7fff43ba6756bcef00de22649 +F src/tclsqlite.c 82979239a896992f9b78efec81cfda05d316a7d0 F src/test1.c 4f1b42699068b7806af3111786f5ad760c2c1ff7 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c a8887dabbbee3059af338f20d290084a63ed1b0f @@ -1061,7 +1061,7 @@ F test/tclsqlite.test 7fb866443c7deceed22b63948ccd6f76b52ad054 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 -F test/tester.tcl 9df86ab273a0877ffb4ec26c255166dcdca4c278 +F test/tester.tcl af4749cf4abf04291710c5e73f40bc8f411bae86 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fd0a50f0797d154fefff724624f00548b5320566 -R 87a59d21671d8eb854da54e44c1cb06d +P 55a11fd627eaf046b3783622b2925399a50a65b4 +R 5876235b8965be95d77913e3f4573bf2 U drh -Z 6b66decd394482c2ac340e90e8473c2f +Z dff9c340c358386729bbf7e0fd3fe53f diff --git a/manifest.uuid b/manifest.uuid index 6cc9954870..d73c6cc5df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -55a11fd627eaf046b3783622b2925399a50a65b4 \ No newline at end of file +4f80440bf566959306f6ca8cbb1fd29d138ee38b \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index f024317e90..604e898265 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -2976,6 +2976,10 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ Tcl_AppendResult(interp,sqlite3_libversion(), (char*)0); return TCL_OK; } + if( strcmp(zArg,"-sourceid")==0 ){ + Tcl_AppendResult(interp,sqlite3_sourceid(), (char*)0); + return TCL_OK; + } if( strcmp(zArg,"-has-codec")==0 ){ #ifdef SQLITE_HAS_CODEC Tcl_AppendResult(interp,"1",(char*)0); diff --git a/test/tester.tcl b/test/tester.tcl index 4008a34491..426808ea90 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -1028,7 +1028,13 @@ proc finalize_testing {} { output2 "[expr {$nErr-$nKnown}] new errors and $nKnown known errors\ out of $nTest tests" } else { - output2 "$nErr errors out of $nTest tests" + set cpuinfo {} + if {[catch {exec hostname} hname]==0} {set cpuinfo [string trim $hname]} + append cpuinfo " $::tcl_platform(os)" + append cpuinfo " [expr {$::tcl_platform(pointerSize)*8}]-bit" + append cpuinfo " [string map {E -e} $::tcl_platform(byteOrder)]" + output2 "SQLite [sqlite3 -sourceid]" + output2 "$nErr errors out of $nTest tests on $cpuinfo" } if {$nErr>$nKnown} { output2 -nonewline "!Failures on these tests:" From 20d876fa1ca9d4ec471e68e2f5b0743b906b8ea2 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Jan 2016 16:06:22 +0000 Subject: [PATCH 149/232] Have the vdbe layer call sqlite3BtreeEnter() on all b-trees in use from within sqlite3VdbeExec() even in SQLITE_THREADSAFE=0 builds. This ensures that BtShared.db is set correctly. FossilOrigin-Name: d0214602d44d6b84b7463d530720e2560aee6edf --- manifest | 25 ++++++++++++++----------- manifest.uuid | 2 +- src/btmutex.c | 42 +++++++++++++++++++----------------------- src/btree.c | 7 +++++++ src/btree.h | 8 ++++---- src/vdbeInt.h | 8 ++++++-- src/vdbeaux.c | 2 +- 7 files changed, 52 insertions(+), 42 deletions(-) diff --git a/manifest b/manifest index c28c217ff1..0594e8504c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"sqlite3\s-sourceid"\scommand\sin\sthe\sTCL\sinterface.\s\sUse\sthat\scommand\sand\nothers\sto\soutput\sadditional\sinformation\sabout\sthe\stest\sconfiguration\sat\sthe\s\nconclusion\sof\sa\sTCL\stest. -D 2016-01-07T02:06:55.894 +C Have\sthe\svdbe\slayer\scall\ssqlite3BtreeEnter()\son\sall\sb-trees\sin\suse\sfrom\swithin\ssqlite3VdbeExec()\seven\sin\sSQLITE_THREADSAFE=0\sbuilds.\sThis\sensures\sthat\sBtShared.db\sis\sset\scorrectly. +D 2016-01-07T16:06:22.102 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -275,9 +275,9 @@ F src/attach.c e944d0052b577703b9b83aac1638452ff42a8395 F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf -F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 4d3452b2a3daf875490ac4f0a278da7f85fabe12 -F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 +F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 +F src/btree.c d40cbcd254c7d716f9b233a87b69f6dc00b18290 +F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 F src/build.c d8006e9030c61b9495d0b2f724edd3fcdae16930 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 @@ -400,9 +400,9 @@ F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 F src/vdbe.c 6ac8e5d808d48afc369316e147c191102f0584c1 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 -F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d +F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 3308a07a6b0b64e22e83cbcc76773eaf330b056a +F src/vdbeaux.c 5d8c7c04e0f677033efb1292248a5f9056bbc34c F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,7 +1406,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 55a11fd627eaf046b3783622b2925399a50a65b4 -R 5876235b8965be95d77913e3f4573bf2 -U drh -Z dff9c340c358386729bbf7e0fd3fe53f +P 4f80440bf566959306f6ca8cbb1fd29d138ee38b +R 1d753fbc081495ae319f7ae5aa1679d6 +T *branch * shared-cache-fix +T *sym-shared-cache-fix * +T -sym-trunk * +U dan +Z 04b02aac85ad706faabaa5003739b07e diff --git a/manifest.uuid b/manifest.uuid index d73c6cc5df..a0f83ff884 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f80440bf566959306f6ca8cbb1fd29d138ee38b \ No newline at end of file +d0214602d44d6b84b7463d530720e2560aee6edf \ No newline at end of file diff --git a/src/btmutex.c b/src/btmutex.c index c9c8572dfb..c1ebff9604 100644 --- a/src/btmutex.c +++ b/src/btmutex.c @@ -169,21 +169,6 @@ int sqlite3BtreeHoldsMutex(Btree *p){ #endif -#ifndef SQLITE_OMIT_INCRBLOB -/* -** Enter and leave a mutex on a Btree given a cursor owned by that -** Btree. These entry points are used by incremental I/O and can be -** omitted if that module is not used. -*/ -void sqlite3BtreeEnterCursor(BtCursor *pCur){ - sqlite3BtreeEnter(pCur->pBtree); -} -void sqlite3BtreeLeaveCursor(BtCursor *pCur){ - sqlite3BtreeLeave(pCur->pBtree); -} -#endif /* SQLITE_OMIT_INCRBLOB */ - - /* ** Enter the mutex on every Btree associated with a database ** connection. This is needed (for example) prior to parsing @@ -217,14 +202,6 @@ void sqlite3BtreeLeaveAll(sqlite3 *db){ } } -/* -** Return true if a particular Btree requires a lock. Return FALSE if -** no lock is ever required since it is not sharable. -*/ -int sqlite3BtreeSharable(Btree *p){ - return p->sharable; -} - #ifndef NDEBUG /* ** Return true if the current thread holds the database connection @@ -298,4 +275,23 @@ void sqlite3BtreeEnterAll(sqlite3 *db){ } } #endif /* if SQLITE_THREADSAFE */ + +#ifndef SQLITE_OMIT_INCRBLOB +/* +** Enter a mutex on a Btree given a cursor owned by that Btree. +** +** These entry points are used by incremental I/O only. Enter() is required +** any time OMIT_SHARED_CACHE is not defined, regardless of whether or not +** the build is threadsafe. Leave() is only required by threadsafe builds. +*/ +void sqlite3BtreeEnterCursor(BtCursor *pCur){ + sqlite3BtreeEnter(pCur->pBtree); +} +# if SQLITE_THREADSAFE +void sqlite3BtreeLeaveCursor(BtCursor *pCur){ + sqlite3BtreeLeave(pCur->pBtree); +} +# endif +#endif /* ifndef SQLITE_OMIT_INCRBLOB */ + #endif /* ifndef SQLITE_OMIT_SHARED_CACHE */ diff --git a/src/btree.c b/src/btree.c index f5feff8a4c..e9393a47c8 100644 --- a/src/btree.c +++ b/src/btree.c @@ -9671,3 +9671,10 @@ int sqlite3BtreeIsReadonly(Btree *p){ ** Return the size of the header added to each page by this module. */ int sqlite3HeaderSizeBtree(void){ return ROUND8(sizeof(MemPage)); } + +/* +** Return true if the Btree passed as the only argument is sharable. +*/ +int sqlite3BtreeSharable(Btree *p){ + return p->sharable; +} diff --git a/src/btree.h b/src/btree.h index 09b713f3db..2f398e7bba 100644 --- a/src/btree.h +++ b/src/btree.h @@ -287,15 +287,17 @@ void sqlite3BtreeCursorList(Btree*); #ifndef SQLITE_OMIT_SHARED_CACHE void sqlite3BtreeEnter(Btree*); void sqlite3BtreeEnterAll(sqlite3*); + int sqlite3BtreeSharable(Btree*); + void sqlite3BtreeEnterCursor(BtCursor*); #else # define sqlite3BtreeEnter(X) # define sqlite3BtreeEnterAll(X) +# define sqlite3BtreeSharable(X) 0 +# define sqlite3BtreeEnterCursor(X) #endif #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE - int sqlite3BtreeSharable(Btree*); void sqlite3BtreeLeave(Btree*); - void sqlite3BtreeEnterCursor(BtCursor*); void sqlite3BtreeLeaveCursor(BtCursor*); void sqlite3BtreeLeaveAll(sqlite3*); #ifndef NDEBUG @@ -306,9 +308,7 @@ void sqlite3BtreeCursorList(Btree*); #endif #else -# define sqlite3BtreeSharable(X) 0 # define sqlite3BtreeLeave(X) -# define sqlite3BtreeEnterCursor(X) # define sqlite3BtreeLeaveCursor(X) # define sqlite3BtreeLeaveAll(X) diff --git a/src/vdbeInt.h b/src/vdbeInt.h index d1de55eb1c..b231cf908e 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -489,11 +489,15 @@ int sqlite3VdbeSorterRewind(const VdbeCursor *, int *); int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *); int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *); -#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0 +#if !defined(SQLITE_OMIT_SHARED_CACHE) void sqlite3VdbeEnter(Vdbe*); - void sqlite3VdbeLeave(Vdbe*); #else # define sqlite3VdbeEnter(X) +#endif + +#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0 + void sqlite3VdbeLeave(Vdbe*); +#else # define sqlite3VdbeLeave(X) #endif diff --git a/src/vdbeaux.c b/src/vdbeaux.c index dbbb2a6ccb..aa8070a132 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1317,7 +1317,7 @@ void sqlite3VdbeUsesBtree(Vdbe *p, int i){ } } -#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0 +#if !defined(SQLITE_OMIT_SHARED_CACHE) /* ** If SQLite is compiled to support shared-cache mode and to be threadsafe, ** this routine obtains the mutex associated with each BtShared structure From 7a2347e20b750f60f1d042ea418398d75c28bb20 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Jan 2016 16:43:54 +0000 Subject: [PATCH 150/232] Add some assert() statements to verify, where possible, that BtShared.db is set correctly. FossilOrigin-Name: 359277e0e5338f6d7743d58cf99e1c934a8460d5 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/btree.c | 42 +++++++++++++++++++++++------------------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index 0594e8504c..6af226d61c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sthe\svdbe\slayer\scall\ssqlite3BtreeEnter()\son\sall\sb-trees\sin\suse\sfrom\swithin\ssqlite3VdbeExec()\seven\sin\sSQLITE_THREADSAFE=0\sbuilds.\sThis\sensures\sthat\sBtShared.db\sis\sset\scorrectly. -D 2016-01-07T16:06:22.102 +C Add\ssome\sassert()\sstatements\sto\sverify,\swhere\spossible,\sthat\sBtShared.db\sis\sset\scorrectly. +D 2016-01-07T16:43:54.695 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -276,7 +276,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c d40cbcd254c7d716f9b233a87b69f6dc00b18290 +F src/btree.c 09ec3ca5e7a6b8c277cef6c4471a1427cab5fa01 F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 F src/build.c d8006e9030c61b9495d0b2f724edd3fcdae16930 @@ -1406,10 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4f80440bf566959306f6ca8cbb1fd29d138ee38b -R 1d753fbc081495ae319f7ae5aa1679d6 -T *branch * shared-cache-fix -T *sym-shared-cache-fix * -T -sym-trunk * +P d0214602d44d6b84b7463d530720e2560aee6edf +R d2d125340e47dee2c161777b81c6bca6 U dan -Z 04b02aac85ad706faabaa5003739b07e +Z cf8789ac325f523b3a85068e24d5a916 diff --git a/manifest.uuid b/manifest.uuid index a0f83ff884..0775299b73 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d0214602d44d6b84b7463d530720e2560aee6edf \ No newline at end of file +359277e0e5338f6d7743d58cf99e1c934a8460d5 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index e9393a47c8..5c60364a6b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -450,6 +450,10 @@ static void releasePage(MemPage *pPage); /* Forward reference */ static int cursorHoldsMutex(BtCursor *p){ return sqlite3_mutex_held(p->pBt->mutex); } +static int cursorOwnsBtShared(BtCursor *p){ + assert( cursorHoldsMutex(p) ); + return (p->pBtree->db==p->pBt->db); +} #endif /* @@ -786,7 +790,7 @@ static int btreeMoveto( static int btreeRestoreCursorPosition(BtCursor *pCur){ int rc; int skipNext; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pCur->eState>=CURSOR_REQUIRESEEK ); if( pCur->eState==CURSOR_FAULT ){ return pCur->skipNext; @@ -4286,7 +4290,7 @@ int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){ ** to return an integer result code for historical reasons. */ int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){ - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pCur->eState==CURSOR_VALID ); assert( pCur->iPage>=0 ); assert( pCur->iPageeState==CURSOR_VALID ); @@ -4704,7 +4708,7 @@ static const void *fetchPayload( assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]); assert( pCur->eState==CURSOR_VALID ); assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pCur->aiIdx[pCur->iPage]apPage[pCur->iPage]->nCell ); assert( pCur->info.nSize>0 ); assert( pCur->info.pPayload>pCur->apPage[pCur->iPage]->aData || CORRUPT_DB ); @@ -4750,7 +4754,7 @@ const void *sqlite3BtreeDataFetch(BtCursor *pCur, u32 *pAmt){ static int moveToChild(BtCursor *pCur, u32 newPgno){ BtShared *pBt = pCur->pBt; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pCur->eState==CURSOR_VALID ); assert( pCur->iPageiPage>=0 ); @@ -4796,7 +4800,7 @@ static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){ ** the largest cell index. */ static void moveToParent(BtCursor *pCur){ - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pCur->eState==CURSOR_VALID ); assert( pCur->iPage>0 ); assert( pCur->apPage[pCur->iPage] ); @@ -4836,7 +4840,7 @@ static int moveToRoot(BtCursor *pCur){ MemPage *pRoot; int rc = SQLITE_OK; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( CURSOR_INVALID < CURSOR_REQUIRESEEK ); assert( CURSOR_VALID < CURSOR_REQUIRESEEK ); assert( CURSOR_FAULT > CURSOR_REQUIRESEEK ); @@ -4915,7 +4919,7 @@ static int moveToLeftmost(BtCursor *pCur){ int rc = SQLITE_OK; MemPage *pPage; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pCur->eState==CURSOR_VALID ); while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){ assert( pCur->aiIdx[pCur->iPage]nCell ); @@ -4940,7 +4944,7 @@ static int moveToRightmost(BtCursor *pCur){ int rc = SQLITE_OK; MemPage *pPage = 0; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pCur->eState==CURSOR_VALID ); while( !(pPage = pCur->apPage[pCur->iPage])->leaf ){ pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]); @@ -4961,7 +4965,7 @@ static int moveToRightmost(BtCursor *pCur){ int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){ int rc; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); rc = moveToRoot(pCur); if( rc==SQLITE_OK ){ @@ -4984,7 +4988,7 @@ int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){ int sqlite3BtreeLast(BtCursor *pCur, int *pRes){ int rc; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); /* If the cursor already points to the last entry, this is a no-op. */ @@ -5062,7 +5066,7 @@ int sqlite3BtreeMovetoUnpacked( int rc; RecordCompare xRecordCompare; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); assert( pRes ); assert( (pIdxKey==0)==(pCur->pKeyInfo==0) ); @@ -5310,7 +5314,7 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur, int *pRes){ int idx; MemPage *pPage; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID ); assert( *pRes==0 ); if( pCur->eState!=CURSOR_VALID ){ @@ -5374,7 +5378,7 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur, int *pRes){ } int sqlite3BtreeNext(BtCursor *pCur, int *pRes){ MemPage *pPage; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pRes!=0 ); assert( *pRes==0 || *pRes==1 ); assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID ); @@ -5419,7 +5423,7 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur, int *pRes){ int rc; MemPage *pPage; - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pRes!=0 ); assert( *pRes==0 ); assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID ); @@ -5475,7 +5479,7 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur, int *pRes){ return rc; } int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){ - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pRes!=0 ); assert( *pRes==0 || *pRes==1 ); assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID ); @@ -7955,7 +7959,7 @@ int sqlite3BtreeInsert( return pCur->skipNext; } - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( (pCur->curFlags & BTCF_WriteFlag)!=0 && pBt->inTransaction==TRANS_WRITE && (pBt->btsFlags & BTS_READ_ONLY)==0 ); @@ -8102,7 +8106,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, int bPreserve){ u16 szCell; /* Size of the cell being deleted */ int bSkipnext = 0; /* Leaf cursor in SKIPNEXT state */ - assert( cursorHoldsMutex(pCur) ); + assert( cursorOwnsBtShared(pCur) ); assert( pBt->inTransaction==TRANS_WRITE ); assert( (pBt->btsFlags & BTS_READ_ONLY)==0 ); assert( pCur->curFlags & BTCF_WriteFlag ); @@ -9564,7 +9568,7 @@ int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){ */ int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){ int rc; - assert( cursorHoldsMutex(pCsr) ); + assert( cursorOwnsBtShared(pCsr) ); assert( sqlite3_mutex_held(pCsr->pBtree->db->mutex) ); assert( pCsr->curFlags & BTCF_Incrblob ); From 8549d55ead7e8bc5cb68b563bf3f7bfccd799dcf Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Jan 2016 17:09:43 +0000 Subject: [PATCH 151/232] Small performance and size optimization spotted while working on the shared-cache problem. FossilOrigin-Name: 828958ff77a5c239d55302f570077835c093e0fa --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/build.c | 9 --------- src/parse.y | 6 +++--- src/sqliteInt.h | 1 - 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index c28c217ff1..b3a7209f04 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"sqlite3\s-sourceid"\scommand\sin\sthe\sTCL\sinterface.\s\sUse\sthat\scommand\sand\nothers\sto\soutput\sadditional\sinformation\sabout\sthe\stest\sconfiguration\sat\sthe\s\nconclusion\sof\sa\sTCL\stest. -D 2016-01-07T02:06:55.894 +C Small\sperformance\sand\ssize\soptimization\sspotted\swhile\sworking\son\sthe\nshared-cache\sproblem. +D 2016-01-07T17:09:43.631 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -279,7 +279,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 4d3452b2a3daf875490ac4f0a278da7f85fabe12 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 -F src/build.c d8006e9030c61b9495d0b2f724edd3fcdae16930 +F src/build.c 9d497ff4bf3c82cecb520436e0e9963785627583 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -322,7 +322,7 @@ F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 58d2593612acb6b542de6715b4af397ea1fa0a35 F src/pager.h bf25005b4656cd805af43487c3139fca9678d0cc -F src/parse.y 23737e649c26ce327603799e57f5c2ff50e5e6ba +F src/parse.y caad1e98edeca6960493d0c60d31b76820dd7776 F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 F src/pcache.h 1ff11adce609ba7de139b6abfabaf9a2bac947b5 F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051 @@ -338,7 +338,7 @@ F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h f97614d43833bae0ed6c51ac8e550f0099a1d0ba +F src/sqliteInt.h 987b46b1d8089155caecbdb14b78850ae1e198ff F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 55a11fd627eaf046b3783622b2925399a50a65b4 -R 5876235b8965be95d77913e3f4573bf2 +P 4f80440bf566959306f6ca8cbb1fd29d138ee38b +R f265718df82e1345668e0777962739f6 U drh -Z dff9c340c358386729bbf7e0fd3fe53f +Z e6c791f6b7ef0a212def33d53e341994 diff --git a/manifest.uuid b/manifest.uuid index d73c6cc5df..64d2588352 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f80440bf566959306f6ca8cbb1fd29d138ee38b \ No newline at end of file +828958ff77a5c239d55302f570077835c093e0fa \ No newline at end of file diff --git a/src/build.c b/src/build.c index 63e3004657..6aac454172 100644 --- a/src/build.c +++ b/src/build.c @@ -24,15 +24,6 @@ */ #include "sqliteInt.h" -/* -** This routine is called when a new SQL statement is beginning to -** be parsed. Initialize the pParse structure as needed. -*/ -void sqlite3BeginParse(Parse *pParse, int explainFlag){ - pParse->explain = (u8)explainFlag; - pParse->nVar = 0; -} - #ifndef SQLITE_OMIT_SHARED_CACHE /* ** The TableLock structure is only used by the sqlite3TableLock() and diff --git a/src/parse.y b/src/parse.y index 6ac2be21f2..d6a587a2c8 100644 --- a/src/parse.y +++ b/src/parse.y @@ -114,10 +114,10 @@ cmdlist ::= cmdlist ecmd. cmdlist ::= ecmd. ecmd ::= SEMI. ecmd ::= explain cmdx SEMI. -explain ::= . { sqlite3BeginParse(pParse, 0); } +explain ::= . %ifndef SQLITE_OMIT_EXPLAIN -explain ::= EXPLAIN. { sqlite3BeginParse(pParse, 1); } -explain ::= EXPLAIN QUERY PLAN. { sqlite3BeginParse(pParse, 2); } +explain ::= EXPLAIN. { pParse->explain = 1; } +explain ::= EXPLAIN QUERY PLAN. { pParse->explain = 2; } %endif SQLITE_OMIT_EXPLAIN cmdx ::= cmd. { sqlite3FinishCoding(pParse); } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c01bbc7869..0fbc7f6cc7 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3340,7 +3340,6 @@ void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); void sqlite3ResetAllSchemasOfConnection(sqlite3*); void sqlite3ResetOneSchema(sqlite3*,int); void sqlite3CollapseDatabaseArray(sqlite3*); -void sqlite3BeginParse(Parse*,int); void sqlite3CommitInternalChanges(sqlite3*); void sqlite3DeleteColumnNames(sqlite3*,Table*); int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**); From 2598b833f06bbf6f8184ea74110ccd427fc8795c Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Jan 2016 20:07:41 +0000 Subject: [PATCH 152/232] Update the fts5vocab module to work with detail=col and detail=none tables. FossilOrigin-Name: eedd095dc1c81ce45df00093ba237dd7b3cdff3d --- ext/fts5/fts5_vocab.c | 86 +++++++++++++++++++++++---------- ext/fts5/test/fts5vocab.test | 92 ++++++++++++++++++++++++++---------- manifest | 14 +++--- manifest.uuid | 2 +- 4 files changed, 134 insertions(+), 60 deletions(-) diff --git a/ext/fts5/fts5_vocab.c b/ext/fts5/fts5_vocab.c index 860cfedb9b..2ed10b7cdb 100644 --- a/ext/fts5/fts5_vocab.c +++ b/ext/fts5/fts5_vocab.c @@ -379,7 +379,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ if( pTab->eType==FTS5_VOCAB_COL ){ for(pCsr->iCol++; pCsr->iColiCol++){ - if( pCsr->aCnt[pCsr->iCol] ) break; + if( pCsr->aDoc[pCsr->iCol] ) break; } } @@ -412,24 +412,52 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ i64 iPos = 0; /* 64-bit position read from poslist */ int iOff = 0; /* Current offset within position list */ - rc = sqlite3Fts5IterPoslist(pCsr->pIter, 0, &pPos, &nPos, &dummy); - if( rc==SQLITE_OK ){ - if( pTab->eType==FTS5_VOCAB_ROW ){ - while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ - pCsr->aCnt[0]++; - } - pCsr->aDoc[0]++; - }else{ - int iCol = -1; - while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ - int ii = FTS5_POS2COLUMN(iPos); - pCsr->aCnt[ii]++; - if( iCol!=ii ){ - pCsr->aDoc[ii]++; - iCol = ii; + switch( pCsr->pConfig->eDetail ){ + case FTS5_DETAIL_FULL: + rc = sqlite3Fts5IterPoslist(pCsr->pIter, 0, &pPos, &nPos, &dummy); + if( rc==SQLITE_OK ){ + if( pTab->eType==FTS5_VOCAB_ROW ){ + while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ + pCsr->aCnt[0]++; + } + pCsr->aDoc[0]++; + }else{ + int iCol = -1; + while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ + int ii = FTS5_POS2COLUMN(iPos); + pCsr->aCnt[ii]++; + if( iCol!=ii ){ + pCsr->aDoc[ii]++; + iCol = ii; + } + } } } - } + break; + + case FTS5_DETAIL_COLUMNS: + if( pTab->eType==FTS5_VOCAB_ROW ){ + pCsr->aDoc[0]++; + }else{ + Fts5Buffer buf = {0, 0, 0}; + rc = sqlite3Fts5IterPoslistBuffer(pCsr->pIter, &buf); + if( rc==SQLITE_OK ){ + while( 0==sqlite3Fts5PoslistNext64(buf.p, buf.n, &iOff,&iPos) ){ + assert_nc( iPos>=0 && iPosaDoc[iPos]++; + } + } + sqlite3Fts5BufferFree(&buf); + } + break; + + default: + assert( pCsr->pConfig->eDetail==FTS5_DETAIL_NONE ); + pCsr->aDoc[0]++; + break; + } + + if( rc==SQLITE_OK ){ rc = sqlite3Fts5IterNextScan(pCsr->pIter); } @@ -445,7 +473,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ } if( pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){ - while( pCsr->aCnt[pCsr->iCol]==0 ) pCsr->iCol++; + while( pCsr->aDoc[pCsr->iCol]==0 ) pCsr->iCol++; assert( pCsr->iColpConfig->nCol ); } return rc; @@ -525,30 +553,36 @@ static int fts5VocabColumnMethod( int iCol /* Index of column to read value from */ ){ Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; + int eDetail = pCsr->pConfig->eDetail; + int eType = ((Fts5VocabTable*)(pCursor->pVtab))->eType; + i64 iVal = 0; if( iCol==0 ){ sqlite3_result_text( pCtx, (const char*)pCsr->term.p, pCsr->term.n, SQLITE_TRANSIENT ); - } - else if( ((Fts5VocabTable*)(pCursor->pVtab))->eType==FTS5_VOCAB_COL ){ + }else if( eType==FTS5_VOCAB_COL ){ assert( iCol==1 || iCol==2 || iCol==3 ); if( iCol==1 ){ - const char *z = pCsr->pConfig->azCol[pCsr->iCol]; - sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC); + if( eDetail!=FTS5_DETAIL_NONE ){ + const char *z = pCsr->pConfig->azCol[pCsr->iCol]; + sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC); + } }else if( iCol==2 ){ - sqlite3_result_int64(pCtx, pCsr->aDoc[pCsr->iCol]); + iVal = pCsr->aDoc[pCsr->iCol]; }else{ - sqlite3_result_int64(pCtx, pCsr->aCnt[pCsr->iCol]); + iVal = pCsr->aCnt[pCsr->iCol]; } }else{ assert( iCol==1 || iCol==2 ); if( iCol==1 ){ - sqlite3_result_int64(pCtx, pCsr->aDoc[0]); + iVal = pCsr->aDoc[0]; }else{ - sqlite3_result_int64(pCtx, pCsr->aCnt[0]); + iVal = pCsr->aCnt[0]; } } + + if( iVal>0 ) sqlite3_result_int64(pCtx, iVal); return SQLITE_OK; } diff --git a/ext/fts5/test/fts5vocab.test b/ext/fts5/test/fts5vocab.test index dc5099c6e3..1f5fa91663 100644 --- a/ext/fts5/test/fts5vocab.test +++ b/ext/fts5/test/fts5vocab.test @@ -21,9 +21,44 @@ ifcapable !fts5 { return } +foreach_detail_mode $testprefix { + +if {[detail_is_none]} continue + +proc null_list_entries {iFirst nInterval L} { + for {set i $iFirst} {$i < [llength $L]} {incr i $nInterval} { + lset L $i {} + } + return $L +} + +proc null_insert {iFirst nInterval L} { + for {set i $iFirst} {$i < [llength $L]} {incr i $nInterval} { + lset L $i {} + } + return $L +} + +proc star_from_row {L} { + if {[detail_is_full]==0} { + set L [null_list_entries 2 3 $L] + } + return $L +} + +proc star_from_col {L} { + if {[detail_is_col]} { + set L [null_list_entries 3 4 $L] + } + if {[detail_is_none]} { + set L [null_list_entries 1 4 $L] + set L [null_list_entries 3 4 $L] + } + return $L +} do_execsql_test 1.1.1 { - CREATE VIRTUAL TABLE t1 USING fts5(one, prefix=1); + CREATE VIRTUAL TABLE t1 USING fts5(one, prefix=1, detail=%DETAIL%); CREATE VIRTUAL TABLE v1 USING fts5vocab(t1, 'row'); PRAGMA table_info = v1; } { @@ -52,32 +87,32 @@ do_execsql_test 1.3 { do_execsql_test 1.4.1 { SELECT * FROM v1; -} {x 2 4 y 1 1 z 1 1} +} [star_from_row {x 2 4 y 1 1 z 1 1}] do_execsql_test 1.4.2 { SELECT * FROM v2; -} {x one 2 4 y one 1 1 z one 1 1} +} [star_from_col {x one 2 4 y one 1 1 z one 1 1}] do_execsql_test 1.5.1 { BEGIN; INSERT INTO t1 VALUES('a b c'); SELECT * FROM v1 WHERE term<'d'; -} {a 1 1 b 1 1 c 1 1} +} [star_from_row {a 1 1 b 1 1 c 1 1}] do_execsql_test 1.5.2 { SELECT * FROM v2 WHERE term<'d'; COMMIT; -} {a one 1 1 b one 1 1 c one 1 1} +} [star_from_col {a one 1 1 b one 1 1 c one 1 1}] do_execsql_test 1.6 { DELETE FROM t1 WHERE one = 'a b c'; SELECT * FROM v1; -} {x 2 4 y 1 1 z 1 1} +} [star_from_row {x 2 4 y 1 1 z 1 1}] #------------------------------------------------------------------------- # do_execsql_test 2.0 { - CREATE VIRTUAL TABLE tt USING fts5(a, b); + CREATE VIRTUAL TABLE tt USING fts5(a, b, detail=%DETAIL%); INSERT INTO tt VALUES('d g b f d f', 'f c e c d a'); INSERT INTO tt VALUES('f a e a a b', 'e d c f d d'); INSERT INTO tt VALUES('b c a a a b', 'f f c c b c'); @@ -90,7 +125,12 @@ do_execsql_test 2.0 { INSERT INTO tt VALUES('c c a a c f', 'd g a e b g'); } -set res_col { +set res_row [star_from_row { + a 10 20 b 9 14 c 9 20 d 9 19 + e 8 13 f 10 20 g 7 14 x 1 1 + y 1 1 +}] +set res_col [star_from_col { a a 6 11 a b 7 9 b a 6 7 b b 7 7 c a 6 12 c b 5 8 @@ -99,12 +139,7 @@ set res_col { f a 9 10 f b 7 10 g a 5 7 g b 5 7 x a 1 1 y b 1 1 -} -set res_row { - a 10 20 b 9 14 c 9 20 d 9 19 - e 8 13 f 10 20 g 7 14 x 1 1 - y 1 1 -} +}] foreach {tn tbl resname} { 1 "fts5vocab(tt, 'col')" res_col @@ -153,9 +188,9 @@ reset_db forcedelete test.db2 do_execsql_test 5.0 { ATTACH 'test.db2' AS aux; - CREATE VIRTUAL TABLE t1 USING fts5(x); - CREATE VIRTUAL TABLE temp.t1 USING fts5(x); - CREATE VIRTUAL TABLE aux.t1 USING fts5(x); + CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%); + CREATE VIRTUAL TABLE temp.t1 USING fts5(x, detail=%DETAIL%); + CREATE VIRTUAL TABLE aux.t1 USING fts5(x, detail=%DETAIL%); INSERT INTO main.t1 VALUES('a b c'); INSERT INTO main.t1 VALUES('d e f'); @@ -178,18 +213,18 @@ do_execsql_test 5.1 { CREATE VIRTUAL TABLE temp.va USING fts5vocab(aux, t1, row); } -do_execsql_test 5.2 { SELECT * FROM vm } { +do_execsql_test 5.2 { SELECT * FROM vm } [star_from_row { a 2 2 b 1 1 c 2 2 d 1 1 e 2 2 f 1 1 -} -do_execsql_test 5.3 { SELECT * FROM vt1 } { +}] +do_execsql_test 5.3 { SELECT * FROM vt1 } [star_from_row { 1 2 2 2 1 1 3 2 2 4 1 1 5 2 2 6 1 1 -} -do_execsql_test 5.4 { SELECT * FROM vt2 } { +}] +do_execsql_test 5.4 { SELECT * FROM vt2 } [star_from_row { 1 2 2 2 1 1 3 2 2 4 1 1 5 2 2 6 1 1 -} -do_execsql_test 5.5 { SELECT * FROM va } { +}] +do_execsql_test 5.5 { SELECT * FROM va } [star_from_row { m 1 1 n 2 2 o 1 1 x 2 2 y 1 1 z 2 2 -} +}] #------------------------------------------------------------------------- # @@ -218,7 +253,7 @@ do_catchsql_test 6.2 { # constraints in the WHERE clause). # do_execsql_test 7.0 { - CREATE VIRTUAL TABLE tx USING fts5(one, two); + CREATE VIRTUAL TABLE tx USING fts5(one, two, detail=%DETAIL%); INSERT INTO tx VALUES('g a ggg g a b eee', 'cc d aa ff g ee'); INSERT INTO tx VALUES('dd fff i a i jjj', 'f fff hh jj e f'); INSERT INTO tx VALUES('ggg a f f fff dd aa', 'd ggg f f j gg ddd'); @@ -276,6 +311,9 @@ foreach {term} { if {[lindex $r2 2]==0} {set r2 [list]} set resc [concat $r1 $r2] + + set resc [star_from_col $resc] + set resr [star_from_row $resr] do_execsql_test 7.$term.1 {SELECT * FROM txc WHERE term=$term} $resc do_execsql_test 7.$term.2 {SELECT * FROM txr WHERE term=$term} $resr } @@ -345,5 +383,7 @@ do_execsql_test 7.3.2 { WHERE txc.term = txc_c.term AND txc.col=txc_c.col; } {57} +} + finish_test diff --git a/manifest b/manifest index efcebbdb14..d860431936 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stest\sscript\sproblem\scaused\sby\sa\schange\sin\sconstraint\shandling\swithin\sthe\score. -D 2016-01-06T19:43:26.257 +C Update\sthe\sfts5vocab\smodule\sto\swork\swith\sdetail=col\sand\sdetail=none\stables. +D 2016-01-07T20:07:41.638 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -111,7 +111,7 @@ F ext/fts5/fts5_test_mi.c 1ec66ffdf7632077fbd773b7a6df5153272ec070 F ext/fts5/fts5_tokenize.c 504984ac6993323247221eebe3cd55bead01b5f8 F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 -F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 +F ext/fts5/fts5_vocab.c da64ecbd217625980a1721fbd588a1e4118a51b6 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl c9169fe40bf751e1b311271df31aec15732b26c0 @@ -179,7 +179,7 @@ F ext/fts5/test/fts5unicode2.test c1dd890ba32b7609adba78e420faa847abe43b59 F ext/fts5/test/fts5unicode3.test 35c3d02aa7acf7d43d8de3bfe32c15ba96e8928e F ext/fts5/test/fts5unindexed.test e9539d5b78c677315e7ed8ea911d4fd25437c680 F ext/fts5/test/fts5version.test 978f59541d8cef7e8591f8be2115ec5ccb863e2e -F ext/fts5/test/fts5vocab.test c88a5554d0409494da95ba647bbdb4879b2624b0 +F ext/fts5/test/fts5vocab.test f4ff3ba4036a83678f2a8ba8b89eb303bebc122e F ext/fts5/tool/fts5txt2db.tcl c374c4c4797e8cdfadabdfaeeb5412dcd6686e84 F ext/fts5/tool/loadfts5.tcl 4cc2d6af43b58d4fac05bc4fdabd0e5862c3b2c1 F ext/fts5/tool/mkfts5c.tcl d1c2a9ab8e0ec690a52316f33dd9b1d379942f45 @@ -1409,7 +1409,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e7dcd013516723941c2fb78ecdc96806d49d310b -R dce0c272fbae692a97296955b7b2c775 +P 625695b3d7d4eae7536b5f761b96cd7519ac6ada +R 276342437a8f737c3f32b7f1a4e61d27 U dan -Z 318fda862dd5c3483c784e4e425f0506 +Z 8c87f6adf59add172dd12da497a3ce1f diff --git a/manifest.uuid b/manifest.uuid index 298843ae92..46d1607a71 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -625695b3d7d4eae7536b5f761b96cd7519ac6ada \ No newline at end of file +eedd095dc1c81ce45df00093ba237dd7b3cdff3d \ No newline at end of file From c9d6d1b67b4a3c140437f1a48045efab65357958 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 7 Jan 2016 21:12:40 +0000 Subject: [PATCH 153/232] Omit performance tracking from the memsys5 memory allocator if neither SQLITE_DEBUG nor SQLITE_TEST are defined. FossilOrigin-Name: af5c7714e993f060841f1e893f754ddf3870e6d0 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/mem5.c | 16 +++++++++++++--- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 1f5fbe7bdd..fbb4b40d59 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sto\scause\sBtShared.db\sto\sbe\sset\scorrectly\son\sshared-cache\nconnections\sin\sSQLITE_THREADSAFE=0\sbuilds.\s\sAdded\sassert()s\sto\sverify\nthe\scorrect\ssetting\sof\sBtShared.db. -D 2016-01-07T17:19:24.484 +C Omit\sperformance\stracking\sfrom\sthe\smemsys5\smemory\sallocator\sif\sneither\nSQLITE_DEBUG\snor\sSQLITE_TEST\sare\sdefined. +D 2016-01-07T21:12:40.900 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -304,7 +304,7 @@ F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a -F src/mem5.c 262055c242fa7db59c5f07ad77fdc4e97888c054 +F src/mem5.c 71f81a11fc5e29a57428761ab38a7bf2ef4ee19d F src/memjournal.c 3eb2c0b51adbd869cb6a44780323f05fa904dc85 F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c @@ -1406,8 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 828958ff77a5c239d55302f570077835c093e0fa 359277e0e5338f6d7743d58cf99e1c934a8460d5 -R 6a20a209200c5a1c13b83cee78194e2e -T +closed 359277e0e5338f6d7743d58cf99e1c934a8460d5 +P 2d96aeba2460779a0a20356739a0ba49144c8a85 +R 0f87ccc97eed432e32f05b109bfdb1a7 U drh -Z 1846b22def634146b1c38f34bfdda1cc +Z 9752f7a1ad4b146c9e3d9fcb5efbd790 diff --git a/manifest.uuid b/manifest.uuid index d6aa2d2612..9cc6b8eedd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2d96aeba2460779a0a20356739a0ba49144c8a85 \ No newline at end of file +af5c7714e993f060841f1e893f754ddf3870e6d0 \ No newline at end of file diff --git a/src/mem5.c b/src/mem5.c index 49bebca093..7316a630a6 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -102,6 +102,7 @@ static SQLITE_WSD struct Mem5Global { */ sqlite3_mutex *mutex; +#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) /* ** Performance statistics */ @@ -113,6 +114,7 @@ static SQLITE_WSD struct Mem5Global { u32 maxOut; /* Maximum instantaneous currentOut */ u32 maxCount; /* Maximum instantaneous currentCount */ u32 maxRequest; /* Largest allocation (exclusive of internal frag) */ +#endif /* ** Lists of free blocks. aiFreelist[0] is a list of free blocks of @@ -224,14 +226,17 @@ static void *memsys5MallocUnsafe(int nByte){ /* nByte must be a positive */ assert( nByte>0 ); + /* No more than 1GiB per allocation */ + if( nByte > 0x40000000 ) return 0; + +#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) /* Keep track of the maximum allocation request. Even unfulfilled ** requests are counted */ if( (u32)nByte>mem5.maxRequest ){ - /* Abort if the requested allocation size is larger than the largest - ** power of two that we can represent using 32-bit signed integers. */ - if( nByte > 0x40000000 ) return 0; mem5.maxRequest = nByte; } +#endif + /* Round nByte up to the next valid power of two */ for(iFullSz=mem5.szAtom,iLogsize=0; iFullSz0 ); assert( mem5.currentOut>=(size*mem5.szAtom) ); mem5.currentCount--; mem5.currentOut -= size*mem5.szAtom; assert( mem5.currentOut>0 || mem5.currentCount==0 ); assert( mem5.currentCount>0 || mem5.currentOut==0 ); +#endif mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize; while( ALWAYS(iLogsize Date: Fri, 8 Jan 2016 02:27:01 +0000 Subject: [PATCH 154/232] Add the experimental SQLITE_FCNTL_JOURNAL_POINTER file control for obtaining the sqlite3_file pointer associated with a rollback journal or WAL file. FossilOrigin-Name: a02ace9a746ff02fc1a5969bf13939b568624f93 --- manifest | 25 ++++++++++++++----------- manifest.uuid | 2 +- src/main.c | 3 +++ src/pager.c | 8 ++++++++ src/pager.h | 1 + src/sqlite.h.in | 1 + src/wal.c | 6 ++++++ src/wal.h | 4 ++++ 8 files changed, 38 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index fbb4b40d59..183b7bbcf7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sperformance\stracking\sfrom\sthe\smemsys5\smemory\sallocator\sif\sneither\nSQLITE_DEBUG\snor\sSQLITE_TEST\sare\sdefined. -D 2016-01-07T21:12:40.900 +C Add\sthe\sexperimental\sSQLITE_FCNTL_JOURNAL_POINTER\sfile\scontrol\sfor\sobtaining\nthe\ssqlite3_file\spointer\sassociated\swith\sa\srollback\sjournal\sor\sWAL\sfile. +D 2016-01-08T02:27:01.544 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -298,7 +298,7 @@ F src/insert.c 6b45cc86967da11aa024d034745f93f66d53f650 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b -F src/main.c b9641a4f650230bfc5dbb0bebf7b33ff4d27586a +F src/main.c 6d589f27980c4aec014ae9a081d611e7e5ebc115 F src/malloc.c 8f787669e79de26efc42272b5797bc00fff527c6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -320,8 +320,8 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 0ca6d8710366fbb01a275160f018334cd347cbda F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 58d2593612acb6b542de6715b4af397ea1fa0a35 -F src/pager.h bf25005b4656cd805af43487c3139fca9678d0cc +F src/pager.c 5dda328a9a5e9405b6971d62d0d5e3ea85c6195a +F src/pager.h 1c2a49143dfba9e69cc8159ef019f472ed8d260b F src/parse.y caad1e98edeca6960493d0c60d31b76820dd7776 F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 F src/pcache.h 1ff11adce609ba7de139b6abfabaf9a2bac947b5 @@ -335,7 +335,7 @@ F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 -F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 +F src/sqlite.h.in f18858fc9440fd3c399b733057d12c53a2360d11 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d F src/sqliteInt.h 987b46b1d8089155caecbdb14b78850ae1e198ff @@ -409,8 +409,8 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 974928c988681c5157202c79dd9f26afaa7b5086 -F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b +F src/wal.c 407f6f3929aeeb360f53a9279342940fe79823e1 +F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c c6d3d2f6af57d574a7365ee2b225a5024f2a6bec F src/whereInt.h 78b6b4de94db84aecbdc07fe3e38f648eb391e9a @@ -1406,7 +1406,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2d96aeba2460779a0a20356739a0ba49144c8a85 -R 0f87ccc97eed432e32f05b109bfdb1a7 +P af5c7714e993f060841f1e893f754ddf3870e6d0 +R 1ed70ce93210d32572be9b1ea5c549df +T *branch * file-control-journal +T *sym-file-control-journal * +T -sym-trunk * U drh -Z 9752f7a1ad4b146c9e3d9fcb5efbd790 +Z 34b65576034eb21a6f6ec3e5456f3b6a diff --git a/manifest.uuid b/manifest.uuid index 9cc6b8eedd..8d6b249f6a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -af5c7714e993f060841f1e893f754ddf3870e6d0 \ No newline at end of file +a02ace9a746ff02fc1a5969bf13939b568624f93 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 8b75e71500..2998f54c77 100644 --- a/src/main.c +++ b/src/main.c @@ -3424,6 +3424,9 @@ int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){ }else if( op==SQLITE_FCNTL_VFS_POINTER ){ *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager); rc = SQLITE_OK; + }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){ + *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager); + rc = SQLITE_OK; }else if( fd->pMethods ){ rc = sqlite3OsFileControl(fd, op, pArg); }else{ diff --git a/src/pager.c b/src/pager.c index 2c8dceb750..8f49e656e8 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6692,6 +6692,14 @@ sqlite3_file *sqlite3PagerFile(Pager *pPager){ return pPager->fd; } +/* +** Return the file handle for the journal file (if it exists). +** This will be either the rollback journal or the WAL file. +*/ +sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){ + return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd; +} + /* ** Return the full pathname of the journal file. */ diff --git a/src/pager.h b/src/pager.h index ba4eec438d..3552a876e7 100644 --- a/src/pager.h +++ b/src/pager.h @@ -188,6 +188,7 @@ int sqlite3PagerMemUsed(Pager*); const char *sqlite3PagerFilename(Pager*, int); sqlite3_vfs *sqlite3PagerVfs(Pager*); sqlite3_file *sqlite3PagerFile(Pager*); +sqlite3_file *sqlite3PagerJrnlFile(Pager*); const char *sqlite3PagerJournalname(Pager*); int sqlite3PagerNosync(Pager*); void *sqlite3PagerTempSpace(Pager*); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index be58c7cd1f..2f61704a2d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1010,6 +1010,7 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_ZIPVFS 25 #define SQLITE_FCNTL_RBU 26 #define SQLITE_FCNTL_VFS_POINTER 27 +#define SQLITE_FCNTL_JOURNAL_POINTER 28 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE diff --git a/src/wal.c b/src/wal.c index 4238ea483b..f38e24a961 100644 --- a/src/wal.c +++ b/src/wal.c @@ -3310,4 +3310,10 @@ int sqlite3WalFramesize(Wal *pWal){ } #endif +/* Return the sqlite3_file object for the WAL file +*/ +sqlite3_file *sqlite3WalFile(Wal *pWal){ + return pWal->pWalFd; +} + #endif /* #ifndef SQLITE_OMIT_WAL */ diff --git a/src/wal.h b/src/wal.h index 94a049493e..97e6ab4f10 100644 --- a/src/wal.h +++ b/src/wal.h @@ -44,6 +44,7 @@ # define sqlite3WalHeapMemory(z) 0 # define sqlite3WalFramesize(z) 0 # define sqlite3WalFindFrame(x,y,z) 0 +# define sqlite3WalFile(x) 0 #else #define WAL_SAVEPOINT_NDATA 4 @@ -138,5 +139,8 @@ void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot); int sqlite3WalFramesize(Wal *pWal); #endif +/* Return the sqlite3_file object for the WAL file */ +sqlite3_file *sqlite3WalFile(Wal *pWal); + #endif /* ifndef SQLITE_OMIT_WAL */ #endif /* _WAL_H_ */ From 4ca02079cfc75005f591e1f9b61e2c615896efa7 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Jan 2016 07:53:09 +0000 Subject: [PATCH 155/232] Fix fts5vocab.test so that it works with detail=none tables. FossilOrigin-Name: d9135cc723fc4227aace6dcf4ffa4630c9d23aa0 --- ext/fts5/test/fts5vocab.test | 32 +++++++++++++++++++------------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/ext/fts5/test/fts5vocab.test b/ext/fts5/test/fts5vocab.test index 1f5fa91663..823b2b2872 100644 --- a/ext/fts5/test/fts5vocab.test +++ b/ext/fts5/test/fts5vocab.test @@ -23,8 +23,6 @@ ifcapable !fts5 { foreach_detail_mode $testprefix { -if {[detail_is_none]} continue - proc null_list_entries {iFirst nInterval L} { for {set i $iFirst} {$i < [llength $L]} {incr i $nInterval} { lset L $i {} @@ -32,13 +30,6 @@ proc null_list_entries {iFirst nInterval L} { return $L } -proc null_insert {iFirst nInterval L} { - for {set i $iFirst} {$i < [llength $L]} {incr i $nInterval} { - lset L $i {} - } - return $L -} - proc star_from_row {L} { if {[detail_is_full]==0} { set L [null_list_entries 2 3 $L] @@ -57,6 +48,15 @@ proc star_from_col {L} { return $L } +proc row_to_col {L} { + if {[detail_is_none]==0} { error "this is for detail=none mode" } + set ret [list] + foreach {a b c} $L { + lappend ret $a {} $b {} + } + set ret +} + do_execsql_test 1.1.1 { CREATE VIRTUAL TABLE t1 USING fts5(one, prefix=1, detail=%DETAIL%); CREATE VIRTUAL TABLE v1 USING fts5vocab(t1, 'row'); @@ -140,6 +140,9 @@ set res_col [star_from_col { g a 5 7 g b 5 7 x a 1 1 y b 1 1 }] +if {[detail_is_none]} { + set res_col [row_to_col $res_row] +} foreach {tn tbl resname} { 1 "fts5vocab(tt, 'col')" res_col @@ -314,6 +317,7 @@ foreach {term} { set resc [star_from_col $resc] set resr [star_from_row $resr] + if {[detail_is_none]} { set resc [row_to_col $resr] } do_execsql_test 7.$term.1 {SELECT * FROM txc WHERE term=$term} $resc do_execsql_test 7.$term.2 {SELECT * FROM txr WHERE term=$term} $resr } @@ -378,10 +382,12 @@ do_execsql_test 7.3.1 { SELECT count(*) FROM txr, txr_c WHERE txr.term = txr_c.term; } {30} -do_execsql_test 7.3.2 { - SELECT count(*) FROM txc, txc_c - WHERE txc.term = txc_c.term AND txc.col=txc_c.col; -} {57} +if {![detail_is_none]} { + do_execsql_test 7.3.2 { + SELECT count(*) FROM txc, txc_c + WHERE txc.term = txc_c.term AND txc.col=txc_c.col; + } {57} +} } diff --git a/manifest b/manifest index d860431936..459ee65528 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sfts5vocab\smodule\sto\swork\swith\sdetail=col\sand\sdetail=none\stables. -D 2016-01-07T20:07:41.638 +C Fix\sfts5vocab.test\sso\sthat\sit\sworks\swith\sdetail=none\stables. +D 2016-01-08T07:53:09.125 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -179,7 +179,7 @@ F ext/fts5/test/fts5unicode2.test c1dd890ba32b7609adba78e420faa847abe43b59 F ext/fts5/test/fts5unicode3.test 35c3d02aa7acf7d43d8de3bfe32c15ba96e8928e F ext/fts5/test/fts5unindexed.test e9539d5b78c677315e7ed8ea911d4fd25437c680 F ext/fts5/test/fts5version.test 978f59541d8cef7e8591f8be2115ec5ccb863e2e -F ext/fts5/test/fts5vocab.test f4ff3ba4036a83678f2a8ba8b89eb303bebc122e +F ext/fts5/test/fts5vocab.test e4b12f238f113795615ba6343b63fb326d6a360e F ext/fts5/tool/fts5txt2db.tcl c374c4c4797e8cdfadabdfaeeb5412dcd6686e84 F ext/fts5/tool/loadfts5.tcl 4cc2d6af43b58d4fac05bc4fdabd0e5862c3b2c1 F ext/fts5/tool/mkfts5c.tcl d1c2a9ab8e0ec690a52316f33dd9b1d379942f45 @@ -1409,7 +1409,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 625695b3d7d4eae7536b5f761b96cd7519ac6ada -R 276342437a8f737c3f32b7f1a4e61d27 +P eedd095dc1c81ce45df00093ba237dd7b3cdff3d +R bd0f99ecb522e0859c1abeb3e9044459 U dan -Z 8c87f6adf59add172dd12da497a3ce1f +Z 0717ee91389ddd999cbabbcc60656596 diff --git a/manifest.uuid b/manifest.uuid index 46d1607a71..042f8c6f9c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eedd095dc1c81ce45df00093ba237dd7b3cdff3d \ No newline at end of file +d9135cc723fc4227aace6dcf4ffa4630c9d23aa0 \ No newline at end of file From 33d09da1f8ff4191eb839fb67a096815bc8c46c8 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Jan 2016 08:35:14 +0000 Subject: [PATCH 156/232] Fix test file vtabH.test so that it works with SQLITE_ENABLE_ICU builds. FossilOrigin-Name: 19c1f4483e3df7fa1e9ac7c8a510fa1c906ac7c7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/vtabH.test | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index fbb4b40d59..e21d82a1bd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sperformance\stracking\sfrom\sthe\smemsys5\smemory\sallocator\sif\sneither\nSQLITE_DEBUG\snor\sSQLITE_TEST\sare\sdefined. -D 2016-01-07T21:12:40.900 +C Fix\stest\sfile\svtabH.test\sso\sthat\sit\sworks\swith\sSQLITE_ENABLE_ICU\sbuilds. +D 2016-01-08T08:35:14.576 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -1274,7 +1274,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test 492ba03dcb7bb8fedcc53f258c410d04013adbc9 +F test/vtabH.test 5f5157a1501d9889ec35c1a1832f69612dd31444 F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2d96aeba2460779a0a20356739a0ba49144c8a85 -R 0f87ccc97eed432e32f05b109bfdb1a7 -U drh -Z 9752f7a1ad4b146c9e3d9fcb5efbd790 +P af5c7714e993f060841f1e893f754ddf3870e6d0 +R 98f692bc8cb5477e05091b4586394805 +U dan +Z fe651ce5a28b2d87f751c475fd148bf4 diff --git a/manifest.uuid b/manifest.uuid index 9cc6b8eedd..7d24d50e54 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -af5c7714e993f060841f1e893f754ddf3870e6d0 \ No newline at end of file +19c1f4483e3df7fa1e9ac7c8a510fa1c906ac7c7 \ No newline at end of file diff --git a/test/vtabH.test b/test/vtabH.test index 7bd542e05b..d16db13674 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -68,19 +68,19 @@ set x7 backbone set x8 backarrow set x9 castle -db func glob gfunc +db func glob -argcount 2 gfunc proc gfunc {a b} { incr ::gfunc return 1 } -db func like lfunc +db func like -argcount 2 lfunc proc lfunc {a b} { incr ::gfunc 100 return 1 } -db func regexp rfunc +db func regexp -argcount 2 rfunc proc rfunc {a b} { incr ::gfunc 10000 return 1 From ca3862dc6eda39e0037e3ee390b75cb2552d6471 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Jan 2016 12:46:39 +0000 Subject: [PATCH 157/232] Reduce the number of calls to memset() in sqlite3DbMallocZero(). FossilOrigin-Name: cede2bf8e42ac140a8cc75a1d173083f543ba467 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 3 ++- src/select.c | 17 +++++++++++------ 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index e21d82a1bd..030f236bfc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stest\sfile\svtabH.test\sso\sthat\sit\sworks\swith\sSQLITE_ENABLE_ICU\sbuilds. -D 2016-01-08T08:35:14.576 +C Reduce\sthe\snumber\sof\scalls\sto\smemset()\sin\ssqlite3DbMallocZero(). +D 2016-01-08T12:46:39.818 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -286,7 +286,7 @@ F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c e4655393bb403fa310eef66cc4583d75d4d7fd93 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c 38790e65d1219f2b7dc26458f39a5252fe7c60cd +F src/expr.c fe55c489362d1429c364e98c877514f4455f45a6 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e18b3dff7d47c7bcac5ac4fc178a89b9fd322b44 F src/func.c cf5e10af9125b245f1b962e8ba4d520a37818795 @@ -333,7 +333,7 @@ F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f +F src/select.c d84c091185bc160c349e8bf460ebd084dbd77e64 F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P af5c7714e993f060841f1e893f754ddf3870e6d0 -R 98f692bc8cb5477e05091b4586394805 -U dan -Z fe651ce5a28b2d87f751c475fd148bf4 +P 19c1f4483e3df7fa1e9ac7c8a510fa1c906ac7c7 +R 3c7ff6f52f3aab7d6a4fdba1fa3eda2d +U drh +Z 6a7b8518ac5ee1faeba157e0f460fa55 diff --git a/manifest.uuid b/manifest.uuid index 7d24d50e54..7213fa9e57 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -19c1f4483e3df7fa1e9ac7c8a510fa1c906ac7c7 \ No newline at end of file +cede2bf8e42ac140a8cc75a1d173083f543ba467 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index d8d36afa54..3be3bf52db 100644 --- a/src/expr.c +++ b/src/expr.c @@ -461,8 +461,9 @@ Expr *sqlite3ExprAlloc( assert( iValue>=0 ); } } - pNew = sqlite3DbMallocZero(db, sizeof(Expr)+nExtra); + pNew = sqlite3DbMallocRaw(db, sizeof(Expr)+nExtra); if( pNew ){ + memset(pNew, 0, sizeof(Expr)); pNew->op = (u8)op; pNew->iAgg = -1; if( pToken ){ diff --git a/src/select.c b/src/select.c index f8b8e9e77f..b1db07d09a 100644 --- a/src/select.c +++ b/src/select.c @@ -111,29 +111,34 @@ Select *sqlite3SelectNew( Select *pNew; Select standin; sqlite3 *db = pParse->db; - pNew = sqlite3DbMallocZero(db, sizeof(*pNew) ); + pNew = sqlite3DbMallocRaw(db, sizeof(*pNew) ); if( pNew==0 ){ assert( db->mallocFailed ); pNew = &standin; - memset(pNew, 0, sizeof(*pNew)); } if( pEList==0 ){ pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db,TK_ASTERISK,0)); } pNew->pEList = pEList; + pNew->op = TK_SELECT; + pNew->selFlags = selFlags; + pNew->iLimit = 0; + pNew->iOffset = 0; + pNew->addrOpenEphm[0] = -1; + pNew->addrOpenEphm[1] = -1; + pNew->nSelectRow = 0; if( pSrc==0 ) pSrc = sqlite3DbMallocZero(db, sizeof(*pSrc)); pNew->pSrc = pSrc; pNew->pWhere = pWhere; pNew->pGroupBy = pGroupBy; pNew->pHaving = pHaving; pNew->pOrderBy = pOrderBy; - pNew->selFlags = selFlags; - pNew->op = TK_SELECT; + pNew->pPrior = 0; + pNew->pNext = 0; pNew->pLimit = pLimit; pNew->pOffset = pOffset; + pNew->pWith = 0; assert( pOffset==0 || pLimit!=0 || pParse->nErr>0 || db->mallocFailed!=0 ); - pNew->addrOpenEphm[0] = -1; - pNew->addrOpenEphm[1] = -1; if( db->mallocFailed ) { clearSelect(db, pNew, pNew!=&standin); pNew = 0; From 4f40cc6f3dc8f2dca8d7020238b22786a3a541b9 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Jan 2016 17:21:18 +0000 Subject: [PATCH 158/232] Begin adding fts5 tests involving synonyms and detail=none/col tables. FossilOrigin-Name: b3e6f15ec2d9a834e2c80b91ffd7097553816228 --- ext/fts5/test/fts5_common.tcl | 154 ++++++++++++++++++++++---------- ext/fts5/test/fts5synonym2.test | 139 ++++++++++++++++++++++++++++ manifest | 13 +-- manifest.uuid | 2 +- 4 files changed, 252 insertions(+), 56 deletions(-) create mode 100644 ext/fts5/test/fts5synonym2.test diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index aadf148716..2c7fedcefe 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -202,15 +202,24 @@ proc fts5_rnddoc {n} { # -near N (NEAR distance. Default 10) # -col C (List of column indexes to match against) # -pc VARNAME (variable in caller frame to use for phrase numbering) +# -dict VARNAME (array in caller frame to use for synonyms) # proc nearset {aCol args} { + + # Process the command line options. + # set O(-near) 10 set O(-col) {} set O(-pc) "" + set O(-dict) "" set nOpt [lsearch -exact $args --] if {$nOpt<0} { error "no -- option" } + # Set $lPhrase to be a list of phrases. $nPhrase its length. + set lPhrase [lrange $args [expr $nOpt+1] end] + set nPhrase [llength $lPhrase] + foreach {k v} [lrange $args 0 [expr $nOpt-1]] { if {[info exists O($k)]==0} { error "unrecognized option $k" } set O($k) $v @@ -222,9 +231,7 @@ proc nearset {aCol args} { upvar $O(-pc) counter } - # Set $phraselist to be a list of phrases. $nPhrase its length. - set phraselist [lrange $args [expr $nOpt+1] end] - set nPhrase [llength $phraselist] + if {$O(-dict)!=""} { upvar $O(-dict) aDict } for {set j 0} {$j < [llength $aCol]} {incr j} { for {set i 0} {$i < $nPhrase} {incr i} { @@ -232,41 +239,54 @@ proc nearset {aCol args} { } } - set iCol -1 - foreach col $aCol { - incr iCol - if {$O(-col)!="" && [lsearch $O(-col) $iCol]<0} continue - set nToken [llength $col] + # Loop through each column of the current row. + for {set iCol 0} {$iCol < [llength $aCol]} {incr iCol} { - set iFL [expr $O(-near) >= $nToken ? $nToken - 1 : $O(-near)] - for { } {$iFL < $nToken} {incr iFL} { - for {set iPhrase 0} {$iPhrase<$nPhrase} {incr iPhrase} { - set B($iPhrase) [list] - } + # If there is a column filter, test whether this column is excluded. If + # so, skip to the next iteration of this loop. Otherwise, set zCol to the + # column value and nToken to the number of tokens that comprise it. + if {$O(-col)!="" && [lsearch $O(-col) $iCol]<0} continue + set zCol [lindex $aCol $iCol] + set nToken [llength $zCol] + + # Each iteration of the following loop searches a substring of the + # column value for phrase matches. The last token of the substring + # is token $iLast of the column value. The first token is: + # + # iFirst = ($iLast - $O(-near) - 1) + # + # where $sz is the length of the phrase being searched for. A phrase + # counts as matching the substring if its first token lies on or before + # $iLast and its last token on or after $iFirst. + # + # For example, if the query is "NEAR(a+b c, 2)" and the column value: + # + # "x x x x A B x x C x" + # 0 1 2 3 4 5 6 7 8 9" + # + # when (iLast==8 && iFirst=5) the range will contain both phrases and + # so both instances can be added to the output poslists. + # + set iLast [expr $O(-near) >= $nToken ? $nToken - 1 : $O(-near)] + for { } {$iLast < $nToken} {incr iLast} { + + catch { array unset B } for {set iPhrase 0} {$iPhrase<$nPhrase} {incr iPhrase} { - set p [lindex $phraselist $iPhrase] + set p [lindex $lPhrase $iPhrase] set nPm1 [expr {[llength $p] - 1}] - set iFirst [expr $iFL - $O(-near) - [llength $p]] - - for {set i $iFirst} {$i <= $iFL} {incr i} { - set lCand [lrange $col $i [expr $i+$nPm1]] + set iFirst [expr $iLast - $O(-near) - [llength $p]] + for {set i $iFirst} {$i <= $iLast} {incr i} { + set lCand [lrange $zCol $i [expr $i+$nPm1]] set bMatch 1 foreach tok $p term $lCand { - if {[string match $tok $term]==0} { - #puts "$tok $term failed" - set bMatch 0 - } + if {[nearset_match aDict $tok $term]==0} { set bMatch 0 ; break } } - if {$bMatch} { - #puts "match at $i" - lappend B($iPhrase) $i - } - - #if {$lCand == $p} { lappend B($iPhrase) $i } + if {$bMatch} { lappend B($iPhrase) $i } } - if {[llength $B($iPhrase)] == 0} break + + if {![info exists B($iPhrase)]} break } if {$iPhrase==$nPhrase} { @@ -294,6 +314,18 @@ proc nearset {aCol args} { sort_poslist $res } +proc nearset_match {aDictVar tok term} { + if {[string match $tok $term]} { return 1 } + + upvar $aDictVar aDict + if {[info exists aDict($tok)]} { + foreach s $aDict($tok) { + if {[string match $s $term]} { return 1 } + } + } + return 0; +} + #------------------------------------------------------------------------- # Usage: # @@ -405,7 +437,6 @@ proc fts5_poslist2collist {poslist} { } # Comparison function used by fts5_poslist2collist to sort collist entries. -# proc fts5_collist_elem_compare {a b} { foreach {a1 a2} [split $a .] {} foreach {b1 b2} [split $b .] {} @@ -426,17 +457,23 @@ proc fts5_collist_elem_compare {a b} { # FROM $tbl('$expr') # ORDER BY rowid $order; # -proc fts5_query_data {expr tbl {order ASC}} { +proc fts5_query_data {expr tbl {order ASC} {aDictVar ""}} { # Figure out the set of columns in the FTS5 table. This routine does # not handle tables with UNINDEXED columns, but if it did, it would # have to be here. db eval "PRAGMA table_info = $tbl" x { lappend lCols $x(name) } + set d "" + if {$aDictVar != ""} { + upvar $aDictVar aDict + set d aDict + } + set cols "" foreach e $lCols { append cols ", '$e'" } set tclexpr [db one [subst -novar { - SELECT fts5_expr_tcl( $expr, 'nearset $cols -pc ::pc' [set cols] ) + SELECT fts5_expr_tcl( $expr, 'nearset $cols -dict $d -pc ::pc' [set cols] ) }]] set res [list] @@ -457,9 +494,17 @@ proc fts5_query_data {expr tbl {order ASC}} { #------------------------------------------------------------------------- # Similar to [fts5_query_data], but omit the collist field. # -proc fts5_poslist_data {expr tbl {order ASC}} { +proc fts5_poslist_data {expr tbl {order ASC} {aDictVar ""}} { set res [list] - foreach {rowid poslist collist} [fts5_query_data $expr $tbl $order] { + + if {$aDictVar!=""} { + upvar $aDictVar aDict + set dict aDict + } else { + set dict "" + } + + foreach {rowid poslist collist} [fts5_query_data $expr $tbl $order $dict] { lappend res $rowid $poslist } set res @@ -467,22 +512,15 @@ proc fts5_poslist_data {expr tbl {order ASC}} { #------------------------------------------------------------------------- # -proc nearset_rf {aCol args} { - set idx [lsearch -exact $args --] - if {$idx != [llength $args]-2 || [llength [lindex $args end]]!=1} { - set ::expr_not_ok 1 - } - list -} - -proc nearset_rc {aCol args} { - nearset_rf $aCol {*}$args - if {[lsearch $args -col]>=0} { - set ::expr_not_ok 1 - } - list -} +# This command will only work inside a [foreach_detail_mode] block. It tests +# whether or not expression $expr run on FTS5 table $tbl is supported by +# the current mode. If so, 1 is returned. If not, 0. +# +# detail=full (all queries supported) +# detail=col (all but phrase queries and NEAR queries) +# detail=none (all but phrase queries, NEAR queries, and column filters) +# proc fts5_expr_ok {expr tbl} { if {![detail_is_full]} { @@ -505,3 +543,21 @@ proc fts5_expr_ok {expr tbl} { return 1 } +# Helper for [fts5_expr_ok] +proc nearset_rf {aCol args} { + set idx [lsearch -exact $args --] + if {$idx != [llength $args]-2 || [llength [lindex $args end]]!=1} { + set ::expr_not_ok 1 + } + list +} + +# Helper for [fts5_expr_ok] +proc nearset_rc {aCol args} { + nearset_rf $aCol {*}$args + if {[lsearch $args -col]>=0} { + set ::expr_not_ok 1 + } + list +} + diff --git a/ext/fts5/test/fts5synonym2.test b/ext/fts5/test/fts5synonym2.test new file mode 100644 index 0000000000..e3a8003758 --- /dev/null +++ b/ext/fts5/test/fts5synonym2.test @@ -0,0 +1,139 @@ +# 2014 Dec 20 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Tests focusing on custom tokenizers that support synonyms. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5synonym + +# If SQLITE_ENABLE_FTS5 is defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +#------------------------------------------------------------------------- +# Code for a simple Tcl tokenizer that supports synonyms at query time. +# +foreach SYNDICT { + {zero 0} + {one 1 i} + {two 2 ii} + {three 3 iii} + {four 4 iv} + {five 5 v} + {six 6 vi} + {seven 7 vii} + {eight 8 viii} + {nine 9 ix} +} { + foreach s $SYNDICT { + set o [list] + foreach x $SYNDICT {if {$x!=$s} {lappend o $x}} + set ::syn($s) $o + } +} + +proc tcl_tokenize {tflags text} { + foreach {w iStart iEnd} [fts5_tokenize_split $text] { + sqlite3_fts5_token $w $iStart $iEnd + if {$tflags == "query"} { + foreach s $::SYNDICT($w) { sqlite3_fts5_token -colo $s $iStart $iEnd } + } + } +} + +proc tcl_create {args} { + return "tcl_tokenize" +} + +# +# End of tokenizer code. +#------------------------------------------------------------------------- + +foreach_detail_mode $testprefix { + +sqlite3_fts5_create_tokenizer db tcl tcl_create +fts5_aux_test_functions db + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE ss USING fts5(a, b, tokenize=tcl, detail=%DETAIL%); + + INSERT INTO ss VALUES('5 5 five seven 3 seven i', '2 1 5 0 two 1 i'); + INSERT INTO ss VALUES('six ix iii 7 i vii iii', 'one seven nine 4 9 1 vi'); + INSERT INTO ss VALUES('6 viii i five six zero seven', '5 v iii iv iv 3'); + INSERT INTO ss VALUES('9 ii six 8 1 6', 'six 4 iv iv 7'); + INSERT INTO ss VALUES('1 5 4 eight ii iv iii', 'nine 2 eight ix v vii'); + INSERT INTO ss VALUES('one 7 seven six 2 two', '1 2 four 7 4 3 4'); + INSERT INTO ss VALUES('eight iv 4 nine vii six 1', '5 6 v one zero 4'); + INSERT INTO ss VALUES('v 9 8 iii 4', '9 4 seven two vi vii'); + INSERT INTO ss VALUES('3 ix two 9 0 nine i', 'five ii nine two viii i five'); + INSERT INTO ss VALUES('six iii 9 two eight 2', 'nine i nine vii nine'); + INSERT INTO ss VALUES('6 three zero seven vii five', '8 vii ix 0 7 seven'); + INSERT INTO ss VALUES('8 vii 8 7 3 4', 'eight iii four viii nine iv three'); + INSERT INTO ss VALUES('4 v 7 two 0 one 8', 'vii 1 two five i zero 9'); + INSERT INTO ss VALUES('3 ii vii vi eight', '8 4 ix one three eight'); + INSERT INTO ss VALUES('iv eight seven 6 9 seven', 'one vi two five seven'); + INSERT INTO ss VALUES('i i 5 i v vii eight', '2 seven i 2 2 four'); + INSERT INTO ss VALUES('0 i iii nine 3 ix five', '0 eight iv 0 six 2'); + INSERT INTO ss VALUES('iv vii three 3 9 one 8', '2 ii 6 eight ii six six'); + INSERT INTO ss VALUES('eight one two nine six', '8 9 3 viii vi'); + INSERT INTO ss VALUES('one 0 four ii eight one 3', 'iii eight vi vi vi'); + INSERT INTO ss VALUES('4 0 eight 0 0', '1 four one vii seven ii'); + INSERT INTO ss VALUES('1 zero nine 2 2', 'viii iv two vi nine v iii'); + INSERT INTO ss VALUES('5 five viii four four vi', '8 five 7 vii 6 4'); + INSERT INTO ss VALUES('7 ix four 8 vii', 'nine three nine ii ix vii'); + INSERT INTO ss VALUES('nine iv v i 0 v', 'two iv vii six i ix 4'); + INSERT INTO ss VALUES('one v v one viii 3 8', '2 1 3 five iii'); + INSERT INTO ss VALUES('six ii 5 nine 4 viii seven', 'eight i ix ix 7 four'); + INSERT INTO ss VALUES('9 ii two seven three 7 0', 'six viii seven 7 five'); + INSERT INTO ss VALUES('five two 4 viii nine', '9 7 nine zero 1 two one'); + INSERT INTO ss VALUES('viii 8 iii i ii 8 3', '4 2 7 v 8 8'); + INSERT INTO ss VALUES('four vii 4 iii zero 0 vii', '3 viii iii zero 9 i'); + INSERT INTO ss VALUES('0 seven v five i five v', 'one 4 2 ix 9'); + INSERT INTO ss VALUES('two 5 two two ix 4 1', '3 nine ii v nine 3 five'); + INSERT INTO ss VALUES('five 5 7 4 6 vii', 'three 2 ix 2 8 6'); + INSERT INTO ss VALUES('six iii vi iv seven eight', '8 six 7 0 4'); + INSERT INTO ss VALUES('vi vi iv 3 0 one one', '9 6 eight ix iv'); + INSERT INTO ss VALUES('7 2 2 iii 0', '0 0 seven 1 nine'); + INSERT INTO ss VALUES('8 6 iv six ii', 'iv 6 3 4 ii five'); + INSERT INTO ss VALUES('0 two two seven ii', 'vii ix four 4 zero vi vi'); + INSERT INTO ss VALUES('2 one eight 8 9 7', 'vi 3 0 3 vii'); + INSERT INTO ss VALUES('iii ii ix iv three', 'vi i 6 1 two'); + INSERT INTO ss VALUES('eight four nine 8 seven', 'one three i nine iii one'); + INSERT INTO ss VALUES('iii seven five ix 8', 'ii 7 seven 0 four ii'); + INSERT INTO ss VALUES('four 0 1 5 two', 'iii 9 5 ii ii 2 4'); + INSERT INTO ss VALUES('iii nine four vi 8 five six', 'i i ii seven vi vii'); + INSERT INTO ss VALUES('eight vii eight six 3', 'i vii 1 six 9 vii'); + INSERT INTO ss VALUES('9 0 viii viii five', 'i 1 viii ix 3 4'); + INSERT INTO ss VALUES('three nine 5 nine viii four zero', 'ii i 1 5 2 viii'); + INSERT INTO ss VALUES('5 vii three 9 four', 'three five one 7 2 eight one'); +} + +foreach {tn expr} { + 1 "eight" +} { + if {[fts5_expr_ok $expr ss]==0} { + do_test 1.$tn.OMITTED { list } [list] + continue + } + + set res [fts5_query_data $expr ss ASC ::SYNDICT] + do_execsql_test 1.$tn.[llength $res].asc { + SELECT rowid, fts5_test_poslist(ss), fts5_test_collist(ss) FROM ss($expr) + } $res +} + +} + +finish_test + diff --git a/manifest b/manifest index 459ee65528..48daf058c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sfts5vocab.test\sso\sthat\sit\sworks\swith\sdetail=none\stables. -D 2016-01-08T07:53:09.125 +C Begin\sadding\sfts5\stests\sinvolving\ssynonyms\sand\sdetail=none/col\stables. +D 2016-01-08T17:21:18.901 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -114,7 +114,7 @@ F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c da64ecbd217625980a1721fbd588a1e4118a51b6 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl c9169fe40bf751e1b311271df31aec15732b26c0 +F ext/fts5/test/fts5_common.tcl 393882afb225a21edf033043bbf936951e9198c1 F ext/fts5/test/fts5aa.test 7e814df4a0e6c22a6fe2d84f210fdc0b5068a084 F ext/fts5/test/fts5ab.test 30325a89453280160106be411bba3acf138e6d1b F ext/fts5/test/fts5ac.test d5073ca7bd2d9fe8aab0c82c6c75a7e4b0d70ced @@ -173,6 +173,7 @@ F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 F ext/fts5/test/fts5simple.test 2bc6451cbe887a9215f5b14ae307c70d850344c9 F ext/fts5/test/fts5simple2.test 843f1f7fe439ff32bf74f4fd6430632f9636ef3a F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 +F ext/fts5/test/fts5synonym2.test 6aa842d0e5bd019db0c3597e0860eb68eb2867e4 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 F ext/fts5/test/fts5unicode.test fbef8d8a3b4b88470536cc57604a82ca52e51841 F ext/fts5/test/fts5unicode2.test c1dd890ba32b7609adba78e420faa847abe43b59 @@ -1409,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P eedd095dc1c81ce45df00093ba237dd7b3cdff3d -R bd0f99ecb522e0859c1abeb3e9044459 +P d9135cc723fc4227aace6dcf4ffa4630c9d23aa0 +R c443735bd0d019a3a4798f3f3350cb78 U dan -Z 0717ee91389ddd999cbabbcc60656596 +Z 48c62f9fa751846d5897bddd7cc5158f diff --git a/manifest.uuid b/manifest.uuid index 042f8c6f9c..dc0f491a48 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d9135cc723fc4227aace6dcf4ffa4630c9d23aa0 \ No newline at end of file +b3e6f15ec2d9a834e2c80b91ffd7097553816228 \ No newline at end of file From c0fba6d8e8168ccf20d20408a951a5c0d6d40d36 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Jan 2016 17:28:24 +0000 Subject: [PATCH 159/232] Remove an obsolete #ifdef related to iOS support. FossilOrigin-Name: e9a51d2a580daa0fb152fe4c891149caa8025b9d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 4 ---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 030f236bfc..6a2cecdd5b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reduce\sthe\snumber\sof\scalls\sto\smemset()\sin\ssqlite3DbMallocZero(). -D 2016-01-08T12:46:39.818 +C Remove\san\sobsolete\s#ifdef\srelated\sto\siOS\ssupport. +D 2016-01-08T17:28:24.140 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -338,7 +338,7 @@ F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 987b46b1d8089155caecbdb14b78850ae1e198ff +F src/sqliteInt.h b8ccd34a919e4b6bab8c4164046330002aa9a27a F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 19c1f4483e3df7fa1e9ac7c8a510fa1c906ac7c7 -R 3c7ff6f52f3aab7d6a4fdba1fa3eda2d +P cede2bf8e42ac140a8cc75a1d173083f543ba467 +R 687150b04bc81fb920941b849f5ff5ae U drh -Z 6a7b8518ac5ee1faeba157e0f460fa55 +Z 8aac296d541ec4b6e638fabbaab161bc diff --git a/manifest.uuid b/manifest.uuid index 7213fa9e57..b1bfb82722 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cede2bf8e42ac140a8cc75a1d173083f543ba467 \ No newline at end of file +e9a51d2a580daa0fb152fe4c891149caa8025b9d \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0fbc7f6cc7..a4d4f65f3c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -767,10 +767,6 @@ typedef INT16_TYPE LogEst; */ #ifdef __APPLE__ # include -# if TARGET_OS_IPHONE -# undef SQLITE_MAX_MMAP_SIZE -# define SQLITE_MAX_MMAP_SIZE 0 -# endif #endif #ifndef SQLITE_MAX_MMAP_SIZE # if defined(__linux__) \ From e4a08f9e39189a0acd04648c62bcc86e2f88763c Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Jan 2016 19:17:30 +0000 Subject: [PATCH 160/232] Fix a problem with #ifdefs on the system calls in the unix VFS that causes problems when compiling with SQLITE_OMIT_WAL. FossilOrigin-Name: ceceea4c5ee242b20ebf216593c15c11ce2c369a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 12 +++++++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6a2cecdd5b..192536623d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sobsolete\s#ifdef\srelated\sto\siOS\ssupport. -D 2016-01-08T17:28:24.140 +C Fix\sa\sproblem\swith\s#ifdefs\son\sthe\ssystem\scalls\sin\sthe\sunix\sVFS\sthat\scauses\nproblems\swhen\scompiling\swith\sSQLITE_OMIT_WAL. +D 2016-01-08T19:17:30.620 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -317,7 +317,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 0ca6d8710366fbb01a275160f018334cd347cbda +F src/os_unix.c 0b8ed82a5d6cdd8c8f48520789b46a6fd3fcb3ba F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 58d2593612acb6b542de6715b4af397ea1fa0a35 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P cede2bf8e42ac140a8cc75a1d173083f543ba467 -R 687150b04bc81fb920941b849f5ff5ae +P e9a51d2a580daa0fb152fe4c891149caa8025b9d +R f00c1274aa3c73407d2f148ceadecbc9 U drh -Z 8aac296d541ec4b6e638fabbaab161bc +Z f360db7d4eecffb564b5a77c7b7dafa5 diff --git a/manifest.uuid b/manifest.uuid index b1bfb82722..386a22a52d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e9a51d2a580daa0fb152fe4c891149caa8025b9d \ No newline at end of file +ceceea4c5ee242b20ebf216593c15c11ce2c369a \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 791ba5d8d9..c41b6c7c29 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -437,13 +437,20 @@ static struct unix_syscall { #define osGeteuid ((uid_t(*)(void))aSyscall[21].pCurrent) #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 - { "mmap", (sqlite3_syscall_ptr)mmap, 0 }, + { "mmap", (sqlite3_syscall_ptr)mmap, 0 }, +#else + { "mmap", (sqlite3_syscall_ptr)0, 0 }, +#endif #define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[22].pCurrent) +#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 { "munmap", (sqlite3_syscall_ptr)munmap, 0 }, +#else + { "munmap", (sqlite3_syscall_ptr), 0 }, +#endif #define osMunmap ((void*(*)(void*,size_t))aSyscall[23].pCurrent) -#if HAVE_MREMAP +#if HAVE_MREMAP && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) { "mremap", (sqlite3_syscall_ptr)mremap, 0 }, #else { "mremap", (sqlite3_syscall_ptr)0, 0 }, @@ -456,7 +463,6 @@ static struct unix_syscall { { "readlink", (sqlite3_syscall_ptr)readlink, 0 }, #define osReadlink ((ssize_t(*)(const char*,char*,size_t))aSyscall[26].pCurrent) -#endif }; /* End of the overrideable system calls */ From 5a1fb1885ad793e663323b6c97f94ed3b78dce05 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Jan 2016 19:34:39 +0000 Subject: [PATCH 161/232] Fix the build for SQLITE_OMIT_SHARED_CACHE, which was broken, possibly by check-in [2d96aeba]. FossilOrigin-Name: 3392f8fa2ddf2c10ffe91ddd92470040c909b36d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 44 ++++++++++++++++++++++++-------------------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 192536623d..e79fa8d733 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\s#ifdefs\son\sthe\ssystem\scalls\sin\sthe\sunix\sVFS\sthat\scauses\nproblems\swhen\scompiling\swith\sSQLITE_OMIT_WAL. -D 2016-01-08T19:17:30.620 +C Fix\sthe\sbuild\sfor\sSQLITE_OMIT_SHARED_CACHE,\swhich\swas\sbroken,\spossibly\nby\scheck-in\s[2d96aeba]. +D 2016-01-08T19:34:39.323 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -276,7 +276,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 09ec3ca5e7a6b8c277cef6c4471a1427cab5fa01 +F src/btree.c 6bd9b3d778a023e2238a81cd0b87b00085220e0e F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 F src/build.c 9d497ff4bf3c82cecb520436e0e9963785627583 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e9a51d2a580daa0fb152fe4c891149caa8025b9d -R f00c1274aa3c73407d2f148ceadecbc9 +P ceceea4c5ee242b20ebf216593c15c11ce2c369a +R aa88b0148c6ce2e00f60d1f7cb2cd85a U drh -Z f360db7d4eecffb564b5a77c7b7dafa5 +Z d454daea05e67b50f7d16f4e08b90e6b diff --git a/manifest.uuid b/manifest.uuid index 386a22a52d..7260cdc2d8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ceceea4c5ee242b20ebf216593c15c11ce2c369a \ No newline at end of file +3392f8fa2ddf2c10ffe91ddd92470040c909b36d \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 5c60364a6b..77552d5831 100644 --- a/src/btree.c +++ b/src/btree.c @@ -3130,7 +3130,6 @@ int sqlite3BtreeNewDb(Btree *p){ ** proceed. */ int sqlite3BtreeBeginTrans(Btree *p, int wrflag){ - sqlite3 *pBlock = 0; BtShared *pBt = p->pBt; int rc = SQLITE_OK; @@ -3153,27 +3152,30 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag){ } #ifndef SQLITE_OMIT_SHARED_CACHE - /* If another database handle has already opened a write transaction - ** on this shared-btree structure and a second write transaction is - ** requested, return SQLITE_LOCKED. - */ - if( (wrflag && pBt->inTransaction==TRANS_WRITE) - || (pBt->btsFlags & BTS_PENDING)!=0 - ){ - pBlock = pBt->pWriter->db; - }else if( wrflag>1 ){ - BtLock *pIter; - for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){ - if( pIter->pBtree!=p ){ - pBlock = pIter->pBtree->db; - break; + { + sqlite3 *pBlock = 0; + /* If another database handle has already opened a write transaction + ** on this shared-btree structure and a second write transaction is + ** requested, return SQLITE_LOCKED. + */ + if( (wrflag && pBt->inTransaction==TRANS_WRITE) + || (pBt->btsFlags & BTS_PENDING)!=0 + ){ + pBlock = pBt->pWriter->db; + }else if( wrflag>1 ){ + BtLock *pIter; + for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){ + if( pIter->pBtree!=p ){ + pBlock = pIter->pBtree->db; + break; + } } } - } - if( pBlock ){ - sqlite3ConnectionBlocked(p->db, pBlock); - rc = SQLITE_LOCKED_SHAREDCACHE; - goto trans_begun; + if( pBlock ){ + sqlite3ConnectionBlocked(p->db, pBlock); + rc = SQLITE_LOCKED_SHAREDCACHE; + goto trans_begun; + } } #endif @@ -9676,9 +9678,11 @@ int sqlite3BtreeIsReadonly(Btree *p){ */ int sqlite3HeaderSizeBtree(void){ return ROUND8(sizeof(MemPage)); } +#if !defined(SQLITE_OMIT_SHARED_CACHE) /* ** Return true if the Btree passed as the only argument is sharable. */ int sqlite3BtreeSharable(Btree *p){ return p->sharable; } +#endif From 24dbeae6f5d736074b16f1f432d209dddd2fb32a Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Jan 2016 22:18:00 +0000 Subject: [PATCH 162/232] More #ifdef fixes for the unix VFS. FossilOrigin-Name: 122c111e360761de8166e16ca151cb7260ee9bf8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e79fa8d733..b7b8ae7c56 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sbuild\sfor\sSQLITE_OMIT_SHARED_CACHE,\swhich\swas\sbroken,\spossibly\nby\scheck-in\s[2d96aeba]. -D 2016-01-08T19:34:39.323 +C More\s#ifdef\sfixes\sfor\sthe\sunix\sVFS. +D 2016-01-08T22:18:00.216 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -317,7 +317,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 0b8ed82a5d6cdd8c8f48520789b46a6fd3fcb3ba +F src/os_unix.c 085352926299f5c5ced95c67bf6e4715f7989be0 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 58d2593612acb6b542de6715b4af397ea1fa0a35 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ceceea4c5ee242b20ebf216593c15c11ce2c369a -R aa88b0148c6ce2e00f60d1f7cb2cd85a +P 3392f8fa2ddf2c10ffe91ddd92470040c909b36d +R 6d9dd78f2a8c3dbacbf5b70f6d546718 U drh -Z d454daea05e67b50f7d16f4e08b90e6b +Z 1972a905aa5c7145f504034b11e18521 diff --git a/manifest.uuid b/manifest.uuid index 7260cdc2d8..778dad919a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3392f8fa2ddf2c10ffe91ddd92470040c909b36d \ No newline at end of file +122c111e360761de8166e16ca151cb7260ee9bf8 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index c41b6c7c29..bf37ae69ed 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -446,7 +446,7 @@ static struct unix_syscall { #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 { "munmap", (sqlite3_syscall_ptr)munmap, 0 }, #else - { "munmap", (sqlite3_syscall_ptr), 0 }, + { "munmap", (sqlite3_syscall_ptr)9, 0 }, #endif #define osMunmap ((void*(*)(void*,size_t))aSyscall[23].pCurrent) @@ -457,7 +457,11 @@ static struct unix_syscall { #endif #define osMremap ((void*(*)(void*,size_t,size_t,int,...))aSyscall[24].pCurrent) +#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 { "getpagesize", (sqlite3_syscall_ptr)unixGetpagesize, 0 }, +#else + { "getpagesize", (sqlite3_syscall_ptr)0, 0 }, +#endif #define osGetpagesize ((int(*)(void))aSyscall[25].pCurrent) { "readlink", (sqlite3_syscall_ptr)readlink, 0 }, From a829992969367549de19beb925fcc27f37c05275 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Jan 2016 22:31:00 +0000 Subject: [PATCH 163/232] Typo fix in the previous commit. FossilOrigin-Name: 52c166039831cc8423e2252019ef64a21b9d7c2a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b7b8ae7c56..45e5e88c6f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\s#ifdef\sfixes\sfor\sthe\sunix\sVFS. -D 2016-01-08T22:18:00.216 +C Typo\sfix\sin\sthe\sprevious\scommit. +D 2016-01-08T22:31:00.176 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -317,7 +317,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 085352926299f5c5ced95c67bf6e4715f7989be0 +F src/os_unix.c 82986e1e75782b54da7822dca42d36d974fc2948 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 58d2593612acb6b542de6715b4af397ea1fa0a35 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3392f8fa2ddf2c10ffe91ddd92470040c909b36d -R 6d9dd78f2a8c3dbacbf5b70f6d546718 +P 122c111e360761de8166e16ca151cb7260ee9bf8 +R 459dbc63e3c56e9f1bc36ac4dabf3593 U drh -Z 1972a905aa5c7145f504034b11e18521 +Z 6b54e5c713520cd21bd942bd06142b38 diff --git a/manifest.uuid b/manifest.uuid index 778dad919a..50a7a74425 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -122c111e360761de8166e16ca151cb7260ee9bf8 \ No newline at end of file +52c166039831cc8423e2252019ef64a21b9d7c2a \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index bf37ae69ed..a40a866780 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -446,7 +446,7 @@ static struct unix_syscall { #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 { "munmap", (sqlite3_syscall_ptr)munmap, 0 }, #else - { "munmap", (sqlite3_syscall_ptr)9, 0 }, + { "munmap", (sqlite3_syscall_ptr)0, 0 }, #endif #define osMunmap ((void*(*)(void*,size_t))aSyscall[23].pCurrent) From d6f7c979523446f8aa8706bb7a335a5eebf63966 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 9 Jan 2016 16:39:29 +0000 Subject: [PATCH 164/232] If a single page is written to the wal file more than once, have each subsequent copy overwrite the original frame. FossilOrigin-Name: 5d113aef2c7d746e8eda88d4e36c04a39b0a11be --- manifest | 26 ++++++----- manifest.uuid | 2 +- src/pager.c | 7 +++ src/pager.h | 1 + src/pcache.h | 2 + src/wal.c | 98 ++++++++++++++++++++++++++++++++++++++ test/wal.test | 4 +- test/waloverwrite.test | 104 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 230 insertions(+), 14 deletions(-) create mode 100644 test/waloverwrite.test diff --git a/manifest b/manifest index 45e5e88c6f..929a82b2bd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Typo\sfix\sin\sthe\sprevious\scommit. -D 2016-01-08T22:31:00.176 +C If\sa\ssingle\spage\sis\swritten\sto\sthe\swal\sfile\smore\sthan\sonce,\shave\seach\ssubsequent\scopy\soverwrite\sthe\soriginal\sframe. +D 2016-01-09T16:39:29.213 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -320,11 +320,11 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 82986e1e75782b54da7822dca42d36d974fc2948 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 58d2593612acb6b542de6715b4af397ea1fa0a35 -F src/pager.h bf25005b4656cd805af43487c3139fca9678d0cc +F src/pager.c c241cace996e19248ddc60f4b8c2e654177e4d3b +F src/pager.h bbbfe27618ac2df8aba22ee0dace08f013351c40 F src/parse.y caad1e98edeca6960493d0c60d31b76820dd7776 F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 -F src/pcache.h 1ff11adce609ba7de139b6abfabaf9a2bac947b5 +F src/pcache.h 4d0ccaad264d360981ec5e6a2b596d6e85242545 F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051 F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c @@ -409,7 +409,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 974928c988681c5157202c79dd9f26afaa7b5086 +F src/wal.c 88661c24c86d88e40560c0be5df39d902502a29a F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c c6d3d2f6af57d574a7365ee2b225a5024f2a6bec @@ -1279,7 +1279,7 @@ F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test ea8778d5b0df200adef2ca7c00c3c37d4375f772 -F test/wal.test dbfc482e10c7263298833bb1fc60b3ac9d6340a1 +F test/wal.test 351bd83d33d41aa1a32f48f74bfebeb8cfcfc23b F test/wal2.test 1f841d2048080d32f552942e333fd99ce541dada F test/wal3.test b1d425f68a1f61d12563f0fa1ee6fca7d5afabf4 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c @@ -1301,6 +1301,7 @@ F test/walfault.test 1f8389f7709877e9b4cc679033d71d6fe529056b F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496 +F test/waloverwrite.test 59476a2cf0638a057ced738b62dc719ed4e32e53 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6 F test/walro.test 34422d1d95aaff0388f0791ec20edb34e2a3ed57 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417 @@ -1406,7 +1407,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 122c111e360761de8166e16ca151cb7260ee9bf8 -R 459dbc63e3c56e9f1bc36ac4dabf3593 -U drh -Z 6b54e5c713520cd21bd942bd06142b38 +P 52c166039831cc8423e2252019ef64a21b9d7c2a +R 7ec438cc7bd0e0a87d33dca3e9bb783a +T *branch * wal-overwrite-frames +T *sym-wal-overwrite-frames * +T -sym-trunk * +U dan +Z eba50524221f3f22640b286e867693f1 diff --git a/manifest.uuid b/manifest.uuid index 50a7a74425..2b25ead966 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -52c166039831cc8423e2252019ef64a21b9d7c2a \ No newline at end of file +5d113aef2c7d746e8eda88d4e36c04a39b0a11be \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 2c8dceb750..b333a746e4 100644 --- a/src/pager.c +++ b/src/pager.c @@ -7301,6 +7301,13 @@ int sqlite3PagerCloseWal(Pager *pPager){ return rc; } +/* +** Return the number of open savepoints. +**/ +int sqlite3PagerSavepointCount(Pager *pPager){ + return pPager->nSavepoint; +} + #ifdef SQLITE_ENABLE_SNAPSHOT /* ** If this is a WAL database, obtain a snapshot handle for the snapshot diff --git a/src/pager.h b/src/pager.h index ba4eec438d..c9b766a55c 100644 --- a/src/pager.h +++ b/src/pager.h @@ -168,6 +168,7 @@ int sqlite3PagerSharedLock(Pager *pPager); int sqlite3PagerWalCallback(Pager *pPager); int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); int sqlite3PagerCloseWal(Pager *pPager); + int sqlite3PagerSavepointCount(Pager *pPager); # ifdef SQLITE_ENABLE_SNAPSHOT int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot); int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot); diff --git a/src/pcache.h b/src/pcache.h index 42c44cf7ba..475c04c061 100644 --- a/src/pcache.h +++ b/src/pcache.h @@ -55,6 +55,8 @@ struct PgHdr { #define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ #define PGHDR_MMAP 0x040 /* This is an mmap page object */ +#define PGHDR_WAL_APPEND 0x080 /* Appended to wal file */ + /* Initialize and shutdown the page cache subsystem */ int sqlite3PcacheInitialize(void); void sqlite3PcacheShutdown(void); diff --git a/src/wal.c b/src/wal.c index 4238ea483b..c900879d12 100644 --- a/src/wal.c +++ b/src/wal.c @@ -462,6 +462,13 @@ struct Wal { #define WAL_EXCLUSIVE_MODE 1 #define WAL_HEAPMEMORY_MODE 2 +/* +** Values for Wal.writeLock. +*/ +#define WAL_WRITELOCK_UNLOCKED 0 +#define WAL_WRITELOCK_LOCKED 1 +#define WAL_WRITELOCK_RECKSUM 2 + /* ** Possible values for WAL.readOnly */ @@ -2885,6 +2892,60 @@ static int walWriteOneFrame( return rc; } +/* +** This function is called as part of committing a transaction within which +** one or more frames have been overwritten. It updates the checksums for +** all frames written to the wal file by the current transaction. +** +** Argument pLive is a pointer to the first wal-index header in shared +** memory (the copy readers will see if they open a read-transaction now, +** before the current commit is finished). This is safe to use because the +** caller holds the WRITER lock. The first frame to update the checksum +** for is (pLive->mxFrame+1). The last is argument iLast. +** +** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +*/ +static int walRewriteChecksums(Wal *pWal, WalIndexHdr *pLive, u32 iLast){ + const int szPage = pWal->szPage;/* Database page size */ + int rc = SQLITE_OK; /* Return code */ + u8 *aBuf; /* Buffer to load data from wal file into */ + u8 aFrame[WAL_FRAME_HDRSIZE]; /* Buffer to assemble frame-headers in */ + u32 iRead; /* Next frame to read from wal file */ + + aBuf = sqlite3_malloc(szPage + WAL_FRAME_HDRSIZE); + if( aBuf==0 ) return SQLITE_NOMEM; + + /* Find the checksum values to use as input for the checksum of the + ** first frame written by this transaction. If that frame is frame 1 + ** (implying that the current transaction restarted the wal file), + ** these values must be read from the wal-file header. If the first + ** frame to update the checksum of is not frame 1, then the initial + ** checksum values can be copied from pLive. */ + if( pLive->mxFrame==0 ){ + rc = sqlite3OsRead(pWal->pWalFd, aBuf, sizeof(u32)*2, 24); + pWal->hdr.aFrameCksum[0] = sqlite3Get4byte(aBuf); + pWal->hdr.aFrameCksum[1] = sqlite3Get4byte(&aBuf[sizeof(u32)]); + }else{ + memcpy(pWal->hdr.aFrameCksum, pLive->aFrameCksum, sizeof(u32)*2); + } + + for(iRead=pLive->mxFrame+1; rc==SQLITE_OK && iRead<=iLast; iRead++){ + i64 iOff = walFrameOffset(iRead, szPage); + rc = sqlite3OsRead(pWal->pWalFd, aBuf, szPage+WAL_FRAME_HDRSIZE, iOff); + if( rc==SQLITE_OK ){ + u32 iPgno, nDbSize; + iPgno = sqlite3Get4byte(aBuf); + nDbSize = sqlite3Get4byte(&aBuf[4]); + + walEncodeFrame(pWal, iPgno, nDbSize, &aBuf[WAL_FRAME_HDRSIZE], aFrame); + rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOff); + } + } + + sqlite3_free(aBuf); + return rc; +} + /* ** Write a set of frames to the log. The caller must hold the write-lock ** on the log file (obtained using sqlite3WalBeginWriteTransaction()). @@ -2905,6 +2966,8 @@ int sqlite3WalFrames( int szFrame; /* The size of a single frame */ i64 iOffset; /* Next byte to write in WAL file */ WalWriter w; /* The writer */ + u32 iFirst = 0; /* First frame that may be overwritten */ + WalIndexHdr *pLive; /* Pointer to shared header */ assert( pList ); assert( pWal->writeLock ); @@ -2920,6 +2983,13 @@ int sqlite3WalFrames( } #endif + pLive = (WalIndexHdr*)walIndexHdr(pWal); + if( memcmp(&pWal->hdr, (void *)pLive, sizeof(WalIndexHdr))!=0 + && (isCommit || sqlite3PagerSavepointCount(pList->pPager)==0) + ){ + iFirst = pLive->mxFrame+1; + } + /* See if it is possible to write these frames into the start of the ** log file, instead of appending to it at pWal->hdr.mxFrame. */ @@ -2984,6 +3054,25 @@ int sqlite3WalFrames( /* Write all frames into the log file exactly once */ for(p=pList; p; p=p->pDirty){ int nDbSize; /* 0 normally. Positive == commit flag */ + + /* Check if this page has already been written into the wal file by + ** the current transaction. If so, overwrite the existing frame and + ** set Wal.writeLock to WAL_WRITELOCK_RECKSUM - indicating that + ** checksums must be recomputed when the transaction is committed. */ + if( iFirst && (p->pDirty || isCommit==0) ){ + u32 iWrite = 0; + rc = sqlite3WalFindFrame(pWal, p->pgno, &iWrite); + if( rc ) return rc; + if( iWrite>=iFirst ){ + i64 iOff = walFrameOffset(iWrite, szPage) + WAL_FRAME_HDRSIZE; + pWal->writeLock = WAL_WRITELOCK_RECKSUM; + rc = sqlite3OsWrite(pWal->pWalFd, p->pData, szPage, iOff); + if( rc ) return rc; + p->flags &= ~PGHDR_WAL_APPEND; + continue; + } + } + iFrame++; assert( iOffset==walFrameOffset(iFrame, szPage) ); nDbSize = (isCommit && p->pDirty==0) ? nTruncate : 0; @@ -2991,6 +3080,13 @@ int sqlite3WalFrames( if( rc ) return rc; pLast = p; iOffset += szFrame; + p->flags |= PGHDR_WAL_APPEND; + } + + /* Recalculate checksums within the wal file if required. */ + if( isCommit && pWal->writeLock==WAL_WRITELOCK_RECKSUM ){ + rc = walRewriteChecksums(pWal, pLive, iFrame); + if( rc ) return rc; } /* If this is the end of a transaction, then we might need to pad @@ -3042,6 +3138,7 @@ int sqlite3WalFrames( */ iFrame = pWal->hdr.mxFrame; for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){ + if( (p->flags & PGHDR_WAL_APPEND)==0 ) continue; iFrame++; rc = walIndexAppend(pWal, iFrame, p->pgno); } @@ -3154,6 +3251,7 @@ int sqlite3WalCheckpoint( /* Copy data from the log to the database file. */ if( rc==SQLITE_OK ){ + if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){ rc = SQLITE_CORRUPT_BKPT; }else{ diff --git a/test/wal.test b/test/wal.test index bfe3634577..3646b46c17 100644 --- a/test/wal.test +++ b/test/wal.test @@ -712,7 +712,7 @@ do_test wal-11.5 { do_test wal-11.6 { execsql COMMIT list [expr [file size test.db]/1024] [file size test.db-wal] -} [list 3 [wal_file_size 41 1024]] +} [list 3 [wal_file_size 40 1024]] do_test wal-11.7 { execsql { SELECT count(*) FROM t1; @@ -722,7 +722,7 @@ do_test wal-11.7 { do_test wal-11.8 { execsql { PRAGMA wal_checkpoint } list [expr [file size test.db]/1024] [file size test.db-wal] -} [list 37 [wal_file_size 41 1024]] +} [list 37 [wal_file_size 40 1024]] do_test wal-11.9 { db close list [expr [file size test.db]/1024] [log_deleted test.db-wal] diff --git a/test/waloverwrite.test b/test/waloverwrite.test new file mode 100644 index 0000000000..02fe4c1ccf --- /dev/null +++ b/test/waloverwrite.test @@ -0,0 +1,104 @@ +# 2010 May 5 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing the operation of the library in +# "PRAGMA journal_mode=WAL" mode. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/wal_common.tcl +set testprefix waloverwrite + +ifcapable !wal {finish_test ; return } + +# Simple test: +# +# 1. Create a database of blobs roughly 50 pages in size. +# +# 2. Set the db cache size to something much smaller than this (5 pages) +# +# 3. Within a transaction, loop through the set of blobs 5 times. Update +# each blob as it is visited. +# +# 4. Test that the wal file is roughly 50 pages in size - even though many +# database pages have been written to it multiple times. +# +# 5. Take a copy of the database and wal file. Test that recovery can +# be run on it. +# +# The above is run twice - once where the wal file is empty at the start of +# step 3 (tn==1) and once where it already contains a transaction (tn==2). +# +foreach {tn xtra} { + 1 {} + 2 { UPDATE t1 SET y = randomblob(799) WHERE x=4 } +} { + reset_db + do_execsql_test 1.$tn.0 { + CREATE TABLE t1(x, y); + CREATE INDEX i1y ON t1(y); + + WITH cnt(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM cnt WHERE i<20 + ) + INSERT INTO t1 SELECT i, randomblob(800) FROM cnt; + } {} + + do_test 1.$tn.1 { + set nPg [db one { PRAGMA page_count } ] + expr $nPg>40 && $nPg<50 + } {1} + + do_test 1.$tn.2 { + db close + sqlite3 db test.db + + execsql {PRAGMA journal_mode = wal} + execsql {PRAGMA cache_size = 5} + execsql $xtra + + db transaction { + for {set i 0} {$i < 5} {incr i} { + foreach x [db eval {SELECT x FROM t1}] { + execsql { UPDATE t1 SET y = randomblob(799) WHERE x=$x } + } + } + } + + set nPg [wal_frame_count test.db-wal 1024] + expr $nPg>40 && $nPg<60 + } {1} + + do_execsql_test 1.$tn.3 { PRAGMA integrity_check } ok + + do_test 1.$tn.4 { + forcedelete test.db2 test.db2-wal + forcecopy test.db test.db2 + sqlite3 db2 test.db2 + execsql { SELECT sum(length(y)) FROM t1 } db2 + } [expr 20*800] + + do_test 1.$tn.5 { + db2 close + forcecopy test.db test.db2 + forcecopy test.db-wal test.db2-wal + sqlite3 db2 test.db2 + execsql { SELECT sum(length(y)) FROM t1 } db2 + } [expr 20*799] + + do_test 1.$tn.6 { + execsql { PRAGMA integrity_check } db2 + } ok +} + +finish_test + From c9a9022b216aab23fb756d4a6a47c14cfeb69da7 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 9 Jan 2016 18:57:35 +0000 Subject: [PATCH 165/232] If it is known that checksums will be recalculated on transaction commit, skip calculating checksums when appending frames to the wal file. When recalculating checksums, recalculate them starting with the first overwritten frame - not the first frame in the transaction. FossilOrigin-Name: 16b34f2537bbc7846d8e6dc2b35daae5af241c1b --- manifest | 15 +++++------ manifest.uuid | 2 +- src/wal.c | 71 +++++++++++++++++++++++++-------------------------- 3 files changed, 42 insertions(+), 46 deletions(-) diff --git a/manifest b/manifest index 929a82b2bd..0d9cd20891 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\ssingle\spage\sis\swritten\sto\sthe\swal\sfile\smore\sthan\sonce,\shave\seach\ssubsequent\scopy\soverwrite\sthe\soriginal\sframe. -D 2016-01-09T16:39:29.213 +C If\sit\sis\sknown\sthat\schecksums\swill\sbe\srecalculated\son\stransaction\scommit,\sskip\scalculating\schecksums\swhen\sappending\sframes\sto\sthe\swal\sfile.\sWhen\srecalculating\schecksums,\srecalculate\sthem\sstarting\swith\sthe\sfirst\soverwritten\sframe\s-\snot\sthe\sfirst\sframe\sin\sthe\stransaction. +D 2016-01-09T18:57:35.280 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -409,7 +409,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 88661c24c86d88e40560c0be5df39d902502a29a +F src/wal.c 38ca0c41b510b636dfada0801fad8a99a982dfa6 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c c6d3d2f6af57d574a7365ee2b225a5024f2a6bec @@ -1407,10 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 52c166039831cc8423e2252019ef64a21b9d7c2a -R 7ec438cc7bd0e0a87d33dca3e9bb783a -T *branch * wal-overwrite-frames -T *sym-wal-overwrite-frames * -T -sym-trunk * +P 5d113aef2c7d746e8eda88d4e36c04a39b0a11be +R 68fe235d45cc69355e6b4ad2de6e1633 U dan -Z eba50524221f3f22640b286e867693f1 +Z 339ef03cecb2ba4cae1a0043b973d562 diff --git a/manifest.uuid b/manifest.uuid index 2b25ead966..44ce854f87 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d113aef2c7d746e8eda88d4e36c04a39b0a11be \ No newline at end of file +16b34f2537bbc7846d8e6dc2b35daae5af241c1b \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index c900879d12..d3e2908ba1 100644 --- a/src/wal.c +++ b/src/wal.c @@ -445,6 +445,7 @@ struct Wal { u8 padToSectorBoundary; /* Pad transactions out to the next sector */ WalIndexHdr hdr; /* Wal-index header for current transaction */ u32 minFrame; /* Ignore wal frames before this one */ + u32 iReCksum; /* On commit, recalculate checksums from here */ const char *zWalName; /* Name of WAL file */ u32 nCkpt; /* Checkpoint sequence counter in the wal-header */ #ifdef SQLITE_DEBUG @@ -462,13 +463,6 @@ struct Wal { #define WAL_EXCLUSIVE_MODE 1 #define WAL_HEAPMEMORY_MODE 2 -/* -** Values for Wal.writeLock. -*/ -#define WAL_WRITELOCK_UNLOCKED 0 -#define WAL_WRITELOCK_LOCKED 1 -#define WAL_WRITELOCK_RECKSUM 2 - /* ** Possible values for WAL.readOnly */ @@ -705,14 +699,16 @@ static void walEncodeFrame( assert( WAL_FRAME_HDRSIZE==24 ); sqlite3Put4byte(&aFrame[0], iPage); sqlite3Put4byte(&aFrame[4], nTruncate); - memcpy(&aFrame[8], pWal->hdr.aSalt, 8); + if( pWal->iReCksum==0 ){ + memcpy(&aFrame[8], pWal->hdr.aSalt, 8); - nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN); - walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum); - walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum); + nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN); + walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum); + walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum); - sqlite3Put4byte(&aFrame[16], aCksum[0]); - sqlite3Put4byte(&aFrame[20], aCksum[1]); + sqlite3Put4byte(&aFrame[16], aCksum[0]); + sqlite3Put4byte(&aFrame[20], aCksum[1]); + } } /* @@ -2639,6 +2635,7 @@ int sqlite3WalBeginWriteTransaction(Wal *pWal){ /* Cannot start a write transaction without first holding a read ** transaction. */ assert( pWal->readLock>=0 ); + assert( pWal->writeLock==0 && pWal->iReCksum==0 ); if( pWal->readOnly ){ return SQLITE_READONLY; @@ -2674,6 +2671,7 @@ int sqlite3WalEndWriteTransaction(Wal *pWal){ if( pWal->writeLock ){ walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1); pWal->writeLock = 0; + pWal->iReCksum = 0; pWal->truncateOnCommit = 0; } return SQLITE_OK; @@ -2895,41 +2893,40 @@ static int walWriteOneFrame( /* ** This function is called as part of committing a transaction within which ** one or more frames have been overwritten. It updates the checksums for -** all frames written to the wal file by the current transaction. -** -** Argument pLive is a pointer to the first wal-index header in shared -** memory (the copy readers will see if they open a read-transaction now, -** before the current commit is finished). This is safe to use because the -** caller holds the WRITER lock. The first frame to update the checksum -** for is (pLive->mxFrame+1). The last is argument iLast. +** all frames written to the wal file by the current transaction starting +** with the earliest to have been overwritten. ** ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. */ -static int walRewriteChecksums(Wal *pWal, WalIndexHdr *pLive, u32 iLast){ +static int walRewriteChecksums(Wal *pWal, u32 iLast){ const int szPage = pWal->szPage;/* Database page size */ int rc = SQLITE_OK; /* Return code */ u8 *aBuf; /* Buffer to load data from wal file into */ u8 aFrame[WAL_FRAME_HDRSIZE]; /* Buffer to assemble frame-headers in */ u32 iRead; /* Next frame to read from wal file */ + i64 iCksumOff; aBuf = sqlite3_malloc(szPage + WAL_FRAME_HDRSIZE); if( aBuf==0 ) return SQLITE_NOMEM; - /* Find the checksum values to use as input for the checksum of the - ** first frame written by this transaction. If that frame is frame 1 - ** (implying that the current transaction restarted the wal file), - ** these values must be read from the wal-file header. If the first - ** frame to update the checksum of is not frame 1, then the initial - ** checksum values can be copied from pLive. */ - if( pLive->mxFrame==0 ){ - rc = sqlite3OsRead(pWal->pWalFd, aBuf, sizeof(u32)*2, 24); - pWal->hdr.aFrameCksum[0] = sqlite3Get4byte(aBuf); - pWal->hdr.aFrameCksum[1] = sqlite3Get4byte(&aBuf[sizeof(u32)]); + /* Find the checksum values to use as input for the recalculating the + ** first checksum. If the first frame is frame 1 (implying that the current + ** transaction restarted the wal file), these values must be read from the + ** wal-file header. Otherwise, read them from the frame header of the + ** previous frame. */ + assert( pWal->iReCksum>0 ); + if( pWal->iReCksum==1 ){ + iCksumOff = 24; }else{ - memcpy(pWal->hdr.aFrameCksum, pLive->aFrameCksum, sizeof(u32)*2); + iCksumOff = walFrameOffset(pWal->iReCksum-1, szPage) + 16; } + rc = sqlite3OsRead(pWal->pWalFd, aBuf, sizeof(u32)*2, iCksumOff); + pWal->hdr.aFrameCksum[0] = sqlite3Get4byte(aBuf); + pWal->hdr.aFrameCksum[1] = sqlite3Get4byte(&aBuf[sizeof(u32)]); - for(iRead=pLive->mxFrame+1; rc==SQLITE_OK && iRead<=iLast; iRead++){ + iRead = pWal->iReCksum; + pWal->iReCksum = 0; + for(; rc==SQLITE_OK && iRead<=iLast; iRead++){ i64 iOff = walFrameOffset(iRead, szPage); rc = sqlite3OsRead(pWal->pWalFd, aBuf, szPage+WAL_FRAME_HDRSIZE, iOff); if( rc==SQLITE_OK ){ @@ -3065,7 +3062,9 @@ int sqlite3WalFrames( if( rc ) return rc; if( iWrite>=iFirst ){ i64 iOff = walFrameOffset(iWrite, szPage) + WAL_FRAME_HDRSIZE; - pWal->writeLock = WAL_WRITELOCK_RECKSUM; + if( pWal->iReCksum==0 || iWriteiReCksum ){ + pWal->iReCksum = iWrite; + } rc = sqlite3OsWrite(pWal->pWalFd, p->pData, szPage, iOff); if( rc ) return rc; p->flags &= ~PGHDR_WAL_APPEND; @@ -3084,8 +3083,8 @@ int sqlite3WalFrames( } /* Recalculate checksums within the wal file if required. */ - if( isCommit && pWal->writeLock==WAL_WRITELOCK_RECKSUM ){ - rc = walRewriteChecksums(pWal, pLive, iFrame); + if( isCommit && pWal->iReCksum ){ + rc = walRewriteChecksums(pWal, iFrame); if( rc ) return rc; } From b7c2f86b857f5ff27192e946cd725ba0da59856f Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 9 Jan 2016 23:55:47 +0000 Subject: [PATCH 166/232] All WAL frame overwrites even if there are active savepoints. This is safe because a ROLLBACK TO will cause all reverted pages to be rewritten to the WAL file prior to COMMIT. FossilOrigin-Name: 99b31a6b491c1c51227f478d3713b020d37a17cf --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/pager.c | 7 ------- src/pager.h | 1 - src/wal.c | 4 +--- test/wal.test | 13 ++++++++++--- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 0d9cd20891..fad33f874f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sit\sis\sknown\sthat\schecksums\swill\sbe\srecalculated\son\stransaction\scommit,\sskip\scalculating\schecksums\swhen\sappending\sframes\sto\sthe\swal\sfile.\sWhen\srecalculating\schecksums,\srecalculate\sthem\sstarting\swith\sthe\sfirst\soverwritten\sframe\s-\snot\sthe\sfirst\sframe\sin\sthe\stransaction. -D 2016-01-09T18:57:35.280 +C All\sWAL\sframe\soverwrites\seven\sif\sthere\sare\sactive\ssavepoints.\s\sThis\sis\ssafe\nbecause\sa\sROLLBACK\sTO\swill\scause\sall\sreverted\spages\sto\sbe\srewritten\sto\sthe\nWAL\sfile\sprior\sto\sCOMMIT. +D 2016-01-09T23:55:47.044 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -320,8 +320,8 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 82986e1e75782b54da7822dca42d36d974fc2948 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c c241cace996e19248ddc60f4b8c2e654177e4d3b -F src/pager.h bbbfe27618ac2df8aba22ee0dace08f013351c40 +F src/pager.c 58d2593612acb6b542de6715b4af397ea1fa0a35 +F src/pager.h bf25005b4656cd805af43487c3139fca9678d0cc F src/parse.y caad1e98edeca6960493d0c60d31b76820dd7776 F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 F src/pcache.h 4d0ccaad264d360981ec5e6a2b596d6e85242545 @@ -409,7 +409,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c 38ca0c41b510b636dfada0801fad8a99a982dfa6 +F src/wal.c e1f55f68a7b512c5f6dc5059ca45474442b295ea F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c c6d3d2f6af57d574a7365ee2b225a5024f2a6bec @@ -1279,7 +1279,7 @@ F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test ea8778d5b0df200adef2ca7c00c3c37d4375f772 -F test/wal.test 351bd83d33d41aa1a32f48f74bfebeb8cfcfc23b +F test/wal.test 65bfc68f3f09dcbc62cee9f794e560428d96cec7 F test/wal2.test 1f841d2048080d32f552942e333fd99ce541dada F test/wal3.test b1d425f68a1f61d12563f0fa1ee6fca7d5afabf4 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5d113aef2c7d746e8eda88d4e36c04a39b0a11be -R 68fe235d45cc69355e6b4ad2de6e1633 -U dan -Z 339ef03cecb2ba4cae1a0043b973d562 +P 16b34f2537bbc7846d8e6dc2b35daae5af241c1b +R 7a7df63cdc3481fc553f1ad7c8a16e77 +U drh +Z 48de22511c800e5231d6beb3d37133dd diff --git a/manifest.uuid b/manifest.uuid index 44ce854f87..bb0195b306 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -16b34f2537bbc7846d8e6dc2b35daae5af241c1b \ No newline at end of file +99b31a6b491c1c51227f478d3713b020d37a17cf \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index b333a746e4..2c8dceb750 100644 --- a/src/pager.c +++ b/src/pager.c @@ -7301,13 +7301,6 @@ int sqlite3PagerCloseWal(Pager *pPager){ return rc; } -/* -** Return the number of open savepoints. -**/ -int sqlite3PagerSavepointCount(Pager *pPager){ - return pPager->nSavepoint; -} - #ifdef SQLITE_ENABLE_SNAPSHOT /* ** If this is a WAL database, obtain a snapshot handle for the snapshot diff --git a/src/pager.h b/src/pager.h index c9b766a55c..ba4eec438d 100644 --- a/src/pager.h +++ b/src/pager.h @@ -168,7 +168,6 @@ int sqlite3PagerSharedLock(Pager *pPager); int sqlite3PagerWalCallback(Pager *pPager); int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen); int sqlite3PagerCloseWal(Pager *pPager); - int sqlite3PagerSavepointCount(Pager *pPager); # ifdef SQLITE_ENABLE_SNAPSHOT int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot); int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot); diff --git a/src/wal.c b/src/wal.c index d3e2908ba1..492e2a1dbc 100644 --- a/src/wal.c +++ b/src/wal.c @@ -2981,9 +2981,7 @@ int sqlite3WalFrames( #endif pLive = (WalIndexHdr*)walIndexHdr(pWal); - if( memcmp(&pWal->hdr, (void *)pLive, sizeof(WalIndexHdr))!=0 - && (isCommit || sqlite3PagerSavepointCount(pList->pPager)==0) - ){ + if( memcmp(&pWal->hdr, (void *)pLive, sizeof(WalIndexHdr))!=0 ){ iFirst = pLive->mxFrame+1; } diff --git a/test/wal.test b/test/wal.test index 3646b46c17..abd3a3ce49 100644 --- a/test/wal.test +++ b/test/wal.test @@ -728,9 +728,16 @@ do_test wal-11.9 { list [expr [file size test.db]/1024] [log_deleted test.db-wal] } {37 1} sqlite3_wal db test.db -set nWal 39 -if {[permutation]!="mmap"} {set nWal 37} -ifcapable !mmap {set nWal 37} + +# After adding the capability of WAL to overwrite prior uncommitted +# frame in the WAL-file with revised content, the size of the WAL file +# following cache-spill is smaller. +# +#set nWal 39 +#if {[permutation]!="mmap"} {set nWal 37} +#ifcapable !mmap {set nWal 37} +set nWal 34 + do_test wal-11.10 { execsql { PRAGMA cache_size = 10; From 8997087a0008ca45345c35f871015db2c5a54840 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Jan 2016 00:52:32 +0000 Subject: [PATCH 167/232] Improved testability. FossilOrigin-Name: e83d3a2a4e06665e8a056f63063bd6df03f063b9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/wal.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index fad33f874f..fb39c5119c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C All\sWAL\sframe\soverwrites\seven\sif\sthere\sare\sactive\ssavepoints.\s\sThis\sis\ssafe\nbecause\sa\sROLLBACK\sTO\swill\scause\sall\sreverted\spages\sto\sbe\srewritten\sto\sthe\nWAL\sfile\sprior\sto\sCOMMIT. -D 2016-01-09T23:55:47.044 +C Improved\stestability. +D 2016-01-11T00:52:32.218 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -409,7 +409,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb -F src/wal.c e1f55f68a7b512c5f6dc5059ca45474442b295ea +F src/wal.c 92ca9e7923c337c497e4c9aa7edac800e269a1d8 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba F src/where.c c6d3d2f6af57d574a7365ee2b225a5024f2a6bec @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 16b34f2537bbc7846d8e6dc2b35daae5af241c1b -R 7a7df63cdc3481fc553f1ad7c8a16e77 +P 99b31a6b491c1c51227f478d3713b020d37a17cf +R d76e78fad37168874a95f2cf1af1f963 U drh -Z 48de22511c800e5231d6beb3d37133dd +Z b9a236105d87275bc956baaa16673a98 diff --git a/manifest.uuid b/manifest.uuid index bb0195b306..23e6efc988 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -99b31a6b491c1c51227f478d3713b020d37a17cf \ No newline at end of file +e83d3a2a4e06665e8a056f63063bd6df03f063b9 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 492e2a1dbc..ae6a54849a 100644 --- a/src/wal.c +++ b/src/wal.c @@ -3056,8 +3056,8 @@ int sqlite3WalFrames( ** checksums must be recomputed when the transaction is committed. */ if( iFirst && (p->pDirty || isCommit==0) ){ u32 iWrite = 0; - rc = sqlite3WalFindFrame(pWal, p->pgno, &iWrite); - if( rc ) return rc; + VVA_ONLY(rc =) sqlite3WalFindFrame(pWal, p->pgno, &iWrite); + assert( rc==SQLITE_OK || iWrite==0 ); if( iWrite>=iFirst ){ i64 iOff = walFrameOffset(iWrite, szPage) + WAL_FRAME_HDRSIZE; if( pWal->iReCksum==0 || iWriteiReCksum ){ From 07e8347221da207a6aeee86238af2aaf731ae358 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Jan 2016 03:48:18 +0000 Subject: [PATCH 168/232] Slightly smaller and faster LIKE/GLOB comparison implementation. FossilOrigin-Name: 5dddcc78eec5bcd0c7e8fe1b70875ce775488f0c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 37 +++++++++++++++---------------------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index 45e5e88c6f..7a565aecb3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Typo\sfix\sin\sthe\sprevious\scommit. -D 2016-01-08T22:31:00.176 +C Slightly\ssmaller\sand\sfaster\sLIKE/GLOB\scomparison\simplementation. +D 2016-01-11T03:48:18.694 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -289,7 +289,7 @@ F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c fe55c489362d1429c364e98c877514f4455f45a6 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e18b3dff7d47c7bcac5ac4fc178a89b9fd322b44 -F src/func.c cf5e10af9125b245f1b962e8ba4d520a37818795 +F src/func.c ccaf46fa98f795673afbfab73dff7c18db88f3cd F src/global.c bd5a0af3f30b0c01be6db756c626cd3c33a3d260 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 122c111e360761de8166e16ca151cb7260ee9bf8 -R 459dbc63e3c56e9f1bc36ac4dabf3593 +P 52c166039831cc8423e2252019ef64a21b9d7c2a +R b3c3f3b7322fc6b535d7f3bde12a066b U drh -Z 6b54e5c713520cd21bd942bd06142b38 +Z 4530f1ebb856a62f721161bd7860507a diff --git a/manifest.uuid b/manifest.uuid index 50a7a74425..fe0beaab78 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -52c166039831cc8423e2252019ef64a21b9d7c2a \ No newline at end of file +5dddcc78eec5bcd0c7e8fe1b70875ce775488f0c \ No newline at end of file diff --git a/src/func.c b/src/func.c index ad4cf73c31..45bbb35cd8 100644 --- a/src/func.c +++ b/src/func.c @@ -567,10 +567,10 @@ static void total_changes( ** A structure defining how to do GLOB-style comparisons. */ struct compareInfo { - u8 matchAll; - u8 matchOne; - u8 matchSet; - u8 noCase; + u8 matchAll; /* "*" or "%" */ + u8 matchOne; /* "?" or "_" */ + u8 matchSet; /* "[" or 0 */ + u8 noCase; /* true to ignore case differences */ }; /* @@ -633,22 +633,14 @@ static int patternCompare( const u8 *zPattern, /* The glob pattern */ const u8 *zString, /* The string to compare against the glob */ const struct compareInfo *pInfo, /* Information about how to do the compare */ - u32 esc /* The escape character */ + u32 matchOther /* The escape char (LIKE) or '[' (GLOB) */ ){ u32 c, c2; /* Next pattern and input string chars */ u32 matchOne = pInfo->matchOne; /* "?" or "_" */ u32 matchAll = pInfo->matchAll; /* "*" or "%" */ - u32 matchOther; /* "[" or the escape character */ u8 noCase = pInfo->noCase; /* True if uppercase==lowercase */ const u8 *zEscaped = 0; /* One past the last escaped input char */ - /* The GLOB operator does not have an ESCAPE clause. And LIKE does not - ** have the matchSet operator. So we either have to look for one or - ** the other, never both. Hence the single variable matchOther is used - ** to store the one we have to look for. - */ - matchOther = esc ? esc : pInfo->matchSet; - while( (c = Utf8Read(zPattern))!=0 ){ if( c==matchAll ){ /* Match "*" */ /* Skip over multiple "*" characters in the pattern. If there @@ -662,7 +654,7 @@ static int patternCompare( if( c==0 ){ return 1; /* "*" at the end of the pattern matches */ }else if( c==matchOther ){ - if( esc ){ + if( pInfo->matchSet==0 ){ c = sqlite3Utf8Read(&zPattern); if( c==0 ) return 0; }else{ @@ -670,7 +662,7 @@ static int patternCompare( ** recursive search in this case, but it is an unusual case. */ assert( matchOther<0x80 ); /* '[' is a single-byte character */ while( *zString - && patternCompare(&zPattern[-1],zString,pInfo,esc)==0 ){ + && patternCompare(&zPattern[-1],zString,pInfo,matchOther)==0 ){ SQLITE_SKIP_UTF8(zString); } return *zString!=0; @@ -696,18 +688,18 @@ static int patternCompare( } while( (c2 = *(zString++))!=0 ){ if( c2!=c && c2!=cx ) continue; - if( patternCompare(zPattern,zString,pInfo,esc) ) return 1; + if( patternCompare(zPattern,zString,pInfo,matchOther) ) return 1; } }else{ while( (c2 = Utf8Read(zString))!=0 ){ if( c2!=c ) continue; - if( patternCompare(zPattern,zString,pInfo,esc) ) return 1; + if( patternCompare(zPattern,zString,pInfo,matchOther) ) return 1; } } return 0; } if( c==matchOther ){ - if( esc ){ + if( pInfo->matchSet==0 ){ c = sqlite3Utf8Read(&zPattern); if( c==0 ) return 0; zEscaped = zPattern; @@ -760,7 +752,7 @@ static int patternCompare( ** The sqlite3_strglob() interface. */ int sqlite3_strglob(const char *zGlobPattern, const char *zString){ - return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0; + return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '[')==0; } /* @@ -798,9 +790,10 @@ static void likeFunc( sqlite3_value **argv ){ const unsigned char *zA, *zB; - u32 escape = 0; + u32 escape; int nPat; sqlite3 *db = sqlite3_context_db_handle(context); + struct compareInfo *pInfo = sqlite3_user_data(context); #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS if( sqlite3_value_type(argv[0])==SQLITE_BLOB @@ -840,13 +833,13 @@ static void likeFunc( return; } escape = sqlite3Utf8Read(&zEsc); + }else{ + escape = pInfo->matchSet; } if( zA && zB ){ - struct compareInfo *pInfo = sqlite3_user_data(context); #ifdef SQLITE_TEST sqlite3_like_count++; #endif - sqlite3_result_int(context, patternCompare(zB, zA, pInfo, escape)); } } From c3bd870f09f4d408b73e20b6bc1d53fb5927c08a Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 11 Jan 2016 08:12:40 +0000 Subject: [PATCH 169/232] Add a test case to waloverwrite.test to check that savepoint rollback does not cause a problem. FossilOrigin-Name: 87dae56c322454094d445e474ae36a4f464272a4 --- manifest | 14 ++++---- manifest.uuid | 2 +- test/waloverwrite.test | 72 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 74 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index fb39c5119c..975aaa75ce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\stestability. -D 2016-01-11T00:52:32.218 +C Add\sa\stest\scase\sto\swaloverwrite.test\sto\scheck\sthat\ssavepoint\srollback\sdoes\snot\scause\sa\sproblem. +D 2016-01-11T08:12:40.471 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -1301,7 +1301,7 @@ F test/walfault.test 1f8389f7709877e9b4cc679033d71d6fe529056b F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496 -F test/waloverwrite.test 59476a2cf0638a057ced738b62dc719ed4e32e53 +F test/waloverwrite.test 8702964967c2f28204f0b4f27af65da81999fc99 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6 F test/walro.test 34422d1d95aaff0388f0791ec20edb34e2a3ed57 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417 @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 99b31a6b491c1c51227f478d3713b020d37a17cf -R d76e78fad37168874a95f2cf1af1f963 -U drh -Z b9a236105d87275bc956baaa16673a98 +P e83d3a2a4e06665e8a056f63063bd6df03f063b9 +R 328bc4f1800dd81a2ef2edb5973d61be +U dan +Z 271430cf4c8b2d1a2970f55a9b9d9220 diff --git a/manifest.uuid b/manifest.uuid index 23e6efc988..a1ad7a192a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e83d3a2a4e06665e8a056f63063bd6df03f063b9 \ No newline at end of file +87dae56c322454094d445e474ae36a4f464272a4 \ No newline at end of file diff --git a/test/waloverwrite.test b/test/waloverwrite.test index 02fe4c1ccf..5e51a70d3f 100644 --- a/test/waloverwrite.test +++ b/test/waloverwrite.test @@ -22,18 +22,28 @@ ifcapable !wal {finish_test ; return } # Simple test: # -# 1. Create a database of blobs roughly 50 pages in size. +# Test cases *.1 - *.6: # -# 2. Set the db cache size to something much smaller than this (5 pages) +# + Create a database of blobs roughly 50 pages in size. # -# 3. Within a transaction, loop through the set of blobs 5 times. Update +# + Set the db cache size to something much smaller than this (5 pages) +# +# + Within a transaction, loop through the set of blobs 5 times. Update # each blob as it is visited. # -# 4. Test that the wal file is roughly 50 pages in size - even though many +# + Test that the wal file is roughly 50 pages in size - even though many # database pages have been written to it multiple times. # -# 5. Take a copy of the database and wal file. Test that recovery can -# be run on it. +# + Take a copy of the database and wal file. Test that recovery can +# be run on it. +# +# Test cases *.7 - *.9: +# +# + Same thing, but before committing the statement transaction open +# a SAVEPOINT, update the blobs another 5 times, then roll it back. +# +# + Check that if recovery is run on the resulting wal file, the rolled +# back changes from within the SAVEPOINT are not present in the db. # # The above is run twice - once where the wal file is empty at the start of # step 3 (tn==1) and once where it already contains a transaction (tn==2). @@ -45,6 +55,7 @@ foreach {tn xtra} { reset_db do_execsql_test 1.$tn.0 { CREATE TABLE t1(x, y); + CREATE TABLE t2(x, y); CREATE INDEX i1y ON t1(y); WITH cnt(i) AS ( @@ -98,6 +109,55 @@ foreach {tn xtra} { do_test 1.$tn.6 { execsql { PRAGMA integrity_check } db2 } ok + db2 close + + do_test 1.$tn.7 { + execsql { PRAGMA wal_checkpoint } + db transaction { + for {set i 0} {$i < 1} {incr i} { + foreach x [db eval {SELECT x FROM t1}] { + execsql { UPDATE t1 SET y = randomblob(798) WHERE x=$x } + } + } + + execsql { + WITH cnt(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM cnt WHERE i<20) + INSERT INTO t2 SELECT i, randomblob(800) FROM cnt; + } + + execsql {SAVEPOINT abc} + for {set i 0} {$i < 5} {incr i} { + foreach x [db eval {SELECT x FROM t1}] { + execsql { UPDATE t1 SET y = randomblob(797) WHERE x=$x } + } + } + breakpoint + execsql {ROLLBACK TO abc} + + } + + set nPg [wal_frame_count test.db-wal 1024] + expr $nPg>55 && $nPg<75 + } {1} + + do_test 1.$tn.8 { + forcedelete test.db2 test.db2-wal + forcecopy test.db test.db2 + sqlite3 db2 test.db2 + execsql { SELECT sum(length(y)) FROM t1 } db2 + } [expr 20*799] + + do_test 1.$tn.9 { + db2 close + forcecopy test.db-wal test.db2-wal + sqlite3 db2 test.db2 + execsql { SELECT sum(length(y)) FROM t1 } db2 + } [expr 20*798] + + do_test 1.$tn.9 { + execsql { PRAGMA integrity_check } db2 + } ok + db2 close } finish_test From 2fca70569d8db348a85c059151b2af5d20527302 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Jan 2016 12:52:55 +0000 Subject: [PATCH 170/232] Increase the version number to 3.11.0 due to the WAL overwrite enhancement. FossilOrigin-Name: 8e807bfaa197027d0cb73532baa96755ce71ea12 --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 17 ++++++++--------- manifest.uuid | 2 +- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/VERSION b/VERSION index 30291cba22..afad818663 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.10.0 +3.11.0 diff --git a/configure b/configure index 174f41ae24..850d986306 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sqlite 3.10.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.11.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -726,8 +726,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.10.0' -PACKAGE_STRING='sqlite 3.10.0' +PACKAGE_VERSION='3.11.0' +PACKAGE_STRING='sqlite 3.11.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1460,7 +1460,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.10.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.11.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1525,7 +1525,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.10.0:";; + short | recursive ) echo "Configuration of sqlite 3.11.0:";; esac cat <<\_ACEOF @@ -1646,7 +1646,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.10.0 +sqlite configure 3.11.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2065,7 +2065,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.10.0, which was +It was created by sqlite $as_me 3.11.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -12023,7 +12023,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.10.0, which was +This file was extended by sqlite $as_me 3.11.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12089,7 +12089,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.10.0 +sqlite config.status 3.11.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/manifest b/manifest index 61584e65e4..b94535791e 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C If\sa\ssingle\spage\sis\swritten\sto\sthe\swal\sfile\smore\sthan\sonce,\sinstead\sof\sappending\sthe\ssecond\sand\ssubsequent\scopy\sto\sthe\swal\sfile,\soverwrite\sthe\sfirst. -D 2016-01-11T12:13:47.299 +C Increase\sthe\sversion\snumber\sto\s3.11.0\sdue\sto\sthe\sWAL\soverwrite\senhancement. +D 2016-01-11T12:52:55.912 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 -F VERSION 8b9d3ac6f1962f94e06ba05462422a544f9c4e36 +F VERSION 866588d1edf0ccb5b0d33896974338f97564f719 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 @@ -29,7 +29,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 42b71ad3fe21c9e88fa59e8458ca1a6bc72eb0c0 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure e511ceefe595e35051933a90c848ab4fa1d48add x +F configure b4519bb54fff37e7cde9d03d8f2946f18d5d0086 x F configure.ac fcfc67b323d32daaa3e46cf7782d9465ed423a6d F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1 @@ -1407,8 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5dddcc78eec5bcd0c7e8fe1b70875ce775488f0c 87dae56c322454094d445e474ae36a4f464272a4 -R 52e14e84cadc34ac79ad50b8340775a5 -T +closed 87dae56c322454094d445e474ae36a4f464272a4 -U dan -Z be438c4ccb03f7e22074fee8f0915a54 +P d493d4f1186c15da50558a13490cba0191e6f649 +R a92483f04fb0661e2d9ab2766c996317 +U drh +Z d2a7370395d09ae9d2ddb7bbbb25edc7 diff --git a/manifest.uuid b/manifest.uuid index 5ee49b098d..7d0842e5bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d493d4f1186c15da50558a13490cba0191e6f649 \ No newline at end of file +8e807bfaa197027d0cb73532baa96755ce71ea12 \ No newline at end of file From 50922cfc7c12514d44bc6641e9e44833eb4b637b Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Jan 2016 14:19:14 +0000 Subject: [PATCH 171/232] Performance optimization in sqlite3WalkExpr(). FossilOrigin-Name: 2f8bd5fab8cc51d1f8932c3490fd24dbccf6ef31 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/walker.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b94535791e..7c3ae97b20 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Increase\sthe\sversion\snumber\sto\s3.11.0\sdue\sto\sthe\sWAL\soverwrite\senhancement. -D 2016-01-11T12:52:55.912 +C Performance\soptimization\sin\ssqlite3WalkExpr(). +D 2016-01-11T14:19:14.339 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -411,7 +411,7 @@ F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 92ca9e7923c337c497e4c9aa7edac800e269a1d8 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b -F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba +F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c c6d3d2f6af57d574a7365ee2b225a5024f2a6bec F src/whereInt.h 78b6b4de94db84aecbdc07fe3e38f648eb391e9a F src/wherecode.c dfbfe198e418b01f208b489e088edd230c91a4e7 @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d493d4f1186c15da50558a13490cba0191e6f649 -R a92483f04fb0661e2d9ab2766c996317 +P 8e807bfaa197027d0cb73532baa96755ce71ea12 +R 177e5551beb5399a29df920e18a04961 U drh -Z d2a7370395d09ae9d2ddb7bbbb25edc7 +Z b8d12fcc18213355136dacd10d5cf924 diff --git a/manifest.uuid b/manifest.uuid index 7d0842e5bd..1f83d937d4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e807bfaa197027d0cb73532baa96755ce71ea12 \ No newline at end of file +2f8bd5fab8cc51d1f8932c3490fd24dbccf6ef31 \ No newline at end of file diff --git a/src/walker.c b/src/walker.c index 81e0f2cd60..1e0ad32871 100644 --- a/src/walker.c +++ b/src/walker.c @@ -36,9 +36,8 @@ ** The return value from this routine is WRC_Abort to abandon the tree walk ** and WRC_Continue to continue. */ -int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){ +static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ int rc; - if( pExpr==0 ) return WRC_Continue; testcase( ExprHasProperty(pExpr, EP_TokenOnly) ); testcase( ExprHasProperty(pExpr, EP_Reduced) ); rc = pWalker->xExprCallback(pWalker, pExpr); @@ -54,6 +53,9 @@ int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){ } return rc & WRC_Abort; } +int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){ + return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue; +} /* ** Call sqlite3WalkExpr() for every expression in list p or until From aaf17c41ec558e2c0c174055c6dcbbd1908aa290 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 11 Jan 2016 17:30:28 +0000 Subject: [PATCH 172/232] Fix bugs in fts5 synonym processing for detail=col and other modes. FossilOrigin-Name: 0e3c545423246231ddac8fed2f103d71d556e17f --- ext/fts5/fts5_expr.c | 106 +++++++++++++++++++++++--------- ext/fts5/test/fts5synonym2.test | 25 ++++++-- manifest | 14 ++--- manifest.uuid | 2 +- 4 files changed, 106 insertions(+), 41 deletions(-) diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 3804a2abfe..16209bf4ba 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -40,6 +40,7 @@ void sqlite3Fts5ParserTrace(FILE*, char*); struct Fts5Expr { Fts5Index *pIndex; + Fts5Config *pConfig; Fts5ExprNode *pRoot; int bDesc; /* Iterate in descending rowid order */ int nPhrase; /* Number of phrases in expression */ @@ -235,6 +236,7 @@ int sqlite3Fts5ExprNew( }else{ pNew->pRoot = sParse.pExpr; pNew->pIndex = 0; + pNew->pConfig = pConfig; pNew->apExprPhrase = sParse.apPhrase; pNew->nPhrase = sParse.nPhrase; sParse.apPhrase = 0; @@ -299,8 +301,9 @@ static i64 fts5ExprSynonymRowid(Fts5ExprTerm *pTerm, int bDesc, int *pbEof){ /* ** Argument pTerm must be a synonym iterator. */ -static int fts5ExprSynonymPoslist( +static int fts5ExprSynonymList( Fts5ExprTerm *pTerm, + int bCollist, Fts5Colset *pColset, i64 iRowid, int *pbDel, /* OUT: Caller should sqlite3_free(*pa) */ @@ -319,9 +322,16 @@ static int fts5ExprSynonymPoslist( if( sqlite3Fts5IterEof(pIter)==0 && sqlite3Fts5IterRowid(pIter)==iRowid ){ const u8 *a; int n; - i64 dummy; - rc = sqlite3Fts5IterPoslist(pIter, pColset, &a, &n, &dummy); + + if( bCollist ){ + rc = sqlite3Fts5IterCollist(pIter, &a, &n); + }else{ + i64 dummy; + rc = sqlite3Fts5IterPoslist(pIter, pColset, &a, &n, &dummy); + } + if( rc!=SQLITE_OK ) goto synonym_poslist_out; + if( n==0 ) continue; if( nIter==nAlloc ){ int nByte = sizeof(Fts5PoslistReader) * nAlloc * 2; Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc(nByte); @@ -422,8 +432,8 @@ static int fts5ExprPhraseIsMatch( int bFlag = 0; const u8 *a = 0; if( pTerm->pSynonym ){ - rc = fts5ExprSynonymPoslist( - pTerm, pColset, pNode->iRowid, &bFlag, (u8**)&a, &n + rc = fts5ExprSynonymList( + pTerm, 0, pColset, pNode->iRowid, &bFlag, (u8**)&a, &n ); }else{ rc = sqlite3Fts5IterPoslist(pTerm->pIter, pColset, &a, &n, &dummy); @@ -757,30 +767,51 @@ static int fts5ExprNearTest( ){ Fts5ExprNearset *pNear = pNode->pNear; int rc = *pRc; - int i; - /* Check that each phrase in the nearset matches the current row. - ** Populate the pPhrase->poslist buffers at the same time. If any - ** phrase is not a match, break out of the loop early. */ - for(i=0; rc==SQLITE_OK && inPhrase; i++){ - Fts5ExprPhrase *pPhrase = pNear->apPhrase[i]; - if( pPhrase->nTerm>1 || pPhrase->aTerm[0].pSynonym || pNear->pColset ){ - int bMatch = 0; - rc = fts5ExprPhraseIsMatch(pNode, pNear->pColset, pPhrase, &bMatch); - if( bMatch==0 ) break; - }else{ - rc = sqlite3Fts5IterPoslistBuffer( - pPhrase->aTerm[0].pIter, &pPhrase->poslist - ); + if( pExpr->pConfig->eDetail!=FTS5_DETAIL_FULL ){ + Fts5ExprTerm *pTerm; + Fts5ExprPhrase *pPhrase = pNear->apPhrase[0]; + pPhrase->poslist.n = 0; + for(pTerm=&pPhrase->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){ + Fts5IndexIter *pIter = pTerm->pIter; + if( sqlite3Fts5IterEof(pIter)==0 ){ + int n; + i64 iRowid; + rc = sqlite3Fts5IterPoslist(pIter, pNear->pColset, 0, &n, &iRowid); + if( rc!=SQLITE_OK ){ + *pRc = rc; + return 0; + }else if( iRowid==pNode->iRowid && n>0 ){ + pPhrase->poslist.n = 1; + } + } } - } + return pPhrase->poslist.n; + }else{ + int i; - *pRc = rc; - if( i==pNear->nPhrase && (i==1 || fts5ExprNearIsMatch(pRc, pNear)) ){ - return 1; - } + /* Check that each phrase in the nearset matches the current row. + ** Populate the pPhrase->poslist buffers at the same time. If any + ** phrase is not a match, break out of the loop early. */ + for(i=0; rc==SQLITE_OK && inPhrase; i++){ + Fts5ExprPhrase *pPhrase = pNear->apPhrase[i]; + if( pPhrase->nTerm>1 || pPhrase->aTerm[0].pSynonym || pNear->pColset ){ + int bMatch = 0; + rc = fts5ExprPhraseIsMatch(pNode, pNear->pColset, pPhrase, &bMatch); + if( bMatch==0 ) break; + }else{ + rc = sqlite3Fts5IterPoslistBuffer( + pPhrase->aTerm[0].pIter, &pPhrase->poslist + ); + } + } - return 0; + *pRc = rc; + if( i==pNear->nPhrase && (i==1 || fts5ExprNearIsMatch(pRc, pNear)) ){ + return 1; + } + return 0; + } } static int fts5ExprTokenTest( @@ -1606,6 +1637,7 @@ int sqlite3Fts5ExprClonePhrase( if( rc==SQLITE_OK ){ /* All the allocations succeeded. Put the expression object together. */ pNew->pIndex = pExpr->pIndex; + pNew->pConfig = pExpr->pConfig; pNew->nPhrase = 1; pNew->apExprPhrase[0] = sCtx.pPhrase; pNew->pRoot->pNear->apPhrase[0] = sCtx.pPhrase; @@ -2453,17 +2485,35 @@ int sqlite3Fts5ExprPhraseCollist( ){ Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase]; Fts5ExprNode *pNode = pPhrase->pNode; - assert( iPhrase>=0 && iPhrasenPhrase ); + int rc = SQLITE_OK; + assert( iPhrase>=0 && iPhrasenPhrase ); if( pNode->bEof==0 && pNode->iRowid==pExpr->pRoot->iRowid && pPhrase->poslist.n>0 ){ - sqlite3Fts5IterCollist(pPhrase->aTerm[0].pIter, ppCollist, pnCollist); + Fts5ExprTerm *pTerm = &pPhrase->aTerm[0]; + if( pTerm->pSynonym ){ + int bDel = 0; + u8 *a; + rc = fts5ExprSynonymList( + pTerm, 1, 0, pNode->iRowid, &bDel, &a, pnCollist + ); + if( bDel ){ + sqlite3Fts5BufferSet(&rc, &pPhrase->poslist, *pnCollist, a); + *ppCollist = pPhrase->poslist.p; + sqlite3_free(a); + }else{ + *ppCollist = a; + } + }else{ + sqlite3Fts5IterCollist(pPhrase->aTerm[0].pIter, ppCollist, pnCollist); + } }else{ *ppCollist = 0; *pnCollist = 0; } - return SQLITE_OK; + + return rc; } diff --git a/ext/fts5/test/fts5synonym2.test b/ext/fts5/test/fts5synonym2.test index e3a8003758..96cacb293f 100644 --- a/ext/fts5/test/fts5synonym2.test +++ b/ext/fts5/test/fts5synonym2.test @@ -13,7 +13,7 @@ # source [file join [file dirname [info script]] fts5_common.tcl] -set testprefix fts5synonym +set testprefix fts5synonym2 # If SQLITE_ENABLE_FTS5 is defined, omit this file. ifcapable !fts5 { @@ -47,7 +47,7 @@ proc tcl_tokenize {tflags text} { foreach {w iStart iEnd} [fts5_tokenize_split $text] { sqlite3_fts5_token $w $iStart $iEnd if {$tflags == "query"} { - foreach s $::SYNDICT($w) { sqlite3_fts5_token -colo $s $iStart $iEnd } + foreach s $::syn($w) { sqlite3_fts5_token -colo $s $iStart $iEnd } } } } @@ -67,7 +67,6 @@ fts5_aux_test_functions db do_execsql_test 1.0 { CREATE VIRTUAL TABLE ss USING fts5(a, b, tokenize=tcl, detail=%DETAIL%); - INSERT INTO ss VALUES('5 5 five seven 3 seven i', '2 1 5 0 two 1 i'); INSERT INTO ss VALUES('six ix iii 7 i vii iii', 'one seven nine 4 9 1 vi'); INSERT INTO ss VALUES('6 viii i five six zero seven', '5 v iii iv iv 3'); @@ -120,14 +119,30 @@ do_execsql_test 1.0 { } foreach {tn expr} { - 1 "eight" + 1.1 "one" 1.2 "two" 1.3 "three" 1.4 "four" + 1.5 "v" 1.6 "vi" 1.7 "vii" 1.8 "viii" + 1.9 "9" 1.10 "0" 1.11 "1" 1.12 "2" + + 2.1 "one OR two OR three OR four" + 2.2 "(one AND two) OR (three AND four)" + 2.3 "(one AND two) OR (three AND four) NOT five" + 2.4 "(one AND two) NOT 6" + + 3.1 "b:one AND a:two" + 3.2 "b:one OR a:two" + 3.3 "a:one OR b:1 OR {a b} : i" + + 4.1 "NEAR(one two, 2)" + 4.2 "NEAR(one two three, 2)" + 4.3 "NEAR(eight nine, 1) OR NEAR(six seven, 1)" } { if {[fts5_expr_ok $expr ss]==0} { do_test 1.$tn.OMITTED { list } [list] continue } - set res [fts5_query_data $expr ss ASC ::SYNDICT] + set res [fts5_query_data $expr ss ASC ::syn] + breakpoint do_execsql_test 1.$tn.[llength $res].asc { SELECT rowid, fts5_test_poslist(ss), fts5_test_collist(ss) FROM ss($expr) } $res diff --git a/manifest b/manifest index 48daf058c3..e4ef860b2c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Begin\sadding\sfts5\stests\sinvolving\ssynonyms\sand\sdetail=none/col\stables. -D 2016-01-08T17:21:18.901 +C Fix\sbugs\sin\sfts5\ssynonym\sprocessing\sfor\sdetail=col\sand\sother\smodes. +D 2016-01-11T17:30:28.056 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -101,7 +101,7 @@ F ext/fts5/fts5Int.h 3918045ebceb1d600c9c1c1b460489ff0c788e96 F ext/fts5/fts5_aux.c 2dafc3aee0c70d643140c77d8d70daffa51a9e9e F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 -F ext/fts5/fts5_expr.c 913ab9f9a7651d76f055f9847ca0ae0e2f5da78d +F ext/fts5/fts5_expr.c 6eba2220747ea1b20a358fb3b34b2ab78323e285 F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 F ext/fts5/fts5_index.c 04fe098ffab66d9424ba4e7c0b88ce7c98748cb1 F ext/fts5/fts5_main.c 03bd44e4bd0ba16213ca9259ad5df1d4d743fd7e @@ -173,7 +173,7 @@ F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 F ext/fts5/test/fts5simple.test 2bc6451cbe887a9215f5b14ae307c70d850344c9 F ext/fts5/test/fts5simple2.test 843f1f7fe439ff32bf74f4fd6430632f9636ef3a F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 -F ext/fts5/test/fts5synonym2.test 6aa842d0e5bd019db0c3597e0860eb68eb2867e4 +F ext/fts5/test/fts5synonym2.test d2d9099d9d105b55ea03fd52d61ae2847d534129 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 F ext/fts5/test/fts5unicode.test fbef8d8a3b4b88470536cc57604a82ca52e51841 F ext/fts5/test/fts5unicode2.test c1dd890ba32b7609adba78e420faa847abe43b59 @@ -1410,7 +1410,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d9135cc723fc4227aace6dcf4ffa4630c9d23aa0 -R c443735bd0d019a3a4798f3f3350cb78 +P b3e6f15ec2d9a834e2c80b91ffd7097553816228 +R f239c4ba67c1753046748953bb2cde92 U dan -Z 48c62f9fa751846d5897bddd7cc5158f +Z 915aa1f2ec9df261dd260c37cdbace05 diff --git a/manifest.uuid b/manifest.uuid index dc0f491a48..3b1a59f4b6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b3e6f15ec2d9a834e2c80b91ffd7097553816228 \ No newline at end of file +0e3c545423246231ddac8fed2f103d71d556e17f \ No newline at end of file From 69f6e2587bef21d7faa3f11748529ac8b96f8641 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Jan 2016 18:05:00 +0000 Subject: [PATCH 173/232] Performance optimization on the Column opcode. FossilOrigin-Name: ecc98bef43c2fd07d64e4efddf340929a875ebac --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 54 ++++++++++++++++++++++++++------------------------- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/manifest b/manifest index 7c3ae97b20..e4dfdc13fc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\soptimization\sin\ssqlite3WalkExpr(). -D 2016-01-11T14:19:14.339 +C Performance\soptimization\son\sthe\sColumn\sopcode. +D 2016-01-11T18:05:00.482 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -398,7 +398,7 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 6ac8e5d808d48afc369316e147c191102f0584c1 +F src/vdbe.c 6572d00eefeaa0b14b325fdf3a409920ec3fee82 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8e807bfaa197027d0cb73532baa96755ce71ea12 -R 177e5551beb5399a29df920e18a04961 +P 2f8bd5fab8cc51d1f8932c3490fd24dbccf6ef31 +R 68508ce4367c0efdf38feafa98972c4a U drh -Z b8d12fcc18213355136dacd10d5cf924 +Z e90441a49428aea3c83069305613bb8e diff --git a/manifest.uuid b/manifest.uuid index 1f83d937d4..bccf8bb6b0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f8bd5fab8cc51d1f8932c3490fd24dbccf6ef31 \ No newline at end of file +ecc98bef43c2fd07d64e4efddf340929a875ebac \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 5acb3b3137..7eb4c0baeb 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2374,7 +2374,6 @@ case OP_Column: { u64 offset64; /* 64-bit offset */ u32 avail; /* Number of bytes of available data */ u32 t; /* A type code from the record header */ - u16 fx; /* pDest->flags value */ Mem *pReg; /* PseudoTable input register */ p2 = pOp->p2; @@ -2552,10 +2551,31 @@ case OP_Column: { assert( sqlite3VdbeCheckMemInvariants(pDest) ); if( VdbeMemDynamic(pDest) ) sqlite3VdbeMemSetNull(pDest); assert( t==pC->aType[p2] ); + pDest->enc = encoding; if( pC->szRow>=aOffset[p2+1] ){ /* This is the common case where the desired content fits on the original ** page - where the content is not on an overflow page */ - sqlite3VdbeSerialGet(pC->aRow+aOffset[p2], t, pDest); + zData = pC->aRow + aOffset[p2]; + if( t<12 ){ + sqlite3VdbeSerialGet(zData, t, pDest); + }else{ + /* If the column value is a string, we need a persistent value, not + ** a MEM_Ephem value. This branch is a fast short-cut that is equivalent + ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize(). + */ + static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term }; + pDest->n = len = (t-12)/2; + if( pDest->szMalloc < len+2 ){ + pDest->flags = MEM_Null; + if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem; + }else{ + pDest->z = pDest->zMalloc; + } + memcpy(pDest->z, zData, len); + pDest->z[len] = 0; + pDest->z[len+1] = 0; + pDest->flags = aFlag[t&1]; + } }else{ /* This branch happens only when content is on overflow pages */ if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0 @@ -2567,38 +2587,20 @@ case OP_Column: { ** 2. the length(X) function if X is a blob, and ** 3. if the content length is zero. ** So we might as well use bogus content rather than reading - ** content from disk. NULL will work for the value for strings - ** and blobs and whatever is in the payloadSize64 variable - ** will work for everything else. */ - sqlite3VdbeSerialGet(t<=13 ? (u8*)&payloadSize64 : 0, t, pDest); + ** content from disk. */ + static u8 aZero[8]; /* This is the bogus content */ + sqlite3VdbeSerialGet(aZero, t, pDest); }else{ rc = sqlite3VdbeMemFromBtree(pCrsr, aOffset[p2], len, !pC->isTable, pDest); - if( rc!=SQLITE_OK ){ - goto op_column_error; + if( rc==SQLITE_OK ){ + sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest); + pDest->flags &= ~MEM_Ephem; } - sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest); - pDest->flags &= ~MEM_Ephem; } } - pDest->enc = encoding; op_column_out: - /* If the column value is an ephemeral string, go ahead and persist - ** that string in case the cursor moves before the column value is - ** used. The following code does the equivalent of Deephemeralize() - ** but does it faster. */ - if( (pDest->flags & MEM_Ephem)!=0 && pDest->z ){ - fx = pDest->flags & (MEM_Str|MEM_Blob); - assert( fx!=0 ); - zData = (const u8*)pDest->z; - len = pDest->n; - if( sqlite3VdbeMemClearAndResize(pDest, len+2) ) goto no_mem; - memcpy(pDest->z, zData, len); - pDest->z[len] = 0; - pDest->z[len+1] = 0; - pDest->flags = fx|MEM_Term; - } op_column_error: UPDATE_MAX_BLOBSIZE(pDest); REGISTER_TRACE(pOp->p3, pDest); From 6a657b2477c4b8d5b67506e9a553a150d482bc1b Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 11 Jan 2016 18:23:07 +0000 Subject: [PATCH 174/232] Add the fts5speed.tcl script to ext/fts5/tool/. FossilOrigin-Name: 2c0b93553ebb00a70c611eb8dac021877933f088 --- ext/fts5/tool/fts5speed.tcl | 59 +++++++++++++++++++++++++++++++++++++ manifest | 11 +++---- manifest.uuid | 2 +- 3 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 ext/fts5/tool/fts5speed.tcl diff --git a/ext/fts5/tool/fts5speed.tcl b/ext/fts5/tool/fts5speed.tcl new file mode 100644 index 0000000000..1b060ea759 --- /dev/null +++ b/ext/fts5/tool/fts5speed.tcl @@ -0,0 +1,59 @@ + + +set Q { + {1 "SELECT count(*) FROM t1 WHERE t1 MATCH 'enron'"} + {25 "SELECT count(*) FROM t1 WHERE t1 MATCH 'hours'"} + {300 "SELECT count(*) FROM t1 WHERE t1 MATCH 'acid'"} + {100 "SELECT count(*) FROM t1 WHERE t1 MATCH 'loaned OR mobility OR popcore OR sunk'"} + {100 "SELECT count(*) FROM t1 WHERE t1 MATCH 'enron AND myapps'"} + {1 "SELECT count(*) FROM t1 WHERE t1 MATCH 'en* AND my*'"} + + {1 "SELECT count(*) FROM t1 WHERE t1 MATCH 'c:t*'"} + {1 "SELECT count(*) FROM t1 WHERE t1 MATCH 'a:t* OR b:t* OR c:t* OR d:t* OR e:t* OR f:t* OR g:t*'"} + {1 "SELECT count(*) FROM t1 WHERE t1 MATCH 'a:t*'"} +} + +proc usage {} { + global Q + puts stderr "Usage: $::argv0 DATABASE QUERY" + puts stderr "" + for {set i 1} {$i <= [llength $Q]} {incr i} { + puts stderr " $i. [lindex $Q [expr $i-1]]" + } + puts stderr "" + exit -1 +} + + +set nArg [llength $argv] +if {$nArg!=2 && $nArg!=3} usage +set database [lindex $argv 0] +set iquery [lindex $argv 1] +if {$iquery<1 || $iquery>[llength $Q]} usage +set nRepeat 0 +if {$nArg==3} { set nRepeat [lindex $argv 2] } + + +sqlite3 db $database +catch { load_static_extension db fts5 } + +incr iquery -1 +set sql [lindex $Q $iquery 1] +if {$nRepeat==0} { + set nRepeat [lindex $Q $iquery 0] +} + +puts "sql: $sql" +puts "nRepeat: $nRepeat" +if {[regexp matchinfo $sql]} { + sqlite3_fts5_register_matchinfo db + db eval $sql +} else { + puts "result: [db eval $sql]" +} + +for {set i 1} {$i < $nRepeat} {incr i} { + db eval $sql +} + + diff --git a/manifest b/manifest index e4ef860b2c..6158acb724 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sbugs\sin\sfts5\ssynonym\sprocessing\sfor\sdetail=col\sand\sother\smodes. -D 2016-01-11T17:30:28.056 +C Add\sthe\sfts5speed.tcl\sscript\sto\sext/fts5/tool/. +D 2016-01-11T18:23:07.397 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -181,6 +181,7 @@ F ext/fts5/test/fts5unicode3.test 35c3d02aa7acf7d43d8de3bfe32c15ba96e8928e F ext/fts5/test/fts5unindexed.test e9539d5b78c677315e7ed8ea911d4fd25437c680 F ext/fts5/test/fts5version.test 978f59541d8cef7e8591f8be2115ec5ccb863e2e F ext/fts5/test/fts5vocab.test e4b12f238f113795615ba6343b63fb326d6a360e +F ext/fts5/tool/fts5speed.tcl aaee41894b552df8fbf8616aad003b2ea9ba3221 F ext/fts5/tool/fts5txt2db.tcl c374c4c4797e8cdfadabdfaeeb5412dcd6686e84 F ext/fts5/tool/loadfts5.tcl 4cc2d6af43b58d4fac05bc4fdabd0e5862c3b2c1 F ext/fts5/tool/mkfts5c.tcl d1c2a9ab8e0ec690a52316f33dd9b1d379942f45 @@ -1410,7 +1411,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b3e6f15ec2d9a834e2c80b91ffd7097553816228 -R f239c4ba67c1753046748953bb2cde92 +P 0e3c545423246231ddac8fed2f103d71d556e17f +R af2ae430a57fbc5161db0dbbd31b8a3f U dan -Z 915aa1f2ec9df261dd260c37cdbace05 +Z 7e47e5a1c7084b8fa203746692b6702a diff --git a/manifest.uuid b/manifest.uuid index 3b1a59f4b6..7a083e6ea4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0e3c545423246231ddac8fed2f103d71d556e17f \ No newline at end of file +2c0b93553ebb00a70c611eb8dac021877933f088 \ No newline at end of file From 46414c29ba18e587643f8e95c9232367ef0839d0 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 11 Jan 2016 22:43:04 +0000 Subject: [PATCH 175/232] Fix duplicate test number in 'waloverwrite'. FossilOrigin-Name: f5fb82686697e5fa1937323b1c1b35cf90ad0302 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/waloverwrite.test | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index e4dfdc13fc..6a59c023df 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\soptimization\son\sthe\sColumn\sopcode. -D 2016-01-11T18:05:00.482 +C Fix\sduplicate\stest\snumber\sin\s'waloverwrite'. +D 2016-01-11T22:43:04.382 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -1301,7 +1301,7 @@ F test/walfault.test 1f8389f7709877e9b4cc679033d71d6fe529056b F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496 -F test/waloverwrite.test 8702964967c2f28204f0b4f27af65da81999fc99 +F test/waloverwrite.test a0d2ae0783187374c1e6a9571e0916152977cb81 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6 F test/walro.test 34422d1d95aaff0388f0791ec20edb34e2a3ed57 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417 @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2f8bd5fab8cc51d1f8932c3490fd24dbccf6ef31 -R 68508ce4367c0efdf38feafa98972c4a -U drh -Z e90441a49428aea3c83069305613bb8e +P ecc98bef43c2fd07d64e4efddf340929a875ebac +R bffff77db2267e7f44f05491f1b6c72d +U mistachkin +Z 70102cc7ed23bad282b82f2981075253 diff --git a/manifest.uuid b/manifest.uuid index bccf8bb6b0..d694eba5b3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ecc98bef43c2fd07d64e4efddf340929a875ebac \ No newline at end of file +f5fb82686697e5fa1937323b1c1b35cf90ad0302 \ No newline at end of file diff --git a/test/waloverwrite.test b/test/waloverwrite.test index 5e51a70d3f..aa1154fb97 100644 --- a/test/waloverwrite.test +++ b/test/waloverwrite.test @@ -154,7 +154,7 @@ foreach {tn xtra} { execsql { SELECT sum(length(y)) FROM t1 } db2 } [expr 20*798] - do_test 1.$tn.9 { + do_test 1.$tn.10 { execsql { PRAGMA integrity_check } db2 } ok db2 close From 00dcecab193d4b9c008caa50ccb10f479a5aae96 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Jan 2016 22:58:50 +0000 Subject: [PATCH 176/232] Performance optimization in the sqlite3VdbeChangeP4() routine of the code generator. FossilOrigin-Name: 28bd8d5fc541464b69886b7e886939035b42a869 --- manifest | 16 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 68 +++++++++++++++++++++++---------------------------- src/where.c | 3 +-- 4 files changed, 41 insertions(+), 48 deletions(-) diff --git a/manifest b/manifest index 6a59c023df..41cffbc0d6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sduplicate\stest\snumber\sin\s'waloverwrite'. -D 2016-01-11T22:43:04.382 +C Performance\soptimization\sin\sthe\ssqlite3VdbeChangeP4()\sroutine\sof\sthe\ncode\sgenerator. +D 2016-01-11T22:58:50.164 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -402,7 +402,7 @@ F src/vdbe.c 6572d00eefeaa0b14b325fdf3a409920ec3fee82 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 5d8c7c04e0f677033efb1292248a5f9056bbc34c +F src/vdbeaux.c f2e6b4fae037db04323be8de7bcd266375746471 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -412,7 +412,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 92ca9e7923c337c497e4c9aa7edac800e269a1d8 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c c6d3d2f6af57d574a7365ee2b225a5024f2a6bec +F src/where.c bb69654f841ae7af0a20cc6fb8f0ac57901c31be F src/whereInt.h 78b6b4de94db84aecbdc07fe3e38f648eb391e9a F src/wherecode.c dfbfe198e418b01f208b489e088edd230c91a4e7 F src/whereexpr.c eebba8340c90de73b3d3bbe8c43b84559b8e6e2c @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ecc98bef43c2fd07d64e4efddf340929a875ebac -R bffff77db2267e7f44f05491f1b6c72d -U mistachkin -Z 70102cc7ed23bad282b82f2981075253 +P f5fb82686697e5fa1937323b1c1b35cf90ad0302 +R 5cc83036f9c9da1fadf85dd4abd0f133 +U drh +Z a8c9a7d6a102c57d4a0aed7eac3aa290 diff --git a/manifest.uuid b/manifest.uuid index d694eba5b3..aa9453cfcd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f5fb82686697e5fa1937323b1c1b35cf90ad0302 \ No newline at end of file +28bd8d5fc541464b69886b7e886939035b42a869 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index aa8070a132..2f65d85777 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -305,8 +305,7 @@ int sqlite3VdbeAddOp4Dup8( */ void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){ int j; - int addr = sqlite3VdbeAddOp3(p, OP_ParseSchema, iDb, 0, 0); - sqlite3VdbeChangeP4(p, addr, zWhere, P4_DYNAMIC); + sqlite3VdbeAddOp4(p, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC); for(j=0; jdb->nDb; j++) sqlite3VdbeUsesBtree(p, j); } @@ -805,7 +804,7 @@ static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){ if( aOp ){ Op *pOp; for(pOp=aOp; pOp<&aOp[nOp]; pOp++){ - freeP4(db, pOp->p4type, pOp->p4.p); + if( pOp->p4type ) freeP4(db, pOp->p4type, pOp->p4.p); #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS sqlite3DbFree(db, pOp->zComment); #endif @@ -867,16 +866,34 @@ int sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){ ** ** If addr<0 then change P4 on the most recently inserted instruction. */ +static void SQLITE_NOINLINE vdbeChangeP4Full( + Vdbe *p, + Op *pOp, + const char *zP4, + int n +){ + if( pOp->p4type ){ + freeP4(p->db, pOp->p4type, pOp->p4.p); + pOp->p4type = 0; + pOp->p4.p = 0; + } + if( n<0 ){ + sqlite3VdbeChangeP4(p, (int)(pOp - p->aOp), zP4, n); + }else{ + if( n==0 ) n = sqlite3Strlen30(zP4); + pOp->p4.z = sqlite3DbStrNDup(p->db, zP4, n); + pOp->p4type = P4_DYNAMIC; + } +} void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){ Op *pOp; sqlite3 *db; assert( p!=0 ); db = p->db; assert( p->magic==VDBE_MAGIC_INIT ); - if( p->aOp==0 || db->mallocFailed ){ - if( n!=P4_VTAB ){ - freeP4(db, n, (void*)*(char**)&zP4); - } + assert( p->aOp!=0 || db->mallocFailed ); + if( db->mallocFailed ){ + if( n!=P4_VTAB ) freeP4(db, n, (void*)*(char**)&zP4); return; } assert( p->nOp>0 ); @@ -885,43 +902,20 @@ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){ addr = p->nOp - 1; } pOp = &p->aOp[addr]; - assert( pOp->p4type==P4_NOTUSED - || pOp->p4type==P4_INT32 - || pOp->p4type==P4_KEYINFO ); - freeP4(db, pOp->p4type, pOp->p4.p); - pOp->p4.p = 0; + if( n>=0 || pOp->p4type ){ + vdbeChangeP4Full(p, pOp, zP4, n); + return; + } if( n==P4_INT32 ){ /* Note: this cast is safe, because the origin data point was an int ** that was cast to a (const char *). */ pOp->p4.i = SQLITE_PTR_TO_INT(zP4); pOp->p4type = P4_INT32; - }else if( zP4==0 ){ - pOp->p4.p = 0; - pOp->p4type = P4_NOTUSED; - }else if( n==P4_KEYINFO ){ - pOp->p4.p = (void*)zP4; - pOp->p4type = P4_KEYINFO; -#ifdef SQLITE_ENABLE_CURSOR_HINTS - }else if( n==P4_EXPR ){ - /* Responsibility for deleting the Expr tree is handed over to the - ** VDBE by this operation. The caller should have already invoked - ** sqlite3ExprDup() or whatever other routine is needed to make a - ** private copy of the tree. */ - pOp->p4.pExpr = (Expr*)zP4; - pOp->p4type = P4_EXPR; -#endif - }else if( n==P4_VTAB ){ - pOp->p4.p = (void*)zP4; - pOp->p4type = P4_VTAB; - sqlite3VtabLock((VTable *)zP4); - assert( ((VTable *)zP4)->db==p->db ); - }else if( n<0 ){ + }else if( zP4!=0 ){ + assert( n<0 ); pOp->p4.p = (void*)zP4; pOp->p4type = (signed char)n; - }else{ - if( n==0 ) n = sqlite3Strlen30(zP4); - pOp->p4.z = sqlite3DbStrNDup(p->db, zP4, n); - pOp->p4type = P4_DYNAMIC; + if( n==P4_VTAB ) sqlite3VtabLock((VTable*)zP4); } } diff --git a/src/where.c b/src/where.c index e86e26ef1a..2cb8334ffb 100644 --- a/src/where.c +++ b/src/where.c @@ -4318,8 +4318,7 @@ WhereInfo *sqlite3WhereBegin( Bitmask b = pTabItem->colUsed; int n = 0; for(; b; b=b>>1, n++){} - sqlite3VdbeChangeP4(v, sqlite3VdbeCurrentAddr(v)-1, - SQLITE_INT_TO_PTR(n), P4_INT32); + sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(n), P4_INT32); assert( n<=pTab->nCol ); } #ifdef SQLITE_ENABLE_CURSOR_HINTS From e2258a2076c237a70d4dbec7be3754fceebc2f1d Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 Jan 2016 00:37:55 +0000 Subject: [PATCH 177/232] Various #ifdef enhancements for improved VxWorks support. FossilOrigin-Name: 75cd41ff179e29c5d45f9d7fed784bc339e0d7a0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 16 +++++++++++++--- src/vxworks.h | 2 ++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 41cffbc0d6..7ae248f6b9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\soptimization\sin\sthe\ssqlite3VdbeChangeP4()\sroutine\sof\sthe\ncode\sgenerator. -D 2016-01-11T22:58:50.164 +C Various\s#ifdef\senhancements\sfor\simproved\sVxWorks\ssupport. +D 2016-01-12T00:37:55.072 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -317,7 +317,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 82986e1e75782b54da7822dca42d36d974fc2948 +F src/os_unix.c b509b49b40a269e7b75ab511b6e92b2dc9444359 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 58d2593612acb6b542de6715b4af397ea1fa0a35 @@ -408,7 +408,7 @@ F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 -F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb +F src/vxworks.h 974e7d9a98f602d6310d563e1dc4e08f9fc48e47 F src/wal.c 92ca9e7923c337c497e4c9aa7edac800e269a1d8 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f5fb82686697e5fa1937323b1c1b35cf90ad0302 -R 5cc83036f9c9da1fadf85dd4abd0f133 +P 28bd8d5fc541464b69886b7e886939035b42a869 +R a0f920051028c27b520313db4d779ce4 U drh -Z a8c9a7d6a102c57d4a0aed7eac3aa290 +Z 6a1495f4c4d6026f44345482bd14549e diff --git a/manifest.uuid b/manifest.uuid index aa9453cfcd..6f028487c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -28bd8d5fc541464b69886b7e886939035b42a869 \ No newline at end of file +75cd41ff179e29c5d45f9d7fed784bc339e0d7a0 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index a40a866780..5bd6116945 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -430,7 +430,11 @@ static struct unix_syscall { { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) +#if defined(HAVE_FCHOWN) { "fchown", (sqlite3_syscall_ptr)fchown, 0 }, +#else + { "fchown", (sqlite3_syscall_ptr)0, 0 }, +#endif #define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent) { "geteuid", (sqlite3_syscall_ptr)geteuid, 0 }, @@ -464,7 +468,11 @@ static struct unix_syscall { #endif #define osGetpagesize ((int(*)(void))aSyscall[25].pCurrent) +#if defined(HAVE_READLINK) { "readlink", (sqlite3_syscall_ptr)readlink, 0 }, +#else + { "readlink", (sqlite3_syscall_ptr)0, 0 }, +#endif #define osReadlink ((ssize_t(*)(const char*,char*,size_t))aSyscall[26].pCurrent) @@ -477,10 +485,10 @@ static struct unix_syscall { ** we are not running as root. */ static int robustFchown(int fd, uid_t uid, gid_t gid){ -#if OS_VXWORKS - return 0; -#else +#if defined(HAVE_FCHOWN) return osGeteuid() ? 0 : osFchown(fd,uid,gid); +#else + return 0; #endif } @@ -5947,6 +5955,7 @@ static int unixFullPathname( assert( pVfs->mxPathname==MAX_PATHNAME ); UNUSED_PARAMETER(pVfs); +#if defined(HAVE_READLINK) /* Attempt to resolve the path as if it were a symbolic link. If it is ** a symbolic link, the resolved path is stored in buffer zOut[]. Or, if ** the identified file is not a symbolic link or does not exist, then @@ -5962,6 +5971,7 @@ static int unixFullPathname( }else{ zOut[nByte] = '\0'; } +#endif /* If buffer zOut[] now contains an absolute path there is nothing more ** to do. If it contains a relative path, do the following: diff --git a/src/vxworks.h b/src/vxworks.h index 45a44453a7..60c41a19b8 100644 --- a/src/vxworks.h +++ b/src/vxworks.h @@ -26,4 +26,6 @@ #else /* This is not VxWorks. */ #define OS_VXWORKS 0 +#define HAVE_FCHOWN 1 +#define HAVE_READLINK 1 #endif /* defined(_WRS_KERNEL) */ From 9ca33fa4c26467330a13d74f1646b27d869ff147 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 Jan 2016 02:00:24 +0000 Subject: [PATCH 178/232] Fix an uninitialized field in the Select object when SELECTTRACE is enabled. FossilOrigin-Name: fc62851667d9120f98a2641c87bbc5a2485482b2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 7ae248f6b9..6575eb3b4e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Various\s#ifdef\senhancements\sfor\simproved\sVxWorks\ssupport. -D 2016-01-12T00:37:55.072 +C Fix\san\suninitialized\sfield\sin\sthe\sSelect\sobject\swhen\sSELECTTRACE\sis\senabled. +D 2016-01-12T02:00:24.480 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -333,7 +333,7 @@ F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c d84c091185bc160c349e8bf460ebd084dbd77e64 +F src/select.c 372234e3554a7917544242563216af760d7d4219 F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 28bd8d5fc541464b69886b7e886939035b42a869 -R a0f920051028c27b520313db4d779ce4 +P 75cd41ff179e29c5d45f9d7fed784bc339e0d7a0 +R f2bd43aeba2b6092057d74bc062b9600 U drh -Z 6a1495f4c4d6026f44345482bd14549e +Z 0ab9387fbd675bc198faa7ea2440e420 diff --git a/manifest.uuid b/manifest.uuid index 6f028487c4..cb7f85349f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -75cd41ff179e29c5d45f9d7fed784bc339e0d7a0 \ No newline at end of file +fc62851667d9120f98a2641c87bbc5a2485482b2 \ No newline at end of file diff --git a/src/select.c b/src/select.c index b1db07d09a..0e7c4595d1 100644 --- a/src/select.c +++ b/src/select.c @@ -124,6 +124,9 @@ Select *sqlite3SelectNew( pNew->selFlags = selFlags; pNew->iLimit = 0; pNew->iOffset = 0; +#if SELECTTRACE_ENABLED + pNew->zSelName[0] = 0; +#endif pNew->addrOpenEphm[0] = -1; pNew->addrOpenEphm[1] = -1; pNew->nSelectRow = 0; From 869aaf0941f440f5ded3e1757da9f24058e76220 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 Jan 2016 02:28:19 +0000 Subject: [PATCH 179/232] Make sure all bytes of the WAL file are initialized even if the checksums are not being computed until commit due to WAL overwrite. FossilOrigin-Name: 1f44a9bdc1577aed088d9b91882527228015dcd3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/wal.c | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 6575eb3b4e..52e6f9a768 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\suninitialized\sfield\sin\sthe\sSelect\sobject\swhen\sSELECTTRACE\sis\senabled. -D 2016-01-12T02:00:24.480 +C Make\ssure\sall\sbytes\sof\sthe\sWAL\sfile\sare\sinitialized\seven\sif\sthe\schecksums\sare\nnot\sbeing\scomputed\suntil\scommit\sdue\sto\sWAL\soverwrite. +D 2016-01-12T02:28:19.320 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -409,7 +409,7 @@ F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h 974e7d9a98f602d6310d563e1dc4e08f9fc48e47 -F src/wal.c 92ca9e7923c337c497e4c9aa7edac800e269a1d8 +F src/wal.c ec116eb4dd257561b0b910b422eb0fc459c82c28 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c bb69654f841ae7af0a20cc6fb8f0ac57901c31be @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 75cd41ff179e29c5d45f9d7fed784bc339e0d7a0 -R f2bd43aeba2b6092057d74bc062b9600 +P fc62851667d9120f98a2641c87bbc5a2485482b2 +R 5117171a7e356e05f85dd4c6a03b017d U drh -Z 0ab9387fbd675bc198faa7ea2440e420 +Z 900d53369fb7ca05847989ae4b11e011 diff --git a/manifest.uuid b/manifest.uuid index cb7f85349f..b281737f3f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fc62851667d9120f98a2641c87bbc5a2485482b2 \ No newline at end of file +1f44a9bdc1577aed088d9b91882527228015dcd3 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index ae6a54849a..9d711198a8 100644 --- a/src/wal.c +++ b/src/wal.c @@ -708,6 +708,8 @@ static void walEncodeFrame( sqlite3Put4byte(&aFrame[16], aCksum[0]); sqlite3Put4byte(&aFrame[20], aCksum[1]); + }else{ + memset(&aFrame[8], 0, 16); } } From 8f3f65ec1cd54c250984f0b0625bbbcdacbbfd1e Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 Jan 2016 04:08:54 +0000 Subject: [PATCH 180/232] Remove an unused field from the MemPage object. FossilOrigin-Name: 5fc0a4c1f353c4c06fcbc4bce8bbe1897ef49eee --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 8 -------- src/btreeInt.h | 1 - 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 52e6f9a768..ca04021326 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sall\sbytes\sof\sthe\sWAL\sfile\sare\sinitialized\seven\sif\sthe\schecksums\sare\nnot\sbeing\scomputed\suntil\scommit\sdue\sto\sWAL\soverwrite. -D 2016-01-12T02:28:19.320 +C Remove\san\sunused\sfield\sfrom\sthe\sMemPage\sobject. +D 2016-01-12T04:08:54.028 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -276,9 +276,9 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 6bd9b3d778a023e2238a81cd0b87b00085220e0e +F src/btree.c 5d93e2477acb99d50a8b045f2e26a0be3d7751fe F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 -F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 +F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 9d497ff4bf3c82cecb520436e0e9963785627583 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fc62851667d9120f98a2641c87bbc5a2485482b2 -R 5117171a7e356e05f85dd4c6a03b017d +P 1f44a9bdc1577aed088d9b91882527228015dcd3 +R dcacd681598087d316aa7da66fd3e6ff U drh -Z 900d53369fb7ca05847989ae4b11e011 +Z a106a14306903405633952b5120c8bc2 diff --git a/manifest.uuid b/manifest.uuid index b281737f3f..c61a4ceebd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f44a9bdc1577aed088d9b91882527228015dcd3 \ No newline at end of file +5fc0a4c1f353c4c06fcbc4bce8bbe1897ef49eee \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 77552d5831..b5a1ee3b2c 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1079,7 +1079,6 @@ static void btreeParseCellPtrNoPayload( ){ assert( sqlite3_mutex_held(pPage->pBt->mutex) ); assert( pPage->leaf==0 ); - assert( pPage->noPayload ); assert( pPage->childPtrSize==4 ); #ifndef SQLITE_DEBUG UNUSED_PARAMETER(pPage); @@ -1101,8 +1100,6 @@ static void btreeParseCellPtr( assert( sqlite3_mutex_held(pPage->pBt->mutex) ); assert( pPage->leaf==0 || pPage->leaf==1 ); - assert( pPage->intKeyLeaf || pPage->noPayload ); - assert( pPage->noPayload==0 ); assert( pPage->intKeyLeaf ); assert( pPage->childPtrSize==0 ); pIter = pCell; @@ -1171,7 +1168,6 @@ static void btreeParseCellPtrIndex( assert( sqlite3_mutex_held(pPage->pBt->mutex) ); assert( pPage->leaf==0 || pPage->leaf==1 ); assert( pPage->intKeyLeaf==0 ); - assert( pPage->noPayload==0 ); pIter = pCell + pPage->childPtrSize; nPayload = *pIter; if( nPayload>=0x80 ){ @@ -1232,7 +1228,6 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){ pPage->xParseCell(pPage, pCell, &debuginfo); #endif - assert( pPage->noPayload==0 ); nSize = *pIter; if( nSize>=0x80 ){ pEnd = &pIter[8]; @@ -1690,11 +1685,9 @@ static int decodeFlags(MemPage *pPage, int flagByte){ pPage->intKey = 1; if( pPage->leaf ){ pPage->intKeyLeaf = 1; - pPage->noPayload = 0; pPage->xParseCell = btreeParseCellPtr; }else{ pPage->intKeyLeaf = 0; - pPage->noPayload = 1; pPage->xCellSize = cellSizePtrNoPayload; pPage->xParseCell = btreeParseCellPtrNoPayload; } @@ -1709,7 +1702,6 @@ static int decodeFlags(MemPage *pPage, int flagByte){ assert( (PTF_ZERODATA|PTF_LEAF)==10 ); pPage->intKey = 0; pPage->intKeyLeaf = 0; - pPage->noPayload = 0; pPage->xParseCell = btreeParseCellPtrIndex; pPage->maxLocal = pBt->maxLocal; pPage->minLocal = pBt->minLocal; diff --git a/src/btreeInt.h b/src/btreeInt.h index a196e18a28..6cd090257c 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -276,7 +276,6 @@ struct MemPage { u8 nOverflow; /* Number of overflow cell bodies in aCell[] */ u8 intKey; /* True if table b-trees. False for index b-trees */ u8 intKeyLeaf; /* True if the leaf of an intKey table */ - u8 noPayload; /* True if internal intKey page (thus w/o data) */ u8 leaf; /* True if a leaf page */ u8 hdrOffset; /* 100 for page 1. 0 otherwise */ u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ From d1dd7507e43a2650d6c4a363dd021653ebbd896f Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 Jan 2016 14:10:05 +0000 Subject: [PATCH 181/232] Fix a harmless use of an uninitialized variable following system errors in the multi-threaded sorter. FossilOrigin-Name: 4bb2c1df105c2d21f5c4c7ef656ff1d6e15f78bc --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbesort.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ca04021326..b4c264a04b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunused\sfield\sfrom\sthe\sMemPage\sobject. -D 2016-01-12T04:08:54.028 +C Fix\sa\sharmless\suse\sof\san\suninitialized\svariable\sfollowing\ssystem\serrors\nin\sthe\smulti-threaded\ssorter. +D 2016-01-12T14:10:05.866 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -405,7 +405,7 @@ F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca F src/vdbeaux.c f2e6b4fae037db04323be8de7bcd266375746471 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 -F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d +F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 F src/vxworks.h 974e7d9a98f602d6310d563e1dc4e08f9fc48e47 @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1f44a9bdc1577aed088d9b91882527228015dcd3 -R dcacd681598087d316aa7da66fd3e6ff +P 5fc0a4c1f353c4c06fcbc4bce8bbe1897ef49eee +R 92b34da2a8b41bb1db044333a3c02410 U drh -Z a106a14306903405633952b5120c8bc2 +Z e6a278c031968913cb3469aed14f2f8a diff --git a/manifest.uuid b/manifest.uuid index c61a4ceebd..9e4a59f983 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5fc0a4c1f353c4c06fcbc4bce8bbe1897ef49eee \ No newline at end of file +4bb2c1df105c2d21f5c4c7ef656ff1d6e15f78bc \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 54e538fd50..e095f80912 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -737,7 +737,7 @@ static int vdbePmaReaderInit( rc = vdbePmaReaderSeek(pTask, pReadr, pFile, iStart); if( rc==SQLITE_OK ){ - u64 nByte; /* Size of PMA in bytes */ + u64 nByte = 0; /* Size of PMA in bytes */ rc = vdbePmaReadVarint(pReadr, &nByte); pReadr->iEof = pReadr->iReadOff + nByte; *pnByte += nByte; From fd7601a125dc1e16f7220540104d9de2be29474e Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Jan 2016 19:28:51 +0000 Subject: [PATCH 182/232] Improve performance of fts5 low level iterators. FossilOrigin-Name: bc5118f40a11f64ffb4e1c086277fa80b9764745 --- ext/fts5/fts5_index.c | 376 ++++++++++++++++++++++++-------------- ext/fts5/test/fts5ad.test | 2 - manifest | 14 +- manifest.uuid | 2 +- 4 files changed, 245 insertions(+), 149 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index ef673085c6..2488cd7ca9 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -433,6 +433,9 @@ struct Fts5SegIter { Fts5Data *pNextLeaf; /* Leaf page (iLeafPgno+1) */ int iLeafOffset; /* Byte offset within current leaf */ + /* Next method */ + void (*xNext)(Fts5Index*, Fts5SegIter*, int*); + /* The page and offset from which the current term was read. The offset ** is the offset of the first rowid in the current doclist. */ int iTermLeafPgno; @@ -453,7 +456,6 @@ struct Fts5SegIter { i64 iRowid; /* Current rowid */ int nPos; /* Number of bytes in current position list */ u8 bDel; /* True if the delete flag is set */ - // u8 bContent; /* True if has content (detail=none mode) */ }; /* @@ -1575,6 +1577,20 @@ static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){ fts5SegIterLoadRowid(p, pIter); } +static void fts5SegIterNext(Fts5Index*, Fts5SegIter*, int*); +static void fts5SegIterNext_Reverse(Fts5Index*, Fts5SegIter*, int*); +static void fts5SegIterNext_None(Fts5Index*, Fts5SegIter*, int*); + +static void fts5SegIterSetNext(Fts5Index *p, Fts5SegIter *pIter){ + if( pIter->flags & FTS5_SEGITER_REVERSE ){ + pIter->xNext = fts5SegIterNext_Reverse; + }else if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){ + pIter->xNext = fts5SegIterNext_None; + }else{ + pIter->xNext = fts5SegIterNext; + } +} + /* ** Initialize the iterator object pIter to iterate through the entries in ** segment pSeg. The iterator is left pointing to the first entry when @@ -1600,6 +1616,7 @@ static void fts5SegIterInit( if( p->rc==SQLITE_OK ){ memset(pIter, 0, sizeof(*pIter)); + fts5SegIterSetNext(p, pIter); pIter->pSeg = pSeg; pIter->iLeafPgno = pSeg->pgnoFirst-1; fts5SegIterNextPage(p, pIter); @@ -1740,6 +1757,110 @@ static int fts5MultiIterIsEmpty(Fts5Index *p, Fts5IndexIter *pIter){ return (p->rc==SQLITE_OK && pSeg->pLeaf && pSeg->nPos==0); } +/* +** Advance iterator pIter to the next entry. +** +** This version of fts5SegIterNext() is only used by reverse iterators. +*/ +static void fts5SegIterNext_Reverse( + Fts5Index *p, /* FTS5 backend object */ + Fts5SegIter *pIter, /* Iterator to advance */ + int *pbNewTerm /* OUT: Set for new term */ +){ + assert( pIter->flags & FTS5_SEGITER_REVERSE ); + assert( pIter->pNextLeaf==0 ); + if( pIter->iRowidOffset>0 ){ + u8 *a = pIter->pLeaf->p; + int iOff; + int nPos; + int bDummy; + i64 iDelta; + + pIter->iRowidOffset--; + pIter->iLeafOffset = pIter->aRowidOffset[pIter->iRowidOffset]; + fts5SegIterLoadNPos(p, pIter); + iOff = pIter->iLeafOffset; + if( p->pConfig->eDetail!=FTS5_DETAIL_NONE ){ + iOff += pIter->nPos; + } + fts5GetVarint(&a[iOff], (u64*)&iDelta); + pIter->iRowid -= iDelta; + }else{ + fts5SegIterReverseNewPage(p, pIter); + } +} + +/* +** Advance iterator pIter to the next entry. +** +** This version of fts5SegIterNext() is only used if detail=none and the +** iterator is not a reverse direction iterator. +*/ +static void fts5SegIterNext_None( + Fts5Index *p, /* FTS5 backend object */ + Fts5SegIter *pIter, /* Iterator to advance */ + int *pbNewTerm /* OUT: Set for new term */ +){ + int iOff; + + assert( p->rc==SQLITE_OK ); + assert( (pIter->flags & FTS5_SEGITER_REVERSE)==0 ); + assert( p->pConfig->eDetail==FTS5_DETAIL_NONE ); + + ASSERT_SZLEAF_OK(pIter->pLeaf); + iOff = pIter->iLeafOffset; + + /* Next entry is on the next page */ + if( pIter->pSeg && iOff>=pIter->pLeaf->szLeaf ){ + fts5SegIterNextPage(p, pIter); + if( p->rc || pIter->pLeaf==0 ) return; + pIter->iRowid = 0; + iOff = 4; + } + + if( iOffiEndofDoclist ){ + /* Next entry is on the current page */ + i64 iDelta; + iOff += sqlite3Fts5GetVarint(&pIter->pLeaf->p[iOff], &iDelta); + pIter->iLeafOffset = iOff; + pIter->iRowid += iDelta; + }else if( (pIter->flags & FTS5_SEGITER_ONETERM)==0 ){ + if( pIter->pSeg ){ + int nKeep = 0; + if( iOff!=fts5LeafFirstTermOff(pIter->pLeaf) ){ + iOff += fts5GetVarint32(&pIter->pLeaf->p[iOff], nKeep); + } + pIter->iLeafOffset = iOff; + fts5SegIterLoadTerm(p, pIter, nKeep); + }else{ + const u8 *pList = 0; + const char *zTerm = 0; + int nList; + sqlite3Fts5HashScanNext(p->pHash); + sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList); + if( pList==0 ) goto next_none_eof; + pIter->pLeaf->p = (u8*)pList; + pIter->pLeaf->nn = nList; + pIter->pLeaf->szLeaf = nList; + pIter->iEndofDoclist = nList; + sqlite3Fts5BufferSet(&p->rc,&pIter->term, (int)strlen(zTerm), (u8*)zTerm); + pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid); + } + + if( pbNewTerm ) *pbNewTerm = 1; + }else{ + goto next_none_eof; + } + + fts5SegIterLoadNPos(p, pIter); + + return; + next_none_eof: + fts5DataRelease(pIter->pLeaf); + pIter->pLeaf = 0; +} + + /* ** Advance iterator pIter to the next entry. ** @@ -1752,151 +1873,119 @@ static void fts5SegIterNext( Fts5SegIter *pIter, /* Iterator to advance */ int *pbNewTerm /* OUT: Set for new term */ ){ - assert( pbNewTerm==0 || *pbNewTerm==0 ); - if( p->rc==SQLITE_OK ){ - if( pIter->flags & FTS5_SEGITER_REVERSE ){ - assert( pIter->pNextLeaf==0 ); - if( pIter->iRowidOffset>0 ){ - u8 *a = pIter->pLeaf->p; - int iOff; - int nPos; - int bDummy; - i64 iDelta; + Fts5Data *pLeaf = pIter->pLeaf; + int iOff; + int bNewTerm = 0; + int nKeep = 0; - pIter->iRowidOffset--; - pIter->iLeafOffset = pIter->aRowidOffset[pIter->iRowidOffset]; - fts5SegIterLoadNPos(p, pIter); - iOff = pIter->iLeafOffset; - if( p->pConfig->eDetail!=FTS5_DETAIL_NONE ){ - iOff += pIter->nPos; - } - fts5GetVarint(&a[iOff], (u64*)&iDelta); - pIter->iRowid -= iDelta; - }else{ - fts5SegIterReverseNewPage(p, pIter); + assert( pbNewTerm==0 || *pbNewTerm==0 ); + assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE ); + + /* Search for the end of the position list within the current page. */ + u8 *a = pLeaf->p; + int n = pLeaf->szLeaf; + + ASSERT_SZLEAF_OK(pLeaf); + iOff = pIter->iLeafOffset + pIter->nPos; + + if( iOffiEndofDoclist ); + if( iOff>=pIter->iEndofDoclist ){ + bNewTerm = 1; + if( iOff!=fts5LeafFirstTermOff(pLeaf) ){ + iOff += fts5GetVarint32(&a[iOff], nKeep); } }else{ - Fts5Data *pLeaf = pIter->pLeaf; - int iOff; - int bNewTerm = 0; - int nKeep = 0; - - /* Search for the end of the position list within the current page. */ - u8 *a = pLeaf->p; - int n = pLeaf->szLeaf; + u64 iDelta; + iOff += sqlite3Fts5GetVarint(&a[iOff], &iDelta); + pIter->iRowid += iDelta; + assert_nc( iDelta>0 ); + } + pIter->iLeafOffset = iOff; + }else if( pIter->pSeg==0 ){ + const u8 *pList = 0; + const char *zTerm = 0; + int nList = 0; + assert( (pIter->flags & FTS5_SEGITER_ONETERM) || pbNewTerm ); + if( 0==(pIter->flags & FTS5_SEGITER_ONETERM) ){ + sqlite3Fts5HashScanNext(p->pHash); + sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList); + } + if( pList==0 ){ + fts5DataRelease(pIter->pLeaf); + pIter->pLeaf = 0; + }else{ + pIter->pLeaf->p = (u8*)pList; + pIter->pLeaf->nn = nList; + pIter->pLeaf->szLeaf = nList; + pIter->iEndofDoclist = nList+1; + sqlite3Fts5BufferSet(&p->rc, &pIter->term, (int)strlen(zTerm), + (u8*)zTerm); + pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid); + *pbNewTerm = 1; + } + }else{ + iOff = 0; + /* Next entry is not on the current page */ + while( iOff==0 ){ + fts5SegIterNextPage(p, pIter); + pLeaf = pIter->pLeaf; + if( pLeaf==0 ) break; ASSERT_SZLEAF_OK(pLeaf); - if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){ - iOff = pIter->iLeafOffset; - }else{ - iOff = pIter->iLeafOffset + pIter->nPos; - } - - if( iOffiEndofDoclist ); - if( iOff>=pIter->iEndofDoclist ){ - bNewTerm = 1; - if( iOff!=fts5LeafFirstTermOff(pLeaf) ){ - iOff += fts5GetVarint32(&a[iOff], nKeep); - } - }else{ - u64 iDelta; - iOff += sqlite3Fts5GetVarint(&a[iOff], &iDelta); - pIter->iRowid += iDelta; - assert_nc( iDelta>0 ); - } + if( (iOff = fts5LeafFirstRowidOff(pLeaf)) && iOffszLeaf ){ + iOff += sqlite3Fts5GetVarint(&pLeaf->p[iOff], (u64*)&pIter->iRowid); pIter->iLeafOffset = iOff; - }else if( pIter->pSeg==0 ){ - const u8 *pList = 0; - const char *zTerm = 0; - int nList = 0; - assert( (pIter->flags & FTS5_SEGITER_ONETERM) || pbNewTerm ); - if( 0==(pIter->flags & FTS5_SEGITER_ONETERM) ){ - sqlite3Fts5HashScanNext(p->pHash); - sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList); - } - if( pList==0 ){ - fts5DataRelease(pIter->pLeaf); - pIter->pLeaf = 0; - }else{ - pIter->pLeaf->p = (u8*)pList; - pIter->pLeaf->nn = nList; - pIter->pLeaf->szLeaf = nList; - pIter->iEndofDoclist = nList+1; - sqlite3Fts5BufferSet(&p->rc, &pIter->term, (int)strlen(zTerm), - (u8*)zTerm); - pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid); - *pbNewTerm = 1; - } - }else{ - iOff = 0; - /* Next entry is not on the current page */ - while( iOff==0 ){ - fts5SegIterNextPage(p, pIter); - pLeaf = pIter->pLeaf; - if( pLeaf==0 ) break; - ASSERT_SZLEAF_OK(pLeaf); - if( (iOff = fts5LeafFirstRowidOff(pLeaf)) && iOffszLeaf ){ - iOff += sqlite3Fts5GetVarint(&pLeaf->p[iOff], (u64*)&pIter->iRowid); - pIter->iLeafOffset = iOff; - - if( pLeaf->nn>pLeaf->szLeaf ){ - pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32( - &pLeaf->p[pLeaf->szLeaf], pIter->iEndofDoclist + if( pLeaf->nn>pLeaf->szLeaf ){ + pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32( + &pLeaf->p[pLeaf->szLeaf], pIter->iEndofDoclist ); - } + } - } - else if( pLeaf->nn>pLeaf->szLeaf ){ - pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32( - &pLeaf->p[pLeaf->szLeaf], iOff + } + else if( pLeaf->nn>pLeaf->szLeaf ){ + pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32( + &pLeaf->p[pLeaf->szLeaf], iOff ); - pIter->iLeafOffset = iOff; - pIter->iEndofDoclist = iOff; - bNewTerm = 1; - } - assert_nc( iOffszLeaf - || p->pConfig->eDetail==FTS5_DETAIL_NONE - ); - if( iOff>pLeaf->szLeaf ){ - p->rc = FTS5_CORRUPT; - return; - } - } + pIter->iLeafOffset = iOff; + pIter->iEndofDoclist = iOff; + bNewTerm = 1; } + assert_nc( iOffszLeaf ); + if( iOff>pLeaf->szLeaf ){ + p->rc = FTS5_CORRUPT; + return; + } + } + } - /* Check if the iterator is now at EOF. If so, return early. */ - if( pIter->pLeaf ){ - if( bNewTerm ){ - if( pIter->flags & FTS5_SEGITER_ONETERM ){ - fts5DataRelease(pIter->pLeaf); - pIter->pLeaf = 0; - }else{ - fts5SegIterLoadTerm(p, pIter, nKeep); - fts5SegIterLoadNPos(p, pIter); - if( pbNewTerm ) *pbNewTerm = 1; - } - }else{ - /* The following could be done by calling fts5SegIterLoadNPos(). But - ** this block is particularly performance critical, so equivalent - ** code is inlined. - ** - ** Later: Switched back to fts5SegIterLoadNPos() because it supports - ** detail=none mode. Not ideal. - */ -#if 0 - int nSz; - assert( p->rc==SQLITE_OK ); - fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz); - pIter->bDel = (nSz & 0x0001); - pIter->nPos = nSz>>1; - assert_nc( pIter->nPos>=0 ); -#endif - fts5SegIterLoadNPos(p, pIter); - } + /* Check if the iterator is now at EOF. If so, return early. */ + if( pIter->pLeaf ){ + if( bNewTerm ){ + if( pIter->flags & FTS5_SEGITER_ONETERM ){ + fts5DataRelease(pIter->pLeaf); + pIter->pLeaf = 0; + }else{ + fts5SegIterLoadTerm(p, pIter, nKeep); + fts5SegIterLoadNPos(p, pIter); + if( pbNewTerm ) *pbNewTerm = 1; } + }else{ + /* The following could be done by calling fts5SegIterLoadNPos(). But + ** this block is particularly performance critical, so equivalent + ** code is inlined. + ** + ** Later: Switched back to fts5SegIterLoadNPos() because it supports + ** detail=none mode. Not ideal. + */ + int nSz; + assert( p->rc==SQLITE_OK ); + fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz); + pIter->bDel = (nSz & 0x0001); + pIter->nPos = nSz>>1; + assert_nc( pIter->nPos>=0 ); } } } @@ -2231,6 +2320,8 @@ static void fts5SegIterSeekInit( } } + fts5SegIterSetNext(p, pIter); + /* Either: ** ** 1) an error has occurred, or @@ -2288,7 +2379,7 @@ static void fts5SegIterHashInit( pLeaf->nn = pLeaf->szLeaf = nList; pIter->pLeaf = pLeaf; pIter->iLeafOffset = fts5GetVarint(pLeaf->p, (u64*)&pIter->iRowid); - pIter->iEndofDoclist = pLeaf->nn+1; + pIter->iEndofDoclist = pLeaf->nn; if( flags & FTS5INDEX_QUERY_DESC ){ pIter->flags |= FTS5_SEGITER_REVERSE; @@ -2297,6 +2388,8 @@ static void fts5SegIterHashInit( fts5SegIterLoadNPos(p, pIter); } } + + fts5SegIterSetNext(p, pIter); } /* @@ -2540,7 +2633,7 @@ static void fts5SegIterNextFrom( } do{ - if( bMove ) fts5SegIterNext(p, pIter, 0); + if( bMove && p->rc==SQLITE_OK ) pIter->xNext(p, pIter, 0); if( pIter->pLeaf==0 ) break; if( bRev==0 && pIter->iRowid>=iMatch ) break; if( bRev!=0 && pIter->iRowid<=iMatch ) break; @@ -2574,7 +2667,9 @@ static void fts5MultiIterAdvanced( for(i=(pIter->nSeg+iChanged)/2; i>=iMinset && p->rc==SQLITE_OK; i=i/2){ int iEq; if( (iEq = fts5MultiIterDoCompare(pIter, i)) ){ - fts5SegIterNext(p, &pIter->aSeg[iEq], 0); + Fts5SegIter *pSeg = &pIter->aSeg[iEq]; + assert( p->rc==SQLITE_OK ); + pSeg->xNext(p, pSeg, 0); i = pIter->nSeg + iEq; } } @@ -2661,7 +2756,7 @@ static void fts5MultiIterNext( if( bUseFrom && pSeg->pDlidx ){ fts5SegIterNextFrom(p, pSeg, iFrom); }else{ - fts5SegIterNext(p, pSeg, &bNewTerm); + pSeg->xNext(p, pSeg, &bNewTerm); } if( pSeg->pLeaf==0 || bNewTerm @@ -2689,7 +2784,8 @@ static void fts5MultiIterNext2( Fts5SegIter *pSeg = &pIter->aSeg[iFirst]; int bNewTerm = 0; - fts5SegIterNext(p, pSeg, &bNewTerm); + assert( p->rc==SQLITE_OK ); + pSeg->xNext(p, pSeg, &bNewTerm); if( pSeg->pLeaf==0 || bNewTerm || fts5MultiIterAdvanceRowid(p, pIter, iFirst) ){ @@ -2809,7 +2905,8 @@ static void fts5MultiIterNew( for(iIter=pNew->nSeg-1; iIter>0; iIter--){ int iEq; if( (iEq = fts5MultiIterDoCompare(pNew, iIter)) ){ - fts5SegIterNext(p, &pNew->aSeg[iEq], 0); + Fts5SegIter *pSeg = &pNew->aSeg[iEq]; + if( p->rc==SQLITE_OK ) pSeg->xNext(p, pSeg, 0); fts5MultiIterAdvanced(p, pNew, iEq, iIter); } } @@ -2859,6 +2956,7 @@ static void fts5MultiIterNew2( }else{ pNew->bEof = 1; } + fts5SegIterSetNext(p, pIter); *ppOut = pNew; } diff --git a/ext/fts5/test/fts5ad.test b/ext/fts5/test/fts5ad.test index b875354534..c6b09d8121 100644 --- a/ext/fts5/test/fts5ad.test +++ b/ext/fts5/test/fts5ad.test @@ -24,8 +24,6 @@ ifcapable !fts5 { foreach_detail_mode $testprefix { -if {[detail_is_none]==0} continue - do_execsql_test 1.0 { CREATE VIRTUAL TABLE yy USING fts5(x, y, detail=%DETAIL%); INSERT INTO yy VALUES('Changes the result to be', 'the list of all matching'); diff --git a/manifest b/manifest index 5a749962b4..bd4318635f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\swith\sthis\sbranch. -D 2016-01-11T18:30:34.152 +C Improve\sperformance\sof\sfts5\slow\slevel\siterators. +D 2016-01-12T19:28:51.507 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -103,7 +103,7 @@ F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 F ext/fts5/fts5_expr.c 6eba2220747ea1b20a358fb3b34b2ab78323e285 F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 -F ext/fts5/fts5_index.c 04fe098ffab66d9424ba4e7c0b88ce7c98748cb1 +F ext/fts5/fts5_index.c 5ab044a67919e2c9f42f0288a39778136154511e F ext/fts5/fts5_main.c 03bd44e4bd0ba16213ca9259ad5df1d4d743fd7e F ext/fts5/fts5_storage.c f7b2d330dd7b29a9f4da09f6d85879ca8c41b2e8 F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb @@ -118,7 +118,7 @@ F ext/fts5/test/fts5_common.tcl 393882afb225a21edf033043bbf936951e9198c1 F ext/fts5/test/fts5aa.test 7e814df4a0e6c22a6fe2d84f210fdc0b5068a084 F ext/fts5/test/fts5ab.test 30325a89453280160106be411bba3acf138e6d1b F ext/fts5/test/fts5ac.test d5073ca7bd2d9fe8aab0c82c6c75a7e4b0d70ced -F ext/fts5/test/fts5ad.test 049f7511a79c155d2d8dfd2ddcfeb640c50ad0dc +F ext/fts5/test/fts5ad.test 0ddaa5b692ff220100ee396228838f4331399eaa F ext/fts5/test/fts5ae.test 612dcb51f4069226791ff14c17dbfb3138c56f20 F ext/fts5/test/fts5af.test be858a96b1f5de66ba6d64f0021bd8b2408e126c F ext/fts5/test/fts5ag.test 27180de76c03036be75ee80b93d8c5f540014071 @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2c0b93553ebb00a70c611eb8dac021877933f088 ecc98bef43c2fd07d64e4efddf340929a875ebac -R fac95fe8d4249da246cad11b14ac9297 +P a73d245f2e523a57163bc93d9fb6a74c4cdf21e7 +R 1ce1920656146c835e2df297e09b2c78 U dan -Z 0acdab0d7c32bec7117a883df7ebebf7 +Z 25b8dbc71e1c6971b424b6f8a3c7183e diff --git a/manifest.uuid b/manifest.uuid index 0ab6f5ff10..0aaeafe188 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a73d245f2e523a57163bc93d9fb6a74c4cdf21e7 \ No newline at end of file +bc5118f40a11f64ffb4e1c086277fa80b9764745 \ No newline at end of file From b19e7352c1113b6ae908d7a10d9777a6708de294 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 12 Jan 2016 19:37:20 +0000 Subject: [PATCH 183/232] Add the ".vfslist" command to the command-line shell. FossilOrigin-Name: 5727562b75edf25102cd72607c420d245379c96d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index b4c264a04b..bd838dc3eb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\suse\sof\san\suninitialized\svariable\sfollowing\ssystem\serrors\nin\sthe\smulti-threaded\ssorter. -D 2016-01-12T14:10:05.866 +C Add\sthe\s".vfslist"\scommand\sto\sthe\scommand-line\sshell. +D 2016-01-12T19:37:20.761 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -334,7 +334,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 372234e3554a7917544242563216af760d7d4219 -F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 +F src/shell.c dcd7a83645ef2a58ee9c6d0ea4714d877d7835c4 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d @@ -1407,7 +1407,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5fc0a4c1f353c4c06fcbc4bce8bbe1897ef49eee -R 92b34da2a8b41bb1db044333a3c02410 +P 4bb2c1df105c2d21f5c4c7ef656ff1d6e15f78bc +R 74300fef6ffb708c0011be0eb0839258 U drh -Z e6a278c031968913cb3469aed14f2f8a +Z 0c47ae55d5f3f2500ab8561940e3da5a diff --git a/manifest.uuid b/manifest.uuid index 9e4a59f983..9a5df7152e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4bb2c1df105c2d21f5c4c7ef656ff1d6e15f78bc \ No newline at end of file +5727562b75edf25102cd72607c420d245379c96d \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index b7a7abcd33..3f8b22f4fa 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1921,6 +1921,7 @@ static char zHelp[] = ".timer on|off Turn SQL timer on or off\n" ".trace FILE|off Output each SQL statement as it is run\n" ".vfsinfo ?AUX? Information about the top-level VFS\n" + ".vfslist List all available VFSes\n" ".vfsname ?AUX? Print the name of the VFS stack\n" ".width NUM1 NUM2 ... Set column widths for \"column\" mode\n" " Negative values right-justify\n" @@ -4170,6 +4171,24 @@ static int do_meta_command(char *zLine, ShellState *p){ } }else + if( c=='v' && strncmp(azArg[0], "vfslist", n)==0 ){ + sqlite3_vfs *pVfs; + sqlite3_vfs *pCurrent = 0; + if( p->db ){ + sqlite3_file_control(p->db, "main", SQLITE_FCNTL_VFS_POINTER, &pCurrent); + } + for(pVfs=sqlite3_vfs_find(0); pVfs; pVfs=pVfs->pNext){ + utf8_printf(p->out, "vfs.zName = \"%s\"%s\n", pVfs->zName, + pVfs==pCurrent ? " <--- CURRENT" : ""); + raw_printf(p->out, "vfs.iVersion = %d\n", pVfs->iVersion); + raw_printf(p->out, "vfs.szOsFile = %d\n", pVfs->szOsFile); + raw_printf(p->out, "vfs.mxPathname = %d\n", pVfs->mxPathname); + if( pVfs->pNext ){ + raw_printf(p->out, "-----------------------------------\n"); + } + } + }else + if( c=='v' && strncmp(azArg[0], "vfsname", n)==0 ){ const char *zDbName = nArg==2 ? azArg[1] : "main"; char *zVfsName = 0; From a04a8be2c29221f7b69de3a22fb8fce27e86a8e5 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jan 2016 17:50:10 +0000 Subject: [PATCH 184/232] When the [https://www.sqlite.org/queryplanner.html#partialsort|block sorting optimization] is used in a scalar subquery, be sure to exit the loop as soon as the first valid output row is received. Fix for ticket [cb3aa0641d9a4]. FossilOrigin-Name: cdbb0947f9ce18d6d7e29ffab5ea6a2ee5365fbb --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/select.c | 21 ++++++++++++--------- test/orderby1.test | 17 +++++++++++++++++ 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 33ebb02266..141b5d8f8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"detail"\soption\sto\sfts5.\sUsed\sto\sreduce\sthe\samount\sof\sinformation\sstored\sin\san\sfts5\sindex. -D 2016-01-12T19:45:01.185 +C When\sthe\s[https://www.sqlite.org/queryplanner.html#partialsort|block\ssorting\soptimization]\nis\sused\sin\sa\sscalar\ssubquery,\sbe\ssure\sto\sexit\sthe\sloop\sas\ssoon\sas\sthe\sfirst\nvalid\soutput\srow\sis\sreceived.\s\sFix\sfor\sticket\s[cb3aa0641d9a4]. +D 2016-01-13T17:50:10.253 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -338,7 +338,7 @@ F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c 372234e3554a7917544242563216af760d7d4219 +F src/select.c 5b0f2aa9f73ec7b65d1711d485471854d5bad23c F src/shell.c dcd7a83645ef2a58ee9c6d0ea4714d877d7835c4 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -908,7 +908,7 @@ F test/numcast.test 5d126f7f581432e86a90d1e35cac625164aec4a1 F test/numindex1.test 20a5450d4b056e48cd5db30e659f13347a099823 F test/offset1.test f06b83657bcf26f9ce805e67450e189e282143b2 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 -F test/orderby1.test 870e150450437d3980badbde3d0166b81d9e33f6 +F test/orderby1.test 4d22a7c75f6a83fc1f188cc7bb5192285fdf2552 F test/orderby2.test bc11009f7cd99d96b1b11e57b199b00633eb5b04 F test/orderby3.test 8619d06a3debdcd80a27c0fdea5c40b468854b99 F test/orderby4.test 4d39bfbaaa3ae64d026ca2ff166353d2edca4ba4 @@ -1412,8 +1412,8 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5727562b75edf25102cd72607c420d245379c96d bc5118f40a11f64ffb4e1c086277fa80b9764745 -R 32b6994fdd76448ebd10466a9fb05893 -T +closed bc5118f40a11f64ffb4e1c086277fa80b9764745 -U dan -Z d6aecf5b74614ca62cb2aeb2f23739db +P a220e85fe535af5ef2da6ef5fb76abe5a96b5abf +Q -2a74129a21f9745f1363f844807e2d10201a3f40 +R 413681dc8f5cf3f3175ce236e8b6c97f +U drh +Z fd0638b6043efd9e3f580e2c8b2c7054 diff --git a/manifest.uuid b/manifest.uuid index 26a759aaef..1133ef1cfb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a220e85fe535af5ef2da6ef5fb76abe5a96b5abf \ No newline at end of file +cdbb0947f9ce18d6d7e29ffab5ea6a2ee5365fbb \ No newline at end of file diff --git a/src/select.c b/src/select.c index 0e7c4595d1..fd094d05dd 100644 --- a/src/select.c +++ b/src/select.c @@ -54,6 +54,7 @@ struct SortCtx { int regReturn; /* Register holding block-output return address */ int labelBkOut; /* Start label for the block-output subroutine */ int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */ + int labelDone; /* Jump here when done, ex: LIMIT reached */ u8 sortFlags; /* Zero or more SORTFLAG_* bits */ }; #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */ @@ -516,6 +517,7 @@ static void pushOntoSorter( int regRecord = ++pParse->nMem; /* Assembled sorter record */ int nOBSat = pSort->nOBSat; /* ORDER BY terms to skip */ int op; /* Opcode to add sorter record to sorter */ + int iLimit; /* LIMIT counter */ assert( bSeq==0 || bSeq==1 ); assert( nData==1 || regData==regOrigData ); @@ -526,6 +528,9 @@ static void pushOntoSorter( regBase = pParse->nMem + 1; pParse->nMem += nBase; } + assert( pSelect->iOffset==0 || pSelect->iLimit!=0 ); + iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit; + pSort->labelDone = sqlite3VdbeMakeLabel(v); sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData, SQLITE_ECEL_DUP|SQLITE_ECEL_REF); if( bSeq ){ @@ -534,7 +539,6 @@ static void pushOntoSorter( if( nPrefixReg==0 ){ sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+bSeq, nData); } - sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regRecord); if( nOBSat>0 ){ int regPrevKey; /* The first nOBSat columns of the previous row */ @@ -569,6 +573,10 @@ static void pushOntoSorter( pSort->regReturn = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut); sqlite3VdbeAddOp1(v, OP_ResetSorter, pSort->iECursor); + if( iLimit ){ + sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, pSort->labelDone); + VdbeCoverage(v); + } sqlite3VdbeJumpHere(v, addrFirst); sqlite3ExprCodeMove(pParse, regBase, regPrevKey, pSort->nOBSat); sqlite3VdbeJumpHere(v, addrJmp); @@ -579,14 +587,8 @@ static void pushOntoSorter( op = OP_IdxInsert; } sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord); - if( pSelect->iLimit ){ + if( iLimit ){ int addr; - int iLimit; - if( pSelect->iOffset ){ - iLimit = pSelect->iOffset+1; - }else{ - iLimit = pSelect->iLimit; - } addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, 1); VdbeCoverage(v); sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor); sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor); @@ -1190,7 +1192,7 @@ static void generateSortTail( SelectDest *pDest /* Write the sorted results here */ ){ Vdbe *v = pParse->pVdbe; /* The prepared statement */ - int addrBreak = sqlite3VdbeMakeLabel(v); /* Jump here to exit loop */ + int addrBreak = pSort->labelDone; /* Jump here to exit loop */ int addrContinue = sqlite3VdbeMakeLabel(v); /* Jump here for next cycle */ int addr; int addrOnce = 0; @@ -1209,6 +1211,7 @@ static void generateSortTail( struct ExprList_item *aOutEx = p->pEList->a; #endif + assert( addrBreak<0 ); if( pSort->labelBkOut ){ sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut); sqlite3VdbeGoto(v, addrBreak); diff --git a/test/orderby1.test b/test/orderby1.test index 3e785c54e4..831936ae96 100644 --- a/test/orderby1.test +++ b/test/orderby1.test @@ -528,4 +528,21 @@ do_test 8.3 { set res } 5000 +#--------------------------------------------------------------------------- +# https://www.sqlite.org/src/tktview/cb3aa0641d9a413841c004293a4fc06cdc122029 +# +# Adverse interaction between scalar subqueries and the partial-sorting +# logic. +# +do_execsql_test 9.0 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(x INTEGER PRIMARY KEY); + INSERT INTO t1 VALUES(1),(2); + DROP TABLE IF EXISTS t2; + CREATE TABLE t2(y); + INSERT INTO t2 VALUES(9),(8),(3),(4); + SELECT (SELECT x||y FROM t2, t1 ORDER BY x, y); +} {13} + + finish_test From 504ef440224126ca19756bdba9b8eeb877357674 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jan 2016 18:06:08 +0000 Subject: [PATCH 185/232] Add documentation for the SQLITE_FCNTL_JOURNAL_POINTER file-control. FossilOrigin-Name: 807c5aee2e5e5c01eb33688a199755c345c3664e --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 9 +++++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 183b7bbcf7..8ad71efa12 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sexperimental\sSQLITE_FCNTL_JOURNAL_POINTER\sfile\scontrol\sfor\sobtaining\nthe\ssqlite3_file\spointer\sassociated\swith\sa\srollback\sjournal\sor\sWAL\sfile. -D 2016-01-08T02:27:01.544 +C Add\sdocumentation\sfor\sthe\sSQLITE_FCNTL_JOURNAL_POINTER\sfile-control. +D 2016-01-13T18:06:08.461 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -335,7 +335,7 @@ F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 -F src/sqlite.h.in f18858fc9440fd3c399b733057d12c53a2360d11 +F src/sqlite.h.in 214476a62012e578f42133a9a3b4f97a9aa421a3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d F src/sqliteInt.h 987b46b1d8089155caecbdb14b78850ae1e198ff @@ -1406,10 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P af5c7714e993f060841f1e893f754ddf3870e6d0 -R 1ed70ce93210d32572be9b1ea5c549df -T *branch * file-control-journal -T *sym-file-control-journal * -T -sym-trunk * +P a02ace9a746ff02fc1a5969bf13939b568624f93 +R 0f2c35be54361ea831426d444981cf27 U drh -Z 34b65576034eb21a6f6ec3e5456f3b6a +Z f9a8aaf9aacff558b761ee4baaf7cc0d diff --git a/manifest.uuid b/manifest.uuid index 8d6b249f6a..a1eb8cfe4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a02ace9a746ff02fc1a5969bf13939b568624f93 \ No newline at end of file +807c5aee2e5e5c01eb33688a199755c345c3664e \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 2f61704a2d..59b30cdd3a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -794,8 +794,13 @@ struct sqlite3_io_methods { **
  • [[SQLITE_FCNTL_FILE_POINTER]] ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer ** to the [sqlite3_file] object associated with a particular database -** connection. See the [sqlite3_file_control()] documentation for -** additional information. +** connection. See also [SQLITE_FCNTL_JOURNAL_POINTER]. +** +**
  • [[SQLITE_FCNTL_JOURNAL_POINTER]] +** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer +** to the [sqlite3_file] object associated with the journal file (either +** the [rollback journal] or the [write-ahead log]) for a particular database +** connection. See also [SQLITE_FCNTL_FILE_POINTER]. ** **
  • [[SQLITE_FCNTL_SYNC_OMITTED]] ** No longer in use. From 7f50d693598ae3c58f57200c75f63eda492c513d Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Jan 2016 18:25:36 +0000 Subject: [PATCH 186/232] Add documentation for new API functions to the comments in fts5.h. FossilOrigin-Name: 14d296fa7b43b4999a1fd070cf030f83fe1b94c3 --- ext/fts5/fts5.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++- manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5.h b/ext/fts5/fts5.h index 990c3f2f0d..96ecb38e33 100644 --- a/ext/fts5/fts5.h +++ b/ext/fts5/fts5.h @@ -84,6 +84,9 @@ struct Fts5PhraseIter { ** an OOM condition or IO error), an appropriate SQLite error code is ** returned. ** +** This function may be quite inefficient if used with an FTS5 table +** created with the "columnsize=0" option. +** ** xColumnText: ** This function attempts to retrieve the text of column iCol of the ** current document. If successful, (*pz) is set to point to a buffer @@ -104,6 +107,11 @@ struct Fts5PhraseIter { ** the query within the current row. Return SQLITE_OK if successful, or ** an error code (i.e. SQLITE_NOMEM) if an error occurs. ** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" or "detail=column" option. If the FTS5 table is created +** with either "detail=none" or "detail=column" and "content=" option +** (i.e. if it is a contentless table), then this API always returns 0. +** ** xInst: ** Query for the details of phrase match iIdx within the current row. ** Phrase matches are numbered starting from zero, so the iIdx argument @@ -119,6 +127,9 @@ struct Fts5PhraseIter { ** Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) ** if an error occurs. ** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" or "detail=column" option. +** ** xRowid: ** Returns the rowid of the current row. ** @@ -210,10 +221,48 @@ struct Fts5PhraseIter { ** ** The Fts5PhraseIter structure is defined above. Applications should not ** modify this structure directly - it should only be used as shown above -** with the xPhraseFirst() and xPhraseNext() API methods. +** with the xPhraseFirst() and xPhraseNext() API methods (and by +** xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below). +** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" or "detail=column" option. If the FTS5 table is created +** with either "detail=none" or "detail=column" and "content=" option +** (i.e. if it is a contentless table), then this API always iterates +** through an empty set (all calls to xPhraseFirst() set iCol to -1). ** ** xPhraseNext() ** See xPhraseFirst above. +** +** xPhraseFirstColumn() +** This function and xPhraseNextColumn() are similar to the xPhraseFirst() +** and xPhraseNext() APIs described above. The difference is that instead +** of iterating through all instances of a phrase in the current row, these +** APIs are used to iterate through the set of columns in the current row +** that contain one or more instances of a specified phrase. For example: +** +** Fts5PhraseIter iter; +** int iCol; +** for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol); +** iCol>=0; +** pApi->xPhraseNextColumn(pFts, &iter, &iCol) +** ){ +** // Column iCol contains at least one instance of phrase iPhrase +** } +** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" option. If the FTS5 table is created with either +** "detail=none" "content=" option (i.e. if it is a contentless table), +** then this API always iterates through an empty set (all calls to +** xPhraseFirstColumn() set iCol to -1). +** +** The information accessed using this API and its companion +** xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext +** (or xInst/xInstCount). The chief advantage of this API is that it is +** significantly more efficient than those alternatives when used with +** "detail=column" tables. +** +** xPhraseNextColumn() +** See xPhraseFirstColumn above. */ struct Fts5ExtensionApi { int iVersion; /* Currently always set to 3 */ diff --git a/manifest b/manifest index 19016057ef..a97cf05cad 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_FCNTL_JOURNAL_POINTER\sfile\scontrol. -D 2016-01-13T18:12:44.833 +C Add\sdocumentation\sfor\snew\sAPI\sfunctions\sto\sthe\scomments\sin\sfts5.h. +D 2016-01-13T18:25:36.824 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -96,7 +96,7 @@ F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7 F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 -F ext/fts5/fts5.h 88fec577a2148f34df75930dc2b0c45b0bad72c3 +F ext/fts5/fts5.h ff9c2782e8ed890b0de2f697a8d63971939e70c7 F ext/fts5/fts5Int.h 3918045ebceb1d600c9c1c1b460489ff0c788e96 F ext/fts5/fts5_aux.c 2dafc3aee0c70d643140c77d8d70daffa51a9e9e F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 @@ -1412,8 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P cdbb0947f9ce18d6d7e29ffab5ea6a2ee5365fbb 807c5aee2e5e5c01eb33688a199755c345c3664e -R 9f69ee1beb680eb7753159da9e58457d -T +closed 807c5aee2e5e5c01eb33688a199755c345c3664e -U drh -Z 158e43f82215274b7eb57ca9b5089c6b +P ad3daa5427672d2d236939ad3285b765f4601801 +R f25d53bc8dd0e47144b4d953a312dda2 +U dan +Z 9aba901b3a90a935129ccd9da6e0e571 diff --git a/manifest.uuid b/manifest.uuid index 92b929ad75..73dacf638f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ad3daa5427672d2d236939ad3285b765f4601801 \ No newline at end of file +14d296fa7b43b4999a1fd070cf030f83fe1b94c3 \ No newline at end of file From 13c808a9fca0775fec27a64701b940d5f2c16934 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 13 Jan 2016 21:23:48 +0000 Subject: [PATCH 187/232] Look for pthread_mutexattr_init() instead of pthread_create() in autoconf scripts, to work around issues with ASAN. FossilOrigin-Name: 9c3a0dc2e8bf202cd846841bd5d4ea67aa189c1a --- autoconf/configure.ac | 2 +- configure | 24 ++++++++++++------------ configure.ac | 2 +- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 8df915e955..deba91ae1d 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -73,7 +73,7 @@ AC_ARG_ENABLE(threadsafe, [AS_HELP_STRING( THREADSAFE_FLAGS=-DSQLITE_THREADSAFE=0 if test x"$enable_threadsafe" != "xno"; then THREADSAFE_FLAGS="-D_REENTRANT=1 -DSQLITE_THREADSAFE=1" - AC_SEARCH_LIBS(pthread_create, pthread) + AC_SEARCH_LIBS(pthread_mutexattr_init, pthread) fi AC_SUBST(THREADSAFE_FLAGS) #----------------------------------------------------------------------- diff --git a/configure b/configure index 850d986306..951b719ed5 100755 --- a/configure +++ b/configure @@ -10464,9 +10464,9 @@ fi if test "$SQLITE_THREADSAFE" = "1"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5 -$as_echo_n "checking for library containing pthread_create... " >&6; } -if ${ac_cv_search_pthread_create+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_mutexattr_init" >&5 +$as_echo_n "checking for library containing pthread_mutexattr_init... " >&6; } +if ${ac_cv_search_pthread_mutexattr_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -10479,11 +10479,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char pthread_create (); +char pthread_mutexattr_init (); int main () { -return pthread_create (); +return pthread_mutexattr_init (); ; return 0; } @@ -10496,25 +10496,25 @@ for ac_lib in '' pthread; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_pthread_create=$ac_res + ac_cv_search_pthread_mutexattr_init=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_pthread_create+:} false; then : + if ${ac_cv_search_pthread_mutexattr_init+:} false; then : break fi done -if ${ac_cv_search_pthread_create+:} false; then : +if ${ac_cv_search_pthread_mutexattr_init+:} false; then : else - ac_cv_search_pthread_create=no + ac_cv_search_pthread_mutexattr_init=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_create" >&5 -$as_echo "$ac_cv_search_pthread_create" >&6; } -ac_res=$ac_cv_search_pthread_create +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_mutexattr_init" >&5 +$as_echo "$ac_cv_search_pthread_mutexattr_init" >&6; } +ac_res=$ac_cv_search_pthread_mutexattr_init if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" diff --git a/configure.ac b/configure.ac index 0b94d33930..26a60147dd 100644 --- a/configure.ac +++ b/configure.ac @@ -194,7 +194,7 @@ fi AC_SUBST(SQLITE_THREADSAFE) if test "$SQLITE_THREADSAFE" = "1"; then - AC_SEARCH_LIBS(pthread_create, pthread) + AC_SEARCH_LIBS(pthread_mutexattr_init, pthread) fi ########## diff --git a/manifest b/manifest index a97cf05cad..db7623fdf9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sdocumentation\sfor\snew\sAPI\sfunctions\sto\sthe\scomments\sin\sfts5.h. -D 2016-01-13T18:25:36.824 +C Look\sfor\spthread_mutexattr_init()\sinstead\sof\spthread_create()\sin\sautoconf\nscripts,\sto\swork\saround\sissues\swith\sASAN. +D 2016-01-13T21:23:48.485 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -13,7 +13,7 @@ F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am 089e5ecdb5761e64ea1013ded02feb4d8b29927d F autoconf/README 14458f1046c118efa721aadec5f227e876d3cd38 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 -F autoconf/configure.ac 82c628c68f0f204d57343dc345b6dbd1789fb1bd +F autoconf/configure.ac 2f41055b10873cfe443a08185343e38c47e2f9f0 F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -29,8 +29,8 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 42b71ad3fe21c9e88fa59e8458ca1a6bc72eb0c0 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure b4519bb54fff37e7cde9d03d8f2946f18d5d0086 x -F configure.ac fcfc67b323d32daaa3e46cf7782d9465ed423a6d +F configure d57d3b9d5c66549e54a4a2960de9813142d30a5a x +F configure.ac c59513d560b3107995c73b9cc1e55bfd086c4764 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1 F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710 @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ad3daa5427672d2d236939ad3285b765f4601801 -R f25d53bc8dd0e47144b4d953a312dda2 -U dan -Z 9aba901b3a90a935129ccd9da6e0e571 +P 14d296fa7b43b4999a1fd070cf030f83fe1b94c3 +R 2b677537f1e9b18e2947e5670c77e061 +U drh +Z d3d675fa0c765d73d93e44db2a68c69e diff --git a/manifest.uuid b/manifest.uuid index 73dacf638f..9104c2d889 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -14d296fa7b43b4999a1fd070cf030f83fe1b94c3 \ No newline at end of file +9c3a0dc2e8bf202cd846841bd5d4ea67aa189c1a \ No newline at end of file From b4acd6a8d64dfb0f768b39c08fb37b3c03b27156 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jan 2016 01:56:43 +0000 Subject: [PATCH 188/232] Fix the build so that it works for SQLITE_OMIT_WAL again. FossilOrigin-Name: d55a557bc70460c46a67ae5acd9f8a8356a580c2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pager.c | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index db7623fdf9..d9cc140750 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Look\sfor\spthread_mutexattr_init()\sinstead\sof\spthread_create()\sin\sautoconf\nscripts,\sto\swork\saround\sissues\swith\sASAN. -D 2016-01-13T21:23:48.485 +C Fix\sthe\sbuild\sso\sthat\sit\sworks\sfor\sSQLITE_OMIT_WAL\sagain. +D 2016-01-14T01:56:43.015 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -325,7 +325,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c b509b49b40a269e7b75ab511b6e92b2dc9444359 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c 5dda328a9a5e9405b6971d62d0d5e3ea85c6195a +F src/pager.c f4e9ac39fbb1e0fde97af85c0f4e00eb90764b67 F src/pager.h 1c2a49143dfba9e69cc8159ef019f472ed8d260b F src/parse.y caad1e98edeca6960493d0c60d31b76820dd7776 F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 14d296fa7b43b4999a1fd070cf030f83fe1b94c3 -R 2b677537f1e9b18e2947e5670c77e061 +P 9c3a0dc2e8bf202cd846841bd5d4ea67aa189c1a +R 7d3ddebf3af55be615ba3903145bc66f U drh -Z d3d675fa0c765d73d93e44db2a68c69e +Z 40f341244fdfbe64f691992440e887ec diff --git a/manifest.uuid b/manifest.uuid index 9104c2d889..6e8776e5e5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9c3a0dc2e8bf202cd846841bd5d4ea67aa189c1a \ No newline at end of file +d55a557bc70460c46a67ae5acd9f8a8356a580c2 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 8f49e656e8..2c904d2df1 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5627,7 +5627,7 @@ int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){ if( rc!=SQLITE_OK ){ return rc; } - sqlite3WalExclusiveMode(pPager->pWal, 1); + (void)sqlite3WalExclusiveMode(pPager->pWal, 1); } /* Grab the write lock on the log file. If successful, upgrade to @@ -6697,7 +6697,11 @@ sqlite3_file *sqlite3PagerFile(Pager *pPager){ ** This will be either the rollback journal or the WAL file. */ sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){ +#if SQLITE_OMIT_WAL + return pPager->jfd; +#else return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd; +#endif } /* From 62e63bb9a93732b7a47eba95d90707c3d10cac31 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jan 2016 12:23:16 +0000 Subject: [PATCH 189/232] Fix harmless compiler warnings in sqldiff.c. FossilOrigin-Name: 74808a79ea3194f6cc00084b9dccc380846a6051 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/sqldiff.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d9cc140750..7187aa4558 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sbuild\sso\sthat\sit\sworks\sfor\sSQLITE_OMIT_WAL\sagain. -D 2016-01-14T01:56:43.015 +C Fix\sharmless\scompiler\swarnings\sin\ssqldiff.c. +D 2016-01-14T12:23:16.611 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -1401,7 +1401,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/sqldiff.c 653db1a9294e0b34849c4504599c282a18d8b8c6 +F tool/sqldiff.c 5a26205111e6fa856d9b1535b1637744dcdb930b F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9c3a0dc2e8bf202cd846841bd5d4ea67aa189c1a -R 7d3ddebf3af55be615ba3903145bc66f +P d55a557bc70460c46a67ae5acd9f8a8356a580c2 +R 34645f4f80a93ccb4b9986535bb6f0b0 U drh -Z 40f341244fdfbe64f691992440e887ec +Z 0c8aaf707fea483adf01b6983fc067a8 diff --git a/manifest.uuid b/manifest.uuid index 6e8776e5e5..4d3f464471 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d55a557bc70460c46a67ae5acd9f8a8356a580c2 \ No newline at end of file +74808a79ea3194f6cc00084b9dccc380846a6051 \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index 56ff53ee25..ae01cd3c4d 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -994,7 +994,7 @@ static int rbuDeltaCreate( zDelta += lenOut; putInt(checksum(zOut, lenOut), &zDelta); *(zDelta++) = ';'; - return zDelta - zOrigDelta; + return (int)(zDelta - zOrigDelta); } /* Compute the hash table used to locate matching sections in the @@ -1141,7 +1141,7 @@ static int rbuDeltaCreate( putInt(checksum(zOut, lenOut), &zDelta); *(zDelta++) = ';'; sqlite3_free(collide); - return zDelta - zOrigDelta; + return (int)(zDelta - zOrigDelta); } /* From 7647377f528ab8fa26ba4be05a5151a51ffbbf08 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jan 2016 13:22:24 +0000 Subject: [PATCH 190/232] Fix harmless compiler warnings in RBU and add RBU to the autoconf and windows makefiles. FossilOrigin-Name: fabe78c5d8ab353988f6fe0decacd651edc17ec2 --- Makefile.in | 11 ++++++++++- Makefile.msc | 9 ++++++++- ext/rbu/rbu.c | 7 +++---- ext/rbu/sqlite3rbu.c | 37 +++++++++++++++++++------------------ manifest | 18 +++++++++--------- manifest.uuid | 2 +- 6 files changed, 50 insertions(+), 34 deletions(-) diff --git a/Makefile.in b/Makefile.in index 1fe49d6789..2782e765f5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -179,7 +179,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \ mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \ notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \ pager.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \ - random.lo resolve.lo rowset.lo rtree.lo select.lo status.lo \ + random.lo resolve.lo rowset.lo rtree.lo select.lo sqlite3rbu.lo status.lo \ table.lo threads.lo tokenize.lo treeview.lo trigger.lo \ update.lo util.lo vacuum.lo \ vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \ @@ -1028,6 +1028,9 @@ fts5.c: $(FTS5_SRC) fts5.lo: fts5.c $(HDR) $(EXTHDR) $(LTCOMPILE) -DSQLITE_CORE -c fts5.c +sqlite3rbu.lo: $(TOP)/ext/rbu/sqlite3rbu.c $(HDR) $(EXTHDR) + $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/rbu/sqlite3rbu.c + # Rules to build the 'testfixture' application. # @@ -1131,6 +1134,12 @@ wordcount$(TEXE): $(TOP)/test/wordcount.c sqlite3.c speedtest1$(TEXE): $(TOP)/test/speedtest1.c sqlite3.lo $(LTLINK) -o $@ $(TOP)/test/speedtest1.c sqlite3.lo $(TLIBS) +rbu$(EXE): $(TOP)/ext/rbu/rbu.c $(TOP)/ext/rbu/sqlite3rbu.c sqlite3.lo + $(LTLINK) -I. -o $@ $(TOP)/ext/rbu/rbu.c sqlite3.lo $(TLIBS) + +loadfts$(EXE): $(TOP)/tool/loadfts.c libsqlite3.la + $(LTLINK) $(TOP)/tool/loadfts.c libsqlite3.la -o $@ $(TLIBS) + # This target will fail if the SQLite amalgamation contains any exported # symbols that do not begin with "sqlite3_". It is run as part of the # releasetest.tcl script. diff --git a/Makefile.msc b/Makefile.msc index 92561a8a32..0eb660adc7 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -839,7 +839,7 @@ LIBOBJS0 = vdbe.lo parse.lo alter.lo analyze.lo attach.lo auth.lo \ mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \ notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \ pager.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \ - random.lo resolve.lo rowset.lo rtree.lo select.lo status.lo \ + random.lo resolve.lo rowset.lo rtree.lo select.lo sqlite3rbu.lo status.lo \ table.lo threads.lo tokenize.lo treeview.lo trigger.lo \ update.lo util.lo vacuum.lo \ vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \ @@ -1714,6 +1714,9 @@ fts5_ext.lo: fts5.c $(HDR) $(EXTHDR) fts5.dll: fts5_ext.lo $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /OUT:$@ fts5_ext.lo +sqlite3rbu.lo: $(TOP)/ext/rbu/sqlite3rbu.c $(HDR) $(EXTHDR) + $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/rbu/sqlite3rbu.c + # Rules to build the 'testfixture' application. # # If using the amalgamation, use sqlite3.c directly to build the test @@ -1836,6 +1839,10 @@ speedtest1.exe: $(TOP)\test\speedtest1.c $(SQLITE3C) $(LTLINK) $(NO_WARN) -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\test\speedtest1.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) +rbu.exe: $(TOP)\ext\rbu\rbu.c $(TOP)\ext\rbu\sqlite3rbu.c $(SQLITE3C) + $(LTLINK) $(NO_WARN) -I. -DSQLITE_ENABLE_RBU -Fe$@ $(TOP)\ext\rbu\rbu.c $(SQLITE3C) \ + $(LDFLAGS) $(LTLINKOPTS) + clean: del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL del /Q *.bsc *.cod *.da *.bb *.bbg gmon.out 2>NUL diff --git a/ext/rbu/rbu.c b/ext/rbu/rbu.c index dd46743def..018296b8dd 100644 --- a/ext/rbu/rbu.c +++ b/ext/rbu/rbu.c @@ -75,7 +75,7 @@ int main(int argc, char **argv){ /* Process command line arguments. Following this block local variables ** zTarget, zRbu and nStep are all set. */ if( argc==5 ){ - int nArg1 = strlen(argv[1]); + size_t nArg1 = strlen(argv[1]); if( nArg1>5 || nArg1<2 || memcmp("-step", argv[1], nArg1) ) usage(argv[0]); nStep = atoi(argv[2]); }else if( argc!=3 ){ @@ -103,7 +103,7 @@ int main(int argc, char **argv){ "SQLITE_OK: rbu update incomplete (%lld operations so far)\n", nProgress ); - fprintf(stdout, zBuf); + fprintf(stdout, "%s", zBuf); break; case SQLITE_DONE: @@ -111,7 +111,7 @@ int main(int argc, char **argv){ "SQLITE_DONE: rbu update completed (%lld operations)\n", nProgress ); - fprintf(stdout, zBuf); + fprintf(stdout, "%s", zBuf); break; default: @@ -122,4 +122,3 @@ int main(int argc, char **argv){ sqlite3_free(zErrmsg); return (rc==SQLITE_OK || rc==SQLITE_DONE) ? 0 : 1; } - diff --git a/ext/rbu/sqlite3rbu.c b/ext/rbu/sqlite3rbu.c index 4c38e14c9e..145b446d30 100644 --- a/ext/rbu/sqlite3rbu.c +++ b/ext/rbu/sqlite3rbu.c @@ -935,7 +935,7 @@ static void *rbuMalloc(sqlite3rbu *p, int nByte){ void *pRet = 0; if( p->rc==SQLITE_OK ){ assert( nByte>0 ); - pRet = sqlite3_malloc(nByte); + pRet = sqlite3_malloc64(nByte); if( pRet==0 ){ p->rc = SQLITE_NOMEM; }else{ @@ -981,8 +981,8 @@ static char *rbuStrndup(const char *zStr, int *pRc){ assert( *pRc==SQLITE_OK ); if( zStr ){ - int nCopy = strlen(zStr) + 1; - zRet = (char*)sqlite3_malloc(nCopy); + size_t nCopy = strlen(zStr) + 1; + zRet = (char*)sqlite3_malloc64(nCopy); if( zRet ){ memcpy(zRet, zStr, nCopy); }else{ @@ -2330,7 +2330,7 @@ static int rbuCaptureWalRead(sqlite3rbu *pRbu, i64 iOff, int iAmt){ if( pRbu->nFrame==pRbu->nFrameAlloc ){ int nNew = (pRbu->nFrameAlloc ? pRbu->nFrameAlloc : 64) * 2; RbuFrame *aNew; - aNew = (RbuFrame*)sqlite3_realloc(pRbu->aFrame, nNew * sizeof(RbuFrame)); + aNew = (RbuFrame*)sqlite3_realloc64(pRbu->aFrame, nNew * sizeof(RbuFrame)); if( aNew==0 ) return SQLITE_NOMEM; pRbu->aFrame = aNew; pRbu->nFrameAlloc = nNew; @@ -2395,7 +2395,7 @@ static LPWSTR rbuWinUtf8ToUnicode(const char *zFilename){ if( nChar==0 ){ return 0; } - zWideFilename = sqlite3_malloc( nChar*sizeof(zWideFilename[0]) ); + zWideFilename = sqlite3_malloc64( nChar*sizeof(zWideFilename[0]) ); if( zWideFilename==0 ){ return 0; } @@ -3029,11 +3029,12 @@ sqlite3rbu *sqlite3rbu_open( const char *zState ){ sqlite3rbu *p; - int nTarget = strlen(zTarget); - int nRbu = strlen(zRbu); - int nState = zState ? strlen(zState) : 0; + size_t nTarget = strlen(zTarget); + size_t nRbu = strlen(zRbu); + size_t nState = zState ? strlen(zState) : 0; + size_t nByte = sizeof(sqlite3rbu) + nTarget+1 + nRbu+1+ nState+1; - p = (sqlite3rbu*)sqlite3_malloc(sizeof(sqlite3rbu)+nTarget+1+nRbu+1+nState+1); + p = (sqlite3rbu*)sqlite3_malloc64(nByte); if( p ){ RbuState *pState = 0; @@ -3170,7 +3171,7 @@ sqlite3 *sqlite3rbu_db(sqlite3rbu *pRbu, int bRbu){ static void rbuEditErrmsg(sqlite3rbu *p){ if( p->rc==SQLITE_CONSTRAINT && p->zErrmsg ){ int i; - int nErrmsg = strlen(p->zErrmsg); + size_t nErrmsg = strlen(p->zErrmsg); for(i=0; i<(nErrmsg-8); i++){ if( memcmp(&p->zErrmsg[i], "rbu_imp_", 8)==0 ){ int nDel = 8; @@ -3634,7 +3635,7 @@ static int rbuVfsShmMap( if( eStage==RBU_STAGE_OAL || eStage==RBU_STAGE_MOVE ){ if( iRegion<=p->nShm ){ int nByte = (iRegion+1) * sizeof(char*); - char **apNew = (char**)sqlite3_realloc(p->apShm, nByte); + char **apNew = (char**)sqlite3_realloc64(p->apShm, nByte); if( apNew==0 ){ rc = SQLITE_NOMEM; }else{ @@ -3645,7 +3646,7 @@ static int rbuVfsShmMap( } if( rc==SQLITE_OK && p->apShm[iRegion]==0 ){ - char *pNew = (char*)sqlite3_malloc(szRegion); + char *pNew = (char*)sqlite3_malloc64(szRegion); if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ @@ -3755,7 +3756,7 @@ static int rbuVfsOpen( ** the name of the *-wal file this db connection will use. SQLite ** happens to pass a pointer to this buffer when using xAccess() ** or xOpen() to operate on the *-wal file. */ - int n = strlen(zName); + int n = (int)strlen(zName); const char *z = &zName[n]; if( flags & SQLITE_OPEN_URI ){ int odd = 0; @@ -3781,8 +3782,8 @@ static int rbuVfsOpen( ** code ensures that the string passed to xOpen() is terminated by a ** pair of '\0' bytes in case the VFS attempts to extract a URI ** parameter from it. */ - int nCopy = strlen(zName); - char *zCopy = sqlite3_malloc(nCopy+2); + size_t nCopy = strlen(zName); + char *zCopy = sqlite3_malloc64(nCopy+2); if( zCopy ){ memcpy(zCopy, zName, nCopy); zCopy[nCopy-3] = 'o'; @@ -4011,13 +4012,13 @@ int sqlite3rbu_create_vfs(const char *zName, const char *zParent){ }; rbu_vfs *pNew = 0; /* Newly allocated VFS */ - int nName; int rc = SQLITE_OK; + size_t nName; + size_t nByte; - int nByte; nName = strlen(zName); nByte = sizeof(rbu_vfs) + nName + 1; - pNew = (rbu_vfs*)sqlite3_malloc(nByte); + pNew = (rbu_vfs*)sqlite3_malloc64(nByte); if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ diff --git a/manifest b/manifest index 7187aa4558..566a67eeac 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Fix\sharmless\scompiler\swarnings\sin\ssqldiff.c. -D 2016-01-14T12:23:16.611 -F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 +C Fix\sharmless\scompiler\swarnings\sin\sRBU\sand\sadd\sRBU\sto\sthe\sautoconf\sand\swindows\nmakefiles. +D 2016-01-14T13:22:24.150 +F Makefile.in cfa1ac03c4b414992fd53f24d978b45b0c21de55 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 +F Makefile.msc 1dc36cfd3c047c9685e539257e158485f16ef035 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 866588d1edf0ccb5b0d33896974338f97564f719 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -208,7 +208,7 @@ F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/rbu/rbu.c e572f7ddef2ef3a73d03e7b44d36448e466772b7 +F ext/rbu/rbu.c ba3983dceffa0938532e79142f391737513de023 F ext/rbu/rbu1.test 57601977588603e82700a43c279bd55282ffa482 F ext/rbu/rbu10.test 046b0980041d30700464a800bbf6733ed2df515d F ext/rbu/rbu11.test 9bc68c2d3dbeb1720153626e3bd0466dcc017702 @@ -230,7 +230,7 @@ F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89 F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06 F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48 -F ext/rbu/sqlite3rbu.c ea47de615e911b3a69a8e7fb3be3866298403a25 +F ext/rbu/sqlite3rbu.c bea954197524631f2691ec272e8a42df8cad01cc F ext/rbu/sqlite3rbu.h 0bdeb3be211aaba7d85445fa36f4701a25a3dbde F ext/rbu/test_rbu.c 4a4cdcef4ef9379fc2a21f008805c80b27bcf573 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d55a557bc70460c46a67ae5acd9f8a8356a580c2 -R 34645f4f80a93ccb4b9986535bb6f0b0 +P 74808a79ea3194f6cc00084b9dccc380846a6051 +R e29cff8691de1217f1757056bcfdb892 U drh -Z 0c8aaf707fea483adf01b6983fc067a8 +Z 1e6a858f101158e4efde76213bfd70e5 diff --git a/manifest.uuid b/manifest.uuid index 4d3f464471..6ea6f0c03c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -74808a79ea3194f6cc00084b9dccc380846a6051 \ No newline at end of file +fabe78c5d8ab353988f6fe0decacd651edc17ec2 \ No newline at end of file From f705e9deab4a18e9c5fd726a59226329e4674c95 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 14 Jan 2016 14:15:54 +0000 Subject: [PATCH 191/232] Fix compiler warnings in fts5. FossilOrigin-Name: 5a343cc0336bba056df4449e6cd2e3fb9e75a105 --- ext/fts5/fts5Int.h | 1 - ext/fts5/fts5_config.c | 2 +- ext/fts5/fts5_expr.c | 5 +++-- ext/fts5/fts5_index.c | 4 +--- ext/fts5/fts5_main.c | 7 ------- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- 7 files changed, 17 insertions(+), 26 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 1a3d57ca26..2a16ec065f 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -424,7 +424,6 @@ int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int); /* ** Functions called by the storage module as part of integrity-check. */ -u64 sqlite3Fts5IndexCksum(Fts5Config*,i64,int,int,const char*,int); int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum); /* diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index fd6da7f11e..d9778bca20 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -379,7 +379,7 @@ static int fts5ConfigParseSpecial( { 0, 0 } }; - if( rc = fts5ConfigSetEnum(aDetail, zArg, &pConfig->eDetail) ){ + if( (rc = fts5ConfigSetEnum(aDetail, zArg, &pConfig->eDetail)) ){ *pzErr = sqlite3_mprintf("malformed detail=... directive"); } return rc; diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 16209bf4ba..409fbd1d05 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -2428,7 +2428,7 @@ static int fts5ExprCheckPoslists(Fts5ExprNode *pNode, i64 iRowid){ return 0; } } - return 1; + break; } case FTS5_OR: { @@ -2453,10 +2453,11 @@ static int fts5ExprCheckPoslists(Fts5ExprNode *pNode, i64 iRowid){ fts5ExprClearPoslists(pNode); return 0; } - return 1; + break; } } } + return 1; } void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){ diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 2488cd7ca9..cc5b8ea521 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -1772,8 +1772,6 @@ static void fts5SegIterNext_Reverse( if( pIter->iRowidOffset>0 ){ u8 *a = pIter->pLeaf->p; int iOff; - int nPos; - int bDummy; i64 iDelta; pIter->iRowidOffset--; @@ -1821,7 +1819,7 @@ static void fts5SegIterNext_None( if( iOffiEndofDoclist ){ /* Next entry is on the current page */ i64 iDelta; - iOff += sqlite3Fts5GetVarint(&pIter->pLeaf->p[iOff], &iDelta); + iOff += sqlite3Fts5GetVarint(&pIter->pLeaf->p[iOff], (u64*)&iDelta); pIter->iLeafOffset = iOff; pIter->iRowid += iDelta; }else if( (pIter->flags & FTS5_SEGITER_ONETERM)==0 ){ diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index ba8903c9a7..fec589efcb 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -310,13 +310,6 @@ static int fts5IsContentless(Fts5Table *pTab){ return pTab->pConfig->eContent==FTS5_CONTENT_NONE; } -/* -** Return true if pTab is an offsetless table. -*/ -static int fts5IsOffsetless(Fts5Table *pTab){ - return pTab->pConfig->eDetail!=FTS5_DETAIL_FULL; -} - /* ** Delete a virtual table handle allocated by fts5InitVtab(). */ diff --git a/manifest b/manifest index 566a67eeac..7290cda6dc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sRBU\sand\sadd\sRBU\sto\sthe\sautoconf\sand\swindows\nmakefiles. -D 2016-01-14T13:22:24.150 +C Fix\scompiler\swarnings\sin\sfts5. +D 2016-01-14T14:15:54.059 F Makefile.in cfa1ac03c4b414992fd53f24d978b45b0c21de55 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 1dc36cfd3c047c9685e539257e158485f16ef035 @@ -97,14 +97,14 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h ff9c2782e8ed890b0de2f697a8d63971939e70c7 -F ext/fts5/fts5Int.h 3918045ebceb1d600c9c1c1b460489ff0c788e96 +F ext/fts5/fts5Int.h 3a09b2eaeac2860d7afc59843796a9410f818ebf F ext/fts5/fts5_aux.c 2dafc3aee0c70d643140c77d8d70daffa51a9e9e F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 -F ext/fts5/fts5_config.c b0ed7b0ddd785fb4d4e6f9037d357f8aa95918e6 -F ext/fts5/fts5_expr.c 6eba2220747ea1b20a358fb3b34b2ab78323e285 +F ext/fts5/fts5_config.c 9c243d04ac0ca997d2d2e2252891f2a10fbd7217 +F ext/fts5/fts5_expr.c 510db45967ca359f64f2ba2c707ab57d740cad56 F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 -F ext/fts5/fts5_index.c 5ab044a67919e2c9f42f0288a39778136154511e -F ext/fts5/fts5_main.c 03bd44e4bd0ba16213ca9259ad5df1d4d743fd7e +F ext/fts5/fts5_index.c 11e2b566b8b29fb42bb970969c92f3a33c2c1125 +F ext/fts5/fts5_main.c 488ceecdb4400ecc6a3d3b2247cedef153955388 F ext/fts5/fts5_storage.c f7b2d330dd7b29a9f4da09f6d85879ca8c41b2e8 F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb F ext/fts5/fts5_test_mi.c 1ec66ffdf7632077fbd773b7a6df5153272ec070 @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 74808a79ea3194f6cc00084b9dccc380846a6051 -R e29cff8691de1217f1757056bcfdb892 -U drh -Z 1e6a858f101158e4efde76213bfd70e5 +P fabe78c5d8ab353988f6fe0decacd651edc17ec2 +R fee981891bfd69d76d7d5d050236b09c +U dan +Z 4d3da4cf65c48965923bd47b765f8e62 diff --git a/manifest.uuid b/manifest.uuid index 6ea6f0c03c..3b2733f52b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fabe78c5d8ab353988f6fe0decacd651edc17ec2 \ No newline at end of file +5a343cc0336bba056df4449e6cd2e3fb9e75a105 \ No newline at end of file From 17535393b9363702fd8fda7a5a7b75446a2a146a Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 14 Jan 2016 14:19:50 +0000 Subject: [PATCH 192/232] Fix another compiler warning in fts5 code. FossilOrigin-Name: d17bc2c92f4d086280e49a3cc72993be7fee2da7 --- ext/fts5/fts5_index.c | 9 +-------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index cc5b8ea521..4368128796 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -2001,7 +2001,6 @@ static void fts5SegIterNext( ** the doclist. */ static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){ - int eDetail = p->pConfig->eDetail; Fts5DlidxIter *pDlidx = pIter->pDlidx; Fts5Data *pLast = 0; int pgnoLast = 0; @@ -2016,11 +2015,6 @@ static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){ /* Currently, Fts5SegIter.iLeafOffset points to the first byte of ** position-list content for the current rowid. Back it up so that it ** points to the start of the position-list size field. */ -#if 0 - if( eDetail!=FTS5_DETAIL_NONE ){ - pIter->iLeafOffset -= sqlite3Fts5GetVarintLen(pIter->nPos*2+pIter->bDel); - } -#else int iPoslist; if( pIter->iTermLeafPgno==pIter->iLeafPgno ){ iPoslist = pIter->iTermLeafOffset; @@ -2028,11 +2022,10 @@ static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){ iPoslist = 4; } fts5IndexSkipVarint(pLeaf->p, iPoslist); - assert( eDetail==FTS5_DETAIL_NONE || iPoslist==( + assert( p->pConfig->eDetail==FTS5_DETAIL_NONE || iPoslist==( pIter->iLeafOffset - sqlite3Fts5GetVarintLen(pIter->nPos*2+pIter->bDel) )); pIter->iLeafOffset = iPoslist; -#endif /* If this condition is true then the largest rowid for the current ** term may not be stored on the current page. So search forward to diff --git a/manifest b/manifest index 7290cda6dc..2748e213ba 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompiler\swarnings\sin\sfts5. -D 2016-01-14T14:15:54.059 +C Fix\sanother\scompiler\swarning\sin\sfts5\scode. +D 2016-01-14T14:19:50.419 F Makefile.in cfa1ac03c4b414992fd53f24d978b45b0c21de55 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 1dc36cfd3c047c9685e539257e158485f16ef035 @@ -103,7 +103,7 @@ F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c 9c243d04ac0ca997d2d2e2252891f2a10fbd7217 F ext/fts5/fts5_expr.c 510db45967ca359f64f2ba2c707ab57d740cad56 F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 -F ext/fts5/fts5_index.c 11e2b566b8b29fb42bb970969c92f3a33c2c1125 +F ext/fts5/fts5_index.c 140617e34ccc61c2af5d313ecea6bca17591d185 F ext/fts5/fts5_main.c 488ceecdb4400ecc6a3d3b2247cedef153955388 F ext/fts5/fts5_storage.c f7b2d330dd7b29a9f4da09f6d85879ca8c41b2e8 F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fabe78c5d8ab353988f6fe0decacd651edc17ec2 -R fee981891bfd69d76d7d5d050236b09c +P 5a343cc0336bba056df4449e6cd2e3fb9e75a105 +R 15e5cdb9315970f41cbec5989792ed12 U dan -Z 4d3da4cf65c48965923bd47b765f8e62 +Z 4127a035afc4dee8202030a933b1de27 diff --git a/manifest.uuid b/manifest.uuid index 3b2733f52b..ef7de38a98 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5a343cc0336bba056df4449e6cd2e3fb9e75a105 \ No newline at end of file +d17bc2c92f4d086280e49a3cc72993be7fee2da7 \ No newline at end of file From d625adb8dbf0558b8575a9e6ee5d0e74489253ef Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jan 2016 14:29:57 +0000 Subject: [PATCH 193/232] Fix more compiler warnings in FTS5. FossilOrigin-Name: f791fc7009d68941c60d7bf953bab19d86112133 --- ext/fts5/fts5Int.h | 23 +++++++++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 2a16ec065f..1daeefc09f 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -339,6 +339,29 @@ int sqlite3Fts5IndexClose(Fts5Index *p); ** } */ +/* +** Return a simple checksum value based on the arguments. +*/ +u64 sqlite3Fts5IndexEntryCksum( + i64 iRowid, + int iCol, + int iPos, + int iIdx, + const char *pTerm, + int nTerm +); + +/* +** Argument p points to a buffer containing utf-8 text that is n bytes in +** size. Return the number of bytes in the nChar character prefix of the +** buffer, or 0 if there are less than nChar characters in total. +*/ +int sqlite3Fts5IndexCharlenToBytelen( + const char *p, + int nByte, + int nChar +); + /* ** Open a new iterator to iterate though all rowids that match the ** specified token or token prefix. diff --git a/manifest b/manifest index 2748e213ba..7832158c65 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sanother\scompiler\swarning\sin\sfts5\scode. -D 2016-01-14T14:19:50.419 +C Fix\smore\scompiler\swarnings\sin\sFTS5. +D 2016-01-14T14:29:57.029 F Makefile.in cfa1ac03c4b414992fd53f24d978b45b0c21de55 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 1dc36cfd3c047c9685e539257e158485f16ef035 @@ -97,7 +97,7 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h ff9c2782e8ed890b0de2f697a8d63971939e70c7 -F ext/fts5/fts5Int.h 3a09b2eaeac2860d7afc59843796a9410f818ebf +F ext/fts5/fts5Int.h 6c5a332e6add01dd69166a252d1818fb75c42a08 F ext/fts5/fts5_aux.c 2dafc3aee0c70d643140c77d8d70daffa51a9e9e F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c 9c243d04ac0ca997d2d2e2252891f2a10fbd7217 @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5a343cc0336bba056df4449e6cd2e3fb9e75a105 -R 15e5cdb9315970f41cbec5989792ed12 -U dan -Z 4127a035afc4dee8202030a933b1de27 +P d17bc2c92f4d086280e49a3cc72993be7fee2da7 +R 3a1d2f76daaee8302a3c8f4c76ae20d1 +U drh +Z 3fe0c32146b166753bb44c9b01cd24a5 diff --git a/manifest.uuid b/manifest.uuid index ef7de38a98..b53571837f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d17bc2c92f4d086280e49a3cc72993be7fee2da7 \ No newline at end of file +f791fc7009d68941c60d7bf953bab19d86112133 \ No newline at end of file From 0ea94db612e0f2348b45dafcedf21d9a8f68c60b Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jan 2016 14:33:36 +0000 Subject: [PATCH 194/232] Yet another change to FTS5 trying to get it to merge successfully into sessions. FossilOrigin-Name: 8dedff3b9ac3e6bf9c131fee19f7d26dc1ebd61f --- ext/fts5/fts5_index.c | 3 +-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 4368128796..2f5b3bdaae 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4856,7 +4856,7 @@ int sqlite3Fts5IndexClose(Fts5Index *p){ ** size. Return the number of bytes in the nChar character prefix of the ** buffer, or 0 if there are less than nChar characters in total. */ -static int sqlite3Fts5IndexCharlenToBytelen( +int sqlite3Fts5IndexCharlenToBytelen( const char *p, int nByte, int nChar @@ -6092,4 +6092,3 @@ int sqlite3Fts5IndexInit(sqlite3 *db){ } return rc; } - diff --git a/manifest b/manifest index 7832158c65..1354db7a40 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\smore\scompiler\swarnings\sin\sFTS5. -D 2016-01-14T14:29:57.029 +C Yet\sanother\schange\sto\sFTS5\strying\sto\sget\sit\sto\smerge\ssuccessfully\sinto\ssessions. +D 2016-01-14T14:33:36.733 F Makefile.in cfa1ac03c4b414992fd53f24d978b45b0c21de55 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 1dc36cfd3c047c9685e539257e158485f16ef035 @@ -103,7 +103,7 @@ F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c 9c243d04ac0ca997d2d2e2252891f2a10fbd7217 F ext/fts5/fts5_expr.c 510db45967ca359f64f2ba2c707ab57d740cad56 F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 -F ext/fts5/fts5_index.c 140617e34ccc61c2af5d313ecea6bca17591d185 +F ext/fts5/fts5_index.c aa798d3a839847fd351b3d0f49520f190e57c2e3 F ext/fts5/fts5_main.c 488ceecdb4400ecc6a3d3b2247cedef153955388 F ext/fts5/fts5_storage.c f7b2d330dd7b29a9f4da09f6d85879ca8c41b2e8 F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d17bc2c92f4d086280e49a3cc72993be7fee2da7 -R 3a1d2f76daaee8302a3c8f4c76ae20d1 +P f791fc7009d68941c60d7bf953bab19d86112133 +R 52083946c40dd4f44744cbc0b447540f U drh -Z 3fe0c32146b166753bb44c9b01cd24a5 +Z 9b36451b3b0b6d81cfd6f7c438e3b3aa diff --git a/manifest.uuid b/manifest.uuid index b53571837f..92616336df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f791fc7009d68941c60d7bf953bab19d86112133 \ No newline at end of file +8dedff3b9ac3e6bf9c131fee19f7d26dc1ebd61f \ No newline at end of file From 83a2253409c9856093c1fc9be16c5793d295a375 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 14 Jan 2016 18:01:16 +0000 Subject: [PATCH 195/232] Minor adjustments to the MSVC makefile. FossilOrigin-Name: e2cba1bbfdcb24e35b2275e29071d8a4e4943417 --- Makefile.msc | 8 ++++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 0eb660adc7..728154737b 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1714,8 +1714,8 @@ fts5_ext.lo: fts5.c $(HDR) $(EXTHDR) fts5.dll: fts5_ext.lo $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /OUT:$@ fts5_ext.lo -sqlite3rbu.lo: $(TOP)/ext/rbu/sqlite3rbu.c $(HDR) $(EXTHDR) - $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/rbu/sqlite3rbu.c +sqlite3rbu.lo: $(TOP)\ext\rbu\sqlite3rbu.c $(HDR) $(EXTHDR) + $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)\ext\rbu\sqlite3rbu.c # Rules to build the 'testfixture' application. # @@ -1840,8 +1840,8 @@ speedtest1.exe: $(TOP)\test\speedtest1.c $(SQLITE3C) $(TOP)\test\speedtest1.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) rbu.exe: $(TOP)\ext\rbu\rbu.c $(TOP)\ext\rbu\sqlite3rbu.c $(SQLITE3C) - $(LTLINK) $(NO_WARN) -I. -DSQLITE_ENABLE_RBU -Fe$@ $(TOP)\ext\rbu\rbu.c $(SQLITE3C) \ - $(LDFLAGS) $(LTLINKOPTS) + $(LTLINK) $(NO_WARN) -DSQLITE_ENABLE_RBU -Fe$@ $(TOP)\ext\rbu\rbu.c $(SQLITE3C) \ + /link $(LDFLAGS) $(LTLINKOPTS) clean: del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL diff --git a/manifest b/manifest index 1354db7a40..199dfc584f 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Yet\sanother\schange\sto\sFTS5\strying\sto\sget\sit\sto\smerge\ssuccessfully\sinto\ssessions. -D 2016-01-14T14:33:36.733 +C Minor\sadjustments\sto\sthe\sMSVC\smakefile. +D 2016-01-14T18:01:16.348 F Makefile.in cfa1ac03c4b414992fd53f24d978b45b0c21de55 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 1dc36cfd3c047c9685e539257e158485f16ef035 +F Makefile.msc 2d8b2ad5a03315940bcb9e64145ab70850d66b4d F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 866588d1edf0ccb5b0d33896974338f97564f719 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f791fc7009d68941c60d7bf953bab19d86112133 -R 52083946c40dd4f44744cbc0b447540f -U drh -Z 9b36451b3b0b6d81cfd6f7c438e3b3aa +P 8dedff3b9ac3e6bf9c131fee19f7d26dc1ebd61f +R ed5fce327e310c7f92985b6ea8c3a0f4 +U mistachkin +Z a106ef292e4f8d6ed0328b1e83183a0f diff --git a/manifest.uuid b/manifest.uuid index 92616336df..754bc8aa98 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8dedff3b9ac3e6bf9c131fee19f7d26dc1ebd61f \ No newline at end of file +e2cba1bbfdcb24e35b2275e29071d8a4e4943417 \ No newline at end of file From 3349620e9eb892ae05a54c9141755adf9ec96a93 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jan 2016 19:32:46 +0000 Subject: [PATCH 196/232] Simplification to the ISO8610 parser in the imnplementation of date/time functions. FossilOrigin-Name: b9159f42a517a95ae52464c96431708c00b7bb36 --- manifest | 14 +++++------ manifest.uuid | 2 +- src/date.c | 70 +++++++++++++++++++++++++++++++-------------------- 3 files changed, 51 insertions(+), 35 deletions(-) diff --git a/manifest b/manifest index 199dfc584f..a9997b0834 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sadjustments\sto\sthe\sMSVC\smakefile. -D 2016-01-14T18:01:16.348 +C Simplification\sto\sthe\sISO8610\sparser\sin\sthe\simnplementation\sof\sdate/time\nfunctions. +D 2016-01-14T19:32:46.777 F Makefile.in cfa1ac03c4b414992fd53f24d978b45b0c21de55 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 2d8b2ad5a03315940bcb9e64145ab70850d66b4d @@ -288,7 +288,7 @@ F src/build.c 9d497ff4bf3c82cecb520436e0e9963785627583 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 -F src/date.c e4655393bb403fa310eef66cc4583d75d4d7fd93 +F src/date.c 997651e3ee6c2818fbf7fcdb7156cef9eb3ece20 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c fe55c489362d1429c364e98c877514f4455f45a6 @@ -1412,7 +1412,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8dedff3b9ac3e6bf9c131fee19f7d26dc1ebd61f -R ed5fce327e310c7f92985b6ea8c3a0f4 -U mistachkin -Z a106ef292e4f8d6ed0328b1e83183a0f +P e2cba1bbfdcb24e35b2275e29071d8a4e4943417 +R 79fbdde13a17c7cb82657d609276debb +U drh +Z 2e5da468d29690cad1fa7e36751b6984 diff --git a/manifest.uuid b/manifest.uuid index 754bc8aa98..7e5be39175 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e2cba1bbfdcb24e35b2275e29071d8a4e4943417 \ No newline at end of file +b9159f42a517a95ae52464c96431708c00b7bb36 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 3d7604ab45..d78e83cf57 100644 --- a/src/date.c +++ b/src/date.c @@ -70,34 +70,49 @@ struct DateTime { /* -** Convert zDate into one or more integers. Additional arguments -** come in groups of 5 as follows: +** Convert zDate into one or more integers according to the conversion +** specifier zFormat. ** -** N number of digits in the integer -** min minimum allowed value of the integer -** max maximum allowed value of the integer -** nextC first character after the integer -** pVal where to write the integers value. +** zFormat[] contains 4 characters for each integer converted, except for +** the last integer which is specified by three characters. The meaning +** of a four-character format specifiers ABCD is: +** +** A: number of digits to convert. Always "2" or "4". +** B: minimum value. Always "0" or "1". +** C: maximum value, decoded as: +** a: 12 +** b: 14 +** c: 24 +** d: 31 +** e: 59 +** f: 9999 +** D: the separator character, or \000 to indicate this is the +** last number to convert. +** +** Example: To translate an ISO-8601 date YYYY-MM-DD, the format would +** be "40f-21a-20c". The "40f-" indicates the 4-digit year followed by "-". +** The "21a-" indicates the 2-digit month followed by "-". The "20c" indicates +** the 2-digit day which is the last integer in the set. ** -** Conversions continue until one with nextC==0 is encountered. ** The function returns the number of successful conversions. */ -static int getDigits(const char *zDate, ...){ +static int getDigits(const char *zDate, const char *zFormat, ...){ + /* The aMx[] array translates the 3rd character of each format + ** spec into a max size: a b c d e f */ + static const u16 aMx[] = { 12, 14, 24, 31, 59, 9999 }; va_list ap; - int val; - int N; - int min; - int max; - int nextC; - int *pVal; int cnt = 0; - va_start(ap, zDate); + char nextC; + va_start(ap, zFormat); do{ - N = va_arg(ap, int); - min = va_arg(ap, int); - max = va_arg(ap, int); - nextC = va_arg(ap, int); - pVal = va_arg(ap, int*); + char N = zFormat[0] - '0'; + char min = zFormat[1] - '0'; + int val = 0; + u16 max; + + assert( zFormat[2]>='a' && zFormat[2]<='f' ); + max = aMx[zFormat[2] - 'a']; + nextC = zFormat[3]; val = 0; while( N-- ){ if( !sqlite3Isdigit(*zDate) ){ @@ -106,12 +121,13 @@ static int getDigits(const char *zDate, ...){ val = val*10 + *zDate - '0'; zDate++; } - if( valmax || (nextC!=0 && nextC!=*zDate) ){ + if( val<(int)min || val>(int)max || (nextC!=0 && nextC!=*zDate) ){ goto end_getDigits; } - *pVal = val; + *va_arg(ap,int*) = val; zDate++; cnt++; + zFormat += 4; }while( nextC ); end_getDigits: va_end(ap); @@ -152,7 +168,7 @@ static int parseTimezone(const char *zDate, DateTime *p){ return c!=0; } zDate++; - if( getDigits(zDate, 2, 0, 14, ':', &nHr, 2, 0, 59, 0, &nMn)!=2 ){ + if( getDigits(zDate, "20b:20e", &nHr, &nMn)!=2 ){ return 1; } zDate += 5; @@ -173,13 +189,13 @@ zulu_time: static int parseHhMmSs(const char *zDate, DateTime *p){ int h, m, s; double ms = 0.0; - if( getDigits(zDate, 2, 0, 24, ':', &h, 2, 0, 59, 0, &m)!=2 ){ + if( getDigits(zDate, "20c:20e", &h, &m)!=2 ){ return 1; } zDate += 5; if( *zDate==':' ){ zDate++; - if( getDigits(zDate, 2, 0, 59, 0, &s)!=1 ){ + if( getDigits(zDate, "20e", &s)!=1 ){ return 1; } zDate += 2; @@ -267,7 +283,7 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){ }else{ neg = 0; } - if( getDigits(zDate,4,0,9999,'-',&Y,2,1,12,'-',&M,2,1,31,0,&D)!=3 ){ + if( getDigits(zDate, "40f-21a-21d", &Y, &M, &D)!=3 ){ return 1; } zDate += 10; From 2cfe049f40d61a17ababf57e0575a12f761a7841 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 14 Jan 2016 20:05:59 +0000 Subject: [PATCH 197/232] Add a test to verify that the fts3 and fts5 "unicode61" tokenizers are byte for byte compatible. FossilOrigin-Name: 8ec8314354edc9d6f7d1c8a6370fd984a552a52f --- Makefile.in | 1 + Makefile.msc | 1 + ext/fts5/fts5_tcl.c | 32 ++- ext/fts5/fts5_test_tok.c | 482 ++++++++++++++++++++++++++++++++++++ ext/fts5/test/fts5tok1.test | 115 +++++++++ ext/fts5/test/fts5tok2.test | 47 ++++ main.mk | 3 +- manifest | 23 +- manifest.uuid | 2 +- 9 files changed, 692 insertions(+), 14 deletions(-) create mode 100644 ext/fts5/fts5_test_tok.c create mode 100644 ext/fts5/test/fts5tok1.test create mode 100644 ext/fts5/test/fts5tok2.test diff --git a/Makefile.in b/Makefile.in index 2782e765f5..005d529594 100644 --- a/Makefile.in +++ b/Makefile.in @@ -418,6 +418,7 @@ TESTSRC += \ $(TOP)/ext/misc/fuzzer.c \ $(TOP)/ext/fts5/fts5_tcl.c \ $(TOP)/ext/fts5/fts5_test_mi.c \ + $(TOP)/ext/fts5/fts5_test_tok.c \ $(TOP)/ext/misc/ieee754.c \ $(TOP)/ext/misc/nextchar.c \ $(TOP)/ext/misc/percentile.c \ diff --git a/Makefile.msc b/Makefile.msc index 728154737b..c8275fde25 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1087,6 +1087,7 @@ TESTEXT = \ $(TOP)\ext\misc\fuzzer.c \ $(TOP)\ext\fts5\fts5_tcl.c \ $(TOP)\ext\fts5\fts5_test_mi.c \ + $(TOP)\ext\fts5\fts5_test_tok.c \ $(TOP)\ext\misc\ieee754.c \ $(TOP)\ext\misc\nextchar.c \ $(TOP)\ext\misc\percentile.c \ diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 4a331a59f4..e633f0ac58 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -23,7 +23,8 @@ #include extern int sqlite3_fts5_may_be_corrupt; -extern int sqlite3Fts5TestRegisterMatchinfo(sqlite3 *); +extern int sqlite3Fts5TestRegisterMatchinfo(sqlite3*); +extern int sqlite3Fts5TestRegisterTok(sqlite3*, fts5_api*); /************************************************************************* ** This is a copy of the first part of the SqliteDb structure in @@ -1078,6 +1079,32 @@ static int f5tRegisterMatchinfo( return TCL_OK; } +static int f5tRegisterTok( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + int rc; + sqlite3 *db = 0; + fts5_api *pApi = 0; + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB"); + return TCL_ERROR; + } + if( f5tDbAndApi(interp, objv[1], &db, &pApi) ){ + return TCL_ERROR; + } + + rc = sqlite3Fts5TestRegisterTok(db, pApi); + if( rc!=SQLITE_OK ){ + Tcl_SetResult(interp, (char*)sqlite3ErrName(rc), TCL_VOLATILE); + return TCL_ERROR; + } + return TCL_OK; +} + /* ** Entry point. */ @@ -1093,7 +1120,8 @@ int Fts5tcl_Init(Tcl_Interp *interp){ { "sqlite3_fts5_create_function", f5tCreateFunction, 0 }, { "sqlite3_fts5_may_be_corrupt", f5tMayBeCorrupt, 0 }, { "sqlite3_fts5_token_hash", f5tTokenHash, 0 }, - { "sqlite3_fts5_register_matchinfo", f5tRegisterMatchinfo, 0 } + { "sqlite3_fts5_register_matchinfo", f5tRegisterMatchinfo, 0 }, + { "sqlite3_fts5_register_fts5tokenize", f5tRegisterTok, 0 } }; int i; F5tTokenizerContext *pContext; diff --git a/ext/fts5/fts5_test_tok.c b/ext/fts5/fts5_test_tok.c new file mode 100644 index 0000000000..10af126c10 --- /dev/null +++ b/ext/fts5/fts5_test_tok.c @@ -0,0 +1,482 @@ +/* +** 2013 Apr 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains code for the "fts5tokenize" virtual table module. +** An fts5tokenize virtual table is created as follows: +** +** CREATE VIRTUAL TABLE USING fts5tokenize( +** , , ... +** ); +** +** The table created has the following schema: +** +** CREATE TABLE (input HIDDEN, token, start, end, position) +** +** When queried, the query must include a WHERE clause of type: +** +** input = +** +** The virtual table module tokenizes this , using the FTS3 +** tokenizer specified by the arguments to the CREATE VIRTUAL TABLE +** statement and returns one row for each token in the result. With +** fields set as follows: +** +** input: Always set to a copy of +** token: A token from the input. +** start: Byte offset of the token within the input . +** end: Byte offset of the byte immediately following the end of the +** token within the input string. +** pos: Token offset of token within input. +** +*/ +#if defined(SQLITE_TEST) && defined(SQLITE_ENABLE_FTS5) + +#include +#include +#include + +typedef struct Fts5tokTable Fts5tokTable; +typedef struct Fts5tokCursor Fts5tokCursor; +typedef struct Fts5tokRow Fts5tokRow; + +/* +** Virtual table structure. +*/ +struct Fts5tokTable { + sqlite3_vtab base; /* Base class used by SQLite core */ + fts5_tokenizer tok; /* Tokenizer functions */ + Fts5Tokenizer *pTok; /* Tokenizer instance */ +}; + +/* +** A container for a rows values. +*/ +struct Fts5tokRow { + char *zToken; + int iStart; + int iEnd; + int iPos; +}; + +/* +** Virtual table cursor structure. +*/ +struct Fts5tokCursor { + sqlite3_vtab_cursor base; /* Base class used by SQLite core */ + int iRowid; /* Current 'rowid' value */ + char *zInput; /* Input string */ + int nRow; /* Number of entries in aRow[] */ + Fts5tokRow *aRow; /* Array of rows to return */ +}; + +static void fts5tokDequote(char *z){ + char q = z[0]; + + if( q=='[' || q=='\'' || q=='"' || q=='`' ){ + int iIn = 1; + int iOut = 0; + if( q=='[' ) q = ']'; + + while( z[iIn] ){ + if( z[iIn]==q ){ + if( z[iIn+1]!=q ){ + /* Character iIn was the close quote. */ + iIn++; + break; + }else{ + /* Character iIn and iIn+1 form an escaped quote character. Skip + ** the input cursor past both and copy a single quote character + ** to the output buffer. */ + iIn += 2; + z[iOut++] = q; + } + }else{ + z[iOut++] = z[iIn++]; + } + } + + z[iOut] = '\0'; + } +} + +/* +** The second argument, argv[], is an array of pointers to nul-terminated +** strings. This function makes a copy of the array and strings into a +** single block of memory. It then dequotes any of the strings that appear +** to be quoted. +** +** If successful, output parameter *pazDequote is set to point at the +** array of dequoted strings and SQLITE_OK is returned. The caller is +** responsible for eventually calling sqlite3_free() to free the array +** in this case. Or, if an error occurs, an SQLite error code is returned. +** The final value of *pazDequote is undefined in this case. +*/ +static int fts5tokDequoteArray( + int argc, /* Number of elements in argv[] */ + const char * const *argv, /* Input array */ + char ***pazDequote /* Output array */ +){ + int rc = SQLITE_OK; /* Return code */ + if( argc==0 ){ + *pazDequote = 0; + }else{ + int i; + int nByte = 0; + char **azDequote; + + for(i=0; i0 ){ + zModule = azDequote[0]; + } + + rc = pApi->xFindTokenizer(pApi, zModule, &pTokCtx, &pTab->tok); + if( rc==SQLITE_OK ){ + const char **azArg = (const char **)&azDequote[1]; + int nArg = nDequote>0 ? nDequote-1 : 0; + rc = pTab->tok.xCreate(pTokCtx, azArg, nArg, &pTab->pTok); + } + } + + if( rc!=SQLITE_OK ){ + sqlite3_free(pTab); + pTab = 0; + } + + *ppVtab = (sqlite3_vtab*)pTab; + sqlite3_free(azDequote); + return rc; +} + +/* +** This function does the work for both the xDisconnect and xDestroy methods. +** These tables have no persistent representation of their own, so xDisconnect +** and xDestroy are identical operations. +*/ +static int fts5tokDisconnectMethod(sqlite3_vtab *pVtab){ + Fts5tokTable *pTab = (Fts5tokTable *)pVtab; + if( pTab->pTok ){ + pTab->tok.xDelete(pTab->pTok); + } + sqlite3_free(pTab); + return SQLITE_OK; +} + +/* +** xBestIndex - Analyze a WHERE and ORDER BY clause. +*/ +static int fts5tokBestIndexMethod( + sqlite3_vtab *pVTab, + sqlite3_index_info *pInfo +){ + int i; + + for(i=0; inConstraint; i++){ + if( pInfo->aConstraint[i].usable + && pInfo->aConstraint[i].iColumn==0 + && pInfo->aConstraint[i].op==SQLITE_INDEX_CONSTRAINT_EQ + ){ + pInfo->idxNum = 1; + pInfo->aConstraintUsage[i].argvIndex = 1; + pInfo->aConstraintUsage[i].omit = 1; + pInfo->estimatedCost = 1; + return SQLITE_OK; + } + } + + pInfo->idxNum = 0; + assert( pInfo->estimatedCost>1000000.0 ); + + return SQLITE_OK; +} + +/* +** xOpen - Open a cursor. +*/ +static int fts5tokOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){ + Fts5tokCursor *pCsr; + + pCsr = (Fts5tokCursor *)sqlite3_malloc(sizeof(Fts5tokCursor)); + if( pCsr==0 ){ + return SQLITE_NOMEM; + } + memset(pCsr, 0, sizeof(Fts5tokCursor)); + + *ppCsr = (sqlite3_vtab_cursor *)pCsr; + return SQLITE_OK; +} + +/* +** Reset the tokenizer cursor passed as the only argument. As if it had +** just been returned by fts5tokOpenMethod(). +*/ +static void fts5tokResetCursor(Fts5tokCursor *pCsr){ + int i; + for(i=0; inRow; i++){ + sqlite3_free(pCsr->aRow[i].zToken); + } + sqlite3_free(pCsr->zInput); + sqlite3_free(pCsr->aRow); + pCsr->zInput = 0; + pCsr->aRow = 0; + pCsr->nRow = 0; + pCsr->iRowid = 0; +} + +/* +** xClose - Close a cursor. +*/ +static int fts5tokCloseMethod(sqlite3_vtab_cursor *pCursor){ + Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor; + fts5tokResetCursor(pCsr); + sqlite3_free(pCsr); + return SQLITE_OK; +} + +/* +** xNext - Advance the cursor to the next row, if any. +*/ +static int fts5tokNextMethod(sqlite3_vtab_cursor *pCursor){ + Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor; + pCsr->iRowid++; + return SQLITE_OK; +} + +static int fts5tokCb( + void *pCtx, /* Pointer to Fts5tokCursor */ + int tflags, /* Mask of FTS5_TOKEN_* flags */ + const char *pToken, /* Pointer to buffer containing token */ + int nToken, /* Size of token in bytes */ + int iStart, /* Byte offset of token within input text */ + int iEnd /* Byte offset of end of token within input text */ +){ + Fts5tokCursor *pCsr = (Fts5tokCursor*)pCtx; + Fts5tokRow *pRow; + + if( (pCsr->nRow & (pCsr->nRow-1))==0 ){ + int nNew = pCsr->nRow ? pCsr->nRow*2 : 32; + Fts5tokRow *aNew; + aNew = (Fts5tokRow*)sqlite3_realloc(pCsr->aRow, nNew*sizeof(Fts5tokRow)); + if( aNew==0 ) return SQLITE_NOMEM; + memset(&aNew[pCsr->nRow], 0, sizeof(Fts5tokRow)*(nNew-pCsr->nRow)); + pCsr->aRow = aNew; + } + + pRow = &pCsr->aRow[pCsr->nRow]; + pRow->iStart = iStart; + pRow->iEnd = iEnd; + if( pCsr->nRow ){ + pRow->iPos = pRow[-1].iPos + ((tflags & FTS5_TOKEN_COLOCATED) ? 0 : 1); + } + pRow->zToken = sqlite3_malloc(nToken+1); + if( pRow->zToken==0 ) return SQLITE_NOMEM; + memcpy(pRow->zToken, pToken, nToken); + pRow->zToken[nToken] = 0; + pCsr->nRow++; + + return SQLITE_OK; +} + +/* +** xFilter - Initialize a cursor to point at the start of its data. +*/ +static int fts5tokFilterMethod( + sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */ + int idxNum, /* Strategy index */ + const char *idxStr, /* Unused */ + int nVal, /* Number of elements in apVal */ + sqlite3_value **apVal /* Arguments for the indexing scheme */ +){ + int rc = SQLITE_ERROR; + Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor; + Fts5tokTable *pTab = (Fts5tokTable *)(pCursor->pVtab); + + fts5tokResetCursor(pCsr); + if( idxNum==1 ){ + const char *zByte = (const char *)sqlite3_value_text(apVal[0]); + int nByte = sqlite3_value_bytes(apVal[0]); + pCsr->zInput = sqlite3_malloc(nByte+1); + if( pCsr->zInput==0 ){ + rc = SQLITE_NOMEM; + }else{ + memcpy(pCsr->zInput, zByte, nByte); + pCsr->zInput[nByte] = 0; + rc = pTab->tok.xTokenize( + pTab->pTok, (void*)pCsr, 0, zByte, nByte, fts5tokCb + ); + } + } + + if( rc!=SQLITE_OK ) return rc; + return fts5tokNextMethod(pCursor); +} + +/* +** xEof - Return true if the cursor is at EOF, or false otherwise. +*/ +static int fts5tokEofMethod(sqlite3_vtab_cursor *pCursor){ + Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor; + return (pCsr->iRowid>pCsr->nRow); +} + +/* +** xColumn - Return a column value. +*/ +static int fts5tokColumnMethod( + sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */ + sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */ + int iCol /* Index of column to read value from */ +){ + Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor; + Fts5tokRow *pRow = &pCsr->aRow[pCsr->iRowid-1]; + + /* CREATE TABLE x(input, token, start, end, position) */ + switch( iCol ){ + case 0: + sqlite3_result_text(pCtx, pCsr->zInput, -1, SQLITE_TRANSIENT); + break; + case 1: + sqlite3_result_text(pCtx, pRow->zToken, -1, SQLITE_TRANSIENT); + break; + case 2: + sqlite3_result_int(pCtx, pRow->iStart); + break; + case 3: + sqlite3_result_int(pCtx, pRow->iEnd); + break; + default: + assert( iCol==4 ); + sqlite3_result_int(pCtx, pRow->iPos); + break; + } + return SQLITE_OK; +} + +/* +** xRowid - Return the current rowid for the cursor. +*/ +static int fts5tokRowidMethod( + sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */ + sqlite_int64 *pRowid /* OUT: Rowid value */ +){ + Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor; + *pRowid = (sqlite3_int64)pCsr->iRowid; + return SQLITE_OK; +} + +/* +** Register the fts5tok module with database connection db. Return SQLITE_OK +** if successful or an error code if sqlite3_create_module() fails. +*/ +int sqlite3Fts5TestRegisterTok(sqlite3 *db, fts5_api *pApi){ + static const sqlite3_module fts5tok_module = { + 0, /* iVersion */ + fts5tokConnectMethod, /* xCreate */ + fts5tokConnectMethod, /* xConnect */ + fts5tokBestIndexMethod, /* xBestIndex */ + fts5tokDisconnectMethod, /* xDisconnect */ + fts5tokDisconnectMethod, /* xDestroy */ + fts5tokOpenMethod, /* xOpen */ + fts5tokCloseMethod, /* xClose */ + fts5tokFilterMethod, /* xFilter */ + fts5tokNextMethod, /* xNext */ + fts5tokEofMethod, /* xEof */ + fts5tokColumnMethod, /* xColumn */ + fts5tokRowidMethod, /* xRowid */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindFunction */ + 0, /* xRename */ + 0, /* xSavepoint */ + 0, /* xRelease */ + 0 /* xRollbackTo */ + }; + int rc; /* Return code */ + + rc = sqlite3_create_module(db, "fts5tokenize", &fts5tok_module, (void*)pApi); + return rc; +} + +#endif /* defined(SQLITE_TEST) && defined(SQLITE_ENABLE_FTS5) */ diff --git a/ext/fts5/test/fts5tok1.test b/ext/fts5/test/fts5tok1.test new file mode 100644 index 0000000000..6ba170062e --- /dev/null +++ b/ext/fts5/test/fts5tok1.test @@ -0,0 +1,115 @@ +# 2016 Jan 15 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# + +source [file join [file dirname [info script]] fts5_common.tcl] +ifcapable !fts5 { finish_test ; return } +set ::testprefix fts5tok1 + + +sqlite3_fts5_register_fts5tokenize db + +#------------------------------------------------------------------------- +# Simple test cases. Using the default (ascii) tokenizer. +# +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5tokenize(ascii); + CREATE VIRTUAL TABLE t2 USING fts5tokenize(); + CREATE VIRTUAL TABLE t3 USING fts5tokenize( + ascii, 'separators', 'xyz', tokenchars, '''' + ); +} + +foreach {tn tbl} {1 t1 2 t2 3 t3} { + do_execsql_test 1.$tn.1 "SELECT input, * FROM $tbl ('one two three')" { + {one two three} one 0 3 0 + {one two three} two 4 7 1 + {one two three} three 8 13 2 + } + + do_execsql_test 1.$tn.2 " + SELECT token FROM $tbl WHERE input = 'OnE tWo tHrEe' + " { + one two three + } +} + +do_execsql_test 1.4 { + SELECT token FROM t3 WHERE input = '1x2x3x' +} {1 2 3} + +do_execsql_test 1.5 { + SELECT token FROM t1 WHERE input = '1x2x3x' +} {1x2x3x} + +do_execsql_test 1.6 { + SELECT token FROM t3 WHERE input = '1''2x3x' +} {1'2 3} + +do_execsql_test 1.7 { + SELECT token FROM t3 WHERE input = '' +} {} + +do_execsql_test 1.8 { + SELECT token FROM t3 WHERE input = NULL +} {} + +do_execsql_test 1.9 { + SELECT input, * FROM t3 WHERE input = 123 +} {123 123 0 3 0} + +do_execsql_test 1.10 { + SELECT input, * FROM t1 WHERE input = 'a b c' AND token = 'b'; +} { + {a b c} b 2 3 1 +} + +do_execsql_test 1.11 { + SELECT input, * FROM t1 WHERE token = 'b' AND input = 'a b c'; +} { + {a b c} b 2 3 1 +} + +do_execsql_test 1.12 { + SELECT input, * FROM t1 WHERE input < 'b' AND input = 'a b c'; +} { + {a b c} a 0 1 0 + {a b c} b 2 3 1 + {a b c} c 4 5 2 +} + +do_execsql_test 1.13.1 { + CREATE TABLE c1(x); + INSERT INTO c1(x) VALUES('a b c'); + INSERT INTO c1(x) VALUES('d e f'); +} +do_execsql_test 1.13.2 { + SELECT c1.*, input, t1.* FROM c1, t1 WHERE input = x AND c1.rowid=t1.rowid; +} { + {a b c} {a b c} a 0 1 0 + {d e f} {d e f} e 2 3 1 +} + + +#------------------------------------------------------------------------- +# Error cases. +# +do_catchsql_test 2.0 { + CREATE VIRTUAL TABLE tX USING fts5tokenize(nosuchtokenizer); +} {1 {vtable constructor failed: tX}} + +do_catchsql_test 2.1 { + CREATE VIRTUAL TABLE t4 USING fts5tokenize; + SELECT * FROM t4; +} {1 {SQL logic error or missing database}} + + +finish_test diff --git a/ext/fts5/test/fts5tok2.test b/ext/fts5/test/fts5tok2.test new file mode 100644 index 0000000000..77c7e1ec8e --- /dev/null +++ b/ext/fts5/test/fts5tok2.test @@ -0,0 +1,47 @@ +# 2016 Jan 15 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# + +source [file join [file dirname [info script]] fts5_common.tcl] +ifcapable !fts5||!fts3 { finish_test ; return } +set ::testprefix fts5tok2 + +sqlite3_fts5_register_fts5tokenize db + +#------------------------------------------------------------------------- +# Simple test cases. Using the default (ascii) tokenizer. +# +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t5 USING fts5tokenize(unicode61); + CREATE VIRTUAL TABLE t3 USING fts3tokenize(unicode61); +} + +do_test 1.1 { + array unset -nocomplain A + + for {set i 1} {$i < 65536} {incr i} { + set input [format "abc%cxyz" $i] + set expect [execsql { + SELECT input, token, start, end FROM t3 WHERE input=$input + }] + + incr A([llength $expect]) + + set res [execsql { + SELECT input, token, start, end FROM t5($input) + }] + if {$res != $expect} {error "failed at i=$i"} + } +} {} + +do_test 1.1.nTokenChars=$A(4).nSeparators=$A(8) {} {} + +finish_test diff --git a/main.mk b/main.mk index e6ca1acbd6..7aaa58fffd 100644 --- a/main.mk +++ b/main.mk @@ -333,7 +333,8 @@ TESTSRC += \ $(TOP)/ext/misc/wholenumber.c \ $(TOP)/ext/misc/vfslog.c \ $(TOP)/ext/fts5/fts5_tcl.c \ - $(TOP)/ext/fts5/fts5_test_mi.c + $(TOP)/ext/fts5/fts5_test_mi.c \ + $(TOP)/ext/fts5/fts5_test_tok.c #TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c diff --git a/manifest b/manifest index a9997b0834..1c030127fd 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Simplification\sto\sthe\sISO8610\sparser\sin\sthe\simnplementation\sof\sdate/time\nfunctions. -D 2016-01-14T19:32:46.777 -F Makefile.in cfa1ac03c4b414992fd53f24d978b45b0c21de55 +C Add\sa\stest\sto\sverify\sthat\sthe\sfts3\sand\sfts5\s"unicode61"\stokenizers\sare\sbyte\sfor\sbyte\scompatible. +D 2016-01-14T20:05:59.293 +F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 2d8b2ad5a03315940bcb9e64145ab70850d66b4d +F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 866588d1edf0ccb5b0d33896974338f97564f719 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -106,8 +106,9 @@ F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 F ext/fts5/fts5_index.c aa798d3a839847fd351b3d0f49520f190e57c2e3 F ext/fts5/fts5_main.c 488ceecdb4400ecc6a3d3b2247cedef153955388 F ext/fts5/fts5_storage.c f7b2d330dd7b29a9f4da09f6d85879ca8c41b2e8 -F ext/fts5/fts5_tcl.c 18e9382d8cdad4c05b49559c68494968b9b4a4fb +F ext/fts5/fts5_tcl.c bcacc05dec0446e7b1a44d5d906057e677bd7ea4 F ext/fts5/fts5_test_mi.c 1ec66ffdf7632077fbd773b7a6df5153272ec070 +F ext/fts5/fts5_test_tok.c db08af63673c3a7d39f053b36fd6e065017706be F ext/fts5/fts5_tokenize.c 504984ac6993323247221eebe3cd55bead01b5f8 F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 @@ -174,6 +175,8 @@ F ext/fts5/test/fts5simple.test 2bc6451cbe887a9215f5b14ae307c70d850344c9 F ext/fts5/test/fts5simple2.test 843f1f7fe439ff32bf74f4fd6430632f9636ef3a F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 F ext/fts5/test/fts5synonym2.test d2d9099d9d105b55ea03fd52d61ae2847d534129 +F ext/fts5/test/fts5tok1.test beb894c6f3468f10a574302f69ebe4436b0287c7 +F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 F ext/fts5/test/fts5unicode.test fbef8d8a3b4b88470536cc57604a82ca52e51841 F ext/fts5/test/fts5unicode2.test c1dd890ba32b7609adba78e420faa847abe43b59 @@ -262,7 +265,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 20e46c09ac8732a74a9e2d55e8d90257d97eb844 +F main.mk 55f0940264e55540773214ee1f2dbba0bf359957 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1412,7 +1415,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e2cba1bbfdcb24e35b2275e29071d8a4e4943417 -R 79fbdde13a17c7cb82657d609276debb -U drh -Z 2e5da468d29690cad1fa7e36751b6984 +P b9159f42a517a95ae52464c96431708c00b7bb36 +R e09ac1cbb3100668573769c5e2d7569a +U dan +Z 6d6590c289b1d7ff01c17cc7ff7964e6 diff --git a/manifest.uuid b/manifest.uuid index 7e5be39175..98da96e742 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b9159f42a517a95ae52464c96431708c00b7bb36 \ No newline at end of file +8ec8314354edc9d6f7d1c8a6370fd984a552a52f \ No newline at end of file From 2d80151f324fc8b4ba93c96bfc7547ce62a8a80f Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Jan 2016 22:19:58 +0000 Subject: [PATCH 198/232] Combine the xFunc and xStep pointers of the FuncDef object into a single pointer xSFunc. FossilOrigin-Name: 0d1b3d7d3ca66cb0b97493f1aeade1703af3c9f4 --- manifest | 34 +++++++++++++++++----------------- manifest.uuid | 2 +- src/analyze.c | 9 +++------ src/attach.c | 6 ++---- src/callback.c | 10 +++++----- src/expr.c | 2 +- src/main.c | 27 +++++++++++++-------------- src/resolve.c | 2 +- src/sqliteInt.h | 21 ++++++++++----------- src/vdbe.c | 6 +++--- src/vdbeapi.c | 4 ++-- src/vdbemem.c | 2 +- src/vtab.c | 6 +++--- 13 files changed, 62 insertions(+), 69 deletions(-) diff --git a/manifest b/manifest index 1c030127fd..01c7dc6b20 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\sto\sverify\sthat\sthe\sfts3\sand\sfts5\s"unicode61"\stokenizers\sare\sbyte\sfor\sbyte\scompatible. -D 2016-01-14T20:05:59.293 +C Combine\sthe\sxFunc\sand\sxStep\spointers\sof\sthe\sFuncDef\sobject\sinto\sa\ssingle\npointer\sxSFunc. +D 2016-01-14T22:19:58.884 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -278,8 +278,8 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 9d649e46c780166e416fb11dbd23f8d49aab8267 -F src/analyze.c 977bd50c751bb939ef52917892e12bedbfcea7ce -F src/attach.c e944d0052b577703b9b83aac1638452ff42a8395 +F src/analyze.c 905d387f6f7e89866e1dc73e13b6e09172bee350 +F src/attach.c ec9f119ca7542b5364924aab84f214440f8ac9e5 F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf @@ -288,13 +288,13 @@ F src/btree.c 5d93e2477acb99d50a8b045f2e26a0be3d7751fe F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 9d497ff4bf3c82cecb520436e0e9963785627583 -F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 +F src/callback.c 29ae4faba226c7ebb9aee93016b5ce8a8f071261 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c 997651e3ee6c2818fbf7fcdb7156cef9eb3ece20 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c fe55c489362d1429c364e98c877514f4455f45a6 +F src/expr.c 9a1a4150864f002b633d12f170a4114c28bbe94d F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e18b3dff7d47c7bcac5ac4fc178a89b9fd322b44 F src/func.c ccaf46fa98f795673afbfab73dff7c18db88f3cd @@ -306,7 +306,7 @@ F src/insert.c 6b45cc86967da11aa024d034745f93f66d53f650 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b -F src/main.c 6d589f27980c4aec014ae9a081d611e7e5ebc115 +F src/main.c 6bcb3de6b4f02552d3df44f2ef73ff6b7ccf5322 F src/malloc.c 8f787669e79de26efc42272b5797bc00fff527c6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -339,14 +339,14 @@ F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f +F src/resolve.c 08dbe0292b24abc79b0c55ea97368e8a6bd235ec F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 5b0f2aa9f73ec7b65d1711d485471854d5bad23c F src/shell.c dcd7a83645ef2a58ee9c6d0ea4714d877d7835c4 F src/sqlite.h.in 214476a62012e578f42133a9a3b4f97a9aa421a3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h b8ccd34a919e4b6bab8c4164046330002aa9a27a +F src/sqliteInt.h 028d1f88501048b5258f7119032278a55c963512 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -406,16 +406,16 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 6572d00eefeaa0b14b325fdf3a409920ec3fee82 +F src/vdbe.c 4f3585480f61f96af3327e921baad223af0ce23e F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 -F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca +F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e F src/vdbeaux.c f2e6b4fae037db04323be8de7bcd266375746471 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 -F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 +F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 -F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806 +F src/vtab.c 320682cca733115b4cbe71320b5c5eeb1074ebde F src/vxworks.h 974e7d9a98f602d6310d563e1dc4e08f9fc48e47 F src/wal.c d21b99fd1458159d0b1ecdccc8ee6ada4fdc4c54 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c @@ -1415,7 +1415,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b9159f42a517a95ae52464c96431708c00b7bb36 -R e09ac1cbb3100668573769c5e2d7569a -U dan -Z 6d6590c289b1d7ff01c17cc7ff7964e6 +P 8ec8314354edc9d6f7d1c8a6370fd984a552a52f +R 470d19e0ca1a1fc910b5e91ee98341ee +U drh +Z f0946172c7ca453502410c246bc450d2 diff --git a/manifest.uuid b/manifest.uuid index 98da96e742..154ae8ed29 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ec8314354edc9d6f7d1c8a6370fd984a552a52f \ No newline at end of file +0d1b3d7d3ca66cb0b97493f1aeade1703af3c9f4 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 06918eb744..367dd698dd 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -478,8 +478,7 @@ static const FuncDef statInitFuncdef = { SQLITE_UTF8, /* funcFlags */ 0, /* pUserData */ 0, /* pNext */ - statInit, /* xFunc */ - 0, /* xStep */ + statInit, /* xSFunc */ 0, /* xFinalize */ "stat_init", /* zName */ 0, /* pHash */ @@ -779,8 +778,7 @@ static const FuncDef statPushFuncdef = { SQLITE_UTF8, /* funcFlags */ 0, /* pUserData */ 0, /* pNext */ - statPush, /* xFunc */ - 0, /* xStep */ + statPush, /* xSFunc */ 0, /* xFinalize */ "stat_push", /* zName */ 0, /* pHash */ @@ -926,8 +924,7 @@ static const FuncDef statGetFuncdef = { SQLITE_UTF8, /* funcFlags */ 0, /* pUserData */ 0, /* pNext */ - statGet, /* xFunc */ - 0, /* xStep */ + statGet, /* xSFunc */ 0, /* xFinalize */ "stat_get", /* zName */ 0, /* pHash */ diff --git a/src/attach.c b/src/attach.c index 2ab55e6ed6..2c47ed47ba 100644 --- a/src/attach.c +++ b/src/attach.c @@ -388,8 +388,7 @@ void sqlite3Detach(Parse *pParse, Expr *pDbname){ SQLITE_UTF8, /* funcFlags */ 0, /* pUserData */ 0, /* pNext */ - detachFunc, /* xFunc */ - 0, /* xStep */ + detachFunc, /* xSFunc */ 0, /* xFinalize */ "sqlite_detach", /* zName */ 0, /* pHash */ @@ -409,8 +408,7 @@ void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){ SQLITE_UTF8, /* funcFlags */ 0, /* pUserData */ 0, /* pNext */ - attachFunc, /* xFunc */ - 0, /* xStep */ + attachFunc, /* xSFunc */ 0, /* xFinalize */ "sqlite_attach", /* zName */ 0, /* pHash */ diff --git a/src/callback.c b/src/callback.c index cd213b4b28..2a9f5b802a 100644 --- a/src/callback.c +++ b/src/callback.c @@ -243,8 +243,8 @@ CollSeq *sqlite3FindCollSeq( ** 5: UTF16 byte order conversion required - argument count matches exactly ** 6: Perfect match: encoding and argument count match exactly. ** -** If nArg==(-2) then any function with a non-null xStep or xFunc is -** a perfect match and any function with both xStep and xFunc NULL is +** If nArg==(-2) then any function with a non-null xSFunc is +** a perfect match and any function with xSFunc NULL is ** a non-match. */ #define FUNC_PERFECT_MATCH 6 /* The score for a perfect match */ @@ -256,7 +256,7 @@ static int matchQuality( int match; /* nArg of -2 is a special case */ - if( nArg==(-2) ) return (p->xFunc==0 && p->xStep==0) ? 0 : FUNC_PERFECT_MATCH; + if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH; /* Wrong number of arguments means "no match" */ if( p->nArg!=nArg && p->nArg>=0 ) return 0; @@ -334,7 +334,7 @@ void sqlite3FuncDefInsert( ** no matching function previously existed. ** ** If nArg is -2, then the first valid function found is returned. A -** function is valid if either xFunc or xStep is non-zero. The nArg==(-2) +** function is valid if xSFunc is non-zero. The nArg==(-2) ** case is used to see if zName is a valid function name for some number ** of arguments. If nArg is -2, then createFlag must be 0. ** @@ -411,7 +411,7 @@ FuncDef *sqlite3FindFunction( sqlite3FuncDefInsert(&db->aFunc, pBest); } - if( pBest && (pBest->xStep || pBest->xFunc || createFlag) ){ + if( pBest && (pBest->xSFunc || createFlag) ){ return pBest; } return 0; diff --git a/src/expr.c b/src/expr.c index 3be3bf52db..b8cf3f7720 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2896,7 +2896,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ zId = pExpr->u.zToken; nId = sqlite3Strlen30(zId); pDef = sqlite3FindFunction(db, zId, nId, nFarg, enc, 0); - if( pDef==0 || pDef->xFunc==0 ){ + if( pDef==0 || pDef->xFinalize!=0 ){ sqlite3ErrorMsg(pParse, "unknown function: %.*s()", nId, zId); break; } diff --git a/src/main.c b/src/main.c index 2998f54c77..35c0607b47 100644 --- a/src/main.c +++ b/src/main.c @@ -1575,7 +1575,7 @@ int sqlite3CreateFunc( int nArg, int enc, void *pUserData, - void (*xFunc)(sqlite3_context*,int,sqlite3_value **), + void (*xSFunc)(sqlite3_context*,int,sqlite3_value **), void (*xStep)(sqlite3_context*,int,sqlite3_value **), void (*xFinal)(sqlite3_context*), FuncDestructor *pDestructor @@ -1586,9 +1586,9 @@ int sqlite3CreateFunc( assert( sqlite3_mutex_held(db->mutex) ); if( zFunctionName==0 || - (xFunc && (xFinal || xStep)) || - (!xFunc && (xFinal && !xStep)) || - (!xFunc && (!xFinal && xStep)) || + (xSFunc && (xFinal || xStep)) || + (!xSFunc && (xFinal && !xStep)) || + (!xSFunc && (!xFinal && xStep)) || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) || (255<(nName = sqlite3Strlen30( zFunctionName))) ){ return SQLITE_MISUSE_BKPT; @@ -1611,10 +1611,10 @@ int sqlite3CreateFunc( }else if( enc==SQLITE_ANY ){ int rc; rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags, - pUserData, xFunc, xStep, xFinal, pDestructor); + pUserData, xSFunc, xStep, xFinal, pDestructor); if( rc==SQLITE_OK ){ rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags, - pUserData, xFunc, xStep, xFinal, pDestructor); + pUserData, xSFunc, xStep, xFinal, pDestructor); } if( rc!=SQLITE_OK ){ return rc; @@ -1658,8 +1658,7 @@ int sqlite3CreateFunc( p->pDestructor = pDestructor; p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags; testcase( p->funcFlags & SQLITE_DETERMINISTIC ); - p->xFunc = xFunc; - p->xStep = xStep; + p->xSFunc = xSFunc ? xSFunc : xStep; p->xFinalize = xFinal; p->pUserData = pUserData; p->nArg = (u16)nArg; @@ -1675,11 +1674,11 @@ int sqlite3_create_function( int nArg, int enc, void *p, - void (*xFunc)(sqlite3_context*,int,sqlite3_value **), + void (*xSFunc)(sqlite3_context*,int,sqlite3_value **), void (*xStep)(sqlite3_context*,int,sqlite3_value **), void (*xFinal)(sqlite3_context*) ){ - return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep, + return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xSFunc, xStep, xFinal, 0); } @@ -1689,7 +1688,7 @@ int sqlite3_create_function_v2( int nArg, int enc, void *p, - void (*xFunc)(sqlite3_context*,int,sqlite3_value **), + void (*xSFunc)(sqlite3_context*,int,sqlite3_value **), void (*xStep)(sqlite3_context*,int,sqlite3_value **), void (*xFinal)(sqlite3_context*), void (*xDestroy)(void *) @@ -1712,7 +1711,7 @@ int sqlite3_create_function_v2( pArg->xDestroy = xDestroy; pArg->pUserData = p; } - rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, xFunc, xStep, xFinal, pArg); + rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, xSFunc, xStep, xFinal, pArg); if( pArg && pArg->nRef==0 ){ assert( rc!=SQLITE_OK ); xDestroy(p); @@ -1732,7 +1731,7 @@ int sqlite3_create_function16( int nArg, int eTextRep, void *p, - void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xSFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*) ){ @@ -1745,7 +1744,7 @@ int sqlite3_create_function16( sqlite3_mutex_enter(db->mutex); assert( !db->mallocFailed ); zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE); - rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal,0); + rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0); sqlite3DbFree(db, zFunc8); rc = sqlite3ApiExit(db, rc); sqlite3_mutex_leave(db->mutex); diff --git a/src/resolve.c b/src/resolve.c index bb6646256a..97cb6556ac 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -665,7 +665,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ wrong_num_args = 1; } }else{ - is_agg = pDef->xFunc==0; + is_agg = pDef->xFinalize!=0; if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){ ExprSetProperty(pExpr, EP_Unlikely|EP_Skip); if( n==2 ){ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index a4d4f65f3c..a70b0cfb36 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1363,9 +1363,8 @@ struct FuncDef { u16 funcFlags; /* Some combination of SQLITE_FUNC_* */ void *pUserData; /* User data parameter */ FuncDef *pNext; /* Next function with same name */ - void (*xFunc)(sqlite3_context*,int,sqlite3_value**); /* Regular function */ - void (*xStep)(sqlite3_context*,int,sqlite3_value**); /* Aggregate step */ - void (*xFinalize)(sqlite3_context*); /* Aggregate finalizer */ + void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */ + void (*xFinalize)(sqlite3_context*); /* Agg finalizer */ char *zName; /* SQL name of the function. */ FuncDef *pHash; /* Next with a different name but the same hash */ FuncDestructor *pDestructor; /* Reference counted destructor function */ @@ -1448,28 +1447,28 @@ struct FuncDestructor { */ #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ - SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} + SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0} #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \ {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ - SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} + SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0} #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ - SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} + SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0} #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ - SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} + SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0} #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ - pArg, 0, xFunc, 0, 0, #zName, 0, 0} + pArg, 0, xFunc, 0, #zName, 0, 0} #define LIKEFUNC(zName, nArg, arg, flags) \ {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ - (void *)arg, 0, likeFunc, 0, 0, #zName, 0, 0} + (void *)arg, 0, likeFunc, 0, #zName, 0, 0} #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \ - SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} + SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName,0,0} #define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \ {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \ - SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0} + SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName,0,0} /* ** All current savepoints are stored in a linked list starting at diff --git a/src/vdbe.c b/src/vdbe.c index 7eb4c0baeb..d4060cae96 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1662,8 +1662,8 @@ case OP_Function: { MemSetTypeFlag(pCtx->pOut, MEM_Null); pCtx->fErrorOrAux = 0; db->lastRowid = lastRowid; - (*pCtx->pFunc->xFunc)(pCtx, pCtx->argc, pCtx->argv); /* IMP: R-24505-23230 */ - lastRowid = db->lastRowid; /* Remember rowid changes made by xFunc */ + (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */ + lastRowid = db->lastRowid; /* Remember rowid changes made by xSFunc */ /* If the function returned an error, throw an exception */ if( pCtx->fErrorOrAux ){ @@ -5903,7 +5903,7 @@ case OP_AggStep: { pCtx->pOut = &t; pCtx->fErrorOrAux = 0; pCtx->skipFlag = 0; - (pCtx->pFunc->xStep)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */ + (pCtx->pFunc->xSFunc)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */ if( pCtx->fErrorOrAux ){ if( pCtx->isError ){ sqlite3VdbeError(p, "%s", sqlite3_value_text(&t)); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 33c6ba3b28..4bc912b940 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -779,7 +779,7 @@ static SQLITE_NOINLINE void *createAggContext(sqlite3_context *p, int nByte){ ** same context that was returned on prior calls. */ void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){ - assert( p && p->pFunc && p->pFunc->xStep ); + assert( p && p->pFunc && p->pFunc->xFinalize ); assert( sqlite3_mutex_held(p->pOut->db->mutex) ); testcase( nByte<0 ); if( (p->pMem->flags & MEM_Agg)==0 ){ @@ -870,7 +870,7 @@ failed: ** context. */ int sqlite3_aggregate_count(sqlite3_context *p){ - assert( p && p->pMem && p->pFunc && p->pFunc->xStep ); + assert( p && p->pMem && p->pFunc && p->pFunc->xFinalize ); return p->pMem->n; } #endif diff --git a/src/vdbemem.c b/src/vdbemem.c index fae69b18a4..0eeb59ef85 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1224,7 +1224,7 @@ static int valueFromFunction( memset(&ctx, 0, sizeof(ctx)); ctx.pOut = pVal; ctx.pFunc = pFunc; - pFunc->xFunc(&ctx, nVal, apVal); + pFunc->xSFunc(&ctx, nVal, apVal); if( ctx.isError ){ rc = ctx.isError; sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal)); diff --git a/src/vtab.c b/src/vtab.c index 6054df3d71..ea79cd8cef 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -1016,7 +1016,7 @@ FuncDef *sqlite3VtabOverloadFunction( Table *pTab; sqlite3_vtab *pVtab; sqlite3_module *pMod; - void (*xFunc)(sqlite3_context*,int,sqlite3_value**) = 0; + void (*xSFunc)(sqlite3_context*,int,sqlite3_value**) = 0; void *pArg = 0; FuncDef *pNew; int rc = 0; @@ -1044,7 +1044,7 @@ FuncDef *sqlite3VtabOverloadFunction( for(z=(unsigned char*)zLowerName; *z; z++){ *z = sqlite3UpperToLower[*z]; } - rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xFunc, &pArg); + rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xSFunc, &pArg); sqlite3DbFree(db, zLowerName); } if( rc==0 ){ @@ -1061,7 +1061,7 @@ FuncDef *sqlite3VtabOverloadFunction( *pNew = *pDef; pNew->zName = (char *)&pNew[1]; memcpy(pNew->zName, pDef->zName, sqlite3Strlen30(pDef->zName)+1); - pNew->xFunc = xFunc; + pNew->xSFunc = xSFunc; pNew->pUserData = pArg; pNew->funcFlags |= SQLITE_FUNC_EPHEM; return pNew; From 1e38927c12c854970033b51aef7c41906912a238 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jan 2016 05:39:55 +0000 Subject: [PATCH 199/232] Fix a couple C99-isms in FTS5 that cause compile errors on MSVC. FossilOrigin-Name: 584848d4396d7755027fab377c97e40fbcc90d21 --- ext/fts5/fts5_index.c | 6 ++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 2f5b3bdaae..d5ea972414 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -1875,13 +1875,15 @@ static void fts5SegIterNext( int iOff; int bNewTerm = 0; int nKeep = 0; + u8 *a; + int n; assert( pbNewTerm==0 || *pbNewTerm==0 ); assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE ); /* Search for the end of the position list within the current page. */ - u8 *a = pLeaf->p; - int n = pLeaf->szLeaf; + a = pLeaf->p; + n = pLeaf->szLeaf; ASSERT_SZLEAF_OK(pLeaf); iOff = pIter->iLeafOffset + pIter->nPos; diff --git a/manifest b/manifest index 01c7dc6b20..9643928154 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Combine\sthe\sxFunc\sand\sxStep\spointers\sof\sthe\sFuncDef\sobject\sinto\sa\ssingle\npointer\sxSFunc. -D 2016-01-14T22:19:58.884 +C Fix\sa\scouple\sC99-isms\sin\sFTS5\sthat\scause\scompile\serrors\son\sMSVC. +D 2016-01-15T05:39:55.053 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -103,7 +103,7 @@ F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c 9c243d04ac0ca997d2d2e2252891f2a10fbd7217 F ext/fts5/fts5_expr.c 510db45967ca359f64f2ba2c707ab57d740cad56 F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 -F ext/fts5/fts5_index.c aa798d3a839847fd351b3d0f49520f190e57c2e3 +F ext/fts5/fts5_index.c cd036089b22b0340fccef88a3ad62ac1016c7cbb F ext/fts5/fts5_main.c 488ceecdb4400ecc6a3d3b2247cedef153955388 F ext/fts5/fts5_storage.c f7b2d330dd7b29a9f4da09f6d85879ca8c41b2e8 F ext/fts5/fts5_tcl.c bcacc05dec0446e7b1a44d5d906057e677bd7ea4 @@ -1415,7 +1415,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8ec8314354edc9d6f7d1c8a6370fd984a552a52f -R 470d19e0ca1a1fc910b5e91ee98341ee -U drh -Z f0946172c7ca453502410c246bc450d2 +P 0d1b3d7d3ca66cb0b97493f1aeade1703af3c9f4 +R b460170dac8e7d7fa7ff80be818c5f70 +U mistachkin +Z 9c8571095ec15b56fdafaa6935514e64 diff --git a/manifest.uuid b/manifest.uuid index 154ae8ed29..b39e9f110d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0d1b3d7d3ca66cb0b97493f1aeade1703af3c9f4 \ No newline at end of file +584848d4396d7755027fab377c97e40fbcc90d21 \ No newline at end of file From 055f298ad49e107b9114017db4fb03e9b72cc7f9 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 15 Jan 2016 15:06:41 +0000 Subject: [PATCH 200/232] Work toward making the schema parsing logic simplier and more compact. FossilOrigin-Name: c52ca2c0662bb30ab34574f933429512655b19ff --- manifest | 20 ++++----- manifest.uuid | 2 +- src/btree.c | 119 +++++++++++++++++++++++++------------------------- src/build.c | 78 +++++++++++++++------------------ src/prepare.c | 58 +++++------------------- src/vdbe.c | 1 + 6 files changed, 115 insertions(+), 163 deletions(-) diff --git a/manifest b/manifest index 9643928154..21f3a58b93 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scouple\sC99-isms\sin\sFTS5\sthat\scause\scompile\serrors\son\sMSVC. -D 2016-01-15T05:39:55.053 +C Work\stoward\smaking\sthe\sschema\sparsing\slogic\ssimplier\sand\smore\scompact. +D 2016-01-15T15:06:41.166 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -284,10 +284,10 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c 5d93e2477acb99d50a8b045f2e26a0be3d7751fe +F src/btree.c d9c6b2e2df06314079aa582f12937401a62171a6 F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c 9d497ff4bf3c82cecb520436e0e9963785627583 +F src/build.c 2778ccdb327923b2eb6cea304e232efd0c85cbe1 F src/callback.c 29ae4faba226c7ebb9aee93016b5ce8a8f071261 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -336,7 +336,7 @@ F src/pcache.h 4d0ccaad264d360981ec5e6a2b596d6e85242545 F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051 F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c -F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 +F src/prepare.c 74855ddbdfad6a1c4a4d5c4b0913ebb01174ba19 F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 08dbe0292b24abc79b0c55ea97368e8a6bd235ec @@ -406,7 +406,7 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 4f3585480f61f96af3327e921baad223af0ce23e +F src/vdbe.c b90d9d38e5e0260c2eafa3cb4c2274d8ea94da27 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e @@ -1415,7 +1415,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0d1b3d7d3ca66cb0b97493f1aeade1703af3c9f4 -R b460170dac8e7d7fa7ff80be818c5f70 -U mistachkin -Z 9c8571095ec15b56fdafaa6935514e64 +P 584848d4396d7755027fab377c97e40fbcc90d21 +R d396ff3cd92323018eeceb835a86df32 +U drh +Z d625867287e0b3ea5f45a2d19f9bb7c8 diff --git a/manifest.uuid b/manifest.uuid index b39e9f110d..281520412b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -584848d4396d7755027fab377c97e40fbcc90d21 \ No newline at end of file +c52ca2c0662bb30ab34574f933429512655b19ff \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index b5a1ee3b2c..eb0808f1d9 100644 --- a/src/btree.c +++ b/src/btree.c @@ -8541,6 +8541,14 @@ static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){ return SQLITE_LOCKED_SHAREDCACHE; } + /* + ** It is illegal to drop the sqlite_master table on page 1. But again, + ** this error is caught long before reaching this point. + */ + if( NEVER(iTable<2) ){ + return SQLITE_CORRUPT_BKPT; + } + rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0); if( rc ) return rc; rc = sqlite3BtreeClearTable(p, iTable, 0); @@ -8551,76 +8559,67 @@ static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){ *piMoved = 0; - if( iTable>1 ){ #ifdef SQLITE_OMIT_AUTOVACUUM - freePage(pPage, &rc); - releasePage(pPage); + freePage(pPage, &rc); + releasePage(pPage); #else - if( pBt->autoVacuum ){ - Pgno maxRootPgno; - sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &maxRootPgno); + if( pBt->autoVacuum ){ + Pgno maxRootPgno; + sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &maxRootPgno); - if( iTable==maxRootPgno ){ - /* If the table being dropped is the table with the largest root-page - ** number in the database, put the root page on the free list. - */ - freePage(pPage, &rc); - releasePage(pPage); - if( rc!=SQLITE_OK ){ - return rc; - } - }else{ - /* The table being dropped does not have the largest root-page - ** number in the database. So move the page that does into the - ** gap left by the deleted root-page. - */ - MemPage *pMove; - releasePage(pPage); - rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0); - if( rc!=SQLITE_OK ){ - return rc; - } - rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0); - releasePage(pMove); - if( rc!=SQLITE_OK ){ - return rc; - } - pMove = 0; - rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0); - freePage(pMove, &rc); - releasePage(pMove); - if( rc!=SQLITE_OK ){ - return rc; - } - *piMoved = maxRootPgno; - } - - /* Set the new 'max-root-page' value in the database header. This - ** is the old value less one, less one more if that happens to - ** be a root-page number, less one again if that is the - ** PENDING_BYTE_PAGE. + if( iTable==maxRootPgno ){ + /* If the table being dropped is the table with the largest root-page + ** number in the database, put the root page on the free list. */ - maxRootPgno--; - while( maxRootPgno==PENDING_BYTE_PAGE(pBt) - || PTRMAP_ISPAGE(pBt, maxRootPgno) ){ - maxRootPgno--; - } - assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) ); - - rc = sqlite3BtreeUpdateMeta(p, 4, maxRootPgno); - }else{ freePage(pPage, &rc); releasePage(pPage); + if( rc!=SQLITE_OK ){ + return rc; + } + }else{ + /* The table being dropped does not have the largest root-page + ** number in the database. So move the page that does into the + ** gap left by the deleted root-page. + */ + MemPage *pMove; + releasePage(pPage); + rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0); + if( rc!=SQLITE_OK ){ + return rc; + } + rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0); + releasePage(pMove); + if( rc!=SQLITE_OK ){ + return rc; + } + pMove = 0; + rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0); + freePage(pMove, &rc); + releasePage(pMove); + if( rc!=SQLITE_OK ){ + return rc; + } + *piMoved = maxRootPgno; } -#endif - }else{ - /* If sqlite3BtreeDropTable was called on page 1. - ** This really never should happen except in a corrupt - ** database. + + /* Set the new 'max-root-page' value in the database header. This + ** is the old value less one, less one more if that happens to + ** be a root-page number, less one again if that is the + ** PENDING_BYTE_PAGE. */ - zeroPage(pPage, PTF_INTKEY|PTF_LEAF ); + maxRootPgno--; + while( maxRootPgno==PENDING_BYTE_PAGE(pBt) + || PTRMAP_ISPAGE(pBt, maxRootPgno) ){ + maxRootPgno--; + } + assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) ); + + rc = sqlite3BtreeUpdateMeta(p, 4, maxRootPgno); + }else{ + freePage(pPage, &rc); releasePage(pPage); } +#endif return rc; } int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){ diff --git a/src/build.c b/src/build.c index 6aac454172..7bc7fc898b 100644 --- a/src/build.c +++ b/src/build.c @@ -758,7 +758,8 @@ int sqlite3TwoPartName( int iDb; /* Database holding the object */ sqlite3 *db = pParse->db; - if( ALWAYS(pName2!=0) && pName2->n>0 ){ + assert( pName2!=0 ); + if( pName2->n>0 ){ if( db->init.busy ) { sqlite3ErrorMsg(pParse, "corrupt database"); return -1; @@ -847,62 +848,46 @@ void sqlite3StartTable( int iDb; /* Database number to create the table in */ Token *pName; /* Unqualified name of the table to create */ - /* The table or view name to create is passed to this routine via tokens - ** pName1 and pName2. If the table name was fully qualified, for example: - ** - ** CREATE TABLE xxx.yyy (...); - ** - ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if - ** the table name is not fully qualified, i.e.: - ** - ** CREATE TABLE yyy(...); - ** - ** Then pName1 is set to "yyy" and pName2 is "". - ** - ** The call below sets the pName pointer to point at the token (pName1 or - ** pName2) that stores the unqualified table name. The variable iDb is - ** set to the index of the database that the table or view is to be - ** created in. - */ - iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName); - if( iDb<0 ) return; - if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){ - /* If creating a temp table, the name may not be qualified. Unless - ** the database name is "temp" anyway. */ - sqlite3ErrorMsg(pParse, "temporary table name must be unqualified"); - return; + if( db->init.busy && db->init.newTnum==1 ){ + /* Special case: Parsing the sqlite_master or sqlite_temp_master schema */ + iDb = db->init.iDb; + zName = sqlite3DbStrDup(db, SCHEMA_TABLE(iDb)); + pName = pName1; + }else{ + /* The common case */ + iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName); + if( iDb<0 ) return; + if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){ + /* If creating a temp table, the name may not be qualified. Unless + ** the database name is "temp" anyway. */ + sqlite3ErrorMsg(pParse, "temporary table name must be unqualified"); + return; + } + if( !OMIT_TEMPDB && isTemp ) iDb = 1; + zName = sqlite3NameFromToken(db, pName); } - if( !OMIT_TEMPDB && isTemp ) iDb = 1; - pParse->sNameToken = *pName; - zName = sqlite3NameFromToken(db, pName); if( zName==0 ) return; if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto begin_table_error; } if( db->init.iDb==1 ) isTemp = 1; #ifndef SQLITE_OMIT_AUTHORIZATION - assert( (isTemp & 1)==isTemp ); + assert( isTemp==0 || isTemp==1 ); + assert( isView==0 || isView==1 ); { - int code; + static const u8 aCode[] = { + SQLITE_CREATE_TABLE, + SQLITE_CREATE_TEMP_TABLE, + SQLITE_CREATE_VIEW, + SQLITE_CREATE_TEMP_VIEW + }; char *zDb = db->aDb[iDb].zName; if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){ goto begin_table_error; } - if( isView ){ - if( !OMIT_TEMPDB && isTemp ){ - code = SQLITE_CREATE_TEMP_VIEW; - }else{ - code = SQLITE_CREATE_VIEW; - } - }else{ - if( !OMIT_TEMPDB && isTemp ){ - code = SQLITE_CREATE_TEMP_TABLE; - }else{ - code = SQLITE_CREATE_TABLE; - } - } - if( !isVirtual && sqlite3AuthCheck(pParse, code, zName, 0, zDb) ){ + if( !isVirtual && sqlite3AuthCheck(pParse, (int)aCode[isTemp+2*isView], + zName, 0, zDb) ){ goto begin_table_error; } } @@ -1864,9 +1849,13 @@ void sqlite3EndTable( ** So do not write to the disk again. Extract the root page number ** for the table from the db->init.newTnum field. (The page number ** should have been put there by the sqliteOpenCb routine.) + ** + ** If the root page number is 1, that means this is the sqlite_master + ** table itself. So mark it read-only. */ if( db->init.busy ){ p->tnum = db->init.newTnum; + if( p->tnum==1 ) p->tabFlags |= TF_Readonly; } /* Special processing for WITHOUT ROWID Tables */ @@ -2319,6 +2308,7 @@ void sqlite3RootPageMoved(sqlite3 *db, int iDb, int iFrom, int iTo){ static void destroyRootPage(Parse *pParse, int iTable, int iDb){ Vdbe *v = sqlite3GetVdbe(pParse); int r1 = sqlite3GetTempReg(pParse); + assert( iTable>1 ); sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb); sqlite3MayAbort(pParse); #ifndef SQLITE_OMIT_AUTOVACUUM diff --git a/src/prepare.c b/src/prepare.c index 5d1ae00d13..acc70dd2d5 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -137,61 +137,27 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ #ifndef SQLITE_OMIT_DEPRECATED int size; #endif - Table *pTab; Db *pDb; char const *azArg[4]; int meta[5]; InitData initData; - char const *zMasterSchema; - char const *zMasterName; + const char *zMasterName; int openedTransaction = 0; - /* - ** The master database table has a structure like this - */ - static const char master_schema[] = - "CREATE TABLE sqlite_master(\n" - " type text,\n" - " name text,\n" - " tbl_name text,\n" - " rootpage integer,\n" - " sql text\n" - ")" - ; -#ifndef SQLITE_OMIT_TEMPDB - static const char temp_master_schema[] = - "CREATE TEMP TABLE sqlite_temp_master(\n" - " type text,\n" - " name text,\n" - " tbl_name text,\n" - " rootpage integer,\n" - " sql text\n" - ")" - ; -#else - #define temp_master_schema 0 -#endif - assert( iDb>=0 && iDbnDb ); assert( db->aDb[iDb].pSchema ); assert( sqlite3_mutex_held(db->mutex) ); assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) ); - /* zMasterSchema and zInitScript are set to point at the master schema - ** and initialisation script appropriate for the database being - ** initialized. zMasterName is the name of the master table. - */ - if( !OMIT_TEMPDB && iDb==1 ){ - zMasterSchema = temp_master_schema; - }else{ - zMasterSchema = master_schema; - } - zMasterName = SCHEMA_TABLE(iDb); - - /* Construct the schema tables. */ - azArg[0] = zMasterName; + /* Construct the in-memory representation schema tables (sqlite_master or + ** sqlite_temp_master) by invoking the parser directly. The appropriate + ** table name will be inserted automatically by the parser so we can just + ** use the abbreviation "x" here. The parser will also automatically tag + ** the schema table as read-only. */ + azArg[0] = zMasterName = SCHEMA_TABLE(iDb); azArg[1] = "1"; - azArg[2] = zMasterSchema; + azArg[2] = "CREATE TABLE x(type text,name text,tbl_name text," + "rootpage integer,sql text)"; azArg[3] = 0; initData.db = db; initData.iDb = iDb; @@ -202,10 +168,6 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ rc = initData.rc; goto error_out; } - pTab = sqlite3FindTable(db, zMasterName, db->aDb[iDb].zName); - if( ALWAYS(pTab) ){ - pTab->tabFlags |= TF_Readonly; - } /* Create a cursor to hold the database open */ @@ -324,7 +286,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ { char *zSql; zSql = sqlite3MPrintf(db, - "SELECT name, rootpage, sql FROM '%q'.%s ORDER BY rowid", + "SELECT name, rootpage, sql FROM \"%w\".%s ORDER BY rowid", db->aDb[iDb].zName, zMasterName); #ifndef SQLITE_OMIT_AUTHORIZATION { diff --git a/src/vdbe.c b/src/vdbe.c index d4060cae96..c6d5f7b0cc 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -5099,6 +5099,7 @@ case OP_Destroy: { /* out2 */ int iDb; assert( p->readOnly==0 ); + assert( pOp->p1>1 ); pOut = out2Prerelease(p, pOp); pOut->flags = MEM_Null; if( db->nVdbeRead > db->nVDestroy+1 ){ From 241873e55c491d7b65b3440b2f3d32d5ab9bbfae Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 15 Jan 2016 16:11:58 +0000 Subject: [PATCH 201/232] Remove unnecessary de-initialization of the Parse object. FossilOrigin-Name: 75ab30c5fcb51e556342dc3112f9acf122f79947 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/build.c | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 21f3a58b93..4bde0b8c82 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Work\stoward\smaking\sthe\sschema\sparsing\slogic\ssimplier\sand\smore\scompact. -D 2016-01-15T15:06:41.166 +C Remove\sunnecessary\sde-initialization\sof\sthe\sParse\sobject. +D 2016-01-15T16:11:58.808 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -287,7 +287,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c d9c6b2e2df06314079aa582f12937401a62171a6 F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c 2778ccdb327923b2eb6cea304e232efd0c85cbe1 +F src/build.c ae94a76279b988a62f82ae25344c68026d5fd47c F src/callback.c 29ae4faba226c7ebb9aee93016b5ce8a8f071261 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -1415,7 +1415,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 584848d4396d7755027fab377c97e40fbcc90d21 -R d396ff3cd92323018eeceb835a86df32 +P c52ca2c0662bb30ab34574f933429512655b19ff +R 18101cd5e40446f0b579af30aa8257e8 U drh -Z d625867287e0b3ea5f45a2d19f9bb7c8 +Z 9e527ccefb4d19cf49503262bc52d994 diff --git a/manifest.uuid b/manifest.uuid index 281520412b..f3f393f928 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c52ca2c0662bb30ab34574f933429512655b19ff \ No newline at end of file +75ab30c5fcb51e556342dc3112f9acf122f79947 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 7bc7fc898b..d783406761 100644 --- a/src/build.c +++ b/src/build.c @@ -228,15 +228,19 @@ void sqlite3FinishCoding(Parse *pParse){ if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1; sqlite3VdbeMakeReady(v, pParse); pParse->rc = SQLITE_DONE; - pParse->colNamesSet = 0; }else{ pParse->rc = SQLITE_ERROR; } + + /* We are done with this Parse object. There is no need to de-initialize it */ +#if 0 + pParse->colNamesSet = 0; pParse->nTab = 0; pParse->nMem = 0; pParse->nSet = 0; pParse->nVar = 0; DbMaskZero(pParse->cookieMask); +#endif } /* From 25247435be528220e2a0e40e966c9b73c8918b3a Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 15 Jan 2016 19:54:47 +0000 Subject: [PATCH 202/232] Rationalize some code in fts5_storage.c. Add tests to cover recently added branches in fts5. FossilOrigin-Name: 3b72df405ac9b3a71144f45317d32e25f0084c4b --- ext/fts5/fts5Int.h | 4 +- ext/fts5/fts5_main.c | 18 ++--- ext/fts5/fts5_storage.c | 125 +++++++++++---------------------- ext/fts5/fts5_vocab.c | 12 +++- ext/fts5/test/fts5fault5.test | 31 +++++++- ext/fts5/test/fts5fault8.test | 12 +++- ext/fts5/test/fts5simple2.test | 26 ++++++- ext/fts5/test/fts5update.test | 93 ++++++++++++++++++++++++ ext/fts5/test/fts5vocab.test | 54 ++++++++++++++ main.mk | 3 +- manifest | 31 ++++---- manifest.uuid | 2 +- 12 files changed, 292 insertions(+), 119 deletions(-) create mode 100644 ext/fts5/test/fts5update.test diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 1daeefc09f..ee953c399c 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -586,7 +586,7 @@ int sqlite3Fts5StorageRename(Fts5Storage*, const char *zName); int sqlite3Fts5DropAll(Fts5Config*); int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **); -int sqlite3Fts5StorageDelete(Fts5Storage *p, i64); +int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**); int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*); int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64); @@ -606,8 +606,6 @@ int sqlite3Fts5StorageConfigValue( Fts5Storage *p, const char*, sqlite3_value*, int ); -int sqlite3Fts5StorageSpecialDelete(Fts5Storage *p, i64 iDel, sqlite3_value**); - int sqlite3Fts5StorageDeleteAll(Fts5Storage *p); int sqlite3Fts5StorageRebuild(Fts5Storage *p); int sqlite3Fts5StorageOptimize(Fts5Storage *p); diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index fec589efcb..95fb10baeb 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1405,7 +1405,7 @@ static int fts5SpecialDelete( int eType1 = sqlite3_value_type(apVal[1]); if( eType1==SQLITE_INTEGER ){ sqlite3_int64 iDel = sqlite3_value_int64(apVal[1]); - rc = sqlite3Fts5StorageSpecialDelete(pTab->pStorage, iDel, &apVal[2]); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, &apVal[2]); } return rc; } @@ -1512,7 +1512,7 @@ static int fts5UpdateMethod( /* Case 1: DELETE */ else if( nArg==1 ){ i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0); } /* Case 2: INSERT */ @@ -1522,7 +1522,7 @@ static int fts5UpdateMethod( && sqlite3_value_type(apVal[1])==SQLITE_INTEGER ){ i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); } fts5StorageInsert(&rc, pTab, apVal, pRowid); } @@ -1533,22 +1533,22 @@ static int fts5UpdateMethod( i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */ if( iOld!=iNew ){ if( eConflict==SQLITE_REPLACE ){ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0); if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); } fts5StorageInsert(&rc, pTab, apVal, pRowid); }else{ rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid); if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0); } if( rc==SQLITE_OK ){ rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *pRowid); } } }else{ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld); + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0); fts5StorageInsert(&rc, pTab, apVal, pRowid); } } @@ -1747,7 +1747,9 @@ static int fts5CacheInstArray(Fts5Cursor *pCsr){ const u8 *a; int n; rc = fts5CsrPoslist(pCsr, i, &a, &n); - sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]); + if( rc==SQLITE_OK ){ + sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]); + } } if( rc==SQLITE_OK ){ diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 4a1ce3a3d9..56383619d1 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -378,39 +378,52 @@ static int fts5StorageInsertCallback( ** delete-markers to the FTS index necessary to delete it. Do not actually ** remove the %_content row at this time though. */ -static int fts5StorageDeleteFromIndex(Fts5Storage *p, i64 iDel){ +static int fts5StorageDeleteFromIndex( + Fts5Storage *p, + i64 iDel, + sqlite3_value **apVal +){ Fts5Config *pConfig = p->pConfig; - sqlite3_stmt *pSeek; /* SELECT to read row iDel from %_data */ + sqlite3_stmt *pSeek = 0; /* SELECT to read row iDel from %_data */ int rc; /* Return code */ + int rc2; /* sqlite3_reset() return code */ + int iCol; + Fts5InsertCtx ctx; - rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP, &pSeek, 0); - if( rc==SQLITE_OK ){ - int rc2; + if( apVal==0 ){ + rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP, &pSeek, 0); + if( rc!=SQLITE_OK ) return rc; sqlite3_bind_int64(pSeek, 1, iDel); - if( sqlite3_step(pSeek)==SQLITE_ROW ){ - int iCol; - Fts5InsertCtx ctx; - ctx.pStorage = p; - ctx.iCol = -1; - rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel); - for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){ - if( pConfig->abUnindexed[iCol-1] ) continue; - ctx.szCol = 0; - rc = sqlite3Fts5Tokenize(pConfig, - FTS5_TOKENIZE_DOCUMENT, - (const char*)sqlite3_column_text(pSeek, iCol), - sqlite3_column_bytes(pSeek, iCol), - (void*)&ctx, - fts5StorageInsertCallback - ); - p->aTotalSize[iCol-1] -= (i64)ctx.szCol; - } - p->nTotalRow--; + if( sqlite3_step(pSeek)!=SQLITE_ROW ){ + return sqlite3_reset(pSeek); } - rc2 = sqlite3_reset(pSeek); - if( rc==SQLITE_OK ) rc = rc2; } + ctx.pStorage = p; + ctx.iCol = -1; + rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel); + for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){ + if( pConfig->abUnindexed[iCol-1]==0 ){ + const char *zText; + int nText; + if( pSeek ){ + zText = (const char*)sqlite3_column_text(pSeek, iCol); + nText = sqlite3_column_bytes(pSeek, iCol); + }else{ + zText = (const char*)sqlite3_value_text(apVal[iCol-1]); + nText = sqlite3_value_bytes(apVal[iCol-1]); + } + ctx.szCol = 0; + rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, + zText, nText, (void*)&ctx, fts5StorageInsertCallback + ); + p->aTotalSize[iCol-1] -= (i64)ctx.szCol; + } + } + p->nTotalRow--; + + rc2 = sqlite3_reset(pSeek); + if( rc==SQLITE_OK ) rc = rc2; return rc; } @@ -490,16 +503,17 @@ static int fts5StorageSaveTotals(Fts5Storage *p){ /* ** Remove a row from the FTS table. */ -int sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel){ +int sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel, sqlite3_value **apVal){ Fts5Config *pConfig = p->pConfig; int rc; sqlite3_stmt *pDel = 0; + assert( pConfig->eContent!=FTS5_CONTENT_NORMAL || apVal==0 ); rc = fts5StorageLoadTotals(p, 1); /* Delete the index records */ if( rc==SQLITE_OK ){ - rc = fts5StorageDeleteFromIndex(p, iDel); + rc = fts5StorageDeleteFromIndex(p, iDel, apVal); } /* Delete the %_docsize record */ @@ -532,61 +546,6 @@ int sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel){ return rc; } -int sqlite3Fts5StorageSpecialDelete( - Fts5Storage *p, - i64 iDel, - sqlite3_value **apVal -){ - Fts5Config *pConfig = p->pConfig; - int rc; - sqlite3_stmt *pDel = 0; - - assert( pConfig->eContent!=FTS5_CONTENT_NORMAL ); - rc = fts5StorageLoadTotals(p, 1); - - /* Delete the index records */ - if( rc==SQLITE_OK ){ - int iCol; - Fts5InsertCtx ctx; - ctx.pStorage = p; - ctx.iCol = -1; - - rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel); - for(iCol=0; rc==SQLITE_OK && iColnCol; iCol++){ - if( pConfig->abUnindexed[iCol] ) continue; - ctx.szCol = 0; - rc = sqlite3Fts5Tokenize(pConfig, - FTS5_TOKENIZE_DOCUMENT, - (const char*)sqlite3_value_text(apVal[iCol]), - sqlite3_value_bytes(apVal[iCol]), - (void*)&ctx, - fts5StorageInsertCallback - ); - p->aTotalSize[iCol] -= (i64)ctx.szCol; - } - p->nTotalRow--; - } - - /* Delete the %_docsize record */ - if( pConfig->bColumnsize ){ - if( rc==SQLITE_OK ){ - rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_DOCSIZE, &pDel, 0); - } - if( rc==SQLITE_OK ){ - sqlite3_bind_int64(pDel, 1, iDel); - sqlite3_step(pDel); - rc = sqlite3_reset(pDel); - } - } - - /* Write the averages record */ - if( rc==SQLITE_OK ){ - rc = fts5StorageSaveTotals(p); - } - - return rc; -} - /* ** Delete all entries in the FTS5 index. */ diff --git a/ext/fts5/fts5_vocab.c b/ext/fts5/fts5_vocab.c index 2ed10b7cdb..ddc5576c5d 100644 --- a/ext/fts5/fts5_vocab.c +++ b/ext/fts5/fts5_vocab.c @@ -427,6 +427,10 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ int ii = FTS5_POS2COLUMN(iPos); pCsr->aCnt[ii]++; if( iCol!=ii ){ + if( ii>=nCol ){ + rc = FTS5_CORRUPT; + break; + } pCsr->aDoc[ii]++; iCol = ii; } @@ -444,7 +448,11 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ if( rc==SQLITE_OK ){ while( 0==sqlite3Fts5PoslistNext64(buf.p, buf.n, &iOff,&iPos) ){ assert_nc( iPos>=0 && iPosaDoc[iPos]++; + if( iPos>=nCol ){ + rc = FTS5_CORRUPT; + break; + } + pCsr->aDoc[iPos]++; } } sqlite3Fts5BufferFree(&buf); @@ -472,7 +480,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ } } - if( pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){ + if( rc==SQLITE_OK && pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){ while( pCsr->aDoc[pCsr->iCol]==0 ) pCsr->iCol++; assert( pCsr->iColpConfig->nCol ); } diff --git a/ext/fts5/test/fts5fault5.test b/ext/fts5/test/fts5fault5.test index 41de5208b2..75b7d9af50 100644 --- a/ext/fts5/test/fts5fault5.test +++ b/ext/fts5/test/fts5fault5.test @@ -65,19 +65,26 @@ do_faultsim_test 2.2 -faults oom-t* -body { } #------------------------------------------------------------------------- -# OOM while scanning an fts5vocab table. +# OOM while scanning fts5vocab tables. # reset_db do_test 3.0 { execsql { CREATE VIRTUAL TABLE tt USING fts5(x); CREATE VIRTUAL TABLE tv USING fts5vocab(tt, 'row'); + + CREATE VIRTUAL TABLE tt2 USING fts5(x, detail=col); + CREATE VIRTUAL TABLE tv2 USING fts5vocab(tt2, 'col'); + INSERT INTO tt(tt, rank) VALUES('pgsz', 32); + INSERT INTO tt2(tt2, rank) VALUES('pgsz', 32); BEGIN; } + for {set i 0} {$i < 20} {incr i} { set str [string repeat "$i " 50] execsql { INSERT INTO tt VALUES($str) } + execsql { INSERT INTO tt2 VALUES($str) } } execsql COMMIT } {} @@ -98,6 +105,28 @@ do_faultsim_test 3.2 -faults oom-t* -body { faultsim_test_result {0 {1 10 11 12 13 14 15 16 17 18 19 2}} } +breakpoint +do_execsql_test 3.3.0 { + SELECT * FROM tv2; +} { + 0 x 1 {} 1 x 1 {} 10 x 1 {} 11 x 1 {} 12 x 1 {} 13 x 1 {} + 14 x 1 {} 15 x 1 {} 16 x 1 {} 17 x 1 {} 18 x 1 {} 19 x 1 {} + 2 x 1 {} 3 x 1 {} 4 x 1 {} 5 x 1 {} 6 x 1 {} 7 x 1 {} 8 x 1 {} + 9 x 1 {} +} +do_faultsim_test 3.3 -faults oom-t* -body { + db eval { + SELECT * FROM tv2; + } +} -test { + faultsim_test_result [list 0 [list \ + 0 x 1 {} 1 x 1 {} 10 x 1 {} 11 x 1 {} 12 x 1 {} 13 x 1 {} \ + 14 x 1 {} 15 x 1 {} 16 x 1 {} 17 x 1 {} 18 x 1 {} 19 x 1 {} \ + 2 x 1 {} 3 x 1 {} 4 x 1 {} 5 x 1 {} 6 x 1 {} 7 x 1 {} 8 x 1 {} \ + 9 x 1 {} + ]] +} + finish_test diff --git a/ext/fts5/test/fts5fault8.test b/ext/fts5/test/fts5fault8.test index 01a1876955..d93066c6c0 100644 --- a/ext/fts5/test/fts5fault8.test +++ b/ext/fts5/test/fts5fault8.test @@ -24,8 +24,6 @@ ifcapable !fts5 { foreach_detail_mode $testprefix { -if {[detail_is_none]==0} continue - fts5_aux_test_functions db do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); @@ -34,7 +32,7 @@ do_execsql_test 1.0 { INSERT INTO t1 VALUES(NULL, '1 2 1 2'); } -do_faultsim_test 1 -faults oom-t* -body { +do_faultsim_test 1 -faults oom-* -body { execsql { SELECT rowid, fts5_test_poslist(t1) FROM t1 WHERE t1 MATCH 'b OR 2' } @@ -43,6 +41,14 @@ do_faultsim_test 1 -faults oom-t* -body { {1 SQLITE_NOMEM} } +do_faultsim_test 2 -faults oom-* -body { + execsql { + INSERT INTO t1(t1) VALUES('integrity-check'); + } +} -test { + faultsim_test_result {0 {}} {1 SQLITE_NOMEM} +} + } finish_test diff --git a/ext/fts5/test/fts5simple2.test b/ext/fts5/test/fts5simple2.test index c61970e154..33b2a73ab9 100644 --- a/ext/fts5/test/fts5simple2.test +++ b/ext/fts5/test/fts5simple2.test @@ -267,8 +267,6 @@ do_execsql_test 14.1 { SELECT fts5_test_poslist(t1) FROM t1('b') ORDER BY rank; } {0.0.1} -} - #------------------------------------------------------------------------- # reset_db @@ -299,6 +297,30 @@ do_execsql_test 15.3.2 { do_test 15.4 { execsql { INSERT INTO t1(t1) VALUES('integrity-check') } } {} + +} + +#------------------------------------------------------------------------- +# +reset_db +do_execsql_test 16.0 { + CREATE VIRTUAL TABLE t2 USING fts5(x, detail=none); + BEGIN; + INSERT INTO t2(rowid, x) VALUES(1, 'a b c'); + INSERT INTO t2(rowid, x) VALUES(456, 'a b c'); + INSERT INTO t2(rowid, x) VALUES(1000, 'a b c'); + COMMIT; + UPDATE t2 SET x=x; +} + +do_execsql_test 16.1 { + INSERT INTO t2(t2) VALUES('integrity-check'); +} {} + +do_execsql_test 16.2 { + SELECT rowid FROM t2('b') ORDER BY rowid DESC +} {1000 456 1} + finish_test diff --git a/ext/fts5/test/fts5update.test b/ext/fts5/test/fts5update.test new file mode 100644 index 0000000000..9e7debe9da --- /dev/null +++ b/ext/fts5/test/fts5update.test @@ -0,0 +1,93 @@ +# 2016 Jan 16 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# This file implements regression tests for SQLite library. The +# focus of this script is testing the FTS5 module. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5update + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +set docs { + "eight zero iv eight 7" "ix one 8 one three ii one" + "1 9 9 three viii" "5 zero ii 6 nine ix 3" + "3 zero 5 2 seven nine" "two eight viii eight 1" + "4 six two 5 9 vii" "viii ii four 8 i i iv" + "vii 0 iv seven 7 viii" "five 1 nine vi seven" + "1 zero zero iii 1" "one one six 6 nine seven" + "one v 4 zero 4 iii ii" "2 3 eight six ix" + "six iv 7 three 5" "ix zero 0 8 ii 7 3" + "four six nine 2 vii 3" "five viii 5 8 0 7" +} + +foreach_detail_mode $::testprefix { + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); +} {} + +do_test 1.1 { + foreach {a b} $docs { + execsql {INSERT INTO t1 VALUES($a, $b)} + } +} {} + +proc update {iRowid iA iB} { + set a [lindex $::docs $iA] + set b [lindex $::docs $iB] + execsql { UPDATE t1 SET a=$a, b=$b WHERE rowid=$iRowid } +} + +set nDoc [llength $::docs] +foreach n {1 5 10 50 100} { + do_test 1.2.$n { + execsql BEGIN + for {set i 1} {$i <= 1000} {incr i} { + set iRowid [expr {int(rand() * ($nDoc/2)) + 1}] + set iA [expr {int(rand() * $nDoc)}] + set iB [expr {int(rand() * $nDoc)}] + update $iRowid $iA $iB + + if {($i % $n)==0} { + execsql { COMMIT; BEGIN } + } + + if {($i % $n)==100} { + execsql { INSERT INTO t1(t1) VALUES('integrity-check') } + } + } + execsql COMMIT + execsql { INSERT INTO t1(t1) VALUES('integrity-check') } + } {} +} + +do_execsql_test 1.3 { + UPDATE t1 SET a=a AND b=b; + INSERT INTO t1(t1) VALUES('integrity-check'); +} + +do_test 1.4 { + execsql { INSERT INTO t1(t1, rank) VALUES('pgsz', 32) } + for {set i 0} {$i < 50} {incr i} { + execsql { UPDATE t1 SET a=a AND b=b } + execsql { INSERT INTO t1(t1) VALUES('integrity-check') } + } +} {} + +} +finish_test + + diff --git a/ext/fts5/test/fts5vocab.test b/ext/fts5/test/fts5vocab.test index 823b2b2872..f7278dd5c1 100644 --- a/ext/fts5/test/fts5vocab.test +++ b/ext/fts5/test/fts5vocab.test @@ -57,6 +57,8 @@ proc row_to_col {L} { set ret } +if 1 { + do_execsql_test 1.1.1 { CREATE VIRTUAL TABLE t1 USING fts5(one, prefix=1, detail=%DETAIL%); CREATE VIRTUAL TABLE v1 USING fts5vocab(t1, 'row'); @@ -391,5 +393,57 @@ if {![detail_is_none]} { } +#------------------------------------------------------------------------- +# Test the fts5vocab tables response to a specific types of corruption: +# where the fts5 index contains hits for columns that do not exist. +# +do_execsql_test 8.0 { + CREATE VIRTUAL TABLE x1 USING fts5(a, b, c, detail=%DETAIL%); + INSERT INTO x1 VALUES('a b c', 'd e f', 'g h i'); + INSERT INTO x1 VALUES('g h i', 'a b c', 'd e f'); + INSERT INTO x1 VALUES('d e f', 'g h i', 'a b c'); + CREATE VIRTUAL TABLE x1_r USING fts5vocab(x1, row); + CREATE VIRTUAL TABLE x1_c USING fts5vocab(x1, col); +} + +set resr [star_from_row {a 3 3 b 3 3 c 3 3 d 3 3 e 3 3 f 3 3 g 3 3 h 3 3 i 3 3}] +set resc [star_from_col { + a a 1 1 a b 1 1 a c 1 1 b a 1 1 + b b 1 1 b c 1 1 c a 1 1 c b 1 1 + c c 1 1 d a 1 1 d b 1 1 d c 1 1 + e a 1 1 e b 1 1 e c 1 1 f a 1 1 + f b 1 1 f c 1 1 g a 1 1 g b 1 1 + g c 1 1 h a 1 1 h b 1 1 h c 1 1 + i a 1 1 i b 1 1 i c 1 1 +}] +if {[detail_is_none]} { set resc [row_to_col $resr] } + +do_execsql_test 8.1.1 { SELECT * FROM x1_r; } $resr +do_execsql_test 8.1.2 { SELECT * FROM x1_c } $resc + +do_execsql_test 8.2 { + PRAGMA writable_schema = 1; + UPDATE sqlite_master + SET sql = 'CREATE VIRTUAL TABLE x1 USING fts5(a, detail=%DETAIL%)' + WHERE name = 'x1'; +} +db close +sqlite3 db test.db +sqlite3_fts5_may_be_corrupt 1 + +do_execsql_test 8.2.1 { SELECT * FROM x1_r } $resr + +if {[detail_is_none]} { + do_execsql_test 8.2.2 { SELECT * FROM x1_c } $resc +} else { + do_catchsql_test 8.2.2 { + SELECT * FROM x1_c + } {1 {database disk image is malformed}} +} + +sqlite3_fts5_may_be_corrupt 0 + +} + finish_test diff --git a/main.mk b/main.mk index 7aaa58fffd..abf4fd2be7 100644 --- a/main.mk +++ b/main.mk @@ -334,7 +334,8 @@ TESTSRC += \ $(TOP)/ext/misc/vfslog.c \ $(TOP)/ext/fts5/fts5_tcl.c \ $(TOP)/ext/fts5/fts5_test_mi.c \ - $(TOP)/ext/fts5/fts5_test_tok.c + $(TOP)/ext/fts5/fts5_test_tok.c \ + $(FTS5_SRC) #TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c diff --git a/manifest b/manifest index 4bde0b8c82..10927de756 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunnecessary\sde-initialization\sof\sthe\sParse\sobject. -D 2016-01-15T16:11:58.808 +C Rationalize\ssome\scode\sin\sfts5_storage.c.\sAdd\stests\sto\scover\srecently\sadded\sbranches\sin\sfts5. +D 2016-01-15T19:54:47.454 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -97,22 +97,22 @@ F ext/fts3/unicode/mkunicode.tcl 95cf7ec186e48d4985e433ff8a1c89090a774252 F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h ff9c2782e8ed890b0de2f697a8d63971939e70c7 -F ext/fts5/fts5Int.h 6c5a332e6add01dd69166a252d1818fb75c42a08 +F ext/fts5/fts5Int.h 313e3276ac9e0245ee722ef803253857a68722b9 F ext/fts5/fts5_aux.c 2dafc3aee0c70d643140c77d8d70daffa51a9e9e F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 F ext/fts5/fts5_config.c 9c243d04ac0ca997d2d2e2252891f2a10fbd7217 F ext/fts5/fts5_expr.c 510db45967ca359f64f2ba2c707ab57d740cad56 F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 F ext/fts5/fts5_index.c cd036089b22b0340fccef88a3ad62ac1016c7cbb -F ext/fts5/fts5_main.c 488ceecdb4400ecc6a3d3b2247cedef153955388 -F ext/fts5/fts5_storage.c f7b2d330dd7b29a9f4da09f6d85879ca8c41b2e8 +F ext/fts5/fts5_main.c 1d116f5c44c6f06ec282d33dd6d041c8131b3d6a +F ext/fts5/fts5_storage.c fb2eaec3aa954b680d43096dc539f8270bd6390e F ext/fts5/fts5_tcl.c bcacc05dec0446e7b1a44d5d906057e677bd7ea4 F ext/fts5/fts5_test_mi.c 1ec66ffdf7632077fbd773b7a6df5153272ec070 F ext/fts5/fts5_test_tok.c db08af63673c3a7d39f053b36fd6e065017706be F ext/fts5/fts5_tokenize.c 504984ac6993323247221eebe3cd55bead01b5f8 F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 -F ext/fts5/fts5_vocab.c da64ecbd217625980a1721fbd588a1e4118a51b6 +F ext/fts5/fts5_vocab.c ee6df1a3be103414d7b7af833ae1885c7b83a9d0 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba F ext/fts5/test/fts5_common.tcl 393882afb225a21edf033043bbf936951e9198c1 @@ -149,10 +149,10 @@ F ext/fts5/test/fts5fault1.test 4b39c47ca3544615daa8a2f733b911fa08022c77 F ext/fts5/test/fts5fault2.test 28c36c843bb39ae855ba79827417ecc37f114341 F ext/fts5/test/fts5fault3.test d6e9577d4312e331a913c72931bf131704efc8f3 F ext/fts5/test/fts5fault4.test 4864f2b5c2c083440dbe85aff60897bc1aa04603 -F ext/fts5/test/fts5fault5.test f2b8645053d48982e8979749e93994c43011c118 +F ext/fts5/test/fts5fault5.test 10c13a783de3f42a21e3e53e123b62ed0c3a1618 F ext/fts5/test/fts5fault6.test 9682664d679643ac6736e90c225526cc84073cda F ext/fts5/test/fts5fault7.test 01be274bfc8d9bf22451a3bf5892e9399d044f1b -F ext/fts5/test/fts5fault8.test aeb4717b7b293678bc4d2f3c0159206a525375d9 +F ext/fts5/test/fts5fault8.test f2d8a2b673a5f72ca1fa0e85bdbfb2041ffd347d F ext/fts5/test/fts5full.test 6f6143af0c6700501d9fd597189dfab1555bb741 F ext/fts5/test/fts5hash.test 7cf4607b8657c383f0b520668a99971e95d8b139 F ext/fts5/test/fts5integrity.test 87db5d4e7da0ce04a1dcba5ba91658673c997a65 @@ -172,7 +172,7 @@ F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 F ext/fts5/test/fts5simple.test 2bc6451cbe887a9215f5b14ae307c70d850344c9 -F ext/fts5/test/fts5simple2.test 843f1f7fe439ff32bf74f4fd6430632f9636ef3a +F ext/fts5/test/fts5simple2.test 7b51f8d411e9a77fa4519fb09ba5a3afda75c94d F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 F ext/fts5/test/fts5synonym2.test d2d9099d9d105b55ea03fd52d61ae2847d534129 F ext/fts5/test/fts5tok1.test beb894c6f3468f10a574302f69ebe4436b0287c7 @@ -182,8 +182,9 @@ F ext/fts5/test/fts5unicode.test fbef8d8a3b4b88470536cc57604a82ca52e51841 F ext/fts5/test/fts5unicode2.test c1dd890ba32b7609adba78e420faa847abe43b59 F ext/fts5/test/fts5unicode3.test 35c3d02aa7acf7d43d8de3bfe32c15ba96e8928e F ext/fts5/test/fts5unindexed.test e9539d5b78c677315e7ed8ea911d4fd25437c680 +F ext/fts5/test/fts5update.test 6f0abb89556f0a638b982e010f4d8d1de373a61c F ext/fts5/test/fts5version.test 978f59541d8cef7e8591f8be2115ec5ccb863e2e -F ext/fts5/test/fts5vocab.test e4b12f238f113795615ba6343b63fb326d6a360e +F ext/fts5/test/fts5vocab.test 480d780aa6b699816c5066225fbd86f3a0239477 F ext/fts5/tool/fts5speed.tcl aaee41894b552df8fbf8616aad003b2ea9ba3221 F ext/fts5/tool/fts5txt2db.tcl c374c4c4797e8cdfadabdfaeeb5412dcd6686e84 F ext/fts5/tool/loadfts5.tcl 4cc2d6af43b58d4fac05bc4fdabd0e5862c3b2c1 @@ -265,7 +266,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 55f0940264e55540773214ee1f2dbba0bf359957 +F main.mk 7575015811ef75a2cfcbc6f09de161cc8236e8a5 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1415,7 +1416,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c52ca2c0662bb30ab34574f933429512655b19ff -R 18101cd5e40446f0b579af30aa8257e8 -U drh -Z 9e527ccefb4d19cf49503262bc52d994 +P 75ab30c5fcb51e556342dc3112f9acf122f79947 +R 374e508382342a2641c42b70ee61e09e +U dan +Z e6d3f908cc39d2673b189171ce4240a7 diff --git a/manifest.uuid b/manifest.uuid index f3f393f928..7756c1a36c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -75ab30c5fcb51e556342dc3112f9acf122f79947 \ No newline at end of file +3b72df405ac9b3a71144f45317d32e25f0084c4b \ No newline at end of file From 079d446dd2c9f9f83c4a77d23c539e1ae5d5d11a Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 15 Jan 2016 21:55:46 +0000 Subject: [PATCH 203/232] Remove an unnecessary memset(). FossilOrigin-Name: 689421a9f73ceeab9786840a2d6ee008124d1f25 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 10927de756..01160c68f8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rationalize\ssome\scode\sin\sfts5_storage.c.\sAdd\stests\sto\scover\srecently\sadded\sbranches\sin\sfts5. -D 2016-01-15T19:54:47.454 +C Remove\san\sunnecessary\smemset(). +D 2016-01-15T21:55:46.864 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -288,7 +288,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c d9c6b2e2df06314079aa582f12937401a62171a6 F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c ae94a76279b988a62f82ae25344c68026d5fd47c +F src/build.c a23d2012f06c7a7dbb33e15608df9fdef68326af F src/callback.c 29ae4faba226c7ebb9aee93016b5ce8a8f071261 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -1416,7 +1416,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 75ab30c5fcb51e556342dc3112f9acf122f79947 -R 374e508382342a2641c42b70ee61e09e -U dan -Z e6d3f908cc39d2673b189171ce4240a7 +P 3b72df405ac9b3a71144f45317d32e25f0084c4b +R 1b6fc5c53ba731472d7f7fb860ed6428 +U drh +Z edef52557fd12bf4085bbb78a4ba3a5f diff --git a/manifest.uuid b/manifest.uuid index 7756c1a36c..6fd8be9245 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3b72df405ac9b3a71144f45317d32e25f0084c4b \ No newline at end of file +689421a9f73ceeab9786840a2d6ee008124d1f25 \ No newline at end of file diff --git a/src/build.c b/src/build.c index d783406761..24f908b078 100644 --- a/src/build.c +++ b/src/build.c @@ -499,7 +499,6 @@ void sqlite3CollapseDatabaseArray(sqlite3 *db){ } j++; } - memset(&db->aDb[j], 0, (db->nDb-j)*sizeof(db->aDb[j])); db->nDb = j; if( db->nDb<=2 && db->aDb!=db->aDbStatic ){ memcpy(db->aDbStatic, db->aDb, 2*sizeof(db->aDb[0])); From 095fb474efec4919c103527e5b0fbe02458f5d2d Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 16 Jan 2016 03:16:19 +0000 Subject: [PATCH 204/232] Fix a potential use-after-free problem when compiling with SQLITE_HAS_CODEC. FossilOrigin-Name: 653ea15ad8e23b333e234eb5dde7b80134db2baf --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 01160c68f8..aecb1e9771 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunnecessary\smemset(). -D 2016-01-15T21:55:46.864 +C Fix\sa\spotential\suse-after-free\sproblem\swhen\scompiling\swith\sSQLITE_HAS_CODEC. +D 2016-01-16T03:16:19.772 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -307,7 +307,7 @@ F src/insert.c 6b45cc86967da11aa024d034745f93f66d53f650 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b -F src/main.c 6bcb3de6b4f02552d3df44f2ef73ff6b7ccf5322 +F src/main.c b686dabe9a7ece9121da87120d5c7bf402d77eb3 F src/malloc.c 8f787669e79de26efc42272b5797bc00fff527c6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -1416,7 +1416,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3b72df405ac9b3a71144f45317d32e25f0084c4b -R 1b6fc5c53ba731472d7f7fb860ed6428 +P 689421a9f73ceeab9786840a2d6ee008124d1f25 +R f13b5cb1e79c02d53b1455abc8833659 U drh -Z edef52557fd12bf4085bbb78a4ba3a5f +Z 5aa5fcf53f35b8097ee55e85c4bed5b9 diff --git a/manifest.uuid b/manifest.uuid index 6fd8be9245..a0ae1f7590 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -689421a9f73ceeab9786840a2d6ee008124d1f25 \ No newline at end of file +653ea15ad8e23b333e234eb5dde7b80134db2baf \ No newline at end of file diff --git a/src/main.c b/src/main.c index 35c0607b47..63a105c3f0 100644 --- a/src/main.c +++ b/src/main.c @@ -2969,7 +2969,6 @@ static int openDatabase( sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT); opendb_out: - sqlite3_free(zOpen); if( db ){ assert( db->mutex!=0 || isThreadsafe==0 || sqlite3GlobalConfig.bFullMutex==0 ); @@ -3006,6 +3005,7 @@ opendb_out: } } #endif + sqlite3_free(zOpen); return rc & 0xff; } From 9b34abee30744c01fcef6570c78859b54c1df256 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 16 Jan 2016 15:12:35 +0000 Subject: [PATCH 205/232] Use sqlite3VdbeAddOp4() rather than a separate sqlite3VdbeChangeP4() call, for a slightly smaller and faster binary. FossilOrigin-Name: a4258cd4613c55acacb5c7b61faa3de7eb0759d2 --- manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- src/analyze.c | 12 ++++++------ src/attach.c | 6 +++--- src/build.c | 2 +- src/insert.c | 6 +++--- src/trigger.c | 4 ++-- src/vdbeaux.c | 2 +- src/wherecode.c | 3 +-- 9 files changed, 30 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index aecb1e9771..fa6bddb8b1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spotential\suse-after-free\sproblem\swhen\scompiling\swith\sSQLITE_HAS_CODEC. -D 2016-01-16T03:16:19.772 +C Use\ssqlite3VdbeAddOp4()\srather\sthan\sa\sseparate\ssqlite3VdbeChangeP4()\scall,\sfor\na\sslightly\ssmaller\sand\sfaster\sbinary. +D 2016-01-16T15:12:35.739 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -279,8 +279,8 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 9d649e46c780166e416fb11dbd23f8d49aab8267 -F src/analyze.c 905d387f6f7e89866e1dc73e13b6e09172bee350 -F src/attach.c ec9f119ca7542b5364924aab84f214440f8ac9e5 +F src/analyze.c 0043d3e501f04297fed2bb50b488bc08d5c39f36 +F src/attach.c 07b3a34a1702dce92a7f1d3888c0c06222b63760 F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf @@ -288,7 +288,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c d9c6b2e2df06314079aa582f12937401a62171a6 F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c a23d2012f06c7a7dbb33e15608df9fdef68326af +F src/build.c 59783188d873daf92150cc1a1caad55496839e8f F src/callback.c 29ae4faba226c7ebb9aee93016b5ce8a8f071261 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -303,7 +303,7 @@ F src/global.c bd5a0af3f30b0c01be6db756c626cd3c33a3d260 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 6b45cc86967da11aa024d034745f93f66d53f650 +F src/insert.c a00e6d8a843dc22e2c136df04e6300c4528d9b9f F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b @@ -402,7 +402,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c bbfb74450643cb5372a43ad4f6cffd7e9dfcecb0 F src/tokenize.c 5606871a377f390af7040ec3c12e0d183512d785 F src/treeview.c 78842e90c1f71269e7a73a1d4221b6fe360bab66 -F src/trigger.c de3ed31ad3218a20d7d7e18bf1b3b734e78bda66 +F src/trigger.c 056e51182a3677434423e3be0c74e61b90b4a663 F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 @@ -411,7 +411,7 @@ F src/vdbe.c b90d9d38e5e0260c2eafa3cb4c2274d8ea94da27 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e -F src/vdbeaux.c f2e6b4fae037db04323be8de7bcd266375746471 +F src/vdbeaux.c 906c0350f316dd13a26d8a91865f1dd7f14dc19b F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 @@ -423,7 +423,7 @@ F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c bb69654f841ae7af0a20cc6fb8f0ac57901c31be F src/whereInt.h 78b6b4de94db84aecbdc07fe3e38f648eb391e9a -F src/wherecode.c dfbfe198e418b01f208b489e088edd230c91a4e7 +F src/wherecode.c 8dee26eb181ea9daa8b1a4d96f34c0860aaf99bd F src/whereexpr.c eebba8340c90de73b3d3bbe8c43b84559b8e6e2c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1416,7 +1416,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 689421a9f73ceeab9786840a2d6ee008124d1f25 -R f13b5cb1e79c02d53b1455abc8833659 +P 653ea15ad8e23b333e234eb5dde7b80134db2baf +R 2155f55389b348e9a35fea6f93c01bbe U drh -Z 5aa5fcf53f35b8097ee55e85c4bed5b9 +Z 32d5bf122f6c10496965338bc29a15a2 diff --git a/manifest.uuid b/manifest.uuid index a0ae1f7590..39ad2ac515 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -653ea15ad8e23b333e234eb5dde7b80134db2baf \ No newline at end of file +a4258cd4613c55acacb5c7b61faa3de7eb0759d2 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 367dd698dd..4d777fa9f5 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -940,8 +940,8 @@ static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){ #else UNUSED_PARAMETER( iParam ); #endif - sqlite3VdbeAddOp3(v, OP_Function0, 0, regStat4, regOut); - sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF); + sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4, regOut, + (char*)&statGetFuncdef, P4_FUNCDEF); sqlite3VdbeChangeP5(v, 1 + IsStat34); } @@ -1095,8 +1095,8 @@ static void analyzeOneTable( #endif sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1); sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2); - sqlite3VdbeAddOp3(v, OP_Function0, 0, regStat4+1, regStat4); - sqlite3VdbeChangeP4(v, -1, (char*)&statInitFuncdef, P4_FUNCDEF); + sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4+1, regStat4, + (char*)&statInitFuncdef, P4_FUNCDEF); sqlite3VdbeChangeP5(v, 2+IsStat34); /* Implementation of the following: @@ -1192,8 +1192,8 @@ static void analyzeOneTable( } #endif assert( regChng==(regStat4+1) ); - sqlite3VdbeAddOp3(v, OP_Function0, 1, regStat4, regTemp); - sqlite3VdbeChangeP4(v, -1, (char*)&statPushFuncdef, P4_FUNCDEF); + sqlite3VdbeAddOp4(v, OP_Function0, 1, regStat4, regTemp, + (char*)&statPushFuncdef, P4_FUNCDEF); sqlite3VdbeChangeP5(v, 2+IsStat34); sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v); diff --git a/src/attach.c b/src/attach.c index 2c47ed47ba..fd5cc7c76c 100644 --- a/src/attach.c +++ b/src/attach.c @@ -359,11 +359,11 @@ static void codeAttach( assert( v || db->mallocFailed ); if( v ){ - sqlite3VdbeAddOp3(v, OP_Function0, 0, regArgs+3-pFunc->nArg, regArgs+3); + sqlite3VdbeAddOp4(v, OP_Function0, 0, regArgs+3-pFunc->nArg, regArgs+3, + (char *)pFunc, P4_FUNCDEF); assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg ); sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg)); - sqlite3VdbeChangeP4(v, -1, (char *)pFunc, P4_FUNCDEF); - + /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this ** statement only). For DETACH, set it to false (expire all existing ** statements). diff --git a/src/build.c b/src/build.c index 24f908b078..f592bb131c 100644 --- a/src/build.c +++ b/src/build.c @@ -4115,7 +4115,7 @@ void sqlite3HaltConstraint( sqlite3MayAbort(pParse); } sqlite3VdbeAddOp4(v, OP_Halt, errCode, onError, 0, p4, p4type); - if( p5Errmsg ) sqlite3VdbeChangeP5(v, p5Errmsg); + sqlite3VdbeChangeP5(v, p5Errmsg); } /* diff --git a/src/insert.c b/src/insert.c index 3e4aac8f4d..8082bcb459 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1595,7 +1595,7 @@ void sqlite3CompleteInsertion( assert( pParse->nested==0 ); pik_flags |= OPFLAG_NCHANGE; } - if( pik_flags ) sqlite3VdbeChangeP5(v, pik_flags); + sqlite3VdbeChangeP5(v, pik_flags); } if( !HasRowid(pTab) ) return; regData = regNewData + 1; @@ -2011,9 +2011,9 @@ static int xferOptimization( assert( (pDest->tabFlags & TF_Autoincrement)==0 ); } sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData); - sqlite3VdbeAddOp3(v, OP_Insert, iDest, regData, regRowid); + sqlite3VdbeAddOp4(v, OP_Insert, iDest, regData, regRowid, + pDest->zName, 0); sqlite3VdbeChangeP5(v, OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND); - sqlite3VdbeChangeP4(v, -1, pDest->zName, 0); sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); VdbeCoverage(v); sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); diff --git a/src/trigger.c b/src/trigger.c index be490e923a..48d6772992 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -952,8 +952,8 @@ void sqlite3CodeRowTriggerDirect( if( pPrg ){ int bRecursive = (p->zName && 0==(pParse->db->flags&SQLITE_RecTriggers)); - sqlite3VdbeAddOp3(v, OP_Program, reg, ignoreJump, ++pParse->nMem); - sqlite3VdbeChangeP4(v, -1, (const char *)pPrg->pProgram, P4_SUBPROGRAM); + sqlite3VdbeAddOp4(v, OP_Program, reg, ignoreJump, ++pParse->nMem, + (const char *)pPrg->pProgram, P4_SUBPROGRAM); VdbeComment( (v, "Call: %s.%s", (p->zName?p->zName:"fkey"), onErrorText(orconf))); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 2f65d85777..758c85fd1c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -716,7 +716,7 @@ void sqlite3VdbeChangeP3(Vdbe *p, u32 addr, int val){ sqlite3VdbeGetOp(p,addr)->p3 = val; } void sqlite3VdbeChangeP5(Vdbe *p, u8 p5){ - sqlite3VdbeGetOp(p,-1)->p5 = p5; + if( !p->db->mallocFailed ) p->aOp[p->nOp-1].p5 = p5; } /* diff --git a/src/wherecode.c b/src/wherecode.c index bc72e0ac7d..9d53a20a67 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -327,8 +327,7 @@ static void codeApplyAffinity(Parse *pParse, int base, int n, char *zAff){ /* Code the OP_Affinity opcode if there is anything left to do. */ if( n>0 ){ - sqlite3VdbeAddOp2(v, OP_Affinity, base, n); - sqlite3VdbeChangeP4(v, -1, zAff, n); + sqlite3VdbeAddOp4(v, OP_Affinity, base, n, 0, zAff, n); sqlite3ExprCacheAffinityChange(pParse, base, n); } } From 8631402e6a53599344406d814962a1fab72fe474 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 16 Jan 2016 18:58:51 +0000 Subject: [PATCH 206/232] Add further tests for fts5. Fix some problems with detail=col mode and auxiliary functions. FossilOrigin-Name: de77d6026e8035c505a704e7b8cfe5af6579d35f --- ext/fts5/fts5_buffer.c | 13 +-- ext/fts5/fts5_config.c | 2 +- ext/fts5/fts5_expr.c | 73 ++++++++--------- ext/fts5/fts5_main.c | 44 +++++----- ext/fts5/fts5_tcl.c | 20 +++-- ext/fts5/test/fts5_common.tcl | 67 +++++++++++++++ ext/fts5/test/fts5config.test | 29 +++++++ ext/fts5/test/fts5fault4.test | 21 ----- ext/fts5/test/fts5fault9.test | 140 ++++++++++++++++++++++++++++++++ ext/fts5/test/fts5hash.test | 10 ++- ext/fts5/test/fts5synonym.test | 94 +++++++-------------- ext/fts5/test/fts5synonym2.test | 67 +++++---------- manifest | 35 ++++---- manifest.uuid | 2 +- 14 files changed, 392 insertions(+), 225 deletions(-) create mode 100644 ext/fts5/test/fts5fault9.test diff --git a/ext/fts5/fts5_buffer.c b/ext/fts5/fts5_buffer.c index 251a543c5a..8558687d8a 100644 --- a/ext/fts5/fts5_buffer.c +++ b/ext/fts5/fts5_buffer.c @@ -322,14 +322,17 @@ int sqlite3Fts5TermsetAdd( *pbPresent = 0; if( p ){ int i; - int hash; + int hash = 13; Fts5TermsetEntry *pEntry; - /* Calculate a hash value for this term */ - hash = 104 + iIdx; - for(i=0; i=0; i--){ + hash = (hash << 3) ^ hash ^ pTerm[i]; } + hash = (hash << 3) ^ hash ^ iIdx; hash = hash % ArraySize(p->apHash); for(pEntry=p->apHash[hash]; pEntry; pEntry=pEntry->pNext){ diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index d9778bca20..70b1229edb 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -278,7 +278,7 @@ static int fts5ConfigParseSpecial( p++; } - if( rc==SQLITE_OK && (nPre<=0 || nPre>=1000) ){ + if( nPre<=0 || nPre>=1000 ){ *pzErr = sqlite3_mprintf("prefix length out of range (max 999)"); rc = SQLITE_ERROR; break; diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 409fbd1d05..7a433b69a0 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -2396,7 +2396,7 @@ int sqlite3Fts5ExprPopulatePoslists( } return sqlite3Fts5Tokenize(pConfig, - FTS5_TOKENIZE_AUX, z, n, (void*)&sCtx, fts5ExprPopulatePoslistsCb + FTS5_TOKENIZE_DOCUMENT, z, n, (void*)&sCtx, fts5ExprPopulatePoslistsCb ); } @@ -2412,49 +2412,44 @@ static void fts5ExprClearPoslists(Fts5ExprNode *pNode){ } static int fts5ExprCheckPoslists(Fts5ExprNode *pNode, i64 iRowid){ - if( pNode ){ - pNode->iRowid = iRowid; - pNode->bEof = 0; - switch( pNode->eType ){ - case FTS5_TERM: - case FTS5_STRING: - return (pNode->pNear->apPhrase[0]->poslist.n>0); + pNode->iRowid = iRowid; + pNode->bEof = 0; + switch( pNode->eType ){ + case FTS5_TERM: + case FTS5_STRING: + return (pNode->pNear->apPhrase[0]->poslist.n>0); - case FTS5_AND: { - int i; - for(i=0; inChild; i++){ - if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid)==0 ){ - fts5ExprClearPoslists(pNode); - return 0; - } - } - break; - } - - case FTS5_OR: { - int i; - int bRet = 0; - for(i=0; inChild; i++){ - if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid) ){ - bRet = 1; - } - } - if( bRet==0 ){ - fts5ExprClearPoslists(pNode); - } - return bRet; - } - - default: { - assert( pNode->eType==FTS5_NOT ); - if( 0==fts5ExprCheckPoslists(pNode->apChild[0], iRowid) - || 0!=fts5ExprCheckPoslists(pNode->apChild[1], iRowid) - ){ + case FTS5_AND: { + int i; + for(i=0; inChild; i++){ + if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid)==0 ){ fts5ExprClearPoslists(pNode); return 0; } - break; } + break; + } + + case FTS5_OR: { + int i; + int bRet = 0; + for(i=0; inChild; i++){ + if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid) ){ + bRet = 1; + } + } + return bRet; + } + + default: { + assert( pNode->eType==FTS5_NOT ); + if( 0==fts5ExprCheckPoslists(pNode->apChild[0], iRowid) + || 0!=fts5ExprCheckPoslists(pNode->apChild[1], iRowid) + ){ + fts5ExprClearPoslists(pNode); + return 0; + } + break; } } return 1; diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 95fb10baeb..7447f9b5e1 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -844,33 +844,32 @@ static int fts5NextMethod(sqlite3_vtab_cursor *pCursor){ } -static sqlite3_stmt *fts5PrepareStatement( - int *pRc, +static int fts5PrepareStatement( + sqlite3_stmt **ppStmt, Fts5Config *pConfig, const char *zFmt, ... ){ sqlite3_stmt *pRet = 0; + int rc; + char *zSql; va_list ap; - va_start(ap, zFmt); - if( *pRc==SQLITE_OK ){ - int rc; - char *zSql = sqlite3_vmprintf(zFmt, ap); - if( zSql==0 ){ - rc = SQLITE_NOMEM; - }else{ - rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pRet, 0); - if( rc!=SQLITE_OK ){ - *pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db)); - } - sqlite3_free(zSql); + va_start(ap, zFmt); + zSql = sqlite3_vmprintf(zFmt, ap); + if( zSql==0 ){ + rc = SQLITE_NOMEM; + }else{ + rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pRet, 0); + if( rc!=SQLITE_OK ){ + *pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db)); } - *pRc = rc; + sqlite3_free(zSql); } va_end(ap); - return pRet; + *ppStmt = pRet; + return rc; } static int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){ @@ -878,7 +877,7 @@ static int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){ Fts5Sorter *pSorter; int nPhrase; int nByte; - int rc = SQLITE_OK; + int rc; const char *zRank = pCsr->zRank; const char *zRankArgs = pCsr->zRankArgs; @@ -896,7 +895,7 @@ static int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){ ** table, saving it creates a circular reference. ** ** If SQLite a built-in statement cache, this wouldn't be a problem. */ - pSorter->pStmt = fts5PrepareStatement(&rc, pConfig, + rc = fts5PrepareStatement(&pSorter->pStmt, pConfig, "SELECT rowid, rank FROM %Q.%Q ORDER BY %s(%s%s%s) %s", pConfig->zDb, pConfig->zName, zRank, pConfig->zName, (zRankArgs ? ", " : ""), @@ -2039,8 +2038,15 @@ static int fts5ApiPhraseFirstColumn( Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig; if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){ + Fts5Sorter *pSorter = pCsr->pSorter; int n; - rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n); + if( pSorter ){ + int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]); + n = pSorter->aIdx[iPhrase] - i1; + pIter->a = &pSorter->aPoslist[i1]; + }else{ + rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n); + } if( rc==SQLITE_OK ){ pIter->b = &pIter->a[n]; *piCol = 0; diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index e633f0ac58..72db65777f 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -447,10 +447,12 @@ static int xF5tApi( zColvar = Tcl_GetString(objv[3]); zOffvar = Tcl_GetString(objv[4]); - for(p->pApi->xPhraseFirst(p->pFts, iPhrase, &iter, &iCol, &iOff); - iCol>=0; - p->pApi->xPhraseNext(p->pFts, &iter, &iCol, &iOff) - ){ + rc = p->pApi->xPhraseFirst(p->pFts, iPhrase, &iter, &iCol, &iOff); + if( rc!=SQLITE_OK ){ + Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); + return TCL_ERROR; + } + for( ;iCol>=0; p->pApi->xPhraseNext(p->pFts, &iter, &iCol, &iOff) ){ Tcl_SetVar2Ex(interp, zColvar, 0, Tcl_NewIntObj(iCol), 0); Tcl_SetVar2Ex(interp, zOffvar, 0, Tcl_NewIntObj(iOff), 0); rc = Tcl_EvalObjEx(interp, pScript, 0); @@ -474,10 +476,12 @@ static int xF5tApi( if( Tcl_GetIntFromObj(interp, objv[2], &iPhrase) ) return TCL_ERROR; zColvar = Tcl_GetString(objv[3]); - for(p->pApi->xPhraseFirstColumn(p->pFts, iPhrase, &iter, &iCol); - iCol>=0; - p->pApi->xPhraseNextColumn(p->pFts, &iter, &iCol) - ){ + rc = p->pApi->xPhraseFirstColumn(p->pFts, iPhrase, &iter, &iCol); + if( rc!=SQLITE_OK ){ + Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); + return TCL_ERROR; + } + for( ; iCol>=0; p->pApi->xPhraseNextColumn(p->pFts, &iter, &iCol)){ Tcl_SetVar2Ex(interp, zColvar, 0, Tcl_NewIntObj(iCol), 0); rc = Tcl_EvalObjEx(interp, pScript, 0); if( rc==TCL_CONTINUE ) rc = TCL_OK; diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index 2c7fedcefe..e45355a6dd 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -510,6 +510,22 @@ proc fts5_poslist_data {expr tbl {order ASC} {aDictVar ""}} { set res } +proc fts5_collist_data {expr tbl {order ASC} {aDictVar ""}} { + set res [list] + + if {$aDictVar!=""} { + upvar $aDictVar aDict + set dict aDict + } else { + set dict "" + } + + foreach {rowid poslist collist} [fts5_query_data $expr $tbl $order $dict] { + lappend res $rowid $collist + } + set res +} + #------------------------------------------------------------------------- # @@ -561,3 +577,54 @@ proc nearset_rc {aCol args} { list } + +#------------------------------------------------------------------------- +# Code for a simple Tcl tokenizer that supports synonyms at query time. +# +proc tclnum_tokenize {mode tflags text} { + foreach {w iStart iEnd} [fts5_tokenize_split $text] { + sqlite3_fts5_token $w $iStart $iEnd + if {$tflags == $mode && [info exists ::tclnum_syn($w)]} { + foreach s $::tclnum_syn($w) { sqlite3_fts5_token -colo $s $iStart $iEnd } + } + } +} + +proc tclnum_create {args} { + set mode query + if {[llength $args]} { + set mode [lindex $args 0] + } + if {$mode != "query" && $mode != "document"} { error "bad mode: $mode" } + return [list tclnum_tokenize $mode] +} + +proc fts5_tclnum_register {db} { + foreach SYNDICT { + {zero 0} + {one 1 i} + {two 2 ii} + {three 3 iii} + {four 4 iv} + {five 5 v} + {six 6 vi} + {seven 7 vii} + {eight 8 viii} + {nine 9 ix} + + {a1 a2 a3 a4 a5 a6 a7 a8 a9} + {b1 b2 b3 b4 b5 b6 b7 b8 b9} + {c1 c2 c3 c4 c5 c6 c7 c8 c9} + } { + foreach s $SYNDICT { + set o [list] + foreach x $SYNDICT {if {$x!=$s} {lappend o $x}} + set ::tclnum_syn($s) $o + } + } + sqlite3_fts5_create_tokenizer db tclnum tclnum_create +} +# +# End of tokenizer code. +#------------------------------------------------------------------------- + diff --git a/ext/fts5/test/fts5config.test b/ext/fts5/test/fts5config.test index dcda2d42a6..223e504a65 100644 --- a/ext/fts5/test/fts5config.test +++ b/ext/fts5/test/fts5config.test @@ -44,6 +44,8 @@ foreach {tn opt} { 3 {prefix='$'} 4 {prefix='1,2,'} 5 {prefix=',1'} + 6 {prefix='1,2,3...'} + 7 {prefix='1,2,3xyz'} } { set res [list 1 {malformed prefix=... directive}] do_catchsql_test 2.$tn "CREATE VIRTUAL TABLE f1 USING fts5(x, $opt)" $res @@ -159,6 +161,8 @@ do_catchsql_test 8.1 { # 9.1.* 'pgsz' options. # 9.2.* 'automerge' options. # 9.3.* 'crisismerge' options. +# 9.4.* a non-existant option. +# 9.5.* 'hashsize' options. # do_execsql_test 9.0 { CREATE VIRTUAL TABLE abc USING fts5(a, b); @@ -203,6 +207,16 @@ do_catchsql_test 9.4.1 { INSERT INTO abc(abc, rank) VALUES('nosuchoption', 1); } {1 {SQL logic error or missing database}} +do_catchsql_test 9.5.1 { + INSERT INTO abc(abc, rank) VALUES('hashsize', 'not an integer'); +} {1 {SQL logic error or missing database}} +do_catchsql_test 9.5.2 { + INSERT INTO abc(abc, rank) VALUES('hashsize', -500000); +} {1 {SQL logic error or missing database}} +do_catchsql_test 9.5.3 { + INSERT INTO abc(abc, rank) VALUES('hashsize', 500000); +} {0 {}} + #------------------------------------------------------------------------- # Too many prefix indexes. Maximum allowed is 31. # @@ -214,5 +228,20 @@ foreach {tn spec} { do_catchsql_test 10.$tn $sql {1 {too many prefix indexes (max 31)}} } +#------------------------------------------------------------------------- +# errors in the detail= option. +# +foreach {tn opt} { + 1 {detail=x} + 2 {detail='x'} + 3 {detail='$'} + 4 {detail='1,2,'} + 5 {detail=',1'} + 6 {detail=''} +} { + set res [list 1 {malformed detail=... directive}] + do_catchsql_test 11.$tn "CREATE VIRTUAL TABLE f1 USING fts5(x, $opt)" $res +} + finish_test diff --git a/ext/fts5/test/fts5fault4.test b/ext/fts5/test/fts5fault4.test index 989a372d49..acc43ebfc6 100644 --- a/ext/fts5/test/fts5fault4.test +++ b/ext/fts5/test/fts5fault4.test @@ -40,27 +40,6 @@ do_faultsim_test 1 -faults oom-* -prep { faultsim_test_result [list 0 {}] } -#------------------------------------------------------------------------- -# An OOM within an "ORDER BY rank" query. -# -db func rnddoc fts5_rnddoc -do_execsql_test 2.0 { - CREATE VIRTUAL TABLE xx USING fts5(x); - INSERT INTO xx VALUES ('abc ' || rnddoc(10)); - INSERT INTO xx VALUES ('abc abc' || rnddoc(9)); - INSERT INTO xx VALUES ('abc abc abc' || rnddoc(8)); -} {} -faultsim_save_and_close - -do_faultsim_test 2 -faults oom-* -prep { - faultsim_restore_and_reopen - execsql { SELECT * FROM xx } -} -body { - execsql { SELECT rowid FROM xx WHERE xx MATCH 'abc' ORDER BY rank } -} -test { - faultsim_test_result [list 0 {3 2 1}] -} - #------------------------------------------------------------------------- # An OOM while "reseeking" an FTS cursor. # diff --git a/ext/fts5/test/fts5fault9.test b/ext/fts5/test/fts5fault9.test new file mode 100644 index 0000000000..b827c32df4 --- /dev/null +++ b/ext/fts5/test/fts5fault9.test @@ -0,0 +1,140 @@ +# 2015 September 3 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# +# This file is focused on OOM errors. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +source $testdir/malloc_common.tcl +set testprefix fts5fault9 + +# If SQLITE_ENABLE_FTS3 is defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + +foreach_detail_mode $testprefix { + +fts5_aux_test_functions db + +if 1 { + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); + INSERT INTO t1(t1, rank) VALUES('pgsz', 32); + WITH seq(s) AS ( SELECT 1 UNION ALL SELECT s+1 FROM seq WHERE s<50) + INSERT INTO t1 SELECT 'x x x y y y', 'a b c d e f' FROM seq; +} + +do_faultsim_test 1 -faults oom-* -body { + execsql { SELECT count(*) FROM t1('x AND y') } +} -test { + faultsim_test_result {0 50} +} + +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE t2 USING fts5(a, b, detail=%DETAIL%); + INSERT INTO t2(t2, rank) VALUES('pgsz', 32); + INSERT INTO t2 VALUES('abc cba', 'cba abc'); + INSERT INTO t2 VALUES('abc cba', 'cba abc'); + INSERT INTO t2 VALUES('abc cba', 'cba abc'); + + INSERT INTO t2 VALUES('axy cyx', 'cyx axy'); + INSERT INTO t2 VALUES('axy cyx', 'cyx axy'); + INSERT INTO t2 VALUES('axy cyx', 'cyx axy'); +} + +do_faultsim_test 2 -faults oom-* -body { + execsql { SELECT count(*) FROM t2('a* AND c*') } +} -test { + faultsim_test_result {0 6} +} + + +do_execsql_test 3.0 { + CREATE VIRTUAL TABLE t3 USING fts5(a, detail=%DETAIL%); + INSERT INTO t3 VALUES('a x x a x a a a'); + INSERT INTO t3 VALUES('x a a x a x x x'); +} + +do_faultsim_test 3.1 -faults oom-* -body { + execsql { SELECT highlight(t3, 0, '[', ']') FROM t3('a') } +} -test { + faultsim_test_result {0 {{[a] x x [a] x [a] [a] [a]} {x [a] [a] x [a] x x x}}} +} + +do_faultsim_test 3.2 -faults oom-t* -body { + execsql { SELECT fts5_test_poslist2(t3) FROM t3('x') } +} -test { + faultsim_test_result \ + {0 {{0.0.1 0.0.2 0.0.4} {0.0.0 0.0.3 0.0.5 0.0.6 0.0.7}}} \ + {1 SQLITE_NOMEM} +} + +#------------------------------------------------------------------------- +# Test OOM injection with the xPhraseFirstColumn() API and a tokenizer +# uses query synonyms. +# +fts5_tclnum_register db +do_execsql_test 4.0 { + CREATE VIRTUAL TABLE t4 USING fts5(x, y, z, detail=%DETAIL%, tokenize=tclnum); + INSERT INTO t4 VALUES('one two three', '1 2 3', 'i ii iii'); + INSERT INTO t4 VALUES('1 2 3', 'i ii iii', 'one two three'); + INSERT INTO t4 VALUES('i ii iii', 'one two three', 'i ii iii'); + + INSERT INTO t4 VALUES('a1 a2 a3', 'a4 a5 a6', 'a7 a8 a9'); + INSERT INTO t4 VALUES('b1 b2 b3', 'b4 b5 b6', 'b7 b8 b9'); + INSERT INTO t4 VALUES('c1 c2 c3', 'c4 c5 c6', 'c7 c8 c9'); +} + +do_faultsim_test 4.1 -faults oom-t* -body { + execsql { SELECT rowid, fts5_test_collist(t4) FROM t4('2') } +} -test { + faultsim_test_result \ + {0 {1 {0.0 0.1 0.2} 2 {0.0 0.1 0.2} 3 {0.0 0.1 0.2}}} {1 SQLITE_NOMEM} +} + +do_faultsim_test 4.2 -faults oom-t* -body { + execsql { SELECT rowid, fts5_test_collist(t4) FROM t4('a5 OR b5 OR c5') } +} -test { + faultsim_test_result \ + {0 {4 {0.0 0.1 0.2} 5 {1.0 1.1 1.2} 6 {2.0 2.1 2.2}}} {1 SQLITE_NOMEM} +} + +} + + +#------------------------------------------------------------------------- +# An OOM within an "ORDER BY rank" query. +# +db func rnddoc fts5_rnddoc +do_execsql_test 5.0 { + CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=%DETAIL%); + INSERT INTO xx VALUES ('def', 'abc ' || rnddoc(10)); + INSERT INTO xx VALUES ('def', 'abc abc' || rnddoc(9)); + INSERT INTO xx VALUES ('def', 'abc abc abc' || rnddoc(8)); +} {} +faultsim_save_and_close + +do_faultsim_test 5 -faults oom-* -prep { + faultsim_restore_and_reopen + execsql { SELECT * FROM xx } +} -body { + execsql { SELECT rowid FROM xx('abc AND def') ORDER BY rank } +} -test { + faultsim_test_result [list 0 {3 2 1}] +} + +} ;# foreach_detail_mode... + +finish_test + diff --git a/ext/fts5/test/fts5hash.test b/ext/fts5/test/fts5hash.test index a4a4f28343..ac8486f070 100644 --- a/ext/fts5/test/fts5hash.test +++ b/ext/fts5/test/fts5hash.test @@ -64,11 +64,13 @@ proc random_doc {vocab nWord} { return $doc } +foreach_detail_mode $testprefix { + set vocab [build_vocab1] db func r random_doc do_execsql_test 1.0 { - CREATE VIRTUAL TABLE eee USING fts5(e, ee); + CREATE VIRTUAL TABLE eee USING fts5(e, ee, detail=%DETAIL%); BEGIN; WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<100) INSERT INTO eee SELECT r($vocab, 5), r($vocab, 7) FROM ii; @@ -91,7 +93,7 @@ do_test 1.2 { } } {} -do_test 1.2 { +do_test 1.3 { db eval { SELECT term, doc FROM vocab } { set nRow [db one {SELECT count(*) FROM eee WHERE eee MATCH $term}] if {$nRow != $doc} { @@ -101,10 +103,12 @@ do_test 1.2 { set {} {} } {} -do_execsql_test 1.3 { +do_execsql_test 1.4 { COMMIT; INSERT INTO eee(eee) VALUES('integrity-check'); } +} ;# foreach_detail_mode + finish_test diff --git a/ext/fts5/test/fts5synonym.test b/ext/fts5/test/fts5synonym.test index 008d2fc543..185dda3ff4 100644 --- a/ext/fts5/test/fts5synonym.test +++ b/ext/fts5/test/fts5synonym.test @@ -21,42 +21,16 @@ ifcapable !fts5 { return } -foreach S { - {zero 0} - {one 1 i} - {two 2 ii} - {three 3 iii} - {four 4 iv} - {five 5 v} - {six 6 vi} - {seven 7 vii} - {eight 8 viii} - {nine 9 ix} -} { - foreach s $S { - set o [list] - foreach x $S {if {$x!=$s} {lappend o $x}} - set ::syn($s) $o - } -} +proc tcl_create {args} { return "tcl_tokenize" } -proc tcl_tokenize {tflags text} { - foreach {w iStart iEnd} [fts5_tokenize_split $text] { - sqlite3_fts5_token $w $iStart $iEnd - } -} - -proc tcl_create {args} { - return "tcl_tokenize" -} - -sqlite3_fts5_create_tokenizer db tcl tcl_create +foreach_detail_mode $testprefix { #------------------------------------------------------------------------- # Warm body test for the code in fts5_tcl.c. # +fts5_tclnum_register db do_execsql_test 1.0 { - CREATE VIRTUAL TABLE ft USING fts5(x, tokenize = tcl); + CREATE VIRTUAL TABLE ft USING fts5(x, tokenize = "tclnum document", detail=%DETAIL%); INSERT INTO ft VALUES('abc def ghi'); INSERT INTO ft VALUES('jkl mno pqr'); SELECT rowid, x FROM ft WHERE ft MATCH 'def'; @@ -67,22 +41,13 @@ do_execsql_test 1.0 { # Test a tokenizer that supports synonyms by adding extra entries to the # FTS index. # - -proc tcl_tokenize {tflags text} { - foreach {w iStart iEnd} [fts5_tokenize_split $text] { - sqlite3_fts5_token $w $iStart $iEnd - if {$tflags=="document" && [info exists ::syn($w)]} { - foreach s $::syn($w) { - sqlite3_fts5_token -colo $s $iStart $iEnd - } - } - } -} reset_db -sqlite3_fts5_create_tokenizer db tcl tcl_create +fts5_tclnum_register db do_execsql_test 2.0 { - CREATE VIRTUAL TABLE ft USING fts5(x, tokenize = tcl); + CREATE VIRTUAL TABLE ft USING fts5( + x, tokenize = "tclnum document", detail=%DETAIL% + ); INSERT INTO ft VALUES('one two three'); INSERT INTO ft VALUES('four five six'); INSERT INTO ft VALUES('eight nine ten'); @@ -95,6 +60,7 @@ foreach {tn expr res} { 4 "1*" {1} 5 "1 + 2" {1} } { + if {![fts5_expr_ok $expr ft]} continue do_execsql_test 2.1.$tn { SELECT rowid FROM ft WHERE ft MATCH $expr } $res @@ -180,17 +146,7 @@ do_execsql_test 3.2.5 { # Check that expressions with synonyms can be parsed and executed. # reset_db -sqlite3_fts5_create_tokenizer db tcl tcl_create -proc tcl_tokenize {tflags text} { - foreach {w iStart iEnd} [fts5_tokenize_split $text] { - sqlite3_fts5_token $w $iStart $iEnd - if {$tflags=="query" && [info exists ::syn($w)]} { - foreach s $::syn($w) { - sqlite3_fts5_token -colo $s $iStart $iEnd - } - } - } -} +fts5_tclnum_register db foreach {tn expr res} { 1 {abc} {"abc"} @@ -198,11 +154,13 @@ foreach {tn expr res} { 3 {3} {"3"|"iii"|"three"} 4 {3*} {"3"|"iii"|"three" *} } { - do_execsql_test 4.1.$tn {SELECT fts5_expr($expr, 'tokenize=tcl')} [list $res] + do_execsql_test 4.1.$tn { + SELECT fts5_expr($expr, 'tokenize=tclnum') + } [list $res] } do_execsql_test 4.2.1 { - CREATE VIRTUAL TABLE xx USING fts5(x, tokenize=tcl); + CREATE VIRTUAL TABLE xx USING fts5(x, tokenize=tclnum, detail=%DETAIL%); INSERT INTO xx VALUES('one two'); INSERT INTO xx VALUES('three four'); } @@ -217,7 +175,7 @@ do_execsql_test 4.2.3 { do_test 5.0 { execsql { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, tokenize=tcl) + CREATE VIRTUAL TABLE t1 USING fts5(a, b, tokenize=tclnum, detail=%DETAIL%) } foreach {rowid a b} { 1 {four v 4 i three} {1 3 five five 4 one} @@ -285,6 +243,7 @@ foreach {tn q res} { 5 {three i v i four 4 1} {ii [five five five] iii} } } { + if {![fts5_expr_ok $q t1]} continue do_execsql_test 5.1.$tn { SELECT rowid, highlight(t1, 0, '[', ']'), highlight(t1, 1, '[', ']') FROM t1 WHERE t1 MATCH $q @@ -316,7 +275,6 @@ foreach {tn q res} { } $res } - #------------------------------------------------------------------------- # Test terms with more than 4 synonyms. # @@ -334,17 +292,19 @@ proc tcl_tokenize {tflags text} { } do_execsql_test 6.0.1 { - CREATE VIRTUAL TABLE t1 USING fts5(x, tokenize=tcl); + CREATE VIRTUAL TABLE t1 USING fts5(x, tokenize=tcl, detail=%DETAIL%); INSERT INTO t1 VALUES('yy xx qq'); INSERT INTO t1 VALUES('yy xx xx'); } -do_execsql_test 6.0.2 { - SELECT * FROM t1 WHERE t1 MATCH 'NEAR(y q)'; -} {{yy xx qq}} +if {[fts5_expr_ok "NEAR(y q)" t1]} { + do_execsql_test 6.0.2 { + SELECT * FROM t1 WHERE t1 MATCH 'NEAR(y q)'; + } {{yy xx qq}} +} do_test 6.0.3 { execsql { - CREATE VIRTUAL TABLE t2 USING fts5(a, b, tokenize=tcl) + CREATE VIRTUAL TABLE t2 USING fts5(a, b, tokenize=tcl, detail=%DETAIL%) } foreach {rowid a b} { 1 {yyyy vvvvv qq oo yyyyyy vvvv eee} {ffff uu r qq aaaa} @@ -387,6 +347,8 @@ foreach {tn q res} { 2 {ww oooooo bbbbb ssssss mm} {ffffff [yy] iiii rr s ccc [qqqqq]} } } { + if {![fts5_expr_ok $q t2]} continue + do_execsql_test 6.1.$tn.asc { SELECT rowid, highlight(t2, 0, '[', ']'), highlight(t2, 1, '[', ']') FROM t2 WHERE t2 MATCH $q @@ -435,7 +397,7 @@ proc tcl_tokenize {tflags text} { } do_execsql_test 7.0.1 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b, columnsize=1, tokenize=tcl); + CREATE VIRTUAL TABLE t1 USING fts5(a, b, columnsize=1, tokenize=tcl, detail=%DETAIL%); INSERT INTO t1 VALUES('0 2 3', '4 5 6 7'); INSERT INTO t1 VALUES('8 9', '0 0 0 0 0 0 0 0 0 0'); SELECT fts5_test_columnsize(t1) FROM t1 WHERE t1 MATCH '000 AND 00 AND 0'; @@ -446,7 +408,7 @@ do_execsql_test 7.0.2 { } do_execsql_test 7.1.1 { - CREATE VIRTUAL TABLE t2 USING fts5(a, b, columnsize=0, tokenize=tcl); + CREATE VIRTUAL TABLE t2 USING fts5(a, b, columnsize=0, tokenize=tcl, detail=%DETAIL%); INSERT INTO t2 VALUES('0 2 3', '4 5 6 7'); INSERT INTO t2 VALUES('8 9', '0 0 0 0 0 0 0 0 0 0'); SELECT fts5_test_columnsize(t2) FROM t2 WHERE t2 MATCH '000 AND 00 AND 0'; @@ -456,5 +418,7 @@ do_execsql_test 7.1.2 { INSERT INTO t2(t2) VALUES('integrity-check'); } +} ;# foreach_detail_mode + finish_test diff --git a/ext/fts5/test/fts5synonym2.test b/ext/fts5/test/fts5synonym2.test index 96cacb293f..dddaa17af8 100644 --- a/ext/fts5/test/fts5synonym2.test +++ b/ext/fts5/test/fts5synonym2.test @@ -21,52 +21,22 @@ ifcapable !fts5 { return } -#------------------------------------------------------------------------- -# Code for a simple Tcl tokenizer that supports synonyms at query time. -# -foreach SYNDICT { - {zero 0} - {one 1 i} - {two 2 ii} - {three 3 iii} - {four 4 iv} - {five 5 v} - {six 6 vi} - {seven 7 vii} - {eight 8 viii} - {nine 9 ix} -} { - foreach s $SYNDICT { - set o [list] - foreach x $SYNDICT {if {$x!=$s} {lappend o $x}} - set ::syn($s) $o - } -} - -proc tcl_tokenize {tflags text} { - foreach {w iStart iEnd} [fts5_tokenize_split $text] { - sqlite3_fts5_token $w $iStart $iEnd - if {$tflags == "query"} { - foreach s $::syn($w) { sqlite3_fts5_token -colo $s $iStart $iEnd } - } - } -} - -proc tcl_create {args} { - return "tcl_tokenize" -} - -# -# End of tokenizer code. -#------------------------------------------------------------------------- - +foreach tok {query document} { foreach_detail_mode $testprefix { -sqlite3_fts5_create_tokenizer db tcl tcl_create +fts5_tclnum_register db fts5_aux_test_functions db -do_execsql_test 1.0 { - CREATE VIRTUAL TABLE ss USING fts5(a, b, tokenize=tcl, detail=%DETAIL%); +proc fts5_rowid {cmd} { expr [$cmd xColumnText -1] } +sqlite3_fts5_create_function db fts5_rowid fts5_rowid + +do_execsql_test 1.$tok.0.1 " + CREATE VIRTUAL TABLE ss USING fts5(a, b, + tokenize='tclnum $tok', detail=%DETAIL%); + INSERT INTO ss(ss, rank) VALUES('rank', 'fts5_rowid()'); +" + +do_execsql_test 1.$tok.0.2 { INSERT INTO ss VALUES('5 5 five seven 3 seven i', '2 1 5 0 two 1 i'); INSERT INTO ss VALUES('six ix iii 7 i vii iii', 'one seven nine 4 9 1 vi'); INSERT INTO ss VALUES('6 viii i five six zero seven', '5 v iii iv iv 3'); @@ -137,17 +107,22 @@ foreach {tn expr} { 4.3 "NEAR(eight nine, 1) OR NEAR(six seven, 1)" } { if {[fts5_expr_ok $expr ss]==0} { - do_test 1.$tn.OMITTED { list } [list] + do_test 1.$tok.$tn.OMITTED { list } [list] continue } - set res [fts5_query_data $expr ss ASC ::syn] - breakpoint - do_execsql_test 1.$tn.[llength $res].asc { + set res [fts5_query_data $expr ss ASC ::tclnum_syn] + do_execsql_test 1.$tok.$tn.[llength $res].asc.1 { SELECT rowid, fts5_test_poslist(ss), fts5_test_collist(ss) FROM ss($expr) } $res + + do_execsql_test 1.$tok.$tn.[llength $res].asc.2 { + SELECT rowid, fts5_test_poslist(ss), fts5_test_collist(ss) FROM ss($expr) + ORDER BY rank ASC + } $res } +} } finish_test diff --git a/manifest b/manifest index fa6bddb8b1..8872e8fc50 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\ssqlite3VdbeAddOp4()\srather\sthan\sa\sseparate\ssqlite3VdbeChangeP4()\scall,\sfor\na\sslightly\ssmaller\sand\sfaster\sbinary. -D 2016-01-16T15:12:35.739 +C Add\sfurther\stests\sfor\sfts5.\sFix\ssome\sproblems\swith\sdetail=col\smode\sand\sauxiliary\sfunctions. +D 2016-01-16T18:58:51.767 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -99,14 +99,14 @@ F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h ff9c2782e8ed890b0de2f697a8d63971939e70c7 F ext/fts5/fts5Int.h 313e3276ac9e0245ee722ef803253857a68722b9 F ext/fts5/fts5_aux.c 2dafc3aee0c70d643140c77d8d70daffa51a9e9e -F ext/fts5/fts5_buffer.c 87204c8b3b8bc62b27376eab09b74d6d5acc41f1 -F ext/fts5/fts5_config.c 9c243d04ac0ca997d2d2e2252891f2a10fbd7217 -F ext/fts5/fts5_expr.c 510db45967ca359f64f2ba2c707ab57d740cad56 +F ext/fts5/fts5_buffer.c ba59964c95f760bd5ff1dbe173b85f197a13864e +F ext/fts5/fts5_config.c 0c384ebdd23fd055e2e50a93277b8d59da538238 +F ext/fts5/fts5_expr.c 3ba4c9588ebb2e4f852d807869af7130b6362e5a F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955 F ext/fts5/fts5_index.c cd036089b22b0340fccef88a3ad62ac1016c7cbb -F ext/fts5/fts5_main.c 1d116f5c44c6f06ec282d33dd6d041c8131b3d6a +F ext/fts5/fts5_main.c 833db0a3df10ab26e0221a9baa40cf871c450df3 F ext/fts5/fts5_storage.c fb2eaec3aa954b680d43096dc539f8270bd6390e -F ext/fts5/fts5_tcl.c bcacc05dec0446e7b1a44d5d906057e677bd7ea4 +F ext/fts5/fts5_tcl.c f8731e0508299bd43f1a2eff7dbeaac870768966 F ext/fts5/fts5_test_mi.c 1ec66ffdf7632077fbd773b7a6df5153272ec070 F ext/fts5/fts5_test_tok.c db08af63673c3a7d39f053b36fd6e065017706be F ext/fts5/fts5_tokenize.c 504984ac6993323247221eebe3cd55bead01b5f8 @@ -115,7 +115,7 @@ F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c ee6df1a3be103414d7b7af833ae1885c7b83a9d0 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl 393882afb225a21edf033043bbf936951e9198c1 +F ext/fts5/test/fts5_common.tcl 75b0af04898c18df289620dd4e7442d881e3ccc1 F ext/fts5/test/fts5aa.test 7e814df4a0e6c22a6fe2d84f210fdc0b5068a084 F ext/fts5/test/fts5ab.test 30325a89453280160106be411bba3acf138e6d1b F ext/fts5/test/fts5ac.test d5073ca7bd2d9fe8aab0c82c6c75a7e4b0d70ced @@ -134,7 +134,7 @@ F ext/fts5/test/fts5aux.test 8c687c948cc98e9a94be014df7d518acc1b3b74f F ext/fts5/test/fts5auxdata.test 141a7cbffcceb1bd2799b4b29c183ff8780d586e F ext/fts5/test/fts5bigpl.test 04ee0d7eebbebf17c31f5a0b5c5f9494eac3a0cb F ext/fts5/test/fts5columnsize.test a8cfef21ffa1c264b9f670a7d94eeaccb5341c07 -F ext/fts5/test/fts5config.test 42c1336cc6ed33d7e9c4a05dbce81721b765e7d0 +F ext/fts5/test/fts5config.test 83941309b94d002ed6f55d9cd814e0353c9ae013 F ext/fts5/test/fts5conflict.test 26f4e46c4d31e16221794832a990dc4e30e18de5 F ext/fts5/test/fts5content.test 9a952c95518a14182dc3b59e3c8fa71cda82a4e1 F ext/fts5/test/fts5corrupt.test c2ad090192708150d50d961278df10ae7a4b8b62 @@ -148,13 +148,14 @@ F ext/fts5/test/fts5eb.test 021aa80b7ac09b964249aa32ced9ee908703e4aa F ext/fts5/test/fts5fault1.test 4b39c47ca3544615daa8a2f733b911fa08022c77 F ext/fts5/test/fts5fault2.test 28c36c843bb39ae855ba79827417ecc37f114341 F ext/fts5/test/fts5fault3.test d6e9577d4312e331a913c72931bf131704efc8f3 -F ext/fts5/test/fts5fault4.test 4864f2b5c2c083440dbe85aff60897bc1aa04603 +F ext/fts5/test/fts5fault4.test 532b6dacb963016cbf7003196bd87fb366540277 F ext/fts5/test/fts5fault5.test 10c13a783de3f42a21e3e53e123b62ed0c3a1618 F ext/fts5/test/fts5fault6.test 9682664d679643ac6736e90c225526cc84073cda F ext/fts5/test/fts5fault7.test 01be274bfc8d9bf22451a3bf5892e9399d044f1b F ext/fts5/test/fts5fault8.test f2d8a2b673a5f72ca1fa0e85bdbfb2041ffd347d +F ext/fts5/test/fts5fault9.test 964a3ee82b95053bd45d809fe2b7acf4a8c90ca9 F ext/fts5/test/fts5full.test 6f6143af0c6700501d9fd597189dfab1555bb741 -F ext/fts5/test/fts5hash.test 7cf4607b8657c383f0b520668a99971e95d8b139 +F ext/fts5/test/fts5hash.test 00668f6fa9b9bffbd7c1be29f408aa2bdade0451 F ext/fts5/test/fts5integrity.test 87db5d4e7da0ce04a1dcba5ba91658673c997a65 F ext/fts5/test/fts5matchinfo.test 86569026d20f1ed748236587ce798de8a96615f1 F ext/fts5/test/fts5merge.test 8f3cdba2ec9c5e7e568246e81b700ad37f764367 @@ -173,8 +174,8 @@ F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 F ext/fts5/test/fts5simple.test 2bc6451cbe887a9215f5b14ae307c70d850344c9 F ext/fts5/test/fts5simple2.test 7b51f8d411e9a77fa4519fb09ba5a3afda75c94d -F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 -F ext/fts5/test/fts5synonym2.test d2d9099d9d105b55ea03fd52d61ae2847d534129 +F ext/fts5/test/fts5synonym.test 6475d189c2e20d60795808f83e36bf9318708d48 +F ext/fts5/test/fts5synonym2.test eadb00c73ef0653258873e756b7e9102e0687539 F ext/fts5/test/fts5tok1.test beb894c6f3468f10a574302f69ebe4436b0287c7 F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 @@ -1416,7 +1417,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 653ea15ad8e23b333e234eb5dde7b80134db2baf -R 2155f55389b348e9a35fea6f93c01bbe -U drh -Z 32d5bf122f6c10496965338bc29a15a2 +P a4258cd4613c55acacb5c7b61faa3de7eb0759d2 +R 7d01724b879e1ef98656daadba5b9cfb +U dan +Z d745955e2f048d17831d9a126adffb23 diff --git a/manifest.uuid b/manifest.uuid index 39ad2ac515..94a16261bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a4258cd4613c55acacb5c7b61faa3de7eb0759d2 \ No newline at end of file +de77d6026e8035c505a704e7b8cfe5af6579d35f \ No newline at end of file From 2ce1865dd86b6a96e305e0736d719de7e60e7b46 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 16 Jan 2016 20:50:21 +0000 Subject: [PATCH 207/232] Improvements to the way sqlite3VdbeAddOpList() works, resulting in a slightly smaller and faster binary. FossilOrigin-Name: 88ceb588bcdb3ca86d0c58cfdeb61b5fe070872f --- manifest | 20 ++++----- manifest.uuid | 2 +- src/pragma.c | 87 +++++++++++++++++++++---------------- src/vdbe.h | 9 +++- src/vdbeaux.c | 56 +++++++++++++++--------- src/vdbeblob.c | 113 +++++++++++++++++++++++++------------------------ 6 files changed, 161 insertions(+), 126 deletions(-) diff --git a/manifest b/manifest index 8872e8fc50..c9a3b49a57 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sfurther\stests\sfor\sfts5.\sFix\ssome\sproblems\swith\sdetail=col\smode\sand\sauxiliary\sfunctions. -D 2016-01-16T18:58:51.767 +C Improvements\sto\sthe\sway\ssqlite3VdbeAddOpList()\sworks,\sresulting\sin\sa\sslightly\nsmaller\sand\sfaster\sbinary. +D 2016-01-16T20:50:21.742 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -336,7 +336,7 @@ F src/parse.y caad1e98edeca6960493d0c60d31b76820dd7776 F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 F src/pcache.h 4d0ccaad264d360981ec5e6a2b596d6e85242545 F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051 -F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 +F src/pragma.c 53c95f5454e2a8bdb25ebf1567bed6690910ce25 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 74855ddbdfad6a1c4a4d5c4b0913ebb01174ba19 F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 @@ -409,11 +409,11 @@ F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 F src/vdbe.c b90d9d38e5e0260c2eafa3cb4c2274d8ea94da27 -F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 +F src/vdbe.h 22f8c913bd2c8549b3d3a897da3428efbe944378 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e -F src/vdbeaux.c 906c0350f316dd13a26d8a91865f1dd7f14dc19b -F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 +F src/vdbeaux.c 82969fb2558e6cf57601e283f0101d0f60f5a4f2 +F src/vdbeblob.c 8542f282b58293bd61c2ea4b2125f250f4fc9543 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 @@ -1417,7 +1417,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a4258cd4613c55acacb5c7b61faa3de7eb0759d2 -R 7d01724b879e1ef98656daadba5b9cfb -U dan -Z d745955e2f048d17831d9a126adffb23 +P de77d6026e8035c505a704e7b8cfe5af6579d35f +R e442832cd3e3e0853ec0a993c2468ee7 +U drh +Z 51b7d6e877f13b345892ef271baf2a12 diff --git a/manifest.uuid b/manifest.uuid index 94a16261bf..fda58e60e8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -de77d6026e8035c505a704e7b8cfe5af6579d35f \ No newline at end of file +88ceb588bcdb3ca86d0c58cfdeb61b5fe070872f \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 0d48057d21..50f7229c33 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -430,15 +430,17 @@ void sqlite3Pragma( { OP_Noop, 0, 0, 0}, { OP_ResultRow, 1, 1, 0}, }; - int addr; + VdbeOp *aOp; sqlite3VdbeUsesBtree(v, iDb); if( !zRight ){ setOneColumnName(v, "cache_size"); pParse->nMem += 2; - addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize,iLn); - sqlite3VdbeChangeP1(v, addr, iDb); - sqlite3VdbeChangeP1(v, addr+1, iDb); - sqlite3VdbeChangeP1(v, addr+6, SQLITE_DEFAULT_CACHE_SIZE); + sqlite3VdbeVerifyAvailableSpace(v, ArraySize(getCacheSize)); + aOp = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize, iLn); + assert( aOp!=0 ); + aOp[0].p1 = iDb; + aOp[1].p1 = iDb; + aOp[6].p1 = SQLITE_DEFAULT_CACHE_SIZE; }else{ int size = sqlite3AbsInt32(sqlite3Atoi(zRight)); sqlite3BeginWriteOperation(pParse, 0, iDb); @@ -684,13 +686,16 @@ void sqlite3Pragma( { OP_Integer, 0, 1, 0}, /* 4 */ { OP_SetCookie, 0, BTREE_INCR_VACUUM, 1}, /* 5 */ }; - int iAddr; - iAddr = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6, iLn); - sqlite3VdbeChangeP1(v, iAddr, iDb); - sqlite3VdbeChangeP1(v, iAddr+1, iDb); - sqlite3VdbeChangeP2(v, iAddr+2, iAddr+4); - sqlite3VdbeChangeP1(v, iAddr+4, eAuto-1); - sqlite3VdbeChangeP1(v, iAddr+5, iDb); + VdbeOp *aOp; + int iAddr = sqlite3VdbeCurrentAddr(v); + sqlite3VdbeVerifyAvailableSpace(v, ArraySize(setMeta6)); + aOp = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6, iLn); + assert( aOp!=0 ); + aOp[0].p1 = iDb; + aOp[1].p1 = iDb; + aOp[2].p2 = iAddr+4; + aOp[4].p1 = eAuto - 1; + aOp[5].p1 = iDb; sqlite3VdbeUsesBtree(v, iDb); } } @@ -1396,18 +1401,6 @@ void sqlite3Pragma( case PragTyp_INTEGRITY_CHECK: { int i, j, addr, mxErr; - /* Code that appears at the end of the integrity check. If no error - ** messages have been generated, output OK. Otherwise output the - ** error message - */ - static const int iLn = VDBE_OFFSET_LINENO(2); - static const VdbeOpList endCode[] = { - { OP_AddImm, 1, 0, 0}, /* 0 */ - { OP_If, 1, 0, 0}, /* 1 */ - { OP_String8, 0, 3, 0}, /* 2 */ - { OP_ResultRow, 3, 1, 0}, - }; - int isQuick = (sqlite3Tolower(zLeft[0])=='q'); /* If the PRAGMA command was of the form "PRAGMA .integrity_check", @@ -1604,10 +1597,24 @@ void sqlite3Pragma( #endif /* SQLITE_OMIT_BTREECOUNT */ } } - addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode, iLn); - sqlite3VdbeChangeP2(v, addr, -mxErr); - sqlite3VdbeJumpHere(v, addr+1); - sqlite3VdbeChangeP4(v, addr+2, "ok", P4_STATIC); + { + static const int iLn = VDBE_OFFSET_LINENO(2); + static const VdbeOpList endCode[] = { + { OP_AddImm, 1, 0, 0}, /* 0 */ + { OP_If, 1, 0, 0}, /* 1 */ + { OP_String8, 0, 3, 0}, /* 2 */ + { OP_ResultRow, 3, 1, 0}, + }; + VdbeOp *aOp; + + aOp = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode, iLn); + if( aOp ){ + aOp[0].p2 = -mxErr; + aOp[1].p2 = sqlite3VdbeCurrentAddr(v); + aOp[2].p4type = P4_STATIC; + aOp[2].p4.z = "ok"; + } + } } break; #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ @@ -1724,11 +1731,14 @@ void sqlite3Pragma( { OP_Integer, 0, 1, 0}, /* 1 */ { OP_SetCookie, 0, 0, 1}, /* 2 */ }; - int addr = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie, 0); - sqlite3VdbeChangeP1(v, addr, iDb); - sqlite3VdbeChangeP1(v, addr+1, sqlite3Atoi(zRight)); - sqlite3VdbeChangeP1(v, addr+2, iDb); - sqlite3VdbeChangeP2(v, addr+2, iCookie); + VdbeOp *aOp; + sqlite3VdbeVerifyAvailableSpace(v, ArraySize(setCookie)); + aOp = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie, 0); + assert( aOp!=0 ); + aOp[0].p1 = iDb; + aOp[1].p1 = sqlite3Atoi(zRight); + aOp[2].p1 = iDb; + aOp[2].p2 = iCookie; }else{ /* Read the specified cookie value */ static const VdbeOpList readCookie[] = { @@ -1736,10 +1746,13 @@ void sqlite3Pragma( { OP_ReadCookie, 0, 1, 0}, /* 1 */ { OP_ResultRow, 1, 1, 0} }; - int addr = sqlite3VdbeAddOpList(v, ArraySize(readCookie), readCookie, 0); - sqlite3VdbeChangeP1(v, addr, iDb); - sqlite3VdbeChangeP1(v, addr+1, iDb); - sqlite3VdbeChangeP3(v, addr+1, iCookie); + VdbeOp *aOp; + sqlite3VdbeVerifyAvailableSpace(v, ArraySize(readCookie)); + aOp = sqlite3VdbeAddOpList(v, ArraySize(readCookie),readCookie,0); + assert( aOp!=0 ); + aOp[0].p1 = iDb; + aOp[1].p1 = iDb; + aOp[1].p3 = iCookie; sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT); } diff --git a/src/vdbe.h b/src/vdbe.h index 68a4f6b2a8..a0ff16d891 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -180,7 +180,12 @@ int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int); int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); -int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno); +#ifdef SQLITE_DEBUG + void sqlite3VdbeVerifyAvailableSpace(Vdbe *p, int N); +#else +# define sqlite3VdbeVerifyAvailableSpace(A,B) +#endif +VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno); void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*); void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8); void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1); @@ -188,7 +193,7 @@ void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2); void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3); void sqlite3VdbeChangeP5(Vdbe*, u8 P5); void sqlite3VdbeJumpHere(Vdbe*, int addr); -void sqlite3VdbeChangeToNoop(Vdbe*, int addr); +int sqlite3VdbeChangeToNoop(Vdbe*, int addr); int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op); void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 758c85fd1c..9859054ba4 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -250,8 +250,7 @@ void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){ for(i=0; (c = zTypes[i])!=0; i++){ if( c=='s' ){ const char *z = va_arg(ap, const char*); - int addr = sqlite3VdbeAddOp2(p, z==0 ? OP_Null : OP_String8, 0, iDest++); - if( z ) sqlite3VdbeChangeP4(p, addr, z, 0); + sqlite3VdbeAddOp4(p, z==0 ? OP_Null : OP_String8, 0, iDest++, 0, z, 0); }else{ assert( c=='i' ); sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest++); @@ -606,6 +605,17 @@ int sqlite3VdbeCurrentAddr(Vdbe *p){ return p->nOp; } +/* +** Verify that at least N opcode slots are available in p without +** having to malloc for more space. This interface is used for +** testing only. +*/ +#ifdef SQLITE_DEBUG +void sqlite3VdbeVerifyAvailableSpace(Vdbe *p, int N){ + assert( p->nOp + N <= p->pParse->nOpAlloc ); +} +#endif + /* ** This function returns a pointer to the array of opcodes associated with ** the Vdbe passed as the first argument. It is the callers responsibility @@ -631,19 +641,23 @@ VdbeOp *sqlite3VdbeTakeOpArray(Vdbe *p, int *pnOp, int *pnMaxArg){ } /* -** Add a whole list of operations to the operation stack. Return the -** address of the first operation added. +** Add a whole list of operations to the operation stack. Return a +** pointer to the first operation inserted. */ -int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp, int iLineno){ - int addr, i; - VdbeOp *pOut; +VdbeOp *sqlite3VdbeAddOpList( + Vdbe *p, /* Add opcodes to the prepared statement */ + int nOp, /* Number of opcodes to add */ + VdbeOpList const *aOp, /* The opcodes to be added */ + int iLineno /* Source-file line number of first opcode */ +){ + int i; + VdbeOp *pOut, *pFirst; assert( nOp>0 ); assert( p->magic==VDBE_MAGIC_INIT ); if( p->nOp + nOp > p->pParse->nOpAlloc && growOpArray(p, nOp) ){ return 0; } - addr = p->nOp; - pOut = &p->aOp[addr]; + pFirst = pOut = &p->aOp[p->nOp]; for(i=0; iopcode = aOp->opcode; pOut->p1 = aOp->p1; @@ -663,12 +677,12 @@ int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp, int iLineno){ #endif #ifdef SQLITE_DEBUG if( p->db->flags & SQLITE_VdbeAddopTrace ){ - sqlite3VdbePrintOp(0, i+addr, &p->aOp[i+addr]); + sqlite3VdbePrintOp(0, i+p->nOp, &p->aOp[i+p->nOp]); } #endif } p->nOp += nOp; - return addr; + return pFirst; } #if defined(SQLITE_ENABLE_STMT_SCANSTATUS) @@ -826,14 +840,15 @@ void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){ /* ** Change the opcode at addr into OP_Noop */ -void sqlite3VdbeChangeToNoop(Vdbe *p, int addr){ - if( addrnOp ){ - VdbeOp *pOp = &p->aOp[addr]; - sqlite3 *db = p->db; - freeP4(db, pOp->p4type, pOp->p4.p); - memset(pOp, 0, sizeof(pOp[0])); - pOp->opcode = OP_Noop; - } +int sqlite3VdbeChangeToNoop(Vdbe *p, int addr){ + VdbeOp *pOp; + if( p->db->mallocFailed ) return 0; + assert( addr>=0 && addrnOp ); + pOp = &p->aOp[addr]; + freeP4(p->db, pOp->p4type, pOp->p4.p); + memset(pOp, 0, sizeof(pOp[0])); + pOp->opcode = OP_Noop; + return 1; } /* @@ -842,8 +857,7 @@ void sqlite3VdbeChangeToNoop(Vdbe *p, int addr){ */ int sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){ if( (p->nOp-1)>(p->pParse->iFixedOp) && p->aOp[p->nOp-1].opcode==op ){ - sqlite3VdbeChangeToNoop(p, p->nOp-1); - return 1; + return sqlite3VdbeChangeToNoop(p, p->nOp-1); }else{ return 0; } diff --git a/src/vdbeblob.c b/src/vdbeblob.c index a4718efacc..e5f08ce933 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -115,38 +115,6 @@ int sqlite3_blob_open( ){ int nAttempt = 0; int iCol; /* Index of zColumn in row-record */ - - /* This VDBE program seeks a btree cursor to the identified - ** db/table/row entry. The reason for using a vdbe program instead - ** of writing code to use the b-tree layer directly is that the - ** vdbe program will take advantage of the various transaction, - ** locking and error handling infrastructure built into the vdbe. - ** - ** After seeking the cursor, the vdbe executes an OP_ResultRow. - ** Code external to the Vdbe then "borrows" the b-tree cursor and - ** uses it to implement the blob_read(), blob_write() and - ** blob_bytes() functions. - ** - ** The sqlite3_blob_close() function finalizes the vdbe program, - ** which closes the b-tree cursor and (possibly) commits the - ** transaction. - */ - static const int iLn = VDBE_OFFSET_LINENO(4); - static const VdbeOpList openBlob[] = { - /* {OP_Transaction, 0, 0, 0}, // 0: Inserted separately */ - {OP_TableLock, 0, 0, 0}, /* 1: Acquire a read or write lock */ - /* One of the following two instructions is replaced by an OP_Noop. */ - {OP_OpenRead, 0, 0, 0}, /* 2: Open cursor 0 for reading */ - {OP_OpenWrite, 0, 0, 0}, /* 3: Open cursor 0 for read/write */ - {OP_Variable, 1, 1, 1}, /* 4: Push the rowid to the stack */ - {OP_NotExists, 0, 10, 1}, /* 5: Seek the cursor */ - {OP_Column, 0, 0, 1}, /* 6 */ - {OP_ResultRow, 1, 0, 0}, /* 7 */ - {OP_Goto, 0, 4, 0}, /* 8 */ - {OP_Close, 0, 0, 0}, /* 9 */ - {OP_Halt, 0, 0, 0}, /* 10 */ - }; - int rc = SQLITE_OK; char *zErr = 0; Table *pTab; @@ -265,45 +233,80 @@ int sqlite3_blob_open( pBlob->pStmt = (sqlite3_stmt *)sqlite3VdbeCreate(pParse); assert( pBlob->pStmt || db->mallocFailed ); if( pBlob->pStmt ){ + + /* This VDBE program seeks a btree cursor to the identified + ** db/table/row entry. The reason for using a vdbe program instead + ** of writing code to use the b-tree layer directly is that the + ** vdbe program will take advantage of the various transaction, + ** locking and error handling infrastructure built into the vdbe. + ** + ** After seeking the cursor, the vdbe executes an OP_ResultRow. + ** Code external to the Vdbe then "borrows" the b-tree cursor and + ** uses it to implement the blob_read(), blob_write() and + ** blob_bytes() functions. + ** + ** The sqlite3_blob_close() function finalizes the vdbe program, + ** which closes the b-tree cursor and (possibly) commits the + ** transaction. + */ + static const int iLn = VDBE_OFFSET_LINENO(3); + static const VdbeOpList openBlob[] = { + /* {OP_Transaction, 0, 0, 0}, // inserted separately */ + {OP_TableLock, 0, 0, 0}, /* 0: Acquire a read or write lock */ + {OP_OpenRead, 0, 0, 0}, /* 1: Open cursor 0 for reading */ + {OP_OpenWrite, 0, 0, 0}, /* 2: Open cursor 0 for read/write */ + {OP_Variable, 1, 1, 1}, /* 3: Push the rowid to the stack */ + {OP_NotExists, 0, 10, 1}, /* 4: Seek the cursor */ + {OP_Column, 0, 0, 1}, /* 5 */ + {OP_ResultRow, 1, 0, 0}, /* 6 */ + {OP_Goto, 0, 4, 0}, /* 7 */ + {OP_Close, 0, 0, 0}, /* 8 */ + {OP_Halt, 0, 0, 0}, /* 9 */ + }; Vdbe *v = (Vdbe *)pBlob->pStmt; int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); - + VdbeOp *aOp; sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, flags, pTab->pSchema->schema_cookie, pTab->pSchema->iGeneration); sqlite3VdbeChangeP5(v, 1); - sqlite3VdbeAddOpList(v, ArraySize(openBlob), openBlob, iLn); + aOp = sqlite3VdbeAddOpList(v, ArraySize(openBlob), openBlob, iLn); /* Make sure a mutex is held on the table to be accessed */ sqlite3VdbeUsesBtree(v, iDb); - /* Configure the OP_TableLock instruction */ + if( db->mallocFailed==0 ){ + assert( aOp!=0 ); + /* Configure the OP_TableLock instruction */ #ifdef SQLITE_OMIT_SHARED_CACHE - sqlite3VdbeChangeToNoop(v, 1); + aOp[0].opcode = OP_Noop; #else - sqlite3VdbeChangeP1(v, 1, iDb); - sqlite3VdbeChangeP2(v, 1, pTab->tnum); - sqlite3VdbeChangeP3(v, 1, flags); - sqlite3VdbeChangeP4(v, 1, pTab->zName, P4_TRANSIENT); + aOp[0].p1 = iDb; + aOp[0].p2 = pTab->tnum; + aOp[0].p3 = flags; + sqlite3VdbeChangeP4(v, 1, pTab->zName, P4_TRANSIENT); + } + if( db->mallocFailed==0 ){ #endif - /* Remove either the OP_OpenWrite or OpenRead. Set the P2 - ** parameter of the other to pTab->tnum. */ - sqlite3VdbeChangeToNoop(v, 3 - flags); - sqlite3VdbeChangeP2(v, 2 + flags, pTab->tnum); - sqlite3VdbeChangeP3(v, 2 + flags, iDb); + /* Remove either the OP_OpenWrite or OpenRead. Set the P2 + ** parameter of the other to pTab->tnum. */ + aOp[2-flags].opcode = OP_Noop; + aOp[1+flags].p2 = pTab->tnum; + aOp[1+flags].p3 = iDb; + + /* Configure the number of columns. Configure the cursor to + ** think that the table has one more column than it really + ** does. An OP_Column to retrieve this imaginary column will + ** always return an SQL NULL. This is useful because it means + ** we can invoke OP_Column to fill in the vdbe cursors type + ** and offset cache without causing any IO. + */ + aOp[1+flags].p4type = P4_INT32; + aOp[1+flags].p4.i = pTab->nCol+1; + aOp[5].p2 = pTab->nCol; - /* Configure the number of columns. Configure the cursor to - ** think that the table has one more column than it really - ** does. An OP_Column to retrieve this imaginary column will - ** always return an SQL NULL. This is useful because it means - ** we can invoke OP_Column to fill in the vdbe cursors type - ** and offset cache without causing any IO. - */ - sqlite3VdbeChangeP4(v, 2+flags, SQLITE_INT_TO_PTR(pTab->nCol+1),P4_INT32); - sqlite3VdbeChangeP2(v, 6, pTab->nCol); - if( !db->mallocFailed ){ pParse->nVar = 1; pParse->nMem = 1; pParse->nTab = 1; From 3ed7029921c201a6dc9a0861497b782d392ac47c Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 16 Jan 2016 21:06:41 +0000 Subject: [PATCH 208/232] Add extra tests to cover untested branches in fts5. FossilOrigin-Name: 61deab043dcea860070dba6b02601a7de627fff1 --- ext/fts5/test/fts5fault9.test | 24 ++++++++++++++++++++---- ext/fts5/test/fts5rowid.test | 4 ++-- ext/fts5/test/fts5update.test | 28 ++++++++++++++++++++++++++++ main.mk | 3 +-- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- 6 files changed, 62 insertions(+), 19 deletions(-) diff --git a/ext/fts5/test/fts5fault9.test b/ext/fts5/test/fts5fault9.test index b827c32df4..908a91d22a 100644 --- a/ext/fts5/test/fts5fault9.test +++ b/ext/fts5/test/fts5fault9.test @@ -26,8 +26,6 @@ foreach_detail_mode $testprefix { fts5_aux_test_functions db -if 1 { - do_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); @@ -110,8 +108,6 @@ do_faultsim_test 4.2 -faults oom-t* -body { {0 {4 {0.0 0.1 0.2} 5 {1.0 1.1 1.2} 6 {2.0 2.1 2.2}}} {1 SQLITE_NOMEM} } -} - #------------------------------------------------------------------------- # An OOM within an "ORDER BY rank" query. @@ -134,6 +130,26 @@ do_faultsim_test 5 -faults oom-* -prep { faultsim_test_result [list 0 {3 2 1}] } +set doc [string repeat "xyz " 500] +do_execsql_test 6.0 { + CREATE VIRTUAL TABLE yy USING fts5(y, detail=%DETAIL%); + INSERT INTO yy(yy, rank) VALUES('pgsz', 64); + INSERT INTO yy VALUES ($doc); + INSERT INTO yy VALUES ('1 2 3'); + INSERT INTO yy VALUES ('xyz'); + UPDATE yy SET y = y WHERE rowid = 1; + UPDATE yy SET y = y WHERE rowid = 1; + UPDATE yy SET y = y WHERE rowid = 1; + UPDATE yy SET y = y WHERE rowid = 1; +} {} + +do_faultsim_test 6 -faults oom-* -body { + execsql { SELECT rowid FROM yy('xyz') } +} -test { + faultsim_test_result [list 0 {1 3}] +} + + } ;# foreach_detail_mode... finish_test diff --git a/ext/fts5/test/fts5rowid.test b/ext/fts5/test/fts5rowid.test index 621934c0f2..1db1d56003 100644 --- a/ext/fts5/test/fts5rowid.test +++ b/ext/fts5/test/fts5rowid.test @@ -63,6 +63,7 @@ do_execsql_test 2.2 { SELECT rnddoc(6), rnddoc(6) FROM r ) INSERT INTO x1 SELECT * FROM r LIMIT 10000; + DELETE FROM x1 WHERE (rowid%2); } set res [db one {SELECT count(*) FROM x1_data}] @@ -71,8 +72,7 @@ do_execsql_test 2.3 { } $res do_execsql_test 2.4 { UPDATE x1_data SET block = X''; - -- SELECT count(fts5_decode(rowid, block)) FROM x1_data; - SELECT count(*) FROM x1_data; + SELECT count(fts5_decode(rowid, block)) FROM x1_data; } $res do_execsql_test 2.5 { diff --git a/ext/fts5/test/fts5update.test b/ext/fts5/test/fts5update.test index 9e7debe9da..399c7ffb11 100644 --- a/ext/fts5/test/fts5update.test +++ b/ext/fts5/test/fts5update.test @@ -87,6 +87,34 @@ do_test 1.4 { } } {} +#------------------------------------------------------------------------- +# Lots of deletes/inserts of the same document with the same rowid. +# +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE x2 USING fts5(x, detail=%DETAIL%); + INSERT INTO x2(x2, rank) VALUES('crisismerge', 2); + INSERT INTO x2 VALUES('a b c'); + INSERT INTO x2 VALUES('a b c'); +} +do_test 2.1 { + for {set i 0} {$i < 1000} {incr i} { + execsql { DELETE FROM x2 WHERE rowid = 2 } + execsql { INSERT INTO x2(rowid, x) VALUES(2, 'a b c') } + } +} {} +do_execsql_test 2.1.integrity { + INSERT INTO x2(x2) VALUES('integrity-check'); +} + +do_test 2.2 { + for {set i 0} {$i < 1000} {incr i} { + execsql { UPDATE x2 SET x=x WHERE rowid=2 } + } +} {} +do_execsql_test 2.2.integrity { + INSERT INTO x2(x2) VALUES('integrity-check'); +} + } finish_test diff --git a/main.mk b/main.mk index abf4fd2be7..934cd36a4e 100644 --- a/main.mk +++ b/main.mk @@ -334,8 +334,7 @@ TESTSRC += \ $(TOP)/ext/misc/vfslog.c \ $(TOP)/ext/fts5/fts5_tcl.c \ $(TOP)/ext/fts5/fts5_test_mi.c \ - $(TOP)/ext/fts5/fts5_test_tok.c \ - $(FTS5_SRC) + $(TOP)/ext/fts5/fts5_test_tok.c #TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c diff --git a/manifest b/manifest index c9a3b49a57..931cca91e8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sway\ssqlite3VdbeAddOpList()\sworks,\sresulting\sin\sa\sslightly\nsmaller\sand\sfaster\sbinary. -D 2016-01-16T20:50:21.742 +C Add\sextra\stests\sto\scover\suntested\sbranches\sin\sfts5. +D 2016-01-16T21:06:41.650 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -153,7 +153,7 @@ F ext/fts5/test/fts5fault5.test 10c13a783de3f42a21e3e53e123b62ed0c3a1618 F ext/fts5/test/fts5fault6.test 9682664d679643ac6736e90c225526cc84073cda F ext/fts5/test/fts5fault7.test 01be274bfc8d9bf22451a3bf5892e9399d044f1b F ext/fts5/test/fts5fault8.test f2d8a2b673a5f72ca1fa0e85bdbfb2041ffd347d -F ext/fts5/test/fts5fault9.test 964a3ee82b95053bd45d809fe2b7acf4a8c90ca9 +F ext/fts5/test/fts5fault9.test e10e395428a9ea0596ebe752ff7123d16ab78e08 F ext/fts5/test/fts5full.test 6f6143af0c6700501d9fd597189dfab1555bb741 F ext/fts5/test/fts5hash.test 00668f6fa9b9bffbd7c1be29f408aa2bdade0451 F ext/fts5/test/fts5integrity.test 87db5d4e7da0ce04a1dcba5ba91658673c997a65 @@ -171,7 +171,7 @@ F ext/fts5/test/fts5query.test f5ec25f5f2fbb70033424113cdffc101b1985a40 F ext/fts5/test/fts5rank.test 7e9e64eac7245637f6f2033aec4b292aaf611aab F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 -F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 +F ext/fts5/test/fts5rowid.test 27a1e18c26d599a80bcabf6f687a4f1d8d29d2d2 F ext/fts5/test/fts5simple.test 2bc6451cbe887a9215f5b14ae307c70d850344c9 F ext/fts5/test/fts5simple2.test 7b51f8d411e9a77fa4519fb09ba5a3afda75c94d F ext/fts5/test/fts5synonym.test 6475d189c2e20d60795808f83e36bf9318708d48 @@ -183,7 +183,7 @@ F ext/fts5/test/fts5unicode.test fbef8d8a3b4b88470536cc57604a82ca52e51841 F ext/fts5/test/fts5unicode2.test c1dd890ba32b7609adba78e420faa847abe43b59 F ext/fts5/test/fts5unicode3.test 35c3d02aa7acf7d43d8de3bfe32c15ba96e8928e F ext/fts5/test/fts5unindexed.test e9539d5b78c677315e7ed8ea911d4fd25437c680 -F ext/fts5/test/fts5update.test 6f0abb89556f0a638b982e010f4d8d1de373a61c +F ext/fts5/test/fts5update.test 57c7012a7919889048947addae10e0613df45529 F ext/fts5/test/fts5version.test 978f59541d8cef7e8591f8be2115ec5ccb863e2e F ext/fts5/test/fts5vocab.test 480d780aa6b699816c5066225fbd86f3a0239477 F ext/fts5/tool/fts5speed.tcl aaee41894b552df8fbf8616aad003b2ea9ba3221 @@ -267,7 +267,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 7575015811ef75a2cfcbc6f09de161cc8236e8a5 +F main.mk 8670f56454bdc59d5e33397bf8c7e43eb33af50c F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1417,7 +1417,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P de77d6026e8035c505a704e7b8cfe5af6579d35f -R e442832cd3e3e0853ec0a993c2468ee7 -U drh -Z 51b7d6e877f13b345892ef271baf2a12 +P 88ceb588bcdb3ca86d0c58cfdeb61b5fe070872f +R 06f6f18fb8f74fb2b70e371e01be7b37 +U dan +Z df25345e1d2056d2ea7917d42461493d diff --git a/manifest.uuid b/manifest.uuid index fda58e60e8..539e4c0214 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -88ceb588bcdb3ca86d0c58cfdeb61b5fe070872f \ No newline at end of file +61deab043dcea860070dba6b02601a7de627fff1 \ No newline at end of file From dad300d8e1a9e9db9b9be19929e22d6a3c2bcdda Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 18 Jan 2016 00:20:26 +0000 Subject: [PATCH 209/232] Fix a problem with SQLITE_TEST_REALLOC_STRESS. FossilOrigin-Name: 0aaf3febb00f622c5ef0853b2491d69f7ca7a21e --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/pragma.c | 16 ++++++++-------- src/sqliteInt.h | 15 +++++++++++++++ src/vdbe.h | 6 +++--- src/vdbeaux.c | 11 +++++++---- 6 files changed, 44 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index 931cca91e8..1042db4582 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\stests\sto\scover\suntested\sbranches\sin\sfts5. -D 2016-01-16T21:06:41.650 +C Fix\sa\sproblem\swith\sSQLITE_TEST_REALLOC_STRESS. +D 2016-01-18T00:20:26.450 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -336,7 +336,7 @@ F src/parse.y caad1e98edeca6960493d0c60d31b76820dd7776 F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23 F src/pcache.h 4d0ccaad264d360981ec5e6a2b596d6e85242545 F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051 -F src/pragma.c 53c95f5454e2a8bdb25ebf1567bed6690910ce25 +F src/pragma.c ea290193369faa0a26ae2f924e7b86289b4a7987 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 74855ddbdfad6a1c4a4d5c4b0913ebb01174ba19 F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 @@ -348,7 +348,7 @@ F src/shell.c dcd7a83645ef2a58ee9c6d0ea4714d877d7835c4 F src/sqlite.h.in 214476a62012e578f42133a9a3b4f97a9aa421a3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 028d1f88501048b5258f7119032278a55c963512 +F src/sqliteInt.h 8fbaf9dc2bb979865c739e5272fe0b352fbc709f F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -409,10 +409,10 @@ F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 F src/vdbe.c b90d9d38e5e0260c2eafa3cb4c2274d8ea94da27 -F src/vdbe.h 22f8c913bd2c8549b3d3a897da3428efbe944378 +F src/vdbe.h 7a733ea8aac1b77305a67698e784fa3484ee3337 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e -F src/vdbeaux.c 82969fb2558e6cf57601e283f0101d0f60f5a4f2 +F src/vdbeaux.c 95e067a5e2a75e128d45ca597388dc83c58142f0 F src/vdbeblob.c 8542f282b58293bd61c2ea4b2125f250f4fc9543 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 @@ -1417,7 +1417,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 88ceb588bcdb3ca86d0c58cfdeb61b5fe070872f -R 06f6f18fb8f74fb2b70e371e01be7b37 -U dan -Z df25345e1d2056d2ea7917d42461493d +P 61deab043dcea860070dba6b02601a7de627fff1 +R 4379f64b4cb45ea0db7a5f863224d3f6 +U drh +Z e0f8e155ee8f1f04cd4cfaa23a1af003 diff --git a/manifest.uuid b/manifest.uuid index 539e4c0214..37eeb2a0f1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -61deab043dcea860070dba6b02601a7de627fff1 \ No newline at end of file +0aaf3febb00f622c5ef0853b2491d69f7ca7a21e \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 50f7229c33..15f0eecce3 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -435,9 +435,9 @@ void sqlite3Pragma( if( !zRight ){ setOneColumnName(v, "cache_size"); pParse->nMem += 2; - sqlite3VdbeVerifyAvailableSpace(v, ArraySize(getCacheSize)); + sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(getCacheSize)); aOp = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize, iLn); - assert( aOp!=0 ); + if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break; aOp[0].p1 = iDb; aOp[1].p1 = iDb; aOp[6].p1 = SQLITE_DEFAULT_CACHE_SIZE; @@ -688,9 +688,9 @@ void sqlite3Pragma( }; VdbeOp *aOp; int iAddr = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeVerifyAvailableSpace(v, ArraySize(setMeta6)); + sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setMeta6)); aOp = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6, iLn); - assert( aOp!=0 ); + if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break; aOp[0].p1 = iDb; aOp[1].p1 = iDb; aOp[2].p2 = iAddr+4; @@ -1732,9 +1732,9 @@ void sqlite3Pragma( { OP_SetCookie, 0, 0, 1}, /* 2 */ }; VdbeOp *aOp; - sqlite3VdbeVerifyAvailableSpace(v, ArraySize(setCookie)); + sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setCookie)); aOp = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie, 0); - assert( aOp!=0 ); + if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break; aOp[0].p1 = iDb; aOp[1].p1 = sqlite3Atoi(zRight); aOp[2].p1 = iDb; @@ -1747,9 +1747,9 @@ void sqlite3Pragma( { OP_ResultRow, 1, 1, 0} }; VdbeOp *aOp; - sqlite3VdbeVerifyAvailableSpace(v, ArraySize(readCookie)); + sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(readCookie)); aOp = sqlite3VdbeAddOpList(v, ArraySize(readCookie),readCookie,0); - assert( aOp!=0 ); + if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break; aOp[0].p1 = iDb; aOp[1].p1 = iDb; aOp[1].p3 = iCookie; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index a70b0cfb36..5d8a504f87 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -402,6 +402,21 @@ # define NEVER(X) (X) #endif +/* +** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is +** defined. We need to defend against those failures when testing with +** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches +** during a normal build. The following macro can be used to disable tests +** that are always false except when SQLITE_TEST_REALLOC_STRESS is set. +*/ +#if defined(SQLITE_TEST_REALLOC_STRESS) +# define ONLY_IF_REALLOC_STRESS(X) (X) +#elif !defined(NDEBUG) +# define ONLY_IF_REALLOC_STRESS(X) ((X)?(assert(0),1):0) +#else +# define ONLY_IF_REALLOC_STRESS(X) (0) +#endif + /* ** Declarations used for tracing the operating system interfaces. */ diff --git a/src/vdbe.h b/src/vdbe.h index a0ff16d891..f09997bf94 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -180,10 +180,10 @@ int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int); int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); -#ifdef SQLITE_DEBUG - void sqlite3VdbeVerifyAvailableSpace(Vdbe *p, int N); +#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS) + void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N); #else -# define sqlite3VdbeVerifyAvailableSpace(A,B) +# define sqlite3VdbeVerifyNoMallocRequired(A,B) #endif VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno); void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 9859054ba4..492a41599b 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -607,11 +607,14 @@ int sqlite3VdbeCurrentAddr(Vdbe *p){ /* ** Verify that at least N opcode slots are available in p without -** having to malloc for more space. This interface is used for -** testing only. +** having to malloc for more space (except when compiled using +** SQLITE_TEST_REALLOC_STRESS). This interface is used during testing +** to verify that certain calls to sqlite3VdbeAddOpList() can never +** fail due to a OOM fault and hence that the return value from +** sqlite3VdbeAddOpList() will always be non-NULL. */ -#ifdef SQLITE_DEBUG -void sqlite3VdbeVerifyAvailableSpace(Vdbe *p, int N){ +#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS) +void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N){ assert( p->nOp + N <= p->pParse->nOpAlloc ); } #endif From e617bc8c0cad70a2237f1f9d5870d62314000831 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 18 Jan 2016 00:46:11 +0000 Subject: [PATCH 210/232] Simplification of the VDBE bytecode for incremental blob I/O. FossilOrigin-Name: d23849f64a110e336f26282bf2b961a2a2372468 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeblob.c | 36 ++++++++++++++++++------------------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 1042db4582..15c1cd6f7b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sSQLITE_TEST_REALLOC_STRESS. -D 2016-01-18T00:20:26.450 +C Simplification\sof\sthe\sVDBE\sbytecode\sfor\sincremental\sblob\sI/O. +D 2016-01-18T00:46:11.199 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -413,7 +413,7 @@ F src/vdbe.h 7a733ea8aac1b77305a67698e784fa3484ee3337 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e F src/vdbeaux.c 95e067a5e2a75e128d45ca597388dc83c58142f0 -F src/vdbeblob.c 8542f282b58293bd61c2ea4b2125f250f4fc9543 +F src/vdbeblob.c 37c3d11a753e403698c69e17383d282e1ae73e75 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0 @@ -1417,7 +1417,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 61deab043dcea860070dba6b02601a7de627fff1 -R 4379f64b4cb45ea0db7a5f863224d3f6 +P 0aaf3febb00f622c5ef0853b2491d69f7ca7a21e +R 8210381425f8a73bf29afce4a64c9930 U drh -Z e0f8e155ee8f1f04cd4cfaa23a1af003 +Z 0317022cefd345ebef2be02c7eb84046 diff --git a/manifest.uuid b/manifest.uuid index 37eeb2a0f1..e7a7e7b187 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0aaf3febb00f622c5ef0853b2491d69f7ca7a21e \ No newline at end of file +d23849f64a110e336f26282bf2b961a2a2372468 \ No newline at end of file diff --git a/src/vdbeblob.c b/src/vdbeblob.c index e5f08ce933..f9015ad6f4 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -249,19 +249,19 @@ int sqlite3_blob_open( ** which closes the b-tree cursor and (possibly) commits the ** transaction. */ - static const int iLn = VDBE_OFFSET_LINENO(3); + static const int iLn = VDBE_OFFSET_LINENO(4); static const VdbeOpList openBlob[] = { - /* {OP_Transaction, 0, 0, 0}, // inserted separately */ - {OP_TableLock, 0, 0, 0}, /* 0: Acquire a read or write lock */ - {OP_OpenRead, 0, 0, 0}, /* 1: Open cursor 0 for reading */ - {OP_OpenWrite, 0, 0, 0}, /* 2: Open cursor 0 for read/write */ - {OP_Variable, 1, 1, 1}, /* 3: Push the rowid to the stack */ - {OP_NotExists, 0, 10, 1}, /* 4: Seek the cursor */ - {OP_Column, 0, 0, 1}, /* 5 */ - {OP_ResultRow, 1, 0, 0}, /* 6 */ - {OP_Goto, 0, 4, 0}, /* 7 */ - {OP_Close, 0, 0, 0}, /* 8 */ - {OP_Halt, 0, 0, 0}, /* 9 */ + /* addr/ofst */ + /* {OP_Transaction, 0, 0, 0}, // 0/ inserted separately */ + {OP_TableLock, 0, 0, 0}, /* 1/0: Acquire a read or write lock */ + {OP_OpenRead, 0, 0, 0}, /* 2/1: Open a cursor */ + {OP_Variable, 1, 1, 0}, /* 3/2: Move ?1 into reg[1] */ + {OP_NotExists, 0, 8, 1}, /* 4/3: Seek the cursor */ + {OP_Column, 0, 0, 1}, /* 5/4 */ + {OP_ResultRow, 1, 0, 0}, /* 6/5 */ + {OP_Goto, 0, 3, 0}, /* 7/6 */ + {OP_Close, 0, 0, 0}, /* 8/7 */ + {OP_Halt, 0, 0, 0}, /* 9/8 */ }; Vdbe *v = (Vdbe *)pBlob->pStmt; int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); @@ -292,9 +292,9 @@ int sqlite3_blob_open( /* Remove either the OP_OpenWrite or OpenRead. Set the P2 ** parameter of the other to pTab->tnum. */ - aOp[2-flags].opcode = OP_Noop; - aOp[1+flags].p2 = pTab->tnum; - aOp[1+flags].p3 = iDb; + if( flags ) aOp[1].opcode = OP_OpenWrite; + aOp[1].p2 = pTab->tnum; + aOp[1].p3 = iDb; /* Configure the number of columns. Configure the cursor to ** think that the table has one more column than it really @@ -303,9 +303,9 @@ int sqlite3_blob_open( ** we can invoke OP_Column to fill in the vdbe cursors type ** and offset cache without causing any IO. */ - aOp[1+flags].p4type = P4_INT32; - aOp[1+flags].p4.i = pTab->nCol+1; - aOp[5].p2 = pTab->nCol; + aOp[1].p4type = P4_INT32; + aOp[1].p4.i = pTab->nCol+1; + aOp[4].p2 = pTab->nCol; pParse->nVar = 1; pParse->nMem = 1; From 0536a07c0efb1b3bf3ba3371ede382d129d1bad4 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 18 Jan 2016 09:08:56 +0000 Subject: [PATCH 211/232] Add a debugging function to print human-readable versions of fts5 detail=none leaf pages. FossilOrigin-Name: 8358af3658d888516cdef5f8c8d89e9bdee53f91 --- ext/fts5/fts5_index.c | 98 ++++++++++++++++++++++++++++++++++ ext/fts5/test/fts5_common.tcl | 6 +++ ext/fts5/test/fts5simple2.test | 20 +++++-- manifest | 18 +++---- manifest.uuid | 2 +- 5 files changed, 130 insertions(+), 14 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index d5ea972414..3d4488aedf 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -5904,6 +5904,47 @@ static int fts5DecodeDoclist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){ return iOff; } +/* +** This function is part of the fts5_decode() debugging function. It is +** only ever used with detail=none tables. +** +** Buffer (pData/nData) contains a doclist in the format used by detail=none +** tables. This function appends a human-readable version of that list to +** buffer pBuf. +** +** If *pRc is other than SQLITE_OK when this function is called, it is a +** no-op. If an OOM or other error occurs within this function, *pRc is +** set to an SQLite error code before returning. The final state of buffer +** pBuf is undefined in this case. +*/ +static void fts5DecodeRowidList( + int *pRc, /* IN/OUT: Error code */ + Fts5Buffer *pBuf, /* Buffer to append text to */ + const u8 *pData, int nData /* Data to decode list-of-rowids from */ +){ + int i = 0; + i64 iRowid = 0; + + while( i Date: Mon, 18 Jan 2016 13:18:54 +0000 Subject: [PATCH 212/232] Avoid unnecessary calls to memset() for a small performance improvement. FossilOrigin-Name: 9e8c23acf74944a165c733682a956948b15bd401 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/build.c | 3 ++- src/expr.c | 3 ++- src/select.c | 5 +++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 0405b4eb80..17430c5423 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sdebugging\sfunction\sto\sprint\shuman-readable\sversions\sof\sfts5\sdetail=none\sleaf\spages. -D 2016-01-18T09:08:56.841 +C Avoid\sunnecessary\scalls\sto\smemset()\sfor\sa\ssmall\sperformance\simprovement. +D 2016-01-18T13:18:54.021 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -289,14 +289,14 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c d9c6b2e2df06314079aa582f12937401a62171a6 F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c 59783188d873daf92150cc1a1caad55496839e8f +F src/build.c 31af80bba31ac159967951ef58f3144cc7db9d70 F src/callback.c 29ae4faba226c7ebb9aee93016b5ce8a8f071261 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c 997651e3ee6c2818fbf7fcdb7156cef9eb3ece20 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c 9a1a4150864f002b633d12f170a4114c28bbe94d +F src/expr.c df0d7c3230d59abd679da22ff5ce4cfd0e3a0e63 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e18b3dff7d47c7bcac5ac4fc178a89b9fd322b44 F src/func.c ccaf46fa98f795673afbfab73dff7c18db88f3cd @@ -343,7 +343,7 @@ F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 08dbe0292b24abc79b0c55ea97368e8a6bd235ec F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c 5b0f2aa9f73ec7b65d1711d485471854d5bad23c +F src/select.c 718954db86277d696c520fe671148db1e9c4ed3c F src/shell.c dcd7a83645ef2a58ee9c6d0ea4714d877d7835c4 F src/sqlite.h.in 214476a62012e578f42133a9a3b4f97a9aa421a3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad @@ -1417,7 +1417,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d23849f64a110e336f26282bf2b961a2a2372468 -R 31b95f2f1604722a026be65030bac1ab -U dan -Z d8bcb32855d826aa490c728ca6c213ac +P 8358af3658d888516cdef5f8c8d89e9bdee53f91 +R c9824fbd0634badf7e3856a23bc7d527 +U drh +Z 3a50e6364ad5d43622d6dbbf0015cd45 diff --git a/manifest.uuid b/manifest.uuid index 99374d367c..f39ceaa8a5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8358af3658d888516cdef5f8c8d89e9bdee53f91 \ No newline at end of file +9e8c23acf74944a165c733682a956948b15bd401 \ No newline at end of file diff --git a/src/build.c b/src/build.c index f592bb131c..f7074ab417 100644 --- a/src/build.c +++ b/src/build.c @@ -3710,9 +3710,10 @@ SrcList *sqlite3SrcListAppend( struct SrcList_item *pItem; assert( pDatabase==0 || pTable!=0 ); /* Cannot have C without B */ if( pList==0 ){ - pList = sqlite3DbMallocZero(db, sizeof(SrcList) ); + pList = sqlite3DbMallocRaw(db, sizeof(SrcList) ); if( pList==0 ) return 0; pList->nAlloc = 1; + pList->nSrc = 0; } pList = sqlite3SrcListEnlarge(db, pList, 1, pList->nSrc); if( db->mallocFailed ){ diff --git a/src/expr.c b/src/expr.c index b8cf3f7720..403e81cf34 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1135,10 +1135,11 @@ ExprList *sqlite3ExprListAppend( ){ sqlite3 *db = pParse->db; if( pList==0 ){ - pList = sqlite3DbMallocZero(db, sizeof(ExprList) ); + pList = sqlite3DbMallocRaw(db, sizeof(ExprList) ); if( pList==0 ){ goto no_mem; } + pList->nExpr = 0; pList->a = sqlite3DbMallocRaw(db, sizeof(pList->a[0])); if( pList->a==0 ) goto no_mem; }else if( (pList->nExpr & (pList->nExpr-1))==0 ){ diff --git a/src/select.c b/src/select.c index fd094d05dd..9eb6279c10 100644 --- a/src/select.c +++ b/src/select.c @@ -1005,8 +1005,8 @@ static void selectInnerLoop( ** X extra columns. */ KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){ - KeyInfo *p = sqlite3DbMallocZero(0, - sizeof(KeyInfo) + (N+X)*(sizeof(CollSeq*)+1)); + int nExtra = (N+X)*(sizeof(CollSeq*)+1); + KeyInfo *p = sqlite3Malloc(sizeof(KeyInfo) + nExtra); if( p ){ p->aSortOrder = (u8*)&p->aColl[N+X]; p->nField = (u16)N; @@ -1014,6 +1014,7 @@ KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){ p->enc = ENC(db); p->db = db; p->nRef = 1; + memset(&p[1], 0, nExtra); }else{ db->mallocFailed = 1; } From 6d3c2889ece6eddcc4df1bd4af0eef7151e4e660 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 18 Jan 2016 17:48:28 +0000 Subject: [PATCH 213/232] Add tests for fts5. Fix a crash that can occur in fts5 if the database content is corrupted. FossilOrigin-Name: acaf426449bf6fd3140fd63141750ff69d1119a5 --- ext/fts5/fts5Int.h | 8 ++--- ext/fts5/fts5_buffer.c | 8 ++--- ext/fts5/fts5_expr.c | 2 +- ext/fts5/fts5_index.c | 8 ++--- ext/fts5/test/fts5merge2.test | 59 +++++++++++++++++++++++++++++++++++ ext/fts5/test/fts5rowid.test | 27 ++++++++++++++++ manifest | 23 +++++++------- manifest.uuid | 2 +- 8 files changed, 112 insertions(+), 25 deletions(-) create mode 100644 ext/fts5/test/fts5merge2.test diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index ee953c399c..b2f0d6c34e 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -225,13 +225,13 @@ int sqlite3Fts5ConfigParseRank(const char*, char**, char**); typedef struct Fts5Buffer Fts5Buffer; struct Fts5Buffer { u8 *p; - int n; - int nSpace; + u32 n; + u32 nSpace; }; -int sqlite3Fts5BufferSize(int*, Fts5Buffer*, int); +int sqlite3Fts5BufferSize(int*, Fts5Buffer*, u32); void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64); -void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, int, const u8*); +void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, u32, const u8*); void sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*); void sqlite3Fts5BufferFree(Fts5Buffer*); void sqlite3Fts5BufferZero(Fts5Buffer*); diff --git a/ext/fts5/fts5_buffer.c b/ext/fts5/fts5_buffer.c index 8558687d8a..94591188d3 100644 --- a/ext/fts5/fts5_buffer.c +++ b/ext/fts5/fts5_buffer.c @@ -15,8 +15,8 @@ #include "fts5Int.h" -int sqlite3Fts5BufferSize(int *pRc, Fts5Buffer *pBuf, int nByte){ - int nNew = pBuf->nSpace ? pBuf->nSpace*2 : 64; +int sqlite3Fts5BufferSize(int *pRc, Fts5Buffer *pBuf, u32 nByte){ + u32 nNew = pBuf->nSpace ? pBuf->nSpace*2 : 64; u8 *pNew; while( nNew=0 ); + assert_nc( *pRc || nData>=0 ); if( fts5BufferGrow(pRc, pBuf, nData) ) return; memcpy(&pBuf->p[pBuf->n], pData, nData); pBuf->n += nData; diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 7a433b69a0..c51ed7939c 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -834,7 +834,7 @@ static int fts5ExprTokenTest( assert( pPhrase->aTerm[0].pSynonym==0 ); rc = sqlite3Fts5IterPoslist(pIter, pColset, - (const u8**)&pPhrase->poslist.p, &pPhrase->poslist.n, &pNode->iRowid + (const u8**)&pPhrase->poslist.p, (int*)&pPhrase->poslist.n, &pNode->iRowid ); pNode->bNomatch = (pPhrase->poslist.n==0); return rc; diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 3d4488aedf..fc11a23413 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -6014,7 +6014,7 @@ static void fts5DecodeFunction( /* Decode any entries that occur before the first term. */ if( szLeaf Date: Tue, 19 Jan 2016 16:06:23 +0000 Subject: [PATCH 214/232] Add further fts5 tests. 100% code coverage is finally restored. FossilOrigin-Name: b914ece0d146cfc8adba4dc4e8633e14f174d6ea --- ext/fts5/test/fts5_common.tcl | 5 +++ ext/fts5/test/fts5bigtok.test | 67 ++++++++++++++++++++++++++++++++ ext/fts5/test/fts5integrity.test | 61 ++++++++++++++++++++++++++++- ext/fts5/test/fts5rowid.test | 8 +++- manifest | 17 ++++---- manifest.uuid | 2 +- 6 files changed, 148 insertions(+), 12 deletions(-) create mode 100644 ext/fts5/test/fts5bigtok.test diff --git a/ext/fts5/test/fts5_common.tcl b/ext/fts5/test/fts5_common.tcl index 4768a3a69b..e7c61af00c 100644 --- a/ext/fts5/test/fts5_common.tcl +++ b/ext/fts5/test/fts5_common.tcl @@ -15,6 +15,11 @@ if {![info exists testdir]} { } source $testdir/tester.tcl +ifcapable !fts5 { + finish_test + return +} + catch { sqlite3_fts5_may_be_corrupt 0 reset_db diff --git a/ext/fts5/test/fts5bigtok.test b/ext/fts5/test/fts5bigtok.test new file mode 100644 index 0000000000..2267be5058 --- /dev/null +++ b/ext/fts5/test/fts5bigtok.test @@ -0,0 +1,67 @@ +# 2016 Jan 19 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# This file implements regression tests for SQLite library. The +# focus of this script is testing the FTS5 module. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5bigtok + +proc rndterm {} { + set L [list a b c d e f g h i j k l m n o p q r s t u v w x y z] + set l [lindex $L [expr int(rand() * [llength $L])]] + string repeat $l [expr int(rand() * 5) + 60] +} + +proc rnddoc {n} { + set res [list] + for {set i 0} {$i < $n} {incr i} { + lappend res [rndterm] + } + set res +} + +foreach_detail_mode $::testprefix { + db func rnddoc rnddoc + do_execsql_test 1.0 { + CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%); + INSERT INTO t1(t1, rank) VALUES('pgsz', 32); + CREATE VIRTUAL TABLE t1vocab USING fts5vocab(t1, row); + + WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 ) + INSERT INTO t1 SELECT rnddoc(3) FROM s; + + WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 ) + INSERT INTO t1 SELECT rnddoc(3) FROM s; + } + + foreach v [db eval {SELECT term FROM t1vocab}] { + set res [db eval {SELECT rowid FROM t1($v)}] + do_execsql_test 1.[string range $v 0 0] { + SELECT rowid FROM t1($v) ORDER BY rowid DESC + } [lsort -integer -decr $res] + } + + do_execsql_test 2.0 { + INSERT INTO t1(t1) VALUES('optimize'); + } + + foreach v [db eval {SELECT term FROM t1vocab}] { + set res [db eval {SELECT rowid FROM t1($v)}] + do_execsql_test 2.[string range $v 0 0] { + SELECT rowid FROM t1($v) ORDER BY rowid DESC + } [lsort -integer -decr $res] + } +} + +finish_test + + diff --git a/ext/fts5/test/fts5integrity.test b/ext/fts5/test/fts5integrity.test index 84490e0cb4..37ca9331dd 100644 --- a/ext/fts5/test/fts5integrity.test +++ b/ext/fts5/test/fts5integrity.test @@ -145,10 +145,69 @@ do_execsql_test 5.2 { INSERT INTO gg(gg) VALUES('optimize'); } -breakpoint do_execsql_test 5.3 { INSERT INTO gg(gg) VALUES('integrity-check'); } +do_test 5.4.1 { + set ok 0 + for {set i 0} {$i < 10000} {incr i} { + set T [format %.5d $i] + set res [db eval { SELECT rowid FROM gg($T) ORDER BY rowid ASC }] + set res2 [db eval { SELECT rowid FROM gg($T) ORDER BY rowid DESC }] + if {$res == [lsort -integer $res2]} { incr ok } + } + set ok +} {10000} + +do_test 5.4.2 { + set ok 0 + for {set i 0} {$i < 100} {incr i} { + set T "[format %.3d $i]*" + set res [db eval { SELECT rowid FROM gg($T) ORDER BY rowid ASC }] + set res2 [db eval { SELECT rowid FROM gg($T) ORDER BY rowid DESC }] + if {$res == [lsort -integer $res2]} { incr ok } + } + set ok +} {100} + +#------------------------------------------------------------------------- +# Similar to 5.*. +# +foreach {tn pgsz} { + 1 32 + 2 36 + 3 40 + 4 44 + 5 48 +} { + do_execsql_test 6.$tn.1 { + DROP TABLE IF EXISTS hh; + CREATE VIRTUAL TABLE hh USING fts5(y); + INSERT INTO hh(hh, rank) VALUES('pgsz', $pgsz); + + WITH s(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<999) + INSERT INTO hh SELECT printf("%.3d%.3d%.3d %.3d%.3d%.3d",i,i,i,i+1,i+1,i+1) + FROM s; + + WITH s(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<999) + INSERT INTO hh SELECT printf("%.3d%.3d%.3d %.3d%.3d%.3d",i,i,i,i+1,i+1,i+1) + FROM s; + + INSERT INTO hh(hh) VALUES('optimize'); + } + + do_test 6.$tn.2 { + set ok 0 + for {set i 0} {$i < 1000} {incr i} { + set T [format %.3d%.3d%.3d $i $i $i] + set res [db eval { SELECT rowid FROM hh($T) ORDER BY rowid ASC }] + set res2 [db eval { SELECT rowid FROM hh($T) ORDER BY rowid DESC }] + if {$res == [lsort -integer $res2]} { incr ok } + } + set ok + } {1000} +} + finish_test diff --git a/ext/fts5/test/fts5rowid.test b/ext/fts5/test/fts5rowid.test index 13a075e0bc..19590cdf0d 100644 --- a/ext/fts5/test/fts5rowid.test +++ b/ext/fts5/test/fts5rowid.test @@ -202,8 +202,12 @@ do_execsql_test 6.0 { } {32} do_execsql_test 6.1 { - DELETE FROM x5 WHERE rowid=1; - UPDATE x5 SET x='a b c d e f' WHERE rowid=2; + DELETE FROM x5 WHERE rowid <= 2; + SELECT count(fts5_decode_none(rowid, block)) FROM x5_data; +} {34} + +do_execsql_test 6.2 { + UPDATE x5 SET x='a b c d e f' WHERE rowid=3; SELECT count(fts5_decode_none(rowid, block)) FROM x5_data; } {36} diff --git a/manifest b/manifest index cdd417e773..a92d3b5535 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sfor\sfts5.\sFix\sa\scrash\sthat\scan\soccur\sin\sfts5\sif\sthe\sdatabase\scontent\sis\scorrupted. -D 2016-01-18T17:48:28.938 +C Add\sfurther\sfts5\stests.\s100%\scode\scoverage\sis\sfinally\srestored. +D 2016-01-19T16:06:23.776 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -115,7 +115,7 @@ F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c ee6df1a3be103414d7b7af833ae1885c7b83a9d0 F ext/fts5/fts5parse.y 1647eba089b9b3fc058b4dc989d9da87d15b9580 F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba -F ext/fts5/test/fts5_common.tcl cf6392ed5bd3e1e2c9eaff6a6409d9f0cfcc1efa +F ext/fts5/test/fts5_common.tcl 6d0d74b695c4be055a8ba1dd807f22a2abc95b5e F ext/fts5/test/fts5aa.test 7e814df4a0e6c22a6fe2d84f210fdc0b5068a084 F ext/fts5/test/fts5ab.test 30325a89453280160106be411bba3acf138e6d1b F ext/fts5/test/fts5ac.test d5073ca7bd2d9fe8aab0c82c6c75a7e4b0d70ced @@ -133,6 +133,7 @@ F ext/fts5/test/fts5auto.test 401c20e89f1114d733b94809be1e6f893e16c09e F ext/fts5/test/fts5aux.test 8c687c948cc98e9a94be014df7d518acc1b3b74f F ext/fts5/test/fts5auxdata.test 141a7cbffcceb1bd2799b4b29c183ff8780d586e F ext/fts5/test/fts5bigpl.test 04ee0d7eebbebf17c31f5a0b5c5f9494eac3a0cb +F ext/fts5/test/fts5bigtok.test 981b2790f6fa02773c889bd35d42c6b97f80f0f4 F ext/fts5/test/fts5columnsize.test a8cfef21ffa1c264b9f670a7d94eeaccb5341c07 F ext/fts5/test/fts5config.test 83941309b94d002ed6f55d9cd814e0353c9ae013 F ext/fts5/test/fts5conflict.test 26f4e46c4d31e16221794832a990dc4e30e18de5 @@ -156,7 +157,7 @@ F ext/fts5/test/fts5fault8.test f2d8a2b673a5f72ca1fa0e85bdbfb2041ffd347d F ext/fts5/test/fts5fault9.test e10e395428a9ea0596ebe752ff7123d16ab78e08 F ext/fts5/test/fts5full.test 6f6143af0c6700501d9fd597189dfab1555bb741 F ext/fts5/test/fts5hash.test 00668f6fa9b9bffbd7c1be29f408aa2bdade0451 -F ext/fts5/test/fts5integrity.test 87db5d4e7da0ce04a1dcba5ba91658673c997a65 +F ext/fts5/test/fts5integrity.test f5e4f8d284385875068ad0f3e894ce43e9de835d F ext/fts5/test/fts5matchinfo.test 86569026d20f1ed748236587ce798de8a96615f1 F ext/fts5/test/fts5merge.test 8f3cdba2ec9c5e7e568246e81b700ad37f764367 F ext/fts5/test/fts5merge2.test c0cb66eb38a41c26cc5848fb9e50093e0f59ac93 @@ -172,7 +173,7 @@ F ext/fts5/test/fts5query.test f5ec25f5f2fbb70033424113cdffc101b1985a40 F ext/fts5/test/fts5rank.test 7e9e64eac7245637f6f2033aec4b292aaf611aab F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 -F ext/fts5/test/fts5rowid.test 42de27109d2f6091108bf27097b105cb7e34f492 +F ext/fts5/test/fts5rowid.test 16908a99d6efc9ba21081b4f2b86b3fc699839a6 F ext/fts5/test/fts5simple.test 2bc6451cbe887a9215f5b14ae307c70d850344c9 F ext/fts5/test/fts5simple2.test 98377ae1ff7749a42c21fe1a139c1ed312522c46 F ext/fts5/test/fts5synonym.test 6475d189c2e20d60795808f83e36bf9318708d48 @@ -1418,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9e8c23acf74944a165c733682a956948b15bd401 -R 08e65f545f5743a4e11b0d8939a59f80 +P acaf426449bf6fd3140fd63141750ff69d1119a5 +R d08b3552b8f27561f27085942ba60d34 U dan -Z 3083046e1d22f6a7fb73cbf36ab37bf0 +Z 7a4ceb8872d3ff383d019f72843d63a3 diff --git a/manifest.uuid b/manifest.uuid index 102b730d6e..0f9bae7512 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -acaf426449bf6fd3140fd63141750ff69d1119a5 \ No newline at end of file +b914ece0d146cfc8adba4dc4e8633e14f174d6ea \ No newline at end of file From b8763639bbef1f0f01cb83c4ac98eb9ff1827b96 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Jan 2016 17:54:21 +0000 Subject: [PATCH 215/232] Fix two harmless compiler warnings about comparisons of dangling pointers. FossilOrigin-Name: 86944f193f1f06b64471953bb5713ecea7f3d803 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/vdbeaux.c | 2 +- src/whereexpr.c | 4 +++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index a92d3b5535..4f8ac4d9b8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sfurther\sfts5\stests.\s100%\scode\scoverage\sis\sfinally\srestored. -D 2016-01-19T16:06:23.776 +C Fix\stwo\sharmless\scompiler\swarnings\sabout\scomparisons\sof\sdangling\spointers. +D 2016-01-19T17:54:21.554 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -414,7 +414,7 @@ F src/vdbe.c b90d9d38e5e0260c2eafa3cb4c2274d8ea94da27 F src/vdbe.h 7a733ea8aac1b77305a67698e784fa3484ee3337 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e -F src/vdbeaux.c 95e067a5e2a75e128d45ca597388dc83c58142f0 +F src/vdbeaux.c fcbca1519bdfe619edf2e95b64aad8e7b718494c F src/vdbeblob.c 37c3d11a753e403698c69e17383d282e1ae73e75 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 @@ -427,7 +427,7 @@ F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c bb69654f841ae7af0a20cc6fb8f0ac57901c31be F src/whereInt.h 78b6b4de94db84aecbdc07fe3e38f648eb391e9a F src/wherecode.c 8dee26eb181ea9daa8b1a4d96f34c0860aaf99bd -F src/whereexpr.c eebba8340c90de73b3d3bbe8c43b84559b8e6e2c +F src/whereexpr.c 197a448b52073aee43eca3a2233fc113369eb2d4 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P acaf426449bf6fd3140fd63141750ff69d1119a5 -R d08b3552b8f27561f27085942ba60d34 -U dan -Z 7a4ceb8872d3ff383d019f72843d63a3 +P b914ece0d146cfc8adba4dc4e8633e14f174d6ea +R 3e5d796fe259d88063a5203a70f6d659 +U drh +Z 42379f3c18aeff0e63b7fa93d55446fd diff --git a/manifest.uuid b/manifest.uuid index 0f9bae7512..5fc95f9db8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b914ece0d146cfc8adba4dc4e8633e14f174d6ea \ No newline at end of file +86944f193f1f06b64471953bb5713ecea7f3d803 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 492a41599b..7cce57a738 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3655,9 +3655,9 @@ static int vdbeCompareMemString( v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc); n2 = v2==0 ? 0 : c2.n; rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2); + if( (v1==0 || v2==0) && prcErr ) *prcErr = SQLITE_NOMEM; sqlite3VdbeMemRelease(&c1); sqlite3VdbeMemRelease(&c2); - if( (v1==0 || v2==0) && prcErr ) *prcErr = SQLITE_NOMEM; return rc; } } diff --git a/src/whereexpr.c b/src/whereexpr.c index 99a97079be..e0b8bac1b7 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -202,6 +202,7 @@ static int isLikeOrGlob( sqlite3 *db = pParse->db; /* Database connection */ sqlite3_value *pVal = 0; int op; /* Opcode of pRight */ + int rc; /* Result code to return */ if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){ return 0; @@ -267,8 +268,9 @@ static int isLikeOrGlob( } } + rc = (z!=0); sqlite3ValueFree(pVal); - return (z!=0); + return rc; } #endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */ From e40cf40c1a56dfd10b5d16db11135f5f0612a9c4 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Jan 2016 21:36:26 +0000 Subject: [PATCH 216/232] Fix an incorrect VFS version number check in the threadtest3.c test program. FossilOrigin-Name: 5bf6442bec83977006bc5049adcdbd4dd39369fe --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/threadtest3.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4f8ac4d9b8..46e63fc992 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stwo\sharmless\scompiler\swarnings\sabout\scomparisons\sof\sdangling\spointers. -D 2016-01-19T17:54:21.554 +C Fix\san\sincorrect\sVFS\sversion\snumber\scheck\sin\sthe\sthreadtest3.c\stest\sprogram. +D 2016-01-19T21:36:26.548 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -1084,7 +1084,7 @@ F test/thread2.test f35d2106452b77523b3a2b7d1dcde2e5ee8f9e46 F test/thread_common.tcl 334639cadcb9f912bf82aa73f49efd5282e6cadd F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b F test/threadtest2.c a70a8e94bef23339d34226eb9521015ef99f4df8 -F test/threadtest3.c 7ca82330041456afa52e4968196bb0867371f91b +F test/threadtest3.c 38a612ea62854349ed66372f330a40d73c5cf956 F test/threadtest4.c c1e67136ceb6c7ec8184e56ac61db28f96bd2925 F test/tkt-02a8e81d44.test 6c80d9c7514e2a42d4918bf87bf6bc54f379110c F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b914ece0d146cfc8adba4dc4e8633e14f174d6ea -R 3e5d796fe259d88063a5203a70f6d659 +P 86944f193f1f06b64471953bb5713ecea7f3d803 +R 1bd8149c5e96ca5f6729d165e7caff84 U drh -Z 42379f3c18aeff0e63b7fa93d55446fd +Z 65f48ec6556e690748ae351a1c163375 diff --git a/manifest.uuid b/manifest.uuid index 5fc95f9db8..3dd90a8dcc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -86944f193f1f06b64471953bb5713ecea7f3d803 \ No newline at end of file +5bf6442bec83977006bc5049adcdbd4dd39369fe \ No newline at end of file diff --git a/test/threadtest3.c b/test/threadtest3.c index 8d213c61f1..6062b64285 100644 --- a/test/threadtest3.c +++ b/test/threadtest3.c @@ -880,7 +880,7 @@ static double currentTime(void){ double t; static sqlite3_vfs *pTimelimitVfs = 0; if( pTimelimitVfs==0 ) pTimelimitVfs = sqlite3_vfs_find(0); - if( pTimelimitVfs->iVersion>=1 && pTimelimitVfs->xCurrentTimeInt64!=0 ){ + if( pTimelimitVfs->iVersion>=2 && pTimelimitVfs->xCurrentTimeInt64!=0 ){ sqlite3_int64 tm; pTimelimitVfs->xCurrentTimeInt64(pTimelimitVfs, &tm); t = tm/86400000.0; From 36b78ee7d8d23cebaffb3d92da28adbdb94a90d3 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 20 Jan 2016 01:32:00 +0000 Subject: [PATCH 217/232] Very small simplification to the btree balancer. FossilOrigin-Name: f421adf54c9db91ba6ca64a8ba3751680e47924a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 46e63fc992..da7d7696b2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sincorrect\sVFS\sversion\snumber\scheck\sin\sthe\sthreadtest3.c\stest\sprogram. -D 2016-01-19T21:36:26.548 +C Very\ssmall\ssimplification\sto\sthe\sbtree\sbalancer. +D 2016-01-20T01:32:00.028 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -288,7 +288,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 -F src/btree.c d9c6b2e2df06314079aa582f12937401a62171a6 +F src/btree.c f224ae877fde69d1a9d430f502edaf8502752dbe F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 31af80bba31ac159967951ef58f3144cc7db9d70 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 86944f193f1f06b64471953bb5713ecea7f3d803 -R 1bd8149c5e96ca5f6729d165e7caff84 +P 5bf6442bec83977006bc5049adcdbd4dd39369fe +R 70eccaeca6a4cd2462229055942e9f5d U drh -Z 65f48ec6556e690748ae351a1c163375 +Z 7b4de528ceedb108b3157672b1895b78 diff --git a/manifest.uuid b/manifest.uuid index 3dd90a8dcc..804b1f705d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5bf6442bec83977006bc5049adcdbd4dd39369fe \ No newline at end of file +f421adf54c9db91ba6ca64a8ba3751680e47924a \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index eb0808f1d9..4e6f6478af 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7186,9 +7186,8 @@ static int balance_nonroot( ** long be able to find the cells if a pointer to each cell is not saved ** first. */ - memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*limit); + memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow)); if( pOld->nOverflow>0 ){ - memset(&b.szCell[b.nCell+limit], 0, sizeof(b.szCell[0])*pOld->nOverflow); limit = pOld->aiOvfl[0]; for(j=0; j Date: Wed, 20 Jan 2016 01:48:25 +0000 Subject: [PATCH 218/232] During compilation, transfer the azVar[0..nzVar-1] array from Parse to Vdbe rather than copying it. Smaller and faster code. FossilOrigin-Name: 80dd495f378614e4eca72e71e43061b1b94ee450 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- src/vdbeaux.c | 11 +++++------ 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index da7d7696b2..2bdfa7fcdd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Very\ssmall\ssimplification\sto\sthe\sbtree\sbalancer. -D 2016-01-20T01:32:00.028 +C During\scompilation,\stransfer\sthe\sazVar[0..nzVar-1]\sarray\sfrom\sParse\sto\sVdbe\nrather\sthan\scopying\sit.\s\sSmaller\sand\sfaster\scode. +D 2016-01-20T01:48:25.150 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -350,7 +350,7 @@ F src/shell.c dcd7a83645ef2a58ee9c6d0ea4714d877d7835c4 F src/sqlite.h.in 214476a62012e578f42133a9a3b4f97a9aa421a3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 8fbaf9dc2bb979865c739e5272fe0b352fbc709f +F src/sqliteInt.h 9c506d4bc748667c0ea74abd4f034124a4c9a0d1 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -414,7 +414,7 @@ F src/vdbe.c b90d9d38e5e0260c2eafa3cb4c2274d8ea94da27 F src/vdbe.h 7a733ea8aac1b77305a67698e784fa3484ee3337 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e -F src/vdbeaux.c fcbca1519bdfe619edf2e95b64aad8e7b718494c +F src/vdbeaux.c f53b709c4c0d8f80e51dbf343292564e8628e217 F src/vdbeblob.c 37c3d11a753e403698c69e17383d282e1ae73e75 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5bf6442bec83977006bc5049adcdbd4dd39369fe -R 70eccaeca6a4cd2462229055942e9f5d +P f421adf54c9db91ba6ca64a8ba3751680e47924a +R 0c5d0312a4aace8397299f6692596f42 U drh -Z 7b4de528ceedb108b3157672b1895b78 +Z ec44132b48754f37e54bd488e98f7a49 diff --git a/manifest.uuid b/manifest.uuid index 804b1f705d..1408be74b1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f421adf54c9db91ba6ca64a8ba3751680e47924a \ No newline at end of file +80dd495f378614e4eca72e71e43061b1b94ee450 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 5d8a504f87..6684953fd5 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2794,7 +2794,7 @@ struct Parse { ** in the recursive region. ************************************************************************/ - int nVar; /* Number of '?' variables seen in the SQL so far */ + ynVar nVar; /* Number of '?' variables seen in the SQL so far */ int nzVar; /* Number of available slots in azVar[] */ u8 iPkSortOrder; /* ASC or DESC for INTEGER PRIMARY KEY */ u8 explain; /* True if the EXPLAIN flag is found on the query */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 7cce57a738..cbb707d25a 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1897,7 +1897,6 @@ void sqlite3VdbeMakeReady( p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), zCsr, &nFree, &nByte); p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), zCsr, &nFree, &nByte); p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), zCsr, &nFree, &nByte); - p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), zCsr, &nFree, &nByte); p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*), zCsr, &nFree, &nByte); p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, zCsr, &nFree, &nByte); @@ -1920,11 +1919,10 @@ void sqlite3VdbeMakeReady( p->aVar[n].db = db; } } - if( p->azVar && pParse->nzVar>0 ){ - p->nzVar = pParse->nzVar; - memcpy(p->azVar, pParse->azVar, p->nzVar*sizeof(p->azVar[0])); - memset(pParse->azVar, 0, pParse->nzVar*sizeof(pParse->azVar[0])); - } + p->nzVar = pParse->nzVar; + p->azVar = pParse->azVar; + pParse->nzVar = 0; + pParse->azVar = 0; if( p->aMem ){ p->aMem--; /* aMem[] goes from 1..nMem */ p->nMem = nMem; /* not from 0..nMem-1 */ @@ -2911,6 +2909,7 @@ void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){ sqlite3DbFree(db, pSub); } for(i=p->nzVar-1; i>=0; i--) sqlite3DbFree(db, p->azVar[i]); + sqlite3DbFree(db, p->azVar); vdbeFreeOpArray(db, p->aOp, p->nOp); sqlite3DbFree(db, p->aColName); sqlite3DbFree(db, p->zSql); From 4b31bda2c5e446e6876c7e7e34c03aa676a0b7a3 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 20 Jan 2016 02:01:02 +0000 Subject: [PATCH 219/232] Remove an unnecessary memset() for a small size reduction and speed improvement. FossilOrigin-Name: 730d7efb6fef54ed7c1f4ae27e3b55778ea6ff01 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 2bdfa7fcdd..712e32918e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C During\scompilation,\stransfer\sthe\sazVar[0..nzVar-1]\sarray\sfrom\sParse\sto\sVdbe\nrather\sthan\scopying\sit.\s\sSmaller\sand\sfaster\scode. -D 2016-01-20T01:48:25.150 +C Remove\san\sunnecessary\smemset()\sfor\sa\ssmall\ssize\sreduction\sand\sspeed\simprovement. +D 2016-01-20T02:01:02.932 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -414,7 +414,7 @@ F src/vdbe.c b90d9d38e5e0260c2eafa3cb4c2274d8ea94da27 F src/vdbe.h 7a733ea8aac1b77305a67698e784fa3484ee3337 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e -F src/vdbeaux.c f53b709c4c0d8f80e51dbf343292564e8628e217 +F src/vdbeaux.c d34740a472662f9555c0cbb46bbfe323014ba0e5 F src/vdbeblob.c 37c3d11a753e403698c69e17383d282e1ae73e75 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f421adf54c9db91ba6ca64a8ba3751680e47924a -R 0c5d0312a4aace8397299f6692596f42 +P 80dd495f378614e4eca72e71e43061b1b94ee450 +R a035637148b8d47d70dffd1e7fd4febf U drh -Z ec44132b48754f37e54bd488e98f7a49 +Z c01377a6a12f63d2df1dc07be9d35345 diff --git a/manifest.uuid b/manifest.uuid index 1408be74b1..4ea4de6797 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -80dd495f378614e4eca72e71e43061b1b94ee450 \ No newline at end of file +730d7efb6fef54ed7c1f4ae27e3b55778ea6ff01 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index cbb707d25a..47ac9dd9f5 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -849,7 +849,7 @@ int sqlite3VdbeChangeToNoop(Vdbe *p, int addr){ assert( addr>=0 && addrnOp ); pOp = &p->aOp[addr]; freeP4(p->db, pOp->p4type, pOp->p4.p); - memset(pOp, 0, sizeof(pOp[0])); + pOp->p4type = P4_NOTUSED; pOp->opcode = OP_Noop; return 1; } From 9bfb024de09a48884c49e093ee07d2cb8e26574b Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 20 Jan 2016 02:21:50 +0000 Subject: [PATCH 220/232] Remove an unnecessary memset() from the symbol name resolver. FossilOrigin-Name: da527ddae06460ab4b706cdb871de2188ebaf5ac --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/resolve.c | 6 ++++-- src/sqliteInt.h | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 712e32918e..33c05175d0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunnecessary\smemset()\sfor\sa\ssmall\ssize\sreduction\sand\sspeed\simprovement. -D 2016-01-20T02:01:02.932 +C Remove\san\sunnecessary\smemset()\sfrom\sthe\ssymbol\sname\sresolver. +D 2016-01-20T02:21:50.387 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -343,14 +343,14 @@ F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 74855ddbdfad6a1c4a4d5c4b0913ebb01174ba19 F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 -F src/resolve.c 08dbe0292b24abc79b0c55ea97368e8a6bd235ec +F src/resolve.c 9f7ce3a3c087afb7597b7c916c99126ff3f12f0c F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c 718954db86277d696c520fe671148db1e9c4ed3c F src/shell.c dcd7a83645ef2a58ee9c6d0ea4714d877d7835c4 F src/sqlite.h.in 214476a62012e578f42133a9a3b4f97a9aa421a3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 9c506d4bc748667c0ea74abd4f034124a4c9a0d1 +F src/sqliteInt.h 8c1debffeeb1579bdc264d54c72c05892e23b7ee F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 80dd495f378614e4eca72e71e43061b1b94ee450 -R a035637148b8d47d70dffd1e7fd4febf +P 730d7efb6fef54ed7c1f4ae27e3b55778ea6ff01 +R 2a84d613eab09af872226a39d465de29 U drh -Z c01377a6a12f63d2df1dc07be9d35345 +Z a3f73fee0434b592305d171cd50a9012 diff --git a/manifest.uuid b/manifest.uuid index 4ea4de6797..8dcaaee610 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -730d7efb6fef54ed7c1f4ae27e3b55778ea6ff01 \ No newline at end of file +da527ddae06460ab4b706cdb871de2188ebaf5ac \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 97cb6556ac..81bb712a2e 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1393,10 +1393,12 @@ int sqlite3ResolveExprNames( #endif savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg); pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg); - memset(&w, 0, sizeof(w)); + w.pParse = pNC->pParse; w.xExprCallback = resolveExprStep; w.xSelectCallback = resolveSelectStep; - w.pParse = pNC->pParse; + w.xSelectCallback2 = 0; + w.walkerDepth = 0; + w.eCode = 0; w.u.pNC = pNC; sqlite3WalkExpr(&w, pExpr); #if SQLITE_MAX_EXPR_DEPTH>0 diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 6684953fd5..8ab59b4679 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3076,10 +3076,10 @@ struct Sqlite3Config { ** Context pointer passed down through the tree-walk. */ struct Walker { + Parse *pParse; /* Parser context. */ int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */ int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */ void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */ - Parse *pParse; /* Parser context. */ int walkerDepth; /* Number of subqueries */ u8 eCode; /* A small processing code */ union { /* Extra data for callback */ From 939e778bc86722fed16a6d85771e4b1794b8e81a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 20 Jan 2016 02:36:12 +0000 Subject: [PATCH 221/232] Suppress the display of the P4 operand in EXPLAIN output when an opcode has been converted into a No-op. FossilOrigin-Name: 9f8297f862a110ded686d091854fae20c6bc393c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 33c05175d0..c246f07bd4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunnecessary\smemset()\sfrom\sthe\ssymbol\sname\sresolver. -D 2016-01-20T02:21:50.387 +C Suppress\sthe\sdisplay\sof\sthe\sP4\soperand\sin\sEXPLAIN\soutput\swhen\san\sopcode\nhas\sbeen\sconverted\sinto\sa\sNo-op. +D 2016-01-20T02:36:12.461 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -414,7 +414,7 @@ F src/vdbe.c b90d9d38e5e0260c2eafa3cb4c2274d8ea94da27 F src/vdbe.h 7a733ea8aac1b77305a67698e784fa3484ee3337 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e -F src/vdbeaux.c d34740a472662f9555c0cbb46bbfe323014ba0e5 +F src/vdbeaux.c db67d3e0fcedced22bfeca47a567eb9df91b3495 F src/vdbeblob.c 37c3d11a753e403698c69e17383d282e1ae73e75 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 730d7efb6fef54ed7c1f4ae27e3b55778ea6ff01 -R 2a84d613eab09af872226a39d465de29 +P da527ddae06460ab4b706cdb871de2188ebaf5ac +R 9c350206cbc3ec71bedbf771eaad6af4 U drh -Z a3f73fee0434b592305d171cd50a9012 +Z d3ee680a30750cc9b6d539ba48a1436a diff --git a/manifest.uuid b/manifest.uuid index 8dcaaee610..4615528f3e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -da527ddae06460ab4b706cdb871de2188ebaf5ac \ No newline at end of file +9f8297f862a110ded686d091854fae20c6bc393c \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 47ac9dd9f5..d88fbac611 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -850,6 +850,7 @@ int sqlite3VdbeChangeToNoop(Vdbe *p, int addr){ pOp = &p->aOp[addr]; freeP4(p->db, pOp->p4type, pOp->p4.p); pOp->p4type = P4_NOTUSED; + pOp->p4.z = 0; pOp->opcode = OP_Noop; return 1; } From 1da26a48ddec0a3dbe8a99464f5171c0cb0354a7 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 20 Jan 2016 03:36:32 +0000 Subject: [PATCH 222/232] Performance improvement in sqlite3DbMallocRaw(). FossilOrigin-Name: ff8eadbed5004ab03438f737492387dee6b9750a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/malloc.c | 12 ++++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index c246f07bd4..7ce89fb2c7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Suppress\sthe\sdisplay\sof\sthe\sP4\soperand\sin\sEXPLAIN\soutput\swhen\san\sopcode\nhas\sbeen\sconverted\sinto\sa\sNo-op. -D 2016-01-20T02:36:12.461 +C Performance\simprovement\sin\ssqlite3DbMallocRaw(). +D 2016-01-20T03:36:32.428 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -311,7 +311,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b F src/main.c b686dabe9a7ece9121da87120d5c7bf402d77eb3 -F src/malloc.c 8f787669e79de26efc42272b5797bc00fff527c6 +F src/malloc.c b67c26c359c13836d370350b3f43d228dff5b360 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P da527ddae06460ab4b706cdb871de2188ebaf5ac -R 9c350206cbc3ec71bedbf771eaad6af4 +P 9f8297f862a110ded686d091854fae20c6bc393c +R 90386a9e726561832778abc9155cd93d U drh -Z d3ee680a30750cc9b6d539ba48a1436a +Z 2aa4bf87eb3a329408d2351dd05edc2d diff --git a/manifest.uuid b/manifest.uuid index 4615528f3e..50bb5b1795 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9f8297f862a110ded686d091854fae20c6bc393c \ No newline at end of file +ff8eadbed5004ab03438f737492387dee6b9750a \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index 2c493b9320..c8a04128cf 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -583,8 +583,9 @@ void *sqlite3DbMallocZero(sqlite3 *db, u64 n){ } /* -** Allocate and zero memory. If the allocation fails, make -** the mallocFailed flag in the connection pointer. +** Allocate memory, either lookaside (if possible) or heap. +** If the allocation fails, set the mallocFailed flag in +** the connection pointer. ** ** If db!=0 and db->mallocFailed is true (indicating a prior malloc ** failure on the same database connection) then always return 0. @@ -600,8 +601,8 @@ void *sqlite3DbMallocZero(sqlite3 *db, u64 n){ ** In other words, if a subsequent malloc (ex: "b") worked, it is assumed ** that all prior mallocs (ex: "a") worked too. */ +static SQLITE_NOINLINE void *dbMallocRawFinish(sqlite3 *db, u64 n); void *sqlite3DbMallocRaw(sqlite3 *db, u64 n){ - void *p; assert( db==0 || sqlite3_mutex_held(db->mutex) ); assert( db==0 || db->pnBytesFreed==0 ); #ifndef SQLITE_OMIT_LOOKASIDE @@ -631,7 +632,10 @@ void *sqlite3DbMallocRaw(sqlite3 *db, u64 n){ return 0; } #endif - p = sqlite3Malloc(n); + return dbMallocRawFinish(db, n); +} +static SQLITE_NOINLINE void *dbMallocRawFinish(sqlite3 *db, u64 n){ + void *p = sqlite3Malloc(n); if( !p && db ){ db->mallocFailed = 1; } From 5c3aa0517ed8a837e4d70cacbaca5d9e267e0fc3 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 20 Jan 2016 08:47:55 +0000 Subject: [PATCH 223/232] Improve performance of sqlite3VtabImportErrmsg(). FossilOrigin-Name: 18d61c8e40ed1466b6a3a2f53bf0eeb09687c20e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 12 +++++++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 7ce89fb2c7..1c1653b60a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\simprovement\sin\ssqlite3DbMallocRaw(). -D 2016-01-20T03:36:32.428 +C Improve\sperformance\sof\ssqlite3VtabImportErrmsg(). +D 2016-01-20T08:47:55.546 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -414,7 +414,7 @@ F src/vdbe.c b90d9d38e5e0260c2eafa3cb4c2274d8ea94da27 F src/vdbe.h 7a733ea8aac1b77305a67698e784fa3484ee3337 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e -F src/vdbeaux.c db67d3e0fcedced22bfeca47a567eb9df91b3495 +F src/vdbeaux.c 07f8f485a6cbc0a62da660f14e303061d45d5cb6 F src/vdbeblob.c 37c3d11a753e403698c69e17383d282e1ae73e75 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9f8297f862a110ded686d091854fae20c6bc393c -R 90386a9e726561832778abc9155cd93d -U drh -Z 2aa4bf87eb3a329408d2351dd05edc2d +P ff8eadbed5004ab03438f737492387dee6b9750a +R 9def3e1e6201afa0dc73a868079c61c0 +U dan +Z 16223910bb7e7f6f85293111cf2f150d diff --git a/manifest.uuid b/manifest.uuid index 50bb5b1795..eacc6db990 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ff8eadbed5004ab03438f737492387dee6b9750a \ No newline at end of file +18d61c8e40ed1466b6a3a2f53bf0eeb09687c20e \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index d88fbac611..17f1cb7dc4 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -4445,10 +4445,12 @@ void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){ ** in memory obtained from sqlite3DbMalloc). */ void sqlite3VtabImportErrmsg(Vdbe *p, sqlite3_vtab *pVtab){ - sqlite3 *db = p->db; - sqlite3DbFree(db, p->zErrMsg); - p->zErrMsg = sqlite3DbStrDup(db, pVtab->zErrMsg); - sqlite3_free(pVtab->zErrMsg); - pVtab->zErrMsg = 0; + if( pVtab->zErrMsg ){ + sqlite3 *db = p->db; + sqlite3DbFree(db, p->zErrMsg); + p->zErrMsg = sqlite3DbStrDup(db, pVtab->zErrMsg); + sqlite3_free(pVtab->zErrMsg); + pVtab->zErrMsg = 0; + } } #endif /* SQLITE_OMIT_VIRTUALTABLE */ From fb3972602c5e584c9abebaddc79dea50c738b1ba Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 20 Jan 2016 14:22:41 +0000 Subject: [PATCH 224/232] Case folding in the LIKE operator should look at all bits of the character, not just the lower 8 bits. Fix for ticket [80369eddd5c94]. This is a back-out of check-in [0a99a8c4facf] with a testcase added. FossilOrigin-Name: 204432ee72fda8e82d244c4aa18de7ec4811b8e1 --- manifest | 17 +++++++++-------- manifest.uuid | 2 +- src/func.c | 2 +- test/like.test | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 1c1653b60a..d21c7850c5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sperformance\sof\ssqlite3VtabImportErrmsg(). -D 2016-01-20T08:47:55.546 +C Case\sfolding\sin\sthe\sLIKE\soperator\sshould\slook\sat\sall\sbits\sof\sthe\scharacter,\nnot\sjust\sthe\slower\s8\sbits.\s\sFix\sfor\sticket\s[80369eddd5c94].\s\sThis\sis\sa\nback-out\sof\scheck-in\s[0a99a8c4facf]\swith\sa\stestcase\sadded. +D 2016-01-20T14:22:41.167 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -301,7 +301,7 @@ F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c df0d7c3230d59abd679da22ff5ce4cfd0e3a0e63 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e18b3dff7d47c7bcac5ac4fc178a89b9fd322b44 -F src/func.c ccaf46fa98f795673afbfab73dff7c18db88f3cd +F src/func.c ba6c03f9e440f5693086c08ee88e6e60212b3504 F src/global.c bd5a0af3f30b0c01be6db756c626cd3c33a3d260 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 @@ -836,7 +836,7 @@ F test/json103.test 923b288a0610ec86c0951778f7db19cbcca36ad1 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 -F test/like.test edcf6d0a055816fd793eab92454597c1be91f720 +F test/like.test 81632c437a947bf1f7130b19537da6a1a844806a F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/like3.test 3608a2042b6f922f900fbfd5d3ce4e7eca57f7c4 F test/limit.test 0c99a27a87b14c646a9d583c7c89fd06c352663e @@ -1419,7 +1419,8 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ff8eadbed5004ab03438f737492387dee6b9750a -R 9def3e1e6201afa0dc73a868079c61c0 -U dan -Z 16223910bb7e7f6f85293111cf2f150d +P 18d61c8e40ed1466b6a3a2f53bf0eeb09687c20e +Q -0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 +R a12b99ab1200f8dc9c9bb177fd701c6e +U drh +Z 48772c507adcfea733ff1f22cebdbc4d diff --git a/manifest.uuid b/manifest.uuid index eacc6db990..f32ef30853 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -18d61c8e40ed1466b6a3a2f53bf0eeb09687c20e \ No newline at end of file +204432ee72fda8e82d244c4aa18de7ec4811b8e1 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 45bbb35cd8..b927296782 100644 --- a/src/func.c +++ b/src/func.c @@ -739,7 +739,7 @@ static int patternCompare( } c2 = Utf8Read(zString); if( c==c2 ) continue; - if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) ){ + if( noCase && c<0x80 && c2<0x80 && sqlite3Tolower(c)==sqlite3Tolower(c2) ){ continue; } if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue; diff --git a/test/like.test b/test/like.test index ceb5f2bfac..fba89e9037 100644 --- a/test/like.test +++ b/test/like.test @@ -964,5 +964,22 @@ do_execsql_test like-12.16 { SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id; } {/SCAN/} +# Ticket [https://www.sqlite.org/src/tktview/80369eddd5c94d49f7fbbcf5] +# 2016-01-20 +# +do_execsql_test like-13.1 { + SELECT char(0x304d) LIKE char(0x306d); +} {0} +do_execsql_test like-13.2 { + SELECT char(0x4d) LIKE char(0x306d); +} {0} +do_execsql_test like-13.3 { + SELECT char(0x304d) LIKE char(0x6d); +} {0} +do_execsql_test like-13.4 { + SELECT char(0x4d) LIKE char(0x6d); +} {1} + + finish_test From 30908c97ac15d7413d4de3d74f77feff9a10abf6 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 20 Jan 2016 15:19:56 +0000 Subject: [PATCH 225/232] Fix a problem in autoconf/configure.ac causing --enable-readline to fail if libedit was not present. FossilOrigin-Name: e8adeb64d4e463772feb58dbd6f00715b92e735c --- autoconf/configure.ac | 2 ++ manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index deba91ae1d..fcca148aea 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -49,6 +49,8 @@ if test x"$enable_editline" != xno ; then READLINE_LIBS=$LIBS if test x"$LIBS" != "x"; then AC_DEFINE([HAVE_EDITLINE],1,Define to use BSD editline) + else + unset ac_cv_search_readline fi LIBS=$sLIBS fi diff --git a/manifest b/manifest index d21c7850c5..705d2ce2ea 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Case\sfolding\sin\sthe\sLIKE\soperator\sshould\slook\sat\sall\sbits\sof\sthe\scharacter,\nnot\sjust\sthe\slower\s8\sbits.\s\sFix\sfor\sticket\s[80369eddd5c94].\s\sThis\sis\sa\nback-out\sof\scheck-in\s[0a99a8c4facf]\swith\sa\stestcase\sadded. -D 2016-01-20T14:22:41.167 +C Fix\sa\sproblem\sin\sautoconf/configure.ac\scausing\s--enable-readline\sto\sfail\sif\slibedit\swas\snot\spresent. +D 2016-01-20T15:19:56.944 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -13,7 +13,7 @@ F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am 089e5ecdb5761e64ea1013ded02feb4d8b29927d F autoconf/README 14458f1046c118efa721aadec5f227e876d3cd38 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 -F autoconf/configure.ac 2f41055b10873cfe443a08185343e38c47e2f9f0 +F autoconf/configure.ac 7b1ea0dcaf49fafba262ce4b0ee8cb3281b555d1 F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -1419,8 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 18d61c8e40ed1466b6a3a2f53bf0eeb09687c20e -Q -0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 -R a12b99ab1200f8dc9c9bb177fd701c6e -U drh -Z 48772c507adcfea733ff1f22cebdbc4d +P 204432ee72fda8e82d244c4aa18de7ec4811b8e1 +R 88c735abd00a694aa5831ac3200d7df4 +U dan +Z 23cee0c6751a379626b5009d557e2a86 diff --git a/manifest.uuid b/manifest.uuid index f32ef30853..48f168413c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -204432ee72fda8e82d244c4aa18de7ec4811b8e1 \ No newline at end of file +e8adeb64d4e463772feb58dbd6f00715b92e735c \ No newline at end of file From bd5af9ea31501d85ced48cff410a77c3200ee972 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 20 Jan 2016 16:36:10 +0000 Subject: [PATCH 226/232] Add a -detail option to the loadfts5.tcl script. For creating tables with the detail= option set. FossilOrigin-Name: 81e830e21f81b6428209afa0b8f42f2fd9bd7aab --- ext/fts5/tool/loadfts5.tcl | 10 ++++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ext/fts5/tool/loadfts5.tcl b/ext/fts5/tool/loadfts5.tcl index 4a5aa37250..96fd69260e 100644 --- a/ext/fts5/tool/loadfts5.tcl +++ b/ext/fts5/tool/loadfts5.tcl @@ -49,6 +49,7 @@ proc usage {} { puts stderr " -prefix PREFIX (comma separated prefix= argument)" puts stderr " -trans N (commit after N inserts - 0 == never)" puts stderr " -hashsize N (set the fts5 hashsize parameter to N)" + puts stderr " -detail MODE (detail mode for fts5 tables)" exit 1 } @@ -61,6 +62,7 @@ set O(crisismerge) -1 set O(prefix) "" set O(trans) 0 set O(hashsize) -1 +set O(detail) full if {[llength $argv]<2} usage set nOpt [expr {[llength $argv]-2}] @@ -113,6 +115,11 @@ for {set i 0} {$i < $nOpt} {incr i} { set O(hashsize) [lindex $argv $i] } + -detail { + if { [incr i]>=$nOpt } usage + set O(detail) [lindex $argv $i] + } + default { usage } @@ -129,6 +136,9 @@ db eval "PRAGMA page_size=4096" db eval BEGIN set pref "" if {$O(prefix)!=""} { set pref ", prefix='$O(prefix)'" } + if {$O(vtab)=="fts5"} { + append pref ", detail=$O(detail)" + } catch { db eval "CREATE VIRTUAL TABLE t1 USING $O(vtab) (path, content$O(tok)$pref)" db eval "INSERT INTO t1(t1, rank) VALUES('pgsz', 4050);" diff --git a/manifest b/manifest index 705d2ce2ea..1fd7c7c1ba 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sautoconf/configure.ac\scausing\s--enable-readline\sto\sfail\sif\slibedit\swas\snot\spresent. -D 2016-01-20T15:19:56.944 +C Add\sa\s-detail\soption\sto\sthe\sloadfts5.tcl\sscript.\sFor\screating\stables\swith\sthe\sdetail=\soption\sset. +D 2016-01-20T16:36:10.587 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -190,7 +190,7 @@ F ext/fts5/test/fts5version.test 978f59541d8cef7e8591f8be2115ec5ccb863e2e F ext/fts5/test/fts5vocab.test 480d780aa6b699816c5066225fbd86f3a0239477 F ext/fts5/tool/fts5speed.tcl aaee41894b552df8fbf8616aad003b2ea9ba3221 F ext/fts5/tool/fts5txt2db.tcl c374c4c4797e8cdfadabdfaeeb5412dcd6686e84 -F ext/fts5/tool/loadfts5.tcl 4cc2d6af43b58d4fac05bc4fdabd0e5862c3b2c1 +F ext/fts5/tool/loadfts5.tcl 95b03429ee6b138645703c6ca192c3ac96eaf093 F ext/fts5/tool/mkfts5c.tcl d1c2a9ab8e0ec690a52316f33dd9b1d379942f45 F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 204432ee72fda8e82d244c4aa18de7ec4811b8e1 -R 88c735abd00a694aa5831ac3200d7df4 +P e8adeb64d4e463772feb58dbd6f00715b92e735c +R 98a9c0dcd39e5c05ab4c041a240f6511 U dan -Z 23cee0c6751a379626b5009d557e2a86 +Z b7cb5f97fd28535e6bf47b6d39323aaf diff --git a/manifest.uuid b/manifest.uuid index 48f168413c..d46650e968 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e8adeb64d4e463772feb58dbd6f00715b92e735c \ No newline at end of file +81e830e21f81b6428209afa0b8f42f2fd9bd7aab \ No newline at end of file From b5a5a23e92dfd32b30cdfc5d8909438bdd46f4ee Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 20 Jan 2016 18:47:59 +0000 Subject: [PATCH 227/232] Add 'rbu' to the clean targets. FossilOrigin-Name: f60f025027ab3acdbc97701f81ff9c11c8463022 --- Makefile.in | 1 + Makefile.msc | 2 +- main.mk | 1 + manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile.in b/Makefile.in index 005d529594..6859dcf854 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1218,6 +1218,7 @@ clean: rm -f sqlite3_analyzer$(TEXE) sqlite3_analyzer.c rm -f sqlite-*-output.vsix rm -f mptester mptester.exe + rm -f rbu rbu.exe rm -f fuzzershell fuzzershell.exe rm -f fuzzcheck fuzzcheck.exe rm -f sqldiff sqldiff.exe diff --git a/Makefile.msc b/Makefile.msc index c8275fde25..160323a103 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1863,7 +1863,7 @@ clean: del /Q testfixture.exe test.db 2>NUL del /Q LogEst.exe fts3view.exe rollback-test.exe showdb.exe 2>NUL del /Q showjournal.exe showstat4.exe showwal.exe speedtest1.exe 2>NUL - del /Q mptester.exe wordcount.exe 2>NUL + del /Q mptester.exe wordcount.exe rbu.exe 2>NUL del /Q sqlite3.exe sqlite3.dll sqlite3.def 2>NUL del /Q sqlite3.c sqlite3-*.c 2>NUL del /Q sqlite3rc.h 2>NUL diff --git a/main.mk b/main.mk index 934cd36a4e..1dda2d153f 100644 --- a/main.mk +++ b/main.mk @@ -892,6 +892,7 @@ clean: rm -f showwal showwal.exe rm -f speedtest1 speedtest1.exe rm -f wordcount wordcount.exe + rm -f rbu rbu.exe rm -f sqlite3.c sqlite3-*.c fts?amal.c tclsqlite3.c rm -f sqlite3rc.h rm -f shell.c sqlite3ext.h diff --git a/manifest b/manifest index 1fd7c7c1ba..7d2bd65367 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Add\sa\s-detail\soption\sto\sthe\sloadfts5.tcl\sscript.\sFor\screating\stables\swith\sthe\sdetail=\soption\sset. -D 2016-01-20T16:36:10.587 -F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 +C Add\s'rbu'\sto\sthe\sclean\stargets. +D 2016-01-20T18:47:59.553 +F Makefile.in 7be88f5b473891e3a8c07245ed60535fcda4f9ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb +F Makefile.msc c5ead4aa22ff6f528c755b07ed1e31184ac5b3d2 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 866588d1edf0ccb5b0d33896974338f97564f719 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -269,7 +269,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 8670f56454bdc59d5e33397bf8c7e43eb33af50c +F main.mk 960071a0bceb043bc5627573986154f507931f33 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e8adeb64d4e463772feb58dbd6f00715b92e735c -R 98a9c0dcd39e5c05ab4c041a240f6511 -U dan -Z b7cb5f97fd28535e6bf47b6d39323aaf +P 81e830e21f81b6428209afa0b8f42f2fd9bd7aab +R 48465c96540143107ca11194f4f37f5c +U mistachkin +Z 6a809d8da8a8f3c2b9daa12aa587edb1 diff --git a/manifest.uuid b/manifest.uuid index d46650e968..849ae0e2a6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -81e830e21f81b6428209afa0b8f42f2fd9bd7aab \ No newline at end of file +f60f025027ab3acdbc97701f81ff9c11c8463022 \ No newline at end of file From 9c0c57a4ca66af40e70f61e042bf477458abe2c4 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 21 Jan 2016 15:55:37 +0000 Subject: [PATCH 228/232] Improved comments on the FORDELETE hint. No logic changes. FossilOrigin-Name: a3cec529f0238e4ca1196fec420f2de80d28db78 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/btree.h | 16 +++++++++++++--- src/sqliteInt.h | 2 +- src/where.c | 11 +++++------ 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 7d2bd65367..d459ef1f26 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\s'rbu'\sto\sthe\sclean\stargets. -D 2016-01-20T18:47:59.553 +C Improved\scomments\son\sthe\sFORDELETE\shint.\s\sNo\slogic\schanges. +D 2016-01-21T15:55:37.704 F Makefile.in 7be88f5b473891e3a8c07245ed60535fcda4f9ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc c5ead4aa22ff6f528c755b07ed1e31184ac5b3d2 @@ -289,7 +289,7 @@ F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c f224ae877fde69d1a9d430f502edaf8502752dbe -F src/btree.h 68ef301795e00cdf1d3ab93abc44a43b7fe771e0 +F src/btree.h 526137361963e746949ab966a910c7f455ac6b04 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/build.c 31af80bba31ac159967951ef58f3144cc7db9d70 F src/callback.c 29ae4faba226c7ebb9aee93016b5ce8a8f071261 @@ -350,7 +350,7 @@ F src/shell.c dcd7a83645ef2a58ee9c6d0ea4714d877d7835c4 F src/sqlite.h.in 214476a62012e578f42133a9a3b4f97a9aa421a3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 8c1debffeeb1579bdc264d54c72c05892e23b7ee +F src/sqliteInt.h 0403328581127bc8ad2f9cc7af2c3bb23d5316da F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -424,7 +424,7 @@ F src/vxworks.h 974e7d9a98f602d6310d563e1dc4e08f9fc48e47 F src/wal.c d21b99fd1458159d0b1ecdccc8ee6ada4fdc4c54 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c bb69654f841ae7af0a20cc6fb8f0ac57901c31be +F src/where.c af9bf5dcec1a0e52726c550924aa91d837166251 F src/whereInt.h 78b6b4de94db84aecbdc07fe3e38f648eb391e9a F src/wherecode.c 8dee26eb181ea9daa8b1a4d96f34c0860aaf99bd F src/whereexpr.c 197a448b52073aee43eca3a2233fc113369eb2d4 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 81e830e21f81b6428209afa0b8f42f2fd9bd7aab -R 48465c96540143107ca11194f4f37f5c -U mistachkin -Z 6a809d8da8a8f3c2b9daa12aa587edb1 +P f60f025027ab3acdbc97701f81ff9c11c8463022 +R 58c662ebb54c7087fe70ba0b9b653627 +U drh +Z 656e64b9ebb4ed29ac85ca9fad2e65b0 diff --git a/manifest.uuid b/manifest.uuid index 849ae0e2a6..80d0db3e83 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f60f025027ab3acdbc97701f81ff9c11c8463022 \ No newline at end of file +a3cec529f0238e4ca1196fec420f2de80d28db78 \ No newline at end of file diff --git a/src/btree.h b/src/btree.h index 2f398e7bba..37a9915eda 100644 --- a/src/btree.h +++ b/src/btree.h @@ -199,14 +199,24 @@ int sqlite3BtreeNewDb(Btree *p); ** Flags passed as the third argument to sqlite3BtreeCursor(). ** ** For read-only cursors the wrFlag argument is always zero. For read-write -** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or -** (BTREE_WRCSR). If the BTREE_FORDELETE flag is set, then the cursor will +** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or just +** (BTREE_WRCSR). If the BTREE_FORDELETE bit is set, then the cursor will ** only be used by SQLite for the following: ** -** * to seek to and delete specific entries, and/or +** * to seek to and then delete specific entries, and/or ** ** * to read values that will be used to create keys that other ** BTREE_FORDELETE cursors will seek to and delete. +** +** The BTREE_FORDELETE flag is an optimization hint. It is not used by +** by this, the native b-tree engine of SQLite, but it is available to +** alternative storage engines that might be substituted in place of this +** b-tree system. For alternative storage engines in which a delete of +** the main table row automatically deletes corresponding index rows, +** the FORDELETE flag hint allows those alternative storage engines to +** skip a lot of work. Namely: FORDELETE cursors may treat all SEEK +** and DELETE operations as no-ops, and any READ operation against a +** FORDELETE cursor may return a null row: 0x01 0x00. */ #define BTREE_WRCSR 0x00000004 /* read-write cursor */ #define BTREE_FORDELETE 0x00000008 /* Cursor is for seek/delete only */ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8ab59b4679..b536b8ab28 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2857,7 +2857,7 @@ struct AuthContext { #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */ #define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */ #define OPFLAG_SEEKEQ 0x02 /* OP_Open** cursor uses EQ seek only */ -#define OPFLAG_FORDELETE 0x08 /* OP_Open is opening for-delete csr */ +#define OPFLAG_FORDELETE 0x08 /* OP_Open should use BTREE_FORDELETE */ #define OPFLAG_P2ISREG 0x10 /* P2 to OP_Open** is a register number */ #define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */ diff --git a/src/where.c b/src/where.c index 2cb8334ffb..8c8dfbb7b6 100644 --- a/src/where.c +++ b/src/where.c @@ -4014,7 +4014,7 @@ WhereInfo *sqlite3WhereBegin( int ii; /* Loop counter */ sqlite3 *db; /* Database connection */ int rc; /* Return code */ - u8 bFordelete = 0; + u8 bFordelete = 0; /* OPFLAG_FORDELETE or zero, as appropriate */ assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || ( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 @@ -4259,16 +4259,15 @@ WhereInfo *sqlite3WhereBegin( /* If the caller is an UPDATE or DELETE statement that is requesting ** to use a one-pass algorithm, determine if this is appropriate. - ** The one-pass algorithm only works if the WHERE clause constrains - ** the statement to update or delete a single row. */ assert( (wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || pWInfo->nLevel==1 ); if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 ){ int wsFlags = pWInfo->a[0].pWLoop->wsFlags; int bOnerow = (wsFlags & WHERE_ONEROW)!=0; - if( bOnerow || ( (wctrlFlags & WHERE_ONEPASS_MULTIROW) - && 0==(wsFlags & WHERE_VIRTUALTABLE) - )){ + if( bOnerow + || ((wctrlFlags & WHERE_ONEPASS_MULTIROW)!=0 + && 0==(wsFlags & WHERE_VIRTUALTABLE)) + ){ pWInfo->eOnePass = bOnerow ? ONEPASS_SINGLE : ONEPASS_MULTI; if( HasRowid(pTabList->a[0].pTab) && (wsFlags & WHERE_IDX_ONLY) ){ if( wctrlFlags & WHERE_ONEPASS_MULTIROW ){ From 153d3e91dbace8dc0c56ef7a80ea1e282208e3c5 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 21 Jan 2016 18:56:10 +0000 Subject: [PATCH 229/232] Fix typo in 'Makefile.in'. FossilOrigin-Name: 29a51c6dcc0ef7cab51aba0024e9c5bec89c6973 --- Makefile.in | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.in b/Makefile.in index 6859dcf854..a07279c3c9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1180,9 +1180,9 @@ lib_install: libsqlite3.la $(INSTALL) -d $(DESTDIR)$(libdir) $(LTINSTALL) libsqlite3.la $(DESTDIR)$(libdir) -install: sqlite3$(BEXE) lib_install sqlite3.h sqlite3.pc ${HAVE_TCL:1=tcl_install} +install: sqlite3$(TEXE) lib_install sqlite3.h sqlite3.pc ${HAVE_TCL:1=tcl_install} $(INSTALL) -d $(DESTDIR)$(bindir) - $(LTINSTALL) sqlite3$(BEXE) $(DESTDIR)$(bindir) + $(LTINSTALL) sqlite3$(TEXE) $(DESTDIR)$(bindir) $(INSTALL) -d $(DESTDIR)$(includedir) $(INSTALL) -m 0644 sqlite3.h $(DESTDIR)$(includedir) $(INSTALL) -m 0644 $(TOP)/src/sqlite3ext.h $(DESTDIR)$(includedir) diff --git a/manifest b/manifest index d459ef1f26..94fd201a3d 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ -C Improved\scomments\son\sthe\sFORDELETE\shint.\s\sNo\slogic\schanges. -D 2016-01-21T15:55:37.704 -F Makefile.in 7be88f5b473891e3a8c07245ed60535fcda4f9ee +C Fix\stypo\sin\s'Makefile.in'. +D 2016-01-21T18:56:10.840 +F Makefile.in 027c1603f255390c43a426671055a31c0a65fdb4 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc c5ead4aa22ff6f528c755b07ed1e31184ac5b3d2 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f60f025027ab3acdbc97701f81ff9c11c8463022 -R 58c662ebb54c7087fe70ba0b9b653627 -U drh -Z 656e64b9ebb4ed29ac85ca9fad2e65b0 +P a3cec529f0238e4ca1196fec420f2de80d28db78 +R 0153ee59df704041be1869f598c173fa +U mistachkin +Z cab32b4afad5b6a6884b5ccdb88994ac diff --git a/manifest.uuid b/manifest.uuid index 80d0db3e83..47bf74ce33 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a3cec529f0238e4ca1196fec420f2de80d28db78 \ No newline at end of file +29a51c6dcc0ef7cab51aba0024e9c5bec89c6973 \ No newline at end of file From edcb4ebba1553304c3a14f127b1991a11f2b1bb0 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 22 Jan 2016 01:25:15 +0000 Subject: [PATCH 230/232] MSVC makefile enhancements for use with the Windows 10 SDK. FossilOrigin-Name: ac2e9d3de54d299f92fc35927b6df6d3aaa2dc59 --- Makefile.msc | 119 +++++++++++++++++++++++++++++++++++++++----------- manifest | 12 ++--- manifest.uuid | 2 +- 3 files changed, 100 insertions(+), 33 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 160323a103..3ac19c2f73 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -130,6 +130,12 @@ FOR_WINRT = 0 FOR_UAP = 0 !ENDIF +# Set this non-0 to compile binaries suitable for Windows 10. +# +!IFNDEF FOR_WIN10 +FOR_WIN10 = 0 +!ENDIF + # Set this non-0 to skip attempting to look for and/or link with the Tcl # runtime library. # @@ -186,6 +192,31 @@ DEBUG = 0 OPTIMIZATIONS = 2 !ENDIF +# This is the name to use for the SQLite dynamic link library (DLL). +# +!IFNDEF SQLITE3DLL +SQLITE3DLL = sqlite3.dll +!ENDIF + +# This is the name to use for the SQLite import library (LIB). +# +!IFNDEF SQLITE3LIB +SQLITE3LIB = sqlite3.lib +!ENDIF + +# This is the name to use for the SQLite shell executable (EXE). +# +!IFNDEF SQLITE3EXE +SQLITE3EXE = sqlite3.exe +!ENDIF + +# This is the argument used to set the program database (PDB) file for the +# SQLite shell executable (EXE). +# +!IFNDEF SQLITE3EXEPDB +SQLITE3EXEPDB = /pdb:sqlite3sh.pdb +!ENDIF + # These are the "standard" SQLite compilation options used when compiling for # the Windows platform. # @@ -195,6 +226,19 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1 !ENDIF +# These are the "extended" SQLite compilation options used when compiling for +# the Windows 10 platform. +# +!IFNDEF EXT_FEATURE_FLAGS +!IF $(FOR_WIN10)!=0 +EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS4=1 +EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_SYSTEM_MALLOC=1 +EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_OMIT_LOCALTIME=1 +!ELSE +EXT_FEATURE_FLAGS = +!ENDIF +!ENDIF + ############################################################################### ############################### END OF OPTIONS ################################ ############################################################################### @@ -327,9 +371,18 @@ TCC = $(CC) -nologo -W4 -DINCLUDE_MSVC_H=1 $(CCOPTS) $(TCCOPTS) TCC = $(CC) -nologo -W3 $(CCOPTS) $(TCCOPTS) !ENDIF -TCC = $(TCC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -I$(TOP)\src -fp:precise +TCC = $(TCC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src -fp:precise RCC = $(RC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src $(RCOPTS) $(RCCOPTS) +# Adjust the names of the primary targets for use with Windows 10. +# +!IF $(FOR_WIN10)!=0 +SQLITE3DLL = winsqlite3.dll +SQLITE3LIB = winsqlite3.lib +SQLITE3EXE = winsqlite3shell.exe +SQLITE3EXEPDB = +!ENDIF + # Check if we want to use the "stdcall" calling convention when compiling. # This is not supported by the compilers for non-x86 platforms. It should # also be noted here that building any target with these "stdcall" options @@ -337,7 +390,7 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src $(RCOPTS) $(RCCOPTS) # to how the Tcl library functions are declared and exported (i.e. without # an explicit calling convention, which results in "cdecl"). # -!IF $(USE_STDCALL)!=0 +!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0 !IF "$(PLATFORM)"=="x86" CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall @@ -358,7 +411,7 @@ SHELL_CCONV_OPTS = # These are additional compiler options used for the core library. # !IFNDEF CORE_COMPILE_OPTS -!IF $(DYNAMIC_SHELL)!=0 +!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) -DSQLITE_API=__declspec(dllexport) !ELSE CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) @@ -369,7 +422,7 @@ CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) # when linking. # !IFNDEF CORE_LINK_DEP -!IF $(DYNAMIC_SHELL)!=0 +!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 CORE_LINK_DEP = !ELSE CORE_LINK_DEP = sqlite3.def @@ -379,7 +432,7 @@ CORE_LINK_DEP = sqlite3.def # These are additional linker options used for the core library. # !IFNDEF CORE_LINK_OPTS -!IF $(DYNAMIC_SHELL)!=0 +!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 CORE_LINK_OPTS = !ELSE CORE_LINK_OPTS = /DEF:sqlite3.def @@ -389,7 +442,7 @@ CORE_LINK_OPTS = /DEF:sqlite3.def # These are additional compiler options used for the shell executable. # !IFNDEF SHELL_COMPILE_OPTS -!IF $(DYNAMIC_SHELL)!=0 +!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 SHELL_COMPILE_OPTS = -DSQLITE_SHELL_JSON1 $(SHELL_CCONV_OPTS) -DSQLITE_API=__declspec(dllimport) !ELSE SHELL_COMPILE_OPTS = -DSQLITE_SHELL_JSON1 $(SHELL_CCONV_OPTS) @@ -399,8 +452,8 @@ SHELL_COMPILE_OPTS = -DSQLITE_SHELL_JSON1 $(SHELL_CCONV_OPTS) # This is the core library that the shell executable should depend on. # !IFNDEF SHELL_CORE_DEP -!IF $(DYNAMIC_SHELL)!=0 -SHELL_CORE_DEP = sqlite3.dll +!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 +SHELL_CORE_DEP = $(SQLITE3DLL) !ELSE SHELL_CORE_DEP = libsqlite3.lib !ENDIF @@ -409,8 +462,8 @@ SHELL_CORE_DEP = libsqlite3.lib # This is the core library that the shell executable should link with. # !IFNDEF SHELL_CORE_LIB -!IF $(DYNAMIC_SHELL)!=0 -SHELL_CORE_LIB = sqlite3.lib +!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 +SHELL_CORE_LIB = $(SQLITE3LIB) !ELSE SHELL_CORE_LIB = libsqlite3.lib !ENDIF @@ -441,6 +494,13 @@ TCC = $(TCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP RCC = $(RCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP !ENDIF +# C compiler options for Windows 10 (needs Visual Studio 2015). +# +!IF $(FOR_WIN10)!=0 +TCC = $(TCC) /guard:cf -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE +BCC = $(BCC) /guard:cf -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE +!ENDIF + # Also, we need to dynamically link to the correct MSVC runtime # when compiling for WinRT (e.g. debug or release) OR if the # USE_CRT_DLL option is set to force dynamically linking to the @@ -498,7 +558,7 @@ BCC = $(BCC) -DNDEBUG RCC = $(RCC) -DNDEBUG !ENDIF -!IF $(DEBUG)>0 || $(API_ARMOR)!=0 +!IF $(DEBUG)>0 || $(API_ARMOR)!=0 || $(FOR_WIN10)!=0 TCC = $(TCC) -DSQLITE_ENABLE_API_ARMOR=1 RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR=1 !ENDIF @@ -659,8 +719,8 @@ REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_WIN32_USE_UUID=1 # Add the required and optional SQLite compilation options into the command # lines used to invoke the MSVC code and resource compilers. # -TCC = $(TCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) -RCC = $(RCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) +TCC = $(TCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) +RCC = $(RCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) # Add in any optional parameters specified on the commane line, e.g. # nmake /f Makefile.msc all "OPTS=-DSQLITE_ENABLE_FOO=1 -DSQLITE_OMIT_FOO=1" @@ -1203,7 +1263,7 @@ EXTHDR = $(EXTHDR) \ # TESTPROGS = \ testfixture.exe \ - sqlite3.exe \ + $(SQLITE3EXE) \ sqlite3_analyzer.exe \ sqldiff.exe @@ -1217,7 +1277,10 @@ FUZZDATA = \ # Extra compiler options for various shell tools # -SHELL_COMPILE_OPTS = -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 +!IF $(FOR_WIN10)==0 +SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS5 +!ENDIF + FUZZERSHELL_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 FUZZCHECK_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 @@ -1228,7 +1291,7 @@ TESTOPTS = --verbose=file --output=test-out.txt # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # -all: dll libsqlite3.lib sqlite3.exe libtclsqlite3.lib +all: dll libsqlite3.lib shell libtclsqlite3.lib libsqlite3.lib: $(LIBOBJ) $(LTLIB) $(LTLIBOPTS) /OUT:$@ $(LIBOBJ) $(TLIBS) @@ -1236,9 +1299,9 @@ libsqlite3.lib: $(LIBOBJ) libtclsqlite3.lib: tclsqlite.lo libsqlite3.lib $(LTLIB) $(LTLIBOPTS) $(LTLIBPATHS) /OUT:$@ tclsqlite.lo libsqlite3.lib $(LIBTCLSTUB) $(TLIBS) -sqlite3.exe: $(TOP)\src\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) sqlite3.h - $(LTLINK) $(SHELL_COMPILE_OPTS) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) $(TOP)\src\shell.c \ - /link /pdb:sqlite3sh.pdb $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS) +$(SQLITE3EXE): $(TOP)\src\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) sqlite3.h + $(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) $(TOP)\src\shell.c \ + /link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS) sqldiff.exe: $(TOP)\tool\sqldiff.c sqlite3.c sqlite3.h $(LTLINK) $(NO_WARN) $(TOP)\tool\sqldiff.c sqlite3.c /link $(LDFLAGS) $(LTLINKOPTS) @@ -1592,7 +1655,7 @@ parse.h: parse.c parse.c: $(TOP)\src\parse.y lemon.exe $(TOP)\tool\addopcodes.tcl del /Q parse.y parse.h parse.h.temp 2>NUL copy $(TOP)\src\parse.y . - .\lemon.exe $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) parse.y + .\lemon.exe $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) $(OPTS) parse.y move parse.h parse.h.temp $(TCLSH_CMD) $(TOP)\tool\addopcodes.tcl parse.h.temp > parse.h @@ -1603,7 +1666,7 @@ sqlite3ext.h: .target_source copy tsrc\sqlite3ext.h . mkkeywordhash.exe: $(TOP)\tool\mkkeywordhash.c - $(BCC) $(NO_WARN) -Fe$@ $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) \ + $(BCC) $(NO_WARN) -Fe$@ $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) $(OPTS) \ $(TOP)\tool\mkkeywordhash.c /link $(LDFLAGS) $(NLTLINKOPTS) $(NLTLIBPATHS) keywordhash.h: $(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe @@ -1698,7 +1761,7 @@ FTS5_SRC = \ fts5parse.c: $(TOP)\ext\fts5\fts5parse.y lemon.exe copy $(TOP)\ext\fts5\fts5parse.y . del /Q fts5parse.h 2>NUL - .\lemon.exe $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) fts5parse.y + .\lemon.exe $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) $(OPTS) fts5parse.y fts5parse.h: fts5parse.c @@ -1759,7 +1822,7 @@ fulltestonly: $(TESTPROGS) fuzztest @set PATH=$(LIBTCLPATH);$(PATH) .\testfixture.exe $(TOP)\test\full.test -queryplantest: testfixture.exe sqlite3.exe +queryplantest: testfixture.exe shell @set PATH=$(LIBTCLPATH);$(PATH) .\testfixture.exe $(TOP)\test\permutations.test queryplanner $(TESTOPTS) @@ -1864,7 +1927,7 @@ clean: del /Q LogEst.exe fts3view.exe rollback-test.exe showdb.exe 2>NUL del /Q showjournal.exe showstat4.exe showwal.exe speedtest1.exe 2>NUL del /Q mptester.exe wordcount.exe rbu.exe 2>NUL - del /Q sqlite3.exe sqlite3.dll sqlite3.def 2>NUL + del /Q $(SQLITE3EXE) $(SQLITE3DLL) sqlite3.def 2>NUL del /Q sqlite3.c sqlite3-*.c 2>NUL del /Q sqlite3rc.h 2>NUL del /Q shell.c sqlite3ext.h 2>NUL @@ -1873,9 +1936,13 @@ clean: del /Q fuzzershell.exe fuzzcheck.exe sqldiff.exe 2>NUL del /Q fts5.* fts5parse.* 2>NUL +# Shell executable. +# +shell: $(SQLITE3EXE) + # Dynamic link library section. # -dll: sqlite3.dll +dll: $(SQLITE3DLL) sqlite3.def: libsqlite3.lib echo EXPORTS > sqlite3.def @@ -1883,5 +1950,5 @@ sqlite3.def: libsqlite3.lib | $(TCLSH_CMD) $(TOP)\tool\replace.tcl include "^\s+1 _?(sqlite3_.*)$$" \1 \ | sort >> sqlite3.def -sqlite3.dll: $(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP) +$(SQLITE3DLL): $(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP) $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL $(CORE_LINK_OPTS) /OUT:$@ $(LIBOBJ) $(LIBRESOBJS) $(LTLIBS) $(TLIBS) diff --git a/manifest b/manifest index 94fd201a3d..67cd5b4802 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Fix\stypo\sin\s'Makefile.in'. -D 2016-01-21T18:56:10.840 +C MSVC\smakefile\senhancements\sfor\suse\swith\sthe\sWindows\s10\sSDK. +D 2016-01-22T01:25:15.110 F Makefile.in 027c1603f255390c43a426671055a31c0a65fdb4 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc c5ead4aa22ff6f528c755b07ed1e31184ac5b3d2 +F Makefile.msc 89b2e9780d97a6a3d7c89c4ad04d093787be3dc2 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 866588d1edf0ccb5b0d33896974338f97564f719 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a3cec529f0238e4ca1196fec420f2de80d28db78 -R 0153ee59df704041be1869f598c173fa +P 29a51c6dcc0ef7cab51aba0024e9c5bec89c6973 +R 9e26ae539c690ec3cae729a6d81b3775 U mistachkin -Z cab32b4afad5b6a6884b5ccdb88994ac +Z d4ab6d93e282614aa0160682fbcc0beb diff --git a/manifest.uuid b/manifest.uuid index 47bf74ce33..5f1ffc501a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -29a51c6dcc0ef7cab51aba0024e9c5bec89c6973 \ No newline at end of file +ac2e9d3de54d299f92fc35927b6df6d3aaa2dc59 \ No newline at end of file From 5d4d941e94546ee93fe1b1823e903afc6b1f598c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 22 Jan 2016 03:54:36 +0000 Subject: [PATCH 231/232] Further refinements to the MSVC makefile. FossilOrigin-Name: 67625b963a6f5a0c6dff1a04a323e693569c2d94 --- Makefile.msc | 126 +++++++++++++++++++++++++++++--------------------- manifest | 12 ++--- manifest.uuid | 2 +- 3 files changed, 81 insertions(+), 59 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 3ac19c2f73..a75045fc98 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -130,7 +130,7 @@ FOR_WINRT = 0 FOR_UAP = 0 !ENDIF -# Set this non-0 to compile binaries suitable for Windows 10. +# Set this non-0 to compile binaries suitable for the Windows 10 platform. # !IFNDEF FOR_WIN10 FOR_WIN10 = 0 @@ -192,6 +192,24 @@ DEBUG = 0 OPTIMIZATIONS = 2 !ENDIF +# Set the source code file to be used by executables and libraries when +# they need the amalgamation. +# +!IFNDEF SQLITE3C +!IF $(SPLIT_AMALGAMATION)!=0 +SQLITE3C = sqlite3-all.c +!ELSE +SQLITE3C = sqlite3.c +!ENDIF +!ENDIF + +# Set the include code file to be used by executables and libraries when +# they need SQLite. +# +!IFNDEF SQLITE3H +SQLITE3H = sqlite3.h +!ENDIF + # This is the name to use for the SQLite dynamic link library (DLL). # !IFNDEF SQLITE3DLL @@ -443,9 +461,20 @@ CORE_LINK_OPTS = /DEF:sqlite3.def # !IFNDEF SHELL_COMPILE_OPTS !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 -SHELL_COMPILE_OPTS = -DSQLITE_SHELL_JSON1 $(SHELL_CCONV_OPTS) -DSQLITE_API=__declspec(dllimport) +SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS) -DSQLITE_API=__declspec(dllimport) !ELSE -SHELL_COMPILE_OPTS = -DSQLITE_SHELL_JSON1 $(SHELL_CCONV_OPTS) +SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS) +!ENDIF +!ENDIF + +# This is the source code that the shell executable should be compiled +# with. +# +!IFNDEF SHELL_CORE_SRC +!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 +SHELL_CORE_SRC = +!ELSE +SHELL_CORE_SRC = $(SQLITE3C) !ENDIF !ENDIF @@ -455,7 +484,7 @@ SHELL_COMPILE_OPTS = -DSQLITE_SHELL_JSON1 $(SHELL_CCONV_OPTS) !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 SHELL_CORE_DEP = $(SQLITE3DLL) !ELSE -SHELL_CORE_DEP = libsqlite3.lib +SHELL_CORE_DEP = !ENDIF !ENDIF @@ -465,7 +494,7 @@ SHELL_CORE_DEP = libsqlite3.lib !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0 SHELL_CORE_LIB = $(SQLITE3LIB) !ELSE -SHELL_CORE_LIB = libsqlite3.lib +SHELL_CORE_LIB = !ENDIF !ENDIF @@ -494,7 +523,7 @@ TCC = $(TCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP RCC = $(RCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP !ENDIF -# C compiler options for Windows 10 (needs Visual Studio 2015). +# C compiler options for the Windows 10 platform (needs MSVC 2015). # !IF $(FOR_WIN10)!=0 TCC = $(TCC) /guard:cf -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE @@ -506,7 +535,7 @@ BCC = $(BCC) /guard:cf -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE # USE_CRT_DLL option is set to force dynamically linking to the # MSVC runtime library. # -!IF $(FOR_WINRT)!=0 || $(USE_CRT_DLL)!=0 +!IF $(FOR_WINRT)!=0 || $(FOR_WIN10)!=0 || $(USE_CRT_DLL)!=0 !IF $(DEBUG)>1 TCC = $(TCC) -MDd BCC = $(BCC) -MDd @@ -1084,7 +1113,7 @@ SRC5 = \ opcodes.h \ parse.c \ parse.h \ - sqlite3.h + $(SQLITE3H) # All source code files. # @@ -1228,7 +1257,7 @@ HDR = \ $(TOP)\src\pcache.h \ parse.h \ $(TOP)\src\pragma.h \ - sqlite3.h \ + $(SQLITE3H) \ $(TOP)\src\sqlite3ext.h \ $(TOP)\src\sqliteInt.h \ $(TOP)\src\sqliteLimit.h \ @@ -1275,16 +1304,20 @@ FUZZDATA = \ $(TOP)\test\fuzzdata3.db \ $(TOP)\test\fuzzdata4.db -# Extra compiler options for various shell tools +# Additional compiler options for the shell. These are only effective +# when the shell is not being dynamically linked. # -!IF $(FOR_WIN10)==0 -SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS5 +!IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0 +SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_SHELL_JSON1 -DSQLITE_ENABLE_FTS5 !ENDIF +# Extra compiler options for various test tools. +# +MPTESTER_COMPILE_OPTS = -DSQLITE_SHELL_JSON1 -DSQLITE_ENABLE_FTS5 FUZZERSHELL_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 FUZZCHECK_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -# Standard options to testfixture +# Standard options to testfixture. # TESTOPTS = --verbose=file --output=test-out.txt @@ -1299,23 +1332,21 @@ libsqlite3.lib: $(LIBOBJ) libtclsqlite3.lib: tclsqlite.lo libsqlite3.lib $(LTLIB) $(LTLIBOPTS) $(LTLIBPATHS) /OUT:$@ tclsqlite.lo libsqlite3.lib $(LIBTCLSTUB) $(TLIBS) -$(SQLITE3EXE): $(TOP)\src\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) sqlite3.h - $(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) $(TOP)\src\shell.c \ +$(SQLITE3EXE): $(TOP)\src\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H) + $(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) $(TOP)\src\shell.c $(SHELL_CORE_SRC) \ /link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS) -sqldiff.exe: $(TOP)\tool\sqldiff.c sqlite3.c sqlite3.h - $(LTLINK) $(NO_WARN) $(TOP)\tool\sqldiff.c sqlite3.c /link $(LDFLAGS) $(LTLINKOPTS) +sqldiff.exe: $(TOP)\tool\sqldiff.c $(SQLITE3C) $(SQLITE3H) + $(LTLINK) $(NO_WARN) $(TOP)\tool\sqldiff.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -fuzzershell.exe: $(TOP)\tool\fuzzershell.c sqlite3.c sqlite3.h - $(LTLINK) $(NO_WARN) $(FUZZERSHELL_COMPILE_OPTS) \ - $(TOP)\tool\fuzzershell.c sqlite3.c /link $(LDFLAGS) $(LTLINKOPTS) +fuzzershell.exe: $(TOP)\tool\fuzzershell.c $(SQLITE3C) $(SQLITE3H) + $(LTLINK) $(NO_WARN) $(FUZZERSHELL_COMPILE_OPTS) $(TOP)\tool\fuzzershell.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -fuzzcheck.exe: $(TOP)\test\fuzzcheck.c sqlite3.c sqlite3.h - $(LTLINK) $(NO_WARN) $(FUZZCHECK_COMPILE_OPTS) $(TOP)\test\fuzzcheck.c sqlite3.c /link $(LDFLAGS) $(LTLINKOPTS) +fuzzcheck.exe: $(TOP)\test\fuzzcheck.c $(SQLITE3C) $(SQLITE3H) + $(LTLINK) $(NO_WARN) $(FUZZCHECK_COMPILE_OPTS) $(TOP)\test\fuzzcheck.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -mptester.exe: $(TOP)\mptest\mptest.c $(SHELL_CORE_DEP) $(LIBRESOBJS) sqlite3.h - $(LTLINK) $(NO_WARN) $(SHELL_COMPILE_OPTS) $(TOP)\mptest\mptest.c \ - /link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) $(SHELL_LINK_OPTS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS) +mptester.exe: $(TOP)\mptest\mptest.c $(SQLITE3C) $(SQLITE3H) + $(LTLINK) $(NO_WARN) $(MPTESTER_COMPILE_OPTS) $(TOP)\mptest\mptest.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) MPTEST1 = mptester mptest.db $(TOP)\mptest\crash01.test --repeat 20 MPTEST2 = mptester mptest.db $(TOP)\mptest\multiwrite01.test --repeat 20 @@ -1359,15 +1390,6 @@ sqlite3.c: .target_source sqlite3ext.h $(TOP)\tool\mksqlite3c.tcl sqlite3-all.c: sqlite3.c $(TOP)\tool\split-sqlite3c.tcl $(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl -# Set the source code file to be used by executables and libraries when -# they need the amalgamation. -# -!IF $(SPLIT_AMALGAMATION)!=0 -SQLITE3C = sqlite3-all.c -!ELSE -SQLITE3C = sqlite3.c -!ENDIF - # Rule to build the amalgamation # sqlite3.lo: $(SQLITE3C) @@ -1637,7 +1659,7 @@ tclsqlite.lo: $(TOP)\src\tclsqlite.c $(HDR) tclsqlite-shell.lo: $(TOP)\src\tclsqlite.c $(HDR) $(LTCOMPILE) $(NO_WARN) -DTCLSH=1 -DBUILD_sqlite -I$(TCLINCDIR) -c $(TOP)\src\tclsqlite.c -tclsqlite3.exe: tclsqlite-shell.lo $(SQLITE3C) $(LIBRESOBJS) +tclsqlite3.exe: tclsqlite-shell.lo $(SQLITE3C) $(SQLITE3H) $(LIBRESOBJS) $(LTLINK) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /OUT:$@ tclsqlite-shell.lo $(LIBRESOBJS) $(LTLIBS) $(TLIBS) # Rules to build opcodes.c and opcodes.h @@ -1659,8 +1681,8 @@ parse.c: $(TOP)\src\parse.y lemon.exe $(TOP)\tool\addopcodes.tcl move parse.h parse.h.temp $(TCLSH_CMD) $(TOP)\tool\addopcodes.tcl parse.h.temp > parse.h -sqlite3.h: $(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION - $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP:\=/) > sqlite3.h +$(SQLITE3H): $(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION + $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP:\=/) > $(SQLITE3H) sqlite3ext.h: .target_source copy tsrc\sqlite3ext.h . @@ -1800,7 +1822,7 @@ TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC0) TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC1) !ENDIF -testfixture.exe: $(TESTFIXTURE_SRC) $(LIBRESOBJS) $(HDR) +testfixture.exe: $(TESTFIXTURE_SRC) $(SQLITE3H) $(LIBRESOBJS) $(HDR) $(LTLINK) -DSQLITE_NO_SYNC=1 $(TESTFIXTURE_FLAGS) \ -DBUILD_sqlite -I$(TCLINCDIR) \ $(TESTFIXTURE_SRC) \ @@ -1849,7 +1871,7 @@ smoketest: $(TESTPROGS) @set PATH=$(LIBTCLPATH);$(PATH) .\testfixture.exe $(TOP)\test\main.test $(TESTOPTS) -sqlite3_analyzer.c: $(SQLITE3C) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl +sqlite3_analyzer.c: $(SQLITE3C) $(SQLITE3H) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl echo #define TCLSH 2 > $@ echo #define SQLITE_ENABLE_DBSTAT_VTAB 1 >> $@ copy $@ + $(SQLITE3C) + $(TOP)\src\tclsqlite.c $@ @@ -1868,49 +1890,49 @@ testloadext.lo: $(TOP)\src\test_loadext.c testloadext.dll: testloadext.lo $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /OUT:$@ testloadext.lo -showdb.exe: $(TOP)\tool\showdb.c $(SQLITE3C) +showdb.exe: $(TOP)\tool\showdb.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\tool\showdb.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -showstat4.exe: $(TOP)\tool\showstat4.c $(SQLITE3C) +showstat4.exe: $(TOP)\tool\showstat4.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\tool\showstat4.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -showjournal.exe: $(TOP)\tool\showjournal.c $(SQLITE3C) +showjournal.exe: $(TOP)\tool\showjournal.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\tool\showjournal.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -showwal.exe: $(TOP)\tool\showwal.c $(SQLITE3C) +showwal.exe: $(TOP)\tool\showwal.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\tool\showwal.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -fts3view.exe: $(TOP)\ext\fts3\tool\fts3view.c $(SQLITE3C) +fts3view.exe: $(TOP)\ext\fts3\tool\fts3view.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\ext\fts3\tool\fts3view.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -rollback-test.exe: $(TOP)\tool\rollback-test.c $(SQLITE3C) +rollback-test.exe: $(TOP)\tool\rollback-test.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\tool\rollback-test.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -LogEst.exe: $(TOP)\tool\logest.c sqlite3.h +LogEst.exe: $(TOP)\tool\logest.c $(SQLITE3H) $(LTLINK) $(NO_WARN) -Fe$@ $(TOP)\tool\LogEst.c /link $(LDFLAGS) $(LTLINKOPTS) -wordcount.exe: $(TOP)\test\wordcount.c $(SQLITE3C) +wordcount.exe: $(TOP)\test\wordcount.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\test\wordcount.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -speedtest1.exe: $(TOP)\test\speedtest1.c $(SQLITE3C) +speedtest1.exe: $(TOP)\test\speedtest1.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\test\speedtest1.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) -rbu.exe: $(TOP)\ext\rbu\rbu.c $(TOP)\ext\rbu\sqlite3rbu.c $(SQLITE3C) - $(LTLINK) $(NO_WARN) -DSQLITE_ENABLE_RBU -Fe$@ $(TOP)\ext\rbu\rbu.c $(SQLITE3C) \ - /link $(LDFLAGS) $(LTLINKOPTS) +rbu.exe: $(TOP)\ext\rbu\rbu.c $(TOP)\ext\rbu\sqlite3rbu.c $(SQLITE3C) $(SQLITE3H) + $(LTLINK) $(NO_WARN) -DSQLITE_ENABLE_RBU -Fe$@ \ + $(TOP)\ext\rbu\rbu.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) clean: del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL del /Q *.bsc *.cod *.da *.bb *.bbg gmon.out 2>NUL - del /Q sqlite3.h opcodes.c opcodes.h 2>NUL + del /Q $(SQLITE3C) $(SQLITE3H) opcodes.c opcodes.h 2>NUL del /Q lemon.* lempar.c parse.* 2>NUL del /Q mkkeywordhash.* keywordhash.h 2>NUL del /Q notasharedlib.* 2>NUL diff --git a/manifest b/manifest index 67cd5b4802..c364abf8fa 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C MSVC\smakefile\senhancements\sfor\suse\swith\sthe\sWindows\s10\sSDK. -D 2016-01-22T01:25:15.110 +C Further\srefinements\sto\sthe\sMSVC\smakefile. +D 2016-01-22T03:54:36.710 F Makefile.in 027c1603f255390c43a426671055a31c0a65fdb4 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 89b2e9780d97a6a3d7c89c4ad04d093787be3dc2 +F Makefile.msc 7e45640ca31116b24372d30a4e087078db22fcd8 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 866588d1edf0ccb5b0d33896974338f97564f719 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 29a51c6dcc0ef7cab51aba0024e9c5bec89c6973 -R 9e26ae539c690ec3cae729a6d81b3775 +P ac2e9d3de54d299f92fc35927b6df6d3aaa2dc59 +R 2fd39a9f583616f965419daf8ad2c68a U mistachkin -Z d4ab6d93e282614aa0160682fbcc0beb +Z 2b921b34884313de5b54030da9770cbb diff --git a/manifest.uuid b/manifest.uuid index 5f1ffc501a..51b2a1dd73 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac2e9d3de54d299f92fc35927b6df6d3aaa2dc59 \ No newline at end of file +67625b963a6f5a0c6dff1a04a323e693569c2d94 \ No newline at end of file From d7d305a25aaa60ce55f9e6ec1840b39309282015 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 22 Jan 2016 04:22:36 +0000 Subject: [PATCH 232/232] Enable FTS4 when building the shell with the MSVC makefile. FossilOrigin-Name: e4c07df557cd50786b05eecf011bf94708e6e31b --- Makefile.msc | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index a75045fc98..3621d4f92b 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1308,7 +1308,7 @@ FUZZDATA = \ # when the shell is not being dynamically linked. # !IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0 -SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_SHELL_JSON1 -DSQLITE_ENABLE_FTS5 +SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_SHELL_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 !ENDIF # Extra compiler options for various test tools. diff --git a/manifest b/manifest index c364abf8fa..5d0ee23cca 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Further\srefinements\sto\sthe\sMSVC\smakefile. -D 2016-01-22T03:54:36.710 +C Enable\sFTS4\swhen\sbuilding\sthe\sshell\swith\sthe\sMSVC\smakefile. +D 2016-01-22T04:22:36.961 F Makefile.in 027c1603f255390c43a426671055a31c0a65fdb4 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 7e45640ca31116b24372d30a4e087078db22fcd8 +F Makefile.msc d2b93511a969c0c8fcf52aeb5e426571e8c610d2 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 866588d1edf0ccb5b0d33896974338f97564f719 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ac2e9d3de54d299f92fc35927b6df6d3aaa2dc59 -R 2fd39a9f583616f965419daf8ad2c68a +P 67625b963a6f5a0c6dff1a04a323e693569c2d94 +R a9194694e295a05f59bbd77f1c470bc0 U mistachkin -Z 2b921b34884313de5b54030da9770cbb +Z bf1c280948a8257fdbbacb5c97da93b0 diff --git a/manifest.uuid b/manifest.uuid index 51b2a1dd73..533751ec8a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67625b963a6f5a0c6dff1a04a323e693569c2d94 \ No newline at end of file +e4c07df557cd50786b05eecf011bf94708e6e31b \ No newline at end of file