Annotation of embedaddon/sqlite3/test/fts3ak.test, revision 1.1.1.1

1.1       misho       1: # 2007 March 9
                      2: #
                      3: # The author disclaims copyright to this source code.
                      4: #
                      5: #*************************************************************************
                      6: # This file implements regression tests for SQLite library.  These
                      7: # make sure that fts3 insertion buffering is fully transparent when
                      8: # using transactions.
                      9: #
                     10: # $Id: fts3ak.test,v 1.1 2007/08/20 17:38:42 shess Exp $
                     11: #
                     12: 
                     13: set testdir [file dirname $argv0]
                     14: source $testdir/tester.tcl
                     15: 
                     16: # If SQLITE_ENABLE_FTS3 is defined, omit this file.
                     17: ifcapable !fts3 {
                     18:   finish_test
                     19:   return
                     20: }
                     21: 
                     22: db eval {
                     23:   CREATE VIRTUAL TABLE t1 USING fts3(content);
                     24:   INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
                     25:   INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
                     26:   INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
                     27: }
                     28: 
                     29: # Test that possibly-buffered inserts went through after commit.
                     30: do_test fts3ak-1.1 {
                     31:   execsql {
                     32:     BEGIN TRANSACTION;
                     33:     INSERT INTO t1 (rowid, content) VALUES(4, "false world");
                     34:     INSERT INTO t1 (rowid, content) VALUES(5, "false door");
                     35:     COMMIT TRANSACTION;
                     36:     SELECT rowid FROM t1 WHERE t1 MATCH 'world';
                     37:   }
                     38: } {1 3 4}
                     39: 
                     40: # Test that buffered inserts are seen by selects in the same
                     41: # transaction.
                     42: do_test fts3ak-1.2 {
                     43:   execsql {
                     44:     BEGIN TRANSACTION;
                     45:     INSERT INTO t1 (rowid, content) VALUES(6, "another world");
                     46:     INSERT INTO t1 (rowid, content) VALUES(7, "another test");
                     47:     SELECT rowid FROM t1 WHERE t1 MATCH 'world';
                     48:     COMMIT TRANSACTION;
                     49:   }
                     50: } {1 3 4 6}
                     51: 
                     52: # Test that buffered inserts are seen within a transaction.  This is
                     53: # really the same test as 1.2.
                     54: do_test fts3ak-1.3 {
                     55:   execsql {
                     56:     BEGIN TRANSACTION;
                     57:     INSERT INTO t1 (rowid, content) VALUES(8, "second world");
                     58:     INSERT INTO t1 (rowid, content) VALUES(9, "second sight");
                     59:     SELECT rowid FROM t1 WHERE t1 MATCH 'world';
                     60:     ROLLBACK TRANSACTION;
                     61:   }
                     62: } {1 3 4 6 8}
                     63: 
                     64: # Double-check that the previous result doesn't persist past the
                     65: # rollback!
                     66: do_test fts3ak-1.4 {
                     67:   execsql {
                     68:     SELECT rowid FROM t1 WHERE t1 MATCH 'world';
                     69:   }
                     70: } {1 3 4 6}
                     71: 
                     72: # Test it all together.
                     73: do_test fts3ak-1.5 {
                     74:   execsql {
                     75:     BEGIN TRANSACTION;
                     76:     INSERT INTO t1 (rowid, content) VALUES(10, "second world");
                     77:     INSERT INTO t1 (rowid, content) VALUES(11, "second sight");
                     78:     ROLLBACK TRANSACTION;
                     79:     SELECT rowid FROM t1 WHERE t1 MATCH 'world';
                     80:   }
                     81: } {1 3 4 6}
                     82: 
                     83: # Test that the obvious case works.
                     84: do_test fts3ak-1.6 {
                     85:   execsql {
                     86:     BEGIN;
                     87:     INSERT INTO t1 (rowid, content) VALUES(12, "third world");
                     88:     COMMIT;
                     89:     SELECT rowid FROM t1 WHERE t1 MATCH 'third';
                     90:   }
                     91: } {12}
                     92: 
                     93: # This is exactly the same as the previous test, except that older
                     94: # code loses the INSERT due to an SQLITE_SCHEMA error.
                     95: do_test fts3ak-1.7 {
                     96:   execsql {
                     97:     BEGIN;
                     98:     INSERT INTO t1 (rowid, content) VALUES(13, "third dimension");
                     99:     CREATE TABLE x (c);
                    100:     COMMIT;
                    101:     SELECT rowid FROM t1 WHERE t1 MATCH 'dimension';
                    102:   }
                    103: } {13}
                    104: 
                    105: finish_test

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