diff options
author | danielk1977 <danielk1977@noemail.net> | 2004-06-09 09:55:16 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2004-06-09 09:55:16 +0000 |
commit | 0202b29ef74de24bcef98427f4551ac4edc0e12e (patch) | |
tree | 1be294b093e50ab1f41eab0b09eb54a6e44c718b /src/select.c | |
parent | 80242055e53a0e72277cb1180316c3c9fecd6cc1 (diff) | |
download | sqlite-0202b29ef74de24bcef98427f4551ac4edc0e12e.tar.gz sqlite-0202b29ef74de24bcef98427f4551ac4edc0e12e.zip |
Some progress on user-defined collation sequences. (CVS 1544)
FossilOrigin-Name: c634e71f1909819fb55c728bc410e5cc390428e3
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/select.c b/src/select.c index 083f19782..d868a85bb 100644 --- a/src/select.c +++ b/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); |