Debian Codegraph @

mysql-test/suite/parts/inc/partition_trigg3.inc

raw
1 ################################################################################
2 # inc/partition_trigg3.inc #
3 # #
4 # Purpose: #
5 # Auxiliary script, only useful when sourced by inc/partition_check.inc. #
6 # The trigger uses new values (--> event UPDATE, INSERT only) #
7 # #
8 # 1. Create a trigger #
9 # 2. Execute a statement, which activates the trigger #
10 # 3. Check the results of the trigger activity #
11 # 4. Revert the modifications #
12 # #
13 #------------------------------------------------------------------------------#
14 # Original Author: mleich #
15 # Original Date: 2006-03-05 #
16 # Change Author: #
17 # Change Date: #
18 # Change: #
19 ################################################################################
20
21 delimiter |;
22 # Original version of the trigger
23 # eval CREATE TRIGGER trg_3 $event ON t1 FOR EACH ROW
24 # BEGIN
25 # SET @counter = 1;
26 # SET @my_max1 = 0, @my_max2 = 0;
27 # SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
28 # SET new.f_int1 = @my_max1 + @counter,
29 # new.f_int2 = @my_min2 - @counter,
30 # new.f_charbig = '####updated per insert trigger####';
31 # SET @counter = @counter + 1;
32 # END|
33 #
34 # Bug/currently undocumented limitation:
35 # 17704: Triggers: MAX, Insert select with several rows, strange error
36 # "A trigger can not access (not even read data) the table it's defined for."
37 #
38 eval CREATE TRIGGER trg_3 $event ON t1 FOR EACH ROW
39 BEGIN
40 SET new.f_int1 = @my_max1 + @counter,
41 new.f_int2 = @my_min2 - @counter,
42 new.f_charbig = '####updated per insert trigger####';
43 SET @counter = @counter + 1;
44 END|
45 delimiter ;|
46 # Additional statements because of Bug(limitation)#17704
47 SET @counter = 1;
48 # Bug#18730 Partitions: crash on SELECT MIN(<unique column>)
49 --disable_cursor_protocol
50 SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
51 --enable_cursor_protocol
52 # Additional statements end
53 eval $statement;
54 DROP TRIGGER trg_3;
55 # Check of preceding statement via Select
56 if ($no_debug)
57 {
58 --disable_query_log
59 }
60 # We insert records around max_row_div2 !
61 eval SELECT '# check trigger-$num success: ' AS "", COUNT(*) = 3 AS "" FROM t1
62 WHERE f_int1 = CAST(f_char1 AS SIGNED INT) + @max_row_div2 + 2
63 AND f_int2 = - CAST(f_char1 AS SIGNED INT) + @max_row_div2 - 1
64 AND f_charbig = '####updated per insert trigger####';
65 --enable_query_log
66 # Revert the changes
67 eval DELETE FROM t1
68 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
69 AND f_int2 <> CAST(f_char1 AS SIGNED INT)
70 AND f_charbig = '####updated per insert trigger####';
71 inc $num;