Skip to content

Commit ba34f40

Browse files
committed
MDEV-21688 Assertion or ER_WARN_DATA_OUT_OF_RANGE upon ALTER on previously versioned table
Earlier skip of history row. Cleanup of dead code for VTMD.
1 parent 44c6c7a commit ba34f40

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

mysql-test/suite/versioning/r/alter.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,3 +684,12 @@ add column c int without system versioning,
684684
change column c c int,
685685
change column b b int without system versioning;
686686
drop table t;
687+
#
688+
# MDEV-21688 Assertion or ER_WARN_DATA_OUT_OF_RANGE upon ALTER on previously versioned table
689+
#
690+
create or replace table t1 (a int) with system versioning;
691+
insert into t1 values (128);
692+
delete from t1;
693+
set statement system_versioning_alter_history=keep for
694+
alter table t1 drop system versioning, modify column a tinyint;
695+
drop table t1;

mysql-test/suite/versioning/t/alter.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,3 +580,15 @@ alter table t
580580
change column b b int without system versioning;
581581

582582
drop table t;
583+
584+
--echo #
585+
--echo # MDEV-21688 Assertion or ER_WARN_DATA_OUT_OF_RANGE upon ALTER on previously versioned table
586+
--echo #
587+
create or replace table t1 (a int) with system versioning;
588+
insert into t1 values (128);
589+
delete from t1;
590+
set statement system_versioning_alter_history=keep for
591+
alter table t1 drop system versioning, modify column a tinyint;
592+
593+
# cleanup
594+
drop table t1;

sql/sql_table.cc

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10379,7 +10379,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
1037910379
bool make_versioned= !from->versioned() && to->versioned();
1038010380
bool make_unversioned= from->versioned() && !to->versioned();
1038110381
bool keep_versioned= from->versioned() && to->versioned();
10382-
bool drop_history= false; // XXX
1038310382
Field *to_row_start= NULL, *to_row_end= NULL, *from_row_end= NULL;
1038410383
MYSQL_TIME query_start;
1038510384
DBUG_ENTER("copy_data_between_tables");
@@ -10507,10 +10506,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
1050710506
{
1050810507
from_row_end= from->vers_end_field();
1050910508
}
10510-
else if (keep_versioned && drop_history)
10511-
{
10512-
from_row_end= from->vers_end_field();
10513-
}
1051410509

1051510510
THD_STAGE_INFO(thd, stage_copy_to_tmp_table);
1051610511
/* Tell handler that we have values for all columns in the to table */
@@ -10542,6 +10537,13 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
1054210537
error= 1;
1054310538
break;
1054410539
}
10540+
10541+
if (make_unversioned)
10542+
{
10543+
if (!from_row_end->is_max())
10544+
continue; // Drop history rows.
10545+
}
10546+
1054510547
if (unlikely(++thd->progress.counter >= time_to_report_progress))
1054610548
{
1054710549
time_to_report_progress+= MY_HOW_OFTEN_TO_WRITE/10;
@@ -10561,20 +10563,12 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
1056110563
copy_ptr->do_copy(copy_ptr);
1056210564
}
1056310565

10564-
if (drop_history && from_row_end && !from_row_end->is_max())
10565-
continue;
10566-
1056710566
if (make_versioned)
1056810567
{
1056910568
to_row_start->set_notnull();
1057010569
to_row_start->store_time(&query_start);
1057110570
to_row_end->set_max();
1057210571
}
10573-
else if (make_unversioned)
10574-
{
10575-
if (!from_row_end->is_max())
10576-
continue; // Drop history rows.
10577-
}
1057810572

1057910573
prev_insert_id= to->file->next_insert_id;
1058010574
if (to->default_field)

0 commit comments

Comments
 (0)