1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Change the name of create_collation_x() to create_collation_v2(). Also add some tests for it. (CVS 3938)

FossilOrigin-Name: ddc4e4797ff902692c4f0d86ec5f4e94cc7f0741
This commit is contained in:
danielk1977
2007-05-07 14:58:53 +00:00
parent 9e91c756a1
commit a393c03686
6 changed files with 111 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
C Fix\stypo\sin\sMakefile.in.\s\sTicket\s#2343\s(CVS\s3937)
D 2007-05-07T13:11:10
C Change\sthe\sname\sof\screate_collation_x()\sto\screate_collation_v2().\sAlso\sadd\ssome\stests\sfor\sit.\s(CVS\s3938)
D 2007-05-07T14:58:53
F Makefile.in ab0f3cb6b34aa8ccec0bb57e6696fd4bd6b34a8f
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -77,7 +77,7 @@ F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
F src/insert.c e595ca26805dfb3a9ebaabc28e7947c479f3b14d
F src/legacy.c 388c71ad7fbcd898ba1bcbfc98a3ac954bfa5d01
F src/loadext.c afe4f4755dc49c36ef505748bbdddecb9f1d02a2
F src/main.c ada896b9554aa71e717a6ab237ab0eff63a1e1e4
F src/main.c 0e389104acf4a7c26b57f35ee84eecc60a5d6da5
F src/malloc.c b89e31258a85158d15795bf87ae3ba007e56329b
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/os.c 4650e98aadd27abfe1698ff58edf6893c58d4881
@@ -101,12 +101,12 @@ F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
F src/select.c a306d03fc7d8365055bef70c3563e8fca897460f
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c d07ae326b3815d80f71c69b3c7584382e47f6447
F src/sqlite.h.in e9b82a9e6e24e279d4e9d239535fbdae464b5594
F src/sqlite.h.in b7682eac8b0365b5c0740a527900449b4815740e
F src/sqlite3ext.h 7d0d363ea7327e817ef0dfe1b7eee1f171b72890
F src/sqliteInt.h 5e1cf645ef1bf8b43c5d020adbeed43746df24ed
F src/table.c a8de75bcedf84d4060d804264b067ab3b1a3561d
F src/tclsqlite.c f3414b2d6bc37e6760b49c9abd3504ff69f4441b
F src/test1.c 84e78efa05a6d36a1868912b84cc5009d990f49d
F src/test1.c 3891b07526d311ad040d099a76d5fbfdcb826783
F src/test2.c 24458b17ab2f3c90cbc1c8446bd7ffe69be62f88
F src/test3.c 946ea9d1a8c928656e3c70f0a2fcb8e733a15e86
F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
@@ -190,6 +190,7 @@ F test/collate3.test 947a77f5b8227e037a7094d0e338a5504f155cc4
F test/collate4.test daf498e294dcd596b961d425c3f2dda117e4717e
F test/collate5.test 8fb4e7e0241839356bd8710f437c32efb47bfff8
F test/collate6.test 6c9470d1606ee3e564675b229653e320c49ec638
F test/collate7.test e23677b1fd271505302643a98178952bb65b6f21
F test/colmeta.test 6505c73ab58796afcb7c89ba9f429d573fbc6e53
F test/conflict.test ac40064d46c4c259cf6c216d30aa5bcc26e7eea2
F test/corrupt.test 18c7a995b1af76a8c8600b996257f2c7b7bff083
@@ -482,7 +483,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P b29a81b4fbb926fa09186340342848b9fe589033
R 070abd22aa31f658bb086ef0bcccfbd9
U drh
Z 0f63f70a104768ba21532b79aaca7f73
P db51f59a7bb7530f919858e2c51057839f6c9f4d
R 27185812931e7f9d41fbfd4819a22118
U danielk1977
Z ae7686d308deffcdeb3aacd0475a723f

View File

