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 / sessionE.test

113 lines · 2441 bytes Raw Blame History
1# 2015 June 02
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#
12# This file implements regression tests for the sessions module.
13# Specifically, it tests that operations on tables without primary keys
14# are ignored.
15#
16
17
18
19if {![info exists testdir]} {
20 set testdir [file join [file dirname [info script]] .. .. test]
21}
22source [file join [file dirname [info script]] session_common.tcl]
23source $testdir/tester.tcl
24ifcapable !session {finish_test; return}
25set testprefix sessionE
26
27#
28# Test plan:
29#
30# 1.*: Test that non-PK tables are not auto-attached.
31# 2.*: Test that explicitly attaching a non-PK table is a no-op.
32# 3.*: Test that sqlite3session_diff() on a non-PK table is a no-op.
33#
34
35
36#--------------------------------------------------------------------------
37reset_db
38do_execsql_test 1.0 {
39 CREATE TABLE t1(a, b);
40 CREATE TABLE t2(a PRIMARY KEY, b);
41}
42do_test 1.1 {
43 sqlite3session S db main
44 S attach *
45 execsql {
46 INSERT INTO t1 VALUES(1, 2);
47 INSERT INTO t2 VALUES(1, 2);
48 }
49} {}
50do_changeset_test 1.2 S {
51 {INSERT t2 0 X. {} {i 1 i 2}}
52}
53S delete
54
55reset_db
56do_execsql_test 2.0 {
57 CREATE TABLE t1(a, b);
58 CREATE TABLE t2(a PRIMARY KEY, b);
59}
60do_test 2.1 {
61 sqlite3session S db main
62 S attach t1
63 S attach t2
64 execsql {
65 INSERT INTO t1 VALUES(3, 4);
66 INSERT INTO t2 VALUES(3, 4);
67 INSERT INTO t1 VALUES(5, 6);
68 INSERT INTO t2 VALUES(5, 6);
69 }
70} {}
71do_changeset_test 2.2 S {
72 {INSERT t2 0 X. {} {i 3 i 4}}
73 {INSERT t2 0 X. {} {i 5 i 6}}
74}
75S delete
76
77reset_db
78forcedelete test.db2
79do_execsql_test 3.0 {
80 ATTACH 'test.db2' AS aux;
81 CREATE TABLE aux.t1(a, b);
82 CREATE TABLE aux.t2(a PRIMARY KEY, b);
83
84 CREATE TABLE t1(a, b);
85 CREATE TABLE t2(a PRIMARY KEY, b);
86
87 INSERT INTO t1 VALUES(1, 2);
88 INSERT INTO t2 VALUES(3, 4);
89}
90do_test 3.1 {
91 sqlite3session S db main
92 S attach t1
93 S diff aux t1
94
95 S attach t2
96 S diff aux t2
97} {}
98do_changeset_test 3.2 S {
99 {INSERT t2 0 X. {} {i 3 i 4}}
100}
101do_execsql_test 3.3 {
102 INSERT INTO t1 VALUES(5, 6);
103 INSERT INTO t2 VALUES(7, 8);
104}
105do_changeset_test 3.4 S {
106 {INSERT t2 0 X. {} {i 3 i 4}}
107 {INSERT t2 0 X. {} {i 7 i 8}}
108}
109
110
111S delete
112
113finish_test