tkt3554.test 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #
  16. # $Id: tkt3554.test,v 1.2 2009/06/05 17:09:12 drh Exp $
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. ifcapable !trigger {
  20. finish_test
  21. return
  22. }
  23. do_test tkt3544-1.1 {
  24. execsql {
  25. CREATE TABLE test ( obj, t1, t2, PRIMARY KEY(obj, t1, t2) );
  26. CREATE TRIGGER test_insert BEFORE INSERT ON test BEGIN
  27. UPDATE test SET t1 = new.t1
  28. WHERE obj = new.obj AND new.t1 < t1 AND new.t2 >= t1;
  29. UPDATE test SET t2 = new.t2
  30. WHERE obj = new.obj AND new.t2 > t2 AND new.t1 <= t2;
  31. SELECT RAISE(IGNORE) WHERE EXISTS (
  32. SELECT obj FROM test
  33. WHERE obj = new.obj AND new.t1 >= t1 AND new.t2 <= t2
  34. );
  35. END;
  36. }
  37. } {}
  38. do_test tkt3544-1.2 {
  39. execsql {
  40. INSERT INTO test VALUES('a', 10000, 11000);
  41. SELECT * FROM test;
  42. }
  43. } {a 10000 11000}
  44. do_test tkt3544-1.3 {
  45. execsql {
  46. INSERT INTO test VALUES('a', 9000, 10500);
  47. }
  48. execsql { SELECT * FROM test }
  49. } {a 9000 11000}
  50. do_test tkt3544-1.4 {
  51. execsql {
  52. INSERT INTO test VALUES('a', 10000, 12000);
  53. }
  54. execsql { SELECT * FROM test }
  55. } {a 9000 12000}
  56. finish_test