/ Check-in [fa6008d5]
Login

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

Overview
Comment:Add new test file reuse5.test. For testing the shell tool ".shared-schema" command.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | reuse-schema
Files: files | file ages | folders
SHA3-256: fa6008d547c6b24108a26e022f3f427fa19ffae006c88fee9de97d2244521de0
User & Date: dan 2019-02-26 16:13:43
Wiki:reuse-schema
Context
2019-02-26
16:36
Update doc/shared_schema.md to describe the shell tool ".shared-schema" dot-command. check-in: 0ce2092a user: dan tags: reuse-schema
16:13
Add new test file reuse5.test. For testing the shell tool ".shared-schema" command. check-in: fa6008d5 user: dan tags: reuse-schema
15:43
Add the ".shared-schema check|fix DB1 DB2..." command to the shell tool. For checking if a database is eligible to share an in-memory with the main database, and for fixing small problems that prevent it from being so. check-in: 7d8e8a95 user: dan tags: reuse-schema
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/reuse5.test.

            1  +# 2019 February 26
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            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.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +#
           13  +
           14  +set testdir [file dirname $argv0]
           15  +source $testdir/tester.tcl
           16  +set testprefix reuse5
           17  +set CLI [test_find_cli]
           18  +
           19  +do_execsql_test 1.0 {
           20  +  CREATE TABLE t1(x, y);
           21  +  CREATE TABLE t2(a, b, c);
           22  +  CREATE INDEX t1x ON t1(x);
           23  +  CREATE INDEX t1y ON t1(y);
           24  +  CREATE VIEW v1 AS SELECT * FROM t2;
           25  +}
           26  +
           27  +foreach {tn sql out1 out2} {
           28  +  1 {
           29  +    CREATE TABLE t1(x, y);
           30  +    CREATE TABLE t2(a, b, c);
           31  +    CREATE INDEX t1x ON t1(x);
           32  +    CREATE INDEX t1y ON t1(y);
           33  +    CREATE VIEW v1 AS SELECT * FROM t2;
           34  +  } {
           35  +    test.db2 is compatible
           36  +  } {}
           37  +
           38  +  2 {
           39  +    CREATE TABLE t1(x, y);
           40  +    CREATE TABLE t2(a, b, c);
           41  +    CREATE INDEX t1x ON t1(x);
           42  +    CREATE INDEX t1y ON t1(y);
           43  +    CREATE VIEW v1 AS SELECT * FROM t2;
           44  +    CREATE TABLE x1(x);
           45  +    DROP TABLE x1;
           46  +  } {
           47  +    test.db2 is NOT compatible (schema cookie)
           48  +  } {
           49  +    Fixing test.db2... test.db2 is compatible
           50  +  }
           51  +
           52  +  3 {
           53  +    CREATE TABLE t1(x, y);
           54  +    CREATE TABLE t2(a, b, c);
           55  +    CREATE INDEX t1y ON t1(y);
           56  +    CREATE VIEW v1 AS SELECT * FROM t2;
           57  +  } {
           58  +    test.db2 is NOT compatible (objects)
           59  +  } {}
           60  +
           61  +  4 {
           62  +    CREATE TABLE t1(x, y);
           63  +    CREATE TABLE t2(a, b, c);
           64  +    CREATE INDEX t1x ON t1(X);
           65  +    CREATE INDEX t1y ON t1(y);
           66  +    CREATE VIEW v1 AS SELECT * FROM t2;
           67  +  } {
           68  +    test.db2 is NOT compatible (SQL)
           69  +  } {}
           70  +
           71  +  5 {
           72  +    CREATE TABLE t1(x, y);
           73  +    CREATE TABLE t2(a, b, c);
           74  +    CREATE INDEX t1y ON t1(y);
           75  +    CREATE INDEX t1x ON t1(x);
           76  +    CREATE VIEW v1 AS SELECT * FROM t2;
           77  +  } {
           78  +    test.db2 is NOT compatible (root pages)
           79  +  } {
           80  +    Fixing test.db2... test.db2 is compatible
           81  +  }
           82  +
           83  +  6 {
           84  +    CREATE TABLE t1(x, y);
           85  +    CREATE TABLE t2(a, b, c);
           86  +    CREATE INDEX t1x ON t1(x);
           87  +    CREATE INDEX t1y ON t1(y);
           88  +    CREATE VIEW v1 AS SELECT * FROM t2;
           89  +    DROP INDEX t1x;
           90  +    CREATE INDEX t1x ON t1(x);
           91  +  } {
           92  +    test.db2 is NOT compatible (order of sqlite_master rows)
           93  +  } {
           94  +    Fixing test.db2... test.db2 is compatible
           95  +  }
           96  +
           97  +} {
           98  +  forcedelete test.db2
           99  +  sqlite3 db2 test.db2
          100  +  db2 eval $sql
          101  +  db2 close
          102  +
          103  +  if {$out2==""} {set out2 $out1}
          104  +
          105  +  do_test 1.$tn.1 {
          106  +    catchcmd test.db ".shared-schema check test.db2"
          107  +  } [list 0 [string trim $out1]]
          108  +
          109  +  do_test 1.$tn.2 {
          110  +    catchcmd test.db ".shared-schema fix test.db2"
          111  +  } [list 0 [string trim $out2]]
          112  +
          113  +  do_test 1.$tn.3 {
          114  +    catchcmd test.db2 "PRAGMA integrity_check"
          115  +  } [list 0 ok]
          116  +}
          117  +
          118  +
          119  +finish_test
          120  +