1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

PARTITION BY SYSTEM_TIME INTERVAL ...

Lots of changes:
* calculate the current history partition in ::external_lock(),
  not in ::write_row() or ::update_row()
* remove dynamically collected per-partition row_end stats
* no full table scan in open_table_from_share to calculate these
  stats, no manual MDL/thr_locks in open_table_from_share
* no shared stats in TABLE_SHARE = no mutexes or condition waits when
  calculating current history partition
* always compare timestamps, don't convert them to MYSQL_TIME
  (avoid DST ambiguity, and it's faster too)
* correct interval handling, 1 month = 1 month, not 30 * 24 * 3600 seconds
* save/restore first partition start time, and count intervals from there
* only allow to drop first partitions if INTERVAL
* when adding new history partitions, split the data in the last history
  parition, if it was overflowed
* show partition boundaries in INFORMATION_SCHEMA.PARTITIONS
This commit is contained in:
Sergei Golubchik
2018-02-21 15:16:19 +01:00
parent 7961bc4b89
commit e36c5ec0a5
16 changed files with 463 additions and 974 deletions

View File

@@ -2037,6 +2037,11 @@ int ha_partition::copy_partitions(ulonglong * const copied,
else
set_linear_hash_mask(m_part_info, m_part_info->num_subparts);
}
else if (m_part_info->part_type == VERSIONING_PARTITION)
{
if (m_part_info->check_constants(ha_thd(), m_part_info))
goto init_error;
}
while (reorg_part < m_reorged_parts)
{
@@ -3909,8 +3914,13 @@ int ha_partition::external_lock(THD *thd, int lock_type)
(void) (*file)->ha_external_lock(thd, lock_type);
} while (*(++file));
}
if (lock_type == F_WRLCK && m_part_info->part_expr)
m_part_info->part_expr->walk(&Item::register_field_in_read_map, 1, 0);
if (lock_type == F_WRLCK)
{
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)
m_part_info->vers_set_hist_part(thd);
}
DBUG_RETURN(0);
err_handler:
@@ -4270,9 +4280,6 @@ int ha_partition::write_row(uchar * buf)
set_auto_increment_if_higher(table->next_number_field);
reenable_binlog(thd);
if (m_part_info->part_type == VERSIONING_PARTITION)
m_part_info->vers_update_stats(thd, part_id);
exit:
thd->variables.sql_mode= saved_sql_mode;
table->auto_increment_field_not_null= saved_auto_inc_field_not_null;
@@ -4381,9 +4388,6 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data)
if (error)
goto exit;
if (m_part_info->part_type == VERSIONING_PARTITION)
m_part_info->vers_update_stats(thd, new_part_id);
tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */
error= m_file[old_part_id]->ha_delete_row(old_data);
reenable_binlog(thd);