diff options
author | dan <dan@noemail.net> | 2015-04-23 19:32:19 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2015-04-23 19:32:19 +0000 |
commit | e11afed5620d285f0d4d9dcb67e36cae8b152ac2 (patch) | |
tree | 633f5e366c1dca38bd2cb71f9e42b069665c6548 /src/resolve.c | |
parent | 55d46f01c52848d403f4ea48f391fbb389bb2013 (diff) | |
parent | 41148f83c47b0d196f9d11aaad89d3528ecb4830 (diff) | |
download | sqlite-e11afed5620d285f0d4d9dcb67e36cae8b152ac2.tar.gz sqlite-e11afed5620d285f0d4d9dcb67e36cae8b152ac2.zip |
Merge latest trunk changes into this branch.
FossilOrigin-Name: 1506e99eca19f72fb59b55ec9e2534505dfa7a6e
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/resolve.c b/src/resolve.c index 6294ba26e..b75db42ef 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -79,7 +79,7 @@ static void incrAggFunctionDepth(Expr *pExpr, int N){ ** SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase; ** ** The nSubquery parameter specifies how many levels of subquery the -** alias is removed from the original expression. The usually value is +** alias is removed from the original expression. The usual value is ** zero but it might be more if the alias is contained within a subquery ** of the original expression. The Expr.op2 field of TK_AGG_FUNCTION ** structures must be increased by the nSubquery amount. @@ -99,7 +99,7 @@ static void resolveAlias( assert( iCol>=0 && iCol<pEList->nExpr ); pOrig = pEList->a[iCol].pExpr; assert( pOrig!=0 ); - assert( pOrig->flags & EP_Resolved ); + assert( (pOrig->flags & EP_Resolved)!=0 || zType[0]==0 ); db = pParse->db; pDup = sqlite3ExprDup(db, pOrig, 0); if( pDup==0 ) return; @@ -460,7 +460,6 @@ static int lookupName( if( cnt==0 && zTab==0 && ExprHasProperty(pExpr,EP_DblQuoted) ){ pExpr->op = TK_STRING; pExpr->pTab = 0; - pExpr->iTable = -1; return WRC_Prune; } @@ -1300,8 +1299,15 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ ** The ORDER BY clause for compounds SELECT statements is handled ** below, after all of the result-sets for all of the elements of ** the compound have been resolved. + ** + ** If there is an ORDER BY clause on a term of a compound-select other + ** than the right-most term, then that is a syntax error. But the error + ** is not detected until much later, and so we need to go ahead and + ** resolve those symbols on the incorrect ORDER BY for consistency. */ - if( !isCompound && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER") ){ + if( isCompound<=nCompound /* Defer right-most ORDER BY of a compound */ + && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER") + ){ return WRC_Abort; } if( db->mallocFailed ){ |