@@ -1 +1 @@
db51f59a7bb7530f919858e2c51057839f6c9f4d
ddc4e4797ff902692c4f0d86ec5f4e94cc7f0741

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.372 2007/05/07 09:32:45 danielk1977 Exp $
** $Id: main.c,v 1.373 2007/05/07 14:58:53 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -1141,7 +1141,7 @@ int sqlite3_create_collation(
/*
** Register a new collation sequence with the database handle db.
*/
int sqlite3_create_collation_x(
int sqlite3_create_collation_v2(
sqlite3* db,
const char *zName,
int enc,

View File

@@ -12,7 +12,7 @@
** This header file defines the interface that the SQLite library
** presents to client programs.
**
** @(#) $Id: sqlite.h.in,v 1.205 2007/05/07 09:32:45 danielk1977 Exp $
** @(#) $Id: sqlite.h.in,v 1.206 2007/05/07 14:58:53 danielk1977 Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
@@ -1281,14 +1281,30 @@ int sqlite3_create_collation16(
/*
****** EXPERIMENTAL - subject to change without notice **************
**
** The following experimental API is identical to the
** sqlite3_create_collation() function described above except that it
** allows a destructor callback function - xDestroy - for the new
** collation sequence to be specified. If this function returns
** successfully, the destructor function will be invoked exactly once
** by SQLite when one of the following occurs:
**
** * The collation sequence is overidden by a subsequent call
** to create_collation(), create_collation16() or
** create_collation_v2(), or
**
** * The database handle is closed.
**
** The argument passed to the destructor function is a copy of
** the void* pointer passed as the 4th argument to this function.
*/
int sqlite3_create_collation_x(
int sqlite3_create_collation_v2(
sqlite3*,
const char *zName,
int eTextRep,
void*,
int(*xCompare)(void*,int,const void*,int,const void*),
void(*xDel)(void*)
void(*xDestroy)(void*)
);
/*

View File

@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.249 2007/05/07 11:24:30 drh Exp $
** $Id: test1.c,v 1.250 2007/05/07 14:58:53 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -1649,10 +1649,10 @@ static int test_blob_write(
#endif
/*
** Usage: sqlite3_create_collation_x DB-HANDLE NAME CMP-PROC DEL-PROC
** Usage: sqlite3_create_collation_v2 DB-HANDLE NAME CMP-PROC DEL-PROC
**
** This Tcl proc is used for testing the experimental
** sqlite3_create_collation_x() interface.
** sqlite3_create_collation_v2() interface.
*/
struct TestCollationX {
Tcl_Interp *interp;
@@ -1696,7 +1696,7 @@ static int testCreateCollationCmp(
return iRes;
}
static int test_create_collation_x(
static int test_create_collation_v2(
ClientData clientData, /* Not used */
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
@@ -1718,7 +1718,7 @@ static int test_create_collation_x(
Tcl_IncrRefCount(p->pCmp);
Tcl_IncrRefCount(p->pDel);
sqlite3_create_collation_x(db, Tcl_GetString(objv[2]), SQLITE_UTF8,
sqlite3_create_collation_v2(db, Tcl_GetString(objv[2]), SQLITE_UTF8,
(void *)p, testCreateCollationCmp, testCreateCollationDel
);
return TCL_OK;
@@ -4744,7 +4744,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{"sqlite3_column_origin_name16", test_stmt_utf16, sqlite3_column_origin_name16},
#endif
#endif
{ "sqlite3_create_collation_x", test_create_collation_x, 0 },
{ "sqlite3_create_collation_v2", test_create_collation_v2, 0 },
{ "sqlite3_global_recover", test_global_recover, 0 },
{ "working_64bit_int", working_64bit_int, 0 },

73
test/collate7.test Normal file
View File

@@ -0,0 +1,73 @@
#
# 2007 May 7
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is the experimental sqlite3_create_collation_v2()
# API.
#
# $Id: collate7.test,v 1.1 2007/05/07 14:58:53 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::caseless_del 0
proc caseless_cmp {zLeft zRight} {
string compare -nocase $zLeft $zRight
}
do_test collate7-1.1 {
set cmd [list incr ::caseless_del]
sqlite3_create_collation_v2 db CASELESS caseless_cmp $cmd
set ::caseless_del
} {0}
do_test collate7-1.2 {
sqlite_delete_collation db CASELESS
set ::caseless_del
} {1}
do_test collate7-1.3 {
catchsql {
CREATE TABLE abc(a COLLATE CASELESS, b, c);
}
} {1 {no such collation sequence: CASELESS}}
do_test collate7-1.4 {
sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del}
db close
set ::caseless_del
} {2}
do_test collate7-2.1 {
file delete -force test.db test.db-journal
sqlite3 db test.db
sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del}
execsql {
PRAGMA encoding='utf-16';
CREATE TABLE abc16(a COLLATE CASELESS, b, c);
} db
set ::caseless_del
} {2}
do_test collate7-2.2 {
execsql {
SELECT * FROM abc16 WHERE a < 'abc';
}
set ::caseless_del
} {2}
do_test collate7-2.3 {
sqlite_delete_collation db CASELESS
set ::caseless_del
} {3}
do_test collate7-2.4 {
catchsql {
SELECT * FROM abc16 WHERE a < 'abc';
}
} {1 {no such collation sequence: CASELESS}}
finish_test