Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Modify test suite to work when SQLITE_OMIT_VIEW is defined. (CVS 2132) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
711e8d7695dfc74b3f1ee00591dcdda2 |
User & Date: | danielk1977 2004-11-22 08:43:32.000 |
Context
2004-11-22
| ||
10:02 | Back out changes allowing writes to tables that have open cursors. (CVS 2133) (check-in: 91acd87e52 user: danielk1977 tags: trunk) | |
08:43 | Modify test suite to work when SQLITE_OMIT_VIEW is defined. (CVS 2132) (check-in: 711e8d7695 user: danielk1977 tags: trunk) | |
05:26 | Have tests pass when SQLITE_OMIT_MEMORYDB is defined. (CVS 2131) (check-in: 9df837c039 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.30 2004/11/22 08:43:32 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 |
︙ | ︙ | |||
516 517 518 519 520 521 522 523 524 525 526 527 528 529 | do_test attach-4.9 { ifcapable {!trigger} {execsql {INSERT INTO main.t4 VALUES('main.15')}} execsql { INSERT INTO main.t3 VALUES(15,16); SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4; } } {db2.6 db2.13 main.11 main.15} do_test attach-4.10 { execsql { DETACH DATABASE db2; } execsql { CREATE VIEW v3 AS SELECT x*100+y FROM t3; SELECT * FROM v3; | > > | 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | do_test attach-4.9 { ifcapable {!trigger} {execsql {INSERT INTO main.t4 VALUES('main.15')}} execsql { INSERT INTO main.t3 VALUES(15,16); SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4; } } {db2.6 db2.13 main.11 main.15} ifcapable view { do_test attach-4.10 { execsql { DETACH DATABASE db2; } execsql { CREATE VIEW v3 AS SELECT x*100+y FROM t3; SELECT * FROM v3; |
︙ | ︙ | |||
542 543 544 545 546 547 548 549 550 551 552 553 554 555 | } } {102 910 607 1314} do_test attach-4.13 { execsql { SELECT * FROM main.v3; } } {910 1112 1516} # Tests for the sqliteFix...() routines in attach.c # ifcapable {trigger} { do_test attach-5.1 { db close sqlite3 db test.db | > | 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | } } {102 910 607 1314} do_test attach-4.13 { execsql { SELECT * FROM main.v3; } } {910 1112 1516} } ;# ifcapable view # Tests for the sqliteFix...() routines in attach.c # ifcapable {trigger} { do_test attach-5.1 { db close sqlite3 db test.db |
︙ | ︙ |
Changes to test/attach3.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 schema changes to attached databases. # | | | 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 schema changes to attached databases. # # $Id: attach3.test,v 1.14 2004/11/22 08:43:32 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Create tables t1 and t2 in the main database |
︙ | ︙ | |||
118 119 120 121 122 123 124 125 126 127 128 129 130 131 | execsql { DROP TABLE t2; SELECT name FROM aux.sqlite_master; } } {t3} # Create a view in the auxilary database. do_test attach3-5.1 { execsql { CREATE VIEW aux.v1 AS SELECT * FROM t3; } } {} do_test attach3-5.2 { execsql { | > | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | execsql { DROP TABLE t2; SELECT name FROM aux.sqlite_master; } } {t3} # Create a view in the auxilary database. ifcapable view { do_test attach3-5.1 { execsql { CREATE VIEW aux.v1 AS SELECT * FROM t3; } } {} do_test attach3-5.2 { execsql { |
︙ | ︙ | |||
146 147 148 149 150 151 152 153 154 155 156 157 158 159 | } } {} do_test attach3-6.2 { execsql { SELECT * FROM aux.sqlite_master WHERE name = 'v1'; } } {} ifcapable {trigger} { # Create a trigger in the auxilary database. do_test attach3-7.1 { execsql { CREATE TRIGGER aux.tr1 AFTER INSERT ON t3 BEGIN INSERT INTO t3 VALUES(new.e*2, new.f*2); | > | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | } } {} do_test attach3-6.2 { execsql { SELECT * FROM aux.sqlite_master WHERE name = 'v1'; } } {} } ;# ifcapable view ifcapable {trigger} { # Create a trigger in the auxilary database. do_test attach3-7.1 { execsql { CREATE TRIGGER aux.tr1 AFTER INSERT ON t3 BEGIN INSERT INTO t3 VALUES(new.e*2, new.f*2); |
︙ | ︙ |
Changes to test/auth.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: auth.test,v 1.22 2004/11/22 08:43:32 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # disable this test if the SQLITE_OMIT_AUTHORIZATION macro is # defined during compilation. |
︙ | ︙ | |||
534 535 536 537 538 539 540 541 542 543 544 545 546 547 | } catchsql {DROP TABLE t1} } {0 {}} do_test auth-1.78 { execsql {SELECT name FROM sqlite_temp_master} } {t1} do_test auth-1.79 { proc auth {code arg1 arg2 arg3 arg4} { if {$code=="SQLITE_CREATE_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK | > > > | 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | } catchsql {DROP TABLE t1} } {0 {}} do_test auth-1.78 { execsql {SELECT name FROM sqlite_temp_master} } {t1} # Test cases auth-1.79 to auth-1.123 test creating and dropping views. # Omit these if the library was compiled with views omitted. ifcapable view { do_test auth-1.79 { proc auth {code arg1 arg2 arg3 arg4} { if {$code=="SQLITE_CREATE_VIEW"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } return SQLITE_OK |
︙ | ︙ | |||
802 803 804 805 806 807 808 809 810 811 812 813 814 815 | } {0 {}} do_test auth-1.123 { set ::authargs } {v1 {} temp {}} do_test auth-1.124 { execsql {SELECT name FROM sqlite_temp_master} } {t1} do_test auth-1.125 { proc auth {code arg1 arg2 arg3 arg4} { if {$code=="SQLITE_CREATE_TRIGGER"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } | > | 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | } {0 {}} do_test auth-1.123 { set ::authargs } {v1 {} temp {}} do_test auth-1.124 { execsql {SELECT name FROM sqlite_temp_master} } {t1} } ;# ifcapable view do_test auth-1.125 { proc auth {code arg1 arg2 arg3 arg4} { if {$code=="SQLITE_CREATE_TRIGGER"} { set ::authargs [list $arg1 $arg2 $arg3 $arg4] return SQLITE_DENY } |
︙ | ︙ | |||
1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 | SQLITE_INSERT tx {} main r1 \ SQLITE_READ t2 a main r1 \ SQLITE_READ t2 a main r1 \ SQLITE_READ t2 b main r1 \ SQLITE_READ t2 b main r1 \ SQLITE_READ t2 c main r1 \ SQLITE_READ t2 c main r1] do_test auth-4.2 { execsql { CREATE VIEW v1 AS SELECT a+b AS x FROM t2; CREATE TABLE v1chng(x1,x2); CREATE TRIGGER r2 INSTEAD OF UPDATE ON v1 BEGIN INSERT INTO v1chng VALUES(OLD.x,NEW.x); END; | > > | 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 | SQLITE_INSERT tx {} main r1 \ SQLITE_READ t2 a main r1 \ SQLITE_READ t2 a main r1 \ SQLITE_READ t2 b main r1 \ SQLITE_READ t2 b main r1 \ SQLITE_READ t2 c main r1 \ SQLITE_READ t2 c main r1] ifcapable view { do_test auth-4.2 { execsql { CREATE VIEW v1 AS SELECT a+b AS x FROM t2; CREATE TABLE v1chng(x1,x2); CREATE TRIGGER r2 INSTEAD OF UPDATE ON v1 BEGIN INSERT INTO v1chng VALUES(OLD.x,NEW.x); END; |
︙ | ︙ | |||
1976 1977 1978 1979 1980 1981 1982 1983 1984 | SQLITE_DELETE v1 {} main {} \ SQLITE_READ v1 x main {} \ SQLITE_SELECT {} {} {} v1 \ SQLITE_READ t2 a main v1 \ SQLITE_READ t2 b main v1 \ SQLITE_INSERT v1chng {} main r3 \ SQLITE_READ v1 x main r3] finish_test | > > | 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 | SQLITE_DELETE v1 {} main {} \ SQLITE_READ v1 x main {} \ SQLITE_SELECT {} {} {} v1 \ SQLITE_READ t2 a main v1 \ SQLITE_READ t2 b main v1 \ SQLITE_INSERT v1chng {} main r3 \ SQLITE_READ v1 x main r3] } ;# ifcapable view finish_test |
Changes to test/collate3.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 page cache subsystem. # | | | 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 page cache subsystem. # # $Id: collate3.test,v 1.5 2004/11/22 08:43:32 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # # Tests are organised as follows: # |
︙ | ︙ | |||
307 308 309 310 311 312 313 314 315 316 317 318 319 320 | set res [expr ($lhs > $rhs)?1:0] } return $res } # Check we can create a view that uses an explicit collation # sequence and then close and re-open the database. do_test collate3-4.9 { db collate user_defined numeric_compare execsql { CREATE TABLE collate3t1(a, b); INSERT INTO collate3t1 VALUES('2', NULL); INSERT INTO collate3t1 VALUES('101', NULL); INSERT INTO collate3t1 VALUES('12', NULL); | > | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | set res [expr ($lhs > $rhs)?1:0] } return $res } # Check we can create a view that uses an explicit collation # sequence and then close and re-open the database. ifcapable view { do_test collate3-4.9 { db collate user_defined numeric_compare execsql { CREATE TABLE collate3t1(a, b); INSERT INTO collate3t1 VALUES('2', NULL); INSERT INTO collate3t1 VALUES('101', NULL); INSERT INTO collate3t1 VALUES('12', NULL); |
︙ | ︙ | |||
337 338 339 340 341 342 343 344 345 346 347 348 349 350 | } } {0 {2 {} 12 {} 101 {}}} do_test collate3-4.12 { execsql { DROP TABLE collate3t1; } } {} # # Test the collation factory. In the code, the "no such collation sequence" # message is only generated in two places. So these tests just test that # the collation factory can be called once from each of those points. # do_test collate3-5.0 { | > | 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | } } {0 {2 {} 12 {} 101 {}}} do_test collate3-4.12 { execsql { DROP TABLE collate3t1; } } {} } ;# ifcapable view # # Test the collation factory. In the code, the "no such collation sequence" # message is only generated in two places. So these tests just test that # the collation factory can be called once from each of those points. # do_test collate3-5.0 { |
︙ | ︙ |
Changes to test/index.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 CREATE INDEX 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 CREATE INDEX statement. # # $Id: index.test,v 1.36 2004/11/22 08:43:32 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a basic index and verify it is added to sqlite_master # do_test index-1.1 { |
︙ | ︙ | |||
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | } } {1 {object name reserved for internal use: sqlite_t1}} do_test index-18.2 { catchsql { CREATE INDEX sqlite_i1 ON t7(c); } } {1 {object name reserved for internal use: sqlite_i1}} do_test index-18.3 { catchsql { CREATE VIEW sqlite_v1 AS SELECT * FROM t7; } } {1 {object name reserved for internal use: sqlite_v1}} ifcapable {trigger} { do_test index-18.4 { catchsql { CREATE TRIGGER sqlite_tr1 BEFORE INSERT ON t7 BEGIN SELECT 1; END; } } {1 {object name reserved for internal use: sqlite_tr1}} } | > > | 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | } } {1 {object name reserved for internal use: sqlite_t1}} do_test index-18.2 { catchsql { CREATE INDEX sqlite_i1 ON t7(c); } } {1 {object name reserved for internal use: sqlite_i1}} ifcapable view { do_test index-18.3 { catchsql { CREATE VIEW sqlite_v1 AS SELECT * FROM t7; } } {1 {object name reserved for internal use: sqlite_v1}} } ;# ifcapable view ifcapable {trigger} { do_test index-18.4 { catchsql { CREATE TRIGGER sqlite_tr1 BEFORE INSERT ON t7 BEGIN SELECT 1; END; } } {1 {object name reserved for internal use: sqlite_tr1}} } |
︙ | ︙ |
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.12 2004/11/22 08:43:32 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test join-1.1 { execsql { CREATE TABLE t1(a,b,c); |
︙ | ︙ | |||
324 325 326 327 328 329 330 331 332 333 334 335 336 337 | SELECT coalesce(t8.a,999) from t7 LEFT JOIN t8 on y=a; } } {1 999 999 2 131 130 999} # Make sure a left join where the right table is really a view that # is itself a join works right. Ticket #306. # do_test join-8.1 { execsql { BEGIN; CREATE TABLE t9(a INTEGER PRIMARY KEY, b); INSERT INTO t9 VALUES(1,11); INSERT INTO t9 VALUES(2,22); CREATE TABLE t10(x INTEGER PRIMARY KEY, y); | > | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | SELECT coalesce(t8.a,999) from t7 LEFT JOIN t8 on y=a; } } {1 999 999 2 131 130 999} # Make sure a left join where the right table is really a view that # is itself a join works right. Ticket #306. # ifcapable view { do_test join-8.1 { execsql { BEGIN; CREATE TABLE t9(a INTEGER PRIMARY KEY, b); INSERT INTO t9 VALUES(1,11); INSERT INTO t9 VALUES(2,22); CREATE TABLE t10(x INTEGER PRIMARY KEY, y); |
︙ | ︙ | |||
352 353 354 355 356 357 358 359 360 361 362 363 364 365 | } } {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 {} {}} # Ticket #350 describes a scenario where LEFT OUTER JOIN does not # function correctly if the right table in the join is really # subquery. # # To test the problem, we generate the same LEFT OUTER JOIN in two # separate selects but with on using a subquery and the other calling | > | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | } } {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 # Ticket #350 describes a scenario where LEFT OUTER JOIN does not # function correctly if the right table in the join is really # subquery. # # To test the problem, we generate the same LEFT OUTER JOIN in two # separate selects but with on using a subquery and the other calling |
︙ | ︙ | |||
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | 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); } } {} 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; } } {} finish_test | > > | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | 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); } } {} 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 finish_test |
Changes to test/lastinsert.test.
︙ | ︙ | |||
49 50 51 52 53 54 55 | catchsql { delete from t1 where k=4; select last_insert_rowid(); } } {0 3} # LIRID unchanged after create table/view statements | | > > > > > > > | 49 50 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 | catchsql { delete from t1 where k=4; select last_insert_rowid(); } } {0 3} # LIRID unchanged after create table/view statements do_test lastinsert-1.4.1 { catchsql { create table t2 (k integer primary key, val1, val2, val3); select last_insert_rowid(); } } {0 3} ifcapable view { do_test lastinsert-1.4.2 { catchsql { create view v as select * from t1; select last_insert_rowid(); } } {0 3} } ;# ifcapable view # All remaining tests involve triggers. Skip them if triggers are not # supported in this build. # ifcapable {!trigger} { finish_test return |
︙ | ︙ | |||
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | catchsql { select val3 from t2; } } {0 1028} # ---------------------------------------------------------------------------- # 4.x - tests with instead of insert trigger # LIRID not changed after an insert into view containing an instead of trigger do_test lastinsert-4.1 { catchsql { delete from t2; drop trigger r1; create trigger r1 instead of insert on v for each row begin insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL); | > > > | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | catchsql { select val3 from t2; } } {0 1028} # ---------------------------------------------------------------------------- # 4.x - tests with instead of insert trigger # These may not be run if either views or triggers were disabled at # compile-time ifcapable {view && trigger} { # LIRID not changed after an insert into view containing an instead of trigger do_test lastinsert-4.1 { catchsql { delete from t2; drop trigger r1; create trigger r1 instead of insert on v for each row begin insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL); |
︙ | ︙ | |||
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | # LIRID unchanged by update within context of instead of trigger do_test lastinsert-4.4 { catchsql { select val3 from t2; } } {0 1030} # ---------------------------------------------------------------------------- # 5.x - tests with before delete trigger # LIRID not changed after a delete on a table containing a before trigger do_test lastinsert-5.1 { catchsql { delete from t2; | > > > > < | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | # LIRID unchanged by update within context of instead of trigger do_test lastinsert-4.4 { catchsql { select val3 from t2; } } {0 1030} } ;# ifcapable (view && trigger) # ---------------------------------------------------------------------------- # 5.x - tests with before delete trigger # LIRID not changed after a delete on a table containing a before trigger do_test lastinsert-5.1 { catchsql { drop trigger r1; -- This was not created if views are disabled. } catchsql { delete from t2; create trigger r1 before delete on t1 for each row begin insert into t2 values (77, last_insert_rowid(), NULL, NULL); update t2 set k=k+10, val2=100+last_insert_rowid(); update t2 set val3=1000+last_insert_rowid(); end; delete from t1 where k=1; select last_insert_rowid(); |
︙ | ︙ | |||
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | catchsql { select val3 from t2; } } {0 1077} # ---------------------------------------------------------------------------- # 6.x - tests with instead of update trigger # LIRID not changed after an update on a view containing an instead of trigger do_test lastinsert-6.1 { catchsql { delete from t2; drop trigger r1; create trigger r1 instead of update on v for each row begin insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL); | > > | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | catchsql { select val3 from t2; } } {0 1077} # ---------------------------------------------------------------------------- # 6.x - tests with instead of update trigger # These tests may not run if either views or triggers are disabled. ifcapable {view && trigger} { # LIRID not changed after an update on a view containing an instead of trigger do_test lastinsert-6.1 { catchsql { delete from t2; drop trigger r1; create trigger r1 instead of update on v for each row begin insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL); |
︙ | ︙ | |||
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | # LIRID unchanged by update within context of instead of trigger do_test lastinsert-6.4 { catchsql { select val3 from t2; } } {0 1032} # ---------------------------------------------------------------------------- # 7.x - complex tests with temporary tables and nested instead of triggers do_test lastinsert-7.1 { catchsql { drop table t1; drop table t2; drop trigger r1; create temp table t1 (k integer primary key); create temp table t2 (k integer primary key); create temp view v1 as select * from t1; create temp view v2 as select * from t2; | > > > | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | # LIRID unchanged by update within context of instead of trigger do_test lastinsert-6.4 { catchsql { select val3 from t2; } } {0 1032} } ;# ifcapable (view && trigger) # ---------------------------------------------------------------------------- # 7.x - complex tests with temporary tables and nested instead of triggers # These do not run if views or triggers are disabled. ifcapable {trigger && view} { do_test lastinsert-7.1 { catchsql { drop table t1; drop table t2; drop trigger r1; create temp table t1 (k integer primary key); create temp table t2 (k integer primary key); create temp view v1 as select * from t1; create temp view v2 as select * from t2; |
︙ | ︙ | |||
318 319 320 321 322 323 324 325 326 | } {0 105} do_test lastinsert-7.6 { catchsql { select rout from rid where k=2; } } {0 1205} finish_test | > > | 336 337 338 339 340 341 342 343 344 345 346 | } {0 105} do_test lastinsert-7.6 { catchsql { select rout from rid where k=2; } } {0 1205} } ;# ifcapable (view && trigger) finish_test |
Changes to test/laststmtchanges.test.
︙ | ︙ | |||
189 190 191 192 193 194 195 196 197 198 199 200 201 202 | catchsql { select v2 from t2; } } {0 1} # ---------------------------------------------------------------------------- # 5.x - complex tests with temporary tables and nested instead of triggers do_test laststmtchanges-5.1 { catchsql { drop table t0; drop table t1; drop table t2; create temp table t0(x); create temp table t1 (k integer primary key); create temp table t2 (k integer primary key); | > > > | 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | catchsql { select v2 from t2; } } {0 1} # ---------------------------------------------------------------------------- # 5.x - complex tests with temporary tables and nested instead of triggers # These tests cannot run if the library does not have view support enabled. ifcapable view { do_test laststmtchanges-5.1 { catchsql { drop table t0; drop table t1; drop table t2; create temp table t0(x); create temp table t1 (k integer primary key); create temp table t2 (k integer primary key); |
︙ | ︙ | |||
257 258 259 260 261 262 263 264 265 | } {0 {0 5 1 0}} do_test laststmtchanges-5.5 { catchsql { select n from n2; } } {0 {0 1 0 3}} finish_test | > > | 260 261 262 263 264 265 266 267 268 269 270 | } {0 {0 5 1 0}} do_test laststmtchanges-5.5 { catchsql { select n from n2; } } {0 {0 1 0 3}} } ;# ifcapable view 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.17 2004/11/22 08:43:32 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Build some test data # execsql { |
︙ | ︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 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} do_test limit-2.1 { execsql { CREATE VIEW v1 AS SELECT * FROM t1 LIMIT 2; SELECT count(*) FROM (SELECT * FROM v1); } } 2 do_test limit-2.2 { execsql { CREATE TABLE t2 AS SELECT * FROM t1 LIMIT 2; SELECT count(*) FROM t2; } } 2 do_test limit-2.3 { | > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | 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 { 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 do_test limit-2.3 { |
︙ | ︙ |
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.15 2004/11/22 08:43:32 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {trigger} { # Test for ticket #360 # |
︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 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); SELECT rowid, * FROM (SELECT * FROM t1, t2); } } {{} 1 2 3 7 8 9} do_test misc2-2.2 { execsql { CREATE VIEW v1 AS SELECT * FROM t1, t2; SELECT rowid, * FROM v1; } } {{} 1 2 3 7 8 9} # 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 } | > > | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 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); SELECT rowid, * FROM (SELECT * FROM t1, t2); } } {{} 1 2 3 7 8 9} ifcapable view { do_test misc2-2.2 { 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 } |
︙ | ︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | } {1 2147483647 2147483648 4000000000} # There were some issues with expanding a SrcList object using a call # to sqliteSrcListAppend() if the SrcList had previously been duplicated # using a call to sqliteSrcListDup(). Ticket #416. The following test # makes sure the problem has been fixed. # do_test misc2-5.1 { execsql { CREATE TABLE x(a,b); CREATE VIEW y AS SELECT x1.b AS p, x2.b AS q FROM x AS x1, x AS x2 WHERE x1.a=x2.a; CREATE VIEW z AS SELECT y1.p, y2.p FROM y AS y1, y AS y2 WHERE y1.q=y2.q; SELECT * from z; } } {} # Make sure we can open a database with an empty filename. What this # does is store the database in a temporary file that is deleted when # the database is closed. Ticket #432. # do_test misc2-6.1 { db close | > > | 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 | } {1 2147483647 2147483648 4000000000} # There were some issues with expanding a SrcList object using a call # to sqliteSrcListAppend() if the SrcList had previously been duplicated # using a call to sqliteSrcListDup(). Ticket #416. The following test # makes sure the problem has been fixed. # ifcapable view { do_test misc2-5.1 { execsql { CREATE TABLE x(a,b); CREATE VIEW y AS SELECT x1.b AS p, x2.b AS q FROM x AS x1, x AS x2 WHERE x1.a=x2.a; CREATE VIEW z AS SELECT y1.p, y2.p FROM y AS y1, y AS y2 WHERE y1.q=y2.q; SELECT * from z; } } {} } # Make sure we can open a database with an empty filename. What this # does is store the database in a temporary file that is deleted when # the database is closed. Ticket #432. # do_test misc2-6.1 { db close |
︙ | ︙ |
Changes to test/select7.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # 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 compute SELECT statements and nested # views. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 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 compute SELECT statements and nested # views. # # $Id: select7.test,v 1.2 2004/11/22 08:43:32 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # A 3-way INTERSECT. Ticket #875 do_test select7-1.1 { |
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | intersect select * from t1 where x like '__x'; } } {amx} # Nested views do not handle * properly. Ticket #826. # do_test select7-2.1 { execsql { CREATE TABLE x(id integer primary key, a TEXT NULL); INSERT INTO x (a) VALUES ('first'); CREATE TABLE tempx(id integer primary key, a TEXT NULL); INSERT INTO tempx (a) VALUES ('t-first'); CREATE VIEW tv1 AS SELECT x.id, tx.id FROM x JOIN tempx tx ON tx.id=x.id; CREATE VIEW tv1b AS SELECT x.id, tx.id FROM x JOIN tempx tx on tx.id=x.id; CREATE VIEW tv2 AS SELECT * FROM tv1 UNION SELECT * FROM tv1b; SELECT * FROM tv2; } } {1 1} finish_test | > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | intersect select * from t1 where x like '__x'; } } {amx} # Nested views do not handle * properly. Ticket #826. # ifcapable view { do_test select7-2.1 { execsql { CREATE TABLE x(id integer primary key, a TEXT NULL); INSERT INTO x (a) VALUES ('first'); CREATE TABLE tempx(id integer primary key, a TEXT NULL); INSERT INTO tempx (a) VALUES ('t-first'); CREATE VIEW tv1 AS SELECT x.id, tx.id FROM x JOIN tempx tx ON tx.id=x.id; CREATE VIEW tv1b AS SELECT x.id, tx.id FROM x JOIN tempx tx on tx.id=x.id; CREATE VIEW tv2 AS SELECT * FROM tv1 UNION SELECT * FROM tv1b; SELECT * FROM tv2; } } {1 1} } ;# ifcapable view finish_test |
Changes to test/sort.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 CREATE TABLE 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 CREATE TABLE statement. # # $Id: sort.test,v 1.17 2004/11/22 08:43:32 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a bunch of data to sort against # do_test sort-1.0 { |
︙ | ︙ | |||
277 278 279 280 281 282 283 284 285 286 287 288 289 290 | } } {1 2 11 12} do_test sort-7.2 { execsql { SELECT b FROM t4 ORDER BY 1 } } {1 11 12 2} do_test sort-7.3 { execsql { CREATE VIEW v4 AS SELECT * FROM t4; SELECT a FROM v4 ORDER BY 1; } } {1 2 11 12} do_test sort-7.4 { | > > > > | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | } } {1 2 11 12} do_test sort-7.2 { execsql { SELECT b FROM t4 ORDER BY 1 } } {1 11 12 2} # Omit tests sort-7.3 to sort-7.8 if view support was disabled at # compilatation time. ifcapable view { do_test sort-7.3 { execsql { CREATE VIEW v4 AS SELECT * FROM t4; SELECT a FROM v4 ORDER BY 1; } } {1 2 11 12} do_test sort-7.4 { |
︙ | ︙ | |||
308 309 310 311 312 313 314 315 316 317 318 319 320 321 | } } {1 2 11 12 1 11 12 2} ;# numeric from t4.a and text from v4.b do_test sort-7.8 { execsql { SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1; } } {1 11 12 2} #### Version 3 works differently here: #do_test sort-7.9 { # execsql { # SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE numeric; # } #} {1 2 11 12} #do_test sort-7.10 { | > > | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | } } {1 2 11 12 1 11 12 2} ;# numeric from t4.a and text from v4.b do_test sort-7.8 { execsql { SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1; } } {1 11 12 2} } ;# ifcapable view #### Version 3 works differently here: #do_test sort-7.9 { # execsql { # SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE numeric; # } #} {1 2 11 12} #do_test sort-7.10 { |
︙ | ︙ |
Changes to test/trigger1.test.
︙ | ︙ | |||
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 | catchsql { create table t1(a,b); create trigger t1t instead of update on t1 for each row begin delete from t1 WHERE a=old.a+2; end; } } {1 {cannot create INSTEAD OF trigger on table: main.t1}} # Ensure that we cannot create BEFORE triggers on views do_test trigger1-1.13 { catchsql { create view v1 as select * from t1; create trigger v1t before update on v1 for each row begin delete from t1 WHERE a=old.a+2; end; } } {1 {cannot create BEFORE trigger on view: main.v1}} # Ensure that we cannot create AFTER triggers on views do_test trigger1-1.14 { catchsql { drop view v1; create view v1 as select * from t1; create trigger v1t AFTER update on v1 for each row begin delete from t1 WHERE a=old.a+2; end; } } {1 {cannot create AFTER trigger on view: main.v1}} # Check for memory leaks in the trigger parser # do_test trigger1-2.1 { catchsql { CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN SELECT * FROM; -- Syntax error | > > > | 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 | catchsql { create table t1(a,b); create trigger t1t instead of update on t1 for each row begin delete from t1 WHERE a=old.a+2; end; } } {1 {cannot create INSTEAD OF trigger on table: main.t1}} ifcapable view { # Ensure that we cannot create BEFORE triggers on views do_test trigger1-1.13 { catchsql { create view v1 as select * from t1; create trigger v1t before update on v1 for each row begin delete from t1 WHERE a=old.a+2; end; } } {1 {cannot create BEFORE trigger on view: main.v1}} # Ensure that we cannot create AFTER triggers on views do_test trigger1-1.14 { catchsql { drop view v1; create view v1 as select * from t1; create trigger v1t AFTER update on v1 for each row begin delete from t1 WHERE a=old.a+2; end; } } {1 {cannot create AFTER trigger on view: main.v1}} } ;# ifcapable view # Check for memory leaks in the trigger parser # do_test trigger1-2.1 { catchsql { CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN SELECT * FROM; -- Syntax error |
︙ | ︙ | |||
315 316 317 318 319 320 321 | # Create a trigger with the same name as a table. Make sure the # trigger works. Then drop the trigger. Make sure the table is # still there. # do_test trigger-6.1 { execsql {SELECT type, name FROM sqlite_master} | | | | | | 318 319 320 321 322 323 324 325 326 327 328 329 330 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 | # Create a trigger with the same name as a table. Make sure the # trigger works. Then drop the trigger. Make sure the table is # still there. # do_test trigger-6.1 { execsql {SELECT type, name FROM sqlite_master} } [concat [ifcapable view {list view v1}] {table t2}] do_test trigger-6.2 { execsql { CREATE TRIGGER t2 BEFORE DELETE ON t2 BEGIN SELECT RAISE(ABORT,'deletes are not allows'); END; SELECT type, name FROM sqlite_master; } } [concat [ifcapable view {list view v1}] {table t2 trigger t2}] do_test trigger-6.3 { catchsql {DELETE FROM t2} } {1 {deletes are not allows}} do_test trigger-6.4 { execsql {SELECT * FROM t2} } {3 4 7 8} do_test trigger-6.5 { db close sqlite3 db test.db execsql {SELECT type, name FROM sqlite_master} } [concat [ifcapable view {list view v1}] {table t2 trigger t2}] do_test trigger-6.6 { execsql { DROP TRIGGER t2; SELECT type, name FROM sqlite_master; } } [concat [ifcapable view {list view v1}] {table t2}] do_test trigger-6.7 { execsql {SELECT * FROM t2} } {3 4 7 8} do_test trigger-6.8 { db close sqlite3 db test.db execsql {SELECT * FROM t2} |
︙ | ︙ |
Changes to test/trigger2.test.
︙ | ︙ | |||
40 41 42 43 44 45 46 | # Verify that rows altered by triggers are not included in the return value # of the "count changes" interface. # # 6. ON CONFLICT clause handling # trigger2-6.1[a-f]: INSERT statements # trigger2-6.2[a-f]: UPDATE statements # | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | # Verify that rows altered by triggers are not included in the return value # of the "count changes" interface. # # 6. ON CONFLICT clause handling # trigger2-6.1[a-f]: INSERT statements # trigger2-6.2[a-f]: UPDATE statements # # 7. & 8. Triggers on views fire correctly. # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {!trigger} { finish_test return |
︙ | ︙ | |||
563 564 565 566 567 568 569 570 571 572 573 574 575 576 | } } {4 2 3 6 3 4} execsql { DROP TABLE tbl; } # 7. Triggers on views do_test trigger2-7.1 { execsql { CREATE TABLE ab(a, b); CREATE TABLE cd(c, d); INSERT INTO ab VALUES (1, 2); INSERT INTO ab VALUES (0, 0); INSERT INTO cd VALUES (3, 4); | > > | 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | } } {4 2 3 6 3 4} execsql { DROP TABLE tbl; } # 7. Triggers on views ifcapable view { do_test trigger2-7.1 { execsql { CREATE TABLE ab(a, b); CREATE TABLE cd(c, d); INSERT INTO ab VALUES (1, 2); INSERT INTO ab VALUES (0, 0); INSERT INTO cd VALUES (3, 4); |
︙ | ︙ | |||
705 706 707 708 709 710 711 712 713 714 715 | INSERT INTO v1log VALUES(OLD.x,NEW.x,OLD.y,NEW.y,OLD.z,NEW.z); END; DELETE FROM v1log; UPDATE v1 SET x=x+100, y=y+200, z=z+300; SELECT * FROM v1log; } } {3 103 5 205 4 304 9 109 11 211 10 310} integrity_check trigger2-9.9 finish_test | > > | 707 708 709 710 711 712 713 714 715 716 717 718 719 | INSERT INTO v1log VALUES(OLD.x,NEW.x,OLD.y,NEW.y,OLD.z,NEW.z); END; DELETE FROM v1log; UPDATE v1 SET x=x+100, y=y+200, z=z+300; SELECT * FROM v1log; } } {3 103 5 205 4 304 9 109 11 211 10 310} } ;# ifcapable view integrity_check trigger2-9.9 finish_test |
Changes to test/trigger3.test.
︙ | ︙ | |||
133 134 135 136 137 138 139 140 141 142 143 144 145 146 | INSERT INTO tbl2 VALUES (1, 2, 3); SELECT * FROM tbl2; SELECT * FROM tbl; } } {1 2 3 1 2 3 1 2 3} # Check that things also work for view-triggers execsql {CREATE VIEW tbl_view AS SELECT * FROM tbl} execsql { CREATE TRIGGER tbl_view_insert INSTEAD OF INSERT ON tbl_view BEGIN SELECT CASE WHEN (new.a = 1) THEN RAISE(ROLLBACK, 'View rollback') WHEN (new.a = 2) THEN RAISE(IGNORE) WHEN (new.a = 3) THEN RAISE(ABORT, 'View abort') END; END; | > > > | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | INSERT INTO tbl2 VALUES (1, 2, 3); SELECT * FROM tbl2; SELECT * FROM tbl; } } {1 2 3 1 2 3 1 2 3} # Check that things also work for view-triggers ifcapable view { execsql {CREATE VIEW tbl_view AS SELECT * FROM tbl} execsql { CREATE TRIGGER tbl_view_insert INSTEAD OF INSERT ON tbl_view BEGIN SELECT CASE WHEN (new.a = 1) THEN RAISE(ROLLBACK, 'View rollback') WHEN (new.a = 2) THEN RAISE(IGNORE) WHEN (new.a = 3) THEN RAISE(ABORT, 'View abort') END; END; |
︙ | ︙ | |||
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | } } {0 {}} do_test trigger3-7.3 { catchsql { INSERT INTO tbl_view VALUES(3, 2, 3); } } {1 {View abort}} integrity_check trigger3-8.1 catchsql { DROP TABLE tbl; } catchsql { DROP TABLE tbl2; } catchsql { DROP VIEW tbl_view; } finish_test | > > | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | } } {0 {}} do_test trigger3-7.3 { catchsql { INSERT INTO tbl_view VALUES(3, 2, 3); } } {1 {View abort}} } ;# ifcapable view integrity_check trigger3-8.1 catchsql { DROP TABLE tbl; } catchsql { DROP TABLE tbl2; } catchsql { DROP VIEW tbl_view; } finish_test |
Changes to test/trigger4.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | #*********************************************************************** # # This file tests the triggers of views. # set testdir [file dirname $argv0] source $testdir/tester.tcl | > > | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #*********************************************************************** # # This file tests the triggers of views. # set testdir [file dirname $argv0] source $testdir/tester.tcl # If either views or triggers are disabled in this build, omit this file. ifcapable {!trigger || !view} { finish_test return } do_test trigger4-1.1 { execsql { create table test1(id integer primary key,a); |
︙ | ︙ |
Changes to test/vacuum.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 VACUUM 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 VACUUM statement. # # $Id: vacuum.test,v 1.31 2004/11/22 08:43:32 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If the VACUUM statement is disabled in the current build, skip all # the tests in this file. # |
︙ | ︙ | |||
81 82 83 84 85 86 87 | } $cksum ifcapable vacuum { do_test vacuum-1.3 { expr {[file size test.db]<$::size1} } {1} } do_test vacuum-1.4 { | | > > > > > > > | 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 | } $cksum ifcapable vacuum { do_test vacuum-1.3 { expr {[file size test.db]<$::size1} } {1} } do_test vacuum-1.4 { set sql_script { BEGIN; CREATE TABLE t2 AS SELECT * FROM t1; CREATE TABLE t3 AS SELECT * FROM t1; CREATE VIEW v1 AS SELECT b, c FROM t3; CREATE TRIGGER r1 AFTER DELETE ON t2 BEGIN SELECT 1; END; COMMIT; DROP TABLE t2; } # If the library was compiled to omit view support, comment out the # create view in the script $sql_script before executing it. ifcapable !view { regsub {CREATE VIEW} $sql_script {-- CREATE VIEW} sql_script } execsql $sql_script set ::size1 [file size test.db] set ::cksum [cksum] expr {$::cksum!=""} } {1} do_test vacuum-1.5 { execsql { VACUUM; } cksum } $cksum ifcapable vacuum { do_test vacuum-1.6 { expr {[file size test.db]<$::size1} } {1} } ifcapable vacuum { do_test vacuum-2.1 { |
︙ | ︙ | |||
167 168 169 170 171 172 173 | sqlite3_step $VM } {SQLITE_DONE} do_test vacuum-4.2 { sqlite3_finalize $VM } SQLITE_OK # Ticket #515. VACUUM after deleting and recreating the table that | | > | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | sqlite3_step $VM } {SQLITE_DONE} do_test vacuum-4.2 { sqlite3_finalize $VM } SQLITE_OK # Ticket #515. VACUUM after deleting and recreating the table that # a view refers to. Omit this test if the library is not view-enabled. # ifcapable view { do_test vacuum-5.1 { db close file delete -force test.db sqlite3 db test.db catchsql { CREATE TABLE Test (TestID int primary key); INSERT INTO Test VALUES (NULL); |
︙ | ︙ | |||
193 194 195 196 197 198 199 200 201 202 203 204 205 206 | } } {0 {}} do_test vacuum-5.2 { catchsql { VACUUM; } } {0 {}} # Ensure vacuum works with complicated tables names. do_test vacuum-6.1 { execsql { CREATE TABLE "abc abc"(a, b, c); INSERT INTO "abc abc" VALUES(1, 2, 3); VACUUM; | > | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | } } {0 {}} do_test vacuum-5.2 { catchsql { VACUUM; } } {0 {}} } ;# ifcapable view # Ensure vacuum works with complicated tables names. do_test vacuum-6.1 { execsql { CREATE TABLE "abc abc"(a, b, c); INSERT INTO "abc abc" VALUES(1, 2, 3); VACUUM; |
︙ | ︙ |
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 22 23 24 25 26 27 28 29 | # 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.20 2004/11/22 08:43:32 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 } do_test view-1.0 { execsql { CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,3); INSERT INTO t1 VALUES(4,5,6); INSERT INTO t1 VALUES(7,8,9); |
︙ | ︙ |