-C When\sa\stransaction\sor\ssavepoint\srollback\soccurs,\ssave\sthe\spositions\sof\sall\sopen\sread-cursors\sso\sthat\sthey\scan\sbe\srestored\sfollowing\sthe\srollback\soperation.\s\sCherry-pick\sof\scheck-in\s[dd03a2802f3f27]
-D 2014-11-13T13:42:39.738
+C Do\snot\sautomatically\sremove\sthe\sDISTINCT\skeyword\sfrom\s"a\sIN\s(SELECT\sDISTINCT\s...)"\sexpressions.\sFix\sfor\s[db87229497].
+D 2014-11-14T15:42:23.965
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/ctime.c bb434068b5308a857b181c2d204a320ff0d6c638
F src/date.c 57a7f9ba9f6b4d5268f5e411739066a611f99036
F src/delete.c 0750b1eb4d96cd3fb2c798599a3a7c85e92f1417
-F src/expr.c fc204d08af06437ddaffe5a1b1f1f6f9e1a55d6d
+F src/expr.c 1891cb50510a31e96de8a54579e7d3aef60f0094
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c da985ae673efef2c712caef825a5d2edb087ead7
F src/func.c ba47c1671ab3cfdafa6e9d6ee490939ea578adee
F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75
F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0
F test/in4.test d2b38cba404bc4320f4fe1b595b3d163f212c068
-F test/in5.test 99f9a40af01711b06d2d614ecfe96129f334fba3
+F test/in5.test 1de657472fa9ac2924be25c2c959ac5ca1aae554
F test/incrblob.test e81846d214f3637622620fbde7cd526781cfe328
F test/incrblob2.test bf4d549aa4a466d7fbe3e3a3693d3861263d5600
F test/incrblob3.test d8d036fde015d4a159cd3cbae9d29003b37227a4
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 839a6df9f98b90fb593534a62145d9c913540bae
-Q +dd03a2802f3f276525f3cef9a93f825dd8606626
-R 0801523eb21d9763755a3afd3e84ae8b
+P 402780a9c8df9e7ea898bdca49c1191042fe387a
+Q +55e453aadbb676dda07f0fa537d39ce184ef636c
+R 0bf0d6ff158ba2352191f711d5e9a856
U drh
-Z 995ce8d43edc83cec464fe7495c36085
+Z fc11fd8e7149b148ee2e3386efe4bde7
-402780a9c8df9e7ea898bdca49c1191042fe387a
\ No newline at end of file
+98457a57d642b35917eb9ad8f70065e273aad206
\ No newline at end of file
assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
pSelect->iLimit = 0;
testcase( pSelect->selFlags & SF_Distinct );
- pSelect->selFlags &= ~SF_Distinct;
testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
if( sqlite3Select(pParse, pSelect, &dest) ){
sqlite3KeyInfoUnref(pKeyInfo);
set testdir [file dirname $argv0]
source $testdir/tester.tcl
+set testprefix in5
do_test in5-1.1 {
execsql {
}]
} {0}
+#-------------------------------------------------------------------------
+# At one point SQLite was removing the DISTINCT keyword from expressions
+# similar to:
+#
+# <expr1> IN (SELECT DISTINCT <expr2> FROM...)
+#
+# However, there are a few obscure cases where this is incorrect. For
+# example, if the SELECT features a LIMIT clause, or if the collation
+# sequence or affinity used by the DISTINCT does not match the one used
+# by the IN(...) expression.
+#
+do_execsql_test 6.1.1 {
+ CREATE TABLE t1(a COLLATE nocase);
+ INSERT INTO t1 VALUES('one');
+ INSERT INTO t1 VALUES('ONE');
+}
+do_execsql_test 6.1.2 {
+ SELECT count(*) FROM t1 WHERE a COLLATE BINARY IN (SELECT DISTINCT a FROM t1)
+} {1}
+
+do_execsql_test 6.2.1 {
+ CREATE TABLE t3(a, b);
+ INSERT INTO t3 VALUES(1, 1);
+ INSERT INTO t3 VALUES(1, 2);
+ INSERT INTO t3 VALUES(1, 3);
+ INSERT INTO t3 VALUES(2, 4);
+ INSERT INTO t3 VALUES(2, 5);
+ INSERT INTO t3 VALUES(2, 6);
+ INSERT INTO t3 VALUES(3, 7);
+ INSERT INTO t3 VALUES(3, 8);
+ INSERT INTO t3 VALUES(3, 9);
+}
+do_execsql_test 6.2.2 {
+ SELECT count(*) FROM t3 WHERE b IN (SELECT DISTINCT a FROM t3 LIMIT 5);
+} {3}
+do_execsql_test 6.2.3 {
+ SELECT count(*) FROM t3 WHERE b IN (SELECT a FROM t3 LIMIT 5);
+} {2}
+
+do_execsql_test 6.3.1 {
+ CREATE TABLE x1(a);
+ CREATE TABLE x2(b);
+ INSERT INTO x1 VALUES(1), (1), (2);
+ INSERT INTO x2 VALUES(1), (2);
+ SELECT count(*) FROM x2 WHERE b IN (SELECT DISTINCT a FROM x1 LIMIT 2);
+} {2}
+
finish_test