track 3.7.0.1

This commit is contained in:
Stephen Lombardo
2010-08-06 23:07:48 -04:00
parent 7b63a4edde
commit 953ca18eb6
11 changed files with 209 additions and 35 deletions
+30
View File
@@ -136,4 +136,34 @@ do_test autoindex1-401 {
}
} {4087}
# Ticket [8011086c85c6c404014c947fcf3eb9f42b184a0d] from 2010-07-08
# Make sure automatic indices are not created for the RHS of an IN expression
# that is not a correlated subquery.
#
do_test autoindex1-500 {
db eval {
CREATE TABLE t501(a INTEGER PRIMARY KEY, b);
CREATE TABLE t502(x INTEGER PRIMARY KEY, y);
EXPLAIN QUERY PLAN
SELECT b FROM t501
WHERE t501.a IN (SELECT x FROM t502 WHERE y=?);
}
} {0 0 {TABLE t501 USING PRIMARY KEY} 0 0 {TABLE t502}}
do_test autoindex1-501 {
db eval {
EXPLAIN QUERY PLAN
SELECT b FROM t501
WHERE t501.a IN (SELECT x FROM t502 WHERE y=t501.b);
}
} {0 0 {TABLE t501} 0 0 {TABLE t502 WITH AUTOMATIC INDEX}}
do_test autoindex1-502 {
db eval {
EXPLAIN QUERY PLAN
SELECT b FROM t501
WHERE t501.a=123
AND t501.a IN (SELECT x FROM t502 WHERE y=t501.b);
}
} {0 0 {TABLE t501 USING PRIMARY KEY} 0 0 {TABLE t502}}
finish_test
+75
View File
@@ -117,5 +117,80 @@ ifcapable pager_pragmas {
} {1 {file is encrypted or 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
# always derives this from the size of the file.
#
db close
file delete -force test.db
set a_string_counter 1
proc a_string {n} {
incr ::a_string_counter
string range [string repeat "${::a_string_counter}." $n] 1 $n
}
sqlite3 db test.db
db func a_string a_string
do_execsql_test filefmt-2.1.1 {
PRAGMA page_size = 1024;
PRAGMA auto_vacuum = 0;
CREATE TABLE t1(a);
CREATE INDEX i1 ON t1(a);
INSERT INTO t1 VALUES(a_string(3000));
CREATE TABLE t2(a);
INSERT INTO t2 VALUES(1);
} {}
do_test filefmt-2.1.2 {
hexio_read test.db 28 4
} {00000009}
do_test filefmt-2.1.3 {
sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }
} {}
do_execsql_test filefmt-2.1.4 { INSERT INTO t2 VALUES(2) } {}
integrity_check filefmt-2.1.5
do_test filefmt-2.1.6 { hexio_read test.db 28 4 } {00000010}
db close
file delete -force test.db
sqlite3 db test.db
db func a_string a_string
do_execsql_test filefmt-2.2.1 {
PRAGMA page_size = 1024;
PRAGMA auto_vacuum = 0;
CREATE TABLE t1(a);
CREATE INDEX i1 ON t1(a);
INSERT INTO t1 VALUES(a_string(3000));
CREATE TABLE t2(a);
INSERT INTO t2 VALUES(1);
} {}
do_test filefmt-2.2.2 {
hexio_read test.db 28 4
} {00000009}
do_test filefmt-2.2.3 {
sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }
} {}
do_execsql_test filefmt-2.2.4 {
PRAGMA integrity_check;
BEGIN;
INSERT INTO t2 VALUES(2);
SAVEPOINT a;
INSERT INTO t2 VALUES(3);
ROLLBACK TO a;
} {ok}
integrity_check filefmt-2.2.5
do_execsql_test filefmt-2.2.6 { COMMIT } {}
db close
sqlite3 db test.db
integrity_check filefmt-2.2.7
finish_test
+33
View File
@@ -1045,4 +1045,37 @@ ifcapable crashtest {
}
}
#-------------------------------------------------------------------------
# When a 3.7.0 client opens a write-transaction on a database file that
# has been appended to or truncated by a pre-370 client, it updates
# the db-size in the file header immediately. This test case provokes
# errors during that operation.
#
do_test pagerfault-22-pre1 {
faultsim_delete_and_reopen
db func a_string a_string
execsql {
PRAGMA page_size = 1024;
PRAGMA auto_vacuum = 0;
CREATE TABLE t1(a);
CREATE INDEX i1 ON t1(a);
INSERT INTO t1 VALUES(a_string(3000));
CREATE TABLE t2(a);
INSERT INTO t2 VALUES(1);
}
db close
sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }
faultsim_save_and_close
} {}
do_faultsim_test pagerfault-22 -prep {
faultsim_restore_and_reopen
} -body {
execsql { INSERT INTO t2 VALUES(2) }
execsql { SELECT * FROM t2 }
} -test {
faultsim_test_result {0 {1 2}}
faultsim_integrity_check
}
finish_test
+17
View File
@@ -1225,6 +1225,23 @@ proc slave_test_file {zFile} {
show_memstats
}
# Open a new connection on database test.db and execute the SQL script
# supplied as an argument. Before returning, close the new conection and
# restore the 4 byte fields starting at header offsets 28, 92 and 96
# to the values they held before the SQL was executed. This simulates
# a write by a pre-3.7.0 client.
#
proc sql36231 {sql} {
set B [hexio_read test.db 92 8]
set A [hexio_read test.db 28 4]
sqlite3 db36231 test.db
catch { db36231 func a_string a_string }
execsql $sql db36231
db36231 close
hexio_write test.db 28 $A
hexio_write test.db 92 $B
return ""
}
# If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
# to non-zero, then set the global variable $AUTOVACUUM to 1.