diff options
author | drh <drh@noemail.net> | 2013-08-15 22:40:21 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-08-15 22:40:21 +0000 |
commit | 0af16ab2c2d5eec0eb01f512af96ef01909a095c (patch) | |
tree | 087313c0625e5751b5662e867ee1c103ab9f15fb /src/resolve.c | |
parent | e35463b312a5ec35ae5546d155a75380e0d03e64 (diff) | |
download | sqlite-0af16ab2c2d5eec0eb01f512af96ef01909a095c.tar.gz sqlite-0af16ab2c2d5eec0eb01f512af96ef01909a095c.zip |
Make sure that GROUP BY terms select input column names in preference to
output column names, in compliance with the SQL standard.
Ticket [1c69be2dafc28].
FossilOrigin-Name: f2d175f975cd0be63425424ec322a98fb650019e
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/resolve.c b/src/resolve.c index b41a7adda..43a3870e2 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1043,14 +1043,16 @@ static int resolveOrderGroupBy( for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){ Expr *pE = pItem->pExpr; Expr *pE2 = sqlite3ExprSkipCollate(pE); - iCol = resolveAsName(pParse, pSelect->pEList, pE2); - if( iCol>0 ){ - /* If an AS-name match is found, mark this ORDER BY column as being - ** a copy of the iCol-th result-set column. The subsequent call to - ** sqlite3ResolveOrderGroupBy() will convert the expression to a - ** copy of the iCol-th result-set expression. */ - pItem->iOrderByCol = (u16)iCol; - continue; + if( zType[0]!='G' ){ + iCol = resolveAsName(pParse, pSelect->pEList, pE2); + if( iCol>0 ){ + /* If an AS-name match is found, mark this ORDER BY column as being + ** a copy of the iCol-th result-set column. The subsequent call to + ** sqlite3ResolveOrderGroupBy() will convert the expression to a + ** copy of the iCol-th result-set expression. */ + pItem->iOrderByCol = (u16)iCol; + continue; + } } if( sqlite3ExprIsInteger(pE2, &iCol) ){ /* The ORDER BY term is an integer constant. Again, set the column |