mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Fix bugs associated with the codec. (CVS 1846)
FossilOrigin-Name: b0a3becd82b9a4203c23f35dc5a5fd725e046f21
This commit is contained in:
166
test/capi3.test
166
test/capi3.test
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script testing the callback-free C/C++ API.
|
||||
#
|
||||
# $Id: capi3.test,v 1.19 2004/06/30 06:30:26 danielk1977 Exp $
|
||||
# $Id: capi3.test,v 1.20 2004/07/22 15:02:26 drh Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -443,6 +443,7 @@ db close
|
||||
|
||||
do_test capi3-6.0 {
|
||||
set DB [sqlite3_open test.db]
|
||||
sqlite3_key $DB xyzzy
|
||||
set sql {SELECT a FROM t1 order by rowid}
|
||||
set STMT [sqlite3_prepare $DB $sql -1 TAIL]
|
||||
expr 0
|
||||
@ -461,87 +462,93 @@ do_test capi3-6.4 {
|
||||
sqlite3_close $DB
|
||||
} {SQLITE_OK}
|
||||
|
||||
# Test what happens when the library encounters a newer file format.
|
||||
# Do this by updating the file format via the btree layer.
|
||||
do_test capi3-7.1 {
|
||||
set ::bt [btree_open test.db 10 0]
|
||||
btree_begin_transaction $::bt
|
||||
set meta [btree_get_meta $::bt]
|
||||
lset meta 2 2
|
||||
eval [concat btree_update_meta $::bt [lrange $meta 0 end]]
|
||||
btree_commit $::bt
|
||||
btree_close $::bt
|
||||
} {}
|
||||
do_test capi3-7.2 {
|
||||
sqlite3 db test.db
|
||||
breakpoint
|
||||
catchsql {
|
||||
SELECT * FROM sqlite_master;
|
||||
}
|
||||
} {1 {unsupported file format}}
|
||||
|
||||
# Now test that the library correctly handles bogus entries in the
|
||||
# sqlite_master table (schema corruption).
|
||||
do_test capi3-8.1 {
|
||||
if {![sqlite3 -has-codec]} {
|
||||
# Test what happens when the library encounters a newer file format.
|
||||
# Do this by updating the file format via the btree layer.
|
||||
do_test capi3-7.1 {
|
||||
set ::bt [btree_open test.db 10 0]
|
||||
btree_begin_transaction $::bt
|
||||
set meta [btree_get_meta $::bt]
|
||||
lset meta 2 2
|
||||
eval [concat btree_update_meta $::bt [lrange $meta 0 end]]
|
||||
btree_commit $::bt
|
||||
btree_close $::bt
|
||||
} {}
|
||||
do_test capi3-7.2 {
|
||||
sqlite3 db test.db
|
||||
catchsql {
|
||||
SELECT * FROM sqlite_master;
|
||||
}
|
||||
} {1 {unsupported file format}}
|
||||
db close
|
||||
file delete -force test.db
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
CREATE TABLE t1(a);
|
||||
}
|
||||
}
|
||||
|
||||
if {![sqlite3 -has-codec]} {
|
||||
# Now test that the library correctly handles bogus entries in the
|
||||
# sqlite_master table (schema corruption).
|
||||
do_test capi3-8.1 {
|
||||
file delete -force test.db
|
||||
file delete -force test.db-journal
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
CREATE TABLE t1(a);
|
||||
}
|
||||
db close
|
||||
} {}
|
||||
do_test capi3-8.2 {
|
||||
set ::bt [btree_open test.db 10 0]
|
||||
btree_begin_transaction $::bt
|
||||
set ::bc [btree_cursor $::bt 1 1]
|
||||
|
||||
# Build a 5-field row record consisting of 5 null records. This is
|
||||
# officially black magic.
|
||||
catch {unset data}
|
||||
set data [binary format c6 {6 0 0 0 0 0}]
|
||||
btree_insert $::bc 5 $data
|
||||
|
||||
btree_close_cursor $::bc
|
||||
btree_commit $::bt
|
||||
btree_close $::bt
|
||||
} {}
|
||||
do_test capi3-8.3 {
|
||||
sqlite3 db test.db
|
||||
catchsql {
|
||||
SELECT * FROM sqlite_master;
|
||||
}
|
||||
} {1 {malformed database schema}}
|
||||
do_test capi3-8.4 {
|
||||
set ::bt [btree_open test.db 10 0]
|
||||
btree_begin_transaction $::bt
|
||||
set ::bc [btree_cursor $::bt 1 1]
|
||||
|
||||
# Build a 5-field row record. The first field is a string 'table', and
|
||||
# subsequent fields are all NULL. Replace the other broken record with
|
||||
# this one and try to read the schema again. The broken record uses
|
||||
# either UTF-8 or native UTF-16 (if this file is being run by
|
||||
# utf16.test).
|
||||
if { [string match UTF-16* $::ENC] } {
|
||||
set data [binary format c6a10 {6 33 0 0 0 0} [utf16 table]]
|
||||
} else {
|
||||
set data [binary format c6a5 {6 23 0 0 0 0} table]
|
||||
}
|
||||
btree_insert $::bc 5 $data
|
||||
|
||||
btree_close_cursor $::bc
|
||||
btree_commit $::bt
|
||||
btree_close $::bt
|
||||
} {}
|
||||
do_test capi3-8.5 {
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
catchsql {
|
||||
SELECT * FROM sqlite_master;
|
||||
}
|
||||
} {1 {malformed database schema}}
|
||||
db close
|
||||
} {}
|
||||
do_test capi3-8.2 {
|
||||
set ::bt [btree_open test.db 10 0]
|
||||
btree_begin_transaction $::bt
|
||||
set ::bc [btree_cursor $::bt 1 1]
|
||||
|
||||
# Build a 5-field row record consisting of 5 null records. This is
|
||||
# officially black magic.
|
||||
catch {unset data}
|
||||
set data [binary format c6 {6 0 0 0 0 0}]
|
||||
btree_insert $::bc 5 $data
|
||||
|
||||
btree_close_cursor $::bc
|
||||
btree_commit $::bt
|
||||
btree_close $::bt
|
||||
} {}
|
||||
do_test capi3-8.3 {
|
||||
sqlite3 db test.db
|
||||
catchsql {
|
||||
SELECT * FROM sqlite_master;
|
||||
}
|
||||
} {1 {malformed database schema}}
|
||||
do_test capi3-8.4 {
|
||||
set ::bt [btree_open test.db 10 0]
|
||||
btree_begin_transaction $::bt
|
||||
set ::bc [btree_cursor $::bt 1 1]
|
||||
|
||||
# Build a 5-field row record. The first field is a string 'table', and
|
||||
# subsequent fields are all NULL. Replace the other broken record with
|
||||
# this one and try to read the schema again. The broken record uses
|
||||
# either UTF-8 or native UTF-16 (if this file is being run by
|
||||
# utf16.test).
|
||||
if { [string match UTF-16* $::ENC] } {
|
||||
set data [binary format c6a10 {6 33 0 0 0 0} [utf16 table]]
|
||||
} else {
|
||||
set data [binary format c6a5 {6 23 0 0 0 0} table]
|
||||
}
|
||||
btree_insert $::bc 5 $data
|
||||
|
||||
btree_close_cursor $::bc
|
||||
btree_commit $::bt
|
||||
btree_close $::bt
|
||||
} {}
|
||||
do_test capi3-8.5 {
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
catchsql {
|
||||
SELECT * FROM sqlite_master;
|
||||
}
|
||||
} {1 {malformed database schema}}
|
||||
db close
|
||||
}
|
||||
file delete -force test.db
|
||||
file delete -force test.db-journal
|
||||
|
||||
|
||||
# Test the english language string equivalents for sqlite error codes
|
||||
set code2english [list \
|
||||
@ -761,4 +768,3 @@ do_test capi3-12.8 {
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is database locks between competing processes.
|
||||
#
|
||||
# $Id: lock2.test,v 1.2 2004/06/28 11:52:46 drh Exp $
|
||||
# $Id: lock2.test,v 1.3 2004/07/22 15:02:26 drh Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -89,7 +89,7 @@ close $f
|
||||
do_test lock2-1.1 {
|
||||
set ::tf1 [launch_testfixture]
|
||||
testfixture $::tf1 {
|
||||
sqlite3 db test.db
|
||||
sqlite3 db test.db -key xyzzy
|
||||
db eval {select * from sqlite_master}
|
||||
}
|
||||
} {}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#
|
||||
# This file implements tests for the PRAGMA command.
|
||||
#
|
||||
# $Id: pragma.test,v 1.15 2004/06/26 19:35:30 drh Exp $
|
||||
# $Id: pragma.test,v 1.16 2004/07/22 15:02:26 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -207,7 +207,8 @@ do_test pragma-2.4 {
|
||||
# Construct a corrupted index and make sure the integrity_check
|
||||
# pragma finds it.
|
||||
#
|
||||
if {![sqlite3 -has-codec]} {
|
||||
# These tests won't work if the database is encrypted
|
||||
#
|
||||
do_test pragma-3.1 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
@ -219,19 +220,19 @@ do_test pragma-3.1 {
|
||||
SELECT rowid, * from t2;
|
||||
}
|
||||
} {1 11 2 3 2 22 3 4}
|
||||
do_test pragma-3.2 {
|
||||
set rootpage [execsql {SELECT rootpage FROM sqlite_master WHERE name='i2'}]
|
||||
set db [btree_open test.db 100 0]
|
||||
btree_begin_transaction $db
|
||||
set c [btree_cursor $db $rootpage 1]
|
||||
btree_first $c
|
||||
btree_delete $c
|
||||
btree_commit $db
|
||||
btree_close $db
|
||||
execsql {PRAGMA integrity_check}
|
||||
} {{rowid 1 missing from index i2} {wrong # of entries in index i2}}
|
||||
}; # endif has-codec
|
||||
|
||||
if {![sqlite3 -has-codec]} {
|
||||
do_test pragma-3.2 {
|
||||
set rootpage [execsql {SELECT rootpage FROM sqlite_master WHERE name='i2'}]
|
||||
set db [btree_open test.db 100 0]
|
||||
btree_begin_transaction $db
|
||||
set c [btree_cursor $db $rootpage 1]
|
||||
btree_first $c
|
||||
btree_delete $c
|
||||
btree_commit $db
|
||||
btree_close $db
|
||||
execsql {PRAGMA integrity_check}
|
||||
} {{rowid 1 missing from index i2} {wrong # of entries in index i2}}
|
||||
}
|
||||
do_test pragma-3.3 {
|
||||
execsql {
|
||||
DROP INDEX i2;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#***********************************************************************
|
||||
# This file runs all tests.
|
||||
#
|
||||
# $Id: quick.test,v 1.27 2004/07/19 00:39:46 drh Exp $
|
||||
# $Id: quick.test,v 1.28 2004/07/22 15:02:26 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -25,18 +25,13 @@ set EXCLUDE {
|
||||
malloc.test
|
||||
memleak.test
|
||||
misuse.test
|
||||
format3.test
|
||||
crash.test
|
||||
utf16.test
|
||||
}
|
||||
|
||||
if {[sqlite3 -has-codec]} {
|
||||
lappend EXCLUDE \
|
||||
attach.test \
|
||||
attach2.test \
|
||||
auth.test \
|
||||
format3.test \
|
||||
version.test
|
||||
# lappend EXCLUDE \
|
||||
# conflict.test
|
||||
}
|
||||
|
||||
foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
|
||||
|
@ -12,7 +12,7 @@
|
||||
# it tests that the different storage classes (integer, real, text etc.)
|
||||
# all work correctly.
|
||||
#
|
||||
# $Id: types.test,v 1.9 2004/06/30 03:08:25 drh Exp $
|
||||
# $Id: types.test,v 1.10 2004/07/22 15:02:26 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -37,6 +37,10 @@ source $testdir/tester.tcl
|
||||
# types-3.*: Test that the '=' operator respects manifest types.
|
||||
#
|
||||
|
||||
# Disable encryption on the database for this test.
|
||||
db close
|
||||
set DB [sqlite3 db test.db]
|
||||
sqlite3_rekey $DB {}
|
||||
|
||||
# Create a table with one column for each type of affinity
|
||||
do_test types-1.1.0 {
|
||||
|
Reference in New Issue
Block a user