Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-42380

Assertion in Field::move_field_offset() on multi-table UPDATE of a table with a BEFORE UPDATE trigger

    XMLWordPrintable

Details

    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.

      Attachments

        Activity

          People

            rennox Juan René Ramírez Monarrez
            rennox Juan René Ramírez Monarrez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.