Fix for ticket [f973c7ac31].

FossilOrigin-Name: 6eb058dda8d5f87b02378d8efd821fe64a525dcc
This commit is contained in:
dan 2010-06-09 15:47:11 +00:00
parent db7f647e41
commit 6ac4339439
4 changed files with 114 additions and 33 deletions

View File

@ -1,8 +1,5 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Shift\sthe\smeaning\sof\saReadMark[]\sback\sso\sthat\s+1\soffset\sfrom\smxFrame\sis\nremoved.\s\sAdd\sthe\snew\sREADMARK_NOT_USED\svalue\s(0xffffffff)\sinstead\sof\nzero\sto\ssignal\san\saReadMark[]\sthat\sis\snot\sin\suse.
D 2010-06-09T14:45:13
C Fix\sfor\sticket\s[f973c7ac31].
D 2010-06-09T15:47:11
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -230,7 +227,7 @@ F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
F src/wal.c 25ce19c8e175baf0c7d303243d38c0b2d4b1ba30
F src/wal.h 4ace25262452d17e7d3ec970c89ee17794004008
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
F src/where.c 75fee9e255b62f773fcadd1d1f25b6f63ac7a356
F src/where.c 1c895bef33d0dfc7ed90fb1f74120435d210ea56
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
F test/all.test 1f527d5ecd6614eeba91a02a24ab2baf5b5a1218
@ -633,6 +630,7 @@ F test/tkt-9d68c883.test 4251ef9fa08158e50b28a682e56124457a59d048
F test/tkt-cbd054fa6b.test f14f97ea43662e6f70c9e63287081e8be5d9d589
F test/tkt-d82e3f3721.test 731359dfdcdb36fea0559cd33fec39dd0ceae8e6
F test/tkt-f777251dc7a.test 6f24c053bc5cdb7e1e19be9a72c8887cf41d5e87
F test/tkt-f973c7ac31.test 1da0ed15ec2c7749fb5ce2828cd69d07153ad9f4
F test/tkt1435.test f8c52c41de6e5ca02f1845f3a46e18e25cadac00
F test/tkt1443.test bacc311da5c96a227bf8c167e77a30c99f8e8368
F test/tkt1444.test a9d72f9e942708bd82dde6c707da61c489e213e9
@ -820,14 +818,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 3c2de820034e01c2e939bd90a05a58159f60df50
R 91636215da20a362ea2e64fc78c9decc
U drh
Z 48ecf6d24ad1746c8fc1cd67f013e730
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFMD6j8oxKgR168RlERAhEQAJ9R5n1TsaleiaYrC7/BGXipfEEX+wCeIl+J
u01EHGRvmB2pUOkEor+I24I=
=iubS
-----END PGP SIGNATURE-----
P c576827d55c156572b76cf7063e9f253ca6e7403
R b48b1a3c1b5bb2e514409ff77e6be7cf
U dan
Z f948595e6780591bfcc76536af294f11

View File

@ -1 +1 @@
c576827d55c156572b76cf7063e9f253ca6e7403
6eb058dda8d5f87b02378d8efd821fe64a525dcc

View File

