mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-18 10:21:03 +03:00
For expressions like (x, y) IN (SELECT ...) where the SELECT uses window-functions, require that all columns on the LHS be indexed before an index can be used. Fix for [d9ed4ebe].
FossilOrigin-Name: 0b1dbd60f5db3abe2097dbc0b6de9671685ca5eaf7d3fc8e3f87ff5065a9d114
This commit is contained in:
@@ -416,23 +416,6 @@ static Expr *removeUnindexableInClauseTerms(
|
||||
){
|
||||
sqlite3 *db = pParse->db;
|
||||
Expr *pNew;
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
/* The SELECT statement at pX->x.pSelect has already been resolved. This
|
||||
** means that its window functions have already been identified and
|
||||
** linked into the Select.pWin list. However, if there are multiple
|
||||
** window functions and they do not all use the same window frame, only
|
||||
** those that use the same window frame as the first resolved are listed
|
||||
** in Select.pWin. Any others are delegated to sub-selects created by the
|
||||
** call to sqlite3WindowRewrite() made when coding the SELECT statement.
|
||||
** But - sqlite3WindowRewrite() is a no-op if Select.pWin==0. And if
|
||||
** removing the unindexable terms happens to remove all window functions
|
||||
** in the Select.pWin list, then Select.pWin ends up set to NULL - meaning
|
||||
** that the other window functions are never processed. To work around
|
||||
** this, ensure that sqlite3WindowRewrite() has been called to create the
|
||||
** required sub-selects before the unindexable terms are removed. See
|
||||
** ticket #f00d096ca. */
|
||||
if( sqlite3WindowRewrite(pParse, pX->x.pSelect) ) return 0;
|
||||
#endif
|
||||
pNew = sqlite3ExprDup(db, pX, 0);
|
||||
if( db->mallocFailed==0 ){
|
||||
ExprList *pOrigRhs = pNew->x.pSelect->pEList; /* Original unmodified RHS */
|
||||
|
||||
Reference in New Issue
Block a user