|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if {![info exists testdir]} { |
|
|
set testdir [file join [file dirname [info script]] .. .. test] |
|
|
} |
|
|
source [file join [file dirname [info script]] session_common.tcl] |
|
|
source $testdir/tester.tcl |
|
|
ifcapable !session {finish_test; return} |
|
|
|
|
|
set testprefix session3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db close |
|
|
sqlite3_shutdown |
|
|
test_sqlite3_log log |
|
|
sqlite3 db test.db |
|
|
|
|
|
proc log {code msg} { lappend ::log $code $msg } |
|
|
|
|
|
forcedelete test.db2 |
|
|
sqlite3 db2 test.db2 |
|
|
|
|
|
do_execsql_test 1.0 { |
|
|
CREATE TABLE t1(a PRIMARY KEY, b); |
|
|
} |
|
|
do_test 1.1 { |
|
|
set ::log {} |
|
|
do_then_apply_sql { |
|
|
INSERT INTO t1 VALUES(1, 2); |
|
|
INSERT INTO t1 VALUES(3, 4); |
|
|
} |
|
|
set ::log |
|
|
} {SQLITE_SCHEMA {sqlite3changeset_apply(): no such table: t1}} |
|
|
|
|
|
do_test 1.2.0 { |
|
|
execsql { CREATE TABLE t1(a PRIMARY KEY, b, c) } db2 |
|
|
} {} |
|
|
do_test 1.2.1 { |
|
|
set ::log {} |
|
|
do_then_apply_sql { |
|
|
INSERT INTO t1 VALUES(5, 6); |
|
|
INSERT INTO t1 VALUES(7, 8); |
|
|
} |
|
|
set ::log |
|
|
} {} |
|
|
do_test 1.2.2 { |
|
|
db2 eval { SELECT * FROM t1 } |
|
|
} {5 6 {} 7 8 {}} |
|
|
|
|
|
do_test 1.3.0 { |
|
|
execsql { |
|
|
DROP TABLE t1; |
|
|
CREATE TABLE t1(a, b PRIMARY KEY); |
|
|
} db2 |
|
|
} {} |
|
|
do_test 1.3.1 { |
|
|
set ::log {} |
|
|
do_then_apply_sql { |
|
|
INSERT INTO t1 VALUES(9, 10); |
|
|
INSERT INTO t1 VALUES(11, 12); |
|
|
} |
|
|
set ::log |
|
|
} {SQLITE_SCHEMA {sqlite3changeset_apply(): primary key mismatch for table t1}} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do_test 2.1 { |
|
|
execsql { CREATE TABLE t2(a, b PRIMARY KEY) } |
|
|
sqlite3session S db main |
|
|
S attach t2 |
|
|
execsql { |
|
|
INSERT INTO t2 VALUES(1, 2); |
|
|
DROP TABLE t2; |
|
|
} |
|
|
list [catch { S changeset } msg] $msg |
|
|
} {1 SQLITE_SCHEMA} |
|
|
|
|
|
do_test 2.2.1 { |
|
|
S delete |
|
|
sqlite3session S db main |
|
|
execsql { CREATE TABLE t2(a, b PRIMARY KEY, c) } |
|
|
S attach t2 |
|
|
execsql { |
|
|
INSERT INTO t2 VALUES(1, 2, 3); |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a, b PRIMARY KEY); |
|
|
} |
|
|
list [catch { S changeset } msg] $msg |
|
|
} {1 SQLITE_SCHEMA} |
|
|
do_test 2.2.2 { |
|
|
S delete |
|
|
sqlite3session S db main |
|
|
execsql { |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a, b PRIMARY KEY, c); |
|
|
} |
|
|
S attach t2 |
|
|
execsql { |
|
|
INSERT INTO t2 VALUES(1, 2, 3); |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a, b PRIMARY KEY, c, d); |
|
|
} |
|
|
catch { S changeset } |
|
|
} {0} |
|
|
do_test 2.2.3 { |
|
|
S delete |
|
|
sqlite3session S db main |
|
|
execsql { |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a, b PRIMARY KEY, c); |
|
|
} |
|
|
S attach t2 |
|
|
execsql { |
|
|
INSERT INTO t2 VALUES(1, 2, 3); |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a, b PRIMARY KEY); |
|
|
INSERT INTO t2 VALUES(4, 5); |
|
|
} |
|
|
list [catch { S changeset } msg] $msg |
|
|
} {1 SQLITE_SCHEMA} |
|
|
do_test 2.2.4 { |
|
|
S delete |
|
|
sqlite3session S db main |
|
|
execsql { |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a, b PRIMARY KEY, c); |
|
|
} |
|
|
S attach t2 |
|
|
execsql { |
|
|
INSERT INTO t2 VALUES(1, 2, 3); |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a, b PRIMARY KEY, c, d); |
|
|
INSERT INTO t2 VALUES(4, 5, 6, 7); |
|
|
} |
|
|
catch { S changeset } |
|
|
} {0} |
|
|
|
|
|
do_test 2.3 { |
|
|
S delete |
|
|
sqlite3session S db main |
|
|
execsql { |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a, b PRIMARY KEY); |
|
|
} |
|
|
S attach t2 |
|
|
execsql { |
|
|
INSERT INTO t2 VALUES(1, 2); |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a PRIMARY KEY, b); |
|
|
} |
|
|
list [catch { S changeset } msg] $msg |
|
|
} {1 SQLITE_SCHEMA} |
|
|
|
|
|
do_test 2.4 { |
|
|
S delete |
|
|
sqlite3session S db main |
|
|
execsql { |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a, b PRIMARY KEY); |
|
|
} |
|
|
S attach t2 |
|
|
execsql { |
|
|
INSERT INTO t2 VALUES(1, 2); |
|
|
DROP TABLE t2; |
|
|
CREATE TABLE t2(a, b PRIMARY KEY); |
|
|
} |
|
|
list [catch { S changeset } msg] $msg |
|
|
} {0 {}} |
|
|
|
|
|
S delete |
|
|
|
|
|
|
|
|
catch { db close } |
|
|
catch { db2 close } |
|
|
sqlite3_shutdown |
|
|
test_sqlite3_log |
|
|
sqlite3_initialize |
|
|
|
|
|
finish_test |
|
|
|