mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Fix problems introduced into fts3 as part of the refactoring.
FossilOrigin-Name: fa0998e19d984ee57f4f506c34eb858026cc49c3
This commit is contained in:
@ -588,7 +588,7 @@ static int fts3CreateTables(Fts3Table *p){
|
|||||||
zContentCols = sqlite3_mprintf("docid INTEGER PRIMARY KEY");
|
zContentCols = sqlite3_mprintf("docid INTEGER PRIMARY KEY");
|
||||||
for(i=0; zContentCols && i<p->nColumn; i++){
|
for(i=0; zContentCols && i<p->nColumn; i++){
|
||||||
char *z = p->azColumn[i];
|
char *z = p->azColumn[i];
|
||||||
zContentCols = sqlite3_mprintf("%z, 'c%d%q'", zContentCols, i+1, z);
|
zContentCols = sqlite3_mprintf("%z, 'c%d%q'", zContentCols, i, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the whole SQL script */
|
/* Create the whole SQL script */
|
||||||
@ -934,10 +934,10 @@ static int fts3SelectLeaf(
|
|||||||
zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);
|
zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);
|
||||||
|
|
||||||
while( zCsr<zEnd ){
|
while( zCsr<zEnd ){
|
||||||
|
int cmp; /* memcmp() result */
|
||||||
int nSuffix; /* Size of term suffix */
|
int nSuffix; /* Size of term suffix */
|
||||||
int nPrefix = 0; /* Size of term prefix */
|
int nPrefix = 0; /* Size of term prefix */
|
||||||
int nBuffer; /* Total term size */
|
int nBuffer; /* Total term size */
|
||||||
int nMin; /* Minimum of nBuffer and nTerm */
|
|
||||||
|
|
||||||
/* Load the next term on the node into zBuffer */
|
/* Load the next term on the node into zBuffer */
|
||||||
if( zBuffer ){
|
if( zBuffer ){
|
||||||
@ -967,8 +967,8 @@ static int fts3SelectLeaf(
|
|||||||
** If the interior node term is larger than the specified term, then
|
** If the interior node term is larger than the specified term, then
|
||||||
** the tree headed by iChild may contain the specified term.
|
** the tree headed by iChild may contain the specified term.
|
||||||
*/
|
*/
|
||||||
nMin = (nBuffer>nTerm ? nTerm : nBuffer);
|
cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer));
|
||||||
if( memcmp(zTerm, zBuffer, nMin)<0 ) break;
|
if( cmp<0 || (cmp==0 && nBuffer>nTerm) ) break;
|
||||||
iChild++;
|
iChild++;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1421,8 +1421,8 @@ static int fts3TermSelectCb(
|
|||||||
){
|
){
|
||||||
TermSelect *pTS = (TermSelect *)pContext;
|
TermSelect *pTS = (TermSelect *)pContext;
|
||||||
int nNew = pTS->nOutput + nDoclist;
|
int nNew = pTS->nOutput + nDoclist;
|
||||||
|
|
||||||
char *aNew = sqlite3_malloc(nNew);
|
char *aNew = sqlite3_malloc(nNew);
|
||||||
|
|
||||||
if( !aNew ){
|
if( !aNew ){
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
@ -1507,7 +1507,7 @@ static int fts3TermSelect(
|
|||||||
sqlite3_int64 i1;
|
sqlite3_int64 i1;
|
||||||
rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &i1);
|
rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &i1);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
sqlite3_int64 i2 = sqlite3_column_int64(pStmt, 3);
|
sqlite3_int64 i2 = sqlite3_column_int64(pStmt, 2);
|
||||||
rc = sqlite3Fts3SegReaderNew(p, iAge, i1, i2, 0, 0, 0, &pNew);
|
rc = sqlite3Fts3SegReaderNew(p, iAge, i1, i2, 0, 0, 0, &pNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1546,6 +1546,7 @@ static int fts3TermSelect(
|
|||||||
filter.iCol = iColumn;
|
filter.iCol = iColumn;
|
||||||
filter.zTerm = zTerm;
|
filter.zTerm = zTerm;
|
||||||
filter.nTerm = nTerm;
|
filter.nTerm = nTerm;
|
||||||
|
|
||||||
rc = sqlite3Fts3SegReaderIterate(p, apSegment, nSegment, &filter,
|
rc = sqlite3Fts3SegReaderIterate(p, apSegment, nSegment, &filter,
|
||||||
fts3TermSelectCb, (void *)&tsc
|
fts3TermSelectCb, (void *)&tsc
|
||||||
);
|
);
|
||||||
|
@ -152,30 +152,31 @@ static int fts3SqlStmt(
|
|||||||
sqlite3_value **apVal
|
sqlite3_value **apVal
|
||||||
){
|
){
|
||||||
const char *azSql[] = {
|
const char *azSql[] = {
|
||||||
"DELETE FROM %Q.'%q_content' WHERE rowid = ?",
|
/* 0 */ "DELETE FROM %Q.'%q_content' WHERE rowid = ?",
|
||||||
"SELECT NOT EXISTS(SELECT docid FROM %Q.'%q_content' WHERE rowid!=?)",
|
/* 1 */ "SELECT NOT EXISTS(SELECT docid FROM %Q.'%q_content' WHERE rowid!=?)",
|
||||||
"DELETE FROM %Q.'%q_content'",
|
/* 2 */ "DELETE FROM %Q.'%q_content'",
|
||||||
"DELETE FROM %Q.'%q_segments'",
|
/* 3 */ "DELETE FROM %Q.'%q_segments'",
|
||||||
"DELETE FROM %Q.'%q_segdir'",
|
/* 4 */ "DELETE FROM %Q.'%q_segdir'",
|
||||||
"SELECT * FROM %Q.'%q_content' WHERE rowid=?",
|
/* 5 */ "SELECT * FROM %Q.'%q_content' WHERE rowid=?",
|
||||||
"SELECT coalesce(max(idx)+1, 0) FROM %Q.'%q_segdir' WHERE level=?",
|
/* 6 */ "SELECT coalesce(max(idx)+1, 0) FROM %Q.'%q_segdir' WHERE level=?",
|
||||||
"INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
|
/* 7 */ "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
|
||||||
"SELECT coalesce(max(blockid)+1, 1) FROM %Q.'%q_segments'",
|
/* 8 */ "SELECT coalesce(max(blockid)+1, 1) FROM %Q.'%q_segments'",
|
||||||
"INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
|
/* 9 */ "INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
|
||||||
|
|
||||||
/* Return segments in order from oldest to newest.*/
|
/* Return segments in order from oldest to newest.*/
|
||||||
"SELECT idx, start_block, leaves_end_block, end_block, root "
|
/* 10 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
|
||||||
"FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
|
"FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
|
||||||
"SELECT idx, start_block, leaves_end_block, end_block, root "
|
/* 11 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
|
||||||
"FROM %Q.'%q_segdir' ORDER BY level DESC, idx ASC",
|
"FROM %Q.'%q_segdir' ORDER BY level DESC, idx ASC",
|
||||||
|
|
||||||
"SELECT count(*) FROM %Q.'%q_segdir' WHERE level = ?",
|
/* 12 */ "SELECT count(*) FROM %Q.'%q_segdir' WHERE level = ?",
|
||||||
"SELECT count(*), max(level) FROM %Q.'%q_segdir'",
|
/* 13 */ "SELECT count(*), max(level) FROM %Q.'%q_segdir'",
|
||||||
|
|
||||||
|
/* 14 */ "DELETE FROM %Q.'%q_segdir' WHERE level = ?",
|
||||||
|
/* 15 */ "DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?",
|
||||||
|
/* 16 */ 0, /* CONTENT_INSERT - generated elsewhere */
|
||||||
|
/* 17 */ "SELECT block FROM %Q.'%q_segments' WHERE blockid = ?",
|
||||||
|
|
||||||
"DELETE FROM %Q.'%q_segdir' WHERE level = ?",
|
|
||||||
"DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?",
|
|
||||||
0, /* CONTENT_INSERT - generated elsewhere */
|
|
||||||
"SELECT block FROM %Q.'%q_segments' WHERE blockid = ?",
|
|
||||||
};
|
};
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
sqlite3_stmt *pStmt;
|
sqlite3_stmt *pStmt;
|
||||||
@ -251,6 +252,14 @@ int sqlite3Fts3ReadBlock(
|
|||||||
**
|
**
|
||||||
** There is only ever one instance of this SQL statement compiled for
|
** There is only ever one instance of this SQL statement compiled for
|
||||||
** each FTS3 table.
|
** each FTS3 table.
|
||||||
|
**
|
||||||
|
** The statement returns the following columns from the %_segdir table:
|
||||||
|
**
|
||||||
|
** 0: idx
|
||||||
|
** 1: start_block
|
||||||
|
** 2: leaves_end_block
|
||||||
|
** 3: end_block
|
||||||
|
** 4: root
|
||||||
*/
|
*/
|
||||||
int sqlite3Fts3AllSegdirs(Fts3Table *p, sqlite3_stmt **ppStmt){
|
int sqlite3Fts3AllSegdirs(Fts3Table *p, sqlite3_stmt **ppStmt){
|
||||||
return fts3SqlStmt(p, SQL_SELECT_ALL_LEVEL, ppStmt, 0);
|
return fts3SqlStmt(p, SQL_SELECT_ALL_LEVEL, ppStmt, 0);
|
||||||
@ -702,6 +711,7 @@ static int fts3SegReaderNext(Fts3SegReader *pReader){
|
|||||||
pReader->nTerm = nPrefix+nSuffix;
|
pReader->nTerm = nPrefix+nSuffix;
|
||||||
pNext += nSuffix;
|
pNext += nSuffix;
|
||||||
pNext += sqlite3Fts3GetVarint32(pNext, &pReader->nDoclist);
|
pNext += sqlite3Fts3GetVarint32(pNext, &pReader->nDoclist);
|
||||||
|
assert( pNext<&pReader->aNode[pReader->nNode] );
|
||||||
pReader->aDoclist = pNext;
|
pReader->aDoclist = pNext;
|
||||||
pReader->pOffsetList = 0;
|
pReader->pOffsetList = 0;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
@ -754,7 +764,7 @@ static void fts3SegReaderNextDocid(
|
|||||||
** Fts3SegReader.pOffsetList to point to the next offset list before
|
** Fts3SegReader.pOffsetList to point to the next offset list before
|
||||||
** returning.
|
** returning.
|
||||||
*/
|
*/
|
||||||
if( p==&pReader->aDoclist[pReader->nDoclist] ){
|
if( p>=&pReader->aDoclist[pReader->nDoclist] ){
|
||||||
pReader->pOffsetList = 0;
|
pReader->pOffsetList = 0;
|
||||||
}else{
|
}else{
|
||||||
sqlite3_int64 iDelta;
|
sqlite3_int64 iDelta;
|
||||||
|
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
|||||||
C Add\ssome\smissing\scomments\sand\sfix\ssome\sother\sissues\sin\sfts3\scode.
|
C Fix\sproblems\sintroduced\sinto\sfts3\sas\spart\sof\sthe\srefactoring.
|
||||||
D 2009-11-18T15:35:59
|
D 2009-11-19T00:15:28
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in 53f3dfa49f28ab5b80cb083fb7c9051e596bcfa1
|
F Makefile.in 53f3dfa49f28ab5b80cb083fb7c9051e596bcfa1
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@ -56,7 +56,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0
|
|||||||
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
|
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
|
||||||
F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
|
F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
|
||||||
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
|
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
|
||||||
F ext/fts3/fts3.c 2aa2c3f7b4d753f048af1c777b2c5fdd7e52c560
|
F ext/fts3/fts3.c 3251d3c5e2304bcd2d8d92d1fa8fa204cfdcd28d
|
||||||
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
|
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
|
||||||
F ext/fts3/fts3Int.h f7488bbc9fd12bd3843f59265227321a92b39ed4
|
F ext/fts3/fts3Int.h f7488bbc9fd12bd3843f59265227321a92b39ed4
|
||||||
F ext/fts3/fts3_expr.c bdf11f3602f62f36f0e42823680bf22033dae0de
|
F ext/fts3/fts3_expr.c bdf11f3602f62f36f0e42823680bf22033dae0de
|
||||||
@ -68,7 +68,7 @@ F ext/fts3/fts3_snippet.c 8ea9619247ac61c79aca650fc3307b8b4097b5f3
|
|||||||
F ext/fts3/fts3_tokenizer.c 185a212670a9bbdeb5cad6942305e681bce5c87b
|
F ext/fts3/fts3_tokenizer.c 185a212670a9bbdeb5cad6942305e681bce5c87b
|
||||||
F ext/fts3/fts3_tokenizer.h 7ff73caa3327589bf6550f60d93ebdd1f6a0fb5c
|
F ext/fts3/fts3_tokenizer.h 7ff73caa3327589bf6550f60d93ebdd1f6a0fb5c
|
||||||
F ext/fts3/fts3_tokenizer1.c 0a5bcc579f35de5d24a9345d7908dc25ae403ee7
|
F ext/fts3/fts3_tokenizer1.c 0a5bcc579f35de5d24a9345d7908dc25ae403ee7
|
||||||
F ext/fts3/fts3_write.c ec6bbf26bfa21e64b059535e46b3a8e57fb21f5c
|
F ext/fts3/fts3_write.c 041f6c4dda87db0248402245dc15c348ef8f7a99
|
||||||
F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
|
F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
|
||||||
F ext/icu/README.txt 3b130aa66e7a681136f6add198b076a2f90d1e33
|
F ext/icu/README.txt 3b130aa66e7a681136f6add198b076a2f90d1e33
|
||||||
F ext/icu/icu.c 12e763d288d23b5a49de37caa30737b971a2f1e2
|
F ext/icu/icu.c 12e763d288d23b5a49de37caa30737b971a2f1e2
|
||||||
@ -772,7 +772,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
P 45c051e78651d8204c17cecdda2bde705698881f
|
P 2fe579e778b75fbf503c02e01e5424c1926f2b49
|
||||||
R f882843f6b95cfb6a8f2fd130e122bb3
|
R 876c3ff77bbdae620820b9bcd69de73e
|
||||||
U dan
|
U dan
|
||||||
Z b8988750cf7cc171c22183eb295bebe6
|
Z 2c58b81314d821564ee17bc92f6804a7
|
||||||
|
@ -1 +1 @@
|
|||||||
2fe579e778b75fbf503c02e01e5424c1926f2b49
|
fa0998e19d984ee57f4f506c34eb858026cc49c3
|
Reference in New Issue
Block a user