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.

FossilOrigin-Name: f27b6370407842e2c175ea4aa9ce018723c57eaac0cccc1f8399bc20f33324be
This commit is contained in:
drh
2017-07-10 12:07:53 +00:00
parent e75be1aedb
commit ff4fa772f5
22 changed files with 104 additions and 108 deletions
+1 -1
View File
@@ -792,7 +792,7 @@ do_test attach-8.1 {
catchsql {
ATTACH 'test2.db' AS t2;
}
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
do_test attach-8.2 {
db errorcode
} {26}
+3 -3
View File
@@ -122,7 +122,7 @@ do_test backup2-7 {
close $out
set rc [catch {db backup temp bu2.db} res]
lappend rc $res
} {1 {backup failed: file is encrypted or is not a database}}
} {1 {backup failed: file is not a database}}
# Try to backup database that does not exist
#
@@ -144,7 +144,7 @@ do_test backup2-9 {
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 encrypted or is not a database}
set msg {restore failed: file is not a database}
} else {
set msg {cannot open source database: disk I/O error}
}
@@ -160,7 +160,7 @@ do_test backup2-10 {
do_test backup2-11 {
set rc [catch {db restore temp bu2.db} res]
lappend rc $res
} {1 {restore failed: file is encrypted or is not a database}}
} {1 {restore failed: file is not a database}}
# Try to restore a database that does not exist
#
+4 -4
View File
@@ -366,11 +366,11 @@ do_test bind-8.1 {
} {1}
do_test bind-8.2 {
sqlite3_errmsg $DB
} {bind or column index out of range}
} {column index out of range}
ifcapable {utf16} {
do_test bind-8.3 {
encoding convertfrom unicode [sqlite3_errmsg16 $DB]
} {bind or column index out of range}
} {column index out of range}
}
do_test bind-8.4 {
sqlite3_bind_null $VM 1
@@ -381,11 +381,11 @@ do_test bind-8.5 {
} {1}
do_test bind-8.6 {
sqlite3_errmsg $DB
} {bind or column index out of range}
} {column index out of range}
ifcapable {utf16} {
do_test bind-8.7 {
encoding convertfrom unicode [sqlite3_errmsg16 $DB]
} {bind or column index out of range}
} {column index out of range}
}
do_test bind-8.8 {
+6 -6
View File
@@ -187,11 +187,11 @@ if {[clang_sanitize_address]==0} {
} {SQLITE_MISUSE}
do_test capi3-3.6.2-misuse {
sqlite3_errmsg $db2
} {library routine called out of sequence}
} {bad parameter or other API misuse}
ifcapable {utf16} {
do_test capi3-3.6.3-misuse {
utf8 [sqlite3_errmsg16 $db2]
} {library routine called out of sequence}
} {bad parameter or other API misuse}
}
}
@@ -771,7 +771,7 @@ set code2english [list \
SQLITE_OK {not an error} \
SQLITE_ERROR {SQL logic error} \
SQLITE_PERM {access permission denied} \
SQLITE_ABORT {callback requested query abort} \
SQLITE_ABORT {query aborted} \
SQLITE_BUSY {database is locked} \
SQLITE_LOCKED {database table is locked} \
SQLITE_NOMEM {out of memory} \
@@ -784,10 +784,10 @@ SQLITE_CANTOPEN {unable to open database file} \
SQLITE_SCHEMA {database schema has changed} \
SQLITE_CONSTRAINT {constraint failed} \
SQLITE_MISMATCH {datatype mismatch} \
SQLITE_MISUSE {library routine called out of sequence} \
SQLITE_MISUSE {bad parameter or other API misuse} \
SQLITE_AUTH {authorization denied} \
SQLITE_RANGE {bind or column index out of range} \
SQLITE_NOTADB {file is encrypted or is not a database} \
SQLITE_RANGE {column index out of range} \
SQLITE_NOTADB {file is not a database} \
unknownerror {unknown error} \
]
+7 -9
View File
@@ -176,11 +176,11 @@ if {[clang_sanitize_address]==0} {
} {SQLITE_MISUSE}
do_test capi3c-3.6.2-misuse {
sqlite3_errmsg $db2
} {library routine called out of sequence}
} {bad parameter or other API misuse}
ifcapable {utf16} {
do_test capi3c-3.6.3-misuse {
utf8 [sqlite3_errmsg16 $db2]
} {library routine called out of sequence}
} {bad parameter or other API misuse}
}
}
@@ -728,7 +728,7 @@ set code2english [list \
SQLITE_OK {not an error} \
SQLITE_ERROR {SQL logic error} \
SQLITE_PERM {access permission denied} \
SQLITE_ABORT {callback requested query abort} \
SQLITE_ABORT {query aborted} \
SQLITE_BUSY {database is locked} \
SQLITE_LOCKED {database table is locked} \
SQLITE_NOMEM {out of memory} \
@@ -738,16 +738,14 @@ 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 {table contains no data} \
SQLITE_EMPTY {unknown error} \
SQLITE_SCHEMA {database schema has changed} \
SQLITE_CONSTRAINT {constraint failed} \
SQLITE_MISMATCH {datatype mismatch} \
SQLITE_MISUSE {library routine called out of sequence} \
SQLITE_NOLFS {large file support is disabled} \
SQLITE_MISUSE {bad parameter or other API misuse} \
SQLITE_AUTH {authorization denied} \
SQLITE_FORMAT {auxiliary database format error} \
SQLITE_RANGE {bind or column index out of range} \
SQLITE_NOTADB {file is encrypted or is not a database} \
SQLITE_RANGE {column index out of range} \
SQLITE_NOTADB {file is not a database} \
unknownerror {unknown error} \
]
+1 -1
View File
@@ -73,7 +73,7 @@ do_test 1.4.3 {
list [catch {
sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 dummy
} msg] $msg
} {1 {(21) library routine called out of sequence}}
} {1 {(21) bad parameter or other API misuse}}
do_test 1.4.4 {
sqlite3_finalize $STMT
+2 -2
View File
@@ -59,7 +59,7 @@ do_test corrupt2-1.2 {
$::presql
SELECT * FROM sqlite_master;
" db2
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
do_test corrupt2-1.3 {
db2 close
@@ -79,7 +79,7 @@ do_test corrupt2-1.3 {
$::presql
SELECT * FROM sqlite_master;
" db2
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
do_test corrupt2-1.4 {
db2 close
+4 -4
View File
@@ -53,7 +53,7 @@ do_test corruptA-2.1 {
hexio_write test.db 19 $unreadable_version ;# the read format number
sqlite3 db test.db
catchsql {SELECT * FROM t1}
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
do_test corruptA-2.2 {
db close
@@ -61,7 +61,7 @@ do_test corruptA-2.2 {
hexio_write test.db 21 41 ;# max embedded payload fraction
sqlite3 db test.db
catchsql {SELECT * FROM t1}
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
do_test corruptA-2.3 {
db close
@@ -69,7 +69,7 @@ do_test corruptA-2.3 {
hexio_write test.db 22 1f ;# min embedded payload fraction
sqlite3 db test.db
catchsql {SELECT * FROM t1}
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
do_test corruptA-2.4 {
db close
@@ -77,7 +77,7 @@ do_test corruptA-2.4 {
hexio_write test.db 23 21 ;# min leaf payload fraction
sqlite3 db test.db
catchsql {SELECT * FROM t1}
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
finish_test
+4 -4
View File
@@ -136,13 +136,13 @@ do_test 2.3 {
execsql { DELETE FROM t2 WHERE b=43 }
} {}
blob_write_error_test 2.3.1 $B 5 $blob 5 \
SQLITE_ABORT {callback requested query abort}
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 {callback requested query abort}
SQLITE_ABORT {query aborted}
sqlite3_blob_close $B
# EVIDENCE-OF: R-08382-59936 Writes to the BLOB that occurred before the
@@ -173,7 +173,7 @@ do_execsql_test 3.1.2 {
1 .....0123456789......................... xyz
}
blob_write_error_test 3.1.3 $B 15 $blob 10 \
SQLITE_ABORT {callback requested query abort}
SQLITE_ABORT {query aborted}
sqlite3_blob_close $B
do_execsql_test 3.1.4 {
SELECT * FROM t3 WHERE i=1;
@@ -190,7 +190,7 @@ do_execsql_test 3.2.2 {
2 xyz ........................................
}
blob_write_error_test 3.2.3 $B 15 $blob 10 \
SQLITE_ABORT {callback requested query abort}
SQLITE_ABORT {query aborted}
sqlite3_blob_close $B
do_execsql_test 3.2.4 {
SELECT * FROM t3 WHERE i=2;
+4 -4
View File
@@ -45,7 +45,7 @@ do_test filefmt-1.3 {
catchsql {
SELECT count(*) FROM sqlite_master
}
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
do_test filefmt-1.4 {
db close
hexio_write test.db 0 53
@@ -85,7 +85,7 @@ do_test filefmt-1.6 {
catchsql {
SELECT count(*) FROM sqlite_master
}
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
# The page-size must be at least 512 bytes
@@ -97,7 +97,7 @@ do_test filefmt-1.7 {
catchsql {
SELECT count(*) FROM sqlite_master
}
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
# Usable space per page (page-size minus unused space per page)
# must be at least 480 bytes
@@ -114,7 +114,7 @@ ifcapable pager_pragmas {
catchsql {
SELECT count(*) FROM sqlite_master
}
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
}
#-------------------------------------------------------------------------
+1 -1
View File
@@ -152,7 +152,7 @@ for {set ii 0} {$ii < 5000} {incr ii} {
if {$rc == 0
|| $msg eq "database or disk is full"
|| $msg eq "database disk image is malformed"
|| $msg eq "file is encrypted or is not a database"
|| $msg eq "file is not a database"
|| [string match "malformed database schema*" $msg]
} {
set msg ok
+1 -1
View File
@@ -736,7 +736,7 @@ if {[permutation] == ""} {
catchsql {
PRAGMA incremental_vacuum(10);
} db3
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
db3 close
}
+1 -1
View File
@@ -522,7 +522,7 @@ if {[permutation] == ""} {
catchsql {
CREATE TABLE t1(a,b,c);
}
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
}
# Ticket #1371. Allow floating point numbers of the form .N or N.
+3 -3
View File
@@ -179,12 +179,12 @@ if {[clang_sanitize_address]==0} {
db cache flush
sqlite3_close $::DB
catchsql2 {SELECT * FROM t1}
} {1 {library routine called out of sequence}}
} {1 {bad parameter or other API misuse}}
do_test misuse-4.5 {
catchsql {
SELECT * FROM t1
}
} {1 {library routine called out of sequence}}
} {1 {bad parameter or other API misuse}}
# Attempt to use a database after it has been closed.
#
@@ -204,7 +204,7 @@ if {[clang_sanitize_address]==0} {
sqlite3_prepare $::DB {SELECT * FROM t1} -1 TAIL
} msg]
lappend r $msg
} {1 {(21) library routine called out of sequence}}
} {1 {(21) bad parameter or other API misuse}}
}
finish_test
+1 -1
View File
@@ -2718,7 +2718,7 @@ do_test 38.1 {
close $fd
sqlite3 db test.db
catchsql { CREATE TABLE t1(x) }
} {1 {file is encrypted or is not a database}}
} {1 {file is not a database}}
do_test 38.2 {
catch { db close }
forcedelete test.db
+1 -1
View File
@@ -378,7 +378,7 @@ do_malloc_test shared_err-6 -tclbody {
# sqlite3_enable_shared_cache 0
# } msg
# set msg
#} {library routine called out of sequence}
#} {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.
+2 -2
View File
@@ -218,8 +218,8 @@ proc create_db_file {nByte} {
foreach {nByte res} {
1 {0 {}}
2 {1 {file is encrypted or is not a database}}
3 {1 {file is encrypted or is not a database}}
2 {1 {file is not a database}}
3 {1 {file is not a database}}
} {
do_test 7.$nByte {
create_db_file $nByte
+1 -1
View File
@@ -948,7 +948,7 @@ do_test vtab1.10-2 {
sqlite3_declare_vtab $ptr {CREATE TABLE abc(a, b, c)}
} msg]
list $rc $msg
} {1 {library routine called out of sequence}}
} {1 {bad parameter or other API misuse}}
do_test vtab1.10-3 {
set ::echo_module_begin_fail r
catchsql {
+1 -1
View File
@@ -162,7 +162,7 @@ ifcapable attach {
# catchsql {
# INSERT INTO abc2 VALUES(1, 2, 3);
# }
# } {1 {library routine called out of sequence}}
# } {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