From 331b67c151b210d60b986af9a2cc845b90ea0221 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 9 Mar 2012 22:02:08 +0000 Subject: [PATCH 01/12] Candidate fix for the optimizer problem described in ticket [b7c8682cc17f3] which can causes a LEFT JOIN to be changed into a INNER JOIN if there are OR terms in the WHERE clause. FossilOrigin-Name: 0dc4cb935514131c99172175d57feec3a1743aa9 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/where.c | 24 +++++++++++++++++++++--- test/where7.test | 2 +- test/where9.test | 28 ++++++++++++++++++++++++---- 5 files changed, 56 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 57d069eb0a..ff717fe1dd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\sWindows,\smake\ssure\sthe\sreturned\stest\scurrent\sdirectory\svalue\sdoes\snot\scontain\sany\sbackslashes. -D 2012-03-08T20:28:31.444 +C Candidate\sfix\sfor\sthe\soptimizer\sproblem\sdescribed\sin\sticket\s\n[b7c8682cc17f3]\swhich\scan\scauses\sa\sLEFT\sJOIN\sto\sbe\schanged\ninto\sa\sINNER\sJOIN\sif\sthere\sare\sOR\sterms\sin\sthe\sWHERE\sclause. +D 2012-03-09T22:02:08.875 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -253,7 +253,7 @@ F src/vtab.c ab90fb600a3f5e4b7c48d22a4cdb2d6b23239847 F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c f2cf59751f7facb4c422adf83ddc989aa5772874 +F src/where.c d4ce63a2887dab037d9d9830abbfcac2643e308a F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 @@ -937,10 +937,10 @@ F test/where3.test 667e75642102c97a00bf9b23d3cb267db321d006 F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b -F test/where7.test 814d7373413398e074f134cff5f8872e2c08bd3b +F test/where7.test 5c566388f0cc318b0032ce860f4ac5548e3c265a F test/where8.test a6c740fd286d7883e274e17b6230a9d672a7ab1f F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 -F test/where9.test cd4ee5e455799ddba7041e5ac539044bb24e3874 +F test/where9.test ae98dc22ef9b6f2bc81e9f164e41b38faa9bda06 F test/whereA.test 24c234263c8fe358f079d5e57d884fb569d2da0a F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5 F test/whereC.test 13ff5ec0dba407c0e0c075980c75b3275a6774e5 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 82bcd7ec1531f6d71c079578434c58d3ce46a1de -R 481f07eae7a20043918617293f6bf255 -U mistachkin -Z e4b7999e3f65d6915663c98d5d60a2e1 +P efee39e64bd95c284220fdb0ae8ee6c1847fadab +R bea1320a1e93f035f866bb48777a9a0b +U drh +Z baafcf2bb8e1f4793d13146917501256 diff --git a/manifest.uuid b/manifest.uuid index 65ab8c5d21..b0f211922a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -efee39e64bd95c284220fdb0ae8ee6c1847fadab \ No newline at end of file +0dc4cb935514131c99172175d57feec3a1743aa9 \ No newline at end of file diff --git a/src/where.c b/src/where.c index eda8d5fb8e..1def2db917 100644 --- a/src/where.c +++ b/src/where.c @@ -4342,10 +4342,25 @@ static Bitmask codeOneLoopStart( ** Then for every term xN, evaluate as the subexpression: xN AND z ** That way, terms in y that are factored into the disjunction will ** be picked up by the recursive calls to sqlite3WhereBegin() below. + ** + ** Actually, each subexpression is converted to "xN AND w" where w is + ** the "interesting" terms of z - terms that did not originate in the + ** ON or USING clause of a LEFT JOIN, and terms that are usable as + ** indices. */ if( pWC->nTerm>1 ){ - pAndExpr = sqlite3ExprAlloc(pParse->db, TK_AND, 0, 0); - pAndExpr->pRight = pWhere; + int ii; + for(ii=0; iinTerm; ii++){ + Expr *pExpr = pWC->a[ii].pExpr; + if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; + if( pWC->a[ii].wtFlags & (TERM_VIRTUAL|TERM_ORINFO) ) continue; + if( (pWC->a[ii].eOperator & WO_ALL)==0 ) continue; + pExpr = sqlite3ExprDup(pParse->db, pExpr, 0); + pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr); + } + if( pAndExpr ){ + pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0); + } } for(ii=0; iinTerm; ii++){ @@ -4387,7 +4402,10 @@ static Bitmask codeOneLoopStart( } } } - sqlite3DbFree(pParse->db, pAndExpr); + if( pAndExpr ){ + pAndExpr->pLeft = 0; + sqlite3ExprDelete(pParse->db, pAndExpr); + } sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk); sqlite3VdbeResolveLabel(v, iLoopBody); diff --git a/test/where7.test b/test/where7.test index ffb7173d21..b6cd7ccbbc 100644 --- a/test/where7.test +++ b/test/where7.test @@ -23339,7 +23339,7 @@ do_execsql_test where7-3.1 { OR t301.c8 = 1407424651264000) ORDER BY t302.c5 LIMIT 200; } { - 0 0 1 {SEARCH TABLE t301 USING COVERING INDEX t301_c4 (c4=?) (~5 rows)} + 0 0 1 {SEARCH TABLE t301 USING COVERING INDEX t301_c4 (c4=?) (~10 rows)} 0 0 1 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)} 0 1 0 {SEARCH TABLE t302 USING INDEX t302_c8_c3 (c8=? AND c3>?) (~2 rows)} 0 0 0 {USE TEMP B-TREE FOR ORDER BY} diff --git a/test/where9.test b/test/where9.test index 8c5c96e2a8..23260a6b65 100644 --- a/test/where9.test +++ b/test/where9.test @@ -364,7 +364,7 @@ ifcapable explain { } { 0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)} 0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?) (~2 rows)} - 0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~5 rows)} + 0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~10 rows)} } do_execsql_test where9-3.2 { EXPLAIN QUERY PLAN @@ -374,7 +374,7 @@ ifcapable explain { } { 0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)} 0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?) (~2 rows)} - 0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~5 rows)} + 0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~10 rows)} } } @@ -453,8 +453,8 @@ ifcapable explain { do_execsql_test where9-5.1 { EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c=31031 OR d IS NULL) } { - 0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?) (~2 rows)} - 0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?) (~2 rows)} + 0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?) (~3 rows)} + 0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?) (~3 rows)} } # In contrast, b=1000 is preferred over any OR-clause. @@ -856,5 +856,25 @@ do_test where9-7.3.2 { } } {79 81} +# Fix for ticket [b7c8682cc17f32903f03a610bd0d35ffd3c1e6e4] +# "Incorrect result from LEFT JOIN with OR in the WHERE clause" +# +do_test where9-8.1 { + db eval { + CREATE TABLE t81(a INTEGER PRIMARY KEY, b, c, d); + CREATE TABLE t82(x INTEGER PRIMARY KEY, y); + CREATE TABLE t83(p INTEGER PRIMARY KEY, q); + + INSERT INTO t81 VALUES(2,3,4,5); + INSERT INTO t81 VALUES(3,4,5,6); + INSERT INTO t82 VALUES(2,4); + INSERT INTO t83 VALUES(5,55); + + SELECT * + FROM t81 LEFT JOIN t82 ON y=b JOIN t83 + WHERE c==p OR d==p + ORDER BY +a; + } +} {2 3 4 5 {} {} 5 55 3 4 5 6 2 4 5 55} finish_test From 421377e67ac7b5289c667a3ef4a23826908213b4 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 15 Mar 2012 21:28:54 +0000 Subject: [PATCH 02/12] Add the sqlite3_db_readonly() interface. This is still tentative, pending a closer look at other ideas to accomplish the same thing. FossilOrigin-Name: 254f99ea9ff1534948bdb179e69ab0c940c87ec1 --- manifest | 23 ++++++++------- manifest.uuid | 2 +- src/main.c | 75 +++++++++++++++++++++++++++--------------------- src/sqlite.h.in | 9 ++++++ src/sqliteInt.h | 1 + src/test1.c | 25 ++++++++++++++++ test/pager1.test | 18 ++++++++++++ 7 files changed, 110 insertions(+), 43 deletions(-) diff --git a/manifest b/manifest index ff717fe1dd..13a39a43c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Candidate\sfix\sfor\sthe\soptimizer\sproblem\sdescribed\sin\sticket\s\n[b7c8682cc17f3]\swhich\scan\scauses\sa\sLEFT\sJOIN\sto\sbe\schanged\ninto\sa\sINNER\sJOIN\sif\sthere\sare\sOR\sterms\sin\sthe\sWHERE\sclause. -D 2012-03-09T22:02:08.875 +C Add\sthe\ssqlite3_db_readonly()\sinterface.\s\sThis\sis\sstill\stentative,\spending\na\scloser\slook\sat\sother\sideas\sto\saccomplish\sthe\ssame\sthing. +D 2012-03-15T21:28:54.896 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -147,7 +147,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c dcb4a15254dca9cc59dba63e813a8c140c021832 +F src/main.c 91458c713e9b7f8dbc98d79e78f1150f0ca9c2a1 F src/malloc.c 15afac5e59b6584efe072e9933aefb4230e74f97 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -182,14 +182,14 @@ F src/resolve.c 3d3e80a98f203ac6b9329e9621e29eda85ddfd40 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 44ccdcb5d2a1c48622c179b2d72167b716388581 F src/shell.c aa28f117033ba3e44b5eaaf2ad572222bcdfd66e -F src/sqlite.h.in f46e368d1a28b09d876e35444785674d170f2d62 +F src/sqlite.h.in 307317b26050634adc0e22c1db2ff071b3262088 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h b013dab7d43fb67c3ca2f0253d7863abb37e233c +F src/sqliteInt.h e65429a6f19b41720561b9434b2192574a91cfa2 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 4568e72dfd36b6a5911f93457364deb072e0b03a F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 2aeb69958965dad0842d5ea1456f1a958ef296e6 -F src/test1.c 328cbe4a4ee6d10d67ece2a7adaa2770569fae0f +F src/test1.c 07f30e8714bab94d8de8a88865d9c59bc512a1a8 F src/test2.c 711555927f1f7e8db9aab86b512bc6934a774abe F src/test3.c 91d3f1a09cfae3533ef17d8b484a160f3d1f1a21 F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 @@ -625,7 +625,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3 -F test/pager1.test 101032cb9d8093806600b343fdcf78ba51c1e3e9 +F test/pager1.test 6e43e79d6ac1fc31b494ff3a0b56445b7eda5d2b F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442 @@ -992,7 +992,10 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P efee39e64bd95c284220fdb0ae8ee6c1847fadab -R bea1320a1e93f035f866bb48777a9a0b +P 0dc4cb935514131c99172175d57feec3a1743aa9 +R 851ef17fd9b25c32052af88e7352afdb +T *branch * db-readonly-api +T *sym-db-readonly-api * +T -sym-trunk * U drh -Z baafcf2bb8e1f4793d13146917501256 +Z 348596b004b2d886ba8debcb3d4e71fa diff --git a/manifest.uuid b/manifest.uuid index b0f211922a..b7a8d8211c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0dc4cb935514131c99172175d57feec3a1743aa9 \ No newline at end of file +254f99ea9ff1534948bdb179e69ab0c940c87ec1 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 3a1dff576a..d148b4b42c 100644 --- a/src/main.c +++ b/src/main.c @@ -2704,35 +2704,27 @@ int sqlite3_extended_result_codes(sqlite3 *db, int onoff){ */ int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){ int rc = SQLITE_ERROR; - int iDb; + Btree *pBtree; + sqlite3_mutex_enter(db->mutex); - if( zDbName==0 ){ - iDb = 0; - }else{ - for(iDb=0; iDbnDb; iDb++){ - if( strcmp(db->aDb[iDb].zName, zDbName)==0 ) break; - } - } - if( iDbnDb ){ - Btree *pBtree = db->aDb[iDb].pBt; - if( pBtree ){ - Pager *pPager; - sqlite3_file *fd; - sqlite3BtreeEnter(pBtree); - pPager = sqlite3BtreePager(pBtree); - assert( pPager!=0 ); - fd = sqlite3PagerFile(pPager); - assert( fd!=0 ); - if( op==SQLITE_FCNTL_FILE_POINTER ){ - *(sqlite3_file**)pArg = fd; - rc = SQLITE_OK; - }else if( fd->pMethods ){ - rc = sqlite3OsFileControl(fd, op, pArg); - }else{ - rc = SQLITE_NOTFOUND; - } - sqlite3BtreeLeave(pBtree); + pBtree = sqlite3DbNameToBtree(db, zDbName); + if( pBtree ){ + Pager *pPager; + sqlite3_file *fd; + sqlite3BtreeEnter(pBtree); + pPager = sqlite3BtreePager(pBtree); + assert( pPager!=0 ); + fd = sqlite3PagerFile(pPager); + assert( fd!=0 ); + if( op==SQLITE_FCNTL_FILE_POINTER ){ + *(sqlite3_file**)pArg = fd; + rc = SQLITE_OK; + }else if( fd->pMethods ){ + rc = sqlite3OsFileControl(fd, op, pArg); + }else{ + rc = SQLITE_NOTFOUND; } + sqlite3BtreeLeave(pBtree); } sqlite3_mutex_leave(db->mutex); return rc; @@ -3028,15 +3020,34 @@ sqlite3_int64 sqlite3_uri_int64( } /* -** Return the filename of the database associated with a database -** connection. +** Return the Btree pointer identified by zDbName. Return NULL if not found. */ -const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){ +Btree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){ int i; for(i=0; inDb; i++){ - if( db->aDb[i].pBt && sqlite3StrICmp(zDbName, db->aDb[i].zName)==0 ){ - return sqlite3BtreeGetFilename(db->aDb[i].pBt); + if( db->aDb[i].pBt + && (zDbName==0 || sqlite3StrICmp(zDbName, db->aDb[i].zName)==0) + ){ + return db->aDb[i].pBt; } } return 0; } + +/* +** Return the filename of the database associated with a database +** connection. +*/ +const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){ + Btree *pBt = sqlite3DbNameToBtree(db, zDbName); + return pBt ? sqlite3BtreeGetFilename(pBt) : 0; +} + +/* +** Return 1 if database is read-only or 0 if read/write. Return -1 if +** no such database exists. +*/ +int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){ + Btree *pBt = sqlite3DbNameToBtree(db, zDbName); + return pBt ? sqlite3PagerIsreadonly(sqlite3BtreePager(pBt)) : -1; +} diff --git a/src/sqlite.h.in b/src/sqlite.h.in index b43fe208f8..3c82ebd600 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4494,6 +4494,15 @@ sqlite3 *sqlite3_db_handle(sqlite3_stmt*); */ const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); +/* +** CAPI3REF: Determine if a database is read-only +** +** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N +** of connection D is read-only, 0 if it is read/write, and -1 if N is not +** the name of a database in connection C. +*/ +int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); + /* ** CAPI3REF: Find the next prepared statement ** diff --git a/src/sqliteInt.h b/src/sqliteInt.h index cfe8fd64fb..15c3f302e2 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2701,6 +2701,7 @@ void sqlite3AddCollateType(Parse*, Token*); void sqlite3EndTable(Parse*,Token*,Token*,Select*); int sqlite3ParseUri(const char*,const char*,unsigned int*, sqlite3_vfs**,char**,char **); +Btree *sqlite3DbNameToBtree(sqlite3*,const char*); int sqlite3CodeOnce(Parse *); Bitvec *sqlite3BitvecCreate(u32); diff --git a/src/test1.c b/src/test1.c index 281823d5a8..e1220cf11f 100644 --- a/src/test1.c +++ b/src/test1.c @@ -4665,6 +4665,30 @@ static int test_db_filename( return TCL_OK; } +/* +** Usage: sqlite3_db_readonly DB DBNAME +** +** Return 1 or 0 if DBNAME is readonly or not. Return -1 if DBNAME does +** not exist. +*/ +static int test_db_readonly( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3 *db; + const char *zDbName; + if( objc!=3 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); + return TCL_ERROR; + } + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; + zDbName = Tcl_GetString(objv[2]); + Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_db_readonly(db, zDbName))); + return TCL_OK; +} + /* ** Usage: sqlite3_soft_heap_limit ?N? ** @@ -6055,6 +6079,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_release_memory", test_release_memory, 0}, { "sqlite3_db_release_memory", test_db_release_memory, 0}, { "sqlite3_db_filename", test_db_filename, 0}, + { "sqlite3_db_readonly", test_db_readonly, 0}, { "sqlite3_soft_heap_limit", test_soft_heap_limit, 0}, { "sqlite3_thread_cleanup", test_thread_cleanup, 0}, { "sqlite3_pager_refcounts", test_pager_refcounts, 0}, diff --git a/test/pager1.test b/test/pager1.test index 3f3c12c541..96fcb5ba0e 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -887,6 +887,24 @@ do_test pager1.4.7.3 { delete_file test.db-journal file exists test.db-journal } {0} +do_test pager1.4.8.1 { + catch {file attributes test.db -permissions r--------} + catch {file attributes test.db -readonly 1} + sqlite3 db test.db + db eval { SELECT * FROM t1 } + sqlite3_db_readonly db main +} {1} +do_test pager1.4.8.2 { + sqlite3_db_readonly db xyz +} {-1} +do_test pager1.4.8.3 { + db close + catch {file attributes test.db -permissions rw-rw-rw-} + catch {file attributes test.db -readonly 0} + sqlite3 db test.db + db eval { SELECT * FROM t1 } + sqlite3_db_readonly db main +} {0} #------------------------------------------------------------------------- # The following tests deal with multi-file commits. From 7a48480d0772dde6f5a7ca3c10f878c8202b9ee4 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 16 Mar 2012 00:28:11 +0000 Subject: [PATCH 03/12] Fix harmless compiler warnings. FossilOrigin-Name: 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e --- ext/fts3/fts3_porter.c | 1 + ext/fts3/fts3_tokenizer1.c | 1 + manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/where.c | 15 +++++++-------- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ext/fts3/fts3_porter.c b/ext/fts3/fts3_porter.c index 84aa132229..579745b85f 100644 --- a/ext/fts3/fts3_porter.c +++ b/ext/fts3/fts3_porter.c @@ -630,6 +630,7 @@ static const sqlite3_tokenizer_module porterTokenizerModule = { porterOpen, porterClose, porterNext, + 0 }; /* diff --git a/ext/fts3/fts3_tokenizer1.c b/ext/fts3/fts3_tokenizer1.c index d11a499766..deea06d92b 100644 --- a/ext/fts3/fts3_tokenizer1.c +++ b/ext/fts3/fts3_tokenizer1.c @@ -218,6 +218,7 @@ static const sqlite3_tokenizer_module simpleTokenizerModule = { simpleOpen, simpleClose, simpleNext, + 0, }; /* diff --git a/manifest b/manifest index b92d8e9431..839b111215 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_db_readonly()\sAPI\sto\strunk. -D 2012-03-15T22:54:37.033 +C Fix\sharmless\scompiler\swarnings. +D 2012-03-16T00:28:11.282 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -71,13 +71,13 @@ F ext/fts3/fts3_expr.c dbc7ba4c3a6061adde0f38ed8e9b349568299551 F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c 6c8f395cdf9e1e3afa7fadb7e523dbbf381c6dfa -F ext/fts3/fts3_porter.c b7e5276f9f0a5fc7018b6fa55ce0f31f269ef881 +F ext/fts3/fts3_porter.c a465b49fcb8249a755792f87516eff182efa42b3 F ext/fts3/fts3_snippet.c c9e126c20760988aa7c43c6ea1379db34738282e F ext/fts3/fts3_term.c d3466cf99432291be08e379d89645462431809d6 F ext/fts3/fts3_test.c 6b7cc68aef4efb084e1449f7d20c4b20d3bdf6b4 F ext/fts3/fts3_tokenizer.c 3da7254a9881f7e270ab28e2004e0d22b3212bce F ext/fts3/fts3_tokenizer.h 66dec98e365854b6cd2d54f1a96bb6d428fc5a68 -F ext/fts3/fts3_tokenizer1.c 0dde8f307b8045565cf63797ba9acfaff1c50c68 +F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 F ext/fts3/fts3_write.c f87bb2d27d31cb7a7bf306747079095393c9d073 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 @@ -253,7 +253,7 @@ F src/vtab.c ab90fb600a3f5e4b7c48d22a4cdb2d6b23239847 F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c d4ce63a2887dab037d9d9830abbfcac2643e308a +F src/where.c 6baab5dfcf4472552c0346d04f6fd2f4f8539c78 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 0dc4cb935514131c99172175d57feec3a1743aa9 254f99ea9ff1534948bdb179e69ab0c940c87ec1 -R 16a5b52f9383f81bfef8d52e60214ef8 +P fed134a5f395533de0c9d76950697c060ddb126d +R 9a71f3ab5326ee35b9bbd87536e2a1d5 U drh -Z 7730c197df8d847371e263295817abcb +Z 60cd8a049ba54606f3a162ca33790b57 diff --git a/manifest.uuid b/manifest.uuid index b419484dbc..9a63bfc3a0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fed134a5f395533de0c9d76950697c060ddb126d \ No newline at end of file +74eadeec34c4b19cf5f8b7f648db3b7ad601a00e \ No newline at end of file diff --git a/src/where.c b/src/where.c index 1def2db917..e6083f0033 100644 --- a/src/where.c +++ b/src/where.c @@ -3802,8 +3802,7 @@ static Bitmask codeOneLoopStart( WhereInfo *pWInfo, /* Complete information about the WHERE clause */ int iLevel, /* Which level of pWInfo->a[] should be coded */ u16 wctrlFlags, /* One of the WHERE_* flags defined in sqliteInt.h */ - Bitmask notReady, /* Which tables are currently available */ - Expr *pWhere /* Complete WHERE clause */ + Bitmask notReady /* Which tables are currently available */ ){ int j, k; /* Loop counters */ int iCur; /* The VDBE cursor for the table */ @@ -4349,12 +4348,12 @@ static Bitmask codeOneLoopStart( ** indices. */ if( pWC->nTerm>1 ){ - int ii; - for(ii=0; iinTerm; ii++){ - Expr *pExpr = pWC->a[ii].pExpr; + int iTerm; + for(iTerm=0; iTermnTerm; iTerm++){ + Expr *pExpr = pWC->a[iTerm].pExpr; if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; - if( pWC->a[ii].wtFlags & (TERM_VIRTUAL|TERM_ORINFO) ) continue; - if( (pWC->a[ii].eOperator & WO_ALL)==0 ) continue; + if( pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_ORINFO) ) continue; + if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue; pExpr = sqlite3ExprDup(pParse->db, pExpr, 0); pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr); } @@ -5061,7 +5060,7 @@ WhereInfo *sqlite3WhereBegin( for(i=0; ia[i]; explainOneScan(pParse, pTabList, pLevel, i, pLevel->iFrom, wctrlFlags); - notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady, pWhere); + notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady); pWInfo->iContinue = pLevel->addrCont; } From c8d7b24e939bb0fb0ddedbffb7d867b0d7af444e Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 16 Mar 2012 16:52:54 +0000 Subject: [PATCH 04/12] Cherrypick the [3475092cff] fix for 32-bit overflow with large language-ids into trunk. FossilOrigin-Name: 2755edc7f1186ba8955f2c3550a90f40a55ddae2 --- ext/fts3/fts3_write.c | 58 +++++++++++++++++------- manifest | 14 +++--- manifest.uuid | 2 +- test/fts4langid.test | 101 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 152 insertions(+), 23 deletions(-) diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 8f97c8be98..bc20dfa3f3 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -434,16 +434,42 @@ int sqlite3Fts3ReadLock(Fts3Table *p){ return rc; } +/* +** FTS maintains a separate indexes for each language-id (a 32-bit integer). +** Within each language id, a separate index is maintained to store the +** document terms, and each configured prefix size (configured the FTS +** "prefix=" option). And each index consists of multiple levels ("relative +** levels"). +** +** All three of these values (the language id, the specific index and the +** level within the index) are encoded in 64-bit integer values stored +** in the %_segdir table on disk. This function is used to convert three +** separate component values into the single 64-bit integer value that +** can be used to query the %_segdir table. +** +** Specifically, each language-id/index combination is allocated 1024 +** 64-bit integer level values ("absolute levels"). The main terms index +** for language-id 0 is allocate values 0-1023. The first prefix index +** (if any) for language-id 0 is allocated values 1024-2047. And so on. +** Language 1 indexes are allocated immediately following language 0. +** +** So, for a system with nPrefix prefix indexes configured, the block of +** absolute levels that corresponds to language-id iLangid and index +** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024). +*/ static sqlite3_int64 getAbsoluteLevel( Fts3Table *p, int iLangid, int iIndex, int iLevel ){ + sqlite3_int64 iBase; /* First absolute level for iLangid/iIndex */ assert( iLangid>=0 ); assert( p->nIndex>0 ); assert( iIndex>=0 && iIndexnIndex ); - return (iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL + iLevel; + + iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL; + return iBase + iLevel; } @@ -468,7 +494,7 @@ int sqlite3Fts3AllSegdirs( Fts3Table *p, /* FTS3 table */ int iLangid, /* Language being queried */ int iIndex, /* Index for p->aIndex[] */ - int iLevel, /* Level to select */ + int iLevel, /* Level to select (relative level) */ sqlite3_stmt **ppStmt /* OUT: Compiled statement */ ){ int rc; @@ -483,7 +509,7 @@ int sqlite3Fts3AllSegdirs( rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0); if( rc==SQLITE_OK ){ sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); - sqlite3_bind_int(pStmt, 2, + sqlite3_bind_int64(pStmt, 2, getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1) ); } @@ -491,7 +517,7 @@ int sqlite3Fts3AllSegdirs( /* "SELECT * FROM %_segdir WHERE level = ? ORDER BY ..." */ rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0); if( rc==SQLITE_OK ){ - sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)); + sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel)); } } *ppStmt = pStmt; @@ -1763,7 +1789,7 @@ static int fts3WriteSegment( */ static int fts3WriteSegdir( Fts3Table *p, /* Virtual table handle */ - int iLevel, /* Value for "level" field */ + sqlite3_int64 iLevel, /* Value for "level" field (absolute level) */ int iIdx, /* Value for "idx" field */ sqlite3_int64 iStartBlock, /* Value for "start_block" field */ sqlite3_int64 iLeafEndBlock, /* Value for "leaves_end_block" field */ @@ -1774,7 +1800,7 @@ static int fts3WriteSegdir( sqlite3_stmt *pStmt; int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0); if( rc==SQLITE_OK ){ - sqlite3_bind_int(pStmt, 1, iLevel); + sqlite3_bind_int64(pStmt, 1, iLevel); sqlite3_bind_int(pStmt, 2, iIdx); sqlite3_bind_int64(pStmt, 3, iStartBlock); sqlite3_bind_int64(pStmt, 4, iLeafEndBlock); @@ -2157,7 +2183,7 @@ static int fts3SegWriterAdd( static int fts3SegWriterFlush( Fts3Table *p, /* Virtual table handle */ SegmentWriter *pWriter, /* SegmentWriter to flush to the db */ - int iLevel, /* Value for 'level' column of %_segdir */ + sqlite3_int64 iLevel, /* Value for 'level' column of %_segdir */ int iIdx /* Value for 'idx' column of %_segdir */ ){ int rc; /* Return code */ @@ -2239,7 +2265,7 @@ static int fts3SegmentMaxLevel( Fts3Table *p, int iLangid, int iIndex, - int *pnMax + sqlite3_int64 *pnMax ){ sqlite3_stmt *pStmt; int rc; @@ -2253,12 +2279,12 @@ static int fts3SegmentMaxLevel( */ rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0); if( rc!=SQLITE_OK ) return rc; - sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); - sqlite3_bind_int(pStmt, 2, + sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); + sqlite3_bind_int64(pStmt, 2, getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1) ); if( SQLITE_ROW==sqlite3_step(pStmt) ){ - *pnMax = sqlite3_column_int(pStmt, 0); + *pnMax = sqlite3_column_int64(pStmt, 0); } return sqlite3_reset(pStmt); } @@ -2307,15 +2333,17 @@ static int fts3DeleteSegdir( if( iLevel==FTS3_SEGCURSOR_ALL ){ rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0); if( rc==SQLITE_OK ){ - sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); - sqlite3_bind_int(pDelete, 2, + sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); + sqlite3_bind_int64(pDelete, 2, getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1) ); } }else{ rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0); if( rc==SQLITE_OK ){ - sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel)); + sqlite3_bind_int64( + pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel) + ); } } @@ -2792,7 +2820,7 @@ static int fts3SegmentMerge( ){ int rc; /* Return code */ int iIdx = 0; /* Index of new segment */ - int iNewLevel = 0; /* Level/index to create new segment at */ + sqlite3_int64 iNewLevel = 0; /* Level/index to create new segment at */ SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */ Fts3SegFilter filter; /* Segment term filter condition */ Fts3MultiSegReader csr; /* Cursor to iterate through level(s) */ diff --git a/manifest b/manifest index 839b111215..4f001824a3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings. -D 2012-03-16T00:28:11.282 +C Cherrypick\sthe\s[3475092cff]\sfix\sfor\s32-bit\soverflow\swith\slarge\slanguage-ids\ninto\strunk. +D 2012-03-16T16:52:54.032 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -78,7 +78,7 @@ F ext/fts3/fts3_test.c 6b7cc68aef4efb084e1449f7d20c4b20d3bdf6b4 F ext/fts3/fts3_tokenizer.c 3da7254a9881f7e270ab28e2004e0d22b3212bce F ext/fts3/fts3_tokenizer.h 66dec98e365854b6cd2d54f1a96bb6d428fc5a68 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 -F ext/fts3/fts3_write.c f87bb2d27d31cb7a7bf306747079095393c9d073 +F ext/fts3/fts3_write.c 8eedfeb2e61114cfd94fd1d917daf3658203332c F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -496,7 +496,7 @@ F test/fts3snippet.test 8e956051221a34c7daeb504f023cb54d5fa5a8b2 F test/fts3sort.test 95be0b19d7e41c44b29014f13ea8bddd495fd659 F test/fts4aa.test 6e7f90420b837b2c685f3bcbe84c868492d40a68 F test/fts4content.test 17b2360f7d1a9a7e5aa8022783f5c5731b6dfd4f -F test/fts4langid.test fabdd5a8db0fa00292e0704809f566e3fb6dba3a +F test/fts4langid.test 2081c357bb6f170f34ef8e08c6abb88002b95c69 F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P fed134a5f395533de0c9d76950697c060ddb126d -R 9a71f3ab5326ee35b9bbd87536e2a1d5 +P 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e +R da59c6040c440e1d087c29c77d94171a U drh -Z 60cd8a049ba54606f3a162ca33790b57 +Z 86f53efe49c877ef67da98d4e974121b diff --git a/manifest.uuid b/manifest.uuid index 9a63bfc3a0..3b6c5ce27f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -74eadeec34c4b19cf5f8b7f648db3b7ad601a00e \ No newline at end of file +2755edc7f1186ba8955f2c3550a90f40a55ddae2 \ No newline at end of file diff --git a/test/fts4langid.test b/test/fts4langid.test index 08f1a21c17..8ad06766b7 100644 --- a/test/fts4langid.test +++ b/test/fts4langid.test @@ -382,4 +382,105 @@ do_catchsql_test 4.1.5 { INSERT INTO t4(content, lid) VALUES('hello world', 101) } {1 {SQL logic error or missing database}} +#------------------------------------------------------------------------- +# Test cases 5.* +# +# The following test cases are designed to detect a 32-bit overflow bug +# that existed at one point. +# +proc build_multilingual_db_3 {db} { + $db eval { + CREATE VIRTUAL TABLE t5 USING fts4(languageid=lid); + } + set languages [list 0 1 2 [expr 1<<30]] + + foreach lid $languages { + execsql { + INSERT INTO t5(docid, content, lid) VALUES( + $lid, 'My language is ' || $lid, $lid + ) + } + } +} + +do_test 5.1.0 { + reset_db + build_multilingual_db_3 db +} {} + +do_execsql_test 5.1.1 { + SELECT level FROM t5_segdir; +} [list 0 1024 2048 [expr 1<<40]] + +do_execsql_test 5.1.2 {SELECT docid FROM t5 WHERE t5 MATCH 'language'} 0 +foreach langid [list 0 1 2 [expr 1<<30]] { + do_execsql_test 5.2.$langid { + SELECT docid FROM t5 WHERE t5 MATCH 'language' AND lid = $langid + } $langid +} + +set lid [expr 1<<30] +do_execsql_test 5.3.1 { + CREATE VIRTUAL TABLE t6 USING fts4(languageid=lid); + INSERT INTO t6 VALUES('I belong to language 0!'); +} +do_test 5.3.2 { + for {set i 0} {$i < 20} {incr i} { + execsql { + INSERT INTO t6(content, lid) VALUES( + 'I (row '||$i||') belong to langauge N!', $lid + ); + } + } + execsql { SELECT docid FROM t6 WHERE t6 MATCH 'belong' } +} {1} + +do_test 5.3.3 { + execsql { SELECT docid FROM t6 WHERE t6 MATCH 'belong' AND lid=$lid} +} {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21} + +do_execsql_test 5.3.4 { INSERT INTO t6(t6) VALUES('optimize') } {} +do_execsql_test 5.3.5 { SELECT docid FROM t6 WHERE t6 MATCH 'belong' } {1} +do_execsql_test 5.3.6 { + SELECT docid FROM t6 WHERE t6 MATCH 'belong' AND lid=$lid +} {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21} + + +set lid [expr 1<<30] +foreach lid [list 4 [expr 1<<30]] { + do_execsql_test 5.4.$lid.1 { + DELETE FROM t6; + SELECT count(*) FROM t6_segdir; + SELECT count(*) FROM t6_segments; + } {0 0} + do_execsql_test 5.4.$lid.2 { + INSERT INTO t6(content, lid) VALUES('zero zero zero', $lid); + INSERT INTO t6(content, lid) VALUES('zero zero one', $lid); + INSERT INTO t6(content, lid) VALUES('zero one zero', $lid); + INSERT INTO t6(content, lid) VALUES('zero one one', $lid); + INSERT INTO t6(content, lid) VALUES('one zero zero', $lid); + INSERT INTO t6(content, lid) VALUES('one zero one', $lid); + INSERT INTO t6(content, lid) VALUES('one one zero', $lid); + INSERT INTO t6(content, lid) VALUES('one one one', $lid); + + SELECT docid FROM t6 WHERE t6 MATCH '"zero zero"' AND lid=$lid; + } {1 2 5} + + do_execsql_test 5.4.$lid.3 { + SELECT count(*) FROM t6_segdir; + SELECT count(*) FROM t6_segments; + } {8 0} + + do_execsql_test 5.4.$lid.4 { + INSERT INTO t6(t6) VALUES('optimize'); + SELECT docid FROM t6 WHERE t6 MATCH '"zero zero"' AND lid=$lid; + } {1 2 5} + + do_execsql_test 5.4.$lid.5 { + SELECT count(*) FROM t6_segdir; + SELECT count(*) FROM t6_segments; + } {1 0} +} + + finish_test From 1a342a4a73fa77abd61064f11893041ed38f61f1 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 16 Mar 2012 17:00:49 +0000 Subject: [PATCH 05/12] Update the trace2.test script for languageid. FossilOrigin-Name: a11528ac575fa20fd8022756d042a32fe1272e12 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/trace2.test | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 4f001824a3..c4d9e8ea38 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Cherrypick\sthe\s[3475092cff]\sfix\sfor\s32-bit\soverflow\swith\slarge\slanguage-ids\ninto\strunk. -D 2012-03-16T16:52:54.032 +C Update\sthe\strace2.test\sscript\sfor\slanguageid. +D 2012-03-16T17:00:49.764 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -855,7 +855,7 @@ F test/tkt3997.test a335fa41ca3985660a139df7b734a26ef53284bd F test/tkt4018.test 7c2c9ba4df489c676a0a7a0e809a1fb9b2185bd1 F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/trace.test 4b36a41a3e9c7842151af6da5998f5080cdad9e5 -F test/trace2.test 962175290996d5f06dc4402ca218bbfc7df4cb20 +F test/trace2.test 37c3a05701e7f133ebdf078a61aa9479a23a73b0 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test d5337e61de45e66b1fcbf9db833fa8c82e624b22 F test/trans3.test 373ac5183cc56be69f48ae44090e7f672939f732 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e -R da59c6040c440e1d087c29c77d94171a +P 2755edc7f1186ba8955f2c3550a90f40a55ddae2 +R ec577cf791cfb44b791ae9dc3e0f7343 U drh -Z 86f53efe49c877ef67da98d4e974121b +Z d80fb6c4fb859b25e151c85bda23f682 diff --git a/manifest.uuid b/manifest.uuid index 3b6c5ce27f..8412294df1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2755edc7f1186ba8955f2c3550a90f40a55ddae2 \ No newline at end of file +a11528ac575fa20fd8022756d042a32fe1272e12 \ No newline at end of file diff --git a/test/trace2.test b/test/trace2.test index 42738db3aa..0e3130ec00 100644 --- a/test/trace2.test +++ b/test/trace2.test @@ -141,6 +141,7 @@ ifcapable fts3 { INSERT INTO x1(x1) VALUES('optimize'); } { "INSERT INTO x1(x1) VALUES('optimize');" + "-- SELECT DISTINCT level / (1024 * ?) FROM 'main'.'x1_segdir'" "-- SELECT idx, start_block, leaves_end_block, end_block, root FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?ORDER BY level DESC, idx ASC" "-- SELECT max(level) FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?" "-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)" From a2e85abaa293d86408fc07300b3b5cc8341d8e0e Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 17 Mar 2012 09:43:09 +0000 Subject: [PATCH 06/12] Modify a test in ioerr2.test to account for the new SQLITE_ABORT_ROLLBACK extended error code. FossilOrigin-Name: affaebde109e8dd851474ffe7b7d48b1aae8c7ed --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/ioerr2.test | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c4d9e8ea38..2aba70d878 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\strace2.test\sscript\sfor\slanguageid. -D 2012-03-16T17:00:49.764 +C Modify\sa\stest\sin\sioerr2.test\sto\saccount\sfor\sthe\snew\sSQLITE_ABORT_ROLLBACK\sextended\serror\scode. +D 2012-03-17T09:43:09.270 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -538,7 +538,7 @@ F test/interrupt.test 42e7cf98646fd9cb4a3b131a93ed3c50b9e149f1 F test/intpkey.test 537669fd535f62632ca64828e435b9e54e8d677f F test/io.test b278aa8fa609ed0dcc825df31b2d9f526c5a52bd F test/ioerr.test 40bb2cfcab63fb6aa7424cd97812a84bc16b5fb8 -F test/ioerr2.test 1b56cb80d5b0726ee3ba325ca175734541e32955 +F test/ioerr2.test 9d71166f8466eda510f1af6137bdabaa82b5408d F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd F test/ioerr4.test f130fe9e71008577b342b8874d52984bd04ede2c F test/ioerr5.test 2edfa4fb0f896f733071303b42224df8bedd9da4 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 2755edc7f1186ba8955f2c3550a90f40a55ddae2 -R ec577cf791cfb44b791ae9dc3e0f7343 -U drh -Z d80fb6c4fb859b25e151c85bda23f682 +P a11528ac575fa20fd8022756d042a32fe1272e12 +R bf459f233481ca6a2e168e0f56c2e565 +U dan +Z da996c893d138c803cabbc3bbda32cec diff --git a/manifest.uuid b/manifest.uuid index 8412294df1..c800cbab77 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a11528ac575fa20fd8022756d042a32fe1272e12 \ No newline at end of file +affaebde109e8dd851474ffe7b7d48b1aae8c7ed \ No newline at end of file diff --git a/test/ioerr2.test b/test/ioerr2.test index 325c0baded..5150ace3ab 100644 --- a/test/ioerr2.test +++ b/test/ioerr2.test @@ -130,7 +130,7 @@ do_test ioerr2-5 { } } msg] list $rc $msg -} {1 {callback requested query abort}} +} {1 {abort due to ROLLBACK}} if {$::tcl_platform(platform) == "unix"} { # Cause the call to xAccess used by [pragma temp_store_directory] to From db0ad5f204f0358f298c87d7cd4b8eac73412580 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 17 Mar 2012 15:12:16 +0000 Subject: [PATCH 07/12] In pager1.test, use "file attr test.db -readonly 0" before "file attr test.db -perm rw-rw-rw-", not after. FossilOrigin-Name: 4f5283f18f570a09b95c26e5aa14885ada518dd2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/pager1.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 2aba70d878..520e3fc8a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sa\stest\sin\sioerr2.test\sto\saccount\sfor\sthe\snew\sSQLITE_ABORT_ROLLBACK\sextended\serror\scode. -D 2012-03-17T09:43:09.270 +C In\spager1.test,\suse\s"file\sattr\stest.db\s-readonly\s0"\sbefore\s"file\sattr\stest.db\s-perm\srw-rw-rw-",\snot\safter. +D 2012-03-17T15:12:16.594 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -625,7 +625,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3 -F test/pager1.test 6e43e79d6ac1fc31b494ff3a0b56445b7eda5d2b +F test/pager1.test cf8f40cf77b5c4f762b1e8492390d61b46a81623 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P a11528ac575fa20fd8022756d042a32fe1272e12 -R bf459f233481ca6a2e168e0f56c2e565 +P affaebde109e8dd851474ffe7b7d48b1aae8c7ed +R c4a04a92e8486010645a44f1a08a5af3 U dan -Z da996c893d138c803cabbc3bbda32cec +Z 7e2f94cd0ef8dfee62915c8ab2714a0c diff --git a/manifest.uuid b/manifest.uuid index c800cbab77..cef18d967d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -affaebde109e8dd851474ffe7b7d48b1aae8c7ed \ No newline at end of file +4f5283f18f570a09b95c26e5aa14885ada518dd2 \ No newline at end of file diff --git a/test/pager1.test b/test/pager1.test index 96fcb5ba0e..45253857c3 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -899,8 +899,8 @@ do_test pager1.4.8.2 { } {-1} do_test pager1.4.8.3 { db close - catch {file attributes test.db -permissions rw-rw-rw-} catch {file attributes test.db -readonly 0} + catch {file attributes test.db -permissions rw-rw-rw-} msg sqlite3 db test.db db eval { SELECT * FROM t1 } sqlite3_db_readonly db main From 0d1614c731704f98943eb8aa34edf615532a6b4a Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 19 Mar 2012 10:21:37 +0000 Subject: [PATCH 08/12] Ensure that compatible malloc and free functions are used with stat3 data if SQLITE_ENABLE_STAT3 is defined. FossilOrigin-Name: 32bb1ecee4e43a4683512dbca047abf735afd313 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/analyze.c | 8 ++++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 520e3fc8a7..179517c1c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\spager1.test,\suse\s"file\sattr\stest.db\s-readonly\s0"\sbefore\s"file\sattr\stest.db\s-perm\srw-rw-rw-",\snot\safter. -D 2012-03-17T15:12:16.594 +C Ensure\sthat\scompatible\smalloc\sand\sfree\sfunctions\sare\sused\swith\sstat3\sdata\sif\sSQLITE_ENABLE_STAT3\sis\sdefined. +D 2012-03-19T10:21:37.927 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -119,7 +119,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 149cc80d9257971b0bff34e58fb2263e01998289 -F src/analyze.c f32ff304da413851eefa562b04e61ff6cb88248b +F src/analyze.c 70c46504c0d2543ea5cdca01140b2cd3e1d886e7 F src/attach.c 12c6957996908edc31c96d7c68d4942c2474405f F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 6be23a344d3301ae38e92fddb3a33b91c309fce4 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P affaebde109e8dd851474ffe7b7d48b1aae8c7ed -R c4a04a92e8486010645a44f1a08a5af3 +P 4f5283f18f570a09b95c26e5aa14885ada518dd2 +R 86b82af92d1239c76d6157fdd039db02 U dan -Z 7e2f94cd0ef8dfee62915c8ab2714a0c +Z fc0fdf7e77db24e47eb9fd009ed1d240 diff --git a/manifest.uuid b/manifest.uuid index cef18d967d..41bdf79e8d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f5283f18f570a09b95c26e5aa14885ada518dd2 \ No newline at end of file +32bb1ecee4e43a4683512dbca047abf735afd313 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index cbfdc8587e..4dfc331bef 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -932,6 +932,7 @@ static int loadStat3(sqlite3 *db, const char *zDb){ int eType; /* Datatype of a sample */ IndexSample *pSample; /* A slot in pIdx->aSample[] */ + assert( db->lookaside.bEnabled==0 ); if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){ return SQLITE_OK; } @@ -958,7 +959,7 @@ static int loadStat3(sqlite3 *db, const char *zDb){ if( pIdx==0 ) continue; assert( pIdx->nSample==0 ); pIdx->nSample = nSample; - pIdx->aSample = sqlite3MallocZero( nSample*sizeof(IndexSample) ); + pIdx->aSample = sqlite3DbMallocZero(db, nSample*sizeof(IndexSample)); pIdx->avgEq = pIdx->aiRowEst[1]; if( pIdx->aSample==0 ){ db->mallocFailed = 1; @@ -1031,7 +1032,7 @@ static int loadStat3(sqlite3 *db, const char *zDb){ if( n < 1){ pSample->u.z = 0; }else{ - pSample->u.z = sqlite3Malloc(n); + pSample->u.z = sqlite3DbMallocRaw(db, n); if( pSample->u.z==0 ){ db->mallocFailed = 1; sqlite3_finalize(pStmt); @@ -1107,7 +1108,10 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ /* Load the statistics from the sqlite_stat3 table. */ #ifdef SQLITE_ENABLE_STAT3 if( rc==SQLITE_OK ){ + int lookasideEnabled = db->lookaside.bEnabled; + db->lookaside.bEnabled = 0; rc = loadStat3(db, sInfo.zDatabase); + db->lookaside.bEnabled = lookasideEnabled; } #endif From bbe05203299797220defebb10212be4a7cdb7613 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 19 Mar 2012 14:28:43 +0000 Subject: [PATCH 09/12] Avoid a compiler warning (an incorrect compiler warning, at that) in vs2010. FossilOrigin-Name: 7dd97f12cd268cac1241f0f3e8de94bb629b97c7 --- ext/fts3/fts3.c | 3 ++- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 96905fc14b..04671af24f 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -1223,7 +1223,8 @@ static int fts3InitVtab( int j; for(j=0; j Date: Mon, 19 Mar 2012 14:51:19 +0000 Subject: [PATCH 10/12] Suppress harmless compiler warnings on windows in FTS4 and RTREE. FossilOrigin-Name: 4fd68647c8d4b120e04d054617cef31001f44c6f --- ext/fts3/fts3.c | 24 ++++++++++++------------ ext/fts3/fts3_aux.c | 4 ++-- ext/rtree/rtree.c | 8 ++++---- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 04671af24f..984712c7b7 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -741,7 +741,7 @@ static void fts3Appendf( static char *fts3QuoteId(char const *zInput){ int nRet; char *zRet; - nRet = 2 + strlen(zInput)*2 + 1; + nRet = 2 + (int)strlen(zInput)*2 + 1; zRet = sqlite3_malloc(nRet); if( zRet ){ int i; @@ -997,7 +997,7 @@ static int fts3ContentColumns( nCol = sqlite3_column_count(pStmt); for(i=0; idoclist.pList = 0; @@ -3820,7 +3820,7 @@ static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){ pPhrase->doclist.pList = aOut; if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){ pPhrase->doclist.bFreeList = 1; - pPhrase->doclist.nList = (aOut - pPhrase->doclist.pList); + pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList); }else{ sqlite3_free(aOut); pPhrase->doclist.pList = 0; @@ -3916,7 +3916,7 @@ void sqlite3Fts3DoclistPrev( iMul = (bDescIdx ? -1 : 1); } - *pnList = pEnd - pNext; + *pnList = (int)(pEnd - pNext); *ppIter = pNext; *piDocid = iDocid; }else{ @@ -3930,7 +3930,7 @@ void sqlite3Fts3DoclistPrev( }else{ char *pSave = p; fts3ReversePoslist(aDoclist, &p); - *pnList = (pSave - p); + *pnList = (int)(pSave - p); } *ppIter = p; } @@ -4348,8 +4348,8 @@ static int fts3EvalStart(Fts3Cursor *pCsr){ Fts3Expr **ppOr = apOr; fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc); - nToken = pTC-aTC; - nOr = ppOr-apOr; + nToken = (int)(pTC-aTC); + nOr = (int)(ppOr-apOr); if( rc==SQLITE_OK ){ rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken); @@ -4421,7 +4421,7 @@ static int fts3EvalNearTrim( &pOut, aTmp, nParam1, nParam2, paPoslist, &p2 ); if( res ){ - nNew = (pOut - pPhrase->doclist.pList) - 1; + nNew = (int)(pOut - pPhrase->doclist.pList) - 1; assert( pPhrase->doclist.pList[nNew]=='\0' ); assert( nNew<=pPhrase->doclist.nList && nNew>0 ); memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew); diff --git a/ext/fts3/fts3_aux.c b/ext/fts3/fts3_aux.c index 89bf3ebf6e..a2bff2e1d3 100644 --- a/ext/fts3/fts3_aux.c +++ b/ext/fts3/fts3_aux.c @@ -79,9 +79,9 @@ static int fts3auxConnectMethod( } zDb = argv[1]; - nDb = strlen(zDb); + nDb = (int)strlen(zDb); zFts3 = argv[3]; - nFts3 = strlen(zFts3); + nFts3 = (int)strlen(zFts3); rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA); if( rc!=SQLITE_OK ) return rc; diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 4c36f26171..ce76e61f08 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -3056,8 +3056,8 @@ static int rtreeInit( sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); /* Allocate the sqlite3_vtab structure */ - nDb = strlen(argv[1]); - nName = strlen(argv[2]); + nDb = (int)strlen(argv[1]); + nName = (int)strlen(argv[2]); pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2); if( !pRtree ){ return SQLITE_NOMEM; @@ -3152,10 +3152,10 @@ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ nodeGetCell(&tree, &node, ii, &cell); sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid); - nCell = strlen(zCell); + nCell = (int)strlen(zCell); for(jj=0; jj Date: Mon, 19 Mar 2012 14:57:49 +0000 Subject: [PATCH 11/12] Fix one more compiler warning missed by the previous check-in. FossilOrigin-Name: bc03d99a78e90c02b69037e5f5f81537b5a3ac60 --- ext/fts3/fts3.c | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 984712c7b7..421052b937 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -3990,7 +3990,7 @@ static int fts3EvalPhraseNext( } pDL->pList = pIter; fts3PoslistCopy(0, &pIter); - pDL->nList = (pIter - pDL->pList); + pDL->nList = (int)(pIter - pDL->pList); /* pIter now points just past the 0x00 that terminates the position- ** list for document pDL->iDocid. However, if this position-list was diff --git a/manifest b/manifest index 853c98bd07..02ccade03d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Suppress\sharmless\scompiler\swarnings\son\swindows\sin\sFTS4\sand\sRTREE. -D 2012-03-19T14:51:19.261 +C Fix\sone\smore\scompiler\swarning\smissed\sby\sthe\sprevious\scheck-in. +D 2012-03-19T14:57:49.232 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -63,7 +63,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c cb5b77609ebe3405f482b81a419e12dd00b5d9b5 +F ext/fts3/fts3.c a62e09140c00f9c401efca661e7f2ae9909194f6 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h d1d7f964ddee067bcd16a6af4ba7ecf66220056d F ext/fts3/fts3_aux.c 5205182bd8f372782597888156404766edf5781e @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 7dd97f12cd268cac1241f0f3e8de94bb629b97c7 -R 3d835a8bbdb81ada9b824f3c7c84ac79 +P 4fd68647c8d4b120e04d054617cef31001f44c6f +R d0de9386b7862d0d496b567825b3fc4a U drh -Z 908ca5c15e2aee882328fc436d7a8c0f +Z d75a5126aa3d9bafa8a4a6d3f6859d6d diff --git a/manifest.uuid b/manifest.uuid index 9f22b09f51..8ce488b11e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4fd68647c8d4b120e04d054617cef31001f44c6f \ No newline at end of file +bc03d99a78e90c02b69037e5f5f81537b5a3ac60 \ No newline at end of file From 0299b40f0fa6ae9de1af5dd1c15cb64fc7797a1a Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 19 Mar 2012 17:42:46 +0000 Subject: [PATCH 12/12] Add additional test cases to e_insert.test. Update evidence marks. no changes to core code. FossilOrigin-Name: 036395c0a8e08883b11df025e3da9e2461e4b1eb --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/util.c | 10 +++++----- test/e_insert.test | 16 +++++++++++++++- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 02ccade03d..50503f5402 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sone\smore\scompiler\swarning\smissed\sby\sthe\sprevious\scheck-in. -D 2012-03-19T14:57:49.232 +C Add\sadditional\stest\scases\sto\se_insert.test.\s\sUpdate\sevidence\smarks.\nno\schanges\sto\score\scode. +D 2012-03-19T17:42:46.646 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -238,7 +238,7 @@ F src/tokenize.c 1e86210d3976717a19238ea7b047fac481fe8c12 F src/trigger.c ee7e178fb9188f44b532cebd449a7c1df90fb684 F src/update.c d3076782c887c10e882996550345da9c4c9f9dea F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 -F src/util.c 906731099c4397bf8adf3fa90a833355e7472af0 +F src/util.c 4f6cfad661b2e3454b0cdd5b1b9d39a54942d0e3 F src/vacuum.c bfd53f9bd20a8fdb70b0fa8e77182b866875c0d8 F src/vdbe.c 32720e873ed0a23e6ee928b676cd995864b984d6 F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb @@ -383,7 +383,7 @@ F test/e_dropview.test 583411e470458c5d76148542cfb5a5fa84c8f93e F test/e_expr.test 5489424d3d9a452ac3701cdf4b680ae31a157894 F test/e_fkey.test 057eed81a41a2b21b1790032f4e8aaba0b2b0e17 F test/e_fts3.test 5c02288842e4f941896fd44afdef564dd5fc1459 -F test/e_insert.test 92d2dab07366aef112f53af4539e30559f5d35a7 +F test/e_insert.test c6ac239a97cb16dfbd0c16496f8cd871b4068c0c F test/e_reindex.test dfedfc32c5a282b0596c6537cbcd4217fbb1a216 F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 F test/e_select.test f5d4b81205701deacfae42051ae200969c41d2c0 @@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 4fd68647c8d4b120e04d054617cef31001f44c6f -R d0de9386b7862d0d496b567825b3fc4a +P bc03d99a78e90c02b69037e5f5f81537b5a3ac60 +R 69afcc9757d71d53b13c043daaf0c06c U drh -Z d75a5126aa3d9bafa8a4a6d3f6859d6d +Z e41b3b1650d5b16145f025deed2994e7 diff --git a/manifest.uuid b/manifest.uuid index 8ce488b11e..0d3f57ac8d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc03d99a78e90c02b69037e5f5f81537b5a3ac60 \ No newline at end of file +036395c0a8e08883b11df025e3da9e2461e4b1eb \ No newline at end of file diff --git a/src/util.c b/src/util.c index 325c75aae1..dd3b08ae46 100644 --- a/src/util.c +++ b/src/util.c @@ -216,11 +216,11 @@ int sqlite3Dequote(char *z){ ** Some systems have stricmp(). Others have strcasecmp(). Because ** there is no consistency, we will define our own. ** -** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows -** applications and extensions to compare the contents of two buffers -** containing UTF-8 strings in a case-independent fashion, using the same -** definition of case independence that SQLite uses internally when -** comparing identifiers. +** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and +** sqlite3_strnicmp() APIs allow applications and extensions to compare +** the contents of two buffers containing UTF-8 strings in a +** case-independent fashion, using the same definition of "case +** independence" that SQLite uses internally when comparing identifiers. */ int sqlite3_stricmp(const char *zLeft, const char *zRight){ register unsigned char *a, *b; diff --git a/test/e_insert.test b/test/e_insert.test index a10d5283de..ac4361f8df 100644 --- a/test/e_insert.test +++ b/test/e_insert.test @@ -50,7 +50,7 @@ proc do_insert_tests {args} { uplevel do_select_tests $args } -# EVIDENCE-OF: R-55375-41353 -- syntax diagram insert-stmt +# EVIDENCE-OF: R-21350-31508 -- syntax diagram insert-stmt # do_insert_tests e_insert-0 { 1 "INSERT INTO a1 DEFAULT VALUES" {} @@ -123,6 +123,20 @@ do_insert_tests e_insert-0 { 68 "INSERT OR IGNORE INTO a1 (b, a) SELECT c, b FROM a2" {} 69 "REPLACE INTO a1 (b, a) SELECT c, b FROM a2" {} 70 "REPLACE INTO main.a1 (b, a) SELECT c, b FROM a2" {} + 71 "INSERT INTO a1 (b, a) VALUES(1, 2),(3,4)" {} + 72 "INSERT INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {} + 73 "INSERT OR ROLLBACK INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {} + 74 "INSERT OR ROLLBACK INTO a1 (b, a) VALUES(1, 2),(3,4)" {} + 75 "INSERT OR ABORT INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {} + 76 "INSERT OR ABORT INTO a1 (b, a) VALUES(1, 2),(3,4)" {} + 77 "INSERT OR REPLACE INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {} + 78 "INSERT OR REPLACE INTO a1 (b, a) VALUES(1, 2),(3,4)" {} + 79 "INSERT OR FAIL INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {} + 80 "INSERT OR FAIL INTO a1 (b, a) VALUES(1, 2),(3,4)" {} + 81 "INSERT OR FAIL INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {} + 82 "INSERT OR IGNORE INTO a1 (b, a) VALUES(1, 2),(3,4)" {} + 83 "REPLACE INTO a1 (b, a) VALUES(1, 2),(3,4)" {} + 84 "REPLACE INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {} } delete_all_data