xref: /sqlite-3.40.0/test/8_3_names.test (revision 24b6422d)
1# 2011 May 17
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 cases for the SQLITE_ENABLE_8_3_NAMES feature that forces all
13# filename extensions to be limited to 3 characters.  Some embedded
14# systems need this to work around microsoft FAT patents, but this
15# feature should be disabled on most deployments.
16#
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20ifcapable !8_3_names {
21  finish_test
22  return
23}
24
25db close
26sqlite3_shutdown
27sqlite3_config_uri 1
28
29do_test 8_3_names-1.0 {
30  forcedelete test.db test.nal test.db-journal
31  sqlite3 db test.db
32  db eval {
33    PRAGMA cache_size=10;
34    CREATE TABLE t1(x);
35    INSERT INTO t1 VALUES(randomblob(20000));
36    BEGIN;
37    DELETE FROM t1;
38    INSERT INTO t1 VALUES(randomblob(15000));
39  }
40  file exists test.db-journal
41} 1
42do_test 8_3_names-1.1 {
43  file exists test.nal
44} 0
45do_test 8_3_names-1.2 {
46  db eval {
47    ROLLBACK;
48    SELECT length(x) FROM t1
49  }
50} 20000
51
52db close
53do_test 8_3_names-2.0 {
54  forcedelete test.db test.nal test.db-journal
55  sqlite3 db file:./test.db?8_3_names=1
56  db eval {
57    PRAGMA cache_size=10;
58    CREATE TABLE t1(x);
59    INSERT INTO t1 VALUES(randomblob(20000));
60    BEGIN;
61    DELETE FROM t1;
62    INSERT INTO t1 VALUES(randomblob(15000));
63  }
64  file exists test.db-journal
65} 0
66do_test 8_3_names-2.1 {
67  file exists test.nal
68} 1
69forcedelete test2.db test2.nal test2.db-journal
70copy_file test.db test2.db
71copy_file test.nal test2.nal
72do_test 8_3_names-2.2 {
73  db eval {
74    COMMIT;
75    SELECT length(x) FROM t1
76  }
77} 15000
78do_test 8_3_names-2.3 {
79  sqlite3 db2 file:./test2.db?8_3_names=1
80  db2 eval {
81    PRAGMA integrity_check;
82    SELECT length(x) FROM t1;
83  }
84} {ok 20000}
85
86db close
87do_test 8_3_names-3.0 {
88  forcedelete test.db test.nal test.db-journal
89  sqlite3 db file:./test.db?8_3_names=0
90  db eval {
91    PRAGMA cache_size=10;
92    CREATE TABLE t1(x);
93    INSERT INTO t1 VALUES(randomblob(20000));
94    BEGIN;
95    DELETE FROM t1;
96    INSERT INTO t1 VALUES(randomblob(15000));
97  }
98  file exists test.db-journal
99} 1
100do_test 8_3_names-3.1 {
101  file exists test.nal
102} 0
103forcedelete test2.db test2.nal test2.db-journal
104copy_file test.db test2.db
105copy_file test.db-journal test2.db-journal
106do_test 8_3_names-3.2 {
107  db eval {
108    COMMIT;
109    SELECT length(x) FROM t1
110  }
111} 15000
112do_test 8_3_names-3.3 {
113  sqlite3 db2 file:./test2.db?8_3_names=0
114  db2 eval {
115    PRAGMA integrity_check;
116    SELECT length(x) FROM t1;
117  }
118} {ok 20000}
119
120##########################################################################
121# Master journals.
122#
123db close
124forcedelete test.db test2.db
125do_test 8_3_names-4.0 {
126  sqlite3 db file:./test.db?8_3_names=1
127  db eval {
128    CREATE TABLE t1(x);
129    INSERT INTO t1 VALUES(1);
130    ATTACH 'file:./test2.db?8_3_names=1' AS db2;
131    CREATE TABLE db2.t2(y);
132    INSERT INTO t2 VALUES(2);
133    BEGIN;
134      INSERT INTO t1 VALUES(3);
135      INSERT INTO t2 VALUES(4);
136    COMMIT;
137    SELECT * FROM t1, t2 ORDER BY x, y
138  }
139} {1 2 1 4 3 2 3 4}
140
141
142##########################################################################
143# WAL mode.
144#
145ifcapable !wal {
146  finish_test
147  return
148}
149db close
150forcedelete test.db
151do_test 8_3_names-5.0 {
152  sqlite3 db file:./test.db?8_3_names=1
153  load_static_extension db wholenumber
154  db eval {
155    PRAGMA journal_mode=WAL;
156    CREATE TABLE t1(x);
157    CREATE VIRTUAL TABLE nums USING wholenumber;
158    INSERT INTO t1 SELECT value FROM nums WHERE value BETWEEN 1 AND 1000;
159    BEGIN;
160    UPDATE t1 SET x=x*2;
161  }
162  sqlite3 db2 file:./test.db?8_3_names=1
163  load_static_extension db2 wholenumber
164  db2 eval {
165    BEGIN;
166    SELECT sum(x) FROM t1;
167  }
168} {500500}
169
170do_test 8_3_names-5.1 {
171  file exists test.db-wal
172} 0
173do_test 8_3_names-5.2 {
174  file exists test.wal
175} 1
176do_test 8_3_names-5.3 {
177  file exists test.db-shm
178} 0
179do_test 8_3_names-5.4 {
180  file exists test.shm
181} 1
182
183
184do_test 8_3_names-5.5 {
185  db eval {
186    COMMIT;
187    SELECT sum(x) FROM t1;
188  }
189} {1001000}
190do_test 8_3_names-5.6 {
191  db2 eval {
192    SELECT sum(x) FROM t1;
193  }
194} {500500}
195
196
197finish_test
198