Index: ext/ota/ota7.test ================================================================== --- ext/ota/ota7.test +++ ext/ota/ota7.test @@ -7,19 +7,27 @@ # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # -# This file contains tests for the OTA module. Specifically, it tests the -# that affinities are correctly applied to values within the OTA database. +# This file contains tests for the OTA module. # + if {![info exists testdir]} { set testdir [file join [file dirname [info script]] .. .. test] } source $testdir/tester.tcl set ::testprefix ota7 + +# Test index: +# +# 1.*: That affinities are correctly applied to values within the +# OTA database. +# +# 2.*: Tests for multi-column primary keys. +# do_test 1.0 { execsql { CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID; INSERT INTO t1 VALUES(1, 'abc'); @@ -43,9 +51,59 @@ sqlite3 db test.db do_execsql_test 1.2 { SELECT * FROM t1 } {2 def} + +#------------------------------------------------------------------------- +# +foreach {tn tbl} { + 1 { CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID } +} { + reset_db + + execsql $tbl + do_execsql_test 2.$tn.1 { + CREATE INDEX t1c ON t1(c); + INSERT INTO t1 VALUES(1, 1, 'a'); + INSERT INTO t1 VALUES(1, 2, 'b'); + INSERT INTO t1 VALUES(2, 1, 'c'); + INSERT INTO t1 VALUES(2, 2, 'd'); + } + + do_test 2.$tn.2 { + forcedelete ota.db + sqlite3 ota ota.db + execsql { + CREATE TABLE data_t1(a, b, c, ota_control); + INSERT INTO data_t1 VALUES(3, 1, 'e', 0); + INSERT INTO data_t1 VALUES(3, 2, 'f', 0); + INSERT INTO data_t1 VALUES(1, 2, NULL, 1); + INSERT INTO data_t1 VALUES(2, 1, 'X', '..x'); + } ota + ota close + } {} + + do_test 2.$tn.3 { + set rc "SQLITE_OK" + while {$rc == "SQLITE_OK"} { + sqlite3ota ota test.db ota.db + ota step + set rc [ota close] + } + set rc + } {SQLITE_DONE} + + do_execsql_test 2.$tn.1 { + SELECT * FROM t1 ORDER BY a, b + } { + 1 1 a + 2 1 X + 2 2 d + 3 1 e + 3 2 f + } +} finish_test