Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove the encoding argument from sqlite4_create_collation(). Pass sqlite4_value objects to the collation sequence callbacks instead. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7f314c9a714cb5265da0b021ca6645e9 |
User & Date: | dan 2013-06-13 20:20:43.311 |
Context
2013-06-14
| ||
17:16 | Update create_collation() documentation. Have the create_collation() function invoke the destructor (if one was specified) before returning if it fails. check-in: bcf7a78f8b user: dan tags: trunk | |
2013-06-13
| ||
20:20 | Remove the encoding argument from sqlite4_create_collation(). Pass sqlite4_value objects to the collation sequence callbacks instead. check-in: 7f314c9a71 user: dan tags: trunk | |
16:32 | Remove the no longer required FuncDestructor object. check-in: e5d82c92f0 user: dan tags: trunk | |
Changes
Changes to src/build.c.
︙ | ︙ | |||
1173 1174 1175 1176 1177 1178 1179 | ** invokes the collation factory if the named collation cannot be found ** and generates an error message. ** ** See also: sqlite4FindCollSeq(), sqlite4GetCollSeq() */ CollSeq *sqlite4LocateCollSeq(Parse *pParse, const char *zName){ sqlite4 *db = pParse->db; | < | | | 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 | ** invokes the collation factory if the named collation cannot be found ** and generates an error message. ** ** See also: sqlite4FindCollSeq(), sqlite4GetCollSeq() */ CollSeq *sqlite4LocateCollSeq(Parse *pParse, const char *zName){ sqlite4 *db = pParse->db; u8 initbusy = db->init.busy; CollSeq *pColl; pColl = sqlite4FindCollSeq(db, zName, initbusy); if( !initbusy && (!pColl || !pColl->xCmp) ){ pColl = sqlite4GetCollSeq(db, pColl, zName); if( !pColl ){ sqlite4ErrorMsg(pParse, "no such collation sequence: %s", zName); } } return pColl; } |
︙ | ︙ | |||
3679 3680 3681 3682 3683 3684 3685 | reindexDatabases(pParse, 0); return; }else if( NEVER(pName2==0) || pName2->z==0 ){ char *zColl; assert( pName1->z ); zColl = sqlite4NameFromToken(pParse->db, pName1); if( !zColl ) return; | | | 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 | reindexDatabases(pParse, 0); return; }else if( NEVER(pName2==0) || pName2->z==0 ){ char *zColl; assert( pName1->z ); zColl = sqlite4NameFromToken(pParse->db, pName1); if( !zColl ) return; pColl = sqlite4FindCollSeq(db, zColl, 0); if( pColl ){ reindexDatabases(pParse, zColl); sqlite4DbFree(db, zColl); return; } sqlite4DbFree(db, zColl); } |
︙ | ︙ |
Changes to src/callback.c.
︙ | ︙ | |||
16 17 18 19 20 21 22 | #include "sqliteInt.h" /* ** Invoke the 'collation needed' callback to request a collation sequence ** in the encoding enc of name zName, length nName. */ | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | < | | | < | | < < < < | | < < | | | < | | < | < < | > | | < < > | | | | | | | | | < < < < < | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | #include "sqliteInt.h" /* ** Invoke the 'collation needed' callback to request a collation sequence ** in the encoding enc of name zName, length nName. */ static void callCollNeeded(sqlite4 *db, const char *zName){ if( db->xCollNeeded ){ char *zExternal = sqlite4DbStrDup(db, zName); if( !zExternal ) return; db->xCollNeeded(db->pCollNeededArg, db, zExternal); sqlite4DbFree(db, zExternal); } } /* ** 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 desired encoding. ** ** If it is not NULL, then pColl must point to the database native encoding ** collation sequence with name zName, length nName. ** ** The return value is either the collation sequence to be used in database ** db for collation type name zName, length nName, or NULL, if no collation ** sequence can be found. ** ** See also: sqlite4LocateCollSeq(), sqlite4FindCollSeq() */ CollSeq *sqlite4GetCollSeq( sqlite4* db, /* The database connection */ CollSeq *pColl, /* Collating sequence object, or NULL */ const char *zName /* Collating sequence name */ ){ CollSeq *p; p = pColl; if( !p ){ p = sqlite4FindCollSeq(db, 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 = sqlite4FindCollSeq(db, zName, 0); } if( p && !p->xCmp ) p = 0; assert( !p || p->xCmp ); return p; } /* ** This routine is called on a collation sequence before it is used to ** check that it is defined. An undefined collation sequence exists when ** a database is loaded that contains references to collation sequences ** that have not been defined by sqlite4_create_collation() etc. ** ** If required, this routine calls the 'collation needed' callback to ** request a definition of the collating sequence. If this doesn't work, ** an equivalent collating sequence that uses a text encoding different ** from the main database is substituted, if one is available. */ int sqlite4CheckCollSeq(Parse *pParse, CollSeq *pColl){ if( pColl ){ const char *zName = pColl->zName; sqlite4 *db = pParse->db; CollSeq *p = sqlite4GetCollSeq(db, pColl, zName); if( !p ){ sqlite4ErrorMsg(pParse, "no such collation sequence: %s", zName); pParse->nErr++; return SQLITE4_ERROR; } assert( p==pColl ); } return SQLITE4_OK; } /* ** Locate and return an entry from the db.aCollSeq hash table. If the entry ** specified by zName and nName is not found and parameter 'create' is ** true, then create a new entry. Otherwise return NULL. ** ** Stored immediately after the CollSeq object in memory is a copy of ** the collation sequence name. A pointer to this string is stored in ** CollSeq.zName. */ static CollSeq *findCollSeqEntry( sqlite4 *db, /* Database connection */ const char *zName, /* Name of the collating sequence */ int create /* Create a new entry if true */ ){ CollSeq *pColl; int nName = sqlite4Strlen30(zName); pColl = sqlite4HashFind(&db->aCollSeq, zName, nName); if( 0==pColl && create ){ CollSeq *pDel; pColl = (CollSeq*)sqlite4DbMallocZero(db, sizeof(CollSeq)+nName+1); if( pColl ){ pColl->zName = (char *)&pColl[1]; memcpy(pColl->zName, zName, nName); } /* If a malloc() failure occurs in sqlite4HashInsert(), a copy of ** pColl is returned. Free it if this happens. */ pDel = sqlite4HashInsert(&db->aCollSeq, pColl[0].zName, nName, pColl); assert( pDel==0 || pDel==pColl ); if( pDel!=0 ){ db->mallocFailed = 1; sqlite4DbFree(db, pDel); pColl = 0; } } return pColl; } /* ** Parameter zName points to a UTF-8 encoded string nName bytes long. ** Return the CollSeq* pointer for the collation sequence named zName. ** ** If the entry specified is not found and 'create' is true, then create a ** new entry. Otherwise return NULL. ** ** A separate function sqlite4LocateCollSeq() is a wrapper around ** this routine. sqlite4LocateCollSeq() invokes the collation factory ** if necessary and generates an error message if the collating sequence ** cannot be found. ** ** See also: sqlite4LocateCollSeq(), sqlite4GetCollSeq() */ CollSeq *sqlite4FindCollSeq( sqlite4 *db, const char *zName, int create ){ CollSeq *pColl; if( zName ){ pColl = findCollSeqEntry(db, zName, create); }else{ pColl = db->pDfltColl; } return pColl; } /* During the search for the best function definition, this procedure ** is called to test how well the function passed as the first argument ** matches the request for a function with nArg arguments in a system ** that uses encoding enc. The value returned indicates how well the |
︙ | ︙ |
Changes to src/expr.c.
︙ | ︙ | |||
103 104 105 106 107 108 109 | /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally ** a TK_COLUMN but was previously evaluated and cached in a register */ const char *zColl; int j = p->iColumn; if( j>=0 ){ sqlite4 *db = pParse->db; zColl = p->pTab->aCol[j].zColl; | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally ** a TK_COLUMN but was previously evaluated and cached in a register */ const char *zColl; int j = p->iColumn; if( j>=0 ){ sqlite4 *db = pParse->db; zColl = p->pTab->aCol[j].zColl; pColl = sqlite4FindCollSeq(db, zColl, 0); pExpr->pColl = pColl; } break; } if( op!=TK_CAST && op!=TK_UPLUS ){ break; } |
︙ | ︙ | |||
1394 1395 1396 1397 1398 1399 1400 | ** comparison is the same as the affinity of the column. If ** it is not, it is not possible to use any index. */ aff = comparisonAffinity(pX); if( aff!=SQLITE4_AFF_NONE && aff!=pTab->aCol[iCol].affinity ) return 0; for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ if( (pIdx->aiColumn[0]==iCol) | | | 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 | ** comparison is the same as the affinity of the column. If ** it is not, it is not possible to use any index. */ aff = comparisonAffinity(pX); if( aff!=SQLITE4_AFF_NONE && aff!=pTab->aCol[iCol].affinity ) return 0; for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ if( (pIdx->aiColumn[0]==iCol) && sqlite4FindCollSeq(db, pIdx->azColl[0], 0)==pReq && (!bReqUnique || (pIdx->nColumn==1 && pIdx->onError!=OE_None)) ){ break; } } } |
︙ | ︙ |
Changes to src/main.c.
︙ | ︙ | |||
207 208 209 210 211 212 213 | } /* ** This is the default collating function named "BINARY" which is always ** available. ** ** If the padFlag argument is not NULL then space padding at the end | | | | > > > | > > | > | | < < < | | | > > > > | | > | | | > > | > > | < < | > > | | | > > > | | > > | | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | } /* ** This is the default collating function named "BINARY" which is always ** available. ** ** If the padFlag argument is not NULL then space padding at the end ** of strings is ignored. This implements the RTRIM collation. */ static int binCollFunc( void *padFlag, sqlite4_value *p1, sqlite4_value *p2, int *pRes ){ int n; int n1; int n2; int res; const char *z1 = sqlite4_value_text(p1, &n1); const char *z2 = sqlite4_value_text(p2, &n2); n = (n1<n2 ? n1 : n2); res = memcmp(z1, z2, n); if( res==0 ){ if( padFlag && allSpaces(z1+n, n1-n) && allSpaces(z2+n, n2-n) ){ /* Leave res unchanged at 0 */ }else{ res = n1 - n2; } } *pRes = res; return SQLITE4_OK; } /* ** The xMakeKey callback for the built-in RTRIM collation. The output ** is the same as the input, with any trailing ' ' characters removed. ** (e.g. " abc " -> " abc"). */ static int collRtrimMkKey( void *NotUsed, /* Not used */ sqlite4_value *pVal, /* Text value to make a key of */ int nOut, void *pOut, /* Output buffer */ int *pnOut ){ int nIn; const char *zIn = sqlite4_value_text(pVal, &nIn); int nCopy = nIn; while( nCopy>0 && zIn[nCopy-1]==' ' ) nCopy--; if( nCopy<=nOut ){ memcpy(pOut, zIn, nCopy); } *pnOut = nCopy; return SQLITE4_OK; } /* ** Another built-in collating sequence: NOCASE. ** ** This collating sequence is intended to be used for "case independant ** comparison". SQLite's knowledge of upper and lower case equivalents ** extends only to the 26 characters used in the English language. ** ** At the moment there is only a UTF-8 implementation. */ static int collNocaseCmp( void *NotUsed, sqlite4_value *p1, sqlite4_value *p2, int *pRes ){ int n1; int n2; int res; const char *z1 = sqlite4_value_text(p1, &n1); const char *z2 = sqlite4_value_text(p2, &n2); UNUSED_PARAMETER(NotUsed); res = sqlite4_strnicmp(z1, z2, (n1 < n2 ? n1 : n2)); if( res==0 ) res = n1 - n2; *pRes = res; return SQLITE4_OK; } static int collNocaseMkKey( void *NotUsed, sqlite4_value *pVal, int nOut, void *pOut, int *pnOut ){ int nIn; const char *zIn = sqlite4_value_text(pVal, &nIn); if( nOut>=nIn ){ int i; u8 *aIn = (u8 *)zIn; u8 *aOut = (u8 *)pOut; for(i=0; i<nIn; i++){ aOut[i] = sqlite4_tolower(aIn[i]); } } *pnOut = nIn; return SQLITE4_OK; } /* ** Return the number of changes in the most recent call to sqlite4_exec(). */ int sqlite4_changes(sqlite4 *db){ return db->nChange; |
︙ | ︙ | |||
408 409 410 411 412 413 414 | sqlite4DbFree(db, p); p = pSame; } } } for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){ CollSeq *pColl = (CollSeq *)sqliteHashData(i); | < < | < < < | 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | sqlite4DbFree(db, p); p = pSame; } } } for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){ CollSeq *pColl = (CollSeq *)sqliteHashData(i); if( pColl->xDel ) pColl->xDel(pColl->pUser); sqlite4DbFree(db, pColl); } sqlite4HashClear(&db->aCollSeq); #ifndef SQLITE4_OMIT_VIRTUALTABLE for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){ Module *pMod = (Module *)sqliteHashData(i); if( pMod->xDestroy ){ |
︙ | ︙ | |||
780 781 782 783 784 785 786 | if( !db || db->mallocFailed ){ return SQLITE4_NOMEM; } return db->errCode; } /* | | < < | | | < < < < < < < < < < < < < < < < | < < < < < < < < < < < < | | | > | > > | | < < < | < < | 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 | if( !db || db->mallocFailed ){ return SQLITE4_NOMEM; } return db->errCode; } /* ** Create a new collating function named zName for database db. */ static int createCollation( sqlite4* db, const char *zName, void *pCtx, int(*xCompare)(void*, sqlite4_value*, sqlite4_value*, int*), int(*xMakeKey)(void*, sqlite4_value*, int, void*, int*), void(*xDel)(void*) ){ CollSeq *pColl; assert( sqlite4_mutex_held(db->mutex) ); /* Check if this call is removing or replacing an existing collation ** sequence. If so, and there are active VMs, return busy. If there ** are no active VMs, invalidate any pre-compiled statements. */ pColl = sqlite4FindCollSeq(db, zName, 0); if( pColl && pColl->xCmp ){ if( db->activeVdbeCnt ){ sqlite4Error(db, SQLITE4_BUSY, "unable to delete/modify collation sequence due to active statements"); return SQLITE4_BUSY; } sqlite4ExpirePreparedStatements(db); if( pColl->xDel ){ pColl->xDel(pColl->pUser); } pColl->xDel = 0; pColl->xCmp = 0; pColl->xMkKey = 0; pColl->pUser = 0; } pColl = sqlite4FindCollSeq(db, zName, 1); if( pColl==0 ) return SQLITE4_NOMEM; pColl->xCmp = xCompare; pColl->xMkKey = xMakeKey; pColl->pUser = pCtx; pColl->xDel = xDel; return SQLITE4_OK; } /* ** This array defines hard upper bounds on limit values. The ** initializer must be kept in sync with the SQLITE4_LIMIT_* |
︙ | ︙ | |||
1220 1221 1222 1223 1224 1225 1226 | ; sqlite4HashInit(pEnv, &db->aCollSeq, 0); #ifndef SQLITE4_OMIT_VIRTUALTABLE sqlite4HashInit(pEnv, &db->aModule, 0); #endif | | < < < | | < | < < | < < < < < | 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 | ; sqlite4HashInit(pEnv, &db->aCollSeq, 0); #ifndef SQLITE4_OMIT_VIRTUALTABLE sqlite4HashInit(pEnv, &db->aModule, 0); #endif /* Add the built-in collation sequences BINARY, RTRIM and NOCASE. */ createCollation(db, "BINARY", 0, binCollFunc, 0, 0); createCollation(db, "RTRIM", (void*)1, binCollFunc, collRtrimMkKey, 0); createCollation(db, "NOCASE", 0, collNocaseCmp, collNocaseMkKey, 0); if( db->mallocFailed ){ goto opendb_out; } db->pDfltColl = sqlite4FindCollSeq(db, "BINARY", 0); assert( db->pDfltColl!=0 ); /* Parse the filename/URI argument. */ rc = sqlite4ParseUri(pEnv, zFilename, &flags, &zOpen, &zErrMsg); if( rc!=SQLITE4_OK ){ if( rc==SQLITE4_NOMEM ) db->mallocFailed = 1; sqlite4Error(db, rc, zErrMsg ? "%s" : 0, zErrMsg); sqlite4_free(pEnv, zErrMsg); goto opendb_out; |
︙ | ︙ | |||
1365 1366 1367 1368 1369 1370 1371 | /* ** Register a new collation sequence with the database handle db. */ int sqlite4_create_collation( sqlite4* db, const char *zName, | < | | | | < | 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 | /* ** Register a new collation sequence with the database handle db. */ int sqlite4_create_collation( sqlite4* db, const char *zName, void* pCtx, int(*xCompare)(void*, sqlite4_value*, sqlite4_value*, int*), int(*xMakeKey)(void*, sqlite4_value*, int, void*, int*), void(*xDel)(void*) ){ int rc; sqlite4_mutex_enter(db->mutex); assert( !db->mallocFailed ); rc = createCollation(db, zName, pCtx, xCompare, xMakeKey, xDel); rc = sqlite4ApiExit(db, rc); sqlite4_mutex_leave(db->mutex); return rc; } /* ** Register a collation sequence factory callback with the database handle ** db. Replace any previously installed collation sequence factory. */ int sqlite4_collation_needed( sqlite4 *db, void(*xCollNeeded)(void*,sqlite4*,const char*), void *pCollNeededArg ){ sqlite4_mutex_enter(db->mutex); db->xCollNeeded = xCollNeeded; db->pCollNeededArg = pCollNeededArg; sqlite4_mutex_leave(db->mutex); return SQLITE4_OK; } /* ** Test to see whether or not the database connection is currently within |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
2339 2340 2341 2342 2343 2344 2345 | ** These constant define integer codes that represent the various ** text encodings supported by SQLite. */ #define SQLITE4_UTF8 1 #define SQLITE4_UTF16LE 2 #define SQLITE4_UTF16BE 3 #define SQLITE4_UTF16 4 /* Use native byte order */ | < | 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 | ** These constant define integer codes that represent the various ** text encodings supported by SQLite. */ #define SQLITE4_UTF8 1 #define SQLITE4_UTF16LE 2 #define SQLITE4_UTF16BE 3 #define SQLITE4_UTF16 4 /* Use native byte order */ /* ** CAPIREF: Obtaining SQL Function Parameter Values ** ** The C-language implementation of SQL functions and aggregates uses ** this set of interface routines to access the parameter values on ** the function or aggregate. |
︙ | ︙ | |||
2739 2740 2741 2742 2743 2744 2745 | ** compatibility. ** ** See also: [sqlite4_collation_needed()] and [sqlite4_collation_needed16()]. */ int sqlite4_create_collation( sqlite4*, const char *zName, | < | | | 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 | ** compatibility. ** ** See also: [sqlite4_collation_needed()] and [sqlite4_collation_needed16()]. */ int sqlite4_create_collation( sqlite4*, const char *zName, void *pArg, int(*xCompare)(void*, sqlite4_value*, sqlite4_value*, int*), int(*xMakeKey)(void*, sqlite4_value*, int, void*, int*), void(*xDestroy)(void*) ); /* ** CAPIREF: Collation Needed Callbacks ** ** ^To avoid having to register all collation sequences before a database |
︙ | ︙ | |||
2767 2768 2769 2770 2771 2772 2773 | ** required collation sequence.)^ ** ** The callback function should register the desired collation using ** [sqlite4_create_collation()]. */ int sqlite4_collation_needed( sqlite4*, | | | 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 | ** required collation sequence.)^ ** ** The callback function should register the desired collation using ** [sqlite4_create_collation()]. */ int sqlite4_collation_needed( sqlite4*, void(*)(void*,sqlite4*,const char*), void* ); /* ** CAPIREF: Suspend Execution For A Short Time ** ** The sqlite4_sleep() function causes the current thread to suspend execution |
︙ | ︙ |
Changes to src/sqliteInt.h.
︙ | ︙ | |||
820 821 822 823 824 825 826 | void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ #ifndef SQLITE4_OMIT_WAL int (*xWalCallback)(void *, sqlite4 *, const char *, int); void *pWalArg; #endif | | < | 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 | void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ #ifndef SQLITE4_OMIT_WAL int (*xWalCallback)(void *, sqlite4 *, const char *, int); void *pWalArg; #endif void(*xCollNeeded)(void*,sqlite4*,const char*); void *pCollNeededArg; sqlite4_value *pErr; /* Most recent error message */ char *zErrMsg; /* Most recent error message (UTF-8 encoded) */ char *zErrMsg16; /* Most recent error message (UTF-16 encoded) */ union { volatile int isInterrupted; /* True if sqlite4_interrupt has been called */ double notUsed1; /* Spacer */ |
︙ | ︙ | |||
1051 1052 1053 1054 1055 1056 1057 | ** ** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the ** collating sequence is undefined. Indices built on an undefined ** collating sequence may not be read or written. */ struct CollSeq { char *zName; /* Name of the collating sequence, UTF-8 encoded */ | < | | | 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | ** ** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the ** collating sequence is undefined. Indices built on an undefined ** collating sequence may not be read or written. */ struct CollSeq { char *zName; /* Name of the collating sequence, UTF-8 encoded */ void *pUser; /* First argument to xCmp() */ int (*xCmp)(void*, sqlite4_value*, sqlite4_value*, int*); int (*xMkKey)(void*, sqlite4_value*, int, void*, int*); void (*xDel)(void*); /* Destructor for pUser */ }; /* ** A sort order can be either ASC or DESC. */ #define SQLITE4_SO_ASC 0 /* Sort in ascending order */ |
︙ | ︙ | |||
2925 2926 2927 2928 2929 2930 2931 | int sqlite4Atoi64(const char*, i64*, int, u8); void sqlite4Error(sqlite4*, int, const char*,...); void *sqlite4HexToBlob(sqlite4*, const char *z, int n); u8 sqlite4HexToInt(int h); int sqlite4TwoPartName(Parse *, Token *, Token *, Token **); const char *sqlite4ErrStr(int); int sqlite4ReadSchema(Parse *pParse); | | | 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 | int sqlite4Atoi64(const char*, i64*, int, u8); void sqlite4Error(sqlite4*, int, const char*,...); void *sqlite4HexToBlob(sqlite4*, const char *z, int n); u8 sqlite4HexToInt(int h); int sqlite4TwoPartName(Parse *, Token *, Token *, Token **); const char *sqlite4ErrStr(int); int sqlite4ReadSchema(Parse *pParse); CollSeq *sqlite4FindCollSeq(sqlite4*,const char*,int); CollSeq *sqlite4LocateCollSeq(Parse *pParse, const char*zName); CollSeq *sqlite4ExprCollSeq(Parse *pParse, Expr *pExpr); Expr *sqlite4ExprSetColl(Expr*, CollSeq*); Expr *sqlite4ExprSetCollByToken(Parse *pParse, Expr*, Token*); int sqlite4CheckCollSeq(Parse *, CollSeq *); int sqlite4CheckObjectName(Parse *, const char *); void sqlite4VdbeSetChanges(sqlite4 *, int); |
︙ | ︙ | |||
2979 2980 2981 2982 2983 2984 2985 | void sqlite4SelectPrep(Parse*, Select*, NameContext*); int sqlite4ResolveExprNames(NameContext*, Expr*); void sqlite4ResolveSelectNames(Parse*, Select*, NameContext*); int sqlite4ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); void sqlite4ColumnDefault(Vdbe *, Table *, int, int); void sqlite4AlterFinishAddColumn(Parse *, Token *); void sqlite4AlterBeginAddColumn(Parse *, SrcList *); | | | 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 | void sqlite4SelectPrep(Parse*, Select*, NameContext*); int sqlite4ResolveExprNames(NameContext*, Expr*); void sqlite4ResolveSelectNames(Parse*, Select*, NameContext*); int sqlite4ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); void sqlite4ColumnDefault(Vdbe *, Table *, int, int); void sqlite4AlterFinishAddColumn(Parse *, Token *); void sqlite4AlterBeginAddColumn(Parse *, SrcList *); CollSeq *sqlite4GetCollSeq(sqlite4*, CollSeq *, const char*); char sqlite4AffinityType(const char*); void sqlite4Analyze(Parse*, Token*, Token*); int sqlite4FindDb(sqlite4*, Token*); int sqlite4FindDbName(sqlite4 *, const char *); int sqlite4AnalysisLoad(sqlite4*,int iDB); void sqlite4DeleteIndexSamples(sqlite4*,Index*); void sqlite4DefaultRowEst(Index*); |
︙ | ︙ |
Changes to src/tclsqlite.c.
︙ | ︙ | |||
296 297 298 299 300 301 302 | Tcl_ResetResult(pDb->interp); } #endif static void tclCollateNeeded( void *pCtx, sqlite4 *db, | < < | < | > > > > > > > | | < | | > > > > > > | | > > | | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | Tcl_ResetResult(pDb->interp); } #endif static void tclCollateNeeded( void *pCtx, sqlite4 *db, const char *zName ){ SqliteDb *pDb = (SqliteDb *)pCtx; Tcl_Obj *pScript = Tcl_DuplicateObj(pDb->pCollateNeeded); Tcl_IncrRefCount(pScript); Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj(zName, -1)); Tcl_EvalObjEx(pDb->interp, pScript, 0); Tcl_DecrRefCount(pScript); } /* ** This routine is called to evaluate an SQL collation function implemented ** using TCL script. */ static int tclSqlCollate( void *pCtx, sqlite4_value *p1, sqlite4_value *p2, int *pRes ){ int n1; int n2; const char *z1; const char *z2; SqlCollate *p = (SqlCollate *)pCtx; Tcl_Obj *pCmd; int rc; z1 = sqlite4_value_text(p1, &n1); z2 = sqlite4_value_text(p2, &n2); pCmd = Tcl_NewStringObj(p->zCmp, -1); Tcl_IncrRefCount(pCmd); Tcl_ListObjAppendElement(p->interp, pCmd, Tcl_NewStringObj(z1, n1)); Tcl_ListObjAppendElement(p->interp, pCmd, Tcl_NewStringObj(z2, n2)); rc = Tcl_EvalObjEx(p->interp, pCmd, TCL_EVAL_DIRECT); Tcl_DecrRefCount(pCmd); *pRes = (atoi(Tcl_GetStringResult(p->interp))); return (rc==TCL_OK ? SQLITE4_OK : SQLITE4_ERROR); } static int tclSqlMkkey( void *pCtx, sqlite4_value *pVal, int nOut, void *pOut, int *pnOut ){ int nIn; int rc; const char *zIn; SqlCollate *p = (SqlCollate *)pCtx; Tcl_Obj *pCmd; int nRes; char *zRes; zIn = sqlite4_value_text(pVal, &nIn); pCmd = Tcl_NewStringObj(p->zMkkey, -1); Tcl_IncrRefCount(pCmd); Tcl_ListObjAppendElement(p->interp, pCmd, Tcl_NewStringObj(zIn, nIn)); rc = Tcl_EvalObjEx(p->interp, pCmd, TCL_EVAL_DIRECT); Tcl_DecrRefCount(pCmd); zRes = Tcl_GetStringFromObj(Tcl_GetObjResult(p->interp), &nRes); if( nRes<=nOut ){ memcpy(pOut, zRes, nRes); } *pnOut = nRes; return rc; } /* ** This routine is called to evaluate an SQL function implemented ** using TCL script. */ static void tclSqlFunc(sqlite4_context *context, int argc, sqlite4_value**argv){ |
︙ | ︙ | |||
1422 1423 1424 1425 1426 1427 1428 | pCollate->pNext = pDb->pCollate; pCollate->zCmp = (char*)&pCollate[1]; pCollate->zMkkey = &pCollate->zCmp[nCmp + 1]; pDb->pCollate = pCollate; memcpy(pCollate->zCmp, zCmp, nCmp+1); memcpy(pCollate->zMkkey, zMkkey, nMkkey+1); | | | > > | 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 | pCollate->pNext = pDb->pCollate; pCollate->zCmp = (char*)&pCollate[1]; pCollate->zMkkey = &pCollate->zCmp[nCmp + 1]; pDb->pCollate = pCollate; memcpy(pCollate->zCmp, zCmp, nCmp+1); memcpy(pCollate->zMkkey, zMkkey, nMkkey+1); rc = sqlite4_create_collation( pDb->db, zName, pCollate, tclSqlCollate, tclSqlMkkey, 0 ); if( rc!=SQLITE4_OK ){ Tcl_SetResult(interp, (char *)sqlite4_errmsg(pDb->db), TCL_VOLATILE); return TCL_ERROR; } break; } /* |
︙ | ︙ |
Changes to src/vdbeInt.h.
︙ | ︙ | |||
381 382 383 384 385 386 387 | u8 **pzOut, /* Write the resulting key here */ int *pnOut, /* Number of bytes in the key */ int nExtra /* Append extra bytes on end of key */ ); int sqlite4VdbeEncodeIntKey(u8 *aBuf,sqlite4_int64 v); int sqlite4VdbeDecodeIntKey(const KVByteArray*, KVSize, sqlite4_int64*); int sqlite4VdbeShortKey(const u8 *, int, int); | | | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | u8 **pzOut, /* Write the resulting key here */ int *pnOut, /* Number of bytes in the key */ int nExtra /* Append extra bytes on end of key */ ); int sqlite4VdbeEncodeIntKey(u8 *aBuf,sqlite4_int64 v); int sqlite4VdbeDecodeIntKey(const KVByteArray*, KVSize, sqlite4_int64*); int sqlite4VdbeShortKey(const u8 *, int, int); int sqlite4MemCompare(Mem*, Mem*, const CollSeq*,int*); int sqlite4VdbeExec(Vdbe*); int sqlite4VdbeList(Vdbe*); int sqlite4VdbeHalt(Vdbe*); int sqlite4VdbeChangeEncoding(Mem *, int); int sqlite4VdbeMemTooBig(Mem*); int sqlite4VdbeMemCopy(Mem*, const Mem*); void sqlite4VdbeMemShallowCopy(Mem*, const Mem*, int); |
︙ | ︙ |
Changes to src/vdbecodec.c.
︙ | ︙ | |||
458 459 460 461 462 463 464 | if( enlargeEncoderAllocation(p, 1) ) return SQLITE4_NOMEM; p->aOut[p->nOut++] = 0x05; /* NULL */ }else if( flags & (MEM_Real|MEM_Int) ){ if( enlargeEncoderAllocation(p, 16) ) return SQLITE4_NOMEM; encodeNumericKey(p, pMem->u.num); }else if( flags & MEM_Str ){ | < < | < < < < < | > | < < | < < < < < | < > > | | > > > > > | | > | | | | | > | | 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | if( enlargeEncoderAllocation(p, 1) ) return SQLITE4_NOMEM; p->aOut[p->nOut++] = 0x05; /* NULL */ }else if( flags & (MEM_Real|MEM_Int) ){ if( enlargeEncoderAllocation(p, 16) ) return SQLITE4_NOMEM; encodeNumericKey(p, pMem->u.num); }else if( flags & MEM_Str ){ int enc; /* Initial encoding of pMem */ assert( pMem->enc==SQLITE4_UTF8 || pMem->enc==SQLITE4_UTF16LE || pMem->enc==SQLITE4_UTF16BE ); assert( pMem->db ); enc = pMem->enc; /* Write the encoded key to the output buffer. */ if( enlargeEncoderAllocation(p, pMem->n*4 + 2) ) return SQLITE4_NOMEM; p->aOut[p->nOut++] = 0x24; /* Text */ if( pColl==0 || pColl->xMkKey==0 ){ const char *z = (const char *)sqlite4ValueText(pMem, SQLITE4_UTF8); if( z ){ memcpy(p->aOut+p->nOut, z, pMem->n); p->nOut += pMem->n; } }else{ int rc; /* xMkKey() return code */ int nReq; /* Space required by xMkKey() */ int nSpc; /* Space available */ nSpc = p->nAlloc-p->nOut; rc = pColl->xMkKey(pColl->pUser, pMem, nSpc, p->aOut+p->nOut, &nReq); if( rc!=SQLITE4_OK ) return rc; if( nReq+1>nSpc ){ if( enlargeEncoderAllocation(p, nReq+1) ) return SQLITE4_NOMEM; rc = pColl->xMkKey(pColl->pUser, pMem, nReq, p->aOut+p->nOut, &nReq); } p->nOut += nReq; } p->aOut[p->nOut++] = 0x00; /* If the operations above changed the encoding of pMem, change it back. ** This call is a no-op if pMem was not modified by the code above. */ sqlite4VdbeChangeEncoding(pMem, enc); }else if( isLastValue ){ /* A BLOB value that is the right-most value of a key */ assert( flags & MEM_Blob ); if( enlargeEncoderAllocation(p, pMem->n+1) ) return SQLITE4_NOMEM; p->aOut[p->nOut++] = 0x26; memcpy(p->aOut+p->nOut, pMem->z, pMem->n); |
︙ | ︙ |
Changes to src/vdbemem.c.
︙ | ︙ | |||
636 637 638 639 640 641 642 | ** than pMem2. Sorting order is NULL's first, followed by numbers (integers ** and reals) sorted numerically, followed by text ordered by the collating ** sequence pColl and finally blob's ordered by memcmp(). ** ** Two NULL values are considered equal by this function. */ int sqlite4MemCompare( | | | | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | ** than pMem2. Sorting order is NULL's first, followed by numbers (integers ** and reals) sorted numerically, followed by text ordered by the collating ** sequence pColl and finally blob's ordered by memcmp(). ** ** Two NULL values are considered equal by this function. */ int sqlite4MemCompare( Mem *pMem1, Mem *pMem2, const CollSeq *pColl, int *pRes /* OUT: Result of comparison operation */ ){ int rc = SQLITE4_OK; int f1, f2; int combined_flags; |
︙ | ︙ | |||
697 698 699 700 701 702 703 704 | /* The collation sequence must be defined at this point, even if ** the user deletes the collation sequence after the vdbe program is ** compiled (this was not always the case). */ assert( !pColl || pColl->xCmp ); if( pColl ){ void *pUser = pColl->pUser; | > < < < < < < < < < < < < < < < < < | | | | | | < < < < < | < < < < < < < | | | 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | /* The collation sequence must be defined at this point, even if ** the user deletes the collation sequence after the vdbe program is ** compiled (this was not always the case). */ assert( !pColl || pColl->xCmp ); if( pColl ){ int enc = pMem1->enc; void *pUser = pColl->pUser; rc = pColl->xCmp(pUser, pMem1, pMem2, pRes); sqlite4VdbeChangeEncoding(pMem1, enc); sqlite4VdbeChangeEncoding(pMem2, enc); return rc; } /* If a NULL pointer was passed as the collate function, fall through ** to the blob case and use memcmp(). */ } /* Both values must be blobs. Compare using memcmp(). */ *pRes = memcmp(pMem1->z, pMem2->z, (pMem1->n>pMem2->n)?pMem2->n:pMem1->n); if( *pRes==0 ){ *pRes = pMem1->n - pMem2->n; } return rc; } /* This function is only available internally, it is not part of the ** external API. It works in a similar way to sqlite4_value_text(), ** except the data returned is in the encoding specified by the second ** parameter, which must be one of SQLITE4_UTF16BE, SQLITE4_UTF16LE or ** SQLITE4_UTF8. */ const void *sqlite4ValueText(sqlite4_value* pVal, u8 enc){ if( !pVal ) return 0; assert( pVal->db==0 || sqlite4_mutex_held(pVal->db->mutex) ); assert( (pVal->flags & MEM_RowSet)==0 ); if( pVal->flags&MEM_Null ){ return 0; } assert( (MEM_Blob>>3) == MEM_Str ); pVal->flags |= (pVal->flags & MEM_Blob)>>3; if( pVal->flags&MEM_Str ){ sqlite4VdbeChangeEncoding(pVal, enc); sqlite4VdbeMemNulTerminate(pVal); /* IMP: R-31275-44060 */ }else{ assert( (pVal->flags&MEM_Blob)==0 ); sqlite4VdbeMemStringify(pVal, enc); assert( 0==(1&SQLITE4_PTR_TO_INT(pVal->z)) ); } assert(pVal->enc==enc || pVal->db==0 || pVal->db->mallocFailed ); if( pVal->enc==enc ){ return pVal->z; }else{ return 0; } } /* |
︙ | ︙ |
Changes to src/where.c.
︙ | ︙ | |||
626 627 628 629 630 631 632 | zColl = pTab->aCol[iColumn].zColl; }else{ zColl = pIdx->azColl[j]; } /* If the collation sequence used by the index is not the same as ** that used by the expression, then this term is not a match. */ | | | 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | zColl = pTab->aCol[iColumn].zColl; }else{ zColl = pIdx->azColl[j]; } /* If the collation sequence used by the index is not the same as ** that used by the expression, then this term is not a match. */ if( pColl!=sqlite4FindCollSeq(db, zColl, 0) ) continue; } return pTerm; } } } return 0; } |
︙ | ︙ | |||
1301 1302 1303 1304 1305 1306 1307 | if( c=='A'-1 ) isComplete = 0; /* EV: R-64339-08207 */ c = sqlite4UpperToLower[c]; } *pC = c + 1; } | | | 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 | if( c=='A'-1 ) isComplete = 0; /* EV: R-64339-08207 */ c = sqlite4UpperToLower[c]; } *pC = c + 1; } pColl = sqlite4FindCollSeq(db, noCase ? "NOCASE" : "BINARY",0); pNewExpr1 = sqlite4PExpr(pParse, TK_GE, sqlite4ExprSetColl(sqlite4ExprDup(db,pLeft,0), pColl), pStr1, 0); idxNew1 = whereClauseInsert(pWC, pNewExpr1, TERM_VIRTUAL|TERM_DYNAMIC); testcase( idxNew1==0 ); exprAnalyze(pSrc, pWC, idxNew1); pNewExpr2 = sqlite4PExpr(pParse, TK_LT, |
︙ | ︙ | |||
1707 1708 1709 1710 1711 1712 1713 | if( iIdxCol<pIdx->nColumn ){ zColl = pIdx->azColl[iIdxCol]; }else if( iColumn>=0 ) { zColl = pTab->aCol[iColumn].zColl; }else{ zColl = 0; } | | | 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 | if( iIdxCol<pIdx->nColumn ){ zColl = pIdx->azColl[iIdxCol]; }else if( iColumn>=0 ) { zColl = pTab->aCol[iColumn].zColl; }else{ zColl = 0; } if( pColl!=sqlite4FindCollSeq(db, zColl, 0) ) break; if( iIdxCol==iNext ){ u8 reqSortOrder; u8 idxSortOrder = SQLITE4_SO_ASC; if( iIdxCol<pIdx->nColumn ) idxSortOrder = pIdx->aSortOrder[iIdxCol]; assert( idxSortOrder==SQLITE4_SO_ASC || idxSortOrder==SQLITE4_SO_DESC ); |
︙ | ︙ |
Changes to test/test_main.c.
︙ | ︙ | |||
1359 1360 1361 1362 1363 1364 1365 | Tcl_DecrRefCount(p->pCmp); Tcl_DecrRefCount(p->pDel); sqlite4_free(0, (void *)p); } static int testCreateCollationCmp( void *pCtx, | | < | < > > > > > > > > > | | | 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 | Tcl_DecrRefCount(p->pCmp); Tcl_DecrRefCount(p->pDel); sqlite4_free(0, (void *)p); } static int testCreateCollationCmp( void *pCtx, sqlite4_value *pLeft, sqlite4_value *pRight, int *pRes ){ int nLeft; int nRight; const char *zLeft; const char *zRight; TestCollationX *p = (TestCollationX *)pCtx; Tcl_Obj *pScript = Tcl_DuplicateObj(p->pCmp); int iRes = 0; int rc; zLeft = sqlite4_value_text(pLeft, &nLeft); zRight = sqlite4_value_text(pRight, &nRight); if( !zLeft || !zRight ) return SQLITE4_NOMEM; Tcl_IncrRefCount(pScript); Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj(zLeft, nLeft)); Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj(zRight,nRight)); rc = Tcl_EvalObjEx(p->interp, pScript, TCL_EVAL_DIRECT|TCL_EVAL_GLOBAL); if( rc==TCL_OK ){ rc = Tcl_GetIntFromObj(p->interp, Tcl_GetObjResult(p->interp), &iRes); } Tcl_DecrRefCount(pScript); |
︙ | ︙ | |||
1409 1410 1411 1412 1413 1414 1415 | p = (TestCollationX *)sqlite4_malloc(0, sizeof(TestCollationX)); p->pCmp = objv[3]; p->pDel = objv[4]; p->interp = interp; Tcl_IncrRefCount(p->pCmp); Tcl_IncrRefCount(p->pDel); | | | < < < < < | 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 | p = (TestCollationX *)sqlite4_malloc(0, sizeof(TestCollationX)); p->pCmp = objv[3]; p->pDel = objv[4]; p->interp = interp; Tcl_IncrRefCount(p->pCmp); Tcl_IncrRefCount(p->pDel); rc = sqlite4_create_collation(db, Tcl_GetString(objv[2]), (void *)p, testCreateCollationCmp, 0, testCreateCollationDel ); if( rc!=SQLITE4_OK ){ return TCL_ERROR; } return TCL_OK; } /* ** USAGE: sqlite4_create_function_v2 DB NAME NARG ENC ?SWITCHES? ** ** Available switches are: |
︙ | ︙ | |||
1791 1792 1793 1794 1795 1796 1797 | static int uses_stmt_journal( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite4_stmt *pStmt; | < | | 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 | static int uses_stmt_journal( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite4_stmt *pStmt; if( objc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; sqlite4_stmt_readonly(pStmt); Tcl_SetObjResult(interp, Tcl_NewBooleanObj(((Vdbe *)pStmt)->needSavepoint)); return TCL_OK; } /* ** Usage: sqlite4_reset STMT |
︙ | ︙ | |||
1924 1925 1926 1927 1928 1929 1930 | sprintf(zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, sqlite4ErrStr(rc), 0); return TCL_ERROR; } return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 | sprintf(zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, sqlite4ErrStr(rc), 0); return TCL_ERROR; } return TCL_OK; } /* ** Usage: add_test_function <db ptr> <utf8> <utf16le> <utf16be> ** ** This function is used to test that SQLite selects the correct user ** function callback when multiple versions (for different text encodings) ** are available. ** |
︙ | ︙ | |||
3439 3440 3441 3442 3443 3444 3445 | Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); return TCL_OK; } /* ** Usage: sqlite_delete_collation DB collation-name ** | | < < | | 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 | Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); return TCL_OK; } /* ** Usage: sqlite_delete_collation DB collation-name ** ** Delete the collation sequence 'collation-name' from database handle DB. */ static int delete_collation( void * clientData, Tcl_Interp *interp, int argc, char **argv ){ int rc; sqlite4 *db; if( argc!=3 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB function-name", 0); return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; rc = sqlite4_create_collation(db, argv[2], 0, 0, 0, 0); Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); return TCL_OK; } /* ** Usage: sqlite4_db_transaction_status DB ** |
︙ | ︙ | |||
4142 4143 4144 4145 4146 4147 4148 | #endif #ifdef SQLITE4_ENABLE_COLUMN_METADATA { "sqlite4_column_database_name",test_stmt_utf8,(void*)sqlite4_column_database_name}, { "sqlite4_column_table_name",test_stmt_utf8,(void*)sqlite4_column_table_name}, { "sqlite4_column_origin_name",test_stmt_utf8,(void*)sqlite4_column_origin_name}, #endif | < < < < < | 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 | #endif #ifdef SQLITE4_ENABLE_COLUMN_METADATA { "sqlite4_column_database_name",test_stmt_utf8,(void*)sqlite4_column_database_name}, { "sqlite4_column_table_name",test_stmt_utf8,(void*)sqlite4_column_table_name}, { "sqlite4_column_origin_name",test_stmt_utf8,(void*)sqlite4_column_origin_name}, #endif { "sqlite4_create_collation", test_create_collation, 0 }, { "working_64bit_int", working_64bit_int, 0 }, { "sqlite4_create_function_v2", test_create_function_v2, 0 }, /* Functions from os.h */ #ifndef SQLITE4_OMIT_UTF16 { "add_test_function", test_function, 0 }, #endif { "sqlite4_test_errstr", test_errstr, 0 }, { "tcl_variable_type", tcl_variable_type, 0 }, { "sqlite4_libversion_number", test_libversion_number, 0 }, { "test_sqlite4_log", test_sqlite4_log, 0 }, #ifndef SQLITE4_OMIT_EXPLAIN |
︙ | ︙ | |||
4215 4216 4217 4218 4219 4220 4221 | (char*)&sqlite4_current_time, TCL_LINK_INT); #if SQLITE4_OS_UNIX && defined(__APPLE__) && SQLITE4_ENABLE_LOCKING_STYLE Tcl_LinkVar(interp, "sqlite_hostid_num", (char*)&sqlite4_hostid_num, TCL_LINK_INT); #endif Tcl_LinkVar(interp, "sqlite4_xferopt_count", (char*)&sqlite4_xferopt_count, TCL_LINK_INT); | < < < < < < < < | 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 | (char*)&sqlite4_current_time, TCL_LINK_INT); #if SQLITE4_OS_UNIX && defined(__APPLE__) && SQLITE4_ENABLE_LOCKING_STYLE Tcl_LinkVar(interp, "sqlite_hostid_num", (char*)&sqlite4_hostid_num, TCL_LINK_INT); #endif Tcl_LinkVar(interp, "sqlite4_xferopt_count", (char*)&sqlite4_xferopt_count, TCL_LINK_INT); #if SQLITE4_OS_WIN Tcl_LinkVar(interp, "sqlite_os_type", (char*)&sqlite4_os_type, TCL_LINK_INT); #endif #ifdef SQLITE4_TEST Tcl_LinkVar(interp, "sqlite_query_plan", (char*)&query_plan, TCL_LINK_STRING|TCL_LINK_READ_ONLY); |
︙ | ︙ |
Changes to test/test_misc1.c.
︙ | ︙ | |||
40 41 42 43 44 45 46 | /* Open a database. */ rc = sqlite4_open(0, ":memory:", &db, 0); if( rc!=SQLITE4_OK ){ zErrFunction = "sqlite4_open"; goto error_out; } | < < < < < < < | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* Open a database. */ rc = sqlite4_open(0, ":memory:", &db, 0); if( rc!=SQLITE4_OK ){ zErrFunction = "sqlite4_open"; goto error_out; } sqlite4_close(db, 0); return TCL_OK; error_out: Tcl_ResetResult(interp); Tcl_AppendResult(interp, "Error testing function: ", zErrFunction, 0); return TCL_ERROR; |
︙ | ︙ |