fulltext_cursor *c = (fulltext_cursor *) pCursor;
fulltext_vtab *v = cursor_vtab(c);
int rc;
- StringBuffer sb;
FTSTRACE(("FTS3 Filter %p\n",pCursor));
- initStringBuffer(&sb);
- append(&sb, "SELECT docid, ");
- appendList(&sb, v->nColumn, v->azContentColumn);
- append(&sb, " FROM %_content");
- if( idxNum!=QUERY_GENERIC ) append(&sb, " WHERE docid = ?");
- sqlite3_finalize(c->pStmt);
- rc = sql_prepare(v->db, v->zDb, v->zName, &c->pStmt, stringBufferData(&sb));
- stringBufferDestroy(&sb);
- if( rc!=SQLITE_OK ) return rc;
+ /* If the cursor has a statement that was not prepared according to
+ ** idxNum, clear it. I believe all calls to fulltextFilter with a
+ ** given cursor will have the same idxNum , but in this case it's
+ ** easy to be safe.
+ */
+ if( c->pStmt && c->iCursorType!=idxNum ){
+ sqlite3_finalize(c->pStmt);
+ c->pStmt = NULL;
+ }
+
+ /* Get a fresh statement appropriate to idxNum. */
+ /* TODO(shess): Add a prepared-statement cache in the vt structure.
+ ** The cache must handle multiple open cursors. Easier to cache the
+ ** statement variants at the vt to reduce malloc/realloc/free here.
+ ** Or we could have a StringBuffer variant which allowed stack
+ ** construction for small values.
+ */
+ if( !c->pStmt ){
+ StringBuffer sb;
+ initStringBuffer(&sb);
+ append(&sb, "SELECT docid, ");
+ appendList(&sb, v->nColumn, v->azContentColumn);
+ append(&sb, " FROM %_content");
+ if( idxNum!=QUERY_GENERIC ) append(&sb, " WHERE docid = ?");
+ rc = sql_prepare(v->db, v->zDb, v->zName, &c->pStmt,
+ stringBufferData(&sb));
+ stringBufferDestroy(&sb);
+ if( rc!=SQLITE_OK ) return rc;
+ c->iCursorType = idxNum;
+ }else{
+ sqlite3_reset(c->pStmt);
+ assert( c->iCursorType==idxNum );
+ }
- c->iCursorType = idxNum;
switch( idxNum ){
case QUERY_GENERIC:
break;
-C Implement\sthe\s"lookaside"\smemory\sallocation\scache.\s\sUse\sof\sthis\scache\smakes\nthe\sspeed1.test\sscript\srun\sabout\s15%\sfaster.\s\sAdded\snew\sinterfaces\sto\ncontrol\sthe\scache.\s(CVS\s5488)
-D 2008-07-28T19:34:53
+C Re-used\sprepared\sstatement\sfrom\sfts3\scursor.\s\sPreviously,\seach\scall\sto\nfulltextFilter()\sfinalized\sany\sexisting\sprepared\sstatement\sand\nprepared\sa\snew\sone.\s\sIn\sthe\scase\swhere\sidxNum\shas\snot\schanged,\ssimply\nreseting\sthe\sstatement\ssuffices.\s\sThis\sprovides\san\sorder\sof\smagnitude\nspeedup\sin\sincoming\sjoins\sagainst\sdocid.\s(CVS\s5489)
+D 2008-07-29T01:13:02
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in bbb62eecc851379aef5a48a1bf8787eb13e6ec06
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0
F ext/fts3/README.tokenizers 226644a0eab97724e8de83061912e8bb248461b6
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
-F ext/fts3/fts3.c 14ac2e37889fda1555d903648772b6be3061d2bb
+F ext/fts3/fts3.c fa37048c369491ba6fb74e1732f24a8a8daaef65
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3_hash.c 83e7bb4042106b32811681dd2859b4577a7a6b35
F ext/fts3/fts3_hash.h 004b759e1602ff16dfa02fea3ca1c77336ad6798
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 51be2e4463ca32f290feb610f59553b55bc67a5c
-R 1624ec122f5ffb86a37761ed2b47d75a
-U drh
-Z 5a311db47e066a208f5f741cb81e1882
+P e48f9697e9fea339e150ddc32940760027dd07d9
+R 680fb3be123f951c8c77ef4a340cd813
+U shess
+Z b0abfd8b0f9f50c33d751a3bf926e781