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

MDEV-34813 A simple implementation of ha_partition::compare_key_parts

It is not clear that the three Compare_key enums form a hierarchy like
alter algorithms do. So on the safe side (in case MDEV-22168 gets
implemented without looking at this code) we should return NotEqual if
partition engines do not return the same enum value. There's a static
merge function that merges these enums, but it is used to merge the
Compare_keys of different key parts (horizontally), rather than
different partitions (vertically).
This commit is contained in:
Yuchen Pei
2025-01-03 17:40:05 +11:00
parent 0301ef38b4
commit 068d061454
4 changed files with 56 additions and 0 deletions

View File

@@ -59,4 +59,18 @@ index_name comment
PRIMARY PRIMARY
i2 disabled i2 disabled
drop table t1; drop table t1;
#
# MDEV-34813 ALGORITHM=INSTANT does not work for partitioned tables on indexed column
#
CREATE TABLE `t1` (
`f1` datetime ,
`f2` VARCHAR(2) ,
`f3` VARCHAR(200) ,
`f4` VARCHAR(100) ,
INDEX `i3` (`f4`) )
PARTITION BY RANGE COLUMNS(`f2`)
(PARTITION `p_01` VALUES LESS THAN ('02') ENGINE = InnoDB,
PARTITION `p_31` VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB);
ALTER online TABLE t1 MODIFY COLUMN `f4` VARCHAR(500) , ALGORITHM=INSTANT, LOCK=NONE;
drop table t1;
# End of 10.5 tests # End of 10.5 tests

View File

@@ -52,4 +52,23 @@ alter table t1 add partition (partition p4);
select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1';
drop table t1; drop table t1;
--echo #
--echo # MDEV-34813 ALGORITHM=INSTANT does not work for partitioned tables on indexed column
--echo #
--source include/have_innodb.inc
CREATE TABLE `t1` (
`f1` datetime ,
`f2` VARCHAR(2) ,
`f3` VARCHAR(200) ,
`f4` VARCHAR(100) ,
INDEX `i3` (`f4`) )
PARTITION BY RANGE COLUMNS(`f2`)
(PARTITION `p_01` VALUES LESS THAN ('02') ENGINE = InnoDB,
PARTITION `p_31` VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB);
ALTER online TABLE t1 MODIFY COLUMN `f4` VARCHAR(500) , ALGORITHM=INSTANT, LOCK=NONE;
drop table t1;
--echo # End of 10.5 tests --echo # End of 10.5 tests

View File

@@ -3178,6 +3178,24 @@ err1:
DBUG_RETURN(true); DBUG_RETURN(true);
} }
Compare_keys ha_partition::compare_key_parts(
const Field &old_field,
const Column_definition &new_field,
const KEY_PART_INFO &old_part,
const KEY_PART_INFO &new_part) const
{
Compare_keys res= m_file[0]->compare_key_parts(old_field, new_field,
old_part, new_part);
/*
Partitions have the same storage engine (until MDEV-22168) so the
calls should all return the same value for now.
*/
for (uint i= 1; i < m_tot_parts; i++)
if (res != m_file[i]->compare_key_parts(old_field, new_field,
old_part, new_part))
return Compare_keys::NotEqual;
return res;
}
/** /**
Setup m_engine_array Setup m_engine_array

View File

@@ -481,6 +481,11 @@ public:
m_part_info= part_info; m_part_info= part_info;
m_is_sub_partitioned= part_info->is_sub_partitioned(); m_is_sub_partitioned= part_info->is_sub_partitioned();
} }
Compare_keys compare_key_parts(
const Field &old_field,
const Column_definition &new_field,
const KEY_PART_INFO &old_part,
const KEY_PART_INFO &new_part) const override;
void return_record_by_parent() override; void return_record_by_parent() override;