mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Add the experimental create_collation_x() api. (CVS 3934)
FossilOrigin-Name: ff49d48f2f025898a0f4ace1fc227e1d367ea89f
This commit is contained in:
@@ -45,6 +45,12 @@ static void xFree(void *p){
|
|||||||
sqlite3_free(p);
|
sqlite3_free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** LIKE operator.
|
||||||
|
**
|
||||||
|
** http://unicode.org/reports/tr21/tr21-5.html#Caseless_Matching
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Function to delete compiled regexp objects. Registered as
|
** Function to delete compiled regexp objects. Registered as
|
||||||
** a destructor function with sqlite3_set_auxdata().
|
** a destructor function with sqlite3_set_auxdata().
|
||||||
@@ -151,6 +157,8 @@ static void icuRegexpFunc(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
|||||||
**
|
**
|
||||||
** lower('I', 'en_us') -> 'i'
|
** lower('I', 'en_us') -> 'i'
|
||||||
** lower('I', 'tr_tr') -> 'ı' (small dotless i)
|
** lower('I', 'tr_tr') -> 'ı' (small dotless i)
|
||||||
|
**
|
||||||
|
** http://www.icu-project.org/userguide/posix.html#case_mappings
|
||||||
*/
|
*/
|
||||||
static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
||||||
const UChar *zInput;
|
const UChar *zInput;
|
||||||
@@ -193,13 +201,11 @@ static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
|||||||
** Register the ICU extension functions with database db.
|
** Register the ICU extension functions with database db.
|
||||||
*/
|
*/
|
||||||
int sqlite3IcuInit(sqlite3 *db){
|
int sqlite3IcuInit(sqlite3 *db){
|
||||||
int rc;
|
|
||||||
int ii;
|
|
||||||
struct IcuScalar {
|
struct IcuScalar {
|
||||||
const char *zName;
|
const char *zName; /* Function name */
|
||||||
int nArg;
|
int nArg; /* Number of arguments */
|
||||||
int enc;
|
int enc; /* Optimal text encoding */
|
||||||
void *pContext;
|
void *pContext; /* sqlite3_user_data() context */
|
||||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
|
void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
|
||||||
} scalars[] = {
|
} scalars[] = {
|
||||||
{"regexp", 2, SQLITE_ANY, 0, icuRegexpFunc},
|
{"regexp", 2, SQLITE_ANY, 0, icuRegexpFunc},
|
||||||
@@ -209,20 +215,23 @@ int sqlite3IcuInit(sqlite3 *db){
|
|||||||
{"upper", 1, SQLITE_UTF16, (void*)1, icuCaseFunc16},
|
{"upper", 1, SQLITE_UTF16, (void*)1, icuCaseFunc16},
|
||||||
{"upper", 2, SQLITE_UTF16, (void*)1, icuCaseFunc16},
|
{"upper", 2, SQLITE_UTF16, (void*)1, icuCaseFunc16},
|
||||||
|
|
||||||
{"lower", 1, SQLITE_UTF8, 0, icuCaseFunc16},
|
{"lower", 1, SQLITE_UTF8, 0, icuCaseFunc16},
|
||||||
{"lower", 2, SQLITE_UTF8, 0, icuCaseFunc16},
|
{"lower", 2, SQLITE_UTF8, 0, icuCaseFunc16},
|
||||||
{"upper", 1, SQLITE_UTF8, (void*)1, icuCaseFunc16},
|
{"upper", 1, SQLITE_UTF8, (void*)1, icuCaseFunc16},
|
||||||
{"upper", 2, SQLITE_UTF8, (void*)1, icuCaseFunc16},
|
{"upper", 2, SQLITE_UTF8, (void*)1, icuCaseFunc16},
|
||||||
};
|
};
|
||||||
|
|
||||||
for(ii=0; ii<(sizeof(scalars)/sizeof(struct IcuScalar)); ii++){
|
int rc = SQLITE_OK;
|
||||||
struct IcuScalar *p = &scalars[ii];
|
int i;
|
||||||
|
|
||||||
|
for(i=0; rc==SQLITE_OK && i<(sizeof(scalars)/sizeof(struct IcuScalar)); i++){
|
||||||
|
struct IcuScalar *p = &scalars[i];
|
||||||
rc = sqlite3_create_function(
|
rc = sqlite3_create_function(
|
||||||
db, p->zName, p->nArg, p->enc, p->pContext, p->xFunc, 0, 0
|
db, p->zName, p->nArg, p->enc, p->pContext, p->xFunc, 0, 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SQLITE_OK;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !SQLITE_CORE
|
#if !SQLITE_CORE
|
||||||
|
26
manifest
26
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\smissing\sword\sin\sthe\scopyright.html\sweb\spage.\s(CVS\s3933)
|
C Add\sthe\sexperimental\screate_collation_x()\sapi.\s(CVS\s3934)
|
||||||
D 2007-05-06T21:20:43
|
D 2007-05-07T09:32:45
|
||||||
F Makefile.in ea8888bdcf53313d26576fcabcb6d0a10ecd35cd
|
F Makefile.in ea8888bdcf53313d26576fcabcb6d0a10ecd35cd
|
||||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -43,7 +43,7 @@ F ext/fts2/fts2_porter.c 991a45463553c7318063fe7773368a6c0f39e35d
|
|||||||
F ext/fts2/fts2_tokenizer.h 4c5ffe31d63622869eb6eec1503df7f6996fd1bd
|
F ext/fts2/fts2_tokenizer.h 4c5ffe31d63622869eb6eec1503df7f6996fd1bd
|
||||||
F ext/fts2/fts2_tokenizer1.c 5c979fe8815f95396beb22b627571da895a025af
|
F ext/fts2/fts2_tokenizer1.c 5c979fe8815f95396beb22b627571da895a025af
|
||||||
F ext/fts2/mkfts2amal.tcl 2a9ec76b0760fe7f3669dca5bc0d60728bc1c977
|
F ext/fts2/mkfts2amal.tcl 2a9ec76b0760fe7f3669dca5bc0d60728bc1c977
|
||||||
F ext/icu/icu.c 17ad2387c27133b5fcf7037687d5ff346f4a1da7
|
F ext/icu/icu.c a30999ba467749ed6232d02cc8c4b5a0e62cd727
|
||||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
|
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
|
||||||
F ltmain.sh 56abb507100ed2d4261f6dd1653dec3cf4066387
|
F ltmain.sh 56abb507100ed2d4261f6dd1653dec3cf4066387
|
||||||
F main.mk 6298bd3fcbc590fe05354f7d962c57ac202d7bcd
|
F main.mk 6298bd3fcbc590fe05354f7d962c57ac202d7bcd
|
||||||
@@ -65,7 +65,7 @@ F src/btree.c 6d3db6416c71f678a4dd4719ce6d754ad5927c46
|
|||||||
F src/btree.h 845543b5a53d5d8a80ea14aeeb521276602317b7
|
F src/btree.h 845543b5a53d5d8a80ea14aeeb521276602317b7
|
||||||
F src/btreeInt.h cb3c0e9eb842d06079a62cdf3492c90c5db7ba75
|
F src/btreeInt.h cb3c0e9eb842d06079a62cdf3492c90c5db7ba75
|
||||||
F src/build.c 0dd6f0d0a5d304be91374f4c7228a3e9b00ff7f1
|
F src/build.c 0dd6f0d0a5d304be91374f4c7228a3e9b00ff7f1
|
||||||
F src/callback.c 6414ed32d55859d0f65067aa5b88d2da27b3af9e
|
F src/callback.c 9c12535669a638f90a67e10440b99c7b93c0fbf4
|
||||||
F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
|
F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
|
||||||
F src/date.c c34a9c86ffd6da4cb3903ea038d977ec539d07e2
|
F src/date.c c34a9c86ffd6da4cb3903ea038d977ec539d07e2
|
||||||
F src/delete.c 5c0d89b3ef7d48fe1f5124bfe8341f982747fe29
|
F src/delete.c 5c0d89b3ef7d48fe1f5124bfe8341f982747fe29
|
||||||
@@ -77,7 +77,7 @@ F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
|
|||||||
F src/insert.c e595ca26805dfb3a9ebaabc28e7947c479f3b14d
|
F src/insert.c e595ca26805dfb3a9ebaabc28e7947c479f3b14d
|
||||||
F src/legacy.c 388c71ad7fbcd898ba1bcbfc98a3ac954bfa5d01
|
F src/legacy.c 388c71ad7fbcd898ba1bcbfc98a3ac954bfa5d01
|
||||||
F src/loadext.c afe4f4755dc49c36ef505748bbdddecb9f1d02a2
|
F src/loadext.c afe4f4755dc49c36ef505748bbdddecb9f1d02a2
|
||||||
F src/main.c 2e11ec21dd11008a339b1d6d61aeb9b51992b2cf
|
F src/main.c ada896b9554aa71e717a6ab237ab0eff63a1e1e4
|
||||||
F src/malloc.c b89e31258a85158d15795bf87ae3ba007e56329b
|
F src/malloc.c b89e31258a85158d15795bf87ae3ba007e56329b
|
||||||
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
|
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
|
||||||
F src/os.c 4650e98aadd27abfe1698ff58edf6893c58d4881
|
F src/os.c 4650e98aadd27abfe1698ff58edf6893c58d4881
|
||||||
@@ -101,12 +101,12 @@ F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
|
|||||||
F src/select.c a306d03fc7d8365055bef70c3563e8fca897460f
|
F src/select.c a306d03fc7d8365055bef70c3563e8fca897460f
|
||||||
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
|
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
|
||||||
F src/shell.c d07ae326b3815d80f71c69b3c7584382e47f6447
|
F src/shell.c d07ae326b3815d80f71c69b3c7584382e47f6447
|
||||||
F src/sqlite.h.in a666300976897eced975b448f722a722b362c6b1
|
F src/sqlite.h.in e9b82a9e6e24e279d4e9d239535fbdae464b5594
|
||||||
F src/sqlite3ext.h 7d0d363ea7327e817ef0dfe1b7eee1f171b72890
|
F src/sqlite3ext.h 7d0d363ea7327e817ef0dfe1b7eee1f171b72890
|
||||||
F src/sqliteInt.h 3ffe2f9c801575e315451e7d2831c4a90a165aa8
|
F src/sqliteInt.h 5e1cf645ef1bf8b43c5d020adbeed43746df24ed
|
||||||
F src/table.c a8de75bcedf84d4060d804264b067ab3b1a3561d
|
F src/table.c a8de75bcedf84d4060d804264b067ab3b1a3561d
|
||||||
F src/tclsqlite.c f3414b2d6bc37e6760b49c9abd3504ff69f4441b
|
F src/tclsqlite.c f3414b2d6bc37e6760b49c9abd3504ff69f4441b
|
||||||
F src/test1.c 17e8402b4b567317b4e49923658d1f5874eaee5f
|
F src/test1.c a91c84e903e3a59ad3bf6c10bd5b93e74d631ea2
|
||||||
F src/test2.c 24458b17ab2f3c90cbc1c8446bd7ffe69be62f88
|
F src/test2.c 24458b17ab2f3c90cbc1c8446bd7ffe69be62f88
|
||||||
F src/test3.c 946ea9d1a8c928656e3c70f0a2fcb8e733a15e86
|
F src/test3.c 946ea9d1a8c928656e3c70f0a2fcb8e733a15e86
|
||||||
F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
|
F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
|
||||||
@@ -247,7 +247,7 @@ F test/fts2n.test a70357e72742681eaebfdbe9007b87ff3b771638
|
|||||||
F test/func.test 6727c7729472ae52b5acd86e802f89aa350ba50f
|
F test/func.test 6727c7729472ae52b5acd86e802f89aa350ba50f
|
||||||
F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a
|
F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a
|
||||||
F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d
|
F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d
|
||||||
F test/incrblob.test 9fd59c5f8460d036188b22688f6c20d5b39e78e6
|
F test/incrblob.test 7f82ae497364612aa17a37f77f12e01e2bee9f20
|
||||||
F test/incrblob_err.test 9dae0762ba4d73b516d176d091c6b2b16f625953
|
F test/incrblob_err.test 9dae0762ba4d73b516d176d091c6b2b16f625953
|
||||||
F test/incrvacuum.test f490c8ae86f2ecca622425d02e27d3119058cb21
|
F test/incrvacuum.test f490c8ae86f2ecca622425d02e27d3119058cb21
|
||||||
F test/incrvacuum2.test a1457ad2441e49e99fbc4d74f9575dd9f7ddbde3
|
F test/incrvacuum2.test a1457ad2441e49e99fbc4d74f9575dd9f7ddbde3
|
||||||
@@ -481,7 +481,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||||
P 9600a998043c6dd1d5ecb03d1ee9a9273910243d
|
P 2d1348dda2cbdf958a15267432063f359550c303
|
||||||
R d5b5efe0e3f18ed8a6801bd7106e316f
|
R cb3c4e9539473867932a2c5f74528890
|
||||||
U drh
|
U danielk1977
|
||||||
Z a53400e87a52148d7645178e850caa33
|
Z eaa2b3011ed3cbd2140fcff678e040f6
|
||||||
|
@@ -1 +1 @@
|
|||||||
2d1348dda2cbdf958a15267432063f359550c303
|
ff49d48f2f025898a0f4ace1fc227e1d367ea89f
|
@@ -13,7 +13,7 @@
|
|||||||
** This file contains functions used to access the internal hash tables
|
** This file contains functions used to access the internal hash tables
|
||||||
** of user defined functions and collation sequences.
|
** of user defined functions and collation sequences.
|
||||||
**
|
**
|
||||||
** $Id: callback.c,v 1.17 2007/04/16 15:06:25 danielk1977 Exp $
|
** $Id: callback.c,v 1.18 2007/05/07 09:32:45 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -63,6 +63,7 @@ static int synthCollSeq(sqlite3 *db, CollSeq *pColl){
|
|||||||
pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, n, 0);
|
pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, n, 0);
|
||||||
if( pColl2->xCmp!=0 ){
|
if( pColl2->xCmp!=0 ){
|
||||||
memcpy(pColl, pColl2, sizeof(CollSeq));
|
memcpy(pColl, pColl2, sizeof(CollSeq));
|
||||||
|
pColl->xDel = 0; /* Do not copy the destructor */
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
63
src/main.c
63
src/main.c
@@ -14,7 +14,7 @@
|
|||||||
** other files are for internal use by SQLite and should not be
|
** other files are for internal use by SQLite and should not be
|
||||||
** accessed by users of the library.
|
** accessed by users of the library.
|
||||||
**
|
**
|
||||||
** $Id: main.c,v 1.371 2007/05/06 16:04:12 danielk1977 Exp $
|
** $Id: main.c,v 1.372 2007/05/07 09:32:45 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@@ -182,6 +182,12 @@ int sqlite3_close(sqlite3 *db){
|
|||||||
|
|
||||||
for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){
|
for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){
|
||||||
CollSeq *pColl = (CollSeq *)sqliteHashData(i);
|
CollSeq *pColl = (CollSeq *)sqliteHashData(i);
|
||||||
|
/* Invoke any destructors registered for collation sequence user data. */
|
||||||
|
for(j=0; j<3; j++){
|
||||||
|
if( pColl[j].xDel ){
|
||||||
|
pColl[j].xDel(pColl[j].pUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
sqliteFree(pColl);
|
sqliteFree(pColl);
|
||||||
}
|
}
|
||||||
sqlite3HashClear(&db->aCollSeq);
|
sqlite3HashClear(&db->aCollSeq);
|
||||||
@@ -825,7 +831,8 @@ static int createCollation(
|
|||||||
const char *zName,
|
const char *zName,
|
||||||
int enc,
|
int enc,
|
||||||
void* pCtx,
|
void* pCtx,
|
||||||
int(*xCompare)(void*,int,const void*,int,const void*)
|
int(*xCompare)(void*,int,const void*,int,const void*),
|
||||||
|
void(*xDel)(void*)
|
||||||
){
|
){
|
||||||
CollSeq *pColl;
|
CollSeq *pColl;
|
||||||
int enc2;
|
int enc2;
|
||||||
@@ -860,12 +867,33 @@ static int createCollation(
|
|||||||
return SQLITE_BUSY;
|
return SQLITE_BUSY;
|
||||||
}
|
}
|
||||||
sqlite3ExpirePreparedStatements(db);
|
sqlite3ExpirePreparedStatements(db);
|
||||||
|
|
||||||
|
/* If collation sequence pColl was created directly by a call to
|
||||||
|
** sqlite3_create_collation, and not generated by synthCollSeq(),
|
||||||
|
** then any copies made by synthCollSeq() need to be invalidated.
|
||||||
|
** Also, collation destructor - CollSeq.xDel() - function may need
|
||||||
|
** to be called.
|
||||||
|
*/
|
||||||
|
if( (pColl->enc & ~SQLITE_UTF16_ALIGNED)==enc2 ){
|
||||||
|
CollSeq *aColl = sqlite3HashFind(&db->aCollSeq, zName, strlen(zName));
|
||||||
|
int j;
|
||||||
|
for(j=0; j<3; j++){
|
||||||
|
CollSeq *p = &aColl[j];
|
||||||
|
if( p->enc==pColl->enc ){
|
||||||
|
if( p->xDel ){
|
||||||
|
p->xDel(p->pUser);
|
||||||
|
}
|
||||||
|
p->xCmp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, strlen(zName), 1);
|
pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, strlen(zName), 1);
|
||||||
if( pColl ){
|
if( pColl ){
|
||||||
pColl->xCmp = xCompare;
|
pColl->xCmp = xCompare;
|
||||||
pColl->pUser = pCtx;
|
pColl->pUser = pCtx;
|
||||||
|
pColl->xDel = xDel;
|
||||||
pColl->enc = enc2 | (enc & SQLITE_UTF16_ALIGNED);
|
pColl->enc = enc2 | (enc & SQLITE_UTF16_ALIGNED);
|
||||||
}
|
}
|
||||||
sqlite3Error(db, SQLITE_OK, 0);
|
sqlite3Error(db, SQLITE_OK, 0);
|
||||||
@@ -915,9 +943,9 @@ static int openDatabase(
|
|||||||
** and UTF-16, so add a version for each to avoid any unnecessary
|
** and UTF-16, so add a version for each to avoid any unnecessary
|
||||||
** conversions. The only error that can occur here is a malloc() failure.
|
** conversions. The only error that can occur here is a malloc() failure.
|
||||||
*/
|
*/
|
||||||
if( createCollation(db, "BINARY", SQLITE_UTF8, 0, binCollFunc) ||
|
if( createCollation(db, "BINARY", SQLITE_UTF8, 0, binCollFunc, 0) ||
|
||||||
createCollation(db, "BINARY", SQLITE_UTF16BE, 0, binCollFunc) ||
|
createCollation(db, "BINARY", SQLITE_UTF16BE, 0, binCollFunc, 0) ||
|
||||||
createCollation(db, "BINARY", SQLITE_UTF16LE, 0, binCollFunc) ||
|
createCollation(db, "BINARY", SQLITE_UTF16LE, 0, binCollFunc, 0) ||
|
||||||
(db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 6, 0))==0
|
(db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 6, 0))==0
|
||||||
){
|
){
|
||||||
assert( sqlite3MallocFailed() );
|
assert( sqlite3MallocFailed() );
|
||||||
@@ -926,7 +954,7 @@ static int openDatabase(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Also add a UTF-8 case-insensitive collation sequence. */
|
/* Also add a UTF-8 case-insensitive collation sequence. */
|
||||||
createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc);
|
createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);
|
||||||
|
|
||||||
/* Set flags on the built-in collating sequences */
|
/* Set flags on the built-in collating sequences */
|
||||||
db->pDfltColl->type = SQLITE_COLL_BINARY;
|
db->pDfltColl->type = SQLITE_COLL_BINARY;
|
||||||
@@ -986,7 +1014,7 @@ static int openDatabase(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SQLITE_ENABLE_ICU
|
#ifdef SQLITE_ENABLE_ICU
|
||||||
{
|
if( !sqlite3MallocFailed() ){
|
||||||
extern int sqlite3IcuInit(sqlite3*);
|
extern int sqlite3IcuInit(sqlite3*);
|
||||||
sqlite3IcuInit(db);
|
sqlite3IcuInit(db);
|
||||||
}
|
}
|
||||||
@@ -1106,7 +1134,24 @@ int sqlite3_create_collation(
|
|||||||
){
|
){
|
||||||
int rc;
|
int rc;
|
||||||
assert( !sqlite3MallocFailed() );
|
assert( !sqlite3MallocFailed() );
|
||||||
rc = createCollation(db, zName, enc, pCtx, xCompare);
|
rc = createCollation(db, zName, enc, pCtx, xCompare, 0);
|
||||||
|
return sqlite3ApiExit(db, rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Register a new collation sequence with the database handle db.
|
||||||
|
*/
|
||||||
|
int sqlite3_create_collation_x(
|
||||||
|
sqlite3* db,
|
||||||
|
const char *zName,
|
||||||
|
int enc,
|
||||||
|
void* pCtx,
|
||||||
|
int(*xCompare)(void*,int,const void*,int,const void*),
|
||||||
|
void(*xDel)(void*)
|
||||||
|
){
|
||||||
|
int rc;
|
||||||
|
assert( !sqlite3MallocFailed() );
|
||||||
|
rc = createCollation(db, zName, enc, pCtx, xCompare, xDel);
|
||||||
return sqlite3ApiExit(db, rc);
|
return sqlite3ApiExit(db, rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1126,7 +1171,7 @@ int sqlite3_create_collation16(
|
|||||||
assert( !sqlite3MallocFailed() );
|
assert( !sqlite3MallocFailed() );
|
||||||
zName8 = sqlite3utf16to8(zName, -1);
|
zName8 = sqlite3utf16to8(zName, -1);
|
||||||
if( zName8 ){
|
if( zName8 ){
|
||||||
rc = createCollation(db, zName8, enc, pCtx, xCompare);
|
rc = createCollation(db, zName8, enc, pCtx, xCompare, 0);
|
||||||
sqliteFree(zName8);
|
sqliteFree(zName8);
|
||||||
}
|
}
|
||||||
return sqlite3ApiExit(db, rc);
|
return sqlite3ApiExit(db, rc);
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
** This header file defines the interface that the SQLite library
|
** This header file defines the interface that the SQLite library
|
||||||
** presents to client programs.
|
** presents to client programs.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqlite.h.in,v 1.204 2007/05/03 16:31:26 danielk1977 Exp $
|
** @(#) $Id: sqlite.h.in,v 1.205 2007/05/07 09:32:45 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITE3_H_
|
#ifndef _SQLITE3_H_
|
||||||
#define _SQLITE3_H_
|
#define _SQLITE3_H_
|
||||||
@@ -1279,6 +1279,18 @@ int sqlite3_create_collation16(
|
|||||||
int(*xCompare)(void*,int,const void*,int,const void*)
|
int(*xCompare)(void*,int,const void*,int,const void*)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
****** EXPERIMENTAL - subject to change without notice **************
|
||||||
|
*/
|
||||||
|
int sqlite3_create_collation_x(
|
||||||
|
sqlite3*,
|
||||||
|
const char *zName,
|
||||||
|
int eTextRep,
|
||||||
|
void*,
|
||||||
|
int(*xCompare)(void*,int,const void*,int,const void*),
|
||||||
|
void(*xDel)(void*)
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** To avoid having to register all collation sequences before a database
|
** To avoid having to register all collation sequences before a database
|
||||||
** can be used, a single callback function may be registered with the
|
** can be used, a single callback function may be registered with the
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** Internal interface definitions for SQLite.
|
** Internal interface definitions for SQLite.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqliteInt.h,v 1.557 2007/05/05 11:48:54 drh Exp $
|
** @(#) $Id: sqliteInt.h,v 1.558 2007/05/07 09:32:45 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITEINT_H_
|
#ifndef _SQLITEINT_H_
|
||||||
#define _SQLITEINT_H_
|
#define _SQLITEINT_H_
|
||||||
@@ -646,11 +646,12 @@ struct Column {
|
|||||||
** collating sequence may not be read or written.
|
** collating sequence may not be read or written.
|
||||||
*/
|
*/
|
||||||
struct CollSeq {
|
struct CollSeq {
|
||||||
char *zName; /* Name of the collating sequence, UTF-8 encoded */
|
char *zName; /* Name of the collating sequence, UTF-8 encoded */
|
||||||
u8 enc; /* Text encoding handled by xCmp() */
|
u8 enc; /* Text encoding handled by xCmp() */
|
||||||
u8 type; /* One of the SQLITE_COLL_... values below */
|
u8 type; /* One of the SQLITE_COLL_... values below */
|
||||||
void *pUser; /* First argument to xCmp() */
|
void *pUser; /* First argument to xCmp() */
|
||||||
int (*xCmp)(void*,int, const void*, int, const void*);
|
int (*xCmp)(void*,int, const void*, int, const void*);
|
||||||
|
void (*xDel)(void*); /* Destructor for pUser */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
106
src/test1.c
106
src/test1.c
@@ -13,7 +13,7 @@
|
|||||||
** is not included in the SQLite library. It is used for automated
|
** is not included in the SQLite library. It is used for automated
|
||||||
** testing of the SQLite library.
|
** testing of the SQLite library.
|
||||||
**
|
**
|
||||||
** $Id: test1.c,v 1.247 2007/05/06 16:04:12 danielk1977 Exp $
|
** $Id: test1.c,v 1.248 2007/05/07 09:32:45 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "tcl.h"
|
#include "tcl.h"
|
||||||
@@ -1508,6 +1508,18 @@ static int test_table_column_metadata(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** sqlite3_blob_read CHANNEL OFFSET N
|
** sqlite3_blob_read CHANNEL OFFSET N
|
||||||
|
**
|
||||||
|
** This command is used to test the sqlite3_blob_read() in ways that
|
||||||
|
** the Tcl channel interface does not. The first argument should
|
||||||
|
** be the name of a valid channel created by the [incrblob] method
|
||||||
|
** of a database handle. This function calls sqlite3_blob_read()
|
||||||
|
** to read N bytes from offset OFFSET from the underlying SQLite
|
||||||
|
** blob handle.
|
||||||
|
**
|
||||||
|
** On success, a byte-array object containing the read data is
|
||||||
|
** returned. On failure, the interpreter result is set to the
|
||||||
|
** text representation of the returned error code (i.e. "SQLITE_NOMEM")
|
||||||
|
** and a Tcl exception is thrown.
|
||||||
*/
|
*/
|
||||||
static int test_blob_read(
|
static int test_blob_read(
|
||||||
ClientData clientData, /* Not used */
|
ClientData clientData, /* Not used */
|
||||||
@@ -1555,6 +1567,17 @@ static int test_blob_read(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** sqlite3_blob_write CHANNEL OFFSET DATA
|
** sqlite3_blob_write CHANNEL OFFSET DATA
|
||||||
|
**
|
||||||
|
** This command is used to test the sqlite3_blob_write() in ways that
|
||||||
|
** the Tcl channel interface does not. The first argument should
|
||||||
|
** be the name of a valid channel created by the [incrblob] method
|
||||||
|
** of a database handle. This function calls sqlite3_blob_write()
|
||||||
|
** to write the DATA byte-array to the underlying SQLite blob handle.
|
||||||
|
** at offset OFFSET.
|
||||||
|
**
|
||||||
|
** On success, an empty string is returned. On failure, the interpreter
|
||||||
|
** result is set to the text representation of the returned error code
|
||||||
|
** (i.e. "SQLITE_NOMEM") and a Tcl exception is thrown.
|
||||||
*/
|
*/
|
||||||
static int test_blob_write(
|
static int test_blob_write(
|
||||||
ClientData clientData, /* Not used */
|
ClientData clientData, /* Not used */
|
||||||
@@ -1598,6 +1621,82 @@ static int test_blob_write(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Usage: sqlite3_create_collation_x DB-HANDLE NAME CMP-PROC DEL-PROC
|
||||||
|
**
|
||||||
|
** This Tcl proc is used for testing the experimental
|
||||||
|
** sqlite3_create_collation_x() interface.
|
||||||
|
*/
|
||||||
|
struct TestCollationX {
|
||||||
|
Tcl_Interp *interp;
|
||||||
|
Tcl_Obj *pCmp;
|
||||||
|
Tcl_Obj *pDel;
|
||||||
|
};
|
||||||
|
typedef struct TestCollationX TestCollationX;
|
||||||
|
static void testCreateCollationDel(void *pCtx){
|
||||||
|
TestCollationX *p = (TestCollationX *)pCtx;
|
||||||
|
|
||||||
|
int rc = Tcl_EvalObjEx(p->interp, p->pDel, TCL_EVAL_DIRECT|TCL_EVAL_GLOBAL);
|
||||||
|
if( rc!=TCL_OK ){
|
||||||
|
Tcl_BackgroundError(p->interp);
|
||||||
|
}
|
||||||
|
|
||||||
|
Tcl_DecrRefCount(p->pCmp);
|
||||||
|
Tcl_DecrRefCount(p->pDel);
|
||||||
|
sqlite3_free((void *)p);
|
||||||
|
}
|
||||||
|
static int testCreateCollationCmp(
|
||||||
|
void *pCtx,
|
||||||
|
int nLeft,
|
||||||
|
const void *zLeft,
|
||||||
|
int nRight,
|
||||||
|
const void *zRight
|
||||||
|
){
|
||||||
|
TestCollationX *p = (TestCollationX *)pCtx;
|
||||||
|
Tcl_Obj *pScript = Tcl_DuplicateObj(p->pCmp);
|
||||||
|
int iRes = 0;
|
||||||
|
|
||||||
|
Tcl_IncrRefCount(pScript);
|
||||||
|
Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj((char *)zLeft, nLeft));
|
||||||
|
Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj((char *)zRight,nRight));
|
||||||
|
|
||||||
|
if( TCL_OK!=Tcl_EvalObjEx(p->interp, pScript, TCL_EVAL_DIRECT|TCL_EVAL_GLOBAL)
|
||||||
|
|| TCL_OK!=Tcl_GetIntFromObj(p->interp, Tcl_GetObjResult(p->interp), &iRes)
|
||||||
|
){
|
||||||
|
Tcl_BackgroundError(p->interp);
|
||||||
|
}
|
||||||
|
Tcl_DecrRefCount(pScript);
|
||||||
|
|
||||||
|
return iRes;
|
||||||
|
}
|
||||||
|
static int test_create_collation_x(
|
||||||
|
ClientData clientData, /* Not used */
|
||||||
|
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||||
|
int objc, /* Number of arguments */
|
||||||
|
Tcl_Obj *CONST objv[] /* Command arguments */
|
||||||
|
){
|
||||||
|
TestCollationX *p;
|
||||||
|
sqlite3 *db;
|
||||||
|
|
||||||
|
if( objc!=5 ){
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "DB-HANDLE NAME CMP-PROC DEL-PROC");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||||
|
|
||||||
|
p = (TestCollationX *)sqlite3_malloc(sizeof(TestCollationX));
|
||||||
|
p->pCmp = objv[3];
|
||||||
|
p->pDel = objv[4];
|
||||||
|
p->interp = interp;
|
||||||
|
Tcl_IncrRefCount(p->pCmp);
|
||||||
|
Tcl_IncrRefCount(p->pDel);
|
||||||
|
|
||||||
|
sqlite3_create_collation_x(db, Tcl_GetString(objv[2]), SQLITE_UTF8,
|
||||||
|
(void *)p, testCreateCollationCmp, testCreateCollationDel
|
||||||
|
);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC?
|
** Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC?
|
||||||
*/
|
*/
|
||||||
@@ -4617,8 +4716,9 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
|||||||
{"sqlite3_column_origin_name16", test_stmt_utf16, sqlite3_column_origin_name16},
|
{"sqlite3_column_origin_name16", test_stmt_utf16, sqlite3_column_origin_name16},
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{ "sqlite3_global_recover", test_global_recover, 0 },
|
{ "sqlite3_create_collation_x", test_create_collation_x, 0 },
|
||||||
{ "working_64bit_int", working_64bit_int, 0 },
|
{ "sqlite3_global_recover", test_global_recover, 0 },
|
||||||
|
{ "working_64bit_int", working_64bit_int, 0 },
|
||||||
|
|
||||||
/* Functions from os.h */
|
/* Functions from os.h */
|
||||||
#ifndef SQLITE_OMIT_DISKIO
|
#ifndef SQLITE_OMIT_DISKIO
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
#
|
#
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
#
|
#
|
||||||
# $Id: incrblob.test,v 1.9 2007/05/04 19:03:03 danielk1977 Exp $
|
# $Id: incrblob.test,v 1.10 2007/05/07 09:32:45 danielk1977 Exp $
|
||||||
#
|
#
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
@@ -551,7 +551,7 @@ do_test incrblob-7.3.2 {
|
|||||||
do_test incrblob-7.3.3 {
|
do_test incrblob-7.3.3 {
|
||||||
execsql {
|
execsql {
|
||||||
DELETE FROM t1 WHERE a = 123;
|
DELETE FROM t1 WHERE a = 123;
|
||||||
INCREMENTAL VACUUM;
|
PRAGMA INCREMENTAL_VACUUM(0);
|
||||||
}
|
}
|
||||||
seek $::b 0
|
seek $::b 0
|
||||||
read $::b
|
read $::b
|
||||||
|
Reference in New Issue
Block a user