diff options
author | drh <drh@noemail.net> | 2007-02-01 23:02:45 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2007-02-01 23:02:45 +0000 |
commit | 8b4c40d8ac254b7e0e7da0e72959dc71a12b648d (patch) | |
tree | 9ad3bd1d2356c7cfe7102dbf4fc9d800e997f7da /src/expr.c | |
parent | 3e701a187ece479c06a2d1c854b990d18c963cf5 (diff) | |
download | sqlite-8b4c40d8ac254b7e0e7da0e72959dc71a12b648d.tar.gz sqlite-8b4c40d8ac254b7e0e7da0e72959dc71a12b648d.zip |
First cut at adding the COLLATE operator. Regression tests pass (or at least
the quick set does) and a few new tests have been added. But many more
tests are needed. Rules for combining collations need to be worked out. (CVS 3624)
FossilOrigin-Name: 85cca7cd252d46ba71d302a89bc67c56146ec552
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/expr.c b/src/expr.c index a20e1541c..7b34352c9 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.272 2007/02/01 01:40:44 drh Exp $ +** $Id: expr.c,v 1.273 2007/02/01 23:02:45 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -50,6 +50,21 @@ char sqlite3ExprAffinity(Expr *pExpr){ } /* +** Set the collating sequence for expression pExpr to be the collating +** sequence named by pToken. Return a pointer to the revised expression. +*/ +Expr *sqlite3ExprSetColl(Parse *pParse, Expr *pExpr, Token *pName){ + CollSeq *pColl; + if( pExpr==0 ) return 0; + pColl = sqlite3LocateCollSeq(pParse, (char*)pName->z, pName->n); + if( pColl ){ + pExpr->pColl = pColl; + pExpr->flags |= EP_ExpCollate; + } + return pExpr; +} + +/* ** Return the default collation sequence for the expression pExpr. If ** there is no default collation type, return 0. */ @@ -890,7 +905,9 @@ static int lookupName( /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ pExpr->iColumn = j==pTab->iPKey ? -1 : j; pExpr->affinity = pTab->aCol[j].affinity; - pExpr->pColl = sqlite3FindCollSeq(db, ENC(db), zColl,-1, 0); + if( (pExpr->flags & EP_ExpCollate)==0 ){ + pExpr->pColl = sqlite3FindCollSeq(db, ENC(db), zColl,-1, 0); + } if( i<pSrcList->nSrc-1 ){ if( pItem[1].jointype & JT_NATURAL ){ /* If this match occurred in the left table of a natural join, @@ -946,7 +963,9 @@ static int lookupName( cnt++; pExpr->iColumn = iCol==pTab->iPKey ? -1 : iCol; pExpr->affinity = pTab->aCol[iCol].affinity; - pExpr->pColl = sqlite3FindCollSeq(db, ENC(db), zColl,-1, 0); + if( (pExpr->flags & EP_ExpCollate)==0 ){ + pExpr->pColl = sqlite3FindCollSeq(db, ENC(db), zColl,-1, 0); + } pExpr->pTab = pTab; break; } |