/ Check-in [712d413d]
Login

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 Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/ota/ota7.test.

     5      5   #
     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12         -# This file contains tests for the OTA module. Specifically, it tests the
    13         -# that affinities are correctly applied to values within the OTA database.
           12  +# This file contains tests for the OTA module.
    14     13   #
           14  +
    15     15   
    16     16   if {![info exists testdir]} {
    17     17     set testdir [file join [file dirname [info script]] .. .. test]
    18     18   }
    19     19   source $testdir/tester.tcl
    20     20   set ::testprefix ota7
           21  +
           22  +# Test index:
           23  +#
           24  +#   1.*: That affinities are correctly applied to values within the 
           25  +#        OTA database.
           26  +#
           27  +#   2.*: Tests for multi-column primary keys.
           28  +#
    21     29   
    22     30   do_test 1.0 {
    23     31     execsql {
    24     32       CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;
    25     33       INSERT INTO t1 VALUES(1, 'abc');
    26     34       INSERT INTO t1 VALUES(2, 'def');
    27     35     }
................................................................................
    41     49     ota close
    42     50   } {SQLITE_DONE}
    43     51   
    44     52   sqlite3 db test.db
    45     53   do_execsql_test 1.2 {
    46     54     SELECT * FROM t1
    47     55   } {2 def}
           56  +
           57  +#-------------------------------------------------------------------------
           58  +#
           59  +foreach {tn tbl} {
           60  +  1 { CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID }
           61  +} {
           62  +  reset_db
           63  +
           64  +  execsql $tbl
           65  +  do_execsql_test 2.$tn.1 {
           66  +    CREATE INDEX t1c ON t1(c);
           67  +    INSERT INTO t1 VALUES(1, 1, 'a');
           68  +    INSERT INTO t1 VALUES(1, 2, 'b');
           69  +    INSERT INTO t1 VALUES(2, 1, 'c');
           70  +    INSERT INTO t1 VALUES(2, 2, 'd');
           71  +  }
           72  +
           73  +  do_test 2.$tn.2 {
           74  +    forcedelete ota.db
           75  +    sqlite3 ota ota.db
           76  +    execsql {
           77  +      CREATE TABLE data_t1(a, b, c, ota_control);
           78  +      INSERT INTO data_t1 VALUES(3, 1, 'e', 0);
           79  +      INSERT INTO data_t1 VALUES(3, 2, 'f', 0);
           80  +      INSERT INTO data_t1 VALUES(1, 2, NULL, 1);
           81  +      INSERT INTO data_t1 VALUES(2, 1, 'X', '..x');
           82  +    } ota
           83  +    ota close
           84  +  } {}
           85  +
           86  +  do_test 2.$tn.3 {
           87  +    set rc "SQLITE_OK"
           88  +    while {$rc == "SQLITE_OK"} {
           89  +      sqlite3ota ota test.db ota.db
           90  +      ota step
           91  +      set rc [ota close]
           92  +    } 
           93  +    set rc
           94  +  } {SQLITE_DONE}
           95  +
           96  +  do_execsql_test 2.$tn.1 {
           97  +    SELECT * FROM t1 ORDER BY a, b
           98  +  } {
           99  +    1 1 a
          100  +    2 1 X
          101  +    2 2 d
          102  +    3 1 e
          103  +    3 2 f
          104  +  }
          105  +}
    48    106   
    49    107   finish_test
    50    108   
    51    109