Resolve names in FROM-clause subqueries prior to resolving names in the

result set expressions of a SELECT statement.

FossilOrigin-Name: 9b67c633d932f3e566f521ee6a9cf3be193436fa
This commit is contained in:
drh
2012-12-18 16:07:08 +00:00
parent e924041846
commit 92689d2869
4 changed files with 31 additions and 31 deletions
+17 -17
View File
@@ -1033,23 +1033,6 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
return WRC_Abort;
}
/* Set up the local name-context to pass to sqlite3ResolveExprNames() to
** resolve the result-set expression list.
*/
sNC.ncFlags = NC_AllowAgg;
sNC.pSrcList = p->pSrc;
sNC.pNext = pOuterNC;
/* Resolve names in the result set. */
pEList = p->pEList;
assert( pEList!=0 );
for(i=0; i<pEList->nExpr; i++){
Expr *pX = pEList->a[i].pExpr;
if( sqlite3ResolveExprNames(&sNC, pX) ){
return WRC_Abort;
}
}
/* Recursively resolve names in all subqueries
*/
for(i=0; i<p->pSrc->nSrc; i++){
@@ -1077,6 +1060,23 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
}
}
/* Set up the local name-context to pass to sqlite3ResolveExprNames() to
** resolve the result-set expression list.
*/
sNC.ncFlags = NC_AllowAgg;
sNC.pSrcList = p->pSrc;
sNC.pNext = pOuterNC;
/* Resolve names in the result set. */
pEList = p->pEList;
assert( pEList!=0 );
for(i=0; i<pEList->nExpr; i++){
Expr *pX = pEList->a[i].pExpr;
if( sqlite3ResolveExprNames(&sNC, pX) ){
return WRC_Abort;
}
}
/* If there are no aggregate functions in the result-set, and no GROUP BY
** expression, do not allow aggregates in any of the other expressions.
*/