aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2009-08-20 02:34:15 +0000
committerdrh <drh@noemail.net>2009-08-20 02:34:15 +0000
commit9aeda79cf6ebb912d6979e0f9190fec2c9b6c998 (patch)
tree2547751240c143538f74a05f4cce8f03ec5d76e9 /src
parent3995c26d1608460ddd472d0121c415c57303d168 (diff)
downloadsqlite-9aeda79cf6ebb912d6979e0f9190fec2c9b6c998.tar.gz
sqlite-9aeda79cf6ebb912d6979e0f9190fec2c9b6c998.zip
All the sqlite3GetCollSeq() function to specify an arbitrary text encoding.
FossilOrigin-Name: 4ee44322ca3c92ed8d6f5d4a3f89d219bf379595
Diffstat (limited to 'src')
-rw-r--r--src/build.c2
-rw-r--r--src/callback.c20
-rw-r--r--src/sqliteInt.h2
-rw-r--r--src/where.c6
4 files changed, 16 insertions, 14 deletions
diff --git a/src/build.c b/src/build.c
index e47aaed08..730caf97e 100644
--- a/src/build.c
+++ b/src/build.c
@@ -1257,7 +1257,7 @@ CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){
pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);
if( !initbusy && (!pColl || !pColl->xCmp) ){
- pColl = sqlite3GetCollSeq(db, pColl, zName);
+ pColl = sqlite3GetCollSeq(db, enc, pColl, zName);
if( !pColl ){
sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
}
diff --git a/src/callback.c b/src/callback.c
index fd4749826..0d4f9dd15 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -20,15 +20,14 @@
/*
** Invoke the 'collation needed' callback to request a collation sequence
-** in the database text encoding of name zName, length nName.
-** If the collation sequence
+** in the encoding enc of name zName, length nName.
*/
-static void callCollNeeded(sqlite3 *db, const char *zName){
+static void callCollNeeded(sqlite3 *db, int enc, const char *zName){
assert( !db->xCollNeeded || !db->xCollNeeded16 );
if( db->xCollNeeded ){
char *zExternal = sqlite3DbStrDup(db, zName);
if( !zExternal ) return;
- db->xCollNeeded(db->pCollNeededArg, db, (int)ENC(db), zExternal);
+ db->xCollNeeded(db->pCollNeededArg, db, enc, zExternal);
sqlite3DbFree(db, zExternal);
}
#ifndef SQLITE_OMIT_UTF16
@@ -71,8 +70,7 @@ static int synthCollSeq(sqlite3 *db, CollSeq *pColl){
/*
** This function is responsible for invoking the collation factory callback
** or substituting a collation sequence of a different encoding when the
-** requested collation sequence is not available in the database native
-** encoding.
+** requested collation sequence is not available in the desired encoding.
**
** If it is not NULL, then pColl must point to the database native encoding
** collation sequence with name zName, length nName.
@@ -85,6 +83,7 @@ static int synthCollSeq(sqlite3 *db, CollSeq *pColl){
*/
CollSeq *sqlite3GetCollSeq(
sqlite3* db, /* The database connection */
+ int enc, /* The desired encoding for the collating sequence */
CollSeq *pColl, /* Collating sequence with native encoding, or NULL */
const char *zName /* Collating sequence name */
){
@@ -92,14 +91,14 @@ CollSeq *sqlite3GetCollSeq(
p = pColl;
if( !p ){
- p = sqlite3FindCollSeq(db, ENC(db), zName, 0);
+ p = sqlite3FindCollSeq(db, enc, zName, 0);
}
if( !p || !p->xCmp ){
/* No collation sequence of this type for this encoding is registered.
** Call the collation factory to see if it can supply us with one.
*/
- callCollNeeded(db, zName);
- p = sqlite3FindCollSeq(db, ENC(db), zName, 0);
+ callCollNeeded(db, enc, zName);
+ p = sqlite3FindCollSeq(db, enc, zName, 0);
}
if( p && !p->xCmp && synthCollSeq(db, p) ){
p = 0;
@@ -122,7 +121,8 @@ CollSeq *sqlite3GetCollSeq(
int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){
if( pColl ){
const char *zName = pColl->zName;
- CollSeq *p = sqlite3GetCollSeq(pParse->db, pColl, zName);
+ sqlite3 *db = pParse->db;
+ CollSeq *p = sqlite3GetCollSeq(db, ENC(db), pColl, zName);
if( !p ){
sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
pParse->nErr++;
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 0185861db..bcc4a6430 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -2827,7 +2827,7 @@ int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
void sqlite3AlterFinishAddColumn(Parse *, Token *);
void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
-CollSeq *sqlite3GetCollSeq(sqlite3*, CollSeq *, const char*);
+CollSeq *sqlite3GetCollSeq(sqlite3*, int, CollSeq *, const char*);
char sqlite3AffinityType(const char*);
void sqlite3Analyze(Parse*, Token*, Token*);
int sqlite3InvokeBusyHandler(BusyHandler*);
diff --git a/src/where.c b/src/where.c
index 3cdab3f70..fb3032ef7 100644
--- a/src/where.c
+++ b/src/where.c
@@ -1932,8 +1932,10 @@ static int whereRangeRegion(
pColl = db->pDfltColl;
assert( pColl->enc==SQLITE_UTF8 );
}else{
- pColl = sqlite3FindCollSeq(db, SQLITE_UTF8, *pIdx->azColl, 0);
- if( sqlite3CheckCollSeq(pParse, pColl) ){
+ pColl = sqlite3GetCollSeq(db, SQLITE_UTF8, 0, *pIdx->azColl);
+ if( pColl==0 ){
+ sqlite3ErrorMsg(pParse, "no such collation sequence: %s",
+ *pIdx->azColl);
return SQLITE_ERROR;
}
z = (const u8 *)sqlite3ValueText(pVal, pColl->enc);