danielk1977 | 45783d0 | 2008-12-26 07:56:39 +0000 | [diff] [blame] | 1 | # 2008 December 24 |
| 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 to verify that ticket #3554 has been |
| 14 | # fixed. |
| 15 | # |
drh | dda70fe | 2009-06-05 17:09:11 +0000 | [diff] [blame] | 16 | # $Id: tkt3554.test,v 1.2 2009/06/05 17:09:12 drh Exp $ |
danielk1977 | 45783d0 | 2008-12-26 07:56:39 +0000 | [diff] [blame] | 17 | |
| 18 | set testdir [file dirname $argv0] |
| 19 | source $testdir/tester.tcl |
| 20 | |
| 21 | ifcapable !trigger { |
| 22 | finish_test |
| 23 | return |
| 24 | } |
| 25 | |
| 26 | do_test tkt3544-1.1 { |
| 27 | execsql { |
| 28 | CREATE TABLE test ( obj, t1, t2, PRIMARY KEY(obj, t1, t2) ); |
| 29 | |
| 30 | CREATE TRIGGER test_insert BEFORE INSERT ON test BEGIN |
| 31 | UPDATE test SET t1 = new.t1 |
| 32 | WHERE obj = new.obj AND new.t1 < t1 AND new.t2 >= t1; |
| 33 | |
| 34 | UPDATE test SET t2 = new.t2 |
| 35 | WHERE obj = new.obj AND new.t2 > t2 AND new.t1 <= t2; |
| 36 | |
| 37 | SELECT RAISE(IGNORE) WHERE EXISTS ( |
| 38 | SELECT obj FROM test |
| 39 | WHERE obj = new.obj AND new.t1 >= t1 AND new.t2 <= t2 |
| 40 | ); |
| 41 | END; |
| 42 | } |
| 43 | } {} |
| 44 | |
| 45 | do_test tkt3544-1.2 { |
| 46 | execsql { |
| 47 | INSERT INTO test VALUES('a', 10000, 11000); |
| 48 | SELECT * FROM test; |
| 49 | } |
| 50 | } {a 10000 11000} |
| 51 | |
| 52 | |
| 53 | do_test tkt3544-1.3 { |
| 54 | execsql { |
| 55 | INSERT INTO test VALUES('a', 9000, 10500); |
| 56 | } |
| 57 | execsql { SELECT * FROM test } |
| 58 | } {a 9000 11000} |
| 59 | |
| 60 | do_test tkt3544-1.4 { |
| 61 | execsql { |
| 62 | INSERT INTO test VALUES('a', 10000, 12000); |
| 63 | } |
| 64 | execsql { SELECT * FROM test } |
| 65 | } {a 9000 12000} |
| 66 | |
| 67 | finish_test |