diff options
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/misc5.test')
-rw-r--r-- | libraries/sqlite/unix/sqlite-3.5.1/test/misc5.test | 620 |
1 files changed, 620 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/misc5.test b/libraries/sqlite/unix/sqlite-3.5.1/test/misc5.test new file mode 100644 index 0000000..86963b2 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/test/misc5.test | |||
@@ -0,0 +1,620 @@ | |||
1 | # 2005 Mar 16 | ||
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 | # This file implements regression tests for SQLite library. | ||
12 | # | ||
13 | # This file implements tests for miscellanous features that were | ||
14 | # left out of other test files. | ||
15 | # | ||
16 | # $Id: misc5.test,v 1.17 2007/09/12 17:01:45 danielk1977 Exp $ | ||
17 | |||
18 | set testdir [file dirname $argv0] | ||
19 | source $testdir/tester.tcl | ||
20 | |||
21 | # Build records using the MakeRecord opcode such that the size of the | ||
22 | # header is at the transition point in the size of a varint. | ||
23 | # | ||
24 | # This test causes an assertion failure or a buffer overrun in version | ||
25 | # 3.1.5 and earlier. | ||
26 | # | ||
27 | for {set i 120} {$i<140} {incr i} { | ||
28 | do_test misc5-1.$i { | ||
29 | catchsql {DROP TABLE t1} | ||
30 | set sql1 {CREATE TABLE t1} | ||
31 | set sql2 {INSERT INTO t1 VALUES} | ||
32 | set sep ( | ||
33 | for {set j 0} {$j<$i} {incr j} { | ||
34 | append sql1 ${sep}a$j | ||
35 | append sql2 ${sep}$j | ||
36 | set sep , | ||
37 | } | ||
38 | append sql1 {);} | ||
39 | append sql2 {);} | ||
40 | execsql $sql1$sql2 | ||
41 | } {} | ||
42 | } | ||
43 | |||
44 | # Make sure large integers are stored correctly. | ||
45 | # | ||
46 | ifcapable conflict { | ||
47 | do_test misc5-2.1 { | ||
48 | execsql { | ||
49 | create table t2(x unique); | ||
50 | insert into t2 values(1); | ||
51 | insert or ignore into t2 select x*2 from t2; | ||
52 | insert or ignore into t2 select x*4 from t2; | ||
53 | insert or ignore into t2 select x*16 from t2; | ||
54 | insert or ignore into t2 select x*256 from t2; | ||
55 | insert or ignore into t2 select x*65536 from t2; | ||
56 | insert or ignore into t2 select x*2147483648 from t2; | ||
57 | insert or ignore into t2 select x-1 from t2; | ||
58 | insert or ignore into t2 select x+1 from t2; | ||
59 | insert or ignore into t2 select -x from t2; | ||
60 | select count(*) from t2; | ||
61 | } | ||
62 | } 371 | ||
63 | } else { | ||
64 | do_test misc5-2.1 { | ||
65 | execsql { | ||
66 | BEGIN; | ||
67 | create table t2(x unique); | ||
68 | create table t2_temp(x); | ||
69 | insert into t2_temp values(1); | ||
70 | insert into t2_temp select x*2 from t2_temp; | ||
71 | insert into t2_temp select x*4 from t2_temp; | ||
72 | insert into t2_temp select x*16 from t2_temp; | ||
73 | insert into t2_temp select x*256 from t2_temp; | ||
74 | insert into t2_temp select x*65536 from t2_temp; | ||
75 | insert into t2_temp select x*2147483648 from t2_temp; | ||
76 | insert into t2_temp select x-1 from t2_temp; | ||
77 | insert into t2_temp select x+1 from t2_temp; | ||
78 | insert into t2_temp select -x from t2_temp; | ||
79 | INSERT INTO t2 SELECT DISTINCT(x) FROM t2_temp; | ||
80 | DROP TABLE t2_temp; | ||
81 | COMMIT; | ||
82 | select count(*) from t2; | ||
83 | } | ||
84 | } 371 | ||
85 | } | ||
86 | do_test misc5-2.2 { | ||
87 | execsql { | ||
88 | select x from t2 order by x; | ||
89 | } | ||
90 | } \ | ||
91 | "-4611686018427387905\ | ||
92 | -4611686018427387904\ | ||
93 | -4611686018427387903\ | ||
94 | -2305843009213693953\ | ||
95 | -2305843009213693952\ | ||
96 | -2305843009213693951\ | ||
97 | -1152921504606846977\ | ||
98 | -1152921504606846976\ | ||
99 | -1152921504606846975\ | ||
100 | -576460752303423489\ | ||
101 | -576460752303423488\ | ||
102 | -576460752303423487\ | ||
103 | -288230376151711745\ | ||
104 | -288230376151711744\ | ||
105 | -288230376151711743\ | ||
106 | -144115188075855873\ | ||
107 | -144115188075855872\ | ||
108 | -144115188075855871\ | ||
109 | -72057594037927937\ | ||
110 | -72057594037927936\ | ||
111 | -72057594037927935\ | ||
112 | -36028797018963969\ | ||
113 | -36028797018963968\ | ||
114 | -36028797018963967\ | ||
115 | -18014398509481985\ | ||
116 | -18014398509481984\ | ||
117 | -18014398509481983\ | ||
118 | -9007199254740993\ | ||
119 | -9007199254740992\ | ||
120 | -9007199254740991\ | ||
121 | -4503599627370497\ | ||
122 | -4503599627370496\ | ||
123 | -4503599627370495\ | ||
124 | -2251799813685249\ | ||
125 | -2251799813685248\ | ||
126 | -2251799813685247\ | ||
127 | -1125899906842625\ | ||
128 | -1125899906842624\ | ||
129 | -1125899906842623\ | ||
130 | -562949953421313\ | ||
131 | -562949953421312\ | ||
132 | -562949953421311\ | ||
133 | -281474976710657\ | ||
134 | -281474976710656\ | ||
135 | -281474976710655\ | ||
136 | -140737488355329\ | ||
137 | -140737488355328\ | ||
138 | -140737488355327\ | ||
139 | -70368744177665\ | ||
140 | -70368744177664\ | ||
141 | -70368744177663\ | ||
142 | -35184372088833\ | ||
143 | -35184372088832\ | ||
144 | -35184372088831\ | ||
145 | -17592186044417\ | ||
146 | -17592186044416\ | ||
147 | -17592186044415\ | ||
148 | -8796093022209\ | ||
149 | -8796093022208\ | ||
150 | -8796093022207\ | ||
151 | -4398046511105\ | ||
152 | -4398046511104\ | ||
153 | -4398046511103\ | ||
154 | -2199023255553\ | ||
155 | -2199023255552\ | ||
156 | -2199023255551\ | ||
157 | -1099511627777\ | ||
158 | -1099511627776\ | ||
159 | -1099511627775\ | ||
160 | -549755813889\ | ||
161 | -549755813888\ | ||
162 | -549755813887\ | ||
163 | -274877906945\ | ||
164 | -274877906944\ | ||
165 | -274877906943\ | ||
166 | -137438953473\ | ||
167 | -137438953472\ | ||
168 | -137438953471\ | ||
169 | -68719476737\ | ||
170 | -68719476736\ | ||
171 | -68719476735\ | ||
172 | -34359738369\ | ||
173 | -34359738368\ | ||
174 | -34359738367\ | ||
175 | -17179869185\ | ||
176 | -17179869184\ | ||
177 | -17179869183\ | ||
178 | -8589934593\ | ||
179 | -8589934592\ | ||
180 | -8589934591\ | ||
181 | -4294967297\ | ||
182 | -4294967296\ | ||
183 | -4294967295\ | ||
184 | -2147483649\ | ||
185 | -2147483648\ | ||
186 | -2147483647\ | ||
187 | -1073741825\ | ||
188 | -1073741824\ | ||
189 | -1073741823\ | ||
190 | -536870913\ | ||
191 | -536870912\ | ||
192 | -536870911\ | ||
193 | -268435457\ | ||
194 | -268435456\ | ||
195 | -268435455\ | ||
196 | -134217729\ | ||
197 | -134217728\ | ||
198 | -134217727\ | ||
199 | -67108865\ | ||
200 | -67108864\ | ||
201 | -67108863\ | ||
202 | -33554433\ | ||
203 | -33554432\ | ||
204 | -33554431\ | ||
205 | -16777217\ | ||
206 | -16777216\ | ||
207 | -16777215\ | ||
208 | -8388609\ | ||
209 | -8388608\ | ||
210 | -8388607\ | ||
211 | -4194305\ | ||
212 | -4194304\ | ||
213 | -4194303\ | ||
214 | -2097153\ | ||
215 | -2097152\ | ||
216 | -2097151\ | ||
217 | -1048577\ | ||
218 | -1048576\ | ||
219 | -1048575\ | ||
220 | -524289\ | ||
221 | -524288\ | ||
222 | -524287\ | ||
223 | -262145\ | ||
224 | -262144\ | ||
225 | -262143\ | ||
226 | -131073\ | ||
227 | -131072\ | ||
228 | -131071\ | ||
229 | -65537\ | ||
230 | -65536\ | ||
231 | -65535\ | ||
232 | -32769\ | ||
233 | -32768\ | ||
234 | -32767\ | ||
235 | -16385\ | ||
236 | -16384\ | ||
237 | -16383\ | ||
238 | -8193\ | ||
239 | -8192\ | ||
240 | -8191\ | ||
241 | -4097\ | ||
242 | -4096\ | ||
243 | -4095\ | ||
244 | -2049\ | ||
245 | -2048\ | ||
246 | -2047\ | ||
247 | -1025\ | ||
248 | -1024\ | ||
249 | -1023\ | ||
250 | -513\ | ||
251 | -512\ | ||
252 | -511\ | ||
253 | -257\ | ||
254 | -256\ | ||
255 | -255\ | ||
256 | -129\ | ||
257 | -128\ | ||
258 | -127\ | ||
259 | -65\ | ||
260 | -64\ | ||
261 | -63\ | ||
262 | -33\ | ||
263 | -32\ | ||
264 | -31\ | ||
265 | -17\ | ||
266 | -16\ | ||
267 | -15\ | ||
268 | -9\ | ||
269 | -8\ | ||
270 | -7\ | ||
271 | -5\ | ||
272 | -4\ | ||
273 | -3\ | ||
274 | -2\ | ||
275 | -1\ | ||
276 | 0\ | ||
277 | 1\ | ||
278 | 2\ | ||
279 | 3\ | ||
280 | 4\ | ||
281 | 5\ | ||
282 | 7\ | ||
283 | 8\ | ||
284 | 9\ | ||
285 | 15\ | ||
286 | 16\ | ||
287 | 17\ | ||
288 | 31\ | ||
289 | 32\ | ||
290 | 33\ | ||
291 | 63\ | ||
292 | 64\ | ||
293 | 65\ | ||
294 | 127\ | ||
295 | 128\ | ||
296 | 129\ | ||
297 | 255\ | ||
298 | 256\ | ||
299 | 257\ | ||
300 | 511\ | ||
301 | 512\ | ||
302 | 513\ | ||
303 | 1023\ | ||
304 | 1024\ | ||
305 | 1025\ | ||
306 | 2047\ | ||
307 | 2048\ | ||
308 | 2049\ | ||
309 | 4095\ | ||
310 | 4096\ | ||
311 | 4097\ | ||
312 | 8191\ | ||
313 | 8192\ | ||
314 | 8193\ | ||
315 | 16383\ | ||
316 | 16384\ | ||
317 | 16385\ | ||
318 | 32767\ | ||
319 | 32768\ | ||
320 | 32769\ | ||
321 | 65535\ | ||
322 | 65536\ | ||
323 | 65537\ | ||
324 | 131071\ | ||
325 | 131072\ | ||
326 | 131073\ | ||
327 | 262143\ | ||
328 | 262144\ | ||
329 | 262145\ | ||
330 | 524287\ | ||
331 | 524288\ | ||
332 | 524289\ | ||
333 | 1048575\ | ||
334 | 1048576\ | ||
335 | 1048577\ | ||
336 | 2097151\ | ||
337 | 2097152\ | ||
338 | 2097153\ | ||
339 | 4194303\ | ||
340 | 4194304\ | ||
341 | 4194305\ | ||
342 | 8388607\ | ||
343 | 8388608\ | ||
344 | 8388609\ | ||
345 | 16777215\ | ||
346 | 16777216\ | ||
347 | 16777217\ | ||
348 | 33554431\ | ||
349 | 33554432\ | ||
350 | 33554433\ | ||
351 | 67108863\ | ||
352 | 67108864\ | ||
353 | 67108865\ | ||
354 | 134217727\ | ||
355 | 134217728\ | ||
356 | 134217729\ | ||
357 | 268435455\ | ||
358 | 268435456\ | ||
359 | 268435457\ | ||
360 | 536870911\ | ||
361 | 536870912\ | ||
362 | 536870913\ | ||
363 | 1073741823\ | ||
364 | 1073741824\ | ||
365 | 1073741825\ | ||
366 | 2147483647\ | ||
367 | 2147483648\ | ||
368 | 2147483649\ | ||
369 | 4294967295\ | ||
370 | 4294967296\ | ||
371 | 4294967297\ | ||
372 | 8589934591\ | ||
373 | 8589934592\ | ||
374 | 8589934593\ | ||
375 | 17179869183\ | ||
376 | 17179869184\ | ||
377 | 17179869185\ | ||
378 | 34359738367\ | ||
379 | 34359738368\ | ||
380 | 34359738369\ | ||
381 | 68719476735\ | ||
382 | 68719476736\ | ||
383 | 68719476737\ | ||
384 | 137438953471\ | ||
385 | 137438953472\ | ||
386 | 137438953473\ | ||
387 | 274877906943\ | ||
388 | 274877906944\ | ||
389 | 274877906945\ | ||
390 | 549755813887\ | ||
391 | 549755813888\ | ||
392 | 549755813889\ | ||
393 | 1099511627775\ | ||
394 | 1099511627776\ | ||
395 | 1099511627777\ | ||
396 | 2199023255551\ | ||
397 | 2199023255552\ | ||
398 | 2199023255553\ | ||
399 | 4398046511103\ | ||
400 | 4398046511104\ | ||
401 | 4398046511105\ | ||
402 | 8796093022207\ | ||
403 | 8796093022208\ | ||
404 | 8796093022209\ | ||
405 | 17592186044415\ | ||
406 | 17592186044416\ | ||
407 | 17592186044417\ | ||
408 | 35184372088831\ | ||
409 | 35184372088832\ | ||
410 | 35184372088833\ | ||
411 | 70368744177663\ | ||
412 | 70368744177664\ | ||
413 | 70368744177665\ | ||
414 | 140737488355327\ | ||
415 | 140737488355328\ | ||
416 | 140737488355329\ | ||
417 | 281474976710655\ | ||
418 | 281474976710656\ | ||
419 | 281474976710657\ | ||
420 | 562949953421311\ | ||
421 | 562949953421312\ | ||
422 | 562949953421313\ | ||
423 | 1125899906842623\ | ||
424 | 1125899906842624\ | ||
425 | 1125899906842625\ | ||
426 | 2251799813685247\ | ||
427 | 2251799813685248\ | ||
428 | 2251799813685249\ | ||
429 | 4503599627370495\ | ||
430 | 4503599627370496\ | ||
431 | 4503599627370497\ | ||
432 | 9007199254740991\ | ||
433 | 9007199254740992\ | ||
434 | 9007199254740993\ | ||
435 | 18014398509481983\ | ||
436 | 18014398509481984\ | ||
437 | 18014398509481985\ | ||
438 | 36028797018963967\ | ||
439 | 36028797018963968\ | ||
440 | 36028797018963969\ | ||
441 | 72057594037927935\ | ||
442 | 72057594037927936\ | ||
443 | 72057594037927937\ | ||
444 | 144115188075855871\ | ||
445 | 144115188075855872\ | ||
446 | 144115188075855873\ | ||
447 | 288230376151711743\ | ||
448 | 288230376151711744\ | ||
449 | 288230376151711745\ | ||
450 | 576460752303423487\ | ||
451 | 576460752303423488\ | ||
452 | 576460752303423489\ | ||
453 | 1152921504606846975\ | ||
454 | 1152921504606846976\ | ||
455 | 1152921504606846977\ | ||
456 | 2305843009213693951\ | ||
457 | 2305843009213693952\ | ||
458 | 2305843009213693953\ | ||
459 | 4611686018427387903\ | ||
460 | 4611686018427387904\ | ||
461 | 4611686018427387905" | ||
462 | |||
463 | # Ticket #1210. Do proper reference counting of Table structures | ||
464 | # so that deeply nested SELECT statements can be flattened correctly. | ||
465 | # | ||
466 | ifcapable subquery { | ||
467 | do_test misc5-3.1 { | ||
468 | execsql { | ||
469 | CREATE TABLE songs(songid, artist, timesplayed); | ||
470 | INSERT INTO songs VALUES(1,'one',1); | ||
471 | INSERT INTO songs VALUES(2,'one',2); | ||
472 | INSERT INTO songs VALUES(3,'two',3); | ||
473 | INSERT INTO songs VALUES(4,'three',5); | ||
474 | INSERT INTO songs VALUES(5,'one',7); | ||
475 | INSERT INTO songs VALUES(6,'two',11); | ||
476 | SELECT DISTINCT artist | ||
477 | FROM ( | ||
478 | SELECT DISTINCT artist | ||
479 | FROM songs | ||
480 | WHERE songid IN ( | ||
481 | SELECT songid | ||
482 | FROM songs | ||
483 | WHERE LOWER(artist) = ( | ||
484 | SELECT DISTINCT LOWER(artist) | ||
485 | FROM ( | ||
486 | SELECT DISTINCT artist,sum(timesplayed) AS total | ||
487 | FROM songs | ||
488 | GROUP BY LOWER(artist) | ||
489 | ORDER BY total DESC | ||
490 | LIMIT 10 | ||
491 | ) | ||
492 | WHERE artist <> '' | ||
493 | ) | ||
494 | ) | ||
495 | ) | ||
496 | ORDER BY LOWER(artist) ASC; | ||
497 | } | ||
498 | } {two} | ||
499 | } | ||
500 | |||
501 | # Ticket #1370. Do not overwrite small files (less than 1024 bytes) | ||
502 | # when trying to open them as a database. | ||
503 | # | ||
504 | do_test misc5-4.1 { | ||
505 | db close | ||
506 | file delete -force test.db | ||
507 | set fd [open test.db w] | ||
508 | puts $fd "This is not really a database" | ||
509 | close $fd | ||
510 | sqlite3 db test.db | ||
511 | catchsql { | ||
512 | CREATE TABLE t1(a,b,c); | ||
513 | } | ||
514 | } {1 {file is encrypted or is not a database}} | ||
515 | |||
516 | # Ticket #1371. Allow floating point numbers of the form .N or N. | ||
517 | # | ||
518 | do_test misc5-5.1 { | ||
519 | execsql {SELECT .1 } | ||
520 | } 0.1 | ||
521 | do_test misc5-5.2 { | ||
522 | execsql {SELECT 2. } | ||
523 | } 2.0 | ||
524 | do_test misc5-5.3 { | ||
525 | execsql {SELECT 3.e0 } | ||
526 | } 3.0 | ||
527 | do_test misc5-5.4 { | ||
528 | execsql {SELECT .4e+1} | ||
529 | } 4.0 | ||
530 | |||
531 | # Ticket #1582. Ensure that an unknown table in a LIMIT clause applied to | ||
532 | # a UNION ALL query causes an error, not a crash. | ||
533 | # | ||
534 | db close | ||
535 | file delete -force test.db | ||
536 | sqlite3 db test.db | ||
537 | ifcapable subquery&&compound { | ||
538 | do_test misc5-6.1 { | ||
539 | catchsql { | ||
540 | SELECT * FROM sqlite_master | ||
541 | UNION ALL | ||
542 | SELECT * FROM sqlite_master | ||
543 | LIMIT (SELECT count(*) FROM blah); | ||
544 | } | ||
545 | } {1 {no such table: blah}} | ||
546 | do_test misc5-6.2 { | ||
547 | execsql { | ||
548 | CREATE TABLE logs(msg TEXT, timestamp INTEGER, dbtime TEXT); | ||
549 | } | ||
550 | catchsql { | ||
551 | SELECT * FROM logs WHERE logs.id >= (SELECT head FROM logs_base) | ||
552 | UNION ALL | ||
553 | SELECT * FROM logs | ||
554 | LIMIT (SELECT lmt FROM logs_base) ; | ||
555 | } | ||
556 | } {1 {no such column: logs.id}} | ||
557 | } | ||
558 | |||
559 | # Overflow the lemon parser stack by providing an overly complex | ||
560 | # expression. Make sure that the overflow is detected and reported. | ||
561 | # | ||
562 | do_test misc5-7.1 { | ||
563 | execsql {CREATE TABLE t1(x)} | ||
564 | set sql "INSERT INTO t1 VALUES(" | ||
565 | set tail "" | ||
566 | for {set i 0} {$i<200} {incr i} { | ||
567 | append sql "(1+" | ||
568 | append tail ")" | ||
569 | } | ||
570 | append sql 2$tail | ||
571 | catchsql $sql | ||
572 | } {1 {parser stack overflow}} | ||
573 | |||
574 | # Check the MISUSE return from sqlitee3_busy_timeout | ||
575 | # | ||
576 | do_test misc5-8.1-misuse { | ||
577 | set DB [sqlite3_connection_pointer db] | ||
578 | db close | ||
579 | sqlite3_busy_timeout $DB 1000 | ||
580 | } SQLITE_MISUSE | ||
581 | sqlite3 db test.db | ||
582 | |||
583 | # Ticket #1911 | ||
584 | # | ||
585 | ifcapable compound { | ||
586 | do_test misc5-9.1 { | ||
587 | execsql { | ||
588 | SELECT name, type FROM sqlite_master WHERE name IS NULL | ||
589 | UNION | ||
590 | SELECT type, name FROM sqlite_master WHERE type IS NULL | ||
591 | ORDER BY 1, 2, 1, 2, 1, 2 | ||
592 | } | ||
593 | } {} | ||
594 | do_test misc5-9.2 { | ||
595 | execsql { | ||
596 | SELECT name, type FROM sqlite_master WHERE name IS NULL | ||
597 | UNION | ||
598 | SELECT type, name FROM sqlite_master WHERE type IS NULL | ||
599 | ORDER BY 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 | ||
600 | } | ||
601 | } {} | ||
602 | } | ||
603 | |||
604 | # Ticket #1912. Make the tokenizer require a space after a numeric | ||
605 | # literal. | ||
606 | # | ||
607 | do_test misc5-10.1 { | ||
608 | catchsql { | ||
609 | SELECT 123abc | ||
610 | } | ||
611 | } {1 {unrecognized token: "123abc"}} | ||
612 | do_test misc5-10.2 { | ||
613 | catchsql { | ||
614 | SELECT 1*123.4e5ghi; | ||
615 | } | ||
616 | } {1 {unrecognized token: "123.4e5ghi"}} | ||
617 | |||
618 | |||
619 | |||
620 | finish_test | ||