-C Cherrypick\schange\s[27c65d4d9c]\sinto\sthe\s3.7.2\sbranch.
-D 2011-07-02T15:42:12.533
+C Cherrypick\schange\s[9f14fa56ba]\s(the\sfix\sfor\s[54844eea3f])\sfrom\sthe\strunk.
+D 2011-07-12T14:48:56.574
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 543f91f24cd7fee774ecc0a61c19704c0c3e78fd
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/ctime.c 2e39d3374e785a63117e077bcba9d4a6656df363
F src/date.c 5dd8448a0bfea8d31fb14cff487d0c06ff8c8b20
F src/delete.c daff6cef77fe8ed57b8acfc5ecebce28244af2fa
-F src/expr.c 21ad2494bd7c0826072216ea0f20db86a0a4ac82
+F src/expr.c c0d7088c13c9cee74043606a41dcc4696a9ea7cc
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c d56da9f698067e52a45736e97b17ee01cd849b78
F src/func.c 464b0dc70618b896c402c574eb04bc5eacf35341
F src/prepare.c c2b318037d626fed27905c9446730b560637217a
F src/printf.c 8ae5082dd38a1b5456030c3755ec3a392cd51506
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
-F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706
+F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c 27ceaf3ae2c493d299adec578bbc9e397ebf2806
F src/shell.c 8517fc1f9c59ae4007e6cc8b9af91ab231ea2056
F src/sqlite.h.in 2d72a6242df41c517e38eec8791abcf5484a36f1
F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
-F src/sqliteInt.h efeea5b4666749c99eceae31194e085c059cdb3e
+F src/sqliteInt.h 0e4a570a645e4e9005ef44e5178ad59755e33623
F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44
F src/status.c 496913d4e8441195f6f2a75b1c95993a45b9b30b
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/wal.c 5ac2119e23ee4424599d4275b66dc88d612a0543
F src/wal.h 96669b645e27cd5a111ba59f0cae7743a207bc3c
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
-F src/where.c f4561d5258681f94b663d81fe76f03ef6a524f0a
+F src/where.c def5ef535909779f6fe23bde7779ce6256976972
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
F test/all.test 6745008c144bd2956d58864d21f7b304689c1cce
F test/tkt-31338dca7e.test 5741cd48de500347a437ba1be58c8335e83c5a5e
F test/tkt-3fe897352e.test 10de1a67bd5c66b238a4c96abe55531b37bb4f00
F test/tkt-4a03edc4c8.test 2865e4edbc075b954daa82f8da7cc973033ec76e
+F test/tkt-54844eea3f.test a12b851128f46a695e4e378cca67409b9b8f5894
F test/tkt-5e10420e8d.test 904d1687b3c06d43e5b3555bbcf6802e7c0ffd84
F test/tkt-5ee23731f.test 3581260f2a71e51db94e1506ba6b0f7311d002a9
F test/tkt-78e04e52ea.test ab52f0c1e2de6e46c910f4cc16b086bba05952b7
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P c593792ce00d0a6379f31cab1bca22f5e159ce18
-R 4d654992cb4816a2a8066724f218a1f3
+P 9bbcd8c076ce1add222da1f45ff4ee5ea2fcfc2e
+R a0a01d591a762c7dcc1325c3e75bbb8f
U dan
-Z 449cb15ff909d159c8f79196788b498c
+Z 72961d3db50330bb343b511f07c73431
-9bbcd8c076ce1add222da1f45ff4ee5ea2fcfc2e
\ No newline at end of file
+7afb2354d3791cbce00200ddee6d9f230b9452e2
\ No newline at end of file
pNewItem->jointype = pOldItem->jointype;
pNewItem->iCursor = pOldItem->iCursor;
pNewItem->isPopulated = pOldItem->isPopulated;
+ pNewItem->isCorrelated = pOldItem->isCorrelated;
pNewItem->zIndex = sqlite3DbStrDup(db, pOldItem->zIndex);
pNewItem->notIndexed = pOldItem->notIndexed;
pNewItem->pIndex = pOldItem->pIndex;
for(i=0; i<p->pSrc->nSrc; i++){
struct SrcList_item *pItem = &p->pSrc->a[i];
if( pItem->pSelect ){
+ NameContext *pNC; /* Used to iterate name contexts */
+ int nRef = 0; /* Refcount for pOuterNC and outer contexts */
const char *zSavedContext = pParse->zAuthContext;
+
+ /* Count the total number of references to pOuterNC and all of its
+ ** parent contexts. After resolving references to expressions in
+ ** pItem->pSelect, check if this value has changed. If so, then
+ ** SELECT statement pItem->pSelect must be correlated. Set the
+ ** pItem->isCorrelated flag if this is the case. */
+ for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef += pNC->nRef;
+
if( pItem->zName ) pParse->zAuthContext = pItem->zName;
sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC);
pParse->zAuthContext = zSavedContext;
if( pParse->nErr || db->mallocFailed ) return WRC_Abort;
+
+ for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef -= pNC->nRef;
+ assert( pItem->isCorrelated==0 && nRef<=0 );
+ pItem->isCorrelated = (nRef!=0);
}
}
u8 isPopulated; /* Temporary table associated with SELECT is populated */
u8 jointype; /* Type of join between this able and the previous */
u8 notIndexed; /* True if there is a NOT INDEXED clause */
+ u8 isCorrelated; /* True if sub-query is correlated */
#ifndef SQLITE_OMIT_EXPLAIN
u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */
#endif
/* The NOT INDEXED clause appears in the SQL. */
return;
}
+ if( pSrc->isCorrelated ){
+ /* The source is a correlated sub-query. No point in indexing it. */
+ return;
+ }
assert( pParse->nQueryLoop >= (double)1 );
pTable = pSrc->pTab;
--- /dev/null
+# 2011 July 8
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing that bug [54844eea3f] has been fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+set ::testprefix tkt-54844eea3f
+
+do_test 1.0 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(1);
+ INSERT INTO t1 VALUES(4);
+
+ CREATE TABLE t2(b INTEGER PRIMARY KEY);
+ INSERT INTO t2 VALUES(1);
+ INSERT INTO t2 VALUES(2);
+ INSERT INTO t2 SELECT b+2 FROM t2;
+ INSERT INTO t2 SELECT b+4 FROM t2;
+ INSERT INTO t2 SELECT b+8 FROM t2;
+ INSERT INTO t2 SELECT b+16 FROM t2;
+
+ CREATE TABLE t3(c INTEGER PRIMARY KEY);
+ INSERT INTO t3 VALUES(1);
+ INSERT INTO t3 VALUES(2);
+ INSERT INTO t3 VALUES(3);
+ }
+} {}
+
+do_test 1.1 {
+ execsql {
+ SELECT 'test-2', t3.c, (
+ SELECT count(*)
+ FROM t1 JOIN (SELECT DISTINCT t3.c AS p FROM t2) AS x ON t1.a=x.p
+ )
+ FROM t3;
+ }
+} {test-2 1 1 test-2 2 0 test-2 3 0}
+
+do_test 1.2 {
+ execsql {
+ CREATE TABLE t4(a, b, c);
+ INSERT INTO t4 VALUES('a', 1, 'one');
+ INSERT INTO t4 VALUES('a', 2, 'two');
+ INSERT INTO t4 VALUES('b', 1, 'three');
+ INSERT INTO t4 VALUES('b', 2, 'four');
+ SELECT (
+ SELECT c FROM (
+ SELECT * FROM t4 WHERE a=out.a ORDER BY b LIMIT 10 OFFSET 1
+ ) WHERE b=out.b
+ ) FROM t4 AS out;
+ }
+} {{} two {} four}
+
+
+finish_test