Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Update error message text for standard error codes to better describe the latest usage of those error codes. Modify sqlite3_open_v2() so that it does return a valid sqlite3 object in the event of SQLITE_MISUSE due to bad open flags, so that sqlite3_errmsg() does not report "out of memory" in that case. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f27b6370407842e2c175ea4aa9ce0187 |
User & Date: | drh 2017-07-10 12:07:53.037 |
Context
2017-07-10
| ||
13:24 | For sqlite3TreeView() debugging output, show the Expr.flags field on scalar subqueries. (check-in: dc857a96b0 user: drh tags: trunk) | |
12:07 | Update error message text for standard error codes to better describe the latest usage of those error codes. Modify sqlite3_open_v2() so that it does return a valid sqlite3 object in the event of SQLITE_MISUSE due to bad open flags, so that sqlite3_errmsg() does not report "out of memory" in that case. (check-in: f27b637040 user: drh tags: trunk) | |
11:17 | Remove the error message text from disused error codes such as SQLITE_EMPTY and SQLITE_FORMAT. (check-in: 871752f292 user: drh tags: trunk) | |
Changes
Changes to src/main.c.
︙ | ︙ | |||
1403 1404 1405 1406 1407 1408 1409 | */ const char *sqlite3ErrStr(int rc){ static const char* const aMsg[] = { /* SQLITE_OK */ "not an error", /* SQLITE_ERROR */ "SQL logic error", /* SQLITE_INTERNAL */ 0, /* SQLITE_PERM */ "access permission denied", | | | | | | 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 | */ const char *sqlite3ErrStr(int rc){ static const char* const aMsg[] = { /* SQLITE_OK */ "not an error", /* SQLITE_ERROR */ "SQL logic error", /* SQLITE_INTERNAL */ 0, /* SQLITE_PERM */ "access permission denied", /* SQLITE_ABORT */ "query aborted", /* SQLITE_BUSY */ "database is locked", /* SQLITE_LOCKED */ "database table is locked", /* SQLITE_NOMEM */ "out of memory", /* SQLITE_READONLY */ "attempt to write a readonly database", /* SQLITE_INTERRUPT */ "interrupted", /* SQLITE_IOERR */ "disk I/O error", /* SQLITE_CORRUPT */ "database disk image is malformed", /* SQLITE_NOTFOUND */ "unknown operation", /* SQLITE_FULL */ "database or disk is full", /* SQLITE_CANTOPEN */ "unable to open database file", /* SQLITE_PROTOCOL */ "locking protocol", /* SQLITE_EMPTY */ 0, /* SQLITE_SCHEMA */ "database schema has changed", /* SQLITE_TOOBIG */ "string or blob too big", /* SQLITE_CONSTRAINT */ "constraint failed", /* SQLITE_MISMATCH */ "datatype mismatch", /* SQLITE_MISUSE */ "bad parameter or other API misuse", #ifdef SQLITE_DISABLE_LFS /* SQLITE_NOLFS */ "large file support is disabled", #else /* SQLITE_NOLFS */ 0, #endif /* SQLITE_AUTH */ "authorization denied", /* SQLITE_FORMAT */ 0, /* SQLITE_RANGE */ "column index out of range", /* SQLITE_NOTADB */ "file is not a database", }; const char *zErr = "unknown error"; switch( rc ){ case SQLITE_ABORT_ROLLBACK: { zErr = "abort due to ROLLBACK"; break; } |
︙ | ︙ | |||
2269 2270 2271 2272 2273 2274 2275 | ** error. */ const void *sqlite3_errmsg16(sqlite3 *db){ static const u16 outOfMem[] = { 'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0 }; static const u16 misuse[] = { | | < < | | < | 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 | ** error. */ const void *sqlite3_errmsg16(sqlite3 *db){ static const u16 outOfMem[] = { 'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0 }; static const u16 misuse[] = { 'b', 'a', 'd', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', ' ', 'o', 'r', ' ', 'o', 't', 'h', 'e', 'r', ' ', 'A', 'P', 'I', ' ', 'm', 'i', 's', 'u', 's', 'e', 0 }; const void *z; if( !db ){ return (void *)outOfMem; } if( !sqlite3SafetyCheckSickOrOk(db) ){ |
︙ | ︙ | |||
2809 2810 2811 2812 2813 2814 2815 | #endif *ppDb = 0; #ifndef SQLITE_OMIT_AUTOINIT rc = sqlite3_initialize(); if( rc ) return rc; #endif | < < < < < < < < < < < < < < < < < < < < | 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 | #endif *ppDb = 0; #ifndef SQLITE_OMIT_AUTOINIT rc = sqlite3_initialize(); if( rc ) return rc; #endif if( sqlite3GlobalConfig.bCoreMutex==0 ){ isThreadsafe = 0; }else if( flags & SQLITE_OPEN_NOMUTEX ){ isThreadsafe = 0; }else if( flags & SQLITE_OPEN_FULLMUTEX ){ isThreadsafe = 1; }else{ |
︙ | ︙ | |||
2950 2951 2952 2953 2954 2955 2956 | } /* EVIDENCE-OF: R-08308-17224 The default collating function for all ** strings is BINARY. */ db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0); assert( db->pDfltColl!=0 ); | | > > > > > > > > > > > > > > > > > > > > | > | 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 | } /* EVIDENCE-OF: R-08308-17224 The default collating function for all ** strings is BINARY. */ db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0); assert( db->pDfltColl!=0 ); /* Parse the filename/URI argument ** ** Only allow sensible combinations of bits in the flags argument. ** Throw an error if any non-sense combination is used. If we ** do not block illegal combinations here, it could trigger ** assert() statements in deeper layers. Sensible combinations ** are: ** ** 1: SQLITE_OPEN_READONLY ** 2: SQLITE_OPEN_READWRITE ** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE */ db->openFlags = flags; assert( SQLITE_OPEN_READONLY == 0x01 ); assert( SQLITE_OPEN_READWRITE == 0x02 ); assert( SQLITE_OPEN_CREATE == 0x04 ); testcase( (1<<(flags&7))==0x02 ); /* READONLY */ testcase( (1<<(flags&7))==0x04 ); /* READWRITE */ testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */ if( ((1<<(flags&7)) & 0x46)==0 ){ rc = SQLITE_MISUSE_BKPT; /* IMP: R-65497-44594 */ }else{ rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg); } if( rc!=SQLITE_OK ){ if( rc==SQLITE_NOMEM ) sqlite3OomFault(db); sqlite3ErrorWithMsg(db, rc, zErrMsg ? "%s" : 0, zErrMsg); sqlite3_free(zErrMsg); goto opendb_out; } |
︙ | ︙ |
Changes to test/attach.test.
︙ | ︙ | |||
788 789 790 791 792 793 794 | do_test attach-8.1 { set fd [open test2.db w] puts $fd "This file is not a valid SQLite database" close $fd catchsql { ATTACH 'test2.db' AS t2; } | | | 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 | do_test attach-8.1 { set fd [open test2.db w] puts $fd "This file is not a valid SQLite database" close $fd catchsql { ATTACH 'test2.db' AS t2; } } {1 {file is not a database}} do_test attach-8.2 { db errorcode } {26} forcedelete test2.db do_test attach-8.3 { sqlite3 db2 test2.db db2 eval {CREATE TABLE t1(x); BEGIN EXCLUSIVE} |
︙ | ︙ |
Changes to test/backup2.test.
︙ | ︙ | |||
118 119 120 121 122 123 124 | catch {file attributes bu2.db -readonly 0} catch {file attributes bu2.db -permissions rw-------} set out [open bu2.db w] puts $out "This is not a valid database file" close $out set rc [catch {db backup temp bu2.db} res] lappend rc $res | | | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | catch {file attributes bu2.db -readonly 0} catch {file attributes bu2.db -permissions rw-------} set out [open bu2.db w] puts $out "This is not a valid database file" close $out set rc [catch {db backup temp bu2.db} res] lappend rc $res } {1 {backup failed: file is not a database}} # Try to backup database that does not exist # do_test backup2-8 { forcedelete bu1.db set rc [catch {db backup aux1 bu1.db} res] lappend rc $res |
︙ | ︙ | |||
140 141 142 143 144 145 146 | } {1 {wrong # args: should be "db backup ?DATABASE? FILENAME"}} # Try to restore from an unreadable file. # if {$tcl_platform(platform)=="windows"} { set msg {cannot open source database: unable to open database file} } elseif {$tcl_platform(os)=="OpenBSD"} { | | | | 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 | } {1 {wrong # args: should be "db backup ?DATABASE? FILENAME"}} # Try to restore from an unreadable file. # if {$tcl_platform(platform)=="windows"} { set msg {cannot open source database: unable to open database file} } elseif {$tcl_platform(os)=="OpenBSD"} { set msg {restore failed: file is not a database} } else { set msg {cannot open source database: disk I/O error} } do_test backup2-10 { forcedelete bu3.db file mkdir bu3.db set rc [catch {db restore temp bu3.db} res] lappend rc $res } [list 1 $msg] # Try to restore from something that is not a database file. # do_test backup2-11 { set rc [catch {db restore temp bu2.db} res] lappend rc $res } {1 {restore failed: file is not a database}} # Try to restore a database that does not exist # do_test backup2-12 { set rc [catch {db restore aux1 bu2.db} res] lappend rc $res } {1 {restore failed: unknown database aux1}} |
︙ | ︙ |
Changes to test/bind.test.
︙ | ︙ | |||
362 363 364 365 366 367 368 | # Test that the 'out of range' error works. do_test bind-8.1 { catch { sqlite3_bind_null $VM 0 } } {1} do_test bind-8.2 { sqlite3_errmsg $DB | | | | | | 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 | # Test that the 'out of range' error works. do_test bind-8.1 { catch { sqlite3_bind_null $VM 0 } } {1} do_test bind-8.2 { sqlite3_errmsg $DB } {column index out of range} ifcapable {utf16} { do_test bind-8.3 { encoding convertfrom unicode [sqlite3_errmsg16 $DB] } {column index out of range} } do_test bind-8.4 { sqlite3_bind_null $VM 1 sqlite3_errmsg $DB } {not an error} do_test bind-8.5 { catch { sqlite3_bind_null $VM 4 } } {1} do_test bind-8.6 { sqlite3_errmsg $DB } {column index out of range} ifcapable {utf16} { do_test bind-8.7 { encoding convertfrom unicode [sqlite3_errmsg16 $DB] } {column index out of range} } do_test bind-8.8 { catch { sqlite3_bind_blob $VM 0 "abc" 3 } } {1} do_test bind-8.9 { catch { sqlite3_bind_blob $VM 4 "abc" 3 } |
︙ | ︙ |
Changes to test/capi3.test.
︙ | ︙ | |||
183 184 185 186 187 188 189 | } [list $::capi3_errno SQLITE_OK] if {[clang_sanitize_address]==0} { do_test capi3-3.6.1-misuse { sqlite3_close $db2 } {SQLITE_MISUSE} do_test capi3-3.6.2-misuse { sqlite3_errmsg $db2 | | | | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | } [list $::capi3_errno SQLITE_OK] if {[clang_sanitize_address]==0} { do_test capi3-3.6.1-misuse { sqlite3_close $db2 } {SQLITE_MISUSE} do_test capi3-3.6.2-misuse { sqlite3_errmsg $db2 } {bad parameter or other API misuse} ifcapable {utf16} { do_test capi3-3.6.3-misuse { utf8 [sqlite3_errmsg16 $db2] } {bad parameter or other API misuse} } } do_test capi3-3.7 { set db2 [sqlite3_open] sqlite3_errcode $db2 } {SQLITE_OK} |
︙ | ︙ | |||
767 768 769 770 771 772 773 | # Test the english language string equivalents for sqlite error codes set code2english [list \ SQLITE_OK {not an error} \ SQLITE_ERROR {SQL logic error} \ SQLITE_PERM {access permission denied} \ | | | | | | 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 | # Test the english language string equivalents for sqlite error codes set code2english [list \ SQLITE_OK {not an error} \ SQLITE_ERROR {SQL logic error} \ SQLITE_PERM {access permission denied} \ SQLITE_ABORT {query aborted} \ SQLITE_BUSY {database is locked} \ SQLITE_LOCKED {database table is locked} \ SQLITE_NOMEM {out of memory} \ SQLITE_READONLY {attempt to write a readonly database} \ SQLITE_INTERRUPT {interrupted} \ SQLITE_IOERR {disk I/O error} \ SQLITE_CORRUPT {database disk image is malformed} \ SQLITE_FULL {database or disk is full} \ SQLITE_CANTOPEN {unable to open database file} \ SQLITE_SCHEMA {database schema has changed} \ SQLITE_CONSTRAINT {constraint failed} \ SQLITE_MISMATCH {datatype mismatch} \ SQLITE_MISUSE {bad parameter or other API misuse} \ SQLITE_AUTH {authorization denied} \ SQLITE_RANGE {column index out of range} \ SQLITE_NOTADB {file is not a database} \ unknownerror {unknown error} \ ] set test_number 1 foreach {code english} $code2english { do_test capi3-9.$test_number "sqlite3_test_errstr $code" $english incr test_number |
︙ | ︙ |
Changes to test/capi3c.test.
︙ | ︙ | |||
172 173 174 175 176 177 178 | } {SQLITE_OK} if {[clang_sanitize_address]==0} { do_test capi3c-3.6.1-misuse { sqlite3_close $db2 } {SQLITE_MISUSE} do_test capi3c-3.6.2-misuse { sqlite3_errmsg $db2 | | | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | } {SQLITE_OK} if {[clang_sanitize_address]==0} { do_test capi3c-3.6.1-misuse { sqlite3_close $db2 } {SQLITE_MISUSE} do_test capi3c-3.6.2-misuse { sqlite3_errmsg $db2 } {bad parameter or other API misuse} ifcapable {utf16} { do_test capi3c-3.6.3-misuse { utf8 [sqlite3_errmsg16 $db2] } {bad parameter or other API misuse} } } # rename sqlite3_open "" # rename sqlite3_open_old sqlite3_open ifcapable {utf16} { |
︙ | ︙ | |||
724 725 726 727 728 729 730 | # Test the english language string equivalents for sqlite error codes set code2english [list \ SQLITE_OK {not an error} \ SQLITE_ERROR {SQL logic error} \ SQLITE_PERM {access permission denied} \ | | | | < < | | | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 | # Test the english language string equivalents for sqlite error codes set code2english [list \ SQLITE_OK {not an error} \ SQLITE_ERROR {SQL logic error} \ SQLITE_PERM {access permission denied} \ SQLITE_ABORT {query aborted} \ SQLITE_BUSY {database is locked} \ SQLITE_LOCKED {database table is locked} \ SQLITE_NOMEM {out of memory} \ SQLITE_READONLY {attempt to write a readonly database} \ SQLITE_INTERRUPT {interrupted} \ SQLITE_IOERR {disk I/O error} \ SQLITE_CORRUPT {database disk image is malformed} \ SQLITE_FULL {database or disk is full} \ SQLITE_CANTOPEN {unable to open database file} \ SQLITE_EMPTY {unknown error} \ SQLITE_SCHEMA {database schema has changed} \ SQLITE_CONSTRAINT {constraint failed} \ SQLITE_MISMATCH {datatype mismatch} \ SQLITE_MISUSE {bad parameter or other API misuse} \ SQLITE_AUTH {authorization denied} \ SQLITE_RANGE {column index out of range} \ SQLITE_NOTADB {file is not a database} \ unknownerror {unknown error} \ ] set test_number 1 foreach {code english} $code2english { do_test capi3c-9.$test_number "sqlite3_test_errstr $code" $english incr test_number |
︙ | ︙ |
Changes to test/close.test.
︙ | ︙ | |||
69 70 71 72 73 74 75 | list [sqlite3_step $STMT] [sqlite3_column_text $STMT 0] } {SQLITE_ROW two} do_test 1.4.3 { list [catch { sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 dummy } msg] $msg | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | list [sqlite3_step $STMT] [sqlite3_column_text $STMT 0] } {SQLITE_ROW two} do_test 1.4.3 { list [catch { sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 dummy } msg] $msg } {1 {(21) bad parameter or other API misuse}} do_test 1.4.4 { sqlite3_finalize $STMT } {SQLITE_OK} finish_test |
Changes to test/corrupt2.test.
︙ | ︙ | |||
55 56 57 58 59 60 61 | close $f sqlite3 db2 corrupt.db catchsql " $::presql SELECT * FROM sqlite_master; " db2 | | | | 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 | close $f sqlite3 db2 corrupt.db catchsql " $::presql SELECT * FROM sqlite_master; " db2 } {1 {file is not a database}} do_test corrupt2-1.3 { db2 close # Corrupt the page-size (bytes 16 and 17 of page 1). forcedelete corrupt.db forcedelete corrupt.db-journal forcecopy test.db corrupt.db set f [open corrupt.db RDWR] fconfigure $f -encoding binary seek $f 16 start puts -nonewline $f "\x00\xFF" close $f sqlite3 db2 corrupt.db catchsql " $::presql SELECT * FROM sqlite_master; " db2 } {1 {file is not a database}} do_test corrupt2-1.4 { db2 close # Corrupt the free-block list on page 1. forcedelete corrupt.db forcedelete corrupt.db-journal |
︙ | ︙ |
Changes to test/corruptA.test.
︙ | ︙ | |||
49 50 51 52 53 54 55 | set unreadable_version 02 ifcapable wal { set unreadable_version 03 } do_test corruptA-2.1 { forcecopy test.db-template test.db hexio_write test.db 19 $unreadable_version ;# the read format number sqlite3 db test.db catchsql {SELECT * FROM t1} | | | | | | 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 | set unreadable_version 02 ifcapable wal { set unreadable_version 03 } do_test corruptA-2.1 { forcecopy test.db-template test.db hexio_write test.db 19 $unreadable_version ;# the read format number sqlite3 db test.db catchsql {SELECT * FROM t1} } {1 {file is not a database}} do_test corruptA-2.2 { db close forcecopy test.db-template test.db hexio_write test.db 21 41 ;# max embedded payload fraction sqlite3 db test.db catchsql {SELECT * FROM t1} } {1 {file is not a database}} do_test corruptA-2.3 { db close forcecopy test.db-template test.db hexio_write test.db 22 1f ;# min embedded payload fraction sqlite3 db test.db catchsql {SELECT * FROM t1} } {1 {file is not a database}} do_test corruptA-2.4 { db close forcecopy test.db-template test.db hexio_write test.db 23 21 ;# min leaf payload fraction sqlite3 db test.db catchsql {SELECT * FROM t1} } {1 {file is not a database}} finish_test |
Changes to test/e_blobwrite.test.
︙ | ︙ | |||
132 133 134 135 136 137 138 | # handle fails with an error code of SQLITE_ABORT. # do_test 2.3 { sqlite3_blob_open db main t2 a 43 0 B execsql { DELETE FROM t2 WHERE b=43 } } {} blob_write_error_test 2.3.1 $B 5 $blob 5 \ | | | | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | # handle fails with an error code of SQLITE_ABORT. # do_test 2.3 { sqlite3_blob_open db main t2 a 43 0 B execsql { DELETE FROM t2 WHERE b=43 } } {} blob_write_error_test 2.3.1 $B 5 $blob 5 \ SQLITE_ABORT {query aborted} do_test 2.3.2 { execsql { SELECT 1, 2, 3 } sqlite3_errcode db } {SQLITE_OK} blob_write_error_test 2.3.3 $B 5 $blob 5 \ SQLITE_ABORT {query aborted} sqlite3_blob_close $B # EVIDENCE-OF: R-08382-59936 Writes to the BLOB that occurred before the # BLOB handle expired are not rolled back by the expiration of the # handle, though of course those changes might have been overwritten by # the statement that expired the BLOB handle or by other independent # statements. |
︙ | ︙ | |||
169 170 171 172 173 174 175 | do_execsql_test 3.1.2 { UPDATE t3 SET k = 'xyz' WHERE i=1; SELECT * FROM t3 WHERE i=1; } { 1 .....0123456789......................... xyz } blob_write_error_test 3.1.3 $B 15 $blob 10 \ | | | | 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 | do_execsql_test 3.1.2 { UPDATE t3 SET k = 'xyz' WHERE i=1; SELECT * FROM t3 WHERE i=1; } { 1 .....0123456789......................... xyz } blob_write_error_test 3.1.3 $B 15 $blob 10 \ SQLITE_ABORT {query aborted} sqlite3_blob_close $B do_execsql_test 3.1.4 { SELECT * FROM t3 WHERE i=1; } { 1 .....0123456789......................... xyz } sqlite3_blob_open db main t3 j 2 1 B blob_write_error_test 3.2.1 $B 5 $blob 10 SQLITE_OK {not an error} do_execsql_test 3.2.2 { UPDATE t3 SET j = 'xyz' WHERE i=2; SELECT * FROM t3 WHERE i=2; } { 2 xyz ........................................ } blob_write_error_test 3.2.3 $B 15 $blob 10 \ SQLITE_ABORT {query aborted} sqlite3_blob_close $B do_execsql_test 3.2.4 { SELECT * FROM t3 WHERE i=2; } { 2 xyz ........................................ } finish_test |
Changes to test/filefmt.test.
︙ | ︙ | |||
41 42 43 44 45 46 47 | set x [catch {sqlite3 db test.db} err] lappend x $err } {0 {}} do_test filefmt-1.3 { catchsql { SELECT count(*) FROM sqlite_master } | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | set x [catch {sqlite3 db test.db} err] lappend x $err } {0 {}} do_test filefmt-1.3 { catchsql { SELECT count(*) FROM sqlite_master } } {1 {file is not a database}} do_test filefmt-1.4 { db close hexio_write test.db 0 53 sqlite3 db test.db catchsql { SELECT count(*) FROM sqlite_master } |
︙ | ︙ | |||
81 82 83 84 85 86 87 | do_test filefmt-1.6 { db close hexio_write test.db 16 [hexio_render_int16 1025] sqlite3 db test.db catchsql { SELECT count(*) FROM sqlite_master } | | | | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | do_test filefmt-1.6 { db close hexio_write test.db 16 [hexio_render_int16 1025] sqlite3 db test.db catchsql { SELECT count(*) FROM sqlite_master } } {1 {file is not a database}} # The page-size must be at least 512 bytes # do_test filefmt-1.7 { db close hexio_write test.db 16 [hexio_render_int16 256] sqlite3 db test.db catchsql { SELECT count(*) FROM sqlite_master } } {1 {file is not a database}} # Usable space per page (page-size minus unused space per page) # must be at least 480 bytes # ifcapable pager_pragmas { do_test filefmt-1.8 { db close forcedelete test.db sqlite3 db test.db db eval {PRAGMA page_size=512; CREATE TABLE t1(x)} db close hexio_write test.db 20 21 sqlite3 db test.db catchsql { SELECT count(*) FROM sqlite_master } } {1 {file is not a database}} } #------------------------------------------------------------------------- # The following block of tests - filefmt-2.* - test that versions 3.7.0 # and later can read and write databases that have been modified or created # by 3.6.23.1 and earlier. The difference difference is that 3.7.0 stores # the size of the database in the database file header, whereas 3.6.23.1 |
︙ | ︙ |
Changes to test/fuzz3.test.
︙ | ︙ | |||
148 149 150 151 152 153 154 | {PRAGMA integrity_check} } { do_test fuzz3-$ii.$iNew.[incr iTest] { foreach {rc msg} [catchsql $sql] {} if {$rc == 0 || $msg eq "database or disk is full" || $msg eq "database disk image is malformed" | | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | {PRAGMA integrity_check} } { do_test fuzz3-$ii.$iNew.[incr iTest] { foreach {rc msg} [catchsql $sql] {} if {$rc == 0 || $msg eq "database or disk is full" || $msg eq "database disk image is malformed" || $msg eq "file is not a database" || [string match "malformed database schema*" $msg] } { set msg ok } set msg } {ok} } |
︙ | ︙ |
Changes to test/incrvacuum.test.
︙ | ︙ | |||
732 733 734 735 736 737 738 | set out [open invalid.db w] puts $out "This is not an SQLite database file" close $out sqlite3 db3 invalid.db catchsql { PRAGMA incremental_vacuum(10); } db3 | | | 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 | set out [open invalid.db w] puts $out "This is not an SQLite database file" close $out sqlite3 db3 invalid.db catchsql { PRAGMA incremental_vacuum(10); } db3 } {1 {file is not a database}} db3 close } do_test incrvacuum-15.1 { db close db2 close forcedelete test.db |
︙ | ︙ |
Changes to test/misc5.test.
︙ | ︙ | |||
518 519 520 521 522 523 524 | set fd [open test.db w] puts $fd "This is not really a database" close $fd sqlite3 db test.db catchsql { CREATE TABLE t1(a,b,c); } | | | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | set fd [open test.db w] puts $fd "This is not really a database" close $fd sqlite3 db test.db catchsql { CREATE TABLE t1(a,b,c); } } {1 {file is not a database}} } # Ticket #1371. Allow floating point numbers of the form .N or N. # do_test misc5-5.1 { execsql {SELECT .1 } } 0.1 |
︙ | ︙ |
Changes to test/misuse.test.
︙ | ︙ | |||
175 176 177 178 179 180 181 | if {[clang_sanitize_address]==0} { do_test misuse-4.4 { # Flush the TCL statement cache here, otherwise the sqlite3_close() will # fail because there are still un-finalized() VDBEs. db cache flush sqlite3_close $::DB catchsql2 {SELECT * FROM t1} | | | | | 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 | if {[clang_sanitize_address]==0} { do_test misuse-4.4 { # Flush the TCL statement cache here, otherwise the sqlite3_close() will # fail because there are still un-finalized() VDBEs. db cache flush sqlite3_close $::DB catchsql2 {SELECT * FROM t1} } {1 {bad parameter or other API misuse}} do_test misuse-4.5 { catchsql { SELECT * FROM t1 } } {1 {bad parameter or other API misuse}} # Attempt to use a database after it has been closed. # do_test misuse-5.1 { db close sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db] execsql { SELECT * FROM t1 } } {1 2} do_test misuse-5.2 { catchsql2 {SELECT * FROM t1} } {0 {a b 1 2}} do_test misuse-5.3 { db close set r [catch { sqlite3_prepare $::DB {SELECT * FROM t1} -1 TAIL } msg] lappend r $msg } {1 {(21) bad parameter or other API misuse}} } finish_test |
Changes to test/pager1.test.
︙ | ︙ | |||
2714 2715 2716 2717 2718 2719 2720 | catch { db close } forcedelete test.db set fd [open test.db w] puts $fd "hello world" close $fd sqlite3 db test.db catchsql { CREATE TABLE t1(x) } | | | 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 | catch { db close } forcedelete test.db set fd [open test.db w] puts $fd "hello world" close $fd sqlite3 db test.db catchsql { CREATE TABLE t1(x) } } {1 {file is not a database}} do_test 38.2 { catch { db close } forcedelete test.db } {} do_test 39.1 { sqlite3 db test.db |
︙ | ︙ |
Changes to test/shared_err.test.
︙ | ︙ | |||
374 375 376 377 378 379 380 | # any time and from any thread #do_test shared_err-misuse-7.1 { # sqlite3 db test.db # catch { # sqlite3_enable_shared_cache 0 # } msg # set msg | | | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | # any time and from any thread #do_test shared_err-misuse-7.1 { # sqlite3 db test.db # catch { # sqlite3_enable_shared_cache 0 # } msg # set msg #} {bad parameter or other API misuse} # Again provoke a malloc() failure when a cursor position is being saved, # this time during a ROLLBACK operation by some other handle. # # The library should return an SQLITE_NOMEM to the caller. The query that # owns the cursor (the one for which the position is not saved) should # be aborted. |
︙ | ︙ |
Changes to test/syscall.test.
︙ | ︙ | |||
214 215 216 217 218 219 220 | fconfigure $fd -translation binary -encoding binary puts -nonewline $fd [string range "xSQLite" 1 $nByte] close $fd } foreach {nByte res} { 1 {0 {}} | | | | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | fconfigure $fd -translation binary -encoding binary puts -nonewline $fd [string range "xSQLite" 1 $nByte] close $fd } foreach {nByte res} { 1 {0 {}} 2 {1 {file is not a database}} 3 {1 {file is not a database}} } { do_test 7.$nByte { create_db_file $nByte list [catch { sqlite3 db test.db execsql { CREATE TABLE t1(a, b) } } msg] $msg |
︙ | ︙ |
Changes to test/vtab1.test.
︙ | ︙ | |||
944 945 946 947 948 949 950 | } {1 {vtable constructor failed: e2}} do_test vtab1.10-2 { set rc [catch { set ptr [sqlite3_connection_pointer db] sqlite3_declare_vtab $ptr {CREATE TABLE abc(a, b, c)} } msg] list $rc $msg | | | 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 | } {1 {vtable constructor failed: e2}} do_test vtab1.10-2 { set rc [catch { set ptr [sqlite3_connection_pointer db] sqlite3_declare_vtab $ptr {CREATE TABLE abc(a, b, c)} } msg] list $rc $msg } {1 {bad parameter or other API misuse}} do_test vtab1.10-3 { set ::echo_module_begin_fail r catchsql { INSERT INTO e VALUES(1, 2, 3); } } {1 {SQL logic error}} do_test vtab1.10-4 { |
︙ | ︙ |
Changes to test/vtab7.test.
︙ | ︙ | |||
158 159 160 161 162 163 164 | # unset -nocomplain ::callbacks(xSync,abc) # set ::callbacks(xCommit,abc) { # execsql { INSERT INTO log VALUES('hello') } # } # catchsql { # INSERT INTO abc2 VALUES(1, 2, 3); # } | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | # unset -nocomplain ::callbacks(xSync,abc) # set ::callbacks(xCommit,abc) { # execsql { INSERT INTO log VALUES('hello') } # } # catchsql { # INSERT INTO abc2 VALUES(1, 2, 3); # } # } {1 {bad parameter or other API misuse}} # These tests, vtab7-4.*, test that an SQLITE_LOCKED error is returned # if an attempt to write to a virtual module table or create a new # virtual table from within an xSync() callback. do_test vtab7-4.1 { execsql { CREATE TABLE def(d, e, f); |
︙ | ︙ |