diff options
-rw-r--r-- | Makefile.in | 5 | ||||
-rw-r--r-- | ext/fts3/fts3.c | 2 | ||||
-rw-r--r-- | ext/fts3/fts3Int.h | 1 | ||||
-rw-r--r-- | manifest | 28 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | src/vdbeblob.c | 2 | ||||
-rw-r--r-- | src/vtab.c | 2 | ||||
-rw-r--r-- | src/where.c | 20 | ||||
-rw-r--r-- | test/incrblob.test | 9 | ||||
-rw-r--r-- | test/vtab1.test | 15 | ||||
-rw-r--r-- | test/where7.test | 45 |
11 files changed, 101 insertions, 30 deletions
diff --git a/Makefile.in b/Makefile.in index 8e57e40ce..3659e944b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -167,7 +167,8 @@ USE_AMALGAMATION = @USE_AMALGAMATION@ # LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \ backup.lo bitvec.lo btmutex.lo btree.lo build.lo \ - callback.lo complete.lo ctime.lo date.lo delete.lo expr.lo fault.lo fkey.lo \ + callback.lo complete.lo ctime.lo date.lo delete.lo \ + expr.lo fault.lo fkey.lo \ fts3.lo fts3_expr.lo fts3_hash.lo fts3_icu.lo fts3_porter.lo \ fts3_snippet.lo fts3_tokenizer.lo fts3_tokenizer1.lo fts3_write.lo \ func.lo global.lo hash.lo \ @@ -181,7 +182,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \ table.lo tokenize.lo trigger.lo \ update.lo util.lo vacuum.lo \ vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbetrace.lo \ - wal.lo walker.lo where.lo utf.o vtab.lo + wal.lo walker.lo where.lo utf.lo vtab.lo # Object files for the amalgamation. # diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 752d0e9bc..c3bbb0829 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -441,6 +441,7 @@ static int fts3DisconnectMethod(sqlite3_vtab *pVtab){ int i; assert( p->nPendingData==0 ); + assert( p->pSegments==0 ); /* Free any prepared statements held */ for(i=0; i<SizeofArray(p->aStmt); i++){ @@ -2061,7 +2062,6 @@ static int fts3TermSelect( */ static int fts3DoclistCountDocids(int isPoslist, char *aList, int nList){ int nDoc = 0; /* Return value */ - if( aList ){ char *aEnd = &aList[nList]; /* Pointer to one byte after EOF */ char *p = aList; /* Cursor */ diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index e905dfc71..c98271729 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -129,7 +129,6 @@ struct Fts3Table { int nNodeSize; /* Soft limit for node size */ u8 bHasContent; /* True if %_content table exists */ u8 bHasDocsize; /* True if %_docsize table exists */ - sqlite3_blob *pSegments; /* Blob handle open on %_segments table */ /* The following hash table is used to buffer pending index updates during @@ -1,7 +1,7 @@ -C Updates\sto\sFTS4\sto\simprove\sperformance\sand\smake\smore\saccurate\scost\sestimates\sfor\sprefix\sterms. -D 2010-10-20T18:56:04 +C Merge\strunk\schanges\sinto\sexperimental\sbranch. +D 2010-10-21T15:49:47 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in b01fdfcfecf8a0716c29867a67959f6148b79961 +F Makefile.in 2c8cefd962eca0147132c7cf9eaa4bb24c656f3f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.vxworks c85ec1d8597fe2f7bc225af12ac1666e21379151 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 @@ -61,9 +61,9 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c ce7bcd1f42e74912149fe6201fc63a6ac0db42a8 +F ext/fts3/fts3.c f423181b76fc35c38c4dcf4d8aac012813817f34 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h 9fbe422f7d0e005371702acaa3cd44283a67c389 +F ext/fts3/fts3Int.h f80be5abfb24e51cb816287230c0d0c8f1712f59 F ext/fts3/fts3_expr.c a5aee50edde20e5c9116199bd58be869a3a22c9f F ext/fts3/fts3_hash.c 3c8f6387a4a7f5305588b203fa7c887d753e1f1c F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec @@ -231,14 +231,14 @@ F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 F src/vdbeInt.h 7f4cf1b2b69bef3a432b1f23dfebef57275436b4 F src/vdbeapi.c 5368714fa750270cf6430160287c21adff44582d F src/vdbeaux.c de0b06b11a25293e820a49159eca9f1c51a64716 -F src/vdbeblob.c c8cbe6ce28cc8bf806ea0818b5167dd9a27c48a3 +F src/vdbeblob.c e6e485934fcc9201dd1bfd65864be2bb14243b5d F src/vdbemem.c 23723a12cd3ba7ab3099193094cbb2eb78956aa9 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 -F src/vtab.c 6c90e3e65b2f026fc54703a8f3c917155f419d87 +F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30 F src/wal.c 0dc7eb9e907a2c280cdcde876d313e07ea4ad811 F src/wal.h 96669b645e27cd5a111ba59f0cae7743a207bc3c F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 204cdfb66eb82ee17a8fc0a9b12c1ab402755cbb +F src/where.c d9a31eb3d59466b6c53567c8c9a6c2fe68bbd565 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 6745008c144bd2956d58864d21f7b304689c1cce @@ -458,7 +458,7 @@ F test/in.test 19b642bb134308980a92249750ea4ce3f6c75c2d F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75 F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0 F test/in4.test 64f3cc1acde1b9161ccdd8e5bde3daefdb5b2617 -F test/incrblob.test fa2cd937f59f5231bfdc2aa152ee184bf254ca02 +F test/incrblob.test 76e787ca3301d9bfa6906031c626d26f8dd707de F test/incrblob2.test edc3a96e557bd61fb39acc8d2edd43371fbbaa19 F test/incrblob_err.test c577c91d4ed9e8336cdb188b15d6ee2a6fe9604e F test/incrvacuum.test 453d1e490d8f5ad2c9b3a54282a0690d6ae56462 @@ -796,7 +796,7 @@ F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 7701bb609fe8bf6535514e8b849a309e8f00573b F test/view.test 45f518205ecdb6dd23a86dd4a99bb4ae945e625d -F test/vtab1.test 9bc4a349a1989bcd064eb3b8fac2f06aca64297a +F test/vtab1.test 7b79832824cbae37ff01a06ed155027f7c15bf9e F test/vtab2.test 7bcffc050da5c68f4f312e49e443063e2d391c0d F test/vtab3.test baad99fd27217f5d6db10660522e0b7192446de1 F test/vtab4.test 942f8b8280b3ea8a41dae20e7822d065ca1cb275 @@ -835,7 +835,7 @@ F test/where3.test 3a72db38e8804b210e9f72001ea16830fea74b4b F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b -F test/where7.test a0a92b8ce48d9c027fbdd7b764c7de1e1213575a +F test/where7.test 221fd05b26be4529647c72ef7de5df646482c675 F test/where8.test a6c740fd286d7883e274e17b6230a9d672a7ab1f F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 F test/where9.test be19e1a92f80985c1a121b4678bf7d2123eaa623 @@ -875,7 +875,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 5ae0ba447a561e3b6637b52f9b83a9fc683d2572 -R acd75bd5094c2beea7f56f4633b47ea2 +P d0a450ce78e99f55c862f26f9332786660007a0a f91471e7234db490f97298b1ccb8d6c7fc45b089 +R 3c9178950d1e4be3aecf1d9f3dffa25a U dan -Z 910cba31e6572b93e93d39c91f91b9da +Z 5bbfebd98739f68617c4d86986bdd88f diff --git a/manifest.uuid b/manifest.uuid index ab22dd85a..278a75661 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d0a450ce78e99f55c862f26f9332786660007a0a
\ No newline at end of file +fd1e5cade04961c2f5438a1dfcc2e15eafb4503f
\ No newline at end of file diff --git a/src/vdbeblob.c b/src/vdbeblob.c index f7ee670f2..129aad736 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -285,7 +285,6 @@ int sqlite3_blob_open( if( db->mallocFailed ){ goto blob_open_out; } - sqlite3_bind_int64(pBlob->pStmt, 1, iRow); rc = blobSeekToRow(pBlob, iRow, &zErr); } while( (++nAttempt)<5 && rc==SQLITE_SCHEMA ); @@ -298,7 +297,6 @@ blob_open_out: if( pBlob && pBlob->pStmt ) sqlite3VdbeFinalize((Vdbe *)pBlob->pStmt); sqlite3DbFree(db, pBlob); } - sqlite3Error(db, rc, (zErr ? "%s" : 0), zErr); sqlite3DbFree(db, zErr); sqlite3StackFree(db, pParse); diff --git a/src/vtab.c b/src/vtab.c index 4d0595f2b..e460ee59e 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -672,7 +672,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ } db->pVTab = 0; }else{ - sqlite3Error(db, SQLITE_ERROR, zErr); + sqlite3Error(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr); sqlite3DbFree(db, zErr); rc = SQLITE_ERROR; } diff --git a/src/where.c b/src/where.c index 226055b47..eb0e8ead7 100644 --- a/src/where.c +++ b/src/where.c @@ -235,7 +235,7 @@ struct WhereCost { #define WHERE_COLUMN_IN 0x00040000 /* x IN (...) */ #define WHERE_COLUMN_NULL 0x00080000 /* x IS NULL */ #define WHERE_INDEXED 0x000f0000 /* Anything that uses an index */ -#define WHERE_NOT_FULLSCAN 0x000f3000 /* Does not do a full table scan */ +#define WHERE_NOT_FULLSCAN 0x100f3000 /* Does not do a full table scan */ #define WHERE_IN_ABLE 0x000f1000 /* Able to support an IN operator */ #define WHERE_TOP_LIMIT 0x00100000 /* x<EXPR or x<=EXPR constraint */ #define WHERE_BTM_LIMIT 0x00200000 /* x>EXPR or x>=EXPR constraint */ @@ -1581,8 +1581,9 @@ static void bestOrClauseIndex( WhereTerm * const pWCEnd = &pWC->a[pWC->nTerm]; /* End of pWC->a[] */ WhereTerm *pTerm; /* A single term of the WHERE clause */ - /* No OR-clause optimization allowed if the NOT INDEXED clause is used */ - if( pSrc->notIndexed ){ + /* No OR-clause optimization allowed if the INDEXED BY or NOT INDEXED clauses + ** are used */ + if( pSrc->notIndexed || pSrc->pIndex!=0 ){ return; } @@ -4066,6 +4067,7 @@ WhereInfo *sqlite3WhereBegin( memset(&bestPlan, 0, sizeof(bestPlan)); bestPlan.rCost = SQLITE_BIG_DBL; + WHERETRACE(("*** Begin search for loop %d ***\n", i)); /* Loop through the remaining entries in the FROM clause to find the ** next nested loop. The loop tests all FROM clause entries @@ -4130,6 +4132,8 @@ WhereInfo *sqlite3WhereBegin( pOrderBy = ((i==0 && ppOrderBy )?*ppOrderBy:0); if( pTabItem->pIndex==0 ) nUnconstrained++; + WHERETRACE(("=== trying table %d with isOptimal=%d ===\n", + j, isOptimal)); assert( pTabItem->pTab ); #ifndef SQLITE_OMIT_VIRTUALTABLE if( IsVirtual(pTabItem->pTab) ){ @@ -4182,8 +4186,9 @@ WhereInfo *sqlite3WhereBegin( && (bestJ<0 || sCost.rCost<bestPlan.rCost /* (4) */ || (sCost.rCost<=bestPlan.rCost && sCost.nRow<bestPlan.nRow)) ){ - WHERETRACE(("... best so far with cost=%g and nRow=%g\n", - sCost.rCost, sCost.nRow)); + WHERETRACE(("=== table %d is best so far" + " with cost=%g and nRow=%g\n", + j, sCost.rCost, sCost.nRow)); bestPlan = sCost; bestJ = j; } @@ -4192,8 +4197,9 @@ WhereInfo *sqlite3WhereBegin( } assert( bestJ>=0 ); assert( notReady & getMask(pMaskSet, pTabList->a[bestJ].iCursor) ); - WHERETRACE(("*** Optimizer selects table %d for loop %d\n", bestJ, - pLevel-pWInfo->a)); + WHERETRACE(("*** Optimizer selects table %d for loop %d" + " with cost=%g and nRow=%g\n", + bestJ, pLevel-pWInfo->a, bestPlan.rCost, bestPlan.nRow)); if( (bestPlan.plan.wsFlags & WHERE_ORDERBY)!=0 ){ *ppOrderBy = 0; } diff --git a/test/incrblob.test b/test/incrblob.test index e0b278779..9c9389eb4 100644 --- a/test/incrblob.test +++ b/test/incrblob.test @@ -677,5 +677,14 @@ do_test incrblob-8.7 { execsql {SELECT b FROM t1 WHERE a = 314159} } {etilqs} +# The following test case exposes an instance in the blob code where +# an error message was set using a call similar to sqlite3_mprintf(zErr), +# where zErr is an arbitrary string. This is no good if the string contains +# characters that can be mistaken for printf() formatting directives. +# +do_test incrblob-9.1 { + list [catch { db incrblob t1 "A tricky column name %s%s" 1 } msg] $msg +} {1 {no such column: "A tricky column name %s%s"}} + finish_test diff --git a/test/vtab1.test b/test/vtab1.test index bafd29ae2..a9aca503c 100644 --- a/test/vtab1.test +++ b/test/vtab1.test @@ -1163,5 +1163,20 @@ ifcapable altertable { incr tn } +# The following test case exposes an instance in sqlite3_declare_vtab() +# an error message was set using a call similar to sqlite3_mprintf(zErr), +# where zErr is an arbitrary string. This is no good if the string contains +# characters that can be mistaken for printf() formatting directives. +# +do_test vtab1-17.1 { + execsql { + PRAGMA writable_schema = 1; + INSERT INTO sqlite_master VALUES( + 'table', 't3', 't3', 0, 'INSERT INTO "%s%s" VALUES(1)' + ); + } + catchsql { CREATE VIRTUAL TABLE t4 USING echo(t3); } +} {1 {vtable constructor failed: t4}} + unset -nocomplain echo_module_begin_fail finish_test diff --git a/test/where7.test b/test/where7.test index dbb9bc6b6..07aba9e60 100644 --- a/test/where7.test +++ b/test/where7.test @@ -23299,6 +23299,49 @@ do_test where7-2.1001.2 { OR a=91 } } {2 22 23 28 54 80 91 scan 0 sort 0} -finish_test + +# test case for the performance regression fixed by +# check-in 28ba6255282b on 2010-10-21 02:05:06 +# +# The test case that follows is code from an actual +# application with identifiers change and unused columns +# remove. +# +do_test where7-3.1 { + db eval { + CREATE TABLE t301 ( + c8 INTEGER PRIMARY KEY, + c6 INTEGER, + c4 INTEGER, + c7 INTEGER, + FOREIGN KEY (c4) REFERENCES series(c4) + ); + CREATE INDEX t301_c6 on t301(c6); + CREATE INDEX t301_c4 on t301(c4); + CREATE INDEX t301_c7 on t301(c7); + + CREATE TABLE t302 ( + c1 INTEGER PRIMARY KEY, + c8 INTEGER, + c5 INTEGER, + c3 INTEGER, + c2 INTEGER, + c4 INTEGER, + FOREIGN KEY (c8) REFERENCES t301(c8) + ); + CREATE INDEX t302_c3 on t302(c3); + CREATE INDEX t302_c8_c3 on t302(c8, c3); + CREATE INDEX t302_c5 on t302(c5); + + EXPLAIN QUERY PLAN + SELECT t302.c1 + FROM t302 JOIN t301 ON t302.c8 = t301.c8 + WHERE t302.c2 = 19571 + AND t302.c3 > 1287603136 + AND (t301.c4 = 1407449685622784 + OR t301.c8 = 1407424651264000) + ORDER BY t302.c5 LIMIT 200; + } +} {0 1 {TABLE t301 VIA MULTI-INDEX UNION} 1 0 {TABLE t302 WITH INDEX t302_c8_c3} 0 0 {TABLE t301 WITH INDEX t301_c4} 0 0 {TABLE t301 USING PRIMARY KEY}} finish_test |