16dc29e60Sdan# 2015 June 02 26dc29e60Sdan# 36dc29e60Sdan# The author disclaims copyright to this source code. In place of 46dc29e60Sdan# a legal notice, here is a blessing: 56dc29e60Sdan# 66dc29e60Sdan# May you do good and not evil. 76dc29e60Sdan# May you find forgiveness for yourself and forgive others. 86dc29e60Sdan# May you share freely, never taking more than you give. 96dc29e60Sdan# 106dc29e60Sdan#*********************************************************************** 116dc29e60Sdan# 126dc29e60Sdan# This file implements regression tests for the sessions module. 136dc29e60Sdan# Specifically, it tests that operations on tables without primary keys 146dc29e60Sdan# are ignored. 156dc29e60Sdan# 166dc29e60Sdan 176dc29e60Sdan 186dc29e60Sdan 196dc29e60Sdanif {![info exists testdir]} { 206dc29e60Sdan set testdir [file join [file dirname [info script]] .. .. test] 216dc29e60Sdan} 226dc29e60Sdansource [file join [file dirname [info script]] session_common.tcl] 236dc29e60Sdansource $testdir/tester.tcl 246dc29e60Sdanifcapable !session {finish_test; return} 256dc29e60Sdanset testprefix sessionE 266dc29e60Sdan 276dc29e60Sdan# 286dc29e60Sdan# Test plan: 296dc29e60Sdan# 306dc29e60Sdan# 1.*: Test that non-PK tables are not auto-attached. 316dc29e60Sdan# 2.*: Test that explicitly attaching a non-PK table is a no-op. 326dc29e60Sdan# 3.*: Test that sqlite3session_diff() on a non-PK table is a no-op. 336dc29e60Sdan# 346dc29e60Sdan 356dc29e60Sdan 366dc29e60Sdan#-------------------------------------------------------------------------- 376dc29e60Sdanreset_db 386dc29e60Sdando_execsql_test 1.0 { 396dc29e60Sdan CREATE TABLE t1(a, b); 406dc29e60Sdan CREATE TABLE t2(a PRIMARY KEY, b); 416dc29e60Sdan} 426dc29e60Sdando_test 1.1 { 436dc29e60Sdan sqlite3session S db main 446dc29e60Sdan S attach * 456dc29e60Sdan execsql { 466dc29e60Sdan INSERT INTO t1 VALUES(1, 2); 476dc29e60Sdan INSERT INTO t2 VALUES(1, 2); 486dc29e60Sdan } 496dc29e60Sdan} {} 506dc29e60Sdando_changeset_test 1.2 S { 516dc29e60Sdan {INSERT t2 0 X. {} {i 1 i 2}} 526dc29e60Sdan} 536dc29e60SdanS delete 546dc29e60Sdan 556dc29e60Sdanreset_db 566dc29e60Sdando_execsql_test 2.0 { 576dc29e60Sdan CREATE TABLE t1(a, b); 586dc29e60Sdan CREATE TABLE t2(a PRIMARY KEY, b); 596dc29e60Sdan} 606dc29e60Sdando_test 2.1 { 616dc29e60Sdan sqlite3session S db main 626dc29e60Sdan S attach t1 636dc29e60Sdan S attach t2 646dc29e60Sdan execsql { 656dc29e60Sdan INSERT INTO t1 VALUES(3, 4); 666dc29e60Sdan INSERT INTO t2 VALUES(3, 4); 676dc29e60Sdan INSERT INTO t1 VALUES(5, 6); 686dc29e60Sdan INSERT INTO t2 VALUES(5, 6); 696dc29e60Sdan } 706dc29e60Sdan} {} 716dc29e60Sdando_changeset_test 2.2 S { 726dc29e60Sdan {INSERT t2 0 X. {} {i 3 i 4}} 736dc29e60Sdan {INSERT t2 0 X. {} {i 5 i 6}} 746dc29e60Sdan} 756dc29e60SdanS delete 766dc29e60Sdan 776dc29e60Sdanreset_db 786dc29e60Sdanforcedelete test.db2 796dc29e60Sdando_execsql_test 3.0 { 806dc29e60Sdan ATTACH 'test.db2' AS aux; 816dc29e60Sdan CREATE TABLE aux.t1(a, b); 826dc29e60Sdan CREATE TABLE aux.t2(a PRIMARY KEY, b); 836dc29e60Sdan 846dc29e60Sdan CREATE TABLE t1(a, b); 856dc29e60Sdan CREATE TABLE t2(a PRIMARY KEY, b); 866dc29e60Sdan 876dc29e60Sdan INSERT INTO t1 VALUES(1, 2); 886dc29e60Sdan INSERT INTO t2 VALUES(3, 4); 896dc29e60Sdan} 906dc29e60Sdando_test 3.1 { 916dc29e60Sdan sqlite3session S db main 926dc29e60Sdan S attach t1 936dc29e60Sdan S diff aux t1 946dc29e60Sdan 956dc29e60Sdan S attach t2 966dc29e60Sdan S diff aux t2 976dc29e60Sdan} {} 986dc29e60Sdando_changeset_test 3.2 S { 996dc29e60Sdan {INSERT t2 0 X. {} {i 3 i 4}} 1006dc29e60Sdan} 1016dc29e60Sdando_execsql_test 3.3 { 1026dc29e60Sdan INSERT INTO t1 VALUES(5, 6); 1036dc29e60Sdan INSERT INTO t2 VALUES(7, 8); 1046dc29e60Sdan} 1056dc29e60Sdando_changeset_test 3.4 S { 1066dc29e60Sdan {INSERT t2 0 X. {} {i 3 i 4}} 1076dc29e60Sdan {INSERT t2 0 X. {} {i 7 i 8}} 1086dc29e60Sdan} 1096dc29e60Sdan 1106dc29e60Sdan 1116dc29e60SdanS delete 1126dc29e60Sdan 113*80754703Sdanfinish_test 114