1
0

tkt2767.test 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # 2007 Oct 3
  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 #2767 has been fixed.
  13. # Ticket #2767 is for a VDBE stack overflow on BEFORE
  14. # triggers that run RAISE(IGNORE).
  15. #
  16. # $Id: tkt2767.test,v 1.3 2009/04/07 14:14:23 danielk1977 Exp $
  17. #
  18. set testdir [file dirname $argv0]
  19. source $testdir/tester.tcl
  20. ifcapable !trigger { finish_test ; return }
  21. do_test tkt2767-1.1 {
  22. execsql {
  23. -- Construct a table with many rows of data
  24. CREATE TABLE t1(x);
  25. INSERT INTO t1 VALUES(1);
  26. INSERT INTO t1 VALUES(2);
  27. INSERT INTO t1 SELECT x+2 FROM t1;
  28. INSERT INTO t1 SELECT x+4 FROM t1;
  29. INSERT INTO t1 SELECT x+8 FROM t1;
  30. INSERT INTO t1 SELECT x+16 FROM t1;
  31. -- BEFORE triggers that invoke raise(ignore). The effect of
  32. -- these triggers should be to make INSERTs, UPDATEs, and DELETEs
  33. -- into no-ops.
  34. CREATE TRIGGER r1 BEFORE UPDATE ON t1 BEGIN
  35. SELECT raise(ignore);
  36. END;
  37. CREATE TRIGGER r2 BEFORE DELETE ON t1 BEGIN
  38. SELECT raise(ignore);
  39. END;
  40. CREATE TRIGGER r3 BEFORE INSERT ON t1 BEGIN
  41. SELECT raise(ignore);
  42. END;
  43. -- Verify the table content
  44. SELECT count(*), sum(x) FROM t1;
  45. }
  46. } {32 528}
  47. # Try to delete all elements of the table. This will invoke the
  48. # DELETE trigger 32 times, which should overflow the VDBE stack if
  49. # the problem of #2767 is not fixed. If the problem is fixed, all
  50. # the deletes should be no-ops so the table should remain unchanged.
  51. #
  52. do_test tkt2767-1.2 {
  53. execsql {
  54. DELETE FROM t1 WHERE x>0;
  55. SELECT count(*), sum(x) FROM t1;
  56. }
  57. } {32 528}
  58. # Try to update all elements of the table. This will invoke the
  59. # UPDATE trigger 32 times, which should overflow the VDBE stack if
  60. # the problem of #2767 is not fixed. If the problem is fixed, all
  61. # the updates should be no-ops so the table should remain unchanged.
  62. #
  63. do_test tkt2767-1.3 {
  64. execsql {
  65. UPDATE t1 SET x=x+1;
  66. SELECT count(*), sum(x) FROM t1;
  67. }
  68. } {32 528}
  69. # Invoke the insert trigger. The insert trigger was working
  70. # even prior to the fix of #2767. But it seems good to go ahead
  71. # and verify that it works.
  72. #
  73. do_test tkt2767-1.4 {
  74. execsql {
  75. INSERT INTO t1 SELECT x+32 FROM t1;
  76. SELECT count(*), sum(x) FROM t1;
  77. }
  78. } {32 528}
  79. finish_test