/ Check-in [4ee44322]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:All the sqlite3GetCollSeq() function to specify an arbitrary text encoding.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4ee44322ca3c92ed8d6f5d4a3f89d219bf379595
User & Date: drh 2009-08-20 02:34:15
Context
2009-08-20
02:49
Set the "type" correctly of built-in BINARY collating sequences for UTF16. check-in: 167644f3 user: drh tags: trunk
02:34
All the sqlite3GetCollSeq() function to specify an arbitrary text encoding. check-in: 4ee44322 user: drh tags: trunk
2009-08-19
22:14
Make sure that sqlite3ValueFromExpr() sets the "type" field of the sqlite3_value object correctly when the value is a floating point number. check-in: 2467eb68 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

  1253   1253     sqlite3 *db = pParse->db;
  1254   1254     u8 enc = ENC(db);
  1255   1255     u8 initbusy = db->init.busy;
  1256   1256     CollSeq *pColl;
  1257   1257   
  1258   1258     pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);
  1259   1259     if( !initbusy && (!pColl || !pColl->xCmp) ){
  1260         -    pColl = sqlite3GetCollSeq(db, pColl, zName);
         1260  +    pColl = sqlite3GetCollSeq(db, enc, pColl, zName);
  1261   1261       if( !pColl ){
  1262   1262         sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
  1263   1263       }
  1264   1264     }
  1265   1265   
  1266   1266     return pColl;
  1267   1267   }

