1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

SQL: 1-row partition rotation fix [fixes #260]

This commit is contained in:
Aleksey Midenkov
2017-09-13 10:57:23 +03:00
parent 78d2430aa2
commit 7e764ae188
7 changed files with 46 additions and 15 deletions

View File

@ -3426,11 +3426,21 @@ int vers_get_partition_id(partition_info *part_info,
DBUG_ASSERT(part_info);
Field *sys_trx_end= part_info->part_field_array[STAT_TRX_END];
DBUG_ASSERT(sys_trx_end);
DBUG_ASSERT(part_info->table);
TABLE *table= part_info->table;
DBUG_ASSERT(table);
Vers_part_info *vers_info= part_info->vers_info;
DBUG_ASSERT(vers_info && vers_info->initialized());
DBUG_ASSERT(sys_trx_end->table == part_info->table && part_info->table->versioned());
DBUG_ASSERT(part_info->table->vers_end_field() == sys_trx_end);
DBUG_ASSERT(vers_info);
DBUG_ASSERT(vers_info->initialized());
DBUG_ASSERT(sys_trx_end->table == table);
bool tmp_off= false;
if (!table->versioned() && table->file->native_versioned())
{
// in copy_data_between_tables() versioning may be temporarily turned off
tmp_off= true;
table->s->versioned= true;
}
DBUG_ASSERT(table->versioned());
DBUG_ASSERT(table->vers_end_field() == sys_trx_end);
// new rows have NULL in sys_trx_end
if (sys_trx_end->is_max() || sys_trx_end->is_null())
@ -3440,7 +3450,6 @@ int vers_get_partition_id(partition_info *part_info,
else // row is historical
{
THD *thd= current_thd;
TABLE *table= part_info->table;
switch (thd->lex->sql_command)
{
@ -3478,6 +3487,9 @@ int vers_get_partition_id(partition_info *part_info,
*part_id= vers_info->hist_part->id;
}
if (tmp_off)
table->s->versioned= false;
DBUG_PRINT("exit",("partition: %d", *part_id));
DBUG_RETURN(0);
}