Commit 1619ae89 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-23672: Partly revert an incorrect fix

In commit 7eda5561 we removed a
valid debug assertion.

AddressSanitizer would trip when writing undo log for an INSERT
operation that follows the problematic ALTER TABLE because the
v_indexes would refer to an index object that was freed during
the execution of ALTER TABLE.

The operation to remove NOT NULL attribute from a column should
lead into any affected indexes to be dropped and re-created.
But, the SQL layer set the ha_alter_info->handler_flags to
HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE|ALTER_COLUMN_NULLABLE
(that is, InnoDB was asked to add an index and change the column,
but not to drop the index that depended on the column).

Let us restore the debug assertion that catches this problem
outside AddressSanitizer, and 'defuse' the offending ALTER TABLE
statement in the test until something has been fixed in the SQL layer.
parent 77c00799
...@@ -422,11 +422,9 @@ col_text text not null, ...@@ -422,11 +422,9 @@ col_text text not null,
col_int_g integer generated always as (col_int) unique, col_int_g integer generated always as (col_int) unique,
col_text_g text generated always as (substr(col_text,1,499)) ) col_text_g text generated always as (substr(col_text,1,499)) )
engine innodb row_format = redundant; engine innodb row_format = redundant;
insert into t1 values (0, 'a', default, default); insert into t1 (col_int,col_text) values (0, 'a'), (null, 'b');
insert into t1 values (null, 'b', default, default);
alter table t1 modify column col_text text null, algorithm = instant; alter table t1 modify column col_text text null, algorithm = instant;
insert into t1 values (1, null, default, default); insert into t1 (col_int,col_text) values (1, null), (null, null);
insert into t1 values (null, null, default, default);
update t1 set col_text= 'd'; update t1 set col_text= 'd';
select * from t1; select * from t1;
col_int col_text col_int_g col_text_g col_int col_text col_int_g col_text_g
......
...@@ -445,11 +445,13 @@ create table t1 ( ...@@ -445,11 +445,13 @@ create table t1 (
col_int_g integer generated always as (col_int) unique, col_int_g integer generated always as (col_int) unique,
col_text_g text generated always as (substr(col_text,1,499)) ) col_text_g text generated always as (substr(col_text,1,499)) )
engine innodb row_format = redundant; engine innodb row_format = redundant;
insert into t1 values (0, 'a', default, default); insert into t1 (col_int,col_text) values (0, 'a'), (null, 'b');
insert into t1 values (null, 'b', default, default); # FIXME: remove the following to trigger the bug
--disable_query_log
alter table t1 modify column col_text text null, force;
--enable_query_log
alter table t1 modify column col_text text null, algorithm = instant; alter table t1 modify column col_text text null, algorithm = instant;
insert into t1 values (1, null, default, default); insert into t1 (col_int,col_text) values (1, null), (null, null);
insert into t1 values (null, null, default, default);
update t1 set col_text= 'd'; update t1 set col_text= 'd';
select * from t1; select * from t1;
check table t1; check table t1;
......
...@@ -605,6 +605,7 @@ inline bool dict_table_t::instant_column(const dict_table_t& table, ...@@ -605,6 +605,7 @@ inline bool dict_table_t::instant_column(const dict_table_t& table,
for (unsigned i = 0; i < n_v_def; i++) { for (unsigned i = 0; i < n_v_def; i++) {
dict_v_col_t& v = v_cols[i]; dict_v_col_t& v = v_cols[i];
DBUG_ASSERT(v.v_indexes.empty());
v.base_col = static_cast<dict_col_t**>( v.base_col = static_cast<dict_col_t**>(
mem_heap_dup(heap, v.base_col, mem_heap_dup(heap, v.base_col,
v.num_base * sizeof *v.base_col)); v.num_base * sizeof *v.base_col));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment