mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Convert the TCL interface to use sqlite3_open_v2 (CVS 4352)
FossilOrigin-Name: 3434b7a9213f210498f43cb5094a0f3f5c25b957
This commit is contained in:
18
manifest
18
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\sa\sproblem\sin\smalloc3.test\spreventing\sall.test\sfrom\scompleting.\sNo\scode\schanges.\s(CVS\s4351)
|
C Convert\sthe\sTCL\sinterface\sto\suse\ssqlite3_open_v2\s(CVS\s4352)
|
||||||
D 2007-08-31T05:00:49
|
D 2007-08-31T14:31:45
|
||||||
F Makefile.in bfcc303429a5d9dcd552d807ee016c77427418c3
|
F Makefile.in bfcc303429a5d9dcd552d807ee016c77427418c3
|
||||||
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
|
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -135,7 +135,7 @@ F src/sqlite3ext.h 3e5368b64a28602ef8abf9cfb6c8c1643903f238
|
|||||||
F src/sqliteInt.h 5dbb7a934a88dfa9893e2627f4821b0464f5edc0
|
F src/sqliteInt.h 5dbb7a934a88dfa9893e2627f4821b0464f5edc0
|
||||||
F src/sqliteLimit.h 1bcbbdfa856f8b71b561abb31edb864b0eca1d12
|
F src/sqliteLimit.h 1bcbbdfa856f8b71b561abb31edb864b0eca1d12
|
||||||
F src/table.c 1aeb9eab57b4235db86fe15a35dec76fb445a9c4
|
F src/table.c 1aeb9eab57b4235db86fe15a35dec76fb445a9c4
|
||||||
F src/tclsqlite.c 5b801c7eeefe8c968325558e2a7977cf8a713d5f
|
F src/tclsqlite.c 8db035768623779c97d0509eb88ecbb49c51abca
|
||||||
F src/test1.c 8b20d1f05777ac480d3caf8d5f79ab7a543513fc
|
F src/test1.c 8b20d1f05777ac480d3caf8d5f79ab7a543513fc
|
||||||
F src/test2.c 4ab230fbdc0decfa7422f6a052b609ba54f4dfac
|
F src/test2.c 4ab230fbdc0decfa7422f6a052b609ba54f4dfac
|
||||||
F src/test3.c 199a440ba2b38b26251393b609451a3484a15907
|
F src/test3.c 199a440ba2b38b26251393b609451a3484a15907
|
||||||
@@ -418,9 +418,9 @@ F test/substr.test 9f26cfca74397b26ab217fb838c3d0549eb4bcf3
|
|||||||
F test/sync.test d05397b8f89f423dd6dba528692019ab036bc1c3
|
F test/sync.test d05397b8f89f423dd6dba528692019ab036bc1c3
|
||||||
F test/table.test dbdfd06aef054ad5aed8e57a782137d57d5c5528
|
F test/table.test dbdfd06aef054ad5aed8e57a782137d57d5c5528
|
||||||
F test/tableapi.test 036575a98dcce7c92e9f39056839bbad8a715412
|
F test/tableapi.test 036575a98dcce7c92e9f39056839bbad8a715412
|
||||||
F test/tclsqlite.test 593f3b30221e85786965d9e5670ae4f96b4e4159
|
F test/tclsqlite.test 3addd6a88b8a756ec802ca8840587fa3d61bfcff
|
||||||
F test/temptable.test c36f3e5a94507abb64f7ba23deeb4e1a8a8c3821
|
F test/temptable.test c36f3e5a94507abb64f7ba23deeb4e1a8a8c3821
|
||||||
F test/tester.tcl d6fd4e9eac69a7bc7791ca2f80c91945d1f6d1cc
|
F test/tester.tcl 577c2eb71a6e308f8e4d6b283c6a0d2966ed2824
|
||||||
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
|
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
|
||||||
F test/thread2.test 6d7b30102d600f51b4055ee3a5a19228799049fb
|
F test/thread2.test 6d7b30102d600f51b4055ee3a5a19228799049fb
|
||||||
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
|
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
|
||||||
@@ -568,7 +568,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
|
|||||||
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 1b39a714efbe1f4ccc8daf68a227a8c9b84a388f
|
P ee9b3e5e38c52f5669009a08aec58678ccad0d87
|
||||||
R 5354fced5254a75816d7576469879796
|
R b9ef3977fd4686cc6e05c610911a5a80
|
||||||
U danielk1977
|
U drh
|
||||||
Z ef735893af1f42e3e38cbeb5ea49fed9
|
Z edb6e93aa3250c0879e9ae9ba46c5a0f
|
||||||
|
@@ -1 +1 @@
|
|||||||
ee9b3e5e38c52f5669009a08aec58678ccad0d87
|
3434b7a9213f210498f43cb5094a0f3f5c25b957
|
@@ -12,7 +12,7 @@
|
|||||||
** A TCL Interface to SQLite. Append this file to sqlite3.c and
|
** A TCL Interface to SQLite. Append this file to sqlite3.c and
|
||||||
** compile the whole thing to build a TCL-enabled version of SQLite.
|
** compile the whole thing to build a TCL-enabled version of SQLite.
|
||||||
**
|
**
|
||||||
** $Id: tclsqlite.c,v 1.199 2007/08/30 14:58:20 drh Exp $
|
** $Id: tclsqlite.c,v 1.200 2007/08/31 14:31:45 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "tcl.h"
|
#include "tcl.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -2255,7 +2255,8 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** sqlite3 DBNAME FILENAME ?MODE? ?-key KEY?
|
** sqlite3 DBNAME FILENAME ?-vfs VFSNAME? ?-key KEY? ?-readonly BOOLEAN?
|
||||||
|
** ?-create BOOLEAN?
|
||||||
**
|
**
|
||||||
** This is the main Tcl command. When the "sqlite" Tcl command is
|
** This is the main Tcl command. When the "sqlite" Tcl command is
|
||||||
** invoked, this routine runs to process that command.
|
** invoked, this routine runs to process that command.
|
||||||
@@ -2265,25 +2266,8 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
|||||||
** DBNAME that is used to control that connection. The database
|
** DBNAME that is used to control that connection. The database
|
||||||
** connection is deleted when the DBNAME command is deleted.
|
** connection is deleted when the DBNAME command is deleted.
|
||||||
**
|
**
|
||||||
** The second argument is the name of the directory that contains
|
** The second argument is the name of the database file.
|
||||||
** the sqlite database that is to be accessed.
|
|
||||||
**
|
**
|
||||||
** For testing purposes, we also support the following:
|
|
||||||
**
|
|
||||||
** sqlite3 -encoding
|
|
||||||
**
|
|
||||||
** Return the encoding used by LIKE and GLOB operators. Choices
|
|
||||||
** are UTF-8 and iso8859.
|
|
||||||
**
|
|
||||||
** sqlite3 -version
|
|
||||||
**
|
|
||||||
** Return the version number of the SQLite library.
|
|
||||||
**
|
|
||||||
** sqlite3 -tcl-uses-utf
|
|
||||||
**
|
|
||||||
** Return "1" if compiled with a Tcl uses UTF-8. Return "0" if
|
|
||||||
** not. Used by tests to make sure the library was compiled
|
|
||||||
** correctly.
|
|
||||||
*/
|
*/
|
||||||
static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
||||||
SqliteDb *p;
|
SqliteDb *p;
|
||||||
@@ -2291,7 +2275,10 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
|||||||
int nKey = 0;
|
int nKey = 0;
|
||||||
const char *zArg;
|
const char *zArg;
|
||||||
char *zErrMsg;
|
char *zErrMsg;
|
||||||
|
int i;
|
||||||
const char *zFile;
|
const char *zFile;
|
||||||
|
const char *zVfs = 0;
|
||||||
|
int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
|
||||||
Tcl_DString translatedFilename;
|
Tcl_DString translatedFilename;
|
||||||
if( objc==2 ){
|
if( objc==2 ){
|
||||||
zArg = Tcl_GetStringFromObj(objv[1], 0);
|
zArg = Tcl_GetStringFromObj(objv[1], 0);
|
||||||
@@ -2307,28 +2294,42 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
|||||||
#endif
|
#endif
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
if( strcmp(zArg,"-tcl-uses-utf")==0 ){
|
|
||||||
#ifdef TCL_UTF_MAX
|
|
||||||
Tcl_AppendResult(interp,"1",0);
|
|
||||||
#else
|
|
||||||
Tcl_AppendResult(interp,"0",0);
|
|
||||||
#endif
|
|
||||||
return TCL_OK;
|
|
||||||
}
|
}
|
||||||
}
|
for(i=3; i+1<objc; i+=2){
|
||||||
if( objc==5 || objc==6 ){
|
zArg = Tcl_GetString(objv[i]);
|
||||||
zArg = Tcl_GetStringFromObj(objv[objc-2], 0);
|
|
||||||
if( strcmp(zArg,"-key")==0 ){
|
if( strcmp(zArg,"-key")==0 ){
|
||||||
pKey = Tcl_GetByteArrayFromObj(objv[objc-1], &nKey);
|
pKey = Tcl_GetByteArrayFromObj(objv[i+1], &nKey);
|
||||||
objc -= 2;
|
}else if( strcmp(zArg, "-vfs")==0 ){
|
||||||
|
i++;
|
||||||
|
zVfs = Tcl_GetString(objv[i]);
|
||||||
|
}else if( strcmp(zArg, "-readonly")==0 ){
|
||||||
|
int b;
|
||||||
|
if( Tcl_GetBooleanFromObj(interp, objv[i+1], &b) ) return TCL_ERROR;
|
||||||
|
if( b ){
|
||||||
|
flags &= ~SQLITE_OPEN_READWRITE;
|
||||||
|
flags |= SQLITE_OPEN_READONLY;
|
||||||
|
}else{
|
||||||
|
flags &= ~SQLITE_OPEN_READONLY;
|
||||||
|
flags |= SQLITE_OPEN_READWRITE;
|
||||||
|
}
|
||||||
|
}else if( strcmp(zArg, "-create")==0 ){
|
||||||
|
int b;
|
||||||
|
if( Tcl_GetBooleanFromObj(interp, objv[i+1], &b) ) return TCL_ERROR;
|
||||||
|
if( b ){
|
||||||
|
flags |= SQLITE_OPEN_CREATE;
|
||||||
|
}else{
|
||||||
|
flags &= ~SQLITE_OPEN_CREATE;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Tcl_AppendResult(interp, "unknown option: ", zArg, (char*)0);
|
||||||
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( objc!=3 && objc!=4 ){
|
if( objc<3 || (objc&1)!=1 ){
|
||||||
Tcl_WrongNumArgs(interp, 1, objv,
|
Tcl_WrongNumArgs(interp, 1, objv,
|
||||||
|
"HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN?"
|
||||||
#ifdef SQLITE_HAS_CODEC
|
#ifdef SQLITE_HAS_CODEC
|
||||||
"HANDLE FILENAME ?-key CODEC-KEY?"
|
" ?-key CODECKEY?"
|
||||||
#else
|
|
||||||
"HANDLE FILENAME ?MODE?"
|
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
@@ -2342,7 +2343,7 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
|||||||
memset(p, 0, sizeof(*p));
|
memset(p, 0, sizeof(*p));
|
||||||
zFile = Tcl_GetStringFromObj(objv[2], 0);
|
zFile = Tcl_GetStringFromObj(objv[2], 0);
|
||||||
zFile = Tcl_TranslateFileName(interp, zFile, &translatedFilename);
|
zFile = Tcl_TranslateFileName(interp, zFile, &translatedFilename);
|
||||||
sqlite3_open(zFile, &p->db);
|
sqlite3_open_v2(zFile, &p->db, flags, zVfs);
|
||||||
Tcl_DStringFree(&translatedFilename);
|
Tcl_DStringFree(&translatedFilename);
|
||||||
if( SQLITE_OK!=sqlite3_errcode(p->db) ){
|
if( SQLITE_OK!=sqlite3_errcode(p->db) ){
|
||||||
zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(p->db));
|
zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(p->db));
|
||||||
@@ -2426,12 +2427,14 @@ EXTERN int Tclsqlite_SafeInit(Tcl_Interp *interp){ return TCL_OK; }
|
|||||||
#ifdef TCLSH
|
#ifdef TCLSH
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
** The code that follows is used to build standalone TCL interpreters
|
** The code that follows is used to build standalone TCL interpreters
|
||||||
|
** that are statically linked with SQLite.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** If the macro TCLSH is one, then put in code this for the
|
** If the macro TCLSH is one, then put in code this for the
|
||||||
** "main" routine that will initialize Tcl and take input from
|
** "main" routine that will initialize Tcl and take input from
|
||||||
** standard input.
|
** standard input, or if a file is named on the command line
|
||||||
|
** the TCL interpreter reads and evaluates that file.
|
||||||
*/
|
*/
|
||||||
#if TCLSH==1
|
#if TCLSH==1
|
||||||
static char zMainloop[] =
|
static char zMainloop[] =
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
# interface is pretty well tested. This file contains some addition
|
# interface is pretty well tested. This file contains some addition
|
||||||
# tests for fringe issues that the main test suite does not cover.
|
# tests for fringe issues that the main test suite does not cover.
|
||||||
#
|
#
|
||||||
# $Id: tclsqlite.test,v 1.59 2007/06/19 23:01:42 drh Exp $
|
# $Id: tclsqlite.test,v 1.60 2007/08/31 14:31:45 drh Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@@ -25,7 +25,7 @@ source $testdir/tester.tcl
|
|||||||
if {[sqlite3 -has-codec]} {
|
if {[sqlite3 -has-codec]} {
|
||||||
set r "sqlite_orig HANDLE FILENAME ?-key CODEC-KEY?"
|
set r "sqlite_orig HANDLE FILENAME ?-key CODEC-KEY?"
|
||||||
} else {
|
} else {
|
||||||
set r "sqlite3 HANDLE FILENAME ?MODE?"
|
set r "sqlite3 HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN?"
|
||||||
}
|
}
|
||||||
do_test tcl-1.1 {
|
do_test tcl-1.1 {
|
||||||
set v [catch {sqlite3 bogus} msg]
|
set v [catch {sqlite3 bogus} msg]
|
||||||
@@ -140,7 +140,6 @@ do_test tcl-1.20 {
|
|||||||
} {1 {wrong # args: should be "db copy CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?"}}
|
} {1 {wrong # args: should be "db copy CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?"}}
|
||||||
|
|
||||||
|
|
||||||
if {[sqlite3 -tcl-uses-utf]} {
|
|
||||||
catch {unset ::result}
|
catch {unset ::result}
|
||||||
do_test tcl-2.1 {
|
do_test tcl-2.1 {
|
||||||
execsql "CREATE TABLE t\u0123x(a int, b\u1235 float)"
|
execsql "CREATE TABLE t\u0123x(a int, b\u1235 float)"
|
||||||
@@ -155,7 +154,6 @@ if {[sqlite3 -tcl-uses-utf]} {
|
|||||||
db eval "SELECT * FROM t\u0123x" result break
|
db eval "SELECT * FROM t\u0123x" result break
|
||||||
set result(*)
|
set result(*)
|
||||||
} "a b\u1235"
|
} "a b\u1235"
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Test the onecolumn method
|
# Test the onecolumn method
|
||||||
|
@@ -11,34 +11,8 @@
|
|||||||
# This file implements some common TCL routines used for regression
|
# This file implements some common TCL routines used for regression
|
||||||
# testing the SQLite library
|
# testing the SQLite library
|
||||||
#
|
#
|
||||||
# $Id: tester.tcl,v 1.88 2007/08/23 11:07:10 danielk1977 Exp $
|
# $Id: tester.tcl,v 1.89 2007/08/31 14:31:45 drh Exp $
|
||||||
|
|
||||||
# Make sure tclsqlite3 was compiled correctly. Abort now with an
|
|
||||||
# error message if not.
|
|
||||||
#
|
|
||||||
if {[sqlite3 -tcl-uses-utf]} {
|
|
||||||
if {"\u1234"=="u1234"} {
|
|
||||||
puts stderr "***** BUILD PROBLEM *****"
|
|
||||||
puts stderr "$argv0 was linked against an older version"
|
|
||||||
puts stderr "of TCL that does not support Unicode, but uses a header"
|
|
||||||
puts stderr "file (\"tcl.h\") from a new TCL version that does support"
|
|
||||||
puts stderr "Unicode. This combination causes internal errors."
|
|
||||||
puts stderr "Recompile using a TCL library and header file that match"
|
|
||||||
puts stderr "and try again.\n**************************"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if {"\u1234"!="u1234"} {
|
|
||||||
puts stderr "***** BUILD PROBLEM *****"
|
|
||||||
puts stderr "$argv0 was linked against an newer version"
|
|
||||||
puts stderr "of TCL that supports Unicode, but uses a header file"
|
|
||||||
puts stderr "(\"tcl.h\") from a old TCL version that does not support"
|
|
||||||
puts stderr "Unicode. This combination causes internal errors."
|
|
||||||
puts stderr "Recompile using a TCL library and header file that match"
|
|
||||||
puts stderr "and try again.\n**************************"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set tcl_precision 15
|
set tcl_precision 15
|
||||||
set sqlite_pending_byte 0x0010000
|
set sqlite_pending_byte 0x0010000
|
||||||
|
Reference in New Issue
Block a user