7531a5a378
FossilOrigin-Name: b7e4dd889d37c8f57c2d3c7900e802f644aac3ea
70 lines
1.5 KiB
Plaintext
70 lines
1.5 KiB
Plaintext
# 2013 July 04
|
|
#
|
|
# The author disclaims copyright to this source code. In place of
|
|
# a legal notice, here is a blessing:
|
|
#
|
|
# May you do good and not evil.
|
|
# May you find forgiveness for yourself and forgive others.
|
|
# May you share freely, never taking more than you give.
|
|
#
|
|
#***********************************************************************
|
|
#
|
|
# This file tests that the sessions module handles foreign key constraint
|
|
# violations when applying changesets as required.
|
|
#
|
|
|
|
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 sessionA
|
|
|
|
|
|
forcedelete test.db2
|
|
sqlite3 db2 test.db2
|
|
foreach {tn db} {1 db 2 db2} {
|
|
do_test 1.$tn.1 {
|
|
execsql {
|
|
CREATE TABLE t1(a PRIMARY KEY, b);
|
|
CREATE TABLE t2(a PRIMARY KEY, b);
|
|
CREATE TABLE t3(a PRIMARY KEY, b);
|
|
} $db
|
|
} {}
|
|
}
|
|
|
|
proc tbl_filter {zTbl} {
|
|
return $::table_filter($zTbl)
|
|
}
|
|
|
|
do_test 2.1 {
|
|
set ::table_filter(t1) 1
|
|
set ::table_filter(t2) 0
|
|
set ::table_filter(t3) 1
|
|
|
|
sqlite3session S db main
|
|
S table_filter tbl_filter
|
|
|
|
execsql {
|
|
INSERT INTO t1 VALUES('a', 'b');
|
|
INSERT INTO t2 VALUES('c', 'd');
|
|
INSERT INTO t3 VALUES('e', 'f');
|
|
}
|
|
|
|
set changeset [S changeset]
|
|
S delete
|
|
sqlite3changeset_apply db2 $changeset xConflict
|
|
|
|
execsql {
|
|
SELECT * FROM t1;
|
|
SELECT * FROM t2;
|
|
SELECT * FROM t3;
|
|
} db2
|
|
} {a b e f}
|
|
|
|
|
|
finish_test
|
|
|
|
|