Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | The sqlite TCL command no longer returns the hex address of the sqlite3* structure. Instead there is a new command in testfixture to find that information. (CVS 2852) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
70b228575e045bc56013aab945334203 |
User & Date: | drh 2006-01-03 00:33:50.000 |
Context
2006-01-03
| ||
13:39 | Add test files for the asynchronous IO concept. (CVS 2853) (check-in: 7c3492c840 user: danielk1977 tags: trunk) | |
00:33 | The sqlite TCL command no longer returns the hex address of the sqlite3* structure. Instead there is a new command in testfixture to find that information. (CVS 2852) (check-in: 70b228575e user: drh tags: trunk) | |
2006-01-02
| ||
20:00 | Add the xInMutex method to the os-layer switch for testing whether or not mutexes are used correctly. (CVS 2851) (check-in: a582b15959 user: drh tags: trunk) | |
Changes
Changes to src/tclsqlite.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 15 ** ** 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. ** ************************************************************************* ** A TCL Interface to SQLite ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 15 ** ** 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. ** ************************************************************************* ** A TCL Interface to SQLite ** ** $Id: tclsqlite.c,v 1.143 2006/01/03 00:33:50 drh Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ #include "sqliteInt.h" #include "hash.h" #include "tcl.h" #include <stdlib.h> |
︙ | ︙ | |||
85 86 87 88 89 90 91 | /* ** There is one instance of this structure for each SQLite database ** that has been opened by the SQLite TCL interface. */ typedef struct SqliteDb SqliteDb; struct SqliteDb { | | | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | /* ** There is one instance of this structure for each SQLite database ** that has been opened by the SQLite TCL interface. */ typedef struct SqliteDb SqliteDb; struct SqliteDb { sqlite3 *db; /* The "real" database structure. MUST BE FIRST */ Tcl_Interp *interp; /* The interpreter used for this database */ char *zBusy; /* The busy callback routine */ char *zCommit; /* The commit hook callback routine */ char *zTrace; /* The trace callback routine */ char *zProfile; /* The profile callback routine */ char *zProgress; /* The progress callback routine */ char *zAuth; /* The authorization callback routine */ |
︙ | ︙ | |||
2004 2005 2006 2007 2008 2009 2010 | static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ SqliteDb *p; void *pKey = 0; int nKey = 0; const char *zArg; char *zErrMsg; const char *zFile; | < | 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 | static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ SqliteDb *p; void *pKey = 0; int nKey = 0; const char *zArg; char *zErrMsg; const char *zFile; if( objc==2 ){ zArg = Tcl_GetStringFromObj(objv[1], 0); if( strcmp(zArg,"-version")==0 ){ Tcl_AppendResult(interp,sqlite3_version,0); return TCL_OK; } if( strcmp(zArg,"-has-codec")==0 ){ |
︙ | ︙ | |||
2072 2073 2074 2075 2076 2077 2078 | free(zErrMsg); return TCL_ERROR; } p->maxStmt = NUM_PREPARED_STMTS; zArg = Tcl_GetStringFromObj(objv[1], 0); Tcl_CreateObjCommand(interp, zArg, DbObjCmd, (char*)p, DbDeleteCmd); | < < < < < < < < | 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 | free(zErrMsg); return TCL_ERROR; } p->maxStmt = NUM_PREPARED_STMTS; zArg = Tcl_GetStringFromObj(objv[1], 0); Tcl_CreateObjCommand(interp, zArg, DbObjCmd, (char*)p, DbDeleteCmd); /* If compiled with SQLITE_TEST turned on, then register the "md5sum" ** SQL function. */ #ifdef SQLITE_TEST { extern void Md5_Register(sqlite3*); #ifdef SQLITE_MEMDEBUG |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 9 10 11 12 13 14 15 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 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.179 2006/01/03 00:33:50 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> /* ** This is a copy of the first part of the SqliteDb structure in ** tclsqlite.c. We need it here so that the get_sqlite_pointer routine ** can extract the sqlite3* pointer from an existing Tcl SQLite ** connection. */ struct SqliteDb { sqlite3 *db; }; /* ** A TCL command that returns the address of the sqlite* pointer ** for an sqlite connection instance. Bad things happen if the ** input is not an sqlite connection. */ static int get_sqlite_pointer( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ struct SqliteDb *p; Tcl_CmdInfo cmdInfo; char zBuf[100]; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "SQLITE-CONNECTION"); return TCL_ERROR; } if( !Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &cmdInfo) ){ Tcl_AppendResult(interp, "command not found: ", Tcl_GetString(objv[1]), (char*)0); return TCL_ERROR; } p = (struct SqliteDb*)cmdInfo.objClientData; sprintf(zBuf, "%p", p->db); if( strncmp(zBuf,"0x",2) ){ sprintf(zBuf, "0x%p", p->db); } Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } const char *sqlite3TestErrorName(int rc){ const char *zName = 0; switch( rc ){ case SQLITE_OK: zName = "SQLITE_OK"; break; case SQLITE_ERROR: zName = "SQLITE_ERROR"; break; case SQLITE_PERM: zName = "SQLITE_PERM"; break; |
︙ | ︙ | |||
3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 | { "sqlite3_stack_used", (Tcl_CmdProc*)test_stack_used }, }; static struct { char *zName; Tcl_ObjCmdProc *xProc; void *clientData; } aObjCmd[] = { { "sqlite3_bind_int", test_bind_int, 0 }, { "sqlite3_bind_int64", test_bind_int64, 0 }, { "sqlite3_bind_double", test_bind_double, 0 }, { "sqlite3_bind_null", test_bind_null ,0 }, { "sqlite3_bind_text", test_bind_text ,0 }, { "sqlite3_bind_text16", test_bind_text16 ,0 }, { "sqlite3_bind_blob", test_bind_blob ,0 }, | > | 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 | { "sqlite3_stack_used", (Tcl_CmdProc*)test_stack_used }, }; static struct { char *zName; Tcl_ObjCmdProc *xProc; void *clientData; } aObjCmd[] = { { "sqlite3_connection_pointer", get_sqlite_pointer, 0 }, { "sqlite3_bind_int", test_bind_int, 0 }, { "sqlite3_bind_int64", test_bind_int64, 0 }, { "sqlite3_bind_double", test_bind_double, 0 }, { "sqlite3_bind_null", test_bind_null ,0 }, { "sqlite3_bind_text", test_bind_text ,0 }, { "sqlite3_bind_text16", test_bind_text16 ,0 }, { "sqlite3_bind_blob", test_bind_blob ,0 }, |
︙ | ︙ |
Changes to test/alter.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2004 November 10 # # 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 testing the ALTER TABLE statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2004 November 10 # # 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 testing the ALTER TABLE statement. # # $Id: alter.test,v 1.12 2006/01/03 00:33:50 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # If SQLITE_OMIT_ALTERTABLE is defined, omit this file. ifcapable !altertable { |
︙ | ︙ | |||
140 141 142 143 144 145 146 | # Make sure the changes persist after restarting the database. # (The TEMP table will not persist, of course.) # ifcapable tempdb { do_test alter-1.6 { db close | | > | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | # Make sure the changes persist after restarting the database. # (The TEMP table will not persist, of course.) # ifcapable tempdb { do_test alter-1.6 { db close sqlite3 db test.db set DB [sqlite3_connection_pointer db] execsql { CREATE TEMP TABLE objlist(type, name, tbl_name); INSERT INTO objlist SELECT type, name, tbl_name FROM sqlite_master; INSERT INTO objlist SELECT type, name, tbl_name FROM sqlite_temp_master WHERE NAME!='objlist'; SELECT type, name, tbl_name FROM objlist |
︙ | ︙ |
Changes to test/alter2.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this script is testing that SQLite can handle a subtle # file format change that may be used in the future to implement # "ALTER TABLE ... ADD COLUMN". # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this script is testing that SQLite can handle a subtle # file format change that may be used in the future to implement # "ALTER TABLE ... ADD COLUMN". # # $Id: alter2.test,v 1.5 2006/01/03 00:33:50 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # We have to have pragmas in order to do this test ifcapable {!pragma} return |
︙ | ︙ | |||
246 247 248 249 250 251 252 | SELECT * FROM sqlite_master; } } {1 {unsupported file format}} do_test alter2-4.3 { sqlite3_errcode $::DB } {SQLITE_ERROR} do_test alter2-4.4 { | < | | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | SELECT * FROM sqlite_master; } } {1 {unsupported file format}} do_test alter2-4.3 { sqlite3_errcode $::DB } {SQLITE_ERROR} do_test alter2-4.4 { set ::DB [sqlite3_connection_pointer db] catchsql { SELECT * FROM sqlite_master; } } {1 {unsupported file format}} do_test alter2-4.5 { sqlite3_errcode $::DB } {SQLITE_ERROR} |
︙ | ︙ | |||
280 281 282 283 284 285 286 | #--------------------------------------------------------------------- # Test that when a database with file-format 2 is opened, new # databases are still created with file-format 1. # do_test alter2-6.1 { db close set_file_format 2 | | > | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | #--------------------------------------------------------------------- # Test that when a database with file-format 2 is opened, new # databases are still created with file-format 1. # do_test alter2-6.1 { db close set_file_format 2 sqlite3 db test.db set ::DB [sqlite3_connection_pointer db] get_file_format } {2} do_test alter2-6.2 { file delete -force test2.db-journal file delete -force test2.db execsql { ATTACH 'test2.db' AS aux; |
︙ | ︙ |
Changes to test/attach2.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # # $Id: attach2.test,v 1.35 2006/01/03 00:33:50 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Ticket #354 # |
︙ | ︙ | |||
125 126 127 128 129 130 131 | COMMIT } } {1 {cannot commit - no transaction is active}} # Ticket #574: Make sure it works using the non-callback API # do_test attach2-3.1 { | < | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | COMMIT } } {1 {cannot commit - no transaction is active}} # Ticket #574: Make sure it works using the non-callback API # do_test attach2-3.1 { set DB [sqlite3_connection_pointer db] set rc [catch {sqlite3_prepare $DB "ATTACH 'test2.db' AS t2" -1 TAIL} VM] if {$rc} {lappend rc $VM} sqlite3_step $VM sqlite3_finalize $VM set rc } {0} do_test attach2-3.2 { |
︙ | ︙ |
Changes to test/autoinc.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2004 November 12 # # 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 testing the AUTOINCREMENT features. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2004 November 12 # # 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 testing the AUTOINCREMENT features. # # $Id: autoinc.test,v 1.9 2006/01/03 00:33:50 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # If the library is not compiled with autoincrement support then # skip all tests in this file. |
︙ | ︙ | |||
508 509 510 511 512 513 514 | # Ticket #1283. Make sure that preparing but never running a statement # that creates the sqlite_sequence table does not mess up the database. # do_test autoinc-8.1 { catch {db2 close} catch {db close} file delete -force test.db | | > | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | # Ticket #1283. Make sure that preparing but never running a statement # that creates the sqlite_sequence table does not mess up the database. # do_test autoinc-8.1 { catch {db2 close} catch {db close} file delete -force test.db sqlite3 db test.db set DB [sqlite3_connection_pointer db] set STMT [sqlite3_prepare $DB { CREATE TABLE t1( x INTEGER PRIMARY KEY AUTOINCREMENT ) } -1 TAIL] sqlite3_finalize $STMT set STMT [sqlite3_prepare $DB { |
︙ | ︙ |
Changes to test/bind.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 September 6 # # 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 testing the sqlite_bind API. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2003 September 6 # # 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 testing the sqlite_bind API. # # $Id: bind.test,v 1.36 2006/01/03 00:33:50 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl proc sqlite_step {stmt N VALS COLS} { upvar VALS vals |
︙ | ︙ | |||
31 32 33 34 35 36 37 | lappend vals [sqlite3_column_text $stmt $i] } return $rc } do_test bind-1.1 { | < | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | lappend vals [sqlite3_column_text $stmt $i] } return $rc } do_test bind-1.1 { set DB [sqlite3_connection_pointer db] execsql {CREATE TABLE t1(a,b,c);} set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:1,?,:abc)} -1 TAIL] set TAIL } {} do_test bind-1.1.1 { sqlite3_bind_parameter_count $VM } 3 |
︙ | ︙ |
Changes to test/bindxfer.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2005 April 21 # # 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 testing the sqlite_transfer_bindings() API. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2005 April 21 # # 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 testing the sqlite_transfer_bindings() API. # # $Id: bindxfer.test,v 1.2 2006/01/03 00:33:50 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl proc sqlite_step {stmt VALS COLS} { upvar #0 $VALS vals |
︙ | ︙ | |||
31 32 33 34 35 36 37 | lappend vals [sqlite3_column_text $stmt $i] } return $rc } do_test bindxfer-1.1 { | < | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | lappend vals [sqlite3_column_text $stmt $i] } return $rc } do_test bindxfer-1.1 { set DB [sqlite3_connection_pointer db] execsql {CREATE TABLE t1(a,b,c);} set VM1 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL] set TAIL } {} do_test bindxfer-1.2 { sqlite3_bind_parameter_count $VM1 } 3 |
︙ | ︙ |
Changes to test/blob.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # 2001 September 15 # # 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. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 2001 September 15 # # 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. # # $Id: blob.test,v 1.5 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {!bloblit} { finish_test return |
︙ | ︙ | |||
100 101 102 103 104 105 106 | set blobs2 [list] foreach b $blobs {lappend blobs2 [bin_to_hex $b]} set blobs2 } {} # Try to bind a blob value to a prepared statement. do_test blob-3.0 { | | > | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | set blobs2 [list] foreach b $blobs {lappend blobs2 [bin_to_hex $b]} set blobs2 } {} # Try to bind a blob value to a prepared statement. do_test blob-3.0 { sqlite3 db2 test.db set DB [sqlite3_connection_pointer db2] set STMT [sqlite3_prepare $DB "DELETE FROM t1 WHERE a = ?" -1 DUMMY] sqlite3_bind_blob $STMT 1 "\x12\x34\x56" 3 sqlite3_step $STMT } {SQLITE_DONE} do_test blob-3.1 { sqlite3_finalize $STMT db2 close |
︙ | ︙ |
Changes to test/capi2.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 January 29 # # 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 testing the callback-free C/C++ API. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2003 January 29 # # 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 testing the callback-free C/C++ API. # # $Id: capi2.test,v 1.27 2006/01/03 00:33:50 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Return the text values from the current row pointed at by STMT as a list. proc get_row_values {STMT} { |
︙ | ︙ | |||
44 45 46 47 48 49 50 | } return $VALUES } # Check basic functionality # do_test capi2-1.1 { | < | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | } return $VALUES } # Check basic functionality # do_test capi2-1.1 { set DB [sqlite3_connection_pointer db] execsql {CREATE TABLE t1(a,b,c)} set VM [sqlite3_prepare $DB {SELECT name, rowid FROM sqlite_master} -1 TAIL] set TAIL } {} do_test capi2-1.2 { sqlite3_step $VM } {SQLITE_ROW} |
︙ | ︙ |
Changes to test/capi3.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 January 29 # # 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 testing the callback-free C/C++ API. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2003 January 29 # # 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 testing the callback-free C/C++ API. # # $Id: capi3.test,v 1.36 2006/01/03 00:33:50 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Return the UTF-16 representation of the supplied UTF-8 string $str. # If $nt is true, append two 0x00 bytes as a nul terminator. |
︙ | ︙ | |||
47 48 49 50 51 52 53 | # capi3-2.*: Test sqlite3_prepare16 # capi3-3.*: Test sqlite3_open # capi3-4.*: Test sqlite3_open16 # capi3-5.*: Test the various sqlite3_result_* APIs # capi3-6.*: Test that sqlite3_close fails if there are outstanding VMs. # | < | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # capi3-2.*: Test sqlite3_prepare16 # capi3-3.*: Test sqlite3_open # capi3-4.*: Test sqlite3_open16 # capi3-5.*: Test the various sqlite3_result_* APIs # capi3-6.*: Test that sqlite3_close fails if there are outstanding VMs. # set DB [sqlite3_connection_pointer db] do_test capi3-1.0 { sqlite3_get_autocommit $DB } 1 do_test capi3-1.1 { set STMT [sqlite3_prepare $DB {SELECT name FROM sqlite_master} -1 TAIL] sqlite3_finalize $STMT |
︙ | ︙ | |||
459 460 461 462 463 464 465 | sqlite3_finalize $STMT } SQLITE_OK set ::ENC [execsql {pragma encoding}] db close do_test capi3-6.0 { | > | > | 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 | sqlite3_finalize $STMT } SQLITE_OK set ::ENC [execsql {pragma encoding}] db close do_test capi3-6.0 { sqlite3 db test.db set DB [sqlite3_connection_pointer db] sqlite3_key $DB xyzzy set sql {SELECT a FROM t1 order by rowid} set STMT [sqlite3_prepare $DB $sql -1 TAIL] expr 0 } {0} do_test capi3-6.1 { sqlite3_close $DB } {SQLITE_BUSY} do_test capi3-6.2 { sqlite3_step $STMT } {SQLITE_ROW} check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1} do_test capi3-6.3 { sqlite3_finalize $STMT } {SQLITE_OK} do_test capi3-6.4 { sqlite3_close $DB } {SQLITE_OK} db close if {![sqlite3 -has-codec]} { # Test what happens when the library encounters a newer file format. # Do this by updating the file format via the btree layer. do_test capi3-7.1 { set ::bt [btree_open test.db 10 0] btree_begin_transaction $::bt |
︙ | ︙ | |||
606 607 608 609 610 611 612 | incr test_number } # Test the error message when a "real" out of memory occurs. if {[info command sqlite_malloc_stat]!=""} { set sqlite_malloc_fail 1 do_test capi3-10-1 { | | > | > | 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | incr test_number } # Test the error message when a "real" out of memory occurs. if {[info command sqlite_malloc_stat]!=""} { set sqlite_malloc_fail 1 do_test capi3-10-1 { sqlite3 db test.db set DB [sqlite3_connection_pointer db] sqlite_malloc_fail 1 catchsql { select * from sqlite_master; } } {1 {out of memory}} do_test capi3-10-2 { sqlite3_errmsg $::DB } {out of memory} ifcapable {utf16} { do_test capi3-10-3 { utf8 [sqlite3_errmsg16 $::DB] } {out of memory} } db close sqlite_malloc_fail 0 } # The following tests - capi3-11.* - test that a COMMIT or ROLLBACK # statement issued while there are still outstanding VMs that are part of # the transaction fails. sqlite3 db test.db set DB [sqlite3_connection_pointer db] sqlite_register_test_function $DB func do_test capi3-11.1 { execsql { BEGIN; CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 'int'); INSERT INTO t1 VALUES(2, 'notatype'); |
︙ | ︙ |
Changes to test/capi3b.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API and in # particular the behavior of sqlite3_step() when trying to commit # with lock contention. # | | < | | > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API and in # particular the behavior of sqlite3_step() when trying to commit # with lock contention. # # $Id: capi3b.test,v 1.3 2006/01/03 00:33:50 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl set DB [sqlite3_connection_pointer db] sqlite3 db2 test.db set DB2 [sqlite3_connection_pointer db2] # Create some data in the database # do_test capi3b-1.1 { execsql { CREATE TABLE t1(x); INSERT INTO t1 VALUES(1); |
︙ | ︙ |
Changes to test/delete.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # 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 file is testing the DELETE FROM statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # 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 file is testing the DELETE FROM statement. # # $Id: delete.test,v 1.21 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Try to delete from a non-existant table. # do_test delete-1.1 { |
︙ | ︙ | |||
273 274 275 276 277 278 279 | INSERT INTO t3 VALUES(123); SELECT * FROM t3; } } {123} db close catch {file attributes test.db -permissions 0444} catch {file attributes test.db -readonly 1} | | > | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | INSERT INTO t3 VALUES(123); SELECT * FROM t3; } } {123} db close catch {file attributes test.db -permissions 0444} catch {file attributes test.db -readonly 1} sqlite3 db test.db set ::DB [sqlite3_connection_pointer db] do_test delete-8.1 { catchsql { DELETE FROM t3; } } {1 {attempt to write a readonly database}} do_test delete-8.2 { execsql {SELECT * FROM t3} |
︙ | ︙ |
Changes to test/delete2.test.
︙ | ︙ | |||
25 26 27 28 29 30 31 | # index entry was deleted first, before the table entry. And the index # delete worked. Thus an entry was deleted from the index but not from # the table. # # The solution to the problem was to detect that the table is locked # before the index entry is deleted. # | | < | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # index entry was deleted first, before the table entry. And the index # delete worked. Thus an entry was deleted from the index but not from # the table. # # The solution to the problem was to detect that the table is locked # before the index entry is deleted. # # $Id: delete2.test,v 1.5 2006/01/03 00:33:50 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table that has an index. # do_test delete2-1.1 { set DB [sqlite3_connection_pointer db] execsql { CREATE TABLE q(s string, id string, constraint pk_q primary key(id)); BEGIN; INSERT INTO q(s,id) VALUES('hello','id.1'); INSERT INTO q(s,id) VALUES('goodbye','id.2'); INSERT INTO q(s,id) VALUES('again','id.3'); END; |
︙ | ︙ |
Changes to test/enc2.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. The focus of # this file is testing the SQLite routines used for converting between the # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # UTF-16be). # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. The focus of # this file is testing the SQLite routines used for converting between the # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # UTF-16be). # # $Id: enc2.test,v 1.25 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If UTF16 support is disabled, ignore the tests in this file # ifcapable {!utf16} { |
︙ | ︙ | |||
67 68 69 70 71 72 73 | # database, and that it is possible to retreive values in # various text encodings. # proc run_test_script {t enc} { # Open the database and pull out a (the) row. do_test $t.1 { | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | # database, and that it is possible to retreive values in # various text encodings. # proc run_test_script {t enc} { # Open the database and pull out a (the) row. do_test $t.1 { sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {SELECT * FROM t1} } {one I 1} # Insert some data do_test $t.2 { execsql {INSERT INTO t1 VALUES('two', 'II', 2);} execsql {SELECT * FROM t1} |
︙ | ︙ | |||
186 187 188 189 190 191 192 | set r [lsearch -exact $::values $rhs] set res [expr $l - $r] # puts "enc=$enc lhs=$lhs/$l rhs=$rhs/$r res=$res" return $res } file delete -force test.db | | | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | set r [lsearch -exact $::values $rhs] set res [expr $l - $r] # puts "enc=$enc lhs=$lhs/$l rhs=$rhs/$r res=$res" return $res } file delete -force test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] do_test enc2-5.0 { execsql { CREATE TABLE t5(a); INSERT INTO t5 VALUES('one'); INSERT INTO t5 VALUES('two'); INSERT INTO t5 VALUES('five'); INSERT INTO t5 VALUES('three'); |
︙ | ︙ | |||
215 216 217 218 219 220 221 | add_test_collate $DB 0 0 1 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] lappend res $::test_collate_enc } {one two three four five UTF-16BE} db close file delete -force test.db | | | 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | add_test_collate $DB 0 0 1 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] lappend res $::test_collate_enc } {one two three four five UTF-16BE} db close file delete -force test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {pragma encoding = 'UTF-16LE'} do_test enc2-5.4 { execsql { CREATE TABLE t5(a); INSERT INTO t5 VALUES('one'); INSERT INTO t5 VALUES('two'); INSERT INTO t5 VALUES('five'); |
︙ | ︙ | |||
245 246 247 248 249 250 251 | add_test_collate $DB 1 0 0 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] lappend res $::test_collate_enc } {one two three four five UTF-8} db close file delete -force test.db | | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | add_test_collate $DB 1 0 0 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] lappend res $::test_collate_enc } {one two three four five UTF-8} db close file delete -force test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {pragma encoding = 'UTF-16BE'} do_test enc2-5.8 { execsql { CREATE TABLE t5(a); INSERT INTO t5 VALUES('one'); INSERT INTO t5 VALUES('two'); INSERT INTO t5 VALUES('five'); |
︙ | ︙ | |||
293 294 295 296 297 298 299 | set ::sqlite_last_needed_collation } test_collate db close file delete -force test.db do_test enc2-5.15 { | | | | | | | | | | | | 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 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 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | set ::sqlite_last_needed_collation } test_collate db close file delete -force test.db do_test enc2-5.15 { sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db] add_test_collate_needed $::DB set ::sqlite_last_needed_collation } {} do_test enc2-5.16 { execsql {CREATE TABLE t1(a varchar collate test_collate);} } {} do_test enc2-5.17 { set ::sqlite_last_needed_collation } {test_collate} # The following tests - enc2-6.* - test that SQLite selects the correct # user function when more than one is available. proc test_function {enc arg} { return "$enc $arg" } file delete -force test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {pragma encoding = 'UTF-8'} do_test enc2-6.0 { execsql { CREATE TABLE t5(a); INSERT INTO t5 VALUES('one'); } } {} do_test enc2-6.1 { add_test_function $DB 1 1 1 execsql { SELECT test_function('sqlite') } } {{UTF-8 sqlite}} db close sqlite3 db test.db; set DB [sqlite3_connection_pointer db] do_test enc2-6.2 { add_test_function $DB 0 1 0 execsql { SELECT test_function('sqlite') } } {{UTF-16LE sqlite}} db close sqlite3 db test.db; set DB [sqlite3_connection_pointer db] do_test enc2-6.3 { add_test_function $DB 0 0 1 execsql { SELECT test_function('sqlite') } } {{UTF-16BE sqlite}} db close file delete -force test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {pragma encoding = 'UTF-16LE'} do_test enc2-6.3 { execsql { CREATE TABLE t5(a); INSERT INTO t5 VALUES('sqlite'); } } {} do_test enc2-6.4 { add_test_function $DB 1 1 1 execsql { SELECT test_function('sqlite') } } {{UTF-16LE sqlite}} db close sqlite3 db test.db; set DB [sqlite3_connection_pointer db] do_test enc2-6.5 { add_test_function $DB 0 1 0 execsql { SELECT test_function('sqlite') } } {{UTF-16LE sqlite}} db close sqlite3 db test.db; set DB [sqlite3_connection_pointer db] do_test enc2-6.6 { add_test_function $DB 0 0 1 execsql { SELECT test_function('sqlite') } } {{UTF-16BE sqlite}} db close file delete -force test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {pragma encoding = 'UTF-16BE'} do_test enc2-6.7 { execsql { CREATE TABLE t5(a); INSERT INTO t5 VALUES('sqlite'); } } {} do_test enc2-6.8 { add_test_function $DB 1 1 1 execsql { SELECT test_function('sqlite') } } {{UTF-16BE sqlite}} db close sqlite3 db test.db; set DB [sqlite3_connection_pointer db] do_test enc2-6.9 { add_test_function $DB 0 1 0 execsql { SELECT test_function('sqlite') } } {{UTF-16LE sqlite}} db close sqlite3 db test.db; set DB [sqlite3_connection_pointer db] do_test enc2-6.10 { add_test_function $DB 0 0 1 execsql { SELECT test_function('sqlite') } } {{UTF-16BE sqlite}} |
︙ | ︙ |
Changes to test/func.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # 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 file is testing built-in functions. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # 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 file is testing built-in functions. # # $Id: func.test,v 1.43 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # do_test func-0.0 { |
︙ | ︙ | |||
291 292 293 294 295 296 297 | } {1} # Use the "sqlite_register_test_function" TCL command which is part of # the text fixture in order to verify correct operation of some of # the user-defined SQL function APIs that are not used by the built-in # functions. # | < | | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | } {1} # Use the "sqlite_register_test_function" TCL command which is part of # the text fixture in order to verify correct operation of some of # the user-defined SQL function APIs that are not used by the built-in # functions. # set ::DB [sqlite3_connection_pointer db] sqlite_register_test_function $::DB testfunc do_test func-10.1 { catchsql { SELECT testfunc(NULL,NULL); } } {1 {first argument should be one of: int int64 string double null value}} do_test func-10.2 { |
︙ | ︙ | |||
437 438 439 440 441 442 443 | execsql { SELECT test_auxdata('hello'||'world', a) FROM t4; } } {{0 0} {1 0}} # Test that auxilary data is preserved between calls for SQL variables. do_test func-13.7 { | < | | 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | execsql { SELECT test_auxdata('hello'||'world', a) FROM t4; } } {{0 0} {1 0}} # Test that auxilary data is preserved between calls for SQL variables. do_test func-13.7 { set DB [sqlite3_connection_pointer db] set sql "SELECT test_auxdata( ? , a ) FROM t4;" set STMT [sqlite3_prepare $DB $sql -1 TAIL] sqlite3_bind_text $STMT 1 hello -1 set res [list] while { "SQLITE_ROW"==[sqlite3_step $STMT] } { lappend res [sqlite3_column_text $STMT 0] } |
︙ | ︙ |
Changes to test/interrupt.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2004 Feb 8 # # 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 sqlite_interrupt() API. # | | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # 2004 Feb 8 # # 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 sqlite_interrupt() API. # # $Id: interrupt.test,v 1.12 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl set DB [sqlite3_connection_pointer db] # Compute a checksum on the entire database. # proc cksum {{db db}} { set txt [$db eval {SELECT name, type, sql FROM sqlite_master}]\n foreach tbl [$db eval {SELECT name FROM sqlite_master WHERE type='table'}] { append txt [$db eval "SELECT * FROM $tbl"]\n |
︙ | ︙ |
Changes to test/misc4.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # | | < | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc4.test,v 1.21 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Prepare a statement that will create a temporary table. Then do # a rollback. Then try to execute the prepared statement. # do_test misc4-1.1 { set DB [sqlite3_connection_pointer db] execsql { CREATE TABLE t1(x); INSERT INTO t1 VALUES(1); } } {} ifcapable tempdb { |
︙ | ︙ |
Changes to test/misuse.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the SQLITE_MISUSE detection logic. # This test file leaks memory and file descriptors. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the SQLITE_MISUSE detection logic. # This test file leaks memory and file descriptors. # # $Id: misuse.test,v 1.11 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl proc catchsql2 {sql} { set r [ catch { |
︙ | ︙ | |||
37 38 39 40 41 42 43 | # Make sure the test logic works # do_test misuse-1.1 { db close catch {file delete -force test2.db} catch {file delete -force test2.db-journal} | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # Make sure the test logic works # do_test misuse-1.1 { db close catch {file delete -force test2.db} catch {file delete -force test2.db-journal} sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db] execsql { CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2); } catchsql2 { SELECT * FROM t1 } |
︙ | ︙ | |||
85 86 87 88 89 90 91 | } } {0 {1 2}} # Attempt to register a new SQL function while an sqlite_exec() is active. # do_test misuse-2.1 { db close | | | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | } } {0 {1 2}} # Attempt to register a new SQL function while an sqlite_exec() is active. # do_test misuse-2.1 { db close sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db] execsql { SELECT * FROM t1 } } {1 2} do_test misuse-2.2 { catchsql2 {SELECT * FROM t1} } {0 {a b 1 2}} |
︙ | ︙ | |||
117 118 119 120 121 122 123 | } } {0 {1 2}} # Attempt to register a new SQL aggregate while an sqlite_exec() is active. # do_test misuse-3.1 { db close | | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | } } {0 {1 2}} # Attempt to register a new SQL aggregate while an sqlite_exec() is active. # do_test misuse-3.1 { db close sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db] execsql { SELECT * FROM t1 } } {1 2} do_test misuse-3.2 { catchsql2 {SELECT * FROM t1} } {0 {a b 1 2}} |
︙ | ︙ | |||
151 152 153 154 155 156 157 | # Attempt to close the database from an sqlite_exec callback. # # Update for v3: The db cannot be closed because there are active # VMs. The sqlite3_close call would return SQLITE_BUSY. do_test misuse-4.1 { db close | | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | # Attempt to close the database from an sqlite_exec callback. # # Update for v3: The db cannot be closed because there are active # VMs. The sqlite3_close call would return SQLITE_BUSY. do_test misuse-4.1 { db close sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db] execsql { SELECT * FROM t1 } } {1 2} do_test misuse-4.2 { catchsql2 {SELECT * FROM t1} } {0 {a b 1 2}} |
︙ | ︙ | |||
184 185 186 187 188 189 190 | } } {1 {library routine called out of sequence}} # Attempt to use a database after it has been closed. # do_test misuse-5.1 { db close | | | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | } } {1 {library routine called out of sequence}} # Attempt to use a database after it has been closed. # do_test misuse-5.1 { db close sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db] execsql { SELECT * FROM t1 } } {1 2} do_test misuse-5.2 { catchsql2 {SELECT * FROM t1} } {0 {a b 1 2}} |
︙ | ︙ |
Changes to test/pragma.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the PRAGMA command. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the PRAGMA command. # # $Id: pragma.test,v 1.37 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Test organization: # # pragma-1.*: Test cache_size, default_cache_size and synchronous on main db. |
︙ | ︙ | |||
34 35 36 37 38 39 40 | # # Delete the preexisting database to avoid the special setup # that the "all.test" script does. # db close file delete test.db | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # # Delete the preexisting database to avoid the special setup # that the "all.test" script does. # db close file delete test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] ifcapable pager_pragmas { do_test pragma-1.1 { execsql { PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; |
︙ | ︙ | |||
105 106 107 108 109 110 111 | PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; } } {123 123 2} do_test pragma-1.9.1 { db close | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; } } {123 123 2} do_test pragma-1.9.1 { db close sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db] execsql { PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; } } {123 123 2} ifcapable vacuum { |
︙ | ︙ | |||
140 141 142 143 144 145 146 | PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; } } {123 123 2} do_test pragma-1.12 { db close | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; } } {123 123 2} do_test pragma-1.12 { db close sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db] execsql { PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; } } {123 123 2} |
︙ | ︙ | |||
458 459 460 461 462 463 464 | } 107 # Now open a second connection to the database. Ensure that changing the # schema-version using the first connection forces the second connection # to reload the schema. This has to be done using the C-API test functions, # because the TCL API accounts for SCHEMA_ERROR and retries the query. do_test pragma-8.1.7 { | | | 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | } 107 # Now open a second connection to the database. Ensure that changing the # schema-version using the first connection forces the second connection # to reload the schema. This has to be done using the C-API test functions, # because the TCL API accounts for SCHEMA_ERROR and retries the query. do_test pragma-8.1.7 { sqlite3 db2 test.db; set ::DB2 [sqlite3_connection_pointer db2] execsql { SELECT * FROM t4; } db2 } {1 2 3} do_test pragma-8.1.8 { execsql { PRAGMA schema_version = 108; |
︙ | ︙ | |||
500 501 502 503 504 505 506 | PRAGMA schema_version; } } 108 # And check that modifying the schema-version in an attached database # forces the second connection to reload the schema. do_test pragma-8.1.14 { | | | 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | PRAGMA schema_version; } } 108 # And check that modifying the schema-version in an attached database # forces the second connection to reload the schema. do_test pragma-8.1.14 { sqlite3 db2 test.db; set ::DB2 [sqlite3_connection_pointer db2] execsql { ATTACH 'test2.db' AS aux; SELECT * FROM aux.t1; } db2 } {} do_test pragma-8.1.15 { execsql { |
︙ | ︙ |
Changes to test/rollback.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is verifying that a rollback in one statement # caused by an ON CONFLICT ROLLBACK clause aborts any other pending # statements. # | | < | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is verifying that a rollback in one statement # caused by an ON CONFLICT ROLLBACK clause aborts any other pending # statements. # # $Id: rollback.test,v 1.3 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl set DB [sqlite3_connection_pointer db] do_test rollback-1.1 { execsql { CREATE TABLE t1(a); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); |
︙ | ︙ |
Changes to test/safety.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the sqlite3SafetyOn and sqlite3SafetyOff # functions. Those routines are not strictly necessary - they are # designed to detect misuse of the library. # | | < | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the sqlite3SafetyOn and sqlite3SafetyOff # functions. Those routines are not strictly necessary - they are # designed to detect misuse of the library. # # $Id: safety.test,v 1.2 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test safety-1.1 { set DB [sqlite3_connection_pointer db] db eval {CREATE TABLE t1(a)} sqlite_set_magic $DB SQLITE_MAGIC_BUSY catchsql { SELECT name FROM sqlite_master; } } {1 {library routine called out of sequence}} do_test safety-1.2 { |
︙ | ︙ |
Changes to test/tester.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # 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 some common TCL routines used for regression # testing the SQLite library # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # 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 some common TCL routines used for regression # testing the SQLite library # # $Id: tester.tcl,v 1.56 2006/01/03 00:33:50 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 *****" |
︙ | ︙ | |||
57 58 59 60 61 62 63 | # Create a test database # catch {db close} file delete -force test.db file delete -force test.db-journal | | > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # Create a test database # catch {db close} file delete -force test.db file delete -force test.db-journal sqlite3 db ./test.db set ::DB [sqlite3_connection_pointer db] if {[info exists ::SETUP_SQL]} { db eval $::SETUP_SQL } # Abort early if this script has been run before. # if {[info exists nTest]} return |
︙ | ︙ |
Changes to test/trace.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the "sqlite3_trace()" API. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the "sqlite3_trace()" API. # # $Id: trace.test,v 1.6 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !trace { finish_test return |
︙ | ︙ | |||
49 50 51 52 53 54 55 | db trace } {} # If we prepare a statement and execute it multiple times, the trace # happens on each execution. # db close | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | db trace } {} # If we prepare a statement and execute it multiple times, the trace # happens on each execution. # db close sqlite3 db test.db; set DB [sqlite3_connection_pointer db] do_test trace-2.1 { set STMT [sqlite3_prepare $DB {INSERT INTO t1 VALUES(2,3)} -1 TAIL] db trace trace_proc proc trace_proc sql { global TRACE_OUT set TRACE_OUT $sql } |
︙ | ︙ | |||
112 113 114 115 116 117 118 | db profile } {} # If we prepare a statement and execute it multiple times, the profile # happens on each execution. # db close | | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | db profile } {} # If we prepare a statement and execute it multiple times, the profile # happens on each execution. # db close sqlite3 db test.db; set DB [sqlite3_connection_pointer db] do_test trace-4.1 { set STMT [sqlite3_prepare $DB {INSERT INTO t2 VALUES(2,3)} -1 TAIL] db trace trace_proc proc profile_proc {sql tm} { global TRACE_OUT set TRACE_OUT $sql } |
︙ | ︙ |
Changes to test/vacuum.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # 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 file is testing the VACUUM statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # 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 file is testing the VACUUM statement. # # $Id: vacuum.test,v 1.36 2006/01/03 00:33:50 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If the VACUUM statement is disabled in the current build, skip all # the tests in this file. # |
︙ | ︙ | |||
213 214 215 216 217 218 219 | } } {} # Ticket #464. Make sure VACUUM works with the sqlite3_prepare() API. # do_test vacuum-4.1 { db close | | | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | } } {} # Ticket #464. Make sure VACUUM works with the sqlite3_prepare() API. # do_test vacuum-4.1 { db close sqlite3 db test.db; set DB [sqlite3_connection_pointer db] set VM [sqlite3_prepare $DB {VACUUM} -1 TAIL] sqlite3_step $VM } {SQLITE_DONE} do_test vacuum-4.2 { sqlite3_finalize $VM } SQLITE_OK |
︙ | ︙ |