Skip to content

Commit e208f91

Browse files
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)));
1 parent c7a2fb1 commit e208f91

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

mysql-test/main/long_unique_bugs.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,10 @@ ERROR 42000: Specified key was too long; max key length is 1000 bytes
270270
create table t1(a int, unique(a) using hash);
271271
#BULK insert > 100 rows (MI_MIN_ROWS_TO_DISABLE_INDEXES)
272272
drop table t1;
273+
SET binlog_row_image= NOBLOB;
274+
CREATE TABLE t1 (pk INT PRIMARY KEY, a text ,UNIQUE(a) using hash);
275+
INSERT INTO t1 VALUES (1,'foo');
276+
create table t2(id int primary key, a blob, b varchar(20) as (LEFT(a,2)));
277+
INSERT INTO t2 VALUES (1, 'foo', default);
278+
DROP TABLE t1, t2;
279+
SET binlog_row_image= FULL;

mysql-test/main/long_unique_bugs.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,19 @@ while ($count)
340340
--eval $insert_stmt
341341
--enable_query_log
342342
drop table t1;
343+
344+
#
345+
# MDEV-21804 Assertion `marked_for_read()' failed upon INSERT into table with long unique blob under binlog_row_image=NOBLOB
346+
#
347+
348+
--source include/have_binlog_format_row.inc
349+
SET binlog_row_image= NOBLOB;
350+
CREATE TABLE t1 (pk INT PRIMARY KEY, a text ,UNIQUE(a) using hash);
351+
INSERT INTO t1 VALUES (1,'foo');
352+
353+
create table t2(id int primary key, a blob, b varchar(20) as (LEFT(a,2)));
354+
INSERT INTO t2 VALUES (1, 'foo', default);
355+
356+
# Cleanup
357+
DROP TABLE t1, t2;
358+
SET binlog_row_image= FULL;

sql/table.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7039,7 +7039,6 @@ void TABLE::mark_columns_needed_for_update()
70397039
DBUG_ENTER("TABLE::mark_columns_needed_for_update");
70407040
bool need_signal= false;
70417041

7042-
mark_columns_per_binlog_row_image();
70437042

70447043
if (triggers)
70457044
triggers->mark_fields_used(TRG_EVENT_UPDATE);
@@ -7115,6 +7114,7 @@ void TABLE::mark_columns_needed_for_update()
71157114
bitmap_union(read_set, write_set);
71167115
need_signal= true;
71177116
}
7117+
mark_columns_per_binlog_row_image();
71187118
if (need_signal)
71197119
file->column_bitmaps_signal();
71207120
DBUG_VOID_RETURN;
@@ -7131,7 +7131,6 @@ void TABLE::mark_columns_needed_for_update()
71317131
void TABLE::mark_columns_needed_for_insert()
71327132
{
71337133
DBUG_ENTER("mark_columns_needed_for_insert");
7134-
mark_columns_per_binlog_row_image();
71357134

71367135
if (triggers)
71377136
{
@@ -7151,6 +7150,7 @@ void TABLE::mark_columns_needed_for_insert()
71517150
/* Mark virtual columns for insert */
71527151
if (vfield)
71537152
mark_virtual_columns_for_write(TRUE);
7153+
mark_columns_per_binlog_row_image();
71547154
if (check_constraints)
71557155
mark_check_constraint_columns_for_read();
71567156
DBUG_VOID_RETURN;

0 commit comments

Comments
 (0)