@ -3384,7 +3384,8 @@ static Bitmask codeOneLoopStart(
int iIdxCur; /* The VDBE cursor for the index */
int nExtraReg = 0; /* Number of extra registers needed */
int op; /* Instruction opcode */
char *zAff;
char *zStartAff; /* Affinity for start of range constraint */
char *zEndAff; /* Affinity for end of range constraint */
pIdx = pLevel->plan.u.pIdx;
iIdxCur = pLevel->iIdxCur;
@ -3425,8 +3426,9 @@ static Bitmask codeOneLoopStart(
** starting at regBase.
*/
regBase = codeAllEqualityTerms(
pParse, pLevel, pWC, notReady, nExtraReg, &zAff
pParse, pLevel, pWC, notReady, nExtraReg, &zStartAff
);
zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
addrNxt = pLevel->addrNxt;
/* If we are doing a reverse order scan on an ascending index, or
@ -3451,15 +3453,15 @@ static Bitmask codeOneLoopStart(
Expr *pRight = pRangeStart->pExpr->pRight;
sqlite3ExprCode(pParse, pRight, regBase+nEq);
sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);
if( zAff ){
if( sqlite3CompareAffinity(pRight, zAff[nConstraint])==SQLITE_AFF_NONE){
if( zStartAff ){
if( sqlite3CompareAffinity(pRight, zStartAff[nEq])==SQLITE_AFF_NONE){
/* Since the comparison is to be performed with no conversions
** applied to the operands, set the affinity to apply to pRight to
** SQLITE_AFF_NONE. */
zAff[nConstraint] = SQLITE_AFF_NONE;
zStartAff[nEq] = SQLITE_AFF_NONE;
}
if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[nConstraint]) ){
zAff[nConstraint] = SQLITE_AFF_NONE;
if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
zStartAff[nEq] = SQLITE_AFF_NONE;
}
}
nConstraint++;
@ -3469,7 +3471,7 @@ static Bitmask codeOneLoopStart(
startEq = 0;
start_constraints = 1;
}
codeApplyAffinity(pParse, regBase, nConstraint, zAff);
codeApplyAffinity(pParse, regBase, nConstraint, zStartAff);
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
assert( op!=0 );
testcase( op==OP_Rewind );
@ -3489,21 +3491,22 @@ static Bitmask codeOneLoopStart(
sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
sqlite3ExprCode(pParse, pRight, regBase+nEq);
sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);
if( zAff ){
if( sqlite3CompareAffinity(pRight, zAff[nConstraint])==SQLITE_AFF_NONE){
if( zEndAff ){
if( sqlite3CompareAffinity(pRight, zEndAff[nEq])==SQLITE_AFF_NONE){
/* Since the comparison is to be performed with no conversions
** applied to the operands, set the affinity to apply to pRight to
** SQLITE_AFF_NONE. */
zAff[nConstraint] = SQLITE_AFF_NONE;
zEndAff[nEq] = SQLITE_AFF_NONE;
}
if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[nConstraint]) ){
zAff[nConstraint] = SQLITE_AFF_NONE;
if( sqlite3ExprNeedsNoAffinityChange(pRight, zEndAff[nEq]) ){
zEndAff[nEq] = SQLITE_AFF_NONE;
}
}
codeApplyAffinity(pParse, regBase, nEq+1, zAff);
codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
nConstraint++;
}
sqlite3DbFree(pParse->db, zAff);
sqlite3DbFree(pParse->db, zStartAff);
sqlite3DbFree(pParse->db, zEndAff);
/* Top of the loop body */
pLevel->p2 = sqlite3VdbeCurrentAddr(v);

87
test/tkt-f973c7ac31.test Normal file
View File

@ -0,0 +1,87 @@
# 2010 June 09
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test tkt-f973c7ac3-1.0 {
execsql {
CREATE TABLE t(c1 INTEGER, c2 INTEGER);
INSERT INTO t VALUES(5, 5);
INSERT INTO t VALUES(5, 4);
}
} {}
foreach {tn sql} {
1 ""
2 "CREATE INDEX i1 ON t(c1, c2)"
} {
execsql $sql
do_test tkt-f973c7ac3-1.$tn.1 {
execsql {
SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='2' ORDER BY c2 DESC
}
} {}
do_test tkt-f973c7ac3-1.$tn.2 {
execsql {
SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<=5 ORDER BY c2 DESC
}
} {5 5 5 4}
do_test tkt-f973c7ac3-1.$tn.3 {
execsql {
SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='5' ORDER BY c2 DESC
}
} {5 5 5 4}
do_test tkt-f973c7ac3-1.$tn.4 {
execsql {
SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<=5 ORDER BY c2 DESC
}
} {5 5 5 4}
do_test tkt-f973c7ac3-1.$tn.5 {
execsql {
SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<='5' ORDER BY c2 DESC
}
} {5 5 5 4}
do_test tkt-f973c7ac3-1.$tn.6 {
execsql {
SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='2' ORDER BY c2 ASC
}
} {}
do_test tkt-f973c7ac3-1.$tn.7 {
execsql {
SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<=5 ORDER BY c2 ASC
}
} {5 4 5 5}
do_test tkt-f973c7ac3-1.$tn.8 {
execsql {
SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='5' ORDER BY c2 ASC
}
} {5 4 5 5}
do_test tkt-f973c7ac3-1.$tn.9 {
execsql {
SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<=5 ORDER BY c2 ASC
}
} {5 4 5 5}
do_test tkt-f973c7ac3-1.$tn.10 {
execsql {
SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<='5' ORDER BY c2 ASC
}
} {5 4 5 5}
}
finish_test