drh | 187e4c6 | 2006-02-27 22:22:27 +0000 | [diff] [blame] | 1 | # 2006 February 27 |
| 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 make sure abusively large triggers |
| 14 | # (triggers with 100s or 1000s of statements) work. |
| 15 | # |
danielk1977 | 89bae3e | 2008-09-17 16:14:10 +0000 | [diff] [blame] | 16 | # $Id: trigger8.test,v 1.2 2008/09/17 16:14:10 danielk1977 Exp $ |
drh | 187e4c6 | 2006-02-27 22:22:27 +0000 | [diff] [blame] | 17 | |
| 18 | set testdir [file dirname $argv0] |
| 19 | source $testdir/tester.tcl |
| 20 | ifcapable {!trigger} { |
| 21 | finish_test |
| 22 | return |
| 23 | } |
| 24 | |
danielk1977 | 89bae3e | 2008-09-17 16:14:10 +0000 | [diff] [blame] | 25 | # Set variable $nStatement to the number of statements to include in the |
| 26 | # body of the trigger. On a workstation with virtually unlimited memory, |
| 27 | # use 10000. But on symbian, which allows each application at most a 32MB |
| 28 | # heap, use 1000. |
| 29 | # |
| 30 | set nStatement 10000 |
| 31 | if {$tcl_platform(platform) == "symbian"} { |
| 32 | set nStatement 1000 |
| 33 | } |
drh | 187e4c6 | 2006-02-27 22:22:27 +0000 | [diff] [blame] | 34 | |
dan | 165921a | 2009-08-28 18:53:45 +0000 | [diff] [blame] | 35 | set nStatement 5 |
drh | 187e4c6 | 2006-02-27 22:22:27 +0000 | [diff] [blame] | 36 | do_test trigger8-1.1 { |
| 37 | execsql { |
| 38 | CREATE TABLE t1(x); |
| 39 | CREATE TABLE t2(y); |
| 40 | } |
danielk1977 | 89bae3e | 2008-09-17 16:14:10 +0000 | [diff] [blame] | 41 | set sql "CREATE TRIGGER r${nStatement} AFTER INSERT ON t1 BEGIN\n" |
| 42 | for {set i 0} {$i<$nStatement} {incr i} { |
drh | 187e4c6 | 2006-02-27 22:22:27 +0000 | [diff] [blame] | 43 | append sql " INSERT INTO t2 VALUES($i);\n" |
| 44 | } |
| 45 | append sql "END;" |
| 46 | execsql $sql |
| 47 | execsql { |
| 48 | INSERT INTO t1 VALUES(5); |
| 49 | SELECT count(*) FROM t2; |
| 50 | } |
danielk1977 | 89bae3e | 2008-09-17 16:14:10 +0000 | [diff] [blame] | 51 | } $nStatement |
drh | 187e4c6 | 2006-02-27 22:22:27 +0000 | [diff] [blame] | 52 | |
| 53 | finish_test |