interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / session / sessionconflict.test

76 lines · 1657 bytes Raw Blame History
1# 2011 March 07
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11# This file implements regression tests for SQLite library.
12#
13
14if {![info exists testdir]} {
15 set testdir [file join [file dirname [info script]] .. .. test]
16}
17source [file join [file dirname [info script]] session_common.tcl]
18source $testdir/tester.tcl
19ifcapable !session {finish_test; return}
20
21set testprefix sessionconflict
22
23db close
24sqlite3_shutdown
25test_sqlite3_log log
26proc log {code msg} { puts "LOG $code $msg" }
27sqlite3 db test.db
28
29forcedelete test.db2
30sqlite3 db2 test.db2
31
32do_test 1.0 {
33 do_common_sql {
34 CREATE TABLE t1(a PRIMARY KEY, b, c UNIQUE);
35 INSERT INTO t1 VALUES(1, 1, 1);
36 INSERT INTO t1 VALUES(2, 2, 2);
37 INSERT INTO t1 VALUES(3, 3, 3);
38 }
39} {}
40
41do_execsql_test -db db2 1.1 {
42 INSERT INTO t1 VALUES(6, 6, 6);
43}
44
45proc xConflict {args} {
46 return "ABORT"
47}
48
49
50do_test 1.2 {
51 set chng [changeset_from_sql {
52 UPDATE t1 SET b=10, c=10 WHERE a=1;
53 UPDATE t1 SET b=444 WHERE a=2;
54 INSERT INTO t1 VALUES(4, 4, 4);
55 INSERT INTO t1 VALUES(5, 5, 5);
56 INSERT INTO t1 VALUES(6, 6, 6);
57 }]
58
59 execsql BEGIN db2
60 set res [list [catch { sqlite3changeset_apply db2 $chng xConflict } msg] $msg]
61 execsql ROLLBACK db2
62 set res
63} {1 SQLITE_ABORT}
64
65do_execsql_test -db db2 1.3 {
66 SELECT * FROM t1;
67} {
68 1 1 1
69 2 2 2
70 3 3 3
71 6 6 6
72}
73
74
75db2 close
76finish_test