mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Ensure that the same subquery does not go through the window-function rewrite
more than once, even when that subquery is part of a virtual table constraint that lacks the omit flag. FossilOrigin-Name: d0bc7db6b0a53edc04815622c46250d26f526f56e59f14875f4e18c75b49000d
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
||||
C Add\sheader\sguard\sto\sthe\sexpert\sextension.
|
||||
D 2019-11-13T18:50:36.270
|
||||
C Ensure\sthat\sthe\ssame\ssubquery\sdoes\snot\sgo\sthrough\sthe\swindow-function\srewrite\nmore\sthan\sonce,\seven\swhen\sthat\ssubquery\sis\spart\sof\sa\svirtual\stable\sconstraint\nthat\slacks\sthe\somit\sflag.
|
||||
D 2019-11-14T13:24:04.275
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@@ -531,7 +531,7 @@ F src/shell.c.in c06961f202f3cc50b819744b7331d3caea3d79d958402f4900b066824855746
|
||||
F src/sqlite.h.in 5ba20664cede7f4e6861541fad1f17bac50f7bf576b40a8784c54f9126a9edd4
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h cef696ce3293242c67b2339763608427bf72ee66f1f3a05389ac2a7b46001c31
|
||||
F src/sqliteInt.h 7015c75411f4df4cc5f694ce68feab6ec32a42189517aacc692f4757d54d2008
|
||||
F src/sqliteInt.h 3a1d168099ceff8565702ac302d99b377db52ce95d57ff59286d4959ff66399a
|
||||
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
|
||||
F src/status.c 46e7aec11f79dad50965a5ca5fa9de009f7d6bde08be2156f1538a0a296d4d0e
|
||||
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
|
||||
@@ -616,7 +616,7 @@ F src/where.c 874845fb5d93b3bc07123df8fee805e9650bd091e3ed62988273c7e2141ab8bd
|
||||
F src/whereInt.h 4a296fd4fa79fdcbc2b5e8c1b898901617655811223e1082b899c23ecb092217
|
||||
F src/wherecode.c 9b84737fd68134249a439813d27b1c61de17a01e121eb98949548d1e7f8e400a
|
||||
F src/whereexpr.c 0705f608f6dbbd4e95d440528d6c760b91b6f402ba4eb8b8d964c110e2010780
|
||||
F src/window.c 064f251451c8e2a1c76b6269229d911a651e119c6a5f522b6eaebf8dc8714041
|
||||
F src/window.c ea53cef29a5c32aa37ea22e87c247cf8e999fa3b70c6268d266af84608cb77f4
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627
|
||||
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
|
||||
@@ -1849,7 +1849,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P fa2416f623d83fe93253137302a74fcd6cdd041da337a0756df344d7d09a19f5
|
||||
R 71e615eaf7cbedece06ae5e725ee8ced
|
||||
U mistachkin
|
||||
Z 68d73206bf0b68f1bcc64ac4698faaf5
|
||||
P 7e3151855fd4370fb7d4fff20516c2c2d1980134620df924106e6989bc130583
|
||||
R c6e1b03c396590f81a466e94769e9c21
|
||||
U drh
|
||||
Z 558c0de79db81d5f1a59e8d57b1accf4
|
||||
|
@@ -1 +1 @@
|
||||
7e3151855fd4370fb7d4fff20516c2c2d1980134620df924106e6989bc130583
|
||||
d0bc7db6b0a53edc04815622c46250d26f526f56e59f14875f4e18c75b49000d
|
@@ -2935,26 +2935,27 @@ struct Select {
|
||||
** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX
|
||||
** SF_FixedLimit == WHERE_USE_LIMIT
|
||||
*/
|
||||
#define SF_Distinct 0x00001 /* Output should be DISTINCT */
|
||||
#define SF_All 0x00002 /* Includes the ALL keyword */
|
||||
#define SF_Resolved 0x00004 /* Identifiers have been resolved */
|
||||
#define SF_Aggregate 0x00008 /* Contains agg functions or a GROUP BY */
|
||||
#define SF_HasAgg 0x00010 /* Contains aggregate functions */
|
||||
#define SF_UsesEphemeral 0x00020 /* Uses the OpenEphemeral opcode */
|
||||
#define SF_Expanded 0x00040 /* sqlite3SelectExpand() called on this */
|
||||
#define SF_HasTypeInfo 0x00080 /* FROM subqueries have Table metadata */
|
||||
#define SF_Compound 0x00100 /* Part of a compound query */
|
||||
#define SF_Values 0x00200 /* Synthesized from VALUES clause */
|
||||
#define SF_MultiValue 0x00400 /* Single VALUES term with multiple rows */
|
||||
#define SF_NestedFrom 0x00800 /* Part of a parenthesized FROM clause */
|
||||
#define SF_MinMaxAgg 0x01000 /* Aggregate containing min() or max() */
|
||||
#define SF_Recursive 0x02000 /* The recursive part of a recursive CTE */
|
||||
#define SF_FixedLimit 0x04000 /* nSelectRow set by a constant LIMIT */
|
||||
#define SF_MaybeConvert 0x08000 /* Need convertCompoundSelectToSubquery() */
|
||||
#define SF_Converted 0x10000 /* By convertCompoundSelectToSubquery() */
|
||||
#define SF_IncludeHidden 0x20000 /* Include hidden columns in output */
|
||||
#define SF_ComplexResult 0x40000 /* Result contains subquery or function */
|
||||
#define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */
|
||||
#define SF_Distinct 0x0000001 /* Output should be DISTINCT */
|
||||
#define SF_All 0x0000002 /* Includes the ALL keyword */
|
||||
#define SF_Resolved 0x0000004 /* Identifiers have been resolved */
|
||||
#define SF_Aggregate 0x0000008 /* Contains agg functions or a GROUP BY */
|
||||
#define SF_HasAgg 0x0000010 /* Contains aggregate functions */
|
||||
#define SF_UsesEphemeral 0x0000020 /* Uses the OpenEphemeral opcode */
|
||||
#define SF_Expanded 0x0000040 /* sqlite3SelectExpand() called on this */
|
||||
#define SF_HasTypeInfo 0x0000080 /* FROM subqueries have Table metadata */
|
||||
#define SF_Compound 0x0000100 /* Part of a compound query */
|
||||
#define SF_Values 0x0000200 /* Synthesized from VALUES clause */
|
||||
#define SF_MultiValue 0x0000400 /* Single VALUES term with multiple rows */
|
||||
#define SF_NestedFrom 0x0000800 /* Part of a parenthesized FROM clause */
|
||||
#define SF_MinMaxAgg 0x0001000 /* Aggregate containing min() or max() */
|
||||
#define SF_Recursive 0x0002000 /* The recursive part of a recursive CTE */
|
||||
#define SF_FixedLimit 0x0004000 /* nSelectRow set by a constant LIMIT */
|
||||
#define SF_MaybeConvert 0x0008000 /* Need convertCompoundSelectToSubquery() */
|
||||
#define SF_Converted 0x0010000 /* By convertCompoundSelectToSubquery() */
|
||||
#define SF_IncludeHidden 0x0020000 /* Include hidden columns in output */
|
||||
#define SF_ComplexResult 0x0040000 /* Result contains subquery or function */
|
||||
#define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */
|
||||
#define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */
|
||||
|
||||
/*
|
||||
** The results of a SELECT can be distributed in several ways, as defined
|
||||
|
@@ -903,7 +903,7 @@ static ExprList *exprListAppendList(
|
||||
*/
|
||||
int sqlite3WindowRewrite(Parse *pParse, Select *p){
|
||||
int rc = SQLITE_OK;
|
||||
if( p->pWin && p->pPrior==0 ){
|
||||
if( p->pWin && p->pPrior==0 && (p->selFlags & SF_WinRewrite)==0 ){
|
||||
Vdbe *v = sqlite3GetVdbe(pParse);
|
||||
sqlite3 *db = pParse->db;
|
||||
Select *pSub = 0; /* The subquery */
|
||||
@@ -928,6 +928,7 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){
|
||||
p->pGroupBy = 0;
|
||||
p->pHaving = 0;
|
||||
p->selFlags &= ~SF_Aggregate;
|
||||
p->selFlags |= SF_WinRewrite;
|
||||
|
||||
/* Create the ORDER BY clause for the sub-select. This is the concatenation
|
||||
** of the window PARTITION and ORDER BY clauses. Then, if this makes it
|
||||
|
Reference in New Issue
Block a user