File: partition_trigg3.inc

package info (click to toggle)
mariadb-10.1 10.1.45-0%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 476,916 kB
  • sloc: cpp: 1,124,656; ansic: 871,843; perl: 52,917; sh: 40,078; pascal: 35,370; javascript: 15,555; yacc: 14,728; ruby: 8,684; xml: 5,377; sql: 3,490; makefile: 2,934; python: 1,970; java: 1,691; asm: 837; lex: 757; php: 22; sed: 16
file content (69 lines) | stat: -rw-r--r-- 3,290 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
################################################################################
# inc/partition_trigg3.inc                                                     #
#                                                                              #
# Purpose:                                                                     #
#   Auxiliary script, only useful when sourced by inc/partition_check.inc.     #
#   The trigger uses new values (--> event UPDATE, INSERT only)                #
#                                                                              #
# 1. Create a trigger                                                          #
# 2. Execute a statement, which activates the trigger                          #
# 3. Check the results of the trigger activity                                 #
# 4. Revert the modifications                                                  #
#                                                                              #
#------------------------------------------------------------------------------#
# Original Author: mleich                                                      #
# Original Date: 2006-03-05                                                    #
# Change Author:                                                               #
# Change Date:                                                                 #
# Change:                                                                      #
################################################################################

delimiter |;
# Original version of the trigger
# eval CREATE TRIGGER trg_3 $event ON t1 FOR EACH ROW
# BEGIN
#    SET @counter = 1;
#    SET @my_max1 = 0, @my_max2 = 0;
#    SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
#    SET new.f_int1 = @my_max1 + @counter,
#        new.f_int2 = @my_min2 - @counter,
#        new.f_charbig = '####updated per insert trigger####';
#    SET @counter = @counter + 1;
# END|
#
# Bug/currently undocumented limitation:
#      17704: Triggers: MAX, Insert select with several rows, strange error
# "A trigger can not access (not even read data) the table it's defined for."
#
eval CREATE TRIGGER trg_3 $event ON t1 FOR EACH ROW
BEGIN
   SET new.f_int1 = @my_max1 + @counter,
       new.f_int2 = @my_min2 - @counter,
       new.f_charbig = '####updated per insert trigger####';
   SET @counter = @counter + 1;
END|
delimiter ;|
# Additional statements because of Bug(limitation)#17704
SET @counter = 1;
# Bug#18730 Partitions: crash on SELECT MIN(<unique column>)
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
# Additional statements end
eval $statement;
DROP TRIGGER trg_3;
#      Check of preceding statement via Select
if ($no_debug)
{
  --disable_query_log
}
# We insert records around max_row_div2 !
eval SELECT '# check trigger-$num success: ' AS "", COUNT(*) = 3 AS "" FROM t1
WHERE f_int1 = CAST(f_char1 AS SIGNED INT) + @max_row_div2 + 2
  AND f_int2 = - CAST(f_char1 AS SIGNED INT) + @max_row_div2 - 1
  AND f_charbig = '####updated per insert trigger####';
--enable_query_log
# Revert the changes
eval DELETE FROM t1
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
  AND f_int2 <> CAST(f_char1 AS SIGNED INT)
  AND f_charbig = '####updated per insert trigger####';
inc $num;