From e208f91ba8e8d674b276d52ba1645e4fef1f974a Mon Sep 17 00:00:00 2001 From: Sachin Date: Mon, 25 May 2020 15:29:44 +0530 Subject: [PATCH] MDEV-21804 Assertion `marked_for_read()' failed upon INSERT into table with long unique blob under binlog_row_image=NOBLOB Problem:- Calling mark_columns_per_binlog_row_image() earlier may change the result of mark_virtual_columns_for_write() , Since it can set the bitmap on for virtual column, and henceforth mark_virtual_column_deps(field) will never be called in mark_virtual_column_with_deps. This bug is not specific for long unique, It also fails for this case create table t2(id int primary key, a blob, b varchar(20) as (LEFT(a,2))); --- mysql-test/main/long_unique_bugs.result | 7 +++++++ mysql-test/main/long_unique_bugs.test | 16 ++++++++++++++++ sql/table.cc | 4 ++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index c0ba4d0b87d..0645de40b59 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -270,3 +270,10 @@ ERROR 42000: Specified key was too long; max key length is 1000 bytes create table t1(a int, unique(a) using hash); #BULK insert > 100 rows (MI_MIN_ROWS_TO_DISABLE_INDEXES) drop table t1; +SET binlog_row_image= NOBLOB; +CREATE TABLE t1 (pk INT PRIMARY KEY, a text ,UNIQUE(a) using hash); +INSERT INTO t1 VALUES (1,'foo'); +create table t2(id int primary key, a blob, b varchar(20) as (LEFT(a,2))); +INSERT INTO t2 VALUES (1, 'foo', default); +DROP TABLE t1, t2; +SET binlog_row_image= FULL; diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 13a4e1367a0..e91c46ca90c 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -340,3 +340,19 @@ while ($count) --eval $insert_stmt --enable_query_log drop table t1; + +# +# MDEV-21804 Assertion `marked_for_read()' failed upon INSERT into table with long unique blob under binlog_row_image=NOBLOB +# + +--source include/have_binlog_format_row.inc +SET binlog_row_image= NOBLOB; +CREATE TABLE t1 (pk INT PRIMARY KEY, a text ,UNIQUE(a) using hash); +INSERT INTO t1 VALUES (1,'foo'); + +create table t2(id int primary key, a blob, b varchar(20) as (LEFT(a,2))); +INSERT INTO t2 VALUES (1, 'foo', default); + +# Cleanup +DROP TABLE t1, t2; +SET binlog_row_image= FULL; diff --git a/sql/table.cc b/sql/table.cc index f58f2428129..648b1794582 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -7039,7 +7039,6 @@ void TABLE::mark_columns_needed_for_update() DBUG_ENTER("TABLE::mark_columns_needed_for_update"); bool need_signal= false; - mark_columns_per_binlog_row_image(); if (triggers) triggers->mark_fields_used(TRG_EVENT_UPDATE); @@ -7115,6 +7114,7 @@ void TABLE::mark_columns_needed_for_update() bitmap_union(read_set, write_set); need_signal= true; } + mark_columns_per_binlog_row_image(); if (need_signal) file->column_bitmaps_signal(); DBUG_VOID_RETURN; @@ -7131,7 +7131,6 @@ void TABLE::mark_columns_needed_for_update() void TABLE::mark_columns_needed_for_insert() { DBUG_ENTER("mark_columns_needed_for_insert"); - mark_columns_per_binlog_row_image(); if (triggers) { @@ -7151,6 +7150,7 @@ void TABLE::mark_columns_needed_for_insert() /* Mark virtual columns for insert */ if (vfield) mark_virtual_columns_for_write(TRUE); + mark_columns_per_binlog_row_image(); if (check_constraints) mark_check_constraint_columns_for_read(); DBUG_VOID_RETURN;