-C Fix\sa\stypo\sin\sa\scomment\sin\sbtree.c.\s\s\sNo\schanges\sto\scode.
-D 2016-08-03T14:51:16.394
+C Make\ssure\sthe\sORDER\sBY\sLIMIT\soptimization\sis\snot\sapplied\sif\sthe\sinner-most\nloop\scan\sonly\shave\sa\ssingle\siteration\sand\sis\shence\snot\sreally\sa\sloop.
+D 2016-08-04T09:09:44.760
F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233
F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a
F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2
F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354
-F src/where.c bb1444f6ae6bc3cbd086cc61cd9c6e3a6168d89b
+F src/where.c 5c9df42d50888be8274a5a0eb062eb0629869bd3
F src/whereInt.h e5b939701a7ceffc5a3a8188a37f9746416ebcd0
F src/wherecode.c 99707d11907c71d289ee9553d2d1a22f1fd8ba41
F src/whereexpr.c d7dcbf14ce1b5876c1f76496162c30fcba669563
F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da
F test/like3.test 3608a2042b6f922f900fbfd5d3ce4e7eca57f7c4
F test/limit.test 0c99a27a87b14c646a9d583c7c89fd06c352663e
-F test/limit2.test 55c9f4d08c89311e00afd75045ee1a2aca205cb4
+F test/limit2.test 40e79f3d95f2077742aa5b7676f58c9af1735d83
F test/loadext.test d077450695ddb5c1ea3ad7d48e5f5850fe732ad9
F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7
F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b91444b5db8465f09d112455e722c888b3f94329
-R aa712e9e7089879865bbb38d4c2c515d
+P 722c12816347ee9fce7a090cfebef2c5841e7445
+R fd11dfb179ebaeb65493cf49055d4419
U drh
-Z 2b4f8b48b03032bd1efbc47f9457218f
+Z c8d986adc7b509414bb3aed9ed932c87
pWInfo->revMask = pFrom->revLoop;
if( pWInfo->nOBSat<=0 ){
pWInfo->nOBSat = 0;
- if( nLoop>0 ){
+ if( nLoop>0 && (pFrom->aLoop[nLoop-1]->wsFlags & WHERE_ONEROW)==0 ){
Bitmask m = 0;
int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,
WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m);
expr {$fast_count < 0.02*$slow_count}
} {1}
+# Bug report against the new ORDER BY LIMIT optimization just prior to
+# release. (Unreleased so there is no ticket).
+#
+# Make sure the optimization is not applied if the inner loop can only
+# provide a single row of output.
+#
+do_execsql_test limit2-200 {
+ CREATE TABLE t200(a, b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
+ INSERT INTO t200(a,b) SELECT x, x FROM c;
+ CREATE TABLE t201(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t201(x,y) VALUES(2,12345);
+
+ SELECT *, '|' FROM t200, t201 WHERE x=b ORDER BY y LIMIT 3;
+} {2 2 2 12345 |}
+do_execsql_test limit2-210 {
+ SELECT *, '|' FROM t200 LEFT JOIN t201 ON x=b ORDER BY y LIMIT 3;
+} {1 1 {} {} | 3 3 {} {} | 4 4 {} {} |}
+
+
+
+
finish_test