Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
13.1.1
-
None
-
None
Description
A multi-table UPDATE that writes its changes to a temporary table fails an assertion when the updated table has a BEFORE UPDATE trigger.
How to repeat:
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, name VARCHAR(255) NOT NULL, |
flag TINYINT NOT NULL DEFAULT 0); |
CREATE TRIGGER t1bu BEFORE UPDATE ON t1 FOR EACH ROW SET @x= OLD.name; |
INSERT t1 VALUES (1, 'a', 7), (2, 'b', 0); |
UPDATE t1 n JOIN t1 o ON o.id = 1 SET n.name= o.name, n.flag= o.flag |
WHERE n.id = 2; |
Result (debug build):
Assertion in Field::move_field_offset() (field.h): ptr - null_ptr <= rec_buff_length
|
Release builds read memory past default_values instead.
Cause:
For a table with BEFORE INSERT or BEFORE UPDATE triggers, the fields an UPDATE sets are the triggers' copies of the NOT NULL fields (Table_triggers_list::record0_field). Their null bit is in extra_null_bitmap, outside the record.
multi_update::initialize_tables() builds its temporary table from these fields. Create_tmp_table::finalize() then reads each field's default value by moving the field from record[0] to default_values, null pointer included. The null pointer then points outside any record.