mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Fix a bug reported on the mailing list triggered by the pattern "SELECT <col>, (SELECT ... FROM tbl WHERE rowid > <col>) FROM ...". (CVS 5855)
FossilOrigin-Name: 6c918c4eb9362ebfdbe0486515679102b2862970
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Test\sthat\ssingle\sbyte\scorruptions\sin\sincreasingly\slarger\squantities\sare\shandled\sgracefully.\s(CVS\s5854)
|
C Fix\sa\sbug\sreported\son\sthe\smailing\slist\striggered\sby\sthe\spattern\s"SELECT\s<col>,\s(SELECT\s...\sFROM\stbl\sWHERE\srowid\s>\s<col>)\sFROM\s...".\s(CVS\s5855)
|
||||||
D 2008-10-31T13:57:40
|
D 2008-11-03T09:06:06
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in da817da72422f9b876602c225fcd17d6ca4182f7
|
F Makefile.in da817da72422f9b876602c225fcd17d6ca4182f7
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@@ -200,7 +200,7 @@ F src/vdbefifo.c 20fda2a7c4c0bcee1b90eb7e545fefcdbf2e1de7
|
|||||||
F src/vdbemem.c c0e9d9947db8968762c7621369f821bb181c1c86
|
F src/vdbemem.c c0e9d9947db8968762c7621369f821bb181c1c86
|
||||||
F src/vtab.c 527c180e9c5fca417c9167d02af4b5039f892b4b
|
F src/vtab.c 527c180e9c5fca417c9167d02af4b5039f892b4b
|
||||||
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
|
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
|
||||||
F src/where.c 1853c1bfb567a415d904d70a4613dc07b00c74c5
|
F src/where.c 171c9b2583944f66484c8552daa85373ce9e949f
|
||||||
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
|
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
|
||||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||||
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
|
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
|
||||||
@@ -617,7 +617,7 @@ F test/vtabC.test 9f2d9eb84bf65e606d6616f20977c5a32a11f548
|
|||||||
F test/vtab_alter.test 3a299749fee97ca3d53bd55717f536e4a2284856
|
F test/vtab_alter.test 3a299749fee97ca3d53bd55717f536e4a2284856
|
||||||
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
|
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
|
||||||
F test/vtab_shared.test c19b2555b807ef2ee014c882cdda5bc8d84fcf48
|
F test/vtab_shared.test c19b2555b807ef2ee014c882cdda5bc8d84fcf48
|
||||||
F test/where.test 12396f15d8bf7a5763aa26129e071cdb441f600c
|
F test/where.test de337a3fe0a459ec7c93db16a519657a90552330
|
||||||
F test/where2.test e446f55417f434929522d87164cd1473d54f10e2
|
F test/where2.test e446f55417f434929522d87164cd1473d54f10e2
|
||||||
F test/where3.test 97d3936e6a443b968f1a61cdcc0f673252000e94
|
F test/where3.test 97d3936e6a443b968f1a61cdcc0f673252000e94
|
||||||
F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2
|
F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2
|
||||||
@@ -653,7 +653,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
|||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
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
|
||||||
P bfce91429b1dad6e0ca36929e41a7adfb30f8522
|
P c73d915923e393f72e1c0897526a20527db2e03c
|
||||||
R 7e7399b4dd0e7285795a33efa071b32a
|
R 81b77b0f0b421033be987682a8d0b4be
|
||||||
U shane
|
U danielk1977
|
||||||
Z 036cf1ab4484f24cac77efa2333c4427
|
Z 86fef2c70c68267aff5116fbaf03ae0a
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
c73d915923e393f72e1c0897526a20527db2e03c
|
6c918c4eb9362ebfdbe0486515679102b2862970
|
||||||
18
src/where.c
18
src/where.c
@@ -16,7 +16,7 @@
|
|||||||
** so is applicable. Because this module is responsible for selecting
|
** so is applicable. Because this module is responsible for selecting
|
||||||
** indices, you might also think of this module as the "query optimizer".
|
** indices, you might also think of this module as the "query optimizer".
|
||||||
**
|
**
|
||||||
** $Id: where.c,v 1.327 2008/10/25 15:03:21 drh Exp $
|
** $Id: where.c,v 1.328 2008/11/03 09:06:06 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -2472,16 +2472,26 @@ WhereInfo *sqlite3WhereBegin(
|
|||||||
}
|
}
|
||||||
if( pStart ){
|
if( pStart ){
|
||||||
Expr *pX;
|
Expr *pX;
|
||||||
int r1, regFree1;
|
int r1;
|
||||||
pX = pStart->pExpr;
|
pX = pStart->pExpr;
|
||||||
assert( pX!=0 );
|
assert( pX!=0 );
|
||||||
assert( pStart->leftCursor==iCur );
|
assert( pStart->leftCursor==iCur );
|
||||||
r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, ®Free1);
|
|
||||||
|
/* The ForceInt instruction may modify the register that it operates
|
||||||
|
** on. For example it may replace a real value with an integer one,
|
||||||
|
** or if p3 is true it may increment the register value. For this
|
||||||
|
** reason we need to make sure that register r1 is really a newly
|
||||||
|
** allocated temporary register, and not part of the column-cache.
|
||||||
|
** For this reason we cannot use sqlite3ExprCodeTemp() here.
|
||||||
|
*/
|
||||||
|
r1 = sqlite3GetTempReg(pParse);
|
||||||
|
sqlite3ExprCode(pParse, pX->pRight, r1);
|
||||||
|
|
||||||
sqlite3VdbeAddOp3(v, OP_ForceInt, r1, brk,
|
sqlite3VdbeAddOp3(v, OP_ForceInt, r1, brk,
|
||||||
pX->op==TK_LE || pX->op==TK_GT);
|
pX->op==TK_LE || pX->op==TK_GT);
|
||||||
sqlite3VdbeAddOp3(v, bRev ? OP_MoveLt : OP_MoveGe, iCur, brk, r1);
|
sqlite3VdbeAddOp3(v, bRev ? OP_MoveLt : OP_MoveGe, iCur, brk, r1);
|
||||||
VdbeComment((v, "pk"));
|
VdbeComment((v, "pk"));
|
||||||
sqlite3ReleaseTempReg(pParse, regFree1);
|
sqlite3ReleaseTempReg(pParse, r1);
|
||||||
disableTerm(pLevel, pStart);
|
disableTerm(pLevel, pStart);
|
||||||
}else{
|
}else{
|
||||||
sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, brk);
|
sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, brk);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this file is testing the use of indices in WHERE clases.
|
# focus of this file is testing the use of indices in WHERE clases.
|
||||||
#
|
#
|
||||||
# $Id: where.test,v 1.49 2008/10/07 23:46:38 drh Exp $
|
# $Id: where.test,v 1.50 2008/11/03 09:06:06 danielk1977 Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@@ -1215,4 +1215,46 @@ do_test where-16.4 {
|
|||||||
|
|
||||||
integrity_check {where-99.0}
|
integrity_check {where-99.0}
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------
|
||||||
|
# These tests test that a bug surrounding the use of ForceInt has been
|
||||||
|
# fixed in where.c.
|
||||||
|
#
|
||||||
|
do_test where-17.1 {
|
||||||
|
execsql {
|
||||||
|
CREATE TABLE tbooking (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
eventtype INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
INSERT INTO tbooking VALUES(42, 3);
|
||||||
|
INSERT INTO tbooking VALUES(43, 4);
|
||||||
|
}
|
||||||
|
} {}
|
||||||
|
do_test where-17.2 {
|
||||||
|
execsql {
|
||||||
|
SELECT a.id
|
||||||
|
FROM tbooking AS a
|
||||||
|
WHERE a.eventtype=3;
|
||||||
|
}
|
||||||
|
} {42}
|
||||||
|
do_test where-17.3 {
|
||||||
|
execsql {
|
||||||
|
SELECT a.id, (SELECT b.id FROM tbooking AS b WHERE b.id>a.id)
|
||||||
|
FROM tbooking AS a
|
||||||
|
WHERE a.eventtype=3;
|
||||||
|
}
|
||||||
|
} {42 43}
|
||||||
|
do_test where-17.4 {
|
||||||
|
execsql {
|
||||||
|
SELECT a.id, (SELECT b.id FROM tbooking AS b WHERE b.id>a.id)
|
||||||
|
FROM (SELECT 1.5 AS id) AS a
|
||||||
|
}
|
||||||
|
} {1.5 42}
|
||||||
|
do_test where-17.5 {
|
||||||
|
execsql {
|
||||||
|
CREATE TABLE tother(a, b);
|
||||||
|
INSERT INTO tother VALUES(1, 3.7);
|
||||||
|
SELECT id, a FROM tbooking, tother WHERE id>a;
|
||||||
|
}
|
||||||
|
} {42 1 43 1}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|||||||
Reference in New Issue
Block a user