mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / t / multi_update2.test
bloba04518f49640333b56b69fb4ca5606b6c10b75f7
2 # Test of update statement that uses many tables.
6 # If we are running with
7 # - Valgrind           -> $VALGRIND_TEST <> 0
8 # - debug tracing      -> @@session.debug LIKE '%trace%'
9 # the resource consumption (storage space needed, runtime) will be extreme.
10 # Therefore we require that the option "--big-test" is also set.
13 let $need_big= 0;
14 --disable_query_log
15 --error 0,ER_UNKNOWN_SYSTEM_VARIABLE
16 SET @aux = @@session.debug;
17 if (!$mysql_errno)
19   # We have returncode 0 = the server system variable @@session.debug exists.
20   # But we only need "--big-test" in case of tracing.
21   if (`SELECT @@session.debug LIKE '%trace%'`)
22   {
23     let $need_big= 1;
24   }
26 --enable_query_log
27 if ($VALGRIND_TEST)
29   # We are running with Valgrind
30   inc $need_big;
32 if (`SELECT '$BIG_TEST' = '' AND $need_big = 1`)
34   --skip Need "--big-test" when running with the option "--debug" or "--valgrind"
38 # Bug#1820 Rows not deleted from second table on multi-table delete
41 --disable_warnings
42 DROP TABLE IF EXISTS t1,t2;
43 --enable_warnings
45 CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL) ;
46 --echo # The protocolling of many inserts into t1 is suppressed.
47 --disable_query_log
48 INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4);
49 let $1=19;
50 set @d=4;
51 while ($1)
53   eval INSERT INTO t1 SELECT a+@d,b+@d FROM t1;
54   eval SET @d=@d*2;
55   dec $1;
58 --enable_query_log
59 ALTER TABLE t1 ADD INDEX i1(a);
60 DELETE FROM t1 WHERE a > 2000000;
61 CREATE TABLE t2 LIKE t1;
62 INSERT INTO t2 SELECT * FROM t1;
64 SELECT 't2 rows before small delete', COUNT(*) FROM t1;
65 DELETE t1,t2 FROM t1,t2 WHERE t1.b=t2.a AND t1.a < 2;
66 SELECT 't2 rows after small delete', COUNT(*) FROM t2;
67 SELECT 't1 rows after small delete', COUNT(*) FROM t1;
69 ## Try deleting many rows 
71 DELETE t1,t2 FROM t1,t2 WHERE t1.b=t2.a AND t1.a < 100*1000;
72 SELECT 't2 rows after big delete', COUNT(*) FROM t2;
73 SELECT 't1 rows after big delete', COUNT(*) FROM t1;
75 DROP TABLE t1,t2;