Skip to content
Permalink
Browse files

MDEV-20336 Assertion bitmap_is_set(read_partitions) upon SELECT FOR U…

…PDATE from versioned table

Exclude SELECT and INSERT SELECT from vers_set_hist_part(). We cannot
likewise exclude REPLACE SELECT because it may REPLACE into itself
(and REPLACE generates history).

INSERT also does not generate history, but we have history
modification setting which might be interfered.
  • Loading branch information...
midenok committed Aug 14, 2019
1 parent 39db116 commit a20f6f9853e522ad388f5b968ce11af3c5d1fc10
@@ -569,6 +569,13 @@ delete from t1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
unlock tables;
#
# MDEV-20336 Assertion bitmap_is_set(read_partitions) upon SELECT FOR UPDATE from versioned table
#
create or replace table t1 (pk int primary key) with system versioning partition by system_time limit 100 (partition p1 history, partition pn current);
execute immediate 'select * from t1 for update';
pk
drop table t1;
# Test cleanup
drop database test;
create database test;
@@ -529,6 +529,13 @@ delete from t1 where x < 3;
delete from t1;
unlock tables;

--echo #
--echo # MDEV-20336 Assertion bitmap_is_set(read_partitions) upon SELECT FOR UPDATE from versioned table
--echo #
create or replace table t1 (pk int primary key) with system versioning partition by system_time limit 100 (partition p1 history, partition pn current);
execute immediate 'select * from t1 for update';
drop table t1;

--echo # Test cleanup
drop database test;
create database test;
@@ -3951,7 +3951,12 @@ int ha_partition::external_lock(THD *thd, int lock_type)
{
if (m_part_info->part_expr)
m_part_info->part_expr->walk(&Item::register_field_in_read_map, 1, 0);
if (m_part_info->part_type == VERSIONING_PARTITION)
if (m_part_info->part_type == VERSIONING_PARTITION &&
/* TODO: MDEV-20345 exclude more inapproriate commands like INSERT
These commands may be excluded because working history partition is needed
only for versioned DML. */
thd->lex->sql_command != SQLCOM_SELECT &&
thd->lex->sql_command != SQLCOM_INSERT_SELECT)
m_part_info->vers_set_hist_part(thd);
}
DBUG_RETURN(0);
@@ -4104,7 +4109,10 @@ int ha_partition::start_stmt(THD *thd, thr_lock_type lock_type)
case TL_WRITE_ONLY:
if (m_part_info->part_expr)
m_part_info->part_expr->walk(&Item::register_field_in_read_map, 1, 0);
if (m_part_info->part_type == VERSIONING_PARTITION)
if (m_part_info->part_type == VERSIONING_PARTITION &&
// TODO: MDEV-20345 (see above)
thd->lex->sql_command != SQLCOM_SELECT &&
thd->lex->sql_command != SQLCOM_INSERT_SELECT)
m_part_info->vers_set_hist_part(thd);
default:;
}
@@ -816,7 +816,10 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
else
vers_conditions.init(SYSTEM_TIME_ALL);
}
else if (!vers_conditions.is_set())
else if (!vers_conditions.is_set() &&
/* We cannot optimize REPLACE .. SELECT because it may need
to call vers_set_hist_part() to update history. */
thd->lex->sql_command != SQLCOM_REPLACE_SELECT)
{
table->partition_names= newx List<String>;
String *s= newx String(vers_info->now_part->partition_name,

0 comments on commit a20f6f9

Please sign in to comment.
You can’t perform that action at this time.