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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
# ==== Purpose ====
#
# Test that non-deterministic expressions in column default expressions invoked
# via triggers, are correctly logged with BINLOG_FORMAT=MIXED.
#
# ==== Requirements ====
#
# R1. If a statement triggers another statement which may modify a table that
# has a column with a non-deterministic DEFAULT expression, the statement
# should be logged in ROW format when BINLOG_FORMAT is MIXED.
#
# R2. If none of the triggered statements modifies a table that has a
# non-deterministic DEFAULT expression, and the triggering statement is not
# unsafe by itself, the statement should be logged in STATEMENT format when
# BINLOG_FORMAT is MIXED.
#
# R3. If a statement directly modifies a table with a column that has a
# non-deterministic DEFAULT expression, and the statement provides an
# explicit value for the column, the statement should be logged in
# STATEMENT format when BINLOG_FORMAT is MIXED.
#
# ==== Implementation ====
#
# Test firing triggers which modify tables with non-deterministic column
# defaults, and verify that they are logged in the row format.
#
# ==== References ====
#
# WL#9418: Permit default value to be a function or expression, support for LOBs
# Bug#28297486: WL#9418: ERROR AND WARNING RELATED ISSUES
#
--source include/have_binlog_format_mixed.inc
RESET MASTER;
CREATE TABLE t1 (a DOUBLE DEFAULT (PI()),
b DOUBLE DEFAULT (RAND()));
CREATE TABLE t2 (x INT);
CREATE TABLE t3 (y DOUBLE DEFAULT (PI()));
--echo # Test R1.
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Table_map # Write_rows # Write_rows # Xid
CREATE TRIGGER t2_trigger AFTER INSERT ON t2
FOR EACH ROW INSERT INTO t1 VALUES ();
--source include/save_binlog_position.inc
INSERT INTO t2 VALUES ();
--source include/assert_binlog_events.inc
DROP TRIGGER t2_trigger;
CREATE TRIGGER t2_trigger AFTER INSERT ON t2
FOR EACH ROW INSERT INTO t1(a) VALUES (1);
--source include/save_binlog_position.inc
INSERT INTO t2 VALUES ();
--source include/assert_binlog_events.inc
DROP TRIGGER t2_trigger;
CREATE TRIGGER t2_trigger AFTER INSERT ON t2
FOR EACH ROW INSERT INTO t1(b) VALUES (DEFAULT);
--source include/save_binlog_position.inc
INSERT INTO t2 VALUES ();
--source include/assert_binlog_events.inc
DROP TRIGGER t2_trigger;
CREATE TRIGGER t2_trigger AFTER INSERT ON t2
FOR EACH ROW INSERT INTO t1(b) VALUES (1);
--source include/save_binlog_position.inc
INSERT INTO t2 VALUES ();
--source include/assert_binlog_events.inc
DROP TRIGGER t2_trigger;
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Table_map # Write_rows # Update_rows # Xid
CREATE TRIGGER t2_trigger AFTER INSERT ON t2
FOR EACH ROW UPDATE t1 SET a = DEFAULT;
--source include/save_binlog_position.inc
INSERT INTO t2 VALUES ();
--source include/assert_binlog_events.inc
DROP TRIGGER t2_trigger;
CREATE TRIGGER t2_trigger AFTER INSERT ON t2
FOR EACH ROW UPDATE t1 SET b = DEFAULT;
--source include/save_binlog_position.inc
INSERT INTO t2 VALUES ();
--source include/assert_binlog_events.inc
DROP TRIGGER t2_trigger;
--echo # Test R2.
CREATE TRIGGER t2_trigger AFTER INSERT ON t2
FOR EACH ROW INSERT INTO t3 VALUES ();
# Logged in STATEMENT format, since the triggered statement does not touch a
# table with any non-deterministic DEFAULT expressions.
--source include/save_binlog_position.inc
INSERT INTO t2 VALUES ();
--let $event_sequence = !Gtid_or_anon # !Begin # Query # Xid
--source include/assert_binlog_events.inc
DROP TRIGGER t2_trigger;
--echo # Test R3.
# Logged in ROW format when the DEFAULT expression is used.
--source include/save_binlog_position.inc
INSERT INTO t1 VALUES ();
--let $event_sequence = !Gtid_or_anon # !Begin # Table_map # Write_rows # Xid
--source include/assert_binlog_events.inc
--source include/save_binlog_position.inc
INSERT INTO t1 (b) VALUES (DEFAULT);
--source include/assert_binlog_events.inc
# Logged in STATEMENT format when the DEFAULT expression is not used.
--source include/save_binlog_position.inc
INSERT INTO t1 (b) VALUES (1);
--let $event_sequence = !Gtid_or_anon # !Begin # Query # Xid
--source include/assert_binlog_events.inc
# Clean up
DROP TABLE t1, t2, t3;
|