/ Check-in [712d413d]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add tests for WITHOUT ROWID tables with composite primary keys.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ota-update
Files: files | file ages | folders
SHA1: 712d413d29950b19d4afb18cfcf9d3afb302d0a0
User & Date: dan 2014-11-17 18:35:30
Context
2014-11-20
15:11
Updates to support zipvfs in pass-through mode. check-in: 556c3de5 user: dan tags: ota-update
2014-11-17
18:35
Add tests for WITHOUT ROWID tables with composite primary keys. check-in: 712d413d user: dan tags: ota-update
17:57
Changes so that sqlite3_ckpt_open() works with zipvfs databases. check-in: acbed338 user: dan tags: ota-update
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/ota/ota7.test.

5
6
7
8
9
10
11
12
13
14

15
16
17
18
19
20








21
22
23
24
25
26
27
..
41
42
43
44
45
46
47
48


















































49
50
51
#
#    May you do good and not evil.
#    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.
#


if {![info exists testdir]} {
  set testdir [file join [file dirname [info script]] .. .. test]
}
source $testdir/tester.tcl
set ::testprefix ota7









do_test 1.0 {
  execsql {
    CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;
    INSERT INTO t1 VALUES(1, 'abc');
    INSERT INTO t1 VALUES(2, 'def');
  }
................................................................................
  ota close
} {SQLITE_DONE}

sqlite3 db test.db
do_execsql_test 1.2 {
  SELECT * FROM t1
} {2 def}



















































finish_test









|
<

>






>
>
>
>
>
>
>
>







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#
#    May you do good and not evil.
#    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.

#


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');
    INSERT INTO t1 VALUES(2, 'def');
  }
................................................................................
  ota close
} {SQLITE_DONE}

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