1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

When determining whether an == or IS constraint in a WHERE clause makes an ORDER BY term redundant, consider the collation sequence used by the == or IS comparison, not the collation sequence of the comparison expression itself. Possible fix for [fb8c538a8f].

FossilOrigin-Name: 16aed5d0c63dcdc2054dbb8a4b6b992476640433bf81e19301e6db5a3fc82633
This commit is contained in:
dan
2020-02-12 11:57:35 +00:00
parent df9b5cab93
commit 41aa442cf4
4 changed files with 60 additions and 11 deletions

View File

@ -126,5 +126,51 @@ do_execsql_test 3.1 {
SELECT a FROM t3 WHERE b=2 AND c=3 ORDER BY d DESC, e DESC, b, c, a DESC;
} {~/B-TREE/}
#-------------------------------------------------------------------------
do_execsql_test 4.1.0 {
CREATE TABLE t4(b COLLATE nocase);
INSERT INTO t4 VALUES('abc');
INSERT INTO t4 VALUES('ABC');
INSERT INTO t4 VALUES('aBC');
}
do_execsql_test 4.1.1 {
SELECT * FROM t4 ORDER BY b COLLATE binary
} {ABC aBC abc}
do_execsql_test 4.1.2 {
SELECT * FROM t4 WHERE b='abc' ORDER BY b COLLATE binary
} {ABC aBC abc}
do_execsql_test 4.2.1 {
CREATE TABLE Records(typeID INTEGER, key TEXT COLLATE nocase, value TEXT);
CREATE INDEX RecordsIndex ON Records(typeID, key, value);
}
do_execsql_test 4.2.2 {
explain query plan
SELECT typeID, key, value FROM Records
WHERE typeID = 2 AND key = 'x'
ORDER BY key, value;
} {~/TEMP B-TREE/}
do_execsql_test 4.2.3 {
explain query plan
SELECT typeID, key, value FROM Records
WHERE typeID = 2 AND (key = 'x' COLLATE binary)
ORDER BY key, value;
} {~/TEMP B-TREE/}
do_execsql_test 4.2.4 {
explain query plan
SELECT typeID, key, value FROM Records
WHERE typeID = 2
ORDER BY key, value;
} {~/TEMP B-TREE/}
db collate hello [list string match]
do_execsql_test 4.3.1 {
CREATE TABLE t5(a INTEGER PRIMARY KEY, b COLLATE hello, c, d);
}
db close
sqlite3 db test.db
do_catchsql_test 4.3.2 {
SELECT a FROM t5 WHERE b='def' ORDER BY b;
} {1 {no such collation sequence: hello}}
finish_test