|
1 |
|
2 // //////////////////////////////////////////////////////////////////////// |
|
3 // |
|
4 // Configuration tests - try changing the values of the default encoding |
|
5 // and cache_size and page_size. From an integration test we can't really |
|
6 // detect an effect of the _size settings, though we can read them back |
|
7 // with the 'pragma' syntax. |
|
8 // |
|
9 // First check the defaults. If these change it will confuse the other tests |
|
10 // so we might as well detect that change and generate a failure ASAP... |
|
11 [CheckDefaults] |
|
12 // First open a zero length database to check the defaults. |
|
13 NoOperation0= |
|
14 Open1=Z:\TEF_SQL\TestData\ReadOnly.db |
|
15 Function2=ScalarFullSelect |
|
16 Method2=SelectTextL |
|
17 Result2=UTF-16le |
|
18 Use_Set2=0 |
|
19 Statement2=PRAGMA encoding; |
|
20 |
|
21 Function3=ScalarFullSelect |
|
22 Method3=SelectIntL |
|
23 Result3=1024 |
|
24 Use_Set3=1 |
|
25 Statement3=PRAGMA page_size; |
|
26 |
|
27 Function4=ScalarFullSelect |
|
28 Method4=SelectIntL |
|
29 Result4=1024 |
|
30 Use_Set4=1 |
|
31 Statement4=PRAGMA cache_size; |
|
32 Close5= |
|
33 EndBlock6= |
|
34 |
|
35 // Check that gibberish in the configuration string prevents Create from |
|
36 // working. |
|
37 [CheckOverride1] |
|
38 DefineConfig0=this is a load of old rubbish which should have no effect on settings |
|
39 Delete1=C:\ConfigTest1.db |
|
40 ExpectedError1=KErrNotFound |
|
41 Create2=C:\ConfigTest1.db |
|
42 ExpectedError2=KErrArgument |
|
43 // The next line will PANIC the client because the Create will have failed due |
|
44 // to the bad configuration line. That's ok, we're expecting it. |
|
45 Exec3=Select * from SomeTable; |
|
46 EndBlock4= |
|
47 |
|
48 // Check that properly formatted configuration options work, but that |
|
49 // page_size can't be changed for a pre-existing db, and a bad encoding |
|
50 // has no effect. The cache_size is also not affected. |
|
51 [CheckOverride2] |
|
52 DefineConfig0=page_size=2048;cache_size=64;encoding=hatstand |
|
53 // On a pre-existing database we can't change the page size, plus the |
|
54 // bad encoding will have been ignored. |
|
55 Open1=Z:\TEF_SQL\TestData\ReadOnly.db |
|
56 |
|
57 // encoding will not have been changed from its default of utf-16 |
|
58 Function2=ScalarFullSelect |
|
59 Method2=SelectTextL |
|
60 Result2=UTF-16le |
|
61 Use_Set2=1 |
|
62 Statement2=PRAGMA encoding; |
|
63 |
|
64 // page_size will not have been changed from its default of 1024.. |
|
65 Function3=ScalarFullSelect |
|
66 Method3=SelectIntL |
|
67 Result3=1024 |
|
68 Use_Set3=1 |
|
69 Statement3=PRAGMA page_size; |
|
70 |
|
71 // cache_size WILL NOT have changed. |
|
72 Function4=ScalarFullSelect |
|
73 Method4=SelectIntL |
|
74 Result4=64 |
|
75 Use_Set4=1 |
|
76 Statement4=PRAGMA cache_size; |
|
77 |
|
78 Close5= |
|
79 EndBlock6= |
|
80 |
|
81 // Try changing all three config items to legal values, and check them. |
|
82 [CheckOverride3] |
|
83 DefineConfig0=page_size=2048;cache_size=34;encoding=UTF-8 |
|
84 // On a new database we can change the page size and the encoding. |
|
85 // Not the cache_size. |
|
86 Delete1=C:\ConfigTest2.db |
|
87 ExpectedError1=KErrNotFound |
|
88 |
|
89 Create2=C:\ConfigTest2.db |
|
90 |
|
91 // encoding will not have been changed from its default of utf-16 |
|
92 Function3=ScalarFullSelect |
|
93 Method3=SelectTextL |
|
94 Result3=UTF-8 |
|
95 Use_Set3=1 |
|
96 Statement3=PRAGMA encoding; |
|
97 |
|
98 // page_size will have been changed from its default of 1024.. |
|
99 Function4=ScalarFullSelect |
|
100 Method4=SelectIntL |
|
101 Result4=2048 |
|
102 Use_Set4=1 |
|
103 Statement4=PRAGMA page_size; |
|
104 |
|
105 // cache_size WILL have changed to 34.. |
|
106 Function5=ScalarFullSelect |
|
107 Method5=SelectIntL |
|
108 Result5=34 |
|
109 Use_Set5=1 |
|
110 Statement5=PRAGMA cache_size; |
|
111 |
|
112 Close6= |
|
113 Delete7=C:\ConfigTest2.db |
|
114 EndBlock8= |
|
115 |
|
116 // Try setting page_size to a non-power-of-two (no effect), stick in some |
|
117 // properly formatted by useless extras (no effect) and attempt to set |
|
118 // cache_size (works) and an unsupported encoding (doesn't work). |
|
119 [CheckOverride4] |
|
120 DefineConfig0=page_size=4095;x=y;i=j;cache_size=43;encoding=UTF-16be |
|
121 // On a new database we can change the page size and the encoding. |
|
122 // But page_size is supposed to be a power of 2. |
|
123 Delete1=C:\ConfigTest3.db |
|
124 ExpectedError1=KErrNotFound |
|
125 |
|
126 Create2=C:\ConfigTest3.db |
|
127 |
|
128 // encoding will not have been changed from its default of utf-16 |
|
129 Function3=ScalarFullSelect |
|
130 Method3=SelectTextL |
|
131 Result3=UTF-16le |
|
132 Use_Set3=1 |
|
133 Statement3=PRAGMA encoding; |
|
134 |
|
135 // page_size will not have been changed from its default of 1024.. |
|
136 Function4=ScalarFullSelect |
|
137 Method4=SelectIntL |
|
138 Result4=1024 |
|
139 Use_Set4=1 |
|
140 Statement4=PRAGMA page_size; |
|
141 |
|
142 // cache_size WILL have changed. |
|
143 Function5=ScalarFullSelect |
|
144 Method5=SelectIntL |
|
145 Result5=43 |
|
146 Use_Set5=1 |
|
147 Statement5=PRAGMA cache_size; |
|
148 |
|
149 Close6= |
|
150 Delete7=C:\ConfigTest3.db |
|
151 EndBlock8= |
|
152 |
|
153 |
|
154 // Try setting a legal page_size (works), a cache_size (doesn't work) and |
|
155 // a legal character encoding (works). |
|
156 [CheckOverride5] |
|
157 DefineConfig0=page_size=512;cache_size=432;encoding=UTF-8 |
|
158 // On a new database we can change the page size, cache size and the |
|
159 // encoding. |
|
160 Delete1=C:\ConfigTest4.db |
|
161 ExpectedError1=KErrNotFound |
|
162 |
|
163 Create2=C:\ConfigTest4.db |
|
164 |
|
165 // encoding will not have been changed from its default of utf-16 |
|
166 Function3=ScalarFullSelect |
|
167 Method3=SelectTextL |
|
168 Result3=UTF-8 |
|
169 Use_Set3=1 |
|
170 Statement3=PRAGMA encoding; |
|
171 |
|
172 // page_size will not have been changed from its default of 1024.. |
|
173 Function4=ScalarFullSelect |
|
174 Method4=SelectIntL |
|
175 Result4=512 |
|
176 Use_Set4=1 |
|
177 Statement4=PRAGMA page_size; |
|
178 |
|
179 // cache_size WILL have changed. |
|
180 Function5=ScalarFullSelect |
|
181 Method5=SelectIntL |
|
182 Result5=432 |
|
183 Use_Set5=1 |
|
184 Statement5=PRAGMA cache_size; |
|
185 |
|
186 Close6= |
|
187 Delete7=C:\ConfigTest4.db |
|
188 EndBlock8= |
|
189 |
|
190 // ///////////////////////////////////////////////////////////////////////// |
|
191 |
|
192 // The following tests create two functionally identical databases but one |
|
193 // block uses UTF-8. Then check that the file sizes differ. |
|
194 |
|
195 // Create a database with a single table containing a single cell containing |
|
196 // the text content of the reference1.txt text file. Set UTF-16. |
|
197 [WriteTextDB-16bit] |
|
198 Delete0=C:\ConfigTest5.db |
|
199 ExpectedError0=KErrNotFound |
|
200 Create1=C:\ConfigTest5.db |
|
201 |
|
202 // First check for our expected defaults. |
|
203 Function2=ScalarFullSelect |
|
204 Method2=SelectTextL |
|
205 Result2=UTF-16le |
|
206 Use_Set2=1 |
|
207 Statement2=PRAGMA encoding; |
|
208 |
|
209 Function3=ScalarFullSelect |
|
210 Method3=SelectIntL |
|
211 Result3=1024 |
|
212 Use_Set3=1 |
|
213 Statement3=PRAGMA page_size; |
|
214 |
|
215 Function4=ScalarFullSelect |
|
216 Method4=SelectIntL |
|
217 Result4=1024 |
|
218 Use_Set4=1 |
|
219 Statement4=PRAGMA cache_size; |
|
220 |
|
221 Exec5=Create Table Sometable(f1 text); |
|
222 Prepare6=Insert into Sometable values(:val); |
|
223 ParameterIndex7=:val |
|
224 StreamWriteBindText8=0,Z:\TEF_SQL\TestData\reference1.txt |
|
225 St_Exec9= |
|
226 Reset10= |
|
227 St_Close11= |
|
228 |
|
229 Prepare12=select f1 from Sometable; |
|
230 ColumnIndex13=f1 |
|
231 Next14=KSqlAtRow |
|
232 ColumnSize15=0,3626 |
|
233 St_Close16= |
|
234 Close17= |
|
235 EndBlock18= |
|
236 |
|
237 // Create a database with a single table containing a single cell containing |
|
238 // the text content of the reference1.txt text file. Set UTF-8. |
|
239 [WriteTextDB-8bit] |
|
240 Delete0=C:\ConfigTest6.db |
|
241 ExpectedError0=KErrNotFound |
|
242 DefineConfig1=encoding=UTF-8 |
|
243 Create2=C:\ConfigTest6.db |
|
244 |
|
245 // Check the defaults (plus our changed character encoding) |
|
246 Function3=ScalarFullSelect |
|
247 Method3=SelectTextL |
|
248 Result3=UTF-8 |
|
249 Use_Set3=1 |
|
250 Statement3=PRAGMA encoding; |
|
251 |
|
252 Function4=ScalarFullSelect |
|
253 Method4=SelectIntL |
|
254 Result4=1024 |
|
255 Use_Set4=1 |
|
256 Statement4=PRAGMA page_size; |
|
257 |
|
258 Function5=ScalarFullSelect |
|
259 Method5=SelectIntL |
|
260 Result5=1024 |
|
261 Use_Set5=1 |
|
262 Statement5=PRAGMA cache_size; |
|
263 |
|
264 Exec6=Create Table Sometable(f1 text); |
|
265 Prepare7=Insert into Sometable values(:val); |
|
266 ParameterIndex8=:val |
|
267 StreamWriteBindText9=0,Z:\TEF_SQL\TestData\reference1.txt |
|
268 St_Exec10= |
|
269 Reset11= |
|
270 St_Close12= |
|
271 |
|
272 Prepare13=select f1 from Sometable; |
|
273 ColumnIndex14=f1 |
|
274 Next15=KSqlAtRow |
|
275 ColumnSize16=0,3626 |
|
276 St_Close17= |
|
277 Close18= |
|
278 EndBlock19= |
|
279 |
|
280 // Check that the two databases created above (which are exactly equivalent) |
|
281 // differ in size. That will suggest that the UTF-8/UTF-16 |
|
282 // encoding options have done their work. Through the SQLite APIs they generate |
|
283 // identical output. It seems kind of overkill to have a whole code-driven |
|
284 // test function to do this but I see no other way.. |
|
285 // Attempt an attach of UTF-16 to UTF-8 database - it will fail, that's an |
|
286 // illegal operation. |
|
287 [FilesDiffer] |
|
288 Function0=FilesDifferBySize |
|
289 FileA0=C:\ConfigTest5.db |
|
290 FileB0=C:\ConfigTest6.db |
|
291 Open1=C:\ConfigTest5.db |
|
292 Exec2=Attach "C:\ConfigTest6.db" as ThatOne; |
|
293 ExpectedError2=KSqlErrGeneral |
|
294 LastErrorMessage3=attached databases must use the same text encoding as main database |
|
295 // Delete will succeed because the attach didn't. |
|
296 Delete4=C:\ConfigTest6.db |
|
297 Close5= |
|
298 Delete6=C:\ConfigTest5.db |
|
299 EndBlock7= |