Changes to src/callback.c.

    16     16   ** $Id: callback.c,v 1.42 2009/06/17 00:35:31 drh Exp $
    17     17   */
    18     18   
    19     19   #include "sqliteInt.h"
    20     20   
    21     21   /*
    22     22   ** Invoke the 'collation needed' callback to request a collation sequence
    23         -** in the database text encoding of name zName, length nName.
    24         -** If the collation sequence
           23  +** in the encoding enc of name zName, length nName.
    25     24   */
    26         -static void callCollNeeded(sqlite3 *db, const char *zName){
           25  +static void callCollNeeded(sqlite3 *db, int enc, const char *zName){
    27     26     assert( !db->xCollNeeded || !db->xCollNeeded16 );
    28     27     if( db->xCollNeeded ){
    29     28       char *zExternal = sqlite3DbStrDup(db, zName);
    30     29       if( !zExternal ) return;
    31         -    db->xCollNeeded(db->pCollNeededArg, db, (int)ENC(db), zExternal);
           30  +    db->xCollNeeded(db->pCollNeededArg, db, enc, zExternal);
    32     31       sqlite3DbFree(db, zExternal);
    33     32     }
    34     33   #ifndef SQLITE_OMIT_UTF16
    35     34     if( db->xCollNeeded16 ){
    36     35       char const *zExternal;
    37     36       sqlite3_value *pTmp = sqlite3ValueNew(db);
    38     37       sqlite3ValueSetStr(pTmp, -1, zName, SQLITE_UTF8, SQLITE_STATIC);
................................................................................
    67     66     }
    68     67     return SQLITE_ERROR;
    69     68   }
    70     69   
    71     70   /*
    72     71   ** This function is responsible for invoking the collation factory callback
    73     72   ** or substituting a collation sequence of a different encoding when the
    74         -** requested collation sequence is not available in the database native
    75         -** encoding.
           73  +** requested collation sequence is not available in the desired encoding.
    76     74   ** 
    77     75   ** If it is not NULL, then pColl must point to the database native encoding 
    78     76   ** collation sequence with name zName, length nName.
    79     77   **
    80     78   ** The return value is either the collation sequence to be used in database
    81     79   ** db for collation type name zName, length nName, or NULL, if no collation
    82     80   ** sequence can be found.
    83     81   **
    84     82   ** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()
    85     83   */
    86     84   CollSeq *sqlite3GetCollSeq(
    87     85     sqlite3* db,          /* The database connection */
           86  +  int enc,              /* The desired encoding for the collating sequence */
    88     87     CollSeq *pColl,       /* Collating sequence with native encoding, or NULL */
    89     88     const char *zName     /* Collating sequence name */
    90     89   ){
    91     90     CollSeq *p;
    92     91   
    93     92     p = pColl;
    94     93     if( !p ){
    95         -    p = sqlite3FindCollSeq(db, ENC(db), zName, 0);
           94  +    p = sqlite3FindCollSeq(db, enc, zName, 0);
    96     95     }
    97     96     if( !p || !p->xCmp ){
    98     97       /* No collation sequence of this type for this encoding is registered.
    99     98       ** Call the collation factory to see if it can supply us with one.
   100     99       */
   101         -    callCollNeeded(db, zName);
   102         -    p = sqlite3FindCollSeq(db, ENC(db), zName, 0);
          100  +    callCollNeeded(db, enc, zName);
          101  +    p = sqlite3FindCollSeq(db, enc, zName, 0);
   103    102     }
   104    103     if( p && !p->xCmp && synthCollSeq(db, p) ){
   105    104       p = 0;
   106    105     }
   107    106     assert( !p || p->xCmp );
   108    107     return p;
   109    108   }
................................................................................
   118    117   ** request a definition of the collating sequence. If this doesn't work, 
   119    118   ** an equivalent collating sequence that uses a text encoding different
   120    119   ** from the main database is substituted, if one is available.
   121    120   */
   122    121   int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){
   123    122     if( pColl ){
   124    123       const char *zName = pColl->zName;
   125         -    CollSeq *p = sqlite3GetCollSeq(pParse->db, pColl, zName);
          124  +    sqlite3 *db = pParse->db;
          125  +    CollSeq *p = sqlite3GetCollSeq(db, ENC(db), pColl, zName);
   126    126       if( !p ){
   127    127         sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
   128    128         pParse->nErr++;
   129    129         return SQLITE_ERROR;
   130    130       }
   131    131       assert( p==pColl );
   132    132     }

Changes to src/sqliteInt.h.

  2823   2823   void sqlite3SelectPrep(Parse*, Select*, NameContext*);
  2824   2824   int sqlite3ResolveExprNames(NameContext*, Expr*);
  2825   2825   void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
  2826   2826   int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
  2827   2827   void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
  2828   2828   void sqlite3AlterFinishAddColumn(Parse *, Token *);
  2829   2829   void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
  2830         -CollSeq *sqlite3GetCollSeq(sqlite3*, CollSeq *, const char*);
         2830  +CollSeq *sqlite3GetCollSeq(sqlite3*, int, CollSeq *, const char*);
  2831   2831   char sqlite3AffinityType(const char*);
  2832   2832   void sqlite3Analyze(Parse*, Token*, Token*);
  2833   2833   int sqlite3InvokeBusyHandler(BusyHandler*);
  2834   2834   int sqlite3FindDb(sqlite3*, Token*);
  2835   2835   int sqlite3FindDbName(sqlite3 *, const char *);
  2836   2836   int sqlite3AnalysisLoad(sqlite3*,int iDB);
  2837   2837   void sqlite3DeleteIndexSamples(Index*);

Changes to src/where.c.

  1928   1928         const u8 *z;
  1929   1929         int n;
  1930   1930         if( eType==SQLITE_BLOB ){
  1931   1931           z = (const u8 *)sqlite3_value_blob(pVal);
  1932   1932           pColl = db->pDfltColl;
  1933   1933           assert( pColl->enc==SQLITE_UTF8 );
  1934   1934         }else{
  1935         -        pColl = sqlite3FindCollSeq(db, SQLITE_UTF8, *pIdx->azColl, 0);
  1936         -        if( sqlite3CheckCollSeq(pParse, pColl) ){
         1935  +        pColl = sqlite3GetCollSeq(db, SQLITE_UTF8, 0, *pIdx->azColl);
         1936  +        if( pColl==0 ){
         1937  +          sqlite3ErrorMsg(pParse, "no such collation sequence: %s",
         1938  +                          *pIdx->azColl);
  1937   1939             return SQLITE_ERROR;
  1938   1940           }
  1939   1941           z = (const u8 *)sqlite3ValueText(pVal, pColl->enc);
  1940   1942           if( !z ){
  1941   1943             return SQLITE_NOMEM;
  1942   1944           }
  1943   1945           assert( z && pColl && pColl->xCmp );