Using "SELECT ALL" instead of just "SELECT" on a query that uses a single

unflattenable subquery or view in its FROM clause will force the subquery to
be manifested into a temporary table rather than run incrementally using a
co-routine.  This is a stop-gap means of controlling the decision to manifest
while we try to work out a better to make that decision automatically.

FossilOrigin-Name: a29e117d7ecec05da949348689dbfb0d3acb1280
This commit is contained in:
drh 2015-05-29 01:35:19 +00:00
parent c68275032e
commit 7cea7f95c7
5 changed files with 25 additions and 23 deletions

View File

@ -1,5 +1,5 @@
C Added\scomments\sand\stestcase()\smacros\sto\serror\scases\sin\sthe\sbtree\ssearch.
D 2015-05-28T15:14:32.636
C Using\s"SELECT\sALL"\sinstead\sof\sjust\s"SELECT"\son\sa\squery\sthat\suses\sa\ssingle\nunflattenable\ssubquery\sor\sview\sin\sits\sFROM\sclause\swill\sforce\sthe\ssubquery\sto\nbe\smanifested\sinto\sa\stemporary\stable\srather\sthan\srun\sincrementally\susing\sa\nco-routine.\s\sThis\sis\sa\sstop-gap\smeans\sof\scontrolling\sthe\sdecision\sto\smanifest\nwhile\swe\stry\sto\swork\sout\sa\sbetter\sto\smake\sthat\sdecision\sautomatically.
D 2015-05-29T01:35:19.289
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 994bab32a3a69e0c35bd148b65cde49879772964
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -239,7 +239,7 @@ F src/os_win.c 27cc135e2d0b8b1e2e4944db1e2669a6a18fa0f8
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
F src/pager.c 9bc918a009285f96ec6dac62dd764c7063552455
F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77
F src/parse.y 44e1605840c1662e08b05e175eb8bb13b9172662
F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8
F src/pcache.c 10539fb959849ad6efff80050541cab3d25089d4
F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8
F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9
@ -250,12 +250,12 @@ F src/printf.c 13ce37e5574f9b0682fa86dbcf9faf76b9d82a15
F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
F src/resolve.c 84c571794e3ee5806274d95158a4c0177c6c4708
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
F src/select.c 4dcc45372759f98754cd6171e48ec2b592fae9b7
F src/select.c 5978cc521cb8fc1aa6a0089e35edaf531accb52a
F src/shell.c 07dda7cd692911d2f22269953418d049f2e2c0ee
F src/sqlite.h.in 4d0ecd8e1e0272d9a2742b39602f5e4fad8d3246
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
F src/sqlite3ext.h 2ebeb634e751a61a6f0eebfa0f4669f46a42f6cd
F src/sqliteInt.h bf82393211a7e9cf20dd48c38f78e6d11eaf13d0
F src/sqliteInt.h bc8496de6a514ac66a5a938ee0e4f0d17d150c77
F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179
F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e
@ -1280,7 +1280,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 60a09f17d8b70dbc4b020586a1b81bce76882729
R f6f606a9ee18565706ed9fa4a93542b7
P 7da7dc714bf1fe34b38fc33a923490dfd3e4f070
R 499acad2035bec51403566408ee68110
U drh
Z daad2a296f17463ceed0e3de94772244
Z 2eaa693f71c1ef80818c82e114933ddd

View File

@ -1 +1 @@
7da7dc714bf1fe34b38fc33a923490dfd3e4f070
a29e117d7ecec05da949348689dbfb0d3acb1280

View File

@ -527,7 +527,7 @@ values(A) ::= values(X) COMMA LP exprlist(Y) RP. {
//
%type distinct {u16}
distinct(A) ::= DISTINCT. {A = SF_Distinct;}
distinct(A) ::= ALL. {A = 0;}
distinct(A) ::= ALL. {A = SF_All;}
distinct(A) ::= . {A = 0;}
// selcollist is a list of expressions that are to become the return
@ -890,7 +890,7 @@ expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP(E). {
}
A.pExpr = sqlite3ExprFunction(pParse, Y, &X);
spanSet(&A,&X,&E);
if( D && A.pExpr ){
if( D==SF_Distinct && A.pExpr ){
A.pExpr->flags |= EP_Distinct;
}
}

View File

@ -4817,6 +4817,7 @@ int sqlite3Select(
}
i = -1;
}else if( pTabList->nSrc==1
&& (p->selFlags & SF_All)==0
&& OptimizationEnabled(db, SQLITE_SubqCoroutine)
){
/* Implement a co-routine that will return a single row of the result

View File

@ -2396,19 +2396,20 @@ struct Select {
** "Select Flag".
*/
#define SF_Distinct 0x0001 /* Output should be DISTINCT */
#define SF_Resolved 0x0002 /* Identifiers have been resolved */
#define SF_Aggregate 0x0004 /* Contains aggregate functions */
#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */
#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */
#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
#define SF_Compound 0x0040 /* Part of a compound query */
#define SF_Values 0x0080 /* Synthesized from VALUES clause */
#define SF_MultiValue 0x0100 /* Single VALUES term with multiple rows */
#define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
#define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
#define SF_Recursive 0x0800 /* The recursive part of a recursive CTE */
#define SF_All 0x0002 /* Includes the ALL keyword */
#define SF_Resolved 0x0004 /* Identifiers have been resolved */
#define SF_Aggregate 0x0008 /* Contains aggregate functions */
#define SF_UsesEphemeral 0x0010 /* Uses the OpenEphemeral opcode */
#define SF_Expanded 0x0020 /* sqlite3SelectExpand() called on this */
#define SF_HasTypeInfo 0x0040 /* FROM subqueries have Table metadata */
#define SF_Compound 0x0080 /* Part of a compound query */
#define SF_Values 0x0100 /* Synthesized from VALUES clause */
#define SF_MultiValue 0x0200 /* Single VALUES term with multiple rows */
#define SF_NestedFrom 0x0400 /* Part of a parenthesized FROM clause */
#define SF_MaybeConvert 0x0800 /* Need convertCompoundSelectToSubquery() */
#define SF_MinMaxAgg 0x1000 /* Aggregate containing min() or max() */
#define SF_Converted 0x2000 /* By convertCompoundSelectToSubquery() */
#define SF_Recursive 0x2000 /* The recursive part of a recursive CTE */
#define SF_Converted 0x4000 /* By convertCompoundSelectToSubquery() */
/*