tkt2832.test 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # 2007 Dec 12
  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. #
  12. # This file is to test that ticket #2832 has been fixed.
  13. #
  14. # $Id: tkt2832.test,v 1.5 2009/04/07 14:14:23 danielk1977 Exp $
  15. #
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. ifcapable !trigger { finish_test ; return }
  19. do_test tkt2832-1.1 {
  20. execsql {
  21. CREATE TABLE t1(a PRIMARY KEY);
  22. INSERT INTO t1 VALUES(2);
  23. INSERT INTO t1 VALUES(1);
  24. INSERT INTO t1 VALUES(3);
  25. }
  26. } {}
  27. do_test tkt2832-1.2 {
  28. execsql {
  29. UPDATE OR REPLACE t1 SET a = 1;
  30. SELECT * FROM t1;
  31. }
  32. } {1}
  33. do_test tkt2832-2.1 {
  34. execsql {
  35. CREATE TABLE t2(a, b);
  36. CREATE TRIGGER t2_t AFTER UPDATE ON t2 BEGIN
  37. DELETE FROM t2 WHERE a = new.a + 1;
  38. END;
  39. INSERT INTO t2 VALUES(1, 2);
  40. INSERT INTO t2 VALUES(2, 3);
  41. }
  42. } {}
  43. do_test tkt2832-2.2 {
  44. execsql {
  45. UPDATE t2 SET b = 5
  46. }
  47. } {}
  48. do_test tkt2832-3.1 {
  49. execsql {
  50. CREATE TABLE t3(a, b);
  51. CREATE TRIGGER t3_t AFTER DELETE ON t3 BEGIN
  52. DELETE FROM t3 WHERE a = old.a + 1;
  53. END;
  54. INSERT INTO t3 VALUES(1, 2);
  55. INSERT INTO t3 VALUES(2, 3);
  56. }
  57. } {}
  58. do_test tkt2832-3.2 {
  59. execsql { DELETE FROM t3 WHERE 1 }
  60. } {}
  61. finish_test