Annotation of embedaddon/sqlite3/test/shared4.test, revision 1.1

1.1     ! misho       1: # 2008 July 14
        !             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: # Test the btree mutex protocol for shared cache mode.
        !            13: #
        !            14: # $Id: shared4.test,v 1.2 2008/08/04 03:51:24 danielk1977 Exp $
        !            15: 
        !            16: set testdir [file dirname $argv0]
        !            17: source $testdir/tester.tcl
        !            18: db close
        !            19: puts hello
        !            20: 
        !            21: # This script is only valid if we are running shared-cache mode in a
        !            22: # threadsafe-capable database engine.
        !            23: #
        !            24: ifcapable !shared_cache||!compound {
        !            25:   finish_test
        !            26:   return
        !            27: }
        !            28: set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
        !            29: 
        !            30: # Prepare multiple databases in shared cache mode.
        !            31: #
        !            32: do_test shared4-1.1 {
        !            33:   forcedelete test1.db test1.db-journal
        !            34:   forcedelete test2.db test2.db-journal
        !            35:   forcedelete test3.db test3.db-journal
        !            36:   forcedelete test4.db test4.db-journal
        !            37:   sqlite3 db1 test1.db
        !            38:   sqlite3 db2 test2.db
        !            39:   sqlite3 db3 test3.db
        !            40:   sqlite3 db4 test4.db
        !            41:   db1 eval {
        !            42:     CREATE TABLE t1(a);
        !            43:     INSERT INTO t1 VALUES(111);
        !            44:   }
        !            45:   db2 eval {
        !            46:     CREATE TABLE t2(b);
        !            47:     INSERT INTO t2 VALUES(222);
        !            48:   }
        !            49:   db3 eval {
        !            50:     CREATE TABLE t3(c);
        !            51:     INSERT INTO t3 VALUES(333);
        !            52:   }
        !            53:   db4 eval {
        !            54:     CREATE TABLE t4(d);
        !            55:     INSERT INTO t4 VALUES(444);
        !            56:   }
        !            57:   db1 eval {
        !            58:     ATTACH DATABASE 'test2.db' AS two;
        !            59:     ATTACH DATABASE 'test3.db' AS three;
        !            60:     ATTACH DATABASE 'test4.db' AS four;
        !            61:   }
        !            62:   db2 eval {
        !            63:     ATTACH DATABASE 'test4.db' AS four;
        !            64:     ATTACH DATABASE 'test3.db' AS three;
        !            65:     ATTACH DATABASE 'test1.db' AS one;
        !            66:   }
        !            67:   db3 eval {
        !            68:     ATTACH DATABASE 'test1.db' AS one;
        !            69:     ATTACH DATABASE 'test2.db' AS two;
        !            70:     ATTACH DATABASE 'test4.db' AS four;
        !            71:   }
        !            72:   db4 eval {
        !            73:     ATTACH DATABASE 'test3.db' AS three;
        !            74:     ATTACH DATABASE 'test2.db' AS two;
        !            75:     ATTACH DATABASE 'test1.db' AS one;
        !            76:   }
        !            77:   db1 eval {
        !            78:      SELECT a FROM t1 UNION ALL
        !            79:      SELECT b FROM t2 UNION ALL
        !            80:      SELECT c FROM t3 UNION ALL
        !            81:      SELECT d FROM t4;
        !            82:   }
        !            83: } {111 222 333 444}
        !            84: do_test shared4-1.2 {
        !            85:   db2 eval {
        !            86:      SELECT a FROM t1 UNION ALL
        !            87:      SELECT b FROM t2 UNION ALL
        !            88:      SELECT d FROM t4 UNION ALL
        !            89:      SELECT c FROM t3;
        !            90:   }
        !            91: } {111 222 444 333}
        !            92: do_test shared4-1.3 {
        !            93:   db3 eval {
        !            94:      SELECT a FROM t1 UNION ALL
        !            95:      SELECT c FROM t3 UNION ALL
        !            96:      SELECT b FROM t2 UNION ALL
        !            97:      SELECT d FROM t4;
        !            98:   }
        !            99: } {111 333 222 444}
        !           100: do_test shared4-1.4 {
        !           101:   db4 eval {
        !           102:      SELECT a FROM t1 UNION ALL
        !           103:      SELECT c FROM t3 UNION ALL
        !           104:      SELECT d FROM t4 UNION ALL
        !           105:      SELECT b FROM t2;
        !           106:   }
        !           107: } {111 333 444 222}
        !           108: do_test shared4-1.5 {
        !           109:   db3 eval {
        !           110:      SELECT a FROM t1 UNION ALL
        !           111:      SELECT d FROM t4 UNION ALL
        !           112:      SELECT b FROM t2 UNION ALL
        !           113:      SELECT c FROM t3;
        !           114:   }
        !           115: } {111 444 222 333}
        !           116: do_test shared4-1.6 {
        !           117:   db4 eval {
        !           118:      SELECT a FROM t1 UNION ALL
        !           119:      SELECT d FROM t4 UNION ALL
        !           120:      SELECT c FROM t3 UNION ALL
        !           121:      SELECT b FROM t2;
        !           122:   }
        !           123: } {111 444 333 222}
        !           124: do_test shared4-1.7 {
        !           125:   db1 eval {
        !           126:      SELECT b FROM t2 UNION ALL
        !           127:      SELECT a FROM t1 UNION ALL
        !           128:      SELECT c FROM t3 UNION ALL
        !           129:      SELECT d FROM t4;
        !           130:   }
        !           131: } {222 111 333 444}
        !           132: do_test shared4-1.8 {
        !           133:   db2 eval {
        !           134:      SELECT b FROM t2 UNION ALL
        !           135:      SELECT a FROM t1 UNION ALL
        !           136:      SELECT d FROM t4 UNION ALL
        !           137:      SELECT c FROM t3;
        !           138:   }
        !           139: } {222 111 444 333}
        !           140: do_test shared4-1.9 {
        !           141:   db3 eval {
        !           142:      SELECT b FROM t2 UNION ALL
        !           143:      SELECT c FROM t3 UNION ALL
        !           144:      SELECT a FROM t1 UNION ALL
        !           145:      SELECT d FROM t4;
        !           146:   }
        !           147: } {222 333 111 444}
        !           148: do_test shared4-1.10 {
        !           149:   db4 eval {
        !           150:      SELECT b FROM t2 UNION ALL
        !           151:      SELECT c FROM t3 UNION ALL
        !           152:      SELECT d FROM t4 UNION ALL
        !           153:      SELECT a FROM t1;
        !           154:   }
        !           155: } {222 333 444 111}
        !           156: do_test shared4-1.11 {
        !           157:   db1 eval {
        !           158:      SELECT c FROM t3 UNION ALL
        !           159:      SELECT a FROM t1 UNION ALL
        !           160:      SELECT b FROM t2 UNION ALL
        !           161:      SELECT d FROM t4;
        !           162:   }
        !           163: } {333 111 222 444}
        !           164: do_test shared4-1.12 {
        !           165:   db2 eval {
        !           166:      SELECT c FROM t3 UNION ALL
        !           167:      SELECT a FROM t1 UNION ALL
        !           168:      SELECT d FROM t4 UNION ALL
        !           169:      SELECT b FROM t2;
        !           170:   }
        !           171: } {333 111 444 222}
        !           172: 
        !           173: do_test shared4-2.1 {
        !           174:   db1 eval {
        !           175:     UPDATE t1 SET a=a+1000;
        !           176:     UPDATE t2 SET b=b+2000;
        !           177:     UPDATE t3 SET c=c+3000;
        !           178:     UPDATE t4 SET d=d+4000;
        !           179:   }
        !           180:   db2 eval {
        !           181:     UPDATE t1 SET a=a+10000;
        !           182:     UPDATE t2 SET b=b+20000;
        !           183:     UPDATE t3 SET c=c+30000;
        !           184:     UPDATE t4 SET d=d+40000;
        !           185:   }
        !           186:   db3 eval {
        !           187:     UPDATE t1 SET a=a+100000;
        !           188:     UPDATE t2 SET b=b+200000;
        !           189:     UPDATE t3 SET c=c+300000;
        !           190:     UPDATE t4 SET d=d+400000;
        !           191:   }
        !           192:   db4 eval {
        !           193:     UPDATE t1 SET a=a+1000000;
        !           194:     UPDATE t2 SET b=b+2000000;
        !           195:     UPDATE t3 SET c=c+3000000;
        !           196:     UPDATE t4 SET d=d+4000000;
        !           197:   }
        !           198:   db1 eval {
        !           199:      SELECT a FROM t1 UNION ALL
        !           200:      SELECT b FROM t2 UNION ALL
        !           201:      SELECT c FROM t3 UNION ALL
        !           202:      SELECT d FROM t4;
        !           203:   }
        !           204: } {1111111 2222222 3333333 4444444}
        !           205: do_test shared4-2.2 {
        !           206:   db2 eval {
        !           207:      SELECT a FROM t1 UNION ALL
        !           208:      SELECT b FROM t2 UNION ALL
        !           209:      SELECT d FROM t4 UNION ALL
        !           210:      SELECT c FROM t3;
        !           211:   }
        !           212: } {1111111 2222222 4444444 3333333}
        !           213: do_test shared4-2.3 {
        !           214:   db3 eval {
        !           215:      SELECT a FROM t1 UNION ALL
        !           216:      SELECT c FROM t3 UNION ALL
        !           217:      SELECT b FROM t2 UNION ALL
        !           218:      SELECT d FROM t4;
        !           219:   }
        !           220: } {1111111 3333333 2222222 4444444}
        !           221: do_test shared4-2.4 {
        !           222:   db4 eval {
        !           223:      SELECT a FROM t1 UNION ALL
        !           224:      SELECT c FROM t3 UNION ALL
        !           225:      SELECT d FROM t4 UNION ALL
        !           226:      SELECT b FROM t2;
        !           227:   }
        !           228: } {1111111 3333333 4444444 2222222}
        !           229: 
        !           230: 
        !           231: db1 close
        !           232: db2 close
        !           233: db3 close
        !           234: db4 close
        !           235: 
        !           236: sqlite3_enable_shared_cache $::enable_shared_cache
        !           237: finish_test

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>