Commit 56e47910 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-28127 EXCHANGE PARTITION with non-matching vcol expression segfault

mysql_compare_tables() treated all columns non-virtual. Now it
properly checks if the columns are virtual and matches expressions.
parent ebb6f575
......@@ -101,3 +101,25 @@ partition pn values less than (maxvalue));
insert into t1 (x, b) values (1, ''), (2, ''), (3, 'a'), (4, 'b');
update t1 set b= 'bar' where x > 0 order by v limit 2;
drop table t1;
#
# MDEV-28127 EXCHANGE PARTITION with non-matching vcol expression segfault
#
set @old_mode= @@sql_mode;
set sql_mode='';
create table t1 (a int, key(a)) partition by range (a) (partition p values less than (1));
create table t (a int generated always as (1) virtual, key(a));
alter table t1 exchange partition p with table t;
ERROR HY000: Tables have different definitions
create or replace table t (a int, key(a));
alter table t1 exchange partition p with table t;
create or replace table t1 (a int generated always as (1) virtual, key(a)) partition by range (a) (partition p values less than (1));
create or replace table t (a int generated always as (1) virtual, key(a));
alter table t1 exchange partition p with table t;
create or replace table t (a int generated always as (1) stored, key(a));
alter table t1 exchange partition p with table t;
ERROR HY000: Tables have different definitions
insert into t values (1);
Warnings:
Warning 1906 The value specified for generated column 'a' in table 't' has been ignored
drop tables t1, t;
set sql_mode= @old_mode;
......@@ -78,3 +78,24 @@ partition by range columns (x) (
insert into t1 (x, b) values (1, ''), (2, ''), (3, 'a'), (4, 'b');
update t1 set b= 'bar' where x > 0 order by v limit 2;
drop table t1;
--echo #
--echo # MDEV-28127 EXCHANGE PARTITION with non-matching vcol expression segfault
--echo #
set @old_mode= @@sql_mode;
set sql_mode='';
create table t1 (a int, key(a)) partition by range (a) (partition p values less than (1));
create table t (a int generated always as (1) virtual, key(a));
--error ER_TABLES_DIFFERENT_METADATA
alter table t1 exchange partition p with table t;
create or replace table t (a int, key(a));
alter table t1 exchange partition p with table t;
create or replace table t1 (a int generated always as (1) virtual, key(a)) partition by range (a) (partition p values less than (1));
create or replace table t (a int generated always as (1) virtual, key(a));
alter table t1 exchange partition p with table t;
create or replace table t (a int generated always as (1) stored, key(a));
--error ER_TABLES_DIFFERENT_METADATA
alter table t1 exchange partition p with table t;
insert into t values (1);
drop tables t1, t;
set sql_mode= @old_mode;
......@@ -7538,6 +7538,14 @@ bool mysql_compare_tables(TABLE *table,
(uint) (field->flags & NOT_NULL_FLAG))
DBUG_RETURN(false);
if (field->vcol_info)
{
if (!tmp_new_field->field->vcol_info)
DBUG_RETURN(false);
if (!field->vcol_info->is_equal(tmp_new_field->field->vcol_info))
DBUG_RETURN(false);
}
/*
mysql_prepare_alter_table() clears HA_OPTION_PACK_RECORD bit when
preparing description of existing table. In ALTER TABLE it is later
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment