3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # This file implements regression tests for the sessions module.
13 # Specifically, it tests that operations on tables without primary keys
19 if {![info exists testdir]} {
20 set testdir [file join [file dirname [info script]] .. .. test]
22 source [file join [file dirname [info script]] session_common.tcl]
23 source $testdir/tester.tcl
24 ifcapable !session {finish_test; return}
25 set testprefix sessionE
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.
36 #--------------------------------------------------------------------------
39 CREATE TABLE t1(a, b);
40 CREATE TABLE t2(a PRIMARY KEY, b);
43 sqlite3session S db main
46 INSERT INTO t1 VALUES(1, 2);
47 INSERT INTO t2 VALUES(1, 2);
50 do_changeset_test 1.2 S {
51 {INSERT t2 0 X. {} {i 1 i 2}}
57 CREATE TABLE t1(a, b);
58 CREATE TABLE t2(a PRIMARY KEY, b);
61 sqlite3session S db main
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);
71 do_changeset_test 2.2 S {
72 {INSERT t2 0 X. {} {i 3 i 4}}
73 {INSERT t2 0 X. {} {i 5 i 6}}
80 ATTACH 'test.db2' AS aux;
81 CREATE TABLE aux.t1(a, b);
82 CREATE TABLE aux.t2(a PRIMARY KEY, b);
84 CREATE TABLE t1(a, b);
85 CREATE TABLE t2(a PRIMARY KEY, b);
87 INSERT INTO t1 VALUES(1, 2);
88 INSERT INTO t2 VALUES(3, 4);
91 sqlite3session S db main
98 do_changeset_test 3.2 S {
99 {INSERT t2 0 X. {} {i 3 i 4}}
101 do_execsql_test 3.3 {
102 INSERT INTO t1 VALUES(5, 6);
103 INSERT INTO t2 VALUES(7, 8);
105 do_changeset_test 3.4 S {
106 {INSERT t2 0 X. {} {i 3 i 4}}
107 {INSERT t2 0 X. {} {i 7 i 8}}