1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Reduce the amount of code used to implement OP_SeekGe and similar.

FossilOrigin-Name: 8b12a15a2a8139d75f56a099f3f6af844da3ac9c
This commit is contained in:
dan
2013-11-26 18:22:59 +00:00
parent 55fcab39be
commit aa1776f093
3 changed files with 29 additions and 39 deletions

View File

@@ -1,5 +1,5 @@
C Fix\sa\spossible\sNULL\spointer\sdeference\sin\sthe\swordcount\stest\sprogram. C Reduce\sthe\samount\sof\scode\sused\sto\simplement\sOP_SeekGe\sand\ssimilar.
D 2013-11-26T16:51:13.426 D 2013-11-26T18:22:59.246
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -280,7 +280,7 @@ F src/update.c c05a0ee658f1a149e0960dfd110f3b8bd846bcb0
F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269 F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269
F src/util.c cbe054290f780fcd472b89d701c7404c51ec9684 F src/util.c cbe054290f780fcd472b89d701c7404c51ec9684
F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
F src/vdbe.c 061d30aea5bbe70926236836be259ed217ee65c0 F src/vdbe.c d9c63f5c5679f6e6c96612264b5674b8020696c4
F src/vdbe.h c06f0813f853566457ce9cfb1a4a4bc39a5da644 F src/vdbe.h c06f0813f853566457ce9cfb1a4a4bc39a5da644
F src/vdbeInt.h 05fbda0e061dbc4aaa2709a8cccf3515c245b263 F src/vdbeInt.h 05fbda0e061dbc4aaa2709a8cccf3515c245b263
F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed
@@ -1143,7 +1143,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P c07caabf2396c84b2ccb0e9f98ae6279ce41c59d P 6f91dca0de908dc2b15130a6593a61c3147a409f
R d1a47818d75d4c09a9dcb48899bdd6d5 R d3fc734a7145de0774dfe549644c265c
U drh U dan
Z 42f2f4c4e3d27d9172438c5ee2b1524f Z 32a0a7a512d388c26cfa54a9b929b27b

View File

@@ -1 +1 @@
6f91dca0de908dc2b15130a6593a61c3147a409f 8b12a15a2a8139d75f56a099f3f6af844da3ac9c

View File

@@ -3510,38 +3510,28 @@ case OP_SeekGt: { /* jump, in3 */
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
break; break;
} }
/* If we reach this point, then the P3 value must be a floating
** point number. */
assert( (pIn3->flags & MEM_Real)!=0 );
if( (iKey==SMALLEST_INT64 && pIn3->r<(double)iKey) /* If the approximation iKey is larger than the actual real search
|| (iKey==LARGEST_INT64 && pIn3->r>(double)iKey) ** term, substitute >= for > and < for <=. e.g. if the search term
){ ** is 4.9 and the integer approximation 5:
/* The P3 value is too large in magnitude to be expressed as an **
** integer. */ ** (x > 4.9) -> (x >= 5)
res = 1; ** (x <= 4.9) -> (x < 5)
if( pIn3->r<0 ){ */
if( oc>=OP_SeekGe ){ assert( oc==OP_SeekGe || oc==OP_SeekGt ); if( pIn3->r<(double)iKey ){
rc = sqlite3BtreeFirst(pC->pCursor, &res); assert( OP_SeekGe==(OP_SeekGt-1) );
if( rc!=SQLITE_OK ) goto abort_due_to_error; assert( OP_SeekLt==(OP_SeekLe-1) );
} assert( (OP_SeekLe & 0x0001)==(OP_SeekGt & 0x0001) );
}else{ if( (oc & 0x0001)==(OP_SeekGt & 0x0001) ) oc--;
if( oc<=OP_SeekLe ){ assert( oc==OP_SeekLt || oc==OP_SeekLe ); }
rc = sqlite3BtreeLast(pC->pCursor, &res);
if( rc!=SQLITE_OK ) goto abort_due_to_error; /* If the approximation iKey is smaller than the actual real search
} ** term, substitute <= for < and > for >=. */
} else if( pIn3->r>(double)iKey ){
if( res ){ assert( OP_SeekLe==(OP_SeekLt+1) );
pc = pOp->p2 - 1; assert( OP_SeekGt==(OP_SeekGe+1) );
} assert( (OP_SeekLt & 0x0001)==(OP_SeekGe & 0x0001) );
break; if( (oc & 0x0001)==(OP_SeekLt & 0x0001) ) oc++;
}else if( oc==OP_SeekLt || oc==OP_SeekGe ){
/* Use the ceiling() function to convert real->int */
if( pIn3->r > (double)iKey ) iKey++;
}else{
/* Use the floor() function to convert real->int */
assert( oc==OP_SeekLe || oc==OP_SeekGt );
if( pIn3->r < (double)iKey ) iKey--;
} }
} }
rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, 0, (u64)iKey, 0, &res); rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, 0, (u64)iKey, 0, &res);