diff options
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/resolve.c b/src/resolve.c index 6294ba26e..32e0a98fd 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -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 ){ |