Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Modify test scripts to work when SQLITE_OMIT_SUBQUERY (but no other OMIT macros) is defined. (CVS 2252) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d4e19efcef68d834c55c7d496cdb3696 |
User & Date: | danielk1977 2005-01-21 04:25:47.000 |
Context
2005-01-21
| ||
08:13 | Exclude a few more lines of code using OMIT macros. (CVS 2253) (check-in: c6fc49e610 user: danielk1977 tags: trunk) | |
04:25 | Modify test scripts to work when SQLITE_OMIT_SUBQUERY (but no other OMIT macros) is defined. (CVS 2252) (check-in: d4e19efcef user: danielk1977 tags: trunk) | |
03:12 | Modify test scripts to work when SQLITE_OMIT_SUBQUERY (along with other OMIT macros) is defined. (CVS 2251) (check-in: bb0254ab14 user: danielk1977 tags: trunk) | |
Changes
Changes to test/attach.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # # $Id: attach.test,v 1.33 2005/01/21 04:25:47 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl for {set i 2} {$i<=15} {incr i} { file delete -force test$i.db |
︙ | ︙ | |||
609 610 611 612 613 614 615 | catchsql { CREATE TEMP TABLE t6(p,q,r); CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN SELECT 'no-op' FROM temp.t6; END; } db2 } {1 {trigger r5 cannot reference objects in database temp}} | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | catchsql { CREATE TEMP TABLE t6(p,q,r); CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN SELECT 'no-op' FROM temp.t6; END; } db2 } {1 {trigger r5 cannot reference objects in database temp}} ifcapable subquery { do_test attach-5.5 { catchsql { CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN SELECT 'no-op' || (SELECT * FROM temp.t6); END; } db2 } {1 {trigger r5 cannot reference objects in database temp}} do_test attach-5.6 { catchsql { CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN SELECT 'no-op' FROM t1 WHERE x<(SELECT min(x) FROM temp.t6); END; } db2 } {1 {trigger r5 cannot reference objects in database temp}} do_test attach-5.7 { catchsql { CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN SELECT 'no-op' FROM t1 GROUP BY 1 HAVING x<(SELECT min(x) FROM temp.t6); END; } db2 } {1 {trigger r5 cannot reference objects in database temp}} do_test attach-5.7 { catchsql { CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN SELECT max(1,x,(SELECT min(x) FROM temp.t6)) FROM t1; END; } db2 } {1 {trigger r5 cannot reference objects in database temp}} do_test attach-5.8 { catchsql { CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN INSERT INTO t1 VALUES((SELECT min(x) FROM temp.t6),5); END; } db2 } {1 {trigger r5 cannot reference objects in database temp}} do_test attach-5.9 { catchsql { CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN DELETE FROM t1 WHERE x<(SELECT min(x) FROM temp.t6); END; } db2 } {1 {trigger r5 cannot reference objects in database temp}} } ;# endif subquery } ;# endif trigger # Check to make sure we get a sensible error if unable to open # the file that we are trying to attach. # do_test attach-6.1 { catchsql { |
︙ | ︙ |
Changes to test/collate5.test.
︙ | ︙ | |||
10 11 12 13 14 15 16 | # #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this file is testing DISTINCT, UNION, INTERSECT and EXCEPT # SELECT statements that use user-defined collation sequences. Also # GROUP BY clauses that use user-defined collation sequences. # | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this file is testing DISTINCT, UNION, INTERSECT and EXCEPT # SELECT statements that use user-defined collation sequences. Also # GROUP BY clauses that use user-defined collation sequences. # # $Id: collate5.test,v 1.3 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # # Tests are organised as follows: |
︙ | ︙ | |||
177 178 179 180 181 182 183 | execsql { BEGIN; CREATE TABLE collate5t3(a, b); } foreach ii $::lens { execsql "INSERT INTO collate5t3 VALUES($ii, '[string repeat a $ii]');" } | | < | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | execsql { BEGIN; CREATE TABLE collate5t3(a, b); } foreach ii $::lens { execsql "INSERT INTO collate5t3 VALUES($ii, '[string repeat a $ii]');" } expr [llength [execsql { COMMIT; SELECT * FROM collate5t3 UNION SELECT * FROM collate5t3; }]] / 2 } [llength $::lens] do_test collate5-2.4.1 { execsql {DROP TABLE collate5t3;} } {} unset ::lens # |
︙ | ︙ |
Changes to test/enc2.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. The focus of # this file is testing the SQLite routines used for converting between the # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # UTF-16be). # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. The focus of # this file is testing the SQLite routines used for converting between the # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # UTF-16be). # # $Id: enc2.test,v 1.20 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If UTF16 support is disabled, ignore the tests in this file # ifcapable {!utf16} { |
︙ | ︙ | |||
98 99 100 101 102 103 104 | } } {one I 1} do_test $t.5 { execsql { SELECT * FROM t1 WHERE a = 'four'; } } {four IV 4} | > | | | | | > | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | } } {one I 1} do_test $t.5 { execsql { SELECT * FROM t1 WHERE a = 'four'; } } {four IV 4} ifcapable subquery { do_test $t.6 { execsql { SELECT * FROM t1 WHERE a IN ('one', 'two'); } } {one I 1 two II 2} } # Now check that we can retrieve data in both UTF-16 and UTF-8 do_test $t.7 { set STMT [sqlite3_prepare $DB "SELECT a FROM t1 WHERE c>3;" -1 TAIL] sqlite3_step $STMT sqlite3_column_text $STMT 0 } {four} |
︙ | ︙ |
Changes to test/join.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for joins, including outer joins. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for joins, including outer joins. # # $Id: join.test,v 1.17 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test join-1.1 { execsql { CREATE TABLE t1(a,b,c); |
︙ | ︙ | |||
370 371 372 373 374 375 376 | INSERT INTO t11 VALUES(2,111); INSERT INTO t11 VALUES(3,333); CREATE VIEW v10_11 AS SELECT x, q FROM t10, t11 WHERE t10.y=t11.p; COMMIT; SELECT * FROM t9 LEFT JOIN v10_11 ON( a=x ); } } {1 11 1 111 2 22 {} {}} | > | | | | | | > | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | INSERT INTO t11 VALUES(2,111); INSERT INTO t11 VALUES(3,333); CREATE VIEW v10_11 AS SELECT x, q FROM t10, t11 WHERE t10.y=t11.p; COMMIT; SELECT * FROM t9 LEFT JOIN v10_11 ON( a=x ); } } {1 11 1 111 2 22 {} {}} ifcapable subquery { do_test join-8.2 { execsql { SELECT * FROM t9 LEFT JOIN (SELECT x, q FROM t10, t11 WHERE t10.y=t11.p) ON( a=x); } } {1 11 1 111 2 22 {} {}} } do_test join-8.3 { execsql { SELECT * FROM v10_11 LEFT JOIN t9 ON( a=x ); } } {1 111 1 11 3 333 {} {}} } ;# ifcapable view |
︙ | ︙ | |||
403 404 405 406 407 408 409 410 411 412 | BEGIN; CREATE TABLE t12(a,b); INSERT INTO t12 VALUES(1,11); INSERT INTO t12 VALUES(2,22); CREATE TABLE t13(b,c); INSERT INTO t13 VALUES(22,222); COMMIT; SELECT * FROM t12 NATURAL LEFT JOIN t13 EXCEPT SELECT * FROM t12 NATURAL LEFT JOIN (SELECT * FROM t13 WHERE b>0); | > > > > > < | > | | | | | | | | | 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | BEGIN; CREATE TABLE t12(a,b); INSERT INTO t12 VALUES(1,11); INSERT INTO t12 VALUES(2,22); CREATE TABLE t13(b,c); INSERT INTO t13 VALUES(22,222); COMMIT; } } {} ifcapable subquery { do_test join-9.1.1 { SELECT * FROM t12 NATURAL LEFT JOIN t13 EXCEPT SELECT * FROM t12 NATURAL LEFT JOIN (SELECT * FROM t13 WHERE b>0); } {} } ifcapable view { do_test join-9.2 { execsql { CREATE VIEW v13 AS SELECT * FROM t13 WHERE b>0; SELECT * FROM t12 NATURAL LEFT JOIN t13 EXCEPT SELECT * FROM t12 NATURAL LEFT JOIN v13; } } {} } ;# ifcapable view } ;# ifcapable compound finish_test |
Changes to test/limit.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the LIMIT ... OFFSET ... clause # of SELECT statements. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the LIMIT ... OFFSET ... clause # of SELECT statements. # # $Id: limit.test,v 1.23 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Build some test data # execsql { |
︙ | ︙ | |||
61 62 63 64 65 66 67 | do_test limit-1.6 { execsql {SELECT * FROM t1 AS a, t1 AS b ORDER BY a.x, b.x LIMIT 5} } {0 5 0 5 0 5 1 5 0 5 2 5 0 5 3 5 0 5 4 5} do_test limit-1.7 { execsql {SELECT * FROM t1 AS a, t1 AS b ORDER BY a.x, b.x LIMIT 5 OFFSET 32} } {1 5 0 5 1 5 1 5 1 5 2 5 1 5 3 5 1 5 4 5} | | | | | | | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | do_test limit-1.6 { execsql {SELECT * FROM t1 AS a, t1 AS b ORDER BY a.x, b.x LIMIT 5} } {0 5 0 5 0 5 1 5 0 5 2 5 0 5 3 5 0 5 4 5} do_test limit-1.7 { execsql {SELECT * FROM t1 AS a, t1 AS b ORDER BY a.x, b.x LIMIT 5 OFFSET 32} } {1 5 0 5 1 5 1 5 1 5 2 5 1 5 3 5 1 5 4 5} ifcapable {view && subquery} { do_test limit-2.1 { execsql { CREATE VIEW v1 AS SELECT * FROM t1 LIMIT 2; SELECT count(*) FROM (SELECT * FROM v1); } } 2 } ;# ifcapable view do_test limit-2.2 { execsql { CREATE TABLE t2 AS SELECT * FROM t1 LIMIT 2; SELECT count(*) FROM t2; } } 2 |
︙ | ︙ |
Changes to test/memdb.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is in-memory database backend. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is in-memory database backend. # # $Id: memdb.test,v 1.13 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable memorydb { |
︙ | ︙ | |||
344 345 346 347 348 349 350 | do_test memdb-6.15 { execsql { DELETE FROM t5 WHERE x>0; SELECT * FROM t5; } } {} | > | | | | | | | | | | | | | | | | | | | | | | | > | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | do_test memdb-6.15 { execsql { DELETE FROM t5 WHERE x>0; SELECT * FROM t5; } } {} ifcapable subquery { do_test memdb-7.1 { execsql { CREATE TABLE t6(x); INSERT INTO t6 VALUES(1); INSERT INTO t6 SELECT x+1 FROM t6; INSERT INTO t6 SELECT x+2 FROM t6; INSERT INTO t6 SELECT x+4 FROM t6; INSERT INTO t6 SELECT x+8 FROM t6; INSERT INTO t6 SELECT x+16 FROM t6; INSERT INTO t6 SELECT x+32 FROM t6; INSERT INTO t6 SELECT x+64 FROM t6; INSERT INTO t6 SELECT x+128 FROM t6; SELECT count(*) FROM (SELECT DISTINCT x FROM t6); } } {256} for {set i 1} {$i<=256} {incr i} { do_test memdb-7.2.$i { execsql "DELETE FROM t6 WHERE x=\ (SELECT x FROM t6 ORDER BY random() LIMIT 1)" execsql {SELECT count(*) FROM t6} } [expr {256-$i}] } } } ;# ifcapable memorydb finish_test |
Changes to test/minmax.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing SELECT statements that contain # aggregate min() and max() functions and which are handled as # as a special case. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing SELECT statements that contain # aggregate min() and max() functions and which are handled as # as a special case. # # $Id: minmax.test,v 1.16 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test minmax-1.0 { execsql { BEGIN; |
︙ | ︙ | |||
130 131 132 133 134 135 136 | execsql { SELECT b FROM t2 WHERE a=max_a_t2() } } } {999} do_test minmax-3.3 { set sqlite_search_count } {0} | | | | | | | | | | | | | | | | | | | | | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | execsql { SELECT b FROM t2 WHERE a=max_a_t2() } } } {999} do_test minmax-3.3 { set sqlite_search_count } {0} ifcapable {compound && subquery} { do_test minmax-4.1 { execsql { SELECT coalesce(min(x+0),-1), coalesce(max(x+0),-1) FROM (SELECT * FROM t1 UNION SELECT NULL as 'x', NULL as 'y') } } {1 20} do_test minmax-4.2 { execsql { SELECT y, sum(x) FROM (SELECT null, y+1 FROM t1 UNION SELECT * FROM t1) GROUP BY y ORDER BY y; } } {1 1.0 2 5.0 3 22.0 4 92.0 5 90.0 6 0.0} do_test minmax-4.3 { execsql { SELECT y, count(x), count(*) FROM (SELECT null, y+1 FROM t1 UNION SELECT * FROM t1) GROUP BY y ORDER BY y; } } {1 1 1 2 2 3 3 4 5 4 8 9 5 5 6 6 0 1} } ;# ifcapable compound # Make sure the min(x) and max(x) optimizations work on empty tables # including empty tables with indices. Ticket #296. # do_test minmax-5.1 { execsql { |
︙ | ︙ | |||
275 276 277 278 279 280 281 | SELECT min(a), max(a) FROM t5; } } {34 1234} # Ticket #658: Test the min()/max() optimization when the FROM clause # is a subquery. # | | | | | | | | | | | | | | | | | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | SELECT min(a), max(a) FROM t5; } } {34 1234} # Ticket #658: Test the min()/max() optimization when the FROM clause # is a subquery. # ifcapable {compound && subquery} { do_test minmax-9.1 { execsql { SELECT max(rowid) FROM ( SELECT max(rowid) FROM t4 UNION SELECT max(rowid) FROM t5 ) } } {1} do_test minmax-9.2 { execsql { SELECT max(rowid) FROM ( SELECT max(rowid) FROM t4 EXCEPT SELECT max(rowid) FROM t5 ) } } {{}} } ;# ifcapable compound&&subquery # If there is a NULL in an aggregate max() or min(), ignore it. An # aggregate min() or max() will only return NULL if all values are NULL. # do_test minmax-10.1 { execsql { CREATE TABLE t6(x); |
︙ | ︙ |
Changes to test/misc1.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc1.test,v 1.33 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Mimic the SQLite 2 collation type NUMERIC. db collate numeric numeric_collate proc numeric_collate {lhs rhs} { |
︙ | ︙ | |||
550 551 552 553 554 555 556 | CREATE TEMP TABLE TempTable(TestID INTEGER PRIMARY KEY, TestString TEXT); CREATE TEMP TRIGGER trigTest_1 AFTER UPDATE ON TempTable BEGIN INSERT INTO RealTable(TestString) SELECT new.TestString FROM TempTable LIMIT 1; END; INSERT INTO TempTable(TestString) VALUES ('1'); INSERT INTO TempTable(TestString) VALUES ('2'); | | | 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | CREATE TEMP TABLE TempTable(TestID INTEGER PRIMARY KEY, TestString TEXT); CREATE TEMP TRIGGER trigTest_1 AFTER UPDATE ON TempTable BEGIN INSERT INTO RealTable(TestString) SELECT new.TestString FROM TempTable LIMIT 1; END; INSERT INTO TempTable(TestString) VALUES ('1'); INSERT INTO TempTable(TestString) VALUES ('2'); UPDATE TempTable SET TestString = TestString + 1 WHERE TestID=1 OR TestId=2; COMMIT; SELECT TestString FROM RealTable ORDER BY 1; } } {2 3} } finish_test |
Changes to test/misc2.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc2.test,v 1.20 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {trigger} { # Test for ticket #360 # |
︙ | ︙ | |||
45 46 47 48 49 50 51 | CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,3); CREATE TABLE t2(a,b,c); INSERT INTO t2 VALUES(7,8,9); } } {} ifcapable view { | > | | | | | > | | | | | | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,3); CREATE TABLE t2(a,b,c); INSERT INTO t2 VALUES(7,8,9); } } {} ifcapable view { ifcapable subquery { do_test misc2-2.2 { execsql { SELECT rowid, * FROM (SELECT * FROM t1, t2); } } {{} 1 2 3 7 8 9} } do_test misc2-2.3 { execsql { CREATE VIEW v1 AS SELECT * FROM t1, t2; SELECT rowid, * FROM v1; } } {{} 1 2 3 7 8 9} } ;# ifcapable view # Check name binding precedence. Ticket #387 # do_test misc2-3.1 { catchsql { SELECT t1.b+t2.b AS a, t1.a, t2.a FROM t1, t2 WHERE a==10 |
︙ | ︙ |
Changes to test/select1.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # # $Id: select1.test,v 1.42 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Try to select on a non-existant table. # do_test select1-1.1 { |
︙ | ︙ | |||
778 779 780 781 782 783 784 | do_test select1-12.8 { execsql { SELECT * FROM t3 WHERE a=(SELECT 2); } } {} } | | | | | | | | | | | | | | | | | 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | do_test select1-12.8 { execsql { SELECT * FROM t3 WHERE a=(SELECT 2); } } {} } ifcapable {compound && subquery} { do_test select1-12.9 { execsql2 { SELECT x FROM ( SELECT a,b FROM t3 UNION SELECT a AS 'x', b AS 'y' FROM t4 ORDER BY a,b ) ORDER BY x; } } {x 1 x 3} do_test select1-12.10 { execsql2 { SELECT z.x FROM ( SELECT a,b FROM t3 UNION SELECT a AS 'x', b AS 'y' FROM t4 ORDER BY a,b ) AS 'z' ORDER BY x; } } {x 1 x 3} } ;# ifcapable compound finish_test |
Changes to test/select4.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing UNION, INTERSECT and EXCEPT operators # in SELECT statements. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing UNION, INTERSECT and EXCEPT operators # in SELECT statements. # # $Id: select4.test,v 1.18 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Most tests in this file depend on compound-select. But there are a couple # right at the end that test DISTINCT, so we cannot omit the entire file. # |
︙ | ︙ | |||
91 92 93 94 95 96 97 | SELECT DISTINCT log FROM t1 UNION ALL SELECT n FROM t1 WHERE log=2; SELECT * FROM t2; } } {0 1 2 3 4 5 3 4} execsql {DROP TABLE t2} | > | | | | | | | | > > | | | | | | | | > | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | SELECT DISTINCT log FROM t1 UNION ALL SELECT n FROM t1 WHERE log=2; SELECT * FROM t2; } } {0 1 2 3 4 5 3 4} execsql {DROP TABLE t2} ifcapable subquery { do_test select4-1.2 { execsql { SELECT log FROM t1 WHERE n IN (SELECT DISTINCT log FROM t1 UNION ALL SELECT n FROM t1 WHERE log=3) ORDER BY log; } } {0 1 2 2 3 3 3 3} } do_test select4-1.3 { set v [catch {execsql { SELECT DISTINCT log FROM t1 ORDER BY log UNION ALL SELECT n FROM t1 WHERE log=3 ORDER BY log; }} msg] lappend v $msg } {1 {ORDER BY clause should come after UNION ALL not before}} # Union operator # do_test select4-2.1 { execsql { SELECT DISTINCT log FROM t1 UNION SELECT n FROM t1 WHERE log=3 ORDER BY log; } } {0 1 2 3 4 5 6 7 8} ifcapable subquery { do_test select4-2.2 { execsql { SELECT log FROM t1 WHERE n IN (SELECT DISTINCT log FROM t1 UNION SELECT n FROM t1 WHERE log=3) ORDER BY log; } } {0 1 2 2 3 3 3 3} } do_test select4-2.3 { set v [catch {execsql { SELECT DISTINCT log FROM t1 ORDER BY log UNION SELECT n FROM t1 WHERE log=3 ORDER BY log; }} msg] |
︙ | ︙ | |||
169 170 171 172 173 174 175 | EXCEPT SELECT n FROM t1 WHERE log=3 ORDER BY log DESC; SELECT * FROM t2; } } {4 3 2 1 0} execsql {DROP TABLE t2} | > | | | | | | | | > | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | EXCEPT SELECT n FROM t1 WHERE log=3 ORDER BY log DESC; SELECT * FROM t2; } } {4 3 2 1 0} execsql {DROP TABLE t2} ifcapable subquery { do_test select4-3.2 { execsql { SELECT log FROM t1 WHERE n IN (SELECT DISTINCT log FROM t1 EXCEPT SELECT n FROM t1 WHERE log=3) ORDER BY log; } } {0 1 2 2} } do_test select4-3.3 { set v [catch {execsql { SELECT DISTINCT log FROM t1 ORDER BY log EXCEPT SELECT n FROM t1 WHERE log=3 ORDER BY log; }} msg] |
︙ | ︙ | |||
228 229 230 231 232 233 234 | INTERSECT SELECT n FROM t1 WHERE log=3 ORDER BY log DESC; SELECT * FROM t2; } } {6 5} execsql {DROP TABLE t2} | > | | | | | | | | > | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | INTERSECT SELECT n FROM t1 WHERE log=3 ORDER BY log DESC; SELECT * FROM t2; } } {6 5} execsql {DROP TABLE t2} ifcapable subquery { do_test select4-4.2 { execsql { SELECT log FROM t1 WHERE n IN (SELECT DISTINCT log FROM t1 INTERSECT SELECT n FROM t1 WHERE log=3) ORDER BY log; } } {3} } do_test select4-4.3 { set v [catch {execsql { SELECT DISTINCT log FROM t1 ORDER BY log INTERSECT SELECT n FROM t1 WHERE log=3 ORDER BY log; }} msg] |
︙ | ︙ | |||
410 411 412 413 414 415 416 | SELECT 1 UNION ALL SELECT 2 AS 'x' ORDER BY x; } } {{} {} 1 2} # Make sure the DISTINCT keyword treats NULLs as indistinct. # | > | | | | | | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | > | 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | SELECT 1 UNION ALL SELECT 2 AS 'x' ORDER BY x; } } {{} {} 1 2} # Make sure the DISTINCT keyword treats NULLs as indistinct. # ifcapable subquery { do_test select4-6.4 { execsql { SELECT * FROM ( SELECT NULL, 1 UNION ALL SELECT NULL, 1 ); } } {{} 1 {} 1} do_test select4-6.5 { execsql { SELECT DISTINCT * FROM ( SELECT NULL, 1 UNION ALL SELECT NULL, 1 ); } } {{} 1} do_test select4-6.6 { execsql { SELECT DISTINCT * FROM ( SELECT 1,2 UNION ALL SELECT 1,2 ); } } {1 2} } # Test distinctness of NULL in other ways. # do_test select4-6.7 { execsql { SELECT NULL EXCEPT SELECT NULL } } {} # Make sure column names are correct when a compound select appears as # an expression in the WHERE clause. # do_test select4-7.1 { execsql { CREATE TABLE t2 AS SELECT log AS 'x', count(*) AS 'y' FROM t1 GROUP BY log; SELECT * FROM t2 ORDER BY x; } } {0 1 1 1 2 2 3 4 4 8 5 15} ifcapable subquery { do_test select4-7.2 { execsql2 { SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 INTERSECT SELECT x FROM t2) ORDER BY n } } {n 1 log 0 n 2 log 1 n 3 log 2 n 4 log 2 n 5 log 3} do_test select4-7.3 { execsql2 { SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 EXCEPT SELECT x FROM t2) ORDER BY n LIMIT 2 } } {n 6 log 3 n 7 log 3} do_test select4-7.4 { execsql2 { SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 UNION SELECT x FROM t2) ORDER BY n LIMIT 2 } } {n 1 log 0 n 2 log 1} } ;# ifcapable subquery } ;# ifcapable compound # Make sure DISTINCT works appropriately on TEXT and NUMERIC columns. do_test select4-8.1 { execsql { BEGIN; |
︙ | ︙ |
Changes to test/trigger1.test.
︙ | ︙ | |||
137 138 139 140 141 142 143 | insert into t1 values(1,'a'); insert into t1 values(2,'b'); insert into t1 values(3,'c'); insert into t1 values(4,'d'); create trigger r1 after delete on t1 for each row begin delete from t1 WHERE a=old.a+2; end; | | | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | insert into t1 values(1,'a'); insert into t1 values(2,'b'); insert into t1 values(3,'c'); insert into t1 values(4,'d'); create trigger r1 after delete on t1 for each row begin delete from t1 WHERE a=old.a+2; end; delete from t1 where a=1 OR a=3; select * from t1; drop table t1; } } {2 b 4 d} do_test trigger1-1.11 { execsql { create table t1(a,b); insert into t1 values(1,'a'); insert into t1 values(2,'b'); insert into t1 values(3,'c'); insert into t1 values(4,'d'); create trigger r1 after update on t1 for each row begin delete from t1 WHERE a=old.a+2; end; update t1 set b='x-' || b where a=1 OR a=3; select * from t1; drop table t1; } } {1 x-a 2 b 4 d} # Ensure that we cannot create INSTEAD OF triggers on tables do_test trigger1-1.12 { |
︙ | ︙ |
Changes to test/trigger2.test.
︙ | ︙ | |||
51 52 53 54 55 56 57 | source $testdir/tester.tcl ifcapable {!trigger} { finish_test return } # 1. | > | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | source $testdir/tester.tcl ifcapable {!trigger} { finish_test return } # 1. ifcapable subquery { set ii 0 foreach tbl_defn { {CREATE TEMP TABLE tbl (a, b);} {CREATE TABLE tbl (a, b);} {CREATE TABLE tbl (a INTEGER PRIMARY KEY, b);} {CREATE TEMPORARY TABLE tbl (a INTEGER PRIMARY KEY, b);} {CREATE TABLE tbl (a, b PRIMARY KEY);} {CREATE TABLE tbl (a, b); CREATE INDEX tbl_idx ON tbl(b);} {CREATE TEMP TABLE tbl (a, b); CREATE INDEX tbl_idx ON tbl(b);} } { incr ii catchsql { DROP INDEX tbl_idx; } catchsql { DROP TABLE rlog; DROP TABLE clog; DROP TABLE tbl; DROP TABLE other_tbl; } execsql $tbl_defn execsql { INSERT INTO tbl VALUES(1, 2); INSERT INTO tbl VALUES(3, 4); CREATE TABLE rlog (idx, old_a, old_b, db_sum_a, db_sum_b, new_a, new_b); CREATE TABLE clog (idx, old_a, old_b, db_sum_a, db_sum_b, new_a, new_b); CREATE TRIGGER before_update_row BEFORE UPDATE ON tbl FOR EACH ROW BEGIN INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), old.a, old.b, (SELECT sum(a) FROM tbl), (SELECT sum(b) FROM tbl), new.a, new.b); END; CREATE TRIGGER after_update_row AFTER UPDATE ON tbl FOR EACH ROW BEGIN INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), old.a, old.b, (SELECT sum(a) FROM tbl), (SELECT sum(b) FROM tbl), new.a, new.b); END; CREATE TRIGGER conditional_update_row AFTER UPDATE ON tbl FOR EACH ROW WHEN old.a = 1 BEGIN INSERT INTO clog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM clog), old.a, old.b, (SELECT sum(a) FROM tbl), (SELECT sum(b) FROM tbl), new.a, new.b); END; } do_test trigger2-1.$ii.1 { set r {} foreach v [execsql { UPDATE tbl SET a = a * 10, b = b * 10; SELECT * FROM rlog ORDER BY idx; SELECT * FROM clog ORDER BY idx; }] { lappend r [expr {int($v)}] } set r } [list 1 1 2 4 6 10 20 \ 2 1 2 13 24 10 20 \ 3 3 4 13 24 30 40 \ 4 3 4 40 60 30 40 \ 1 1 2 13 24 10 20 ] execsql { DELETE FROM rlog; DELETE FROM tbl; INSERT INTO tbl VALUES (100, 100); INSERT INTO tbl VALUES (300, 200); CREATE TRIGGER delete_before_row BEFORE DELETE ON tbl FOR EACH ROW BEGIN INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), old.a, old.b, (SELECT sum(a) FROM tbl), (SELECT sum(b) FROM tbl), 0, 0); END; CREATE TRIGGER delete_after_row AFTER DELETE ON tbl FOR EACH ROW BEGIN INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), old.a, old.b, (SELECT sum(a) FROM tbl), (SELECT sum(b) FROM tbl), 0, 0); END; } do_test trigger2-1.$ii.2 { set r {} foreach v [execsql { DELETE FROM tbl; SELECT * FROM rlog; }] { lappend r [expr {int($v)}] } set r } [list 1 100 100 400 300 0 0 \ 2 100 100 300 200 0 0 \ 3 300 200 300 200 0 0 \ 4 300 200 0 0 0 0 ] execsql { DELETE FROM rlog; CREATE TRIGGER insert_before_row BEFORE INSERT ON tbl FOR EACH ROW BEGIN INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), 0, 0, (SELECT sum(a) FROM tbl), (SELECT sum(b) FROM tbl), new.a, new.b); END; CREATE TRIGGER insert_after_row AFTER INSERT ON tbl FOR EACH ROW BEGIN INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), 0, 0, (SELECT sum(a) FROM tbl), (SELECT sum(b) FROM tbl), new.a, new.b); END; } do_test trigger2-1.$ii.3 { execsql { CREATE TABLE other_tbl(a, b); INSERT INTO other_tbl VALUES(1, 2); INSERT INTO other_tbl VALUES(3, 4); -- INSERT INTO tbl SELECT * FROM other_tbl; INSERT INTO tbl VALUES(5, 6); DROP TABLE other_tbl; SELECT * FROM rlog; } } [list 1 0 0 0.0 0.0 5 6 \ 2 0 0 5.0 6.0 5 6 ] integrity_check trigger2-1.$ii.4 } catchsql { DROP TABLE rlog; DROP TABLE clog; DROP TABLE tbl; DROP TABLE other_tbl; } } # 2. set ii 0 foreach tr_program { {UPDATE tbl SET b = old.b;} {INSERT INTO log VALUES(new.c, 2, 3);} |
︙ | ︙ | |||
344 345 346 347 348 349 350 | } {3} execsql { DROP TABLE tbl; DROP TABLE log; } # trigger2-3.2: WHEN clause | < | > > | > > > > > > | | | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | } {3} execsql { DROP TABLE tbl; DROP TABLE log; } # trigger2-3.2: WHEN clause set when_triggers [list {t1 BEFORE INSERT ON tbl WHEN new.a > 20}] ifcapable subquery { lappend when_triggers \ {t2 BEFORE INSERT ON tbl WHEN (SELECT count(*) FROM tbl) = 0} ] } execsql { CREATE TABLE tbl (a, b, c, d); CREATE TABLE log (a); INSERT INTO log VALUES (0); } foreach trig $when_triggers { execsql "CREATE TRIGGER $trig BEGIN UPDATE log set a = a + 1; END;" } ifcapable subquery { set t232 {1 0 1} } else { set t232 {0 0 1} } do_test trigger2-3.2 { execsql { INSERT INTO tbl VALUES(0, 0, 0, 0); -- 1 (ifcapable subquery) SELECT * FROM log; UPDATE log SET a = 0; INSERT INTO tbl VALUES(0, 0, 0, 0); -- 0 SELECT * FROM log; UPDATE log SET a = 0; INSERT INTO tbl VALUES(200, 0, 0, 0); -- 1 SELECT * FROM log; UPDATE log SET a = 0; } } $t232 execsql { DROP TABLE tbl; DROP TABLE log; } integrity_check trigger2-3.3 # Simple cascaded trigger |
︙ | ︙ |
Changes to test/view.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2002 February 26 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing VIEW statements. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2002 February 26 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing VIEW statements. # # $Id: view.test,v 1.22 2005/01/21 04:25:47 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Omit this entire file if the library is not configured with views enabled. ifcapable !view { finish_test return |
︙ | ︙ | |||
331 332 333 334 335 336 337 | } {7 2 13 5 19 8 27 12} do_test view-8.3 { execsql { CREATE VIEW v7 AS SELECT pqr+xyz AS a FROM v6; SELECT * FROM v7 ORDER BY a; } } {9 18 27 39} | > > | | | | | | | | | | | | | | | | | | | | | | > | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | } {7 2 13 5 19 8 27 12} do_test view-8.3 { execsql { CREATE VIEW v7 AS SELECT pqr+xyz AS a FROM v6; SELECT * FROM v7 ORDER BY a; } } {9 18 27 39} ifcapable subquery { do_test view-8.4 { execsql { CREATE VIEW v8 AS SELECT max(cnt) AS mx FROM (SELECT a%2 AS eo, count(*) AS cnt FROM t1 GROUP BY eo); SELECT * FROM v8; } } 3 do_test view-8.5 { execsql { SELECT mx+10, mx*2 FROM v8; } } {13 6} do_test view-8.6 { execsql { SELECT mx+10, pqr FROM v6, v8 WHERE xyz=2; } } {13 7} do_test view-8.7 { execsql { SELECT mx+10, pqr FROM v6, v8 WHERE xyz>2; } } {13 13 13 19 13 27} } ;# ifcapable subquery # Tests for a bug found by Michiel de Wit involving ORDER BY in a VIEW. # do_test view-9.1 { execsql { INSERT INTO t2 SELECT * FROM t2 WHERE a<5; INSERT INTO t2 SELECT * FROM t2 WHERE a<4; |
︙ | ︙ |