1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-21 09:00:59 +03:00

Always resolve symbols in all ORDER BY clauses of a compound-SELECT, even

illegal ORDER BY clauses.

FossilOrigin-Name: 6c39ef73d5899eabdb46db50c2b00c2d8381a41a
This commit is contained in:
drh
2015-04-17 18:52:37 +00:00
parent 97ab32bcd3
commit 7b4da150da
4 changed files with 23 additions and 10 deletions

View File

@@ -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 ){