mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Some progress on user-defined collation sequences. (CVS 1544)
FossilOrigin-Name: c634e71f1909819fb55c728bc410e5cc390428e3
This commit is contained in:
30
src/select.c
30
src/select.c
@@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle SELECT statements in SQLite.
|
||||
**
|
||||
** $Id: select.c,v 1.184 2004/06/07 10:00:31 danielk1977 Exp $
|
||||
** $Id: select.c,v 1.185 2004/06/09 09:55:18 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -546,7 +546,14 @@ static void generateSortTail(
|
||||
pInfo->aSortOrder = (char*)&pInfo->aColl[nCol];
|
||||
pInfo->nField = nCol;
|
||||
for(i=0; i<nCol; i++){
|
||||
pInfo->aColl[i] = db->pDfltColl;
|
||||
/* If a collation sequence was specified explicity, then it
|
||||
** is stored in pOrderBy->a[i].zName. Otherwise, use the default
|
||||
** collation type for the expression.
|
||||
*/
|
||||
pInfo->aColl[i] = sqlite3ExprCollSeq(pOrderBy->a[i].pExpr);
|
||||
if( !pInfo->aColl[i] ){
|
||||
pInfo->aColl[i] = db->pDfltColl;
|
||||
}
|
||||
pInfo->aSortOrder[i] = pOrderBy->a[i].sortOrder;
|
||||
}
|
||||
sqlite3VdbeOp3(v, OP_Sort, 0, 0, (char*)pInfo, P3_KEYINFO_HANDOFF);
|
||||
@@ -818,6 +825,10 @@ Table *sqlite3ResultSetOfSelect(Parse *pParse, char *zTabName, Select *pSelect){
|
||||
if( zType ){
|
||||
pTab->aCol[i].affinity = sqlite3AffinityType(zType, strlen(zType));
|
||||
}
|
||||
pTab->aCol[i].pColl = sqlite3ExprCollSeq(p);
|
||||
if( !pTab->aCol[i].pColl ){
|
||||
pTab->aCol[i].pColl = pParse->db->pDfltColl;
|
||||
}
|
||||
}
|
||||
pTab->iPKey = -1;
|
||||
return pTab;
|
||||
@@ -2222,6 +2233,21 @@ int sqlite3Select(
|
||||
}
|
||||
}
|
||||
|
||||
/* If there is an ORDER BY clause, resolve any collation sequences
|
||||
** names that have been explicitly specified.
|
||||
*/
|
||||
if( pOrderBy ){
|
||||
for(i=0; i<pOrderBy->nExpr; i++){
|
||||
if( pOrderBy->a[i].zName ){
|
||||
pOrderBy->a[i].pExpr->pColl =
|
||||
sqlite3LocateCollSeq(pParse, pOrderBy->a[i].zName, -1);
|
||||
}
|
||||
}
|
||||
if( pParse->nErr ){
|
||||
goto select_end;
|
||||
}
|
||||
}
|
||||
|
||||
/* Begin generating code.
|
||||
*/
|
||||
v = sqlite3GetVdbe(pParse);
|
||||
|
||||
Reference in New Issue
Block a user