summaryrefslogtreecommitdiff
path: root/mysql-test/r/ndb_trigger.result
diff options
context:
space:
mode:
authorunknown <mskold/marty@mysql.com/linux.site>2007-04-04 12:50:39 +0200
committerunknown <mskold/marty@mysql.com/linux.site>2007-04-04 12:50:39 +0200
commit2efc0f51cf3e80cd49c1ea0dee9a440936ee6287 (patch)
tree3330e0cd8c3d7c512db5cc6a3e6df4d4240eaed8 /mysql-test/r/ndb_trigger.result
parentef60c96f8bb7c8ab0c044750b39f56f1eb1953ea (diff)
downloadmariadb-git-2efc0f51cf3e80cd49c1ea0dee9a440936ee6287.tar.gz
Bug #26242 UPDATE with subquery and triggers failing with cluster tables
In certain cases AFTER UPDATE/DELETE triggers on NDB tables that referenced subject table didn't see the results of operation which caused invocation of those triggers. In other words AFTER trigger invoked as result of update (or deletion) of particular row saw version of this row before update (or deletion). The problem occured because NDB handler in those cases postponed actual update/delete operations to be able to perform them later as one batch. This fix solves the problem by disabling this optimization for particular operation if subject table has AFTER trigger for this operation defined. To achieve this we introduce two new flags for handler::extra() method: HA_EXTRA_DELETE_CANNOT_BATCH and HA_EXTRA_UPDATE_CANNOT_BATCH. These are called if there exists AFTER DELETE/UPDATE triggers during a statement that potentially can generate calls to delete_row()/update_row(). This includes multi_delete/multi_update statements as well as insert statements that do delete/update as part of an ON DUPLICATE statement. include/my_base.h: Added HA_EXTRA_DELETE_CANNOT_BATCH and HA_EXTRA_UPDATE_CANNOT_BATCH to inform handler when batching of delete/update is not possible. mysql-test/r/ndb_trigger.result: Bug #26242 UPDATE with subquery and triggers failing with cluster tables --- Added new test cases mysql-test/t/ndb_trigger.test: Bug #26242 UPDATE with subquery and triggers failing with cluster tables --- Added new test cases sql/ha_ndbcluster.cc: Bug #26242 UPDATE with subquery and triggers failing with cluster tables: Use HA_EXTRA_DELETE_CANNOT_BATCH and HA_EXTRA_UPDATE_CANNOT_BATCH to inform handler when batching of delete/update is not possible sql/ha_ndbcluster.h: Bug #26242 UPDATE with subquery and triggers failing with cluster tables: Added member variables for handling of HA_EXTRA_DELETE_CANNOT_BATCH and HA_EXTRA_UPDATE_CANNOT_BATCH to inform handler when batching of delete/update is not possible sql/mysql_priv.h: Added new method prepare_triggers_for_insert_stmt to check if batching of delete/update must be disallowed. sql/sql_delete.cc: Use HA_EXTRA_DELETE_CANNOT_BATCH to inform handler when batching of delete is not possible sql/sql_insert.cc: Added method prepare_triggers_for_insert_stmt to check if batching of delete/update must be dissallowed. Use HA_EXTRA_DELETE_CANNOT_BATCH and HA_EXTRA_UPDATE_CANNOT_BATCH to inform handler when batching of delete/update is not possible sql/sql_load.cc: Call prepare_triggers_for_insert_stmt to check if batching of delete/update must be dissallowed and mark fields used by triggers for the insert statement. sql/sql_trigger.h: Added has_triggers to support what particular triggers exist on a table. sql/sql_update.cc: Use HA_EXTRA_UPDATE_CANNOT_BATCH to inform handler when batching of update is not possible
Diffstat (limited to 'mysql-test/r/ndb_trigger.result')
-rw-r--r--mysql-test/r/ndb_trigger.result171
1 files changed, 171 insertions, 0 deletions
diff --git a/mysql-test/r/ndb_trigger.result b/mysql-test/r/ndb_trigger.result
index 27f83df70c9..562c5120715 100644
--- a/mysql-test/r/ndb_trigger.result
+++ b/mysql-test/r/ndb_trigger.result
@@ -116,4 +116,175 @@ op a b
d 1 1.050000000000000000000000000000
d 2 2.050000000000000000000000000000
drop tables t1, t2, t3;
+CREATE TABLE t1 (
+id INT NOT NULL PRIMARY KEY,
+xy INT
+) ENGINE=ndbcluster;
+INSERT INTO t1 VALUES (1, 0);
+CREATE TRIGGER t1_update AFTER UPDATE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id = NEW.id; END //
+CREATE TABLE t2 (
+id INT NOT NULL PRIMARY KEY,
+xy INT
+) ENGINE=ndbcluster;
+INSERT INTO t2 VALUES (2, 0);
+CREATE TABLE t3 (id INT NOT NULL PRIMARY KEY) ENGINE=ndbcluster;
+INSERT INTO t3 VALUES (1);
+CREATE TABLE t4 LIKE t1;
+CREATE TRIGGER t4_update AFTER UPDATE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id = NEW.id; END //
+CREATE TABLE t5 LIKE t2;
+UPDATE t1 SET xy = 3 WHERE id = 1;
+SELECT xy FROM t1 where id = 1;
+xy
+3
+SELECT xy FROM t2 where id = 1;
+xy
+3
+UPDATE t1 SET xy = 4 WHERE id IN (SELECT id FROM t3 WHERE id = 1);
+SELECT xy FROM t1 where id = 1;
+xy
+4
+SELECT xy FROM t2 where id = 1;
+xy
+4
+INSERT INTO t4 SELECT * FROM t1;
+INSERT INTO t5 SELECT * FROM t2;
+UPDATE t1,t4 SET t1.xy = 3, t4.xy = 3 WHERE t1.id = 1 AND t4.id = 1;
+SELECT xy FROM t1 where id = 1;
+xy
+3
+SELECT xy FROM t2 where id = 1;
+xy
+3
+SELECT xy FROM t4 where id = 1;
+xy
+3
+SELECT xy FROM t5 where id = 1;
+xy
+3
+UPDATE t1,t4 SET t1.xy = 4, t4.xy = 4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 1) AND t4.id IN (SELECT id FROM t3 WHERE id = 1);
+SELECT xy FROM t1 where id = 1;
+xy
+4
+SELECT xy FROM t2 where id = 1;
+xy
+4
+SELECT xy FROM t4 where id = 1;
+xy
+4
+SELECT xy FROM t5 where id = 1;
+xy
+4
+INSERT INTO t1 VALUES (1,0) ON DUPLICATE KEY UPDATE xy = 5;
+SELECT xy FROM t1 where id = 1;
+xy
+5
+SELECT xy FROM t2 where id = 1;
+xy
+5
+DROP TRIGGER t1_update;
+DROP TRIGGER t4_update;
+CREATE TRIGGER t1_delete AFTER DELETE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id > 4; END //
+CREATE TRIGGER t4_delete AFTER DELETE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id > 4; END //
+INSERT INTO t1 VALUES (5, 0),(6,0);
+INSERT INTO t2 VALUES (5, 1),(6,1);
+INSERT INTO t3 VALUES (5);
+SELECT * FROM t1 order by id;
+id xy
+1 5
+5 0
+6 0
+SELECT * FROM t2 order by id;
+id xy
+1 5
+2 0
+5 1
+6 1
+DELETE FROM t1 WHERE id IN (SELECT id FROM t3 WHERE id = 5);
+SELECT * FROM t1 order by id;
+id xy
+1 5
+6 0
+SELECT * FROM t2 order by id;
+id xy
+1 5
+2 0
+5 1
+6 0
+INSERT INTO t1 VALUES (5,0);
+UPDATE t2 SET xy = 1 WHERE id = 6;
+TRUNCATE t4;
+INSERT INTO t4 SELECT * FROM t1;
+TRUNCATE t5;
+INSERT INTO t5 SELECT * FROM t2;
+SELECT * FROM t1 order by id;
+id xy
+1 5
+5 0
+6 0
+SELECT * FROM t2 order by id;
+id xy
+1 5
+2 0
+5 1
+6 1
+SELECT * FROM t4 order by id;
+id xy
+1 5
+5 0
+6 0
+SELECT * FROM t5 order by id;
+id xy
+1 5
+2 0
+5 1
+6 1
+DELETE FROM t1,t4 USING t1,t3,t4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 5) AND t4.id IN (SELECT id FROM t3 WHERE id = 5);
+SELECT * FROM t1 order by id;
+id xy
+1 5
+6 0
+SELECT * FROM t2 order by id;
+id xy
+1 5
+2 0
+5 1
+6 0
+SELECT * FROM t4 order by id;
+id xy
+1 5
+6 0
+SELECT * FROM t5 order by id;
+id xy
+1 5
+2 0
+5 1
+6 0
+INSERT INTO t1 VALUES (5, 0);
+REPLACE INTO t2 VALUES (6,1);
+SELECT * FROM t1 order by id;
+id xy
+1 5
+5 0
+6 0
+SELECT * FROM t2 order by id;
+id xy
+1 5
+2 0
+5 1
+6 1
+REPLACE INTO t1 VALUES (5, 1);
+SELECT * FROM t1 order by id;
+id xy
+1 5
+5 1
+6 0
+SELECT * FROM t2 order by id;
+id xy
+1 5
+2 0
+5 1
+6 0
+DROP TRIGGER t1_delete;
+DROP TRIGGER t4_delete;
+DROP TABLE t1, t2, t3, t4, t5;
End of 5.0 tests