mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Bug#13002783 PARTIALLY UNINITIALIZED CASCADE UPDATE VECTOR
In the ON UPDATE CASCADE clause of FOREIGN KEY constraints, the calculated update vector was not fully initialized. This bug was introduced in the InnoDB Plugin when implementing support for ROW_FORMAT=DYNAMIC. Additionally, the data type information was not initialized, but apparently it has never been needed in this case. Nevertheless, it is not good programming practice to pass uninitialized values around. calc_row_difference(): Declare the update field uninitialized in Valgrind. Copy the data type information as well, except when the field is SQL NULL. In the built-in InnoDB, initialize ufield->extern_storage = FALSE (an initialization bug that had gone unnoticed this far). The InnoDB Plugin and later have this flag to dfield_t and have always initialized it properly. row_ins_cascade_calc_update_vec(): Reduce the scope of some pointers. Initialize orig_len. (This caused the bug in InnoDB Plugin and later.) row_ins_foreign_check_on_constraint(): Simplify a condition. Declare the update vector uninitialized. rb:771 approved by Jimmy Yang
This commit is contained in:
@ -1040,6 +1040,24 @@ update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id
|
||||
update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
|
||||
drop table t3,t2,t1;
|
||||
|
||||
# test ON UPDATE CASCADE
|
||||
CREATE TABLE t1 (
|
||||
c1 VARCHAR(8), c2 VARCHAR(8),
|
||||
PRIMARY KEY (c1, c2)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE t2 (
|
||||
c0 INT PRIMARY KEY,
|
||||
c1 VARCHAR(8) UNIQUE,
|
||||
FOREIGN KEY (c1) REFERENCES t1 (c1) ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
INSERT INTO t1 VALUES ('old', 'somevalu'), ('other', 'anyvalue');
|
||||
INSERT INTO t2 VALUES (10, 'old'), (20, 'other');
|
||||
-- error ER_FOREIGN_DUPLICATE_KEY
|
||||
UPDATE t1 SET c1 = 'other' WHERE c1 = 'old';
|
||||
DROP TABLE t2,t1;
|
||||
|
||||
#
|
||||
# test for recursion depth limit
|
||||
#
|
||||
|
Reference in New Issue
Block a user