1 ################################################################################ 
    2 # inc/partition_trigg3.inc                                                     # 
    5 #   Auxiliary script, only useful when sourced by inc/partition_check.inc.     # 
    6 #   The trigger uses new values (--> event UPDATE, INSERT only)                # 
    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                                                  # 
   13 #------------------------------------------------------------------------------# 
   14 # Original Author: mleich                                                      # 
   15 # Original Date: 2006-03-05                                                    # 
   19 ################################################################################ 
   22 # Original version of the trigger 
   23 # eval CREATE TRIGGER trg_3 $event ON t1 FOR EACH ROW 
   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; 
   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." 
   38 eval CREATE TRIGGER trg_3 $event ON t1 FOR EACH ROW
 
   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;
 
   46 # Additional statements because of Bug(limitation)#17704 
   48 # Bug#18730 Partitions: NDB, crash on SELECT MIN(<unique column>) 
   49 SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
 
   50 # Additional statements end 
   53 #      Check of preceding statement via Select 
   58 # We insert records around max_row_div2 ! 
   59 eval SELECT 
'# check trigger-$num success: ' AS 
"", COUNT(*) = 3 AS 
"" FROM t1
 
   60 WHERE f_int1 = CAST(f_char1 AS SIGNED INT) + @max_row_div2 + 2
 
   61   AND f_int2 = - CAST(f_char1 AS SIGNED INT) + @max_row_div2 - 1
 
   62   AND f_charbig = 
'####updated per insert trigger####';
 
   66 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
 
   67   AND f_int2 <> CAST(f_char1 AS SIGNED INT)
 
   68   AND f_charbig = 
'####updated per insert trigger####';