aboutsummaryrefslogtreecommitdiff
path: root/src/resolve.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-04-17 18:52:37 +0000
committerdrh <drh@noemail.net>2015-04-17 18:52:37 +0000
commit7b4da150da7615c380e1ce3bd142ff66e817d962 (patch)
treed67397be0f21c411cb46d37f354d2af43a6e6449 /src/resolve.c
parent97ab32bcd3cb14cedca0dcea055ef3b6d3caea47 (diff)
downloadsqlite-7b4da150da7615c380e1ce3bd142ff66e817d962.tar.gz
sqlite-7b4da150da7615c380e1ce3bd142ff66e817d962.zip
Always resolve symbols in all ORDER BY clauses of a compound-SELECT, even
illegal ORDER BY clauses. FossilOrigin-Name: 6c39ef73d5899eabdb46db50c2b00c2d8381a41a
Diffstat (limited to 'src/resolve.c')
-rw-r--r--src/resolve.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/resolve.c b/src/resolve.c
index 6294ba26e..f7e68ff4f 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -1300,8 +1300,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 ){