Disable the LIKE optimization if the affinity of the LHS column is
not TEXT. Ticket #3901. (CVS 6727) FossilOrigin-Name: a255c645c46ae03b65f862858fe57e462076e1fc
This commit is contained in:
parent
49008596ed
commit
c4ac22e905
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C Update\sthe\serror\smessage\son\sone\sof\sthe\scorruption\stests\sto\saccount\sfor\sthe\sfact\nthat\swe\sare\sfinding\sthe\scorruption\ssooner.\s(CVS\s6726)
|
||||
D 2009-06-06T19:21:13
|
||||
C Disable\sthe\sLIKE\soptimization\sif\sthe\saffinity\sof\sthe\sLHS\scolumn\sis\nnot\sTEXT.\s\sTicket\s#3901.\s(CVS\s6727)
|
||||
D 2009-06-07T23:45:11
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 8b8fb7823264331210cddf103831816c286ba446
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -212,7 +212,7 @@ F src/vdbeblob.c c25d7e7bc6d5917feeb17270bd275fa771f26e5c
|
||||
F src/vdbemem.c 05183d46094aa99b8f8350e5761b9369dbef35a8
|
||||
F src/vtab.c e2f4c92df7d06330b151448718c4724742ff444b
|
||||
F src/walker.c ec4b9742a4077ef80346e2f9aaf0f44c2d95087a
|
||||
F src/where.c c6dda6e349e83de5da471704841791ecacaf87ca
|
||||
F src/where.c 01b8d4733f177f047014c0b391b4ecbcc867dfd8
|
||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
|
||||
F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45
|
||||
@ -431,7 +431,7 @@ F test/jrnlmode3.test cfcdb12b90e640a23b92785a002d96c0624c8710
|
||||
F test/keyword1.test a2400977a2e4fde43bf33754c2929fda34dbca05
|
||||
F test/lastinsert.test 474d519c68cb79d07ecae56a763aa7f322c72f51
|
||||
F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200
|
||||
F test/like.test 22f7857f9d7da7ff5061ded8806c43a6271109fc
|
||||
F test/like.test 4b594af9eddfd01018df1e9b1d18721aff619fa7
|
||||
F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da
|
||||
F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e
|
||||
F test/loadext.test 0393ce12d9616aa87597dd0ec88181de181f6db0
|
||||
@ -702,8 +702,8 @@ F test/where3.test 97d3936e6a443b968f1a61cdcc0f673252000e94
|
||||
F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2
|
||||
F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2
|
||||
F test/where6.test 42c4373595f4409d9c6a9987b4a60000ad664faf
|
||||
F test/where7.test 42d5e19c88234bfd110e01dd890a449a8ecb24fa
|
||||
F test/where8.test d403734801f8ec1a306222a94a111a641a28bee6
|
||||
F test/where7.test b6e84b472a024e45c6dbdadc52bbcab3fcc8d0e1
|
||||
F test/where8.test 4839a0a1447e178a9a0725c5136fb963445e7708
|
||||
F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739
|
||||
F test/where9.test be19e1a92f80985c1a121b4678bf7d2123eaa623
|
||||
F test/whereA.test 522469ca013ff97c81b5367e730042290889a061
|
||||
@ -733,7 +733,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
|
||||
P 4d129bee696f3a537f7ea5501a387012fc08c27e
|
||||
R 0886867af8335377b414a641e43ab0d1
|
||||
P ba9848e7b89df1fb6bf6db2b9d66cd3ffce375df
|
||||
R 81cd2c4f24010387a42ab7914dcb3be9
|
||||
U drh
|
||||
Z 92acfcf11caa462c7de054705c7ddd22
|
||||
Z e83d06023b0c10acd9b2d2194fc4e200
|
||||
|
@ -1 +1 @@
|
||||
ba9848e7b89df1fb6bf6db2b9d66cd3ffce375df
|
||||
a255c645c46ae03b65f862858fe57e462076e1fc
|
10
src/where.c
10
src/where.c
@ -16,7 +16,7 @@
|
||||
** so is applicable. Because this module is responsible for selecting
|
||||
** indices, you might also think of this module as the "query optimizer".
|
||||
**
|
||||
** $Id: where.c,v 1.401 2009/06/06 15:17:28 drh Exp $
|
||||
** $Id: where.c,v 1.402 2009/06/07 23:45:11 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -654,17 +654,15 @@ static int isLikeOrGlob(
|
||||
}
|
||||
pColl = sqlite3ExprCollSeq(pParse, pLeft);
|
||||
assert( pColl!=0 || pLeft->iColumn==-1 );
|
||||
if( pColl==0 ){
|
||||
/* No collation is defined for the ROWID. Use the default. */
|
||||
pColl = db->pDfltColl;
|
||||
}
|
||||
if( pColl==0 ) return 0;
|
||||
if( (pColl->type!=SQLITE_COLL_BINARY || *pnoCase) &&
|
||||
(pColl->type!=SQLITE_COLL_NOCASE || !*pnoCase) ){
|
||||
return 0;
|
||||
}
|
||||
if( sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT ) return 0;
|
||||
z = pRight->u.zToken;
|
||||
cnt = 0;
|
||||
if( z ){
|
||||
if( ALWAYS(z) ){
|
||||
while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
|
||||
cnt++;
|
||||
}
|
||||
|
113
test/like.test
113
test/like.test
@ -13,7 +13,7 @@
|
||||
# in particular the optimizations that occur to help those operators
|
||||
# run faster.
|
||||
#
|
||||
# $Id: like.test,v 1.12 2009/01/09 21:41:17 drh Exp $
|
||||
# $Id: like.test,v 1.13 2009/06/07 23:45:11 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -357,7 +357,7 @@ do_test like-5.2 {
|
||||
} 12
|
||||
do_test like-5.3 {
|
||||
execsql {
|
||||
CREATE TABLE t2(x COLLATE NOCASE);
|
||||
CREATE TABLE t2(x TEXT COLLATE NOCASE);
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
CREATE INDEX i2 ON t2(x COLLATE NOCASE);
|
||||
}
|
||||
@ -476,7 +476,7 @@ do_test like-5.24 {
|
||||
do_test like-5.25 {
|
||||
queryplan {
|
||||
PRAGMA case_sensitive_like=on;
|
||||
CREATE TABLE t3(x);
|
||||
CREATE TABLE t3(x TEXT);
|
||||
CREATE INDEX i3 ON t3(x);
|
||||
INSERT INTO t3 VALUES('ZZ-upper-upper');
|
||||
INSERT INTO t3 VALUES('zZ-lower-upper');
|
||||
@ -519,9 +519,9 @@ do_test like-6.1 {
|
||||
|
||||
do_test like-7.1 {
|
||||
execsql {
|
||||
SELECT * FROM t1 WHERE rowid GLOB '1*';
|
||||
SELECT rowid, * FROM t1 WHERE rowid GLOB '1*' ORDER BY rowid;
|
||||
}
|
||||
} {a}
|
||||
} {1 a 10 ABC 11 CDE 12 {ABC abc xyz}}
|
||||
|
||||
# ticket #3345.
|
||||
#
|
||||
@ -630,5 +630,108 @@ ifcapable like_opt {
|
||||
}
|
||||
}
|
||||
|
||||
# Do an SQL statement. Append the search count to the end of the result.
|
||||
#
|
||||
proc count sql {
|
||||
set ::sqlite_search_count 0
|
||||
set ::sqlite_like_count 0
|
||||
return [concat [execsql $sql] scan $::sqlite_search_count \
|
||||
like $::sqlite_like_count]
|
||||
}
|
||||
|
||||
# The LIKE and GLOB optimizations do not work on columns with
|
||||
# affinity other than TEXT.
|
||||
# Ticket #3901
|
||||
#
|
||||
do_test like-10.1 {
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
CREATE TABLE t10(
|
||||
a INTEGER PRIMARY KEY,
|
||||
b INTEGER COLLATE nocase UNIQUE,
|
||||
c NUMBER COLLATE nocase UNIQUE,
|
||||
d BLOB COLLATE nocase UNIQUE,
|
||||
e COLLATE nocase UNIQUE,
|
||||
f TEXT COLLATE nocase UNIQUE
|
||||
);
|
||||
INSERT INTO t10 VALUES(1,1,1,1,1,1);
|
||||
INSERT INTO t10 VALUES(12,12,12,12,12,12);
|
||||
INSERT INTO t10 VALUES(123,123,123,123,123,123);
|
||||
INSERT INTO t10 VALUES(234,234,234,234,234,234);
|
||||
INSERT INTO t10 VALUES(345,345,345,345,345,345);
|
||||
INSERT INTO t10 VALUES(45,45,45,45,45,45);
|
||||
}
|
||||
count {
|
||||
SELECT a FROM t10 WHERE b LIKE '12%' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 5 like 6}
|
||||
do_test like-10.2 {
|
||||
count {
|
||||
SELECT a FROM t10 WHERE c LIKE '12%' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 5 like 6}
|
||||
do_test like-10.3 {
|
||||
count {
|
||||
SELECT a FROM t10 WHERE d LIKE '12%' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 5 like 6}
|
||||
do_test like-10.4 {
|
||||
count {
|
||||
SELECT a FROM t10 WHERE e LIKE '12%' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 5 like 6}
|
||||
do_test like-10.5 {
|
||||
count {
|
||||
SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 3 like 0}
|
||||
do_test like-10.6 {
|
||||
count {
|
||||
SELECT a FROM t10 WHERE a LIKE '12%' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 5 like 6}
|
||||
do_test like-10.10 {
|
||||
execsql {
|
||||
CREATE TABLE t10b(
|
||||
a INTEGER PRIMARY KEY,
|
||||
b INTEGER UNIQUE,
|
||||
c NUMBER UNIQUE,
|
||||
d BLOB UNIQUE,
|
||||
e UNIQUE,
|
||||
f TEXT UNIQUE
|
||||
);
|
||||
INSERT INTO t10b SELECT * FROM t10;
|
||||
}
|
||||
count {
|
||||
SELECT a FROM t10b WHERE b GLOB '12*' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 5 like 6}
|
||||
do_test like-10.11 {
|
||||
count {
|
||||
SELECT a FROM t10b WHERE c GLOB '12*' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 5 like 6}
|
||||
do_test like-10.12 {
|
||||
count {
|
||||
SELECT a FROM t10b WHERE d GLOB '12*' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 5 like 6}
|
||||
do_test like-10.13 {
|
||||
count {
|
||||
SELECT a FROM t10b WHERE e GLOB '12*' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 5 like 6}
|
||||
do_test like-10.14 {
|
||||
count {
|
||||
SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 3 like 0}
|
||||
do_test like-10.15 {
|
||||
count {
|
||||
SELECT a FROM t10b WHERE a GLOB '12*' ORDER BY a;
|
||||
}
|
||||
} {12 123 scan 5 like 6}
|
||||
|
||||
|
||||
finish_test
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the multi-index OR clause optimizer.
|
||||
#
|
||||
# $Id: where7.test,v 1.8 2009/04/21 09:02:47 danielk1977 Exp $
|
||||
# $Id: where7.test,v 1.9 2009/06/07 23:45:11 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -181,7 +181,7 @@ do_test where7-1.32 {
|
||||
|
||||
do_test where7-2.1 {
|
||||
db eval {
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY,b,c,d,e,f,g);
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY,b,c,d,e,f TEXT,g);
|
||||
INSERT INTO t2 VALUES(1,11,1001,1.001,100.1,'bcdefghij','yxwvuts');
|
||||
INSERT INTO t2 VALUES(2,22,1001,2.002,100.1,'cdefghijk','yxwvuts');
|
||||
INSERT INTO t2 VALUES(3,33,1001,3.0029999999999997,100.1,'defghijkl','xwvutsr');
|
||||
@ -288,7 +288,7 @@ do_test where7-2.1 {
|
||||
CREATE INDEX t2e ON t2(e);
|
||||
CREATE INDEX t2f ON t2(f);
|
||||
CREATE INDEX t2g ON t2(g);
|
||||
CREATE TABLE t3(a INTEGER PRIMARY KEY,b,c,d,e,f,g);
|
||||
CREATE TABLE t3(a INTEGER PRIMARY KEY,b,c,d,e,f TEXT,g);
|
||||
INSERT INTO t3 SELECT * FROM t2;
|
||||
CREATE INDEX t3b ON t3(b,c);
|
||||
CREATE INDEX t3c ON t3(c,e);
|
||||
|
@ -12,7 +12,7 @@
|
||||
# is testing of where.c. More specifically, the focus is the optimization
|
||||
# of WHERE clauses that feature the OR operator.
|
||||
#
|
||||
# $Id: where8.test,v 1.7 2009/06/05 17:09:12 drh Exp $
|
||||
# $Id: where8.test,v 1.8 2009/06/07 23:45:11 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -40,7 +40,7 @@ proc execsql_status2 {sql {db db}} {
|
||||
|
||||
do_test where8-1.1 {
|
||||
execsql {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
CREATE TABLE t1(a, b TEXT, c);
|
||||
CREATE INDEX i1 ON t1(a);
|
||||
CREATE INDEX i2 ON t1(b);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user