1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Remove some unreachable code.

FossilOrigin-Name: 650e1a79eda5a2134a1fbd305ab1f205a57c0892
This commit is contained in:
dan
2011-06-04 20:13:24 +00:00
parent b46ee91729
commit 76e04431ef
3 changed files with 8 additions and 207 deletions

View File

@ -447,20 +447,6 @@ static void fts3GetReverseVarint(
*pVal = iVal;
}
/*
** As long as *pp has not reached its end (pEnd), then do the same
** as fts3GetDeltaVarint(): read a single varint and add it to *pVal.
** But if we have reached the end of the varint, just set *pp=0 and
** leave *pVal unchanged.
*/
static void fts3GetDeltaVarint2(char **pp, char *pEnd, sqlite3_int64 *pVal){
if( *pp>=pEnd ){
*pp = 0;
}else{
fts3GetDeltaVarint(pp, pVal);
}
}
/*
** The xDisconnect() virtual table method.
*/
@ -1912,188 +1898,6 @@ static int fts3PoslistNearMerge(
}
}
/*
** Values that may be used as the first parameter to fts3DoclistMerge().
*/
#define MERGE_NOT 2 /* D + D -> D */
#define MERGE_AND 3 /* D + D -> D */
#define MERGE_OR 4 /* D + D -> D */
#define MERGE_PHRASE 6 /* P + P -> D */
#define MERGE_NEAR 8 /* P + P -> D */
#define MERGE_POS_OR 5 /* P + P -> P */
#define MERGE_POS_PHRASE 7 /* P + P -> P */
#define MERGE_POS_NEAR 9 /* P + P -> P */
/*
** Merge the two doclists passed in buffer a1 (size n1 bytes) and a2
** (size n2 bytes). The output is written to pre-allocated buffer aBuffer,
** which is guaranteed to be large enough to hold the results. The number
** of bytes written to aBuffer is stored in *pnBuffer before returning.
**
** If successful, SQLITE_OK is returned. Otherwise, if a malloc error
** occurs while allocating a temporary buffer as part of the merge operation,
** SQLITE_NOMEM is returned.
*/
static int fts3DoclistMerge(
int mergetype, /* One of the MERGE_XXX constants */
int nParam1, /* Used by MERGE_NEAR and MERGE_POS_NEAR */
int nParam2, /* Used by MERGE_NEAR and MERGE_POS_NEAR */
char *aBuffer, /* Pre-allocated output buffer */
int *pnBuffer, /* OUT: Bytes written to aBuffer */
char *a1, /* Buffer containing first doclist */
int n1, /* Size of buffer a1 */
char *a2, /* Buffer containing second doclist */
int n2, /* Size of buffer a2 */
int *pnDoc /* OUT: Number of docids in output */
){
sqlite3_int64 i1 = 0;
sqlite3_int64 i2 = 0;
sqlite3_int64 iPrev = 0;
char *p = aBuffer;
char *p1 = a1;
char *p2 = a2;
char *pEnd1 = &a1[n1];
char *pEnd2 = &a2[n2];
int nDoc = 0;
assert( mergetype==MERGE_OR || mergetype==MERGE_POS_OR
|| mergetype==MERGE_AND || mergetype==MERGE_NOT
|| mergetype==MERGE_PHRASE || mergetype==MERGE_POS_PHRASE
|| mergetype==MERGE_NEAR || mergetype==MERGE_POS_NEAR
);
assert( mergetype==MERGE_POS_PHRASE || mergetype==MERGE_POS_NEAR );
if( !aBuffer ){
*pnBuffer = 0;
return SQLITE_NOMEM;
}
/* Read the first docid from each doclist */
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
switch( mergetype ){
case MERGE_OR:
case MERGE_POS_OR:
while( p1 || p2 ){
if( p2 && p1 && i1==i2 ){
fts3PutDeltaVarint(&p, &iPrev, i1);
if( mergetype==MERGE_POS_OR ) fts3PoslistMerge(&p, &p1, &p2);
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
}else if( !p2 || (p1 && i1<i2) ){
fts3PutDeltaVarint(&p, &iPrev, i1);
if( mergetype==MERGE_POS_OR ) fts3PoslistCopy(&p, &p1);
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
}else{
fts3PutDeltaVarint(&p, &iPrev, i2);
if( mergetype==MERGE_POS_OR ) fts3PoslistCopy(&p, &p2);
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
}
}
break;
case MERGE_AND:
while( p1 && p2 ){
if( i1==i2 ){
fts3PutDeltaVarint(&p, &iPrev, i1);
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
nDoc++;
}else if( i1<i2 ){
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
}else{
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
}
}
break;
case MERGE_NOT:
while( p1 ){
if( p2 && i1==i2 ){
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
}else if( !p2 || i1<i2 ){
fts3PutDeltaVarint(&p, &iPrev, i1);
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
}else{
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
}
}
break;
case MERGE_POS_PHRASE:
case MERGE_PHRASE: {
char **ppPos = (mergetype==MERGE_PHRASE ? 0 : &p);
while( p1 && p2 ){
if( i1==i2 ){
char *pSave = p;
sqlite3_int64 iPrevSave = iPrev;
fts3PutDeltaVarint(&p, &iPrev, i1);
if( 0==fts3PoslistPhraseMerge(ppPos, nParam1, 0, 1, &p1, &p2) ){
p = pSave;
iPrev = iPrevSave;
}else{
nDoc++;
}
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
}else if( i1<i2 ){
fts3PoslistCopy(0, &p1);
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
}else{
fts3PoslistCopy(0, &p2);
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
}
}
break;
}
default: assert( mergetype==MERGE_POS_NEAR || mergetype==MERGE_NEAR ); {
char *aTmp = 0;
char **ppPos = 0;
if( mergetype==MERGE_POS_NEAR ){
ppPos = &p;
aTmp = sqlite3_malloc(2*(n1+n2+1));
if( !aTmp ){
return SQLITE_NOMEM;
}
}
while( p1 && p2 ){
if( i1==i2 ){
char *pSave = p;
sqlite3_int64 iPrevSave = iPrev;
fts3PutDeltaVarint(&p, &iPrev, i1);
if( !fts3PoslistNearMerge(ppPos, aTmp, nParam1, nParam2, &p1, &p2) ){
iPrev = iPrevSave;
p = pSave;
}
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
}else if( i1<i2 ){
fts3PoslistCopy(0, &p1);
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
}else{
fts3PoslistCopy(0, &p2);
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
}
}
sqlite3_free(aTmp);
break;
}
}
if( pnDoc ) *pnDoc = nDoc;
*pnBuffer = (int)(p-aBuffer);
return SQLITE_OK;
}
/*
** A pointer to an instance of this structure is used as the context
** argument to sqlite3Fts3SegReaderIterate()
@ -2253,7 +2057,6 @@ static void fts3DoclistPhraseMerge(
*/
static int fts3DoclistNearMerge(
int bDescIdx,
int mergetype, /* MERGE_POS_NEAR or MERGE_NEAR */
int nNear, /* Parameter to NEAR operator */
int nTokenLeft, /* Number of tokens in LHS phrase arg */
char *aLeft, /* Doclist for LHS (incl. positions) */
@ -2336,7 +2139,6 @@ static int fts3DoclistNearMerge(
** TermSelect.aaOutput[] array.
*/
static int fts3TermSelectMerge(Fts3Table *p, TermSelect *pTS){
int mergetype = (pTS->isReqPos ? MERGE_POS_OR : MERGE_OR);
char *aOut = 0;
int nOut = 0;
int i;
@ -2406,7 +2208,6 @@ static int fts3TermSelectCb(
return SQLITE_NOMEM;
}
}else{
int mergetype = (pTS->isReqPos ? MERGE_POS_OR : MERGE_OR);
char *aMerge = aDoclist;
int nMerge = nDoclist;
int iOut;
@ -3816,7 +3617,7 @@ static void fts3EvalNearMerge(
char *aOut; /* Buffer in which to assemble new doclist */
int nOut; /* Size of buffer aOut in bytes */
*pRc = fts3DoclistNearMerge(bDescIdx, MERGE_POS_NEAR, nNear,
*pRc = fts3DoclistNearMerge(bDescIdx, nNear,
pLeft->nToken, pLeft->doclist.aAll, pLeft->doclist.nAll,
pRight->nToken, pRight->doclist.aAll, pRight->doclist.nAll,
&aOut, &nOut

View File

@ -1,5 +1,5 @@
C Allow\sthe\s"order=DESC"\sand\s"order=ASC"\sparameters\sin\sFTS4\s"CREATE\sVIRTUAL\sTABLE"\sstatements.\sTables\screated\swith\s"order=DESC"\sstore\sall\sdoclists\sin\sdescending\sorder,\swhich\sallows\soptimizations\snormally\sapplied\sto\s"ORDER\sBY\sdocid\sASC"\squeries\sto\sbe\sused\swith\s"ORDER\sBY\sdocid\sDESC"\squeries\sinstead.
D 2011-06-04T20:04:35.492
C Remove\ssome\sunreachable\scode.
D 2011-06-04T20:13:24.690
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -61,7 +61,7 @@ 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 432c902c697850cbc5ffc2be8a945ac7ac3328d7
F ext/fts3/fts3.c 31f73cae1d21daba547c471a0a78d31e7516a29e
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h d76b021d5b7061eff7aa4055b5938eebef2bdb6a
F ext/fts3/fts3_aux.c 28fc512608e147015c36080025456f57f571f76f
@ -939,7 +939,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P a4c7e2820824e82580730c36f85aede2efa66754
R 2bf28954217e137f11160d52b346ca5f
P f6a0193f5a32603eb48bddc6297042dbd2ffe96e
R a65937620eeff7552523045d1ea22bb7
U dan
Z b16ce48fbf2f9ba7236a3b596adb6f59
Z 582e1f65a0e245127649a23c8e5f1248

View File

@ -1 +1 @@
f6a0193f5a32603eb48bddc6297042dbd2ffe96e
650e1a79eda5a2134a1fbd305ab1f205a57c0892