Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fixes for compilation/testing when the various OMIT macros are defined. (CVS 4423) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
c8405b15c074c94dab5e33272cf1471f |
User & Date: | danielk1977 2007-09-12 17:01:45.000 |
Context
2007-09-13
| ||
17:54 | Fix incorrect index cost assumptions that occur after an ANALYZE. Ticket #2643. (CVS 4424) (check-in: 2cfdbfe654 user: drh tags: trunk) | |
2007-09-12
| ||
17:01 | Fixes for compilation/testing when the various OMIT macros are defined. (CVS 4423) (check-in: c8405b15c0 user: danielk1977 tags: trunk) | |
15:41 | In the query optimizer, make sure table dependencies from all terms of a compound SELECT statement are recognized so that subqueries in a WHERE clause are not evaluated too early. Fix for ticket #2640. (CVS 4422) (check-in: 9c9c2a1da2 user: drh tags: trunk) | |
Changes
Changes to src/btree.c.
1 2 3 4 5 6 7 8 9 10 11 | /* ** 2004 April 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. ** ************************************************************************* | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* ** 2004 April 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. ** ************************************************************************* ** $Id: btree.c,v 1.426 2007/09/12 17:01:45 danielk1977 Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. ** Including a description of file format and an overview of operation. */ #include "btreeInt.h" |
︙ | ︙ | |||
6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 | rc = pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR; }else{ assert( pBt->pPage1!=0 ); pP1 = pBt->pPage1->aData; rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); if( rc==SQLITE_OK ){ put4byte(&pP1[36 + idx*4], iMeta); if( idx==7 ){ assert( pBt->autoVacuum || iMeta==0 ); assert( iMeta==0 || iMeta==1 ); pBt->incrVacuum = iMeta; } } } sqlite3BtreeLeave(p); return rc; } /* | > > | 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 | rc = pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR; }else{ assert( pBt->pPage1!=0 ); pP1 = pBt->pPage1->aData; rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); if( rc==SQLITE_OK ){ put4byte(&pP1[36 + idx*4], iMeta); #ifndef SQLITE_OMIT_AUTOVACUUM if( idx==7 ){ assert( pBt->autoVacuum || iMeta==0 ); assert( iMeta==0 || iMeta==1 ); pBt->incrVacuum = iMeta; } #endif } } sqlite3BtreeLeave(p); return rc; } /* |
︙ | ︙ |
Changes to src/date.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: date.c,v 1.73 2007/09/12 17:01:45 danielk1977 Exp $ ** ** SQLite processes all times and dates as Julian Day numbers. The ** dates and times are stored as the number of days since noon ** in Greenwich on November 24, 4714 B.C. according to the Gregorian ** calendar system. ** ** 1970-01-01 00:00:00 is JD 2440587.5 |
︙ | ︙ | |||
984 985 986 987 988 989 990 | struct tm sNow; gmtime_r(&t, &sNow); strftime(zBuf, 20, zFormat, &sNow); } #else { struct tm *pTm; | | | | 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 | struct tm sNow; gmtime_r(&t, &sNow); strftime(zBuf, 20, zFormat, &sNow); } #else { struct tm *pTm; sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER)); pTm = gmtime(&t); strftime(zBuf, 20, zFormat, pTm); sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER)); } #endif sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); } #endif |
︙ | ︙ |
Changes to src/test3.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the btree.c module in 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 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the btree.c module in SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test3.c,v 1.87 2007/09/12 17:01:45 danielk1977 Exp $ */ #include "sqliteInt.h" #include "btreeInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
1394 1395 1396 1397 1398 1399 1400 | pPager = sqlite3BtreePager(pBt); rc = sqlite3BtreeCursorInfo(pCur, aResult, 0); if( rc ){ Tcl_AppendResult(interp, errorName(rc), 0); sqlite3BtreeLeave(pBt); return TCL_ERROR; } | | | 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 | pPager = sqlite3BtreePager(pBt); rc = sqlite3BtreeCursorInfo(pCur, aResult, 0); if( rc ){ Tcl_AppendResult(interp, errorName(rc), 0); sqlite3BtreeLeave(pBt); return TCL_ERROR; } dataSize = pBt->pBt->usableSize; Tcl_DStringInit(&str); n = aResult[6] - aResult[8]; n = (n + dataSize - 1)/dataSize; pgno = (u32)aResult[10]; while( pgno && n-- ){ DbPage *pDbPage; sprintf(zElem, "%d", pgno); |
︙ | ︙ |
Changes to src/test7.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the client/server version of the SQLite library. ** Derived from test4.c. ** | | < | > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the client/server version of the SQLite library. ** Derived from test4.c. ** ** $Id: test7.c,v 1.9 2007/09/12 17:01:45 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" /* ** This test only works on UNIX with a SQLITE_THREADSAFE build that includes ** the SQLITE_SERVER option. */ #if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE) #if defined(OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE #include <stdlib.h> #include <string.h> #include <pthread.h> #include <sched.h> #include <ctype.h> |
︙ | ︙ | |||
717 718 719 720 721 722 723 | Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); } return TCL_OK; } #else int Sqlitetest7_Init(Tcl_Interp *interp){ return TCL_OK; } #endif /* OS_UNIX */ | > | 717 718 719 720 721 722 723 724 | Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); } return TCL_OK; } #else int Sqlitetest7_Init(Tcl_Interp *interp){ return TCL_OK; } #endif /* OS_UNIX */ #endif |
Changes to src/test_server.c.
︙ | ︙ | |||
191 192 193 194 195 196 197 198 199 200 201 202 203 204 | ** or deallocate memory. In the case of sqlite3_bind_int(), if the ** parameter was previously bound to a string that string might need ** to be deallocated before the new integer value is inserted. In ** the case of sqlite3_column_int(), the value of the column might be ** a UTF-16 string which will need to be converted to UTF-8 then into ** an integer. */ /* ** Only compile the code in this file on UNIX with a SQLITE_THREADSAFE build ** and only if the SQLITE_SERVER macro is defined. */ #if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE) #if defined(OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE | > > > > > | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | ** or deallocate memory. In the case of sqlite3_bind_int(), if the ** parameter was previously bound to a string that string might need ** to be deallocated before the new integer value is inserted. In ** the case of sqlite3_column_int(), the value of the column might be ** a UTF-16 string which will need to be converted to UTF-8 then into ** an integer. */ /* Include this to get the definition of SQLITE_THREADSAFE, in the ** case that default values are used. */ #include "sqliteInt.h" /* ** Only compile the code in this file on UNIX with a SQLITE_THREADSAFE build ** and only if the SQLITE_SERVER macro is defined. */ #if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE) #if defined(OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE |
︙ | ︙ |
Changes to src/utf.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** ** $Id: utf.c,v 1.58 2007/09/12 17:01:45 danielk1977 Exp $ ** ** Notes on UTF-8: ** ** Byte-0 Byte-1 Byte-2 Byte-3 Value ** 0xxxxxxx 00000000 00000000 0xxxxxxx ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx |
︙ | ︙ | |||
398 399 400 401 402 403 404 405 406 407 408 409 410 411 | assert( z<=zTerm ); while( *z!=0 && z<zTerm ){ SQLITE_SKIP_UTF8(z); r++; } return r; } #ifndef SQLITE_OMIT_UTF16 /* ** Convert a UTF-16 string in the native encoding into a UTF-8 string. ** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must ** be freed by the calling function. ** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | assert( z<=zTerm ); while( *z!=0 && z<zTerm ){ SQLITE_SKIP_UTF8(z); r++; } return r; } /* This test function is not currently used by the automated test-suite. ** Hence it is only available in debug builds. */ #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG) /* ** Translate UTF-8 to UTF-8. ** ** This has the effect of making sure that the string is well-formed ** UTF-8. Miscoded characters are removed. ** ** The translation is done in-place (since it is impossible for the ** correct UTF-8 encoding to be longer than a malformed encoding). */ int sqlite3Utf8To8(unsigned char *zIn){ unsigned char *zOut = zIn; unsigned char *zStart = zIn; unsigned char *zTerm; u32 c; while( zIn[0] ){ c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); if( c!=0xfffd ){ WRITE_UTF8(zOut, c); } } *zOut = 0; return zOut - zStart; } #endif #ifndef SQLITE_OMIT_UTF16 /* ** Convert a UTF-16 string in the native encoding into a UTF-8 string. ** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must ** be freed by the calling function. ** |
︙ | ︙ | |||
452 453 454 455 456 457 458 | READ_UTF16LE(z, c); n++; } } return (z-(char const *)zIn)-((c==0)?2:0); } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | READ_UTF16LE(z, c); n++; } } return (z-(char const *)zIn)-((c==0)?2:0); } #if defined(SQLITE_TEST) /* ** This routine is called from the TCL test function "translate_selftest". ** It checks that the primitives for serializing and deserializing ** characters in each encoding are inverses of each other. */ void sqlite3UtfSelfTest(){ |
︙ | ︙ |
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.9 2007/09/12 17:01:45 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # We have to have pragmas in order to do this test ifcapable {!pragma} return |
︙ | ︙ | |||
64 65 66 67 68 69 70 | # This procedure sets the SQL statement stored for table $tbl in the # sqlite_master table of file 'test.db' to $sql. Also set the file format # to the supplied value. This is 2 if the added column has a default that is # NULL, or 3 otherwise. # proc alter_table {tbl sql {file_format 2}} { sqlite3 dbat test.db | > > | | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | # This procedure sets the SQL statement stored for table $tbl in the # sqlite_master table of file 'test.db' to $sql. Also set the file format # to the supplied value. This is 2 if the added column has a default that is # NULL, or 3 otherwise. # proc alter_table {tbl sql {file_format 2}} { sqlite3 dbat test.db set s [string map {' ''} $sql] set t [string map {' ''} $tbl] dbat eval [subst { PRAGMA writable_schema = 1; UPDATE sqlite_master SET sql = '$s' WHERE name = '$t' AND type = 'table'; PRAGMA writable_schema = 0; }] dbat close set_file_format 2 } #----------------------------------------------------------------------- # Some basic tests to make sure short rows are handled. # |
︙ | ︙ | |||
255 256 257 258 259 260 261 | } {SQLITE_ERROR} #--------------------------------------------------------------------- # Check that executing VACUUM on a file with file-format version 2 # resets the file format to 1. # set default_file_format [expr $SQLITE_DEFAULT_FILE_FORMAT==4 ? 4 : 1] | > | | | | | | | | | | | | > | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | } {SQLITE_ERROR} #--------------------------------------------------------------------- # Check that executing VACUUM on a file with file-format version 2 # resets the file format to 1. # set default_file_format [expr $SQLITE_DEFAULT_FILE_FORMAT==4 ? 4 : 1] ifcapable vacuum { do_test alter2-5.1 { set_file_format 2 get_file_format } {2} do_test alter2-5.2 { execsql { VACUUM; } } {} do_test alter2-5.3 { get_file_format } $default_file_format } #--------------------------------------------------------------------- # 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 |
︙ | ︙ | |||
393 394 395 396 397 398 399 | set ::val } {-123 integer 5 text} } #----------------------------------------------------------------------- # Test creating an index on a column added with a default value. # | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | set ::val } {-123 integer 5 text} } #----------------------------------------------------------------------- # Test creating an index on a column added with a default value. # ifcapable bloblit { do_test alter2-10.1 { execsql { CREATE TABLE t2(a); INSERT INTO t2 VALUES('a'); INSERT INTO t2 VALUES('b'); INSERT INTO t2 VALUES('c'); INSERT INTO t2 VALUES('d'); } alter_table t2 {CREATE TABLE t2(a, b DEFAULT X'ABCD', c DEFAULT NULL);} 3 catchsql { SELECT * FROM sqlite_master; } execsql { SELECT quote(a), quote(b), quote(c) FROM t2 LIMIT 1; } } {'a' X'ABCD' NULL} do_test alter2-10.2 { execsql { CREATE INDEX i1 ON t2(b); SELECT a FROM t2 WHERE b = X'ABCD'; } } {a b c d} do_test alter2-10.3 { execsql { DELETE FROM t2 WHERE a = 'c'; SELECT a FROM t2 WHERE b = X'ABCD'; } } {a b d} do_test alter2-10.4 { execsql { SELECT count(b) FROM t2 WHERE b = X'ABCD'; } } {3} } finish_test |
Changes to test/attach.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: attach.test,v 1.46 2007/09/12 17:01:45 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl for {set i 2} {$i<=15} {incr i} { file delete -force test$i.db |
︙ | ︙ | |||
732 733 734 735 736 737 738 | for {set i 2} {$i<=15} {incr i} { catch {db$i close} } db close file delete -force test2.db file delete -force no-such-file | > | | | | | | | | | > | 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | for {set i 2} {$i<=15} {incr i} { catch {db$i close} } db close file delete -force test2.db file delete -force no-such-file ifcapable subquery { do_test attach-7.1 { file delete -force test.db test.db-journal sqlite3 db test.db catchsql { DETACH RAISE ( IGNORE ) IN ( SELECT "AAAAAA" . * ORDER BY REGISTER LIMIT "AAAAAA" . "AAAAAA" OFFSET RAISE ( IGNORE ) NOT NULL ) } } {1 {invalid name: "RAISE ( IGNORE ) IN ( SELECT "AAAAAA" . * ORDER BY REGISTER LIMIT "AAAAAA" . "AAAAAA" OFFSET RAISE ( IGNORE ) NOT NULL )"}} } finish_test |
Changes to test/avtrans.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 is a copy of "trans.test" modified to run under autovacuum mode. # the point is to stress the autovacuum logic and try to get it to fail. # | | | 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 is a copy of "trans.test" modified to run under autovacuum mode. # the point is to stress the autovacuum logic and try to get it to fail. # # $Id: avtrans.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create several tables to work with. |
︙ | ︙ | |||
905 906 907 908 909 910 911 | } 1 ifcapable pager_pragmas { do_test avtrans-9.$i.5-$cnt { expr {$sqlite_fullsync_count>0} } [expr {$i%2==0}] } else { do_test avtrans-9.$i.5-$cnt { | | | 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 | } 1 ifcapable pager_pragmas { do_test avtrans-9.$i.5-$cnt { expr {$sqlite_fullsync_count>0} } [expr {$i%2==0}] } else { do_test avtrans-9.$i.5-$cnt { expr {$sqlite_fullsync_count==0} } {1} } } } set ::pager_old_format 0 } integrity_check avtrans-10.1 finish_test |
Changes to test/badutf.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file checks to make sure SQLite is able to gracefully # handle malformed UTF-8. # | | | 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 checks to make sure SQLite is able to gracefully # handle malformed UTF-8. # # $Id: badutf.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test badutf-1.1 { db eval {PRAGMA encoding=UTF8} sqlite3_exec db {SELECT hex('%80') AS x} |
︙ | ︙ | |||
37 38 39 40 41 42 43 | do_test badutf-1.6 { sqlite3_exec db {SELECT hex('%f0') AS x} } {0 {x F0}} do_test badutf-1.7 { sqlite3_exec db {SELECT hex('%ff') AS x} } {0 {x FF}} | < | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | | | | | | > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | do_test badutf-1.6 { sqlite3_exec db {SELECT hex('%f0') AS x} } {0 {x F0}} do_test badutf-1.7 { sqlite3_exec db {SELECT hex('%ff') AS x} } {0 {x FF}} sqlite3 db2 {} ifcapable utf16 { do_test badutf-1.10 { db2 eval {PRAGMA encoding=UTF16be} sqlite3_exec db2 {SELECT hex('%80') AS x} } {0 {x 0080}} do_test badutf-1.11 { sqlite3_exec db2 {SELECT hex('%81') AS x} } {0 {x 0081}} do_test badutf-1.12 { sqlite3_exec db2 {SELECT hex('%bf') AS x} } {0 {x 00BF}} do_test badutf-1.13 { sqlite3_exec db2 {SELECT hex('%c0') AS x} } {0 {x FFFD}} do_test badutf-1.14 { sqlite3_exec db2 {SELECT hex('%c1') AS x} } {0 {x FFFD}} do_test badutf-1.15 { sqlite3_exec db2 {SELECT hex('%c0%bf') AS x} } {0 {x FFFD}} do_test badutf-1.16 { sqlite3_exec db2 {SELECT hex('%c1%bf') AS x} } {0 {x FFFD}} do_test badutf-1.17 { sqlite3_exec db2 {SELECT hex('%c3%bf') AS x} } {0 {x 00FF}} do_test badutf-1.18 { sqlite3_exec db2 {SELECT hex('%e0') AS x} } {0 {x FFFD}} do_test badutf-1.19 { sqlite3_exec db2 {SELECT hex('%f0') AS x} } {0 {x FFFD}} do_test badutf-1.20 { sqlite3_exec db2 {SELECT hex('%ff') AS x} } {0 {x FFFD}} } ifcapable bloblit { do_test badutf-2.1 { sqlite3_exec db {SELECT '%80'=CAST(x'80' AS text) AS x} } {0 {x 1}} do_test badutf-2.2 { sqlite3_exec db {SELECT CAST('%80' AS blob)=x'80' AS x} } {0 {x 1}} } do_test badutf-3.1 { sqlite3_exec db {SELECT length('%80') AS x} } {0 {x 1}} do_test badutf-3.2 { sqlite3_exec db {SELECT length('%61%62%63') AS x} } {0 {x 3}} |
︙ | ︙ |
Changes to test/createtab.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 file is testing that it is OK to create new tables # and indices while creating existing tables and indices. # | | | 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 file is testing that it is OK to create new tables # and indices while creating existing tables and indices. # # $Id: createtab.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable autovacuum { set upperBound 2 } else { |
︙ | ︙ | |||
41 42 43 44 45 46 47 48 49 | INSERT INTO t1 VALUES(1, hex(randomblob(200))); INSERT INTO t1 VALUES(2, hex(randomblob(200))); INSERT INTO t1 VALUES(3, hex(randomblob(200))); INSERT INTO t1 VALUES(4, hex(randomblob(200))); SELECT count(*) FROM t1; } } {4} do_test createtab-$av.2 { file size test.db | > > > > > > | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | INSERT INTO t1 VALUES(1, hex(randomblob(200))); INSERT INTO t1 VALUES(2, hex(randomblob(200))); INSERT INTO t1 VALUES(3, hex(randomblob(200))); INSERT INTO t1 VALUES(4, hex(randomblob(200))); SELECT count(*) FROM t1; } } {4} set isUtf16 0 ifcapable utf16 { set isUtf16 [expr {[execsql {PRAGMA encoding}] != "UTF-8"}] } do_test createtab-$av.2 { file size test.db } [expr {1024*(4+($av!=0)+(${isUtf16}*2))}] # Start reading the table # do_test createtab-$av.3 { set STMT [sqlite3_prepare db {SELECT x FROM t1} -1 TAIL] sqlite3_step $STMT } {SQLITE_ROW} |
︙ | ︙ |
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.69 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # do_test func-0.0 { |
︙ | ︙ | |||
320 321 322 323 324 325 326 | } } {32 1 2000} # The "hex()" function was added in order to be able to render blobs # generated by randomblob(). So this seems like a good place to test # hex(). # | > | | | > | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | } } {32 1 2000} # The "hex()" function was added in order to be able to render blobs # generated by randomblob(). So this seems like a good place to test # hex(). # ifcapable bloblit { do_test func-9.10 { execsql {SELECT hex(x'00112233445566778899aAbBcCdDeEfF')} } {00112233445566778899AABBCCDDEEFF} } set encoding [db one {PRAGMA encoding}] if {$encoding=="UTF-16le"} { do_test func-9.11-utf16le { execsql {SELECT hex(replace('abcdefg','ef','12'))} } {6100620063006400310032006700} do_test func-9.12-utf16le { execsql {SELECT hex(replace('abcdefg','','12'))} |
︙ | ︙ | |||
793 794 795 796 797 798 799 | } {{This is the larger-main test string}} do_test func-21.8 { execsql { SELECT replace("aaaaaaa", "a", "0123456789"); } } {0123456789012345678901234567890123456789012345678901234567890123456789} | > | | | | | | | | | > | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | } {{This is the larger-main test string}} do_test func-21.8 { execsql { SELECT replace("aaaaaaa", "a", "0123456789"); } } {0123456789012345678901234567890123456789012345678901234567890123456789} ifcapable tclvar { do_test func-21.9 { # Attempt to exploit a buffer-overflow that at one time existed # in the REPLACE function. set ::str "[string repeat A 29998]CC[string repeat A 35537]" set ::rep [string repeat B 65536] execsql { SELECT LENGTH(REPLACE($::str, 'C', $::rep)); } } [expr 29998 + 2*65536 + 35537] } # Tests for the TRIM, LTRIM and RTRIM functions. # do_test func-22.1 { catchsql {SELECT trim(1,2,3)} } {1 {wrong number of arguments to function trim()}} do_test func-22.2 { |
︙ | ︙ |
Changes to test/incrblob_err.test.
1 2 3 4 5 6 7 8 9 10 11 | # 2007 May 1 # # 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. # #*********************************************************************** # | | | | 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 | # 2007 May 1 # # 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. # #*********************************************************************** # # $Id: incrblob_err.test,v 1.8 2007/09/12 17:01:45 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {!incrblob || !memdebug || !tclvar} { finish_test return } source $testdir/malloc_common.tcl set ::fd [open [info script]] |
︙ | ︙ |
Changes to test/insert3.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2005 January 13 # # 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 corner cases of the INSERT statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2005 January 13 # # 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 corner cases of the INSERT statement. # # $Id: insert3.test,v 1.7 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # All the tests in this file require trigger support # ifcapable {trigger} { |
︙ | ︙ | |||
152 153 154 155 156 157 158 | } {1 xyz} do_test insert3-3.6 { execsql { INSERT INTO t5 DEFAULT VALUES; SELECT * FROM t5; } } {1 xyz 2 xyz} | > > | | | | | | | > | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | } {1 xyz} do_test insert3-3.6 { execsql { INSERT INTO t5 DEFAULT VALUES; SELECT * FROM t5; } } {1 xyz 2 xyz} ifcapable bloblit { do_test insert3-3.7 { execsql { CREATE TABLE t6(x,y DEFAULT 4.3, z DEFAULT x'6869'); INSERT INTO t6 DEFAULT VALUES; SELECT * FROM t6; } } {{} 4.3 hi} } db close finish_test |
Changes to test/insert4.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2007 January 24 # # 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 INSERT transfer optimization. # | | > > > > > | 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 27 28 29 | # 2007 January 24 # # 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 INSERT transfer optimization. # # $Id: insert4.test,v 1.7 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !view||!subquery { finish_test return } # The sqlite3_xferopt_count variable is incremented whenever the # insert transfer optimization applies. # # This procedure runs a test to see if the sqlite3_xferopt_count is # set to N. # |
︙ | ︙ |
Changes to test/io.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # # The focus of this file is testing some specific characteristics of the # IO traffic generated by SQLite (making sure SQLite is not writing out # more database pages than it has to, stuff like that). # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # # The focus of this file is testing some specific characteristics of the # IO traffic generated by SQLite (making sure SQLite is not writing out # more database pages than it has to, stuff like that). # # $Id: io.test,v 1.10 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Test summary: # # io-1.* - Test that quick-balance does not journal pages unnecessarily. |
︙ | ︙ | |||
357 358 359 360 361 362 363 | } ;# /* ifcapable atomicwrite */ #---------------------------------------------------------------------- # Test cases io-3.* test the IOCAP_SEQUENTIAL optimization. # sqlite3_simulate_device -char sequential -sectorsize 0 | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 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 | } ;# /* ifcapable atomicwrite */ #---------------------------------------------------------------------- # Test cases io-3.* test the IOCAP_SEQUENTIAL optimization. # sqlite3_simulate_device -char sequential -sectorsize 0 ifcapable pager_pragmas { do_test io-3.1 { db close file delete -force test.db test.db-journal sqlite3 db test.db file size test.db } {0} do_test io-3.2 { execsql { CREATE TABLE abc(a, b) } nSync execsql { PRAGMA cache_size = 10; BEGIN; INSERT INTO abc VALUES('hello', 'world'); INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; } # File has grown - showing there was a cache-spill - but there # have been no calls to fsync(): list [file size test.db] [nSync] } {31744 0} do_test io-3.3 { # The COMMIT requires a single fsync() - to the database file. execsql { COMMIT } list [file size test.db] [nSync] } {39936 1} } #---------------------------------------------------------------------- # Test cases io-4.* test the IOCAP_SAFE_APPEND optimization. # sqlite3_simulate_device -char safe_append # With the SAFE_APPEND flag set, simple transactions require 3, rather |
︙ | ︙ | |||
464 465 466 467 468 469 470 | INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; } expr {[file size test.db]/1024} } {43} | > | | | | | | | > | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; INSERT INTO abc SELECT * FROM abc; } expr {[file size test.db]/1024} } {43} ifcapable pager_pragmas { do_test io-4.3.2 { execsql { PRAGMA synchronous = full; PRAGMA cache_size = 10; PRAGMA synchronous; } } {2} } do_test io-4.3.3 { execsql { BEGIN; UPDATE abc SET a = 'x'; } file exists test.db-journal } {1} |
︙ | ︙ |
Changes to test/ioerr2.test.
︙ | ︙ | |||
11 12 13 14 15 16 17 | # This file implements regression tests for SQLite library. The # focus of this file is testing for correct handling of I/O errors # such as writes failing because the disk is full. # # The tests in this file use special facilities that are only # available in the SQLite test fixture. # | | > > > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # This file implements regression tests for SQLite library. The # focus of this file is testing for correct handling of I/O errors # such as writes failing because the disk is full. # # The tests in this file use special facilities that are only # available in the SQLite test fixture. # # $Id: ioerr2.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !integrityck { finish_test return } do_test ioerr2-1.1 { execsql { PRAGMA cache_size = 10; PRAGMA default_cache_size = 10; CREATE TABLE t1(a, b, PRIMARY KEY(a, b)); INSERT INTO t1 VALUES(randstr(400,400),randstr(400,400)); |
︙ | ︙ |
Changes to test/like.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the LIKE and GLOB operators and # in particular the optimizations that occur to help those operators # run faster. # | | | 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 LIKE and GLOB operators and # in particular the optimizations that occur to help those operators # run faster. # # $Id: like.test,v 1.7 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create some sample data to work with. # do_test like-1.0 { |
︙ | ︙ | |||
385 386 387 388 389 390 391 | # ticket #2407 # # Make sure the LIKE prefix optimization does not strip off leading # characters of the like pattern that happen to be quote characters. # do_test like-6.1 { foreach x { 'abc 'bcd 'def 'ax } { | > | | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | # ticket #2407 # # Make sure the LIKE prefix optimization does not strip off leading # characters of the like pattern that happen to be quote characters. # do_test like-6.1 { foreach x { 'abc 'bcd 'def 'ax } { set x2 '[string map {' ''} $x]' db eval "INSERT INTO t2 VALUES($x2)" } execsql { SELECT * FROM t2 WHERE x LIKE '''a%' } } {'abc 'ax} finish_test |
Changes to test/malloc.test.
︙ | ︙ | |||
12 13 14 15 16 17 18 | # This file attempts to check the behavior of the SQLite library in # an out-of-memory situation. When compiled with -DSQLITE_DEBUG=1, # the SQLite library accepts a special command (sqlite3_memdebug_fail N C) # which causes the N-th malloc to fail. This special feature is used # to see what happens in the library if a malloc were to really fail # due to an out-of-memory situation. # | | > | | | | | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | > | 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | # This file attempts to check the behavior of the SQLite library in # an out-of-memory situation. When compiled with -DSQLITE_DEBUG=1, # the SQLite library accepts a special command (sqlite3_memdebug_fail N C) # which causes the N-th malloc to fail. This special feature is used # to see what happens in the library if a malloc were to really fail # due to an out-of-memory situation. # # $Id: malloc.test,v 1.48 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if memory debugging is turned on. # ifcapable !memdebug { puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..." finish_test return } source $testdir/malloc_common.tcl ifcapable bloblit&&subquery { do_malloc_test 1 -tclprep { db close } -tclbody { if {[catch {sqlite3 db test.db}]} { error "out of memory" } } -sqlbody { DROP TABLE IF EXISTS t1; CREATE TABLE t1( a int, b float, c double, d text, e varchar(20), primary key(a,b,c) ); CREATE INDEX i1 ON t1(a,b); INSERT INTO t1 VALUES(1,2.3,4.5,'hi',x'746865726500'); INSERT INTO t1 VALUES(6,7.0,0.8,'hello','out yonder'); SELECT * FROM t1; SELECT avg(b) FROM t1 GROUP BY a HAVING b>20.0; DELETE FROM t1 WHERE a IN (SELECT min(a) FROM t1); SELECT count(*) FROM t1; } } # Ensure that no file descriptors were leaked. do_test malloc-1.X { catch {db close} set sqlite_open_file_count } {0} ifcapable subquery { do_malloc_test 2 -sqlbody { CREATE TABLE t1(a int, b int default 'abc', c int default 1); CREATE INDEX i1 ON t1(a,b); INSERT INTO t1 VALUES(1,1,'99 abcdefghijklmnopqrstuvwxyz'); INSERT INTO t1 VALUES(2,4,'98 abcdefghijklmnopqrstuvwxyz'); INSERT INTO t1 VALUES(3,9,'97 abcdefghijklmnopqrstuvwxyz'); INSERT INTO t1 VALUES(4,16,'96 abcdefghijklmnopqrstuvwxyz'); INSERT INTO t1 VALUES(5,25,'95 abcdefghijklmnopqrstuvwxyz'); INSERT INTO t1 VALUES(6,36,'94 abcdefghijklmnopqrstuvwxyz'); SELECT 'stuff', count(*) as 'other stuff', max(a+10) FROM t1; UPDATE t1 SET b=b||b||b||b; UPDATE t1 SET b=a WHERE a in (10,12,22); INSERT INTO t1(c,b,a) VALUES(20,10,5); INSERT INTO t1 SELECT * FROM t1 WHERE a IN (SELECT a FROM t1 WHERE a<10); DELETE FROM t1 WHERE a>=10; DROP INDEX i1; DELETE FROM t1; } } # Ensure that no file descriptors were leaked. do_test malloc-2.X { catch {db close} set sqlite_open_file_count } {0} |
︙ | ︙ | |||
104 105 106 107 108 109 110 | # Ensure that no file descriptors were leaked. do_test malloc-3.X { catch {db close} set sqlite_open_file_count } {0} | > | | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | > | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | # Ensure that no file descriptors were leaked. do_test malloc-3.X { catch {db close} set sqlite_open_file_count } {0} ifcapable subquery { do_malloc_test 4 -sqlbody { BEGIN TRANSACTION; CREATE TABLE t1(a int, b int, c int); CREATE INDEX i1 ON t1(a,b); INSERT INTO t1 VALUES(1,1,99); INSERT INTO t1 VALUES(2,4,98); INSERT INTO t1 VALUES(3,9,97); INSERT INTO t1 VALUES(4,16,96); INSERT INTO t1 VALUES(5,25,95); INSERT INTO t1 VALUES(6,36,94); UPDATE t1 SET b=a WHERE a in (10,12,22); INSERT INTO t1 SELECT * FROM t1 WHERE a IN (SELECT a FROM t1 WHERE a<10); DROP INDEX i1; DELETE FROM t1; COMMIT; } } # Ensure that no file descriptors were leaked. do_test malloc-4.X { catch {db close} set sqlite_open_file_count } {0} ifcapable trigger { do_malloc_test 5 -sqlbody { BEGIN TRANSACTION; CREATE TABLE t1(a,b); CREATE TABLE t2(x,y); CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN INSERT INTO t2(x,y) VALUES(new.rowid,1); INSERT INTO t2(x,y) SELECT * FROM t2; INSERT INTO t2 SELECT * FROM t2; UPDATE t2 SET y=y+1 WHERE x=new.rowid; SELECT 123; DELETE FROM t2 WHERE x=new.rowid; END; INSERT INTO t1(a,b) VALUES(2,3); COMMIT; } } # Ensure that no file descriptors were leaked. do_test malloc-5.X { catch {db close} set sqlite_open_file_count } {0} ifcapable vacuum { do_malloc_test 6 -sqlprep { BEGIN TRANSACTION; CREATE TABLE t1(a); INSERT INTO t1 VALUES(1); INSERT INTO t1 SELECT a*2 FROM t1; INSERT INTO t1 SELECT a*2 FROM t1; INSERT INTO t1 SELECT a*2 FROM t1; INSERT INTO t1 SELECT a*2 FROM t1; INSERT INTO t1 SELECT a*2 FROM t1; INSERT INTO t1 SELECT a*2 FROM t1; INSERT INTO t1 SELECT a*2 FROM t1; INSERT INTO t1 SELECT a*2 FROM t1; INSERT INTO t1 SELECT a*2 FROM t1; INSERT INTO t1 SELECT a*2 FROM t1; DELETE FROM t1 where rowid%5 = 0; COMMIT; } -sqlbody { VACUUM; } } do_malloc_test 7 -sqlprep { CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); INSERT INTO t1 VALUES(3, 4); INSERT INTO t1 VALUES(5, 6); INSERT INTO t1 VALUES(7, randstr(1200,1200)); |
︙ | ︙ | |||
194 195 196 197 198 199 200 | # This is done by retrieving a string from the database engine and # manipulating it using the sqlite3_column_*** APIs. This doesn't # actually return an error to the user when a malloc() fails.. That # could be viewed as a bug. # # These tests only run if UTF-16 support is compiled in. # | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | # This is done by retrieving a string from the database engine and # manipulating it using the sqlite3_column_*** APIs. This doesn't # actually return an error to the user when a malloc() fails.. That # could be viewed as a bug. # # These tests only run if UTF-16 support is compiled in. # ifcapable utf16 { set ::STMT {} do_malloc_test 8 -tclprep { set sql "SELECT '[string repeat abc 20]', '[string repeat def 20]', ?" set ::STMT [sqlite3_prepare db $sql -1 X] sqlite3_step $::STMT if { $::tcl_platform(byteOrder)=="littleEndian" } { set ::bomstr "\xFF\xFE" |
︙ | ︙ | |||
330 331 332 333 334 335 336 | proc string_compare {a b} { return [string compare $a $b] } # Test for malloc() failures in sqlite3_create_collation() and # sqlite3_create_collation16(). # | > | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | | | | | | | | | > | 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 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | proc string_compare {a b} { return [string compare $a $b] } # Test for malloc() failures in sqlite3_create_collation() and # sqlite3_create_collation16(). # ifcapable utf16 { do_malloc_test 15 -start 4 -tclbody { db collate string_compare string_compare if {[catch {add_test_collate db 1 1 1} msg]} { if {$msg=="SQLITE_NOMEM"} {set msg "out of memory"} error $msg } db complete {SELECT "hello """||'world"' [microsoft], * FROM anicetable;} db complete {-- Useful comment} execsql { CREATE TABLE t1(a, b COLLATE string_compare); INSERT INTO t1 VALUES(10, 'string'); INSERT INTO t1 VALUES(10, 'string2'); } } } # Also test sqlite3_complete(). There are (currently) no malloc() # calls in this function, but test anyway against future changes. # do_malloc_test 16 -tclbody { db complete {SELECT "hello """||'world"' [microsoft], * FROM anicetable;} db complete {-- Useful comment} db eval { SELECT * FROM sqlite_master; } } # Test handling of malloc() failures in sqlite3_open16(). # ifcapable utf16 { do_malloc_test 17 -tclbody { set DB2 0 set STMT 0 # open database using sqlite3_open16() set filename [encoding convertto unicode test.db] append filename "\x00\x00" set DB2 [sqlite3_open16 $filename -unused] if {0==$DB2} { error "out of memory" } # Prepare statement set rc [catch {sqlite3_prepare $DB2 {SELECT * FROM sqlite_master} -1 X} msg] if {$rc} { error [string range $msg 4 end] } set STMT $msg # Finalize statement set rc [sqlite3_finalize $STMT] if {$rc!="SQLITE_OK"} { error [sqlite3_errmsg $DB2] } set STMT 0 # Close database set rc [sqlite3_close $DB2] if {$rc!="SQLITE_OK"} { error [sqlite3_errmsg $DB2] } set DB2 0 } -cleanup { if {$STMT!="0"} { sqlite3_finalize $STMT } if {$DB2!="0"} { set rc [sqlite3_close $DB2] } } } # Test handling of malloc() failures in sqlite3_errmsg16(). # ifcapable utf16 { do_malloc_test 18 -tclbody { catch { db eval "SELECT [string repeat longcolumnname 10] FROM sqlite_master" } msg if {$msg=="out of memory"} {error $msg} set utf16 [sqlite3_errmsg16 [sqlite3_connection_pointer db]] binary scan $utf16 c* bytes if {[llength $bytes]==0} { error "out of memory" } } } # This test is aimed at coverage testing. Specificly, it is supposed to # cause a malloc() only used when converting between the two utf-16 # encodings to fail (i.e. little-endian->big-endian). It only actually # hits this malloc() on little-endian hosts. |
︙ | ︙ | |||
466 467 468 469 470 471 472 | ATTACH DATABASE 'test2.db' AS t2; SELECT * FROM t1; DETACH DATABASE t2; } # Test malloc failure whilst installing a foreign key. # | > | | | > | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | ATTACH DATABASE 'test2.db' AS t2; SELECT * FROM t1; DETACH DATABASE t2; } # Test malloc failure whilst installing a foreign key. # ifcapable foreignkey { do_malloc_test 21 -sqlbody { CREATE TABLE abc(a, b, c, FOREIGN KEY(a) REFERENCES abc(b)) } } # Test malloc failure in an sqlite3_prepare_v2() call. # do_malloc_test 22 -tclbody { set ::STMT "" set r [catch { set ::STMT [ |
︙ | ︙ |
Changes to test/malloc8.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2007 April 25 # # 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 contains additional out-of-memory checks (see malloc.tcl) # added to expose a bug in out-of-memory handling for sqlite3_value_text() # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2007 April 25 # # 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 contains additional out-of-memory checks (see malloc.tcl) # added to expose a bug in out-of-memory handling for sqlite3_value_text() # # $Id: malloc8.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if memory debugging is turned on. # ifcapable !memdebug { |
︙ | ︙ | |||
55 56 57 58 59 60 61 | PRAGMA encoding='UTF-16'; CREATE TABLE t1(a); INSERT INTO t1 VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'); } -sqlbody { SELECT length(a), substr(a, 4, 4) FROM t1; } | > | | | | | | | > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | PRAGMA encoding='UTF-16'; CREATE TABLE t1(a); INSERT INTO t1 VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'); } -sqlbody { SELECT length(a), substr(a, 4, 4) FROM t1; } ifcapable datetime { do_malloc_test malloc8-4 -sqlprep { PRAGMA encoding='UTF-16'; CREATE TABLE t1(a); INSERT INTO t1 VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'); } -sqlbody { SELECT julianday(a,a) FROM t1; } } do_malloc_test malloc8-5 -sqlprep { PRAGMA encoding='UTF-16'; CREATE TABLE t1(a); INSERT INTO t1 VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'); } -sqlbody { |
︙ | ︙ |
Changes to test/mallocA.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # 2007 April 30 # # 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 contains additional out-of-memory checks (see malloc.tcl). # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 2007 April 30 # # 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 contains additional out-of-memory checks (see malloc.tcl). # # $Id: mallocA.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if memory debugging is turned on. # ifcapable !memdebug { |
︙ | ︙ | |||
40 41 42 43 44 45 46 | db close file copy test.db test.db.bu do_malloc_test mallocA-1 -testdb test.db.bu -sqlbody { ANALYZE } | > | | | | | | | | | | | > | 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 | db close file copy test.db test.db.bu do_malloc_test mallocA-1 -testdb test.db.bu -sqlbody { ANALYZE } ifcapable reindex { do_malloc_test mallocA-2 -testdb test.db.bu -sqlbody { REINDEX; } do_malloc_test mallocA-3 -testdb test.db.bu -sqlbody { REINDEX t1; } do_malloc_test mallocA-4 -testdb test.db.bu -sqlbody { REINDEX main.t1; } do_malloc_test mallocA-5 -testdb test.db.bu -sqlbody { REINDEX nocase; } } # Ensure that no file descriptors were leaked. do_test malloc-99.X { catch {db close} set sqlite_open_file_count } {0} file delete -force test.db.bu finish_test |
Changes to test/mallocB.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file contains additional out-of-memory checks (see malloc.tcl). # These were all discovered by fuzzy generation of SQL. Apart from # that they have little in common. # # | | > | > | 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 | # #*********************************************************************** # This file contains additional out-of-memory checks (see malloc.tcl). # These were all discovered by fuzzy generation of SQL. Apart from # that they have little in common. # # # $Id: mallocB.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/malloc_common.tcl # Only run these tests if memory debugging is turned on. # ifcapable !memdebug { puts "Skipping mallocB tests: not compiled with -DSQLITE_MEMDEBUG..." finish_test return } source $testdir/malloc_common.tcl do_malloc_test mallocB-1 -sqlbody {SELECT - 456} do_malloc_test mallocB-2 -sqlbody {SELECT - 456.1} do_malloc_test mallocB-3 -sqlbody {SELECT random()} do_malloc_test mallocB-4 -sqlbody {SELECT zeroblob(1000)} ifcapable subquery { do_malloc_test mallocB-5 -sqlbody {SELECT * FROM (SELECT 1) GROUP BY 1;} } # The following test checks that there are no resource leaks following a # malloc() failure in sqlite3_set_auxdata(). # # Note: This problem was not discovered by fuzzy generation of SQL. Not # that it really matters. # do_malloc_test mallocB-6 -sqlbody { SELECT test_auxdata('hello world'); } finish_test |
Changes to test/mallocC.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # # This file tests aspects of the malloc failure while parsing # CREATE TABLE statements in auto_vacuum mode. # | | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # May you share freely, never taking more than you give. # #*********************************************************************** # # This file tests aspects of the malloc failure while parsing # CREATE TABLE statements in auto_vacuum mode. # # $Id: mallocC.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if memory debugging is turned on. # ifcapable !memdebug||!compound { puts "Skipping mallocC tests: not compiled with -DSQLITE_MEMDEBUG..." finish_test return } # Generate a checksum based on the contents of the database. If the # checksum of two databases is the same, and the integrity-check passes |
︙ | ︙ |
Changes to test/misc2.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 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc2.test,v 1.28 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {trigger} { # Test for ticket #360 # |
︙ | ︙ | |||
153 154 155 156 157 158 159 | # Make sure we get an error message (not a segfault) on an attempt to # update a table from within the callback of a select on that same # table. # # 2006-08-16: This has changed. It is now permitted to update # the table being SELECTed from within the callback of the query. # | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 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 | # Make sure we get an error message (not a segfault) on an attempt to # update a table from within the callback of a select on that same # table. # # 2006-08-16: This has changed. It is now permitted to update # the table being SELECTed from within the callback of the query. # ifcapable tclvar { do_test misc2-7.1 { db close file delete -force test.db sqlite3 db test.db execsql { CREATE TABLE t1(x); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); SELECT * FROM t1; } } {1 2 3} do_test misc2-7.2 { set rc [catch { db eval {SELECT rowid FROM t1} {} { db eval "DELETE FROM t1 WHERE rowid=$rowid" } } msg] lappend rc $msg } {0 {}} do_test misc2-7.3 { execsql {SELECT * FROM t1} } {} do_test misc2-7.4 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(4); } db eval {SELECT rowid, x FROM t1} { if {$x & 1} { db eval {DELETE FROM t1 WHERE rowid=$rowid} } } execsql {SELECT * FROM t1} } {2 4} do_test misc2-7.5 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(4); } db eval {SELECT rowid, x FROM t1} { if {$x & 1} { db eval {DELETE FROM t1 WHERE rowid=$rowid+1} } } execsql {SELECT * FROM t1} } {1 3} do_test misc2-7.6 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(4); } db eval {SELECT rowid, x FROM t1} { if {$x & 1} { db eval {DELETE FROM t1} } } execsql {SELECT * FROM t1} } {} do_test misc2-7.7 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(4); } db eval {SELECT rowid, x FROM t1} { if {$x & 1} { db eval {UPDATE t1 SET x=x+100 WHERE rowid=$rowid} } } execsql {SELECT * FROM t1} } {101 2 103 4} do_test misc2-7.8 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES(1); } db eval {SELECT rowid, x FROM t1} { if {$x<10} { db eval {INSERT INTO t1 VALUES($x+1)} } } execsql {SELECT * FROM t1} } {1 2 3 4 5 6 7 8 9 10} # Repeat the tests 7.1 through 7.8 about but this time do the SELECTs # in reverse order so that we exercise the sqlite3BtreePrev() routine # instead of sqlite3BtreeNext() # do_test misc2-7.11 { db close file delete -force test.db sqlite3 db test.db execsql { CREATE TABLE t1(x); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); SELECT * FROM t1; } } {1 2 3} do_test misc2-7.12 { set rc [catch { db eval {SELECT rowid FROM t1 ORDER BY rowid DESC} {} { db eval "DELETE FROM t1 WHERE rowid=$rowid" } } msg] lappend rc $msg } {0 {}} do_test misc2-7.13 { execsql {SELECT * FROM t1} } {} do_test misc2-7.14 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(4); } db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} { if {$x & 1} { db eval {DELETE FROM t1 WHERE rowid=$rowid} } } execsql {SELECT * FROM t1} } {2 4} do_test misc2-7.15 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(4); } db eval {SELECT rowid, x FROM t1} { if {$x & 1} { db eval {DELETE FROM t1 WHERE rowid=$rowid+1} } } execsql {SELECT * FROM t1} } {1 3} do_test misc2-7.16 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(4); } db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} { if {$x & 1} { db eval {DELETE FROM t1} } } execsql {SELECT * FROM t1} } {} do_test misc2-7.17 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); INSERT INTO t1 VALUES(4); } db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} { if {$x & 1} { db eval {UPDATE t1 SET x=x+100 WHERE rowid=$rowid} } } execsql {SELECT * FROM t1} } {101 2 103 4} do_test misc2-7.18 { execsql { DELETE FROM t1; INSERT INTO t1(rowid,x) VALUES(10,10); } db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} { if {$x>1} { db eval {INSERT INTO t1(rowid,x) VALUES($x-1,$x-1)} } } execsql {SELECT * FROM t1} } {1 2 3 4 5 6 7 8 9 10} } db close file delete -force test.db sqlite3 db test.db # Ticket #453. If the SQL ended with "-", the tokenizer was calling that # an incomplete token, which caused problem. The solution was to just call |
︙ | ︙ |
Changes to test/misc5.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 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc5.test,v 1.17 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Build records using the MakeRecord opcode such that the size of the # header is at the transition point in the size of a varint. # |
︙ | ︙ | |||
578 579 580 581 582 583 584 | db close sqlite3_busy_timeout $DB 1000 } SQLITE_MISUSE sqlite3 db test.db # Ticket #1911 # | > | | | | | | | | | | | | | | | | > | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | db close sqlite3_busy_timeout $DB 1000 } SQLITE_MISUSE sqlite3 db test.db # Ticket #1911 # ifcapable compound { do_test misc5-9.1 { execsql { SELECT name, type FROM sqlite_master WHERE name IS NULL UNION SELECT type, name FROM sqlite_master WHERE type IS NULL ORDER BY 1, 2, 1, 2, 1, 2 } } {} do_test misc5-9.2 { execsql { SELECT name, type FROM sqlite_master WHERE name IS NULL UNION SELECT type, name FROM sqlite_master WHERE type IS NULL ORDER BY 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 } } {} } # Ticket #1912. Make the tokenizer require a space after a numeric # literal. # do_test misc5-10.1 { catchsql { SELECT 123abc |
︙ | ︙ |
Changes to test/pragma2.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 23 24 25 26 27 28 29 30 31 32 33 34 | # 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: pragma2.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Test organization: # # pragma2-1.*: Test freelist_count pragma on the main database. # pragma2-2.*: Test freelist_count pragma on an attached database. # pragma2-3.*: Test trying to write to the freelist_count is a no-op. # ifcapable !pragma||!schema_pragmas { finish_test return } # Delete the preexisting database to avoid the special setup # that the "all.test" script does. # |
︙ | ︙ |
Changes to test/ptrchng.test.
︙ | ︙ | |||
17 18 19 20 21 22 23 | # # sqlite3_value_text() # sqlite3_value_text16() # sqlite3_value_blob() # sqlite3_value_bytes() # sqlite3_value_bytes16() # | | > > > > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # # sqlite3_value_text() # sqlite3_value_text16() # sqlite3_value_blob() # sqlite3_value_bytes() # sqlite3_value_bytes16() # # $Id: ptrchng.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !bloblit { finish_test return } # Register the "pointer_change" SQL function. # sqlite3_create_function db do_test ptrchng-1.1 { 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 | # #*********************************************************************** # 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.6 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl set DB [sqlite3_connection_pointer db] do_test rollback-1.1 { |
︙ | ︙ | |||
54 55 56 57 58 59 60 | catchsql { INSERT INTO t3 SELECT a FROM t1; } } {1 {column a is not unique}} # Try to continue with the SELECT statement # | < | < | | | > | > | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | catchsql { INSERT INTO t3 SELECT a FROM t1; } } {1 {column a is not unique}} # Try to continue with the SELECT statement # do_test rollback-1.5 { sqlite3_step $STMT } {SQLITE_ERROR} # Restart the SELECT statement # do_test rollback-1.6 { sqlite3_reset $STMT } {SQLITE_ABORT} } else { do_test rollback-1.6 { sqlite3_reset $STMT } {SQLITE_OK} } do_test rollback-1.7 { sqlite3_step $STMT } {SQLITE_ROW} do_test rollback-1.8 { sqlite3_step $STMT } {SQLITE_ROW} do_test rollback-1.9 { sqlite3_finalize $STMT } {SQLITE_OK} finish_test |
Changes to test/select7.test.
1 2 3 4 5 6 7 8 9 10 11 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 file is testing compute SELECT statements and nested # views. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 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 compute SELECT statements and nested # views. # # $Id: select7.test,v 1.11 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable compound { |
︙ | ︙ | |||
134 135 136 137 138 139 140 | } [list 1 \ {only a single result allowed for a SELECT that is part of an expression}] } # Verify that an error occurs if you have too many terms on a # compound select statement. # | > | | | | | | | | | | | | | | | | > | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | } [list 1 \ {only a single result allowed for a SELECT that is part of an expression}] } # Verify that an error occurs if you have too many terms on a # compound select statement. # ifcapable compound { if {$SQLITE_MAX_COMPOUND_SELECT>0} { set sql {SELECT 0} set result 0 for {set i 1} {$i<$SQLITE_MAX_COMPOUND_SELECT} {incr i} { append sql " UNION ALL SELECT $i" lappend result $i } do_test select7-6.1 { catchsql $sql } [list 0 $result] append sql { UNION ALL SELECT 99999999} do_test select7-6.2 { catchsql $sql } {1 {too many terms in compound SELECT}} } } finish_test |
Changes to test/shared.test.
1 2 3 4 5 6 7 8 9 10 11 | # 2005 December 30 # # 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. # #*********************************************************************** # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 2005 December 30 # # 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. # #*********************************************************************** # # $Id: shared.test,v 1.27 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl db close ifcapable !shared_cache { finish_test |
︙ | ︙ | |||
861 862 863 864 865 866 867 | do_test shared-$av.11.11 { db close db2 close } {} # This tests that if it is impossible to free any pages, SQLite will # exceed the limit set by PRAGMA cache_size. | < | | > > | | | | | > | 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | do_test shared-$av.11.11 { db close db2 close } {} # This tests that if it is impossible to free any pages, SQLite will # exceed the limit set by PRAGMA cache_size. file delete -force test.db test.db-journal sqlite3 db test.db ifcapable pager_pragmas { do_test shared-$av.12.1 { execsql { PRAGMA cache_size = 10; PRAGMA cache_size; } } {10} } do_test shared-$av.12.2 { set ::db_handles [list] for {set i 1} {$i < 15} {incr i} { lappend ::db_handles db$i sqlite3 db$i test.db execsql "CREATE TABLE db${i}(a, b, c)" db$i execsql "INSERT INTO db${i} VALUES(1, 2, 3)" |
︙ | ︙ |
Changes to test/softheap1.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # # This test script reproduces the problem reported by ticket #2565, # A database corruption bug that occurs in auto_vacuum mode when # the soft_heap_limit is set low enough to be triggered. # | | > > > > > | 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 test script reproduces the problem reported by ticket #2565, # A database corruption bug that occurs in auto_vacuum mode when # the soft_heap_limit is set low enough to be triggered. # # $Id: softheap1.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !integrityck { finish_test return } sqlite3_soft_heap_limit 5000 do_test softheap1-1.1 { execsql { PRAGMA auto_vacuum=1; CREATE TABLE t1(x); INSERT INTO t1 VALUES(hex(randomblob(1000))); |
︙ | ︙ |
Changes to test/speed3.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 that the overflow-page related # enhancements added after version 3.3.17 speed things up. # | | | 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 that the overflow-page related # enhancements added after version 3.3.17 speed things up. # # $Id: speed3.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $ # #--------------------------------------------------------------------- # Test plan: # # If auto-vacuum is enabled for the database, the following cases # should show performance improvement with respect to 3.3.17. |
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # in this case is because the overflow pages between the tree # page and the overflow page containing the value do not have # to be read (test cases speed3-2.X). # set testdir [file dirname $argv0] source $testdir/tester.tcl speed_trial_init speed1 # Set a uniform random seed expr srand(0) set ::NROW 1000 | > > > > > > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # in this case is because the overflow pages between the tree # page and the overflow page containing the value do not have # to be read (test cases speed3-2.X). # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !tclvar { finish_test return } speed_trial_init speed1 # Set a uniform random seed expr srand(0) set ::NROW 1000 |
︙ | ︙ |
Changes to test/substr.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2007 May 14 # # 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 built-in SUBSTR() functions. # | | > > > > > | 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 27 28 29 | # 2007 May 14 # # 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 built-in SUBSTR() functions. # # $Id: substr.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !tclvar { finish_test return } # Create a table to work with. # execsql { CREATE TABLE t1(t text, b blob) } proc substr-test {id string i1 i2 result} { |
︙ | ︙ |
Changes to test/tableapi.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 file is testing the sqlite_exec_printf() and # sqlite_get_table_printf() APIs. # | | | 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 file is testing the sqlite_exec_printf() and # sqlite_get_table_printf() APIs. # # $Id: tableapi.test,v 1.13 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test tableapi-1.0 { set ::dbx [sqlite3_open test.db] catch {sqlite_exec_printf $::dbx {DROP TABLE xyz} {}} |
︙ | ︙ | |||
202 203 204 205 206 207 208 | set sep , } append sql ) sqlite3_get_table_printf $::dbx $sql {} sqlite3_get_table_printf $::dbx {SELECT * FROM t2} {} } {0 2 100 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41 x42 x43 x44 x45 x46 x47 x48 x49 x50 x51 x52 x53 x54 x55 x56 x57 x58 x59 x60 x61 x62 x63 x64 x65 x66 x67 x68 x69 x70 x71 x72 x73 x74 x75 x76 x77 x78 x79 x80 x81 x82 x83 x84 x85 x86 x87 x88 x89 x90 x91 x92 x93 x94 x95 x96 x97 x98 x99 x100 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100} | > | | | > | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | set sep , } append sql ) sqlite3_get_table_printf $::dbx $sql {} sqlite3_get_table_printf $::dbx {SELECT * FROM t2} {} } {0 2 100 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41 x42 x43 x44 x45 x46 x47 x48 x49 x50 x51 x52 x53 x54 x55 x56 x57 x58 x59 x60 x61 x62 x63 x64 x65 x66 x67 x68 x69 x70 x71 x72 x73 x74 x75 x76 x77 x78 x79 x80 x81 x82 x83 x84 x85 x86 x87 x88 x89 x90 x91 x92 x93 x94 x95 x96 x97 x98 x99 x100 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100} ifcapable schema_pragmas { do_test tableapi-6.1 { sqlite3_get_table_printf $::dbx {PRAGMA user_version} {} } {0 1 1 user_version 0} } do_test tableapi-99.0 { sqlite3_close $::dbx } {SQLITE_OK} finish_test |
Changes to test/tclsqlite.test.
︙ | ︙ | |||
11 12 13 14 15 16 17 | # This file implements regression tests for TCL interface to the # SQLite library. # # Actually, all tests are based on the TCL interface, so the main # interface is pretty well tested. This file contains some addition # tests for fringe issues that the main test suite does not cover. # | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # This file implements regression tests for TCL interface to the # SQLite library. # # Actually, all tests are based on the TCL interface, so the main # interface is pretty well tested. This file contains some addition # tests for fringe issues that the main test suite does not cover. # # $Id: tclsqlite.test,v 1.62 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Check the error messages generated by tclsqlite # if {[sqlite3 -has-codec]} { |
︙ | ︙ | |||
456 457 458 459 460 461 462 | } [sqlite3_libversion_number] # Check to see that when bindings of the form @aaa are used instead # of $aaa, that objects are treated as bytearray and are inserted # as BLOBs. # | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | } [sqlite3_libversion_number] # Check to see that when bindings of the form @aaa are used instead # of $aaa, that objects are treated as bytearray and are inserted # as BLOBs. # ifcapable tclvar { do_test tcl-13.1 { db eval {CREATE TABLE t5(x BLOB)} set x abc123 db eval {INSERT INTO t5 VALUES($x)} db eval {SELECT typeof(x) FROM t5} } {text} do_test tcl-13.2 { binary scan $x H notUsed db eval { DELETE FROM t5; INSERT INTO t5 VALUES($x); SELECT typeof(x) FROM t5; } } {text} do_test tcl-13.3 { db eval { DELETE FROM t5; INSERT INTO t5 VALUES(@x); SELECT typeof(x) FROM t5; } } {blob} do_test tcl-13.4 { set y 1234 db eval { DELETE FROM t5; INSERT INTO t5 VALUES(@y); SELECT hex(x), typeof(x) FROM t5 } } {31323334 blob} } finish_test |
Changes to test/tkt2141.test.
︙ | ︙ | |||
10 11 12 13 14 15 16 | #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests to verify that ticket #2141 has been # fixed. # # | | > > > > | 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 to verify that ticket #2141 has been # fixed. # # # $Id: tkt2141.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !subquery { finish_test return } do_test tkt2141-1.1 { execsql { CREATE TABLE tab1 (t1_id integer PRIMARY KEY, t1_desc); INSERT INTO tab1 VALUES(1,'rec 1 tab 1'); CREATE TABLE tab2 (t2_id integer PRIMARY KEY, t2_id_t1, t2_desc); INSERT INTO tab2 VALUES(1,1,'rec 1 tab 2'); |
︙ | ︙ |
Changes to test/tkt2192.test.
︙ | ︙ | |||
10 11 12 13 14 15 16 | #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests to verify that ticket #2192 has been # fixed. # # | | > > > > | 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 to verify that ticket #2192 has been # fixed. # # # $Id: tkt2192.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !datetime { finish_test return } do_test tkt2191-1.1 { execsql { -- Raw data (RBS) -------- create table records ( date real, |
︙ | ︙ |
Changes to test/tkt2251.test.
︙ | ︙ | |||
24 25 26 27 28 29 30 | # # The sqlite3ExprCodeGetColumn() routine was added to take care of # all of the complications above. The tests in this file attempt # to verify that sqlite3ExprCodeGetColumn() is used instead of a # raw OP_Column in all places where a table column is extracted from # the database. # | | > > > > > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # # The sqlite3ExprCodeGetColumn() routine was added to take care of # all of the complications above. The tests in this file attempt # to verify that sqlite3ExprCodeGetColumn() is used instead of a # raw OP_Column in all places where a table column is extracted from # the database. # # $Id: tkt2251.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !altertable { finish_test return } # Create sample data. Verify that the default value and type of an added # column is correct for aggregates. do_test tkt2251-1.1 { execsql { CREATE TABLE t1(a INTEGER); INSERT INTO t1 VALUES(1); |
︙ | ︙ |
Changes to test/tkt2332.test.
1 2 3 4 5 6 7 8 9 10 11 | # 2007 May 3 # # 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. # #*********************************************************************** # | | | | 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 | # 2007 May 3 # # 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. # #*********************************************************************** # # $Id: tkt2332.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !incrblob||!tclvar { finish_test return } do_test tkt2332.1 { execsql { CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB); |
︙ | ︙ |
Changes to test/tkt2339.test.
1 2 3 4 5 6 7 8 9 10 11 | # 2007 May 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. # #*********************************************************************** # | | > > > > > | 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 27 28 | # 2007 May 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. # #*********************************************************************** # # $Id: tkt2339.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !subquery||!compound { finish_test return } do_test tkt2339.1 { execsql { create table t1(num int); insert into t1 values (1); insert into t1 values (2); insert into t1 values (3); |
︙ | ︙ |
Changes to test/tkt2409.test.
︙ | ︙ | |||
12 13 14 15 16 17 18 | # # This file implements tests to verify that ticket #2409 has been # fixed. More specifically, they verify that if SQLite cannot # obtain an EXCLUSIVE lock while trying to spill the cache during # any statement other than a COMMIT, an I/O error is returned instead # of SQLITE_BUSY. # | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # # This file implements tests to verify that ticket #2409 has been # fixed. More specifically, they verify that if SQLite cannot # obtain an EXCLUSIVE lock while trying to spill the cache during # any statement other than a COMMIT, an I/O error is returned instead # of SQLITE_BUSY. # # $Id: tkt2409.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $ # Test Outline: # # tkt-2409-1.*: Cause a cache-spill during an INSERT that is within # a db transaction but does not start a statement transaction. # Verify that the transaction is automatically rolled back # and SQLITE_IOERR_BLOCKED is returned |
︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # tkt-2409-4.*: Similar to 2409-1.*, but rig it so that the # INSERT statement starts a statement transaction. Verify that # SQLOTE_BUSY is returned and the transaction is not rolled back. # set testdir [file dirname $argv0] source $testdir/tester.tcl sqlite3_extended_result_codes $::DB 1 # Aquire a read-lock on the database using handle [db2]. # proc read_lock_db {} { if {$::STMT eq ""} { | > > > > > | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | # tkt-2409-4.*: Similar to 2409-1.*, but rig it so that the # INSERT statement starts a statement transaction. Verify that # SQLOTE_BUSY is returned and the transaction is not rolled back. # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !pager_pragmas { finish_test return } sqlite3_extended_result_codes $::DB 1 # Aquire a read-lock on the database using handle [db2]. # proc read_lock_db {} { if {$::STMT eq ""} { |
︙ | ︙ |
Changes to test/trans.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 script is database locks. # | | | 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 script is database locks. # # $Id: trans.test,v 1.37 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create several tables to work with. |
︙ | ︙ | |||
904 905 906 907 908 909 910 | } 1 ifcapable pager_pragmas { do_test trans-9.$i.5-$cnt { expr {$sqlite_fullsync_count>0} } [expr {$i%2==0}] } else { do_test trans-9.$i.5-$cnt { | | | 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 | } 1 ifcapable pager_pragmas { do_test trans-9.$i.5-$cnt { expr {$sqlite_fullsync_count>0} } [expr {$i%2==0}] } else { do_test trans-9.$i.5-$cnt { expr {$sqlite_fullsync_count==0} } {1} } } } set ::pager_old_format 0 } finish_test |
Changes to test/where2.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 file is testing the use of indices in WHERE clauses # based on recent changes to the optimizer. # | | | 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 file is testing the use of indices in WHERE clauses # based on recent changes to the optimizer. # # $Id: where2.test,v 1.12 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Build some test data # do_test where2-1.0 { |
︙ | ︙ | |||
324 325 326 327 328 329 330 | } {123 0123 nosort t2249b {} t2249a {}} do_test where2-6.11.4 { # Permutations of the expression terms. queryplan { SELECT * FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR b=a; } } {123 0123 nosort t2249b {} t2249a {}} | > | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | > | 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 | } {123 0123 nosort t2249b {} t2249a {}} do_test where2-6.11.4 { # Permutations of the expression terms. queryplan { SELECT * FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR b=a; } } {123 0123 nosort t2249b {} t2249a {}} ifcapable explain { do_test where2-6.12 { # In this case, the +b disables the affinity conflict and allows # the OR optimization to be used again. The result is now an empty # set, the same as in where2-6.9. queryplan { SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b OR a='hello'; } } {nosort t2249b {} {} sqlite_autoindex_t2249a_1} do_test where2-6.12.2 { # In this case, the +b disables the affinity conflict and allows # the OR optimization to be used again. The result is now an empty # set, the same as in where2-6.9. queryplan { SELECT * FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR +b=a; } } {nosort t2249b {} {} sqlite_autoindex_t2249a_1} } ifcapable explain { do_test where2-6.12.3 { # In this case, the +b disables the affinity conflict and allows # the OR optimization to be used again. The result is now an empty # set, the same as in where2-6.9. queryplan { SELECT * FROM t2249b CROSS JOIN t2249a WHERE +b=a OR a='hello'; } } {nosort t2249b {} {} sqlite_autoindex_t2249a_1} do_test where2-6.13 { # The addition of +a on the second term disabled the OR optimization. # But we should still get the same empty-set result as in where2-6.9. queryplan { SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b OR +a='hello'; } } {nosort t2249b {} t2249a {}} } # Variations on the order of terms in a WHERE clause in order # to make sure the OR optimizer can recognize them all. do_test where2-6.20 { queryplan { SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a } } {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1} ifcapable explain { do_test where2-6.21 { queryplan { SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a OR y.a='hello' } } {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1} do_test where2-6.22 { queryplan { SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE y.a=x.a OR y.a='hello' } } {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1} do_test where2-6.23 { queryplan { SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE y.a='hello' OR x.a=y.a } } {0123 0123 nosort x {} {} sqlite_autoindex_t2249a_1} } # Unique queries (queries that are guaranteed to return only a single # row of result) do not call the sorter. But all tables must give # a unique result. If any one table in the join does not give a unique # result then sorting is necessary. # do_test where2-7.1 { |
︙ | ︙ | |||
576 577 578 579 580 581 582 | } } {} } # Make sure WHERE clauses of the form A=1 AND (B=2 OR B=3) are optimized # when we have an index on A and B. # | | | 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | } } {} } # Make sure WHERE clauses of the form A=1 AND (B=2 OR B=3) are optimized # when we have an index on A and B. # ifcapable or_opt&&tclvar { do_test where2-9.1 { execsql { BEGIN; CREATE TABLE t10(a,b,c); INSERT INTO t10 VALUES(1,1,1); INSERT INTO t10 VALUES(1,2,2); INSERT INTO t10 VALUES(1,3,3); |
︙ | ︙ |
Changes to test/where4.test.
︙ | ︙ | |||
11 12 13 14 15 16 17 | # This file implements regression tests for SQLite library. The # focus of this file is testing the use of indices in WHERE clauses. # This file was created when support for optimizing IS NULL phrases # was added. And so the principle purpose of this file is to test # that IS NULL phrases are correctly optimized. But you can never # have too many tests, so some other tests are thrown in as well. # | | > > > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # This file implements regression tests for SQLite library. The # focus of this file is testing the use of indices in WHERE clauses. # This file was created when support for optimizing IS NULL phrases # was added. And so the principle purpose of this file is to test # that IS NULL phrases are correctly optimized. But you can never # have too many tests, so some other tests are thrown in as well. # # $Id: where4.test,v 1.5 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !tclvar||!bloblit { finish_test return } # Build some test data # do_test where4-1.0 { execsql { CREATE TABLE t1(w, x, y); CREATE INDEX i1wxy ON t1(w,x,y); |
︙ | ︙ |
Changes to test/zeroblob.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing of the zero-filled blob functionality # including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(), # and the built-in zeroblob() SQL function. # | | | 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 of the zero-filled blob functionality # including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(), # and the built-in zeroblob() SQL function. # # $Id: zeroblob.test,v 1.10 2007/09/12 17:01:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !incrblob { finish_test return |
︙ | ︙ | |||
106 107 108 109 110 111 112 | CREATE INDEX i1_1 ON t1(b); SELECT a FROM t1 WHERE b=zeroblob(10000); } } {5} # DISTINCT works for zeroblobs # | > | | | | | | | | | | > > | | | | | > | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | CREATE INDEX i1_1 ON t1(b); SELECT a FROM t1 WHERE b=zeroblob(10000); } } {5} # DISTINCT works for zeroblobs # ifcapable bloblit&&subquery&&compound { do_test zeroblob-3.1 { execsql { SELECT count(DISTINCT a) FROM ( SELECT x'00000000000000000000' AS a UNION ALL SELECT zeroblob(10) AS a ) } } {1} } # Concatentation works with zeroblob # ifcapable bloblit { do_test zeroblob-4.1 { execsql { SELECT hex(zeroblob(2) || x'61') } } {000061} } # Check various CAST(...) operations on zeroblob. # do_test zeroblob-5.1 { execsql { SELECT CAST (zeroblob(100) AS REAL); } |
︙ | ︙ |