Skip to content

Commit 0109312

Browse files
committed
Revert "MDEV-34033 Exchange partition with virtual columns fails"
This reverts commit 0cf2176
1 parent a394fc0 commit 0109312

File tree

8 files changed

+1
-118
lines changed

8 files changed

+1
-118
lines changed

mysql-test/main/partition_exchange.result

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,28 +1250,6 @@ ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
12501250
ERROR HY000: Tables have different definitions
12511251
DROP TABLE t1, t2;
12521252
#
1253-
# MDEV-34033 Exchange partition with virtual columns fails
1254-
#
1255-
create or replace table t1(
1256-
id int primary key,
1257-
col1 int,
1258-
col2 boolean as (col1 is null))
1259-
partition by list (id) ( partition p1 values in (1)
1260-
);
1261-
create or replace table t1_working like t1;
1262-
alter table t1_working remove partitioning;
1263-
alter table t1 exchange partition p1 with table t1_working;
1264-
create or replace table t2(
1265-
id int primary key,
1266-
col1 int,
1267-
col2 boolean as (true))
1268-
partition by list (id) ( partition p1 values in (1)
1269-
);
1270-
create or replace table t2_working like t2;
1271-
alter table t2_working remove partitioning;
1272-
alter table t2 exchange partition p1 with table t2_working;
1273-
drop tables t1, t1_working, t2, t2_working;
1274-
#
12751253
# MDEV-35612 EXCHANGE PARTITION does not work for tables with unique blobs
12761254
#
12771255
create table t (a int, b text, unique (b), unique(a, b)) partition by list (a) (partition p0 values in (1,2), partition pdef default);

mysql-test/main/partition_exchange.test

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -552,38 +552,6 @@ ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
552552
# Cleanup
553553
DROP TABLE t1, t2;
554554

555-
--echo #
556-
--echo # MDEV-34033 Exchange partition with virtual columns fails
557-
--echo #
558-
# this fails when the virtual persistent column
559-
# references another column
560-
create or replace table t1(
561-
id int primary key,
562-
col1 int,
563-
col2 boolean as (col1 is null))
564-
partition by list (id) ( partition p1 values in (1)
565-
);
566-
567-
create or replace table t1_working like t1;
568-
alter table t1_working remove partitioning;
569-
alter table t1 exchange partition p1 with table t1_working;
570-
571-
# this works when the virtual persistent column
572-
# does not reference another column
573-
create or replace table t2(
574-
id int primary key,
575-
col1 int,
576-
col2 boolean as (true))
577-
partition by list (id) ( partition p1 values in (1)
578-
);
579-
580-
create or replace table t2_working like t2;
581-
alter table t2_working remove partitioning;
582-
alter table t2 exchange partition p1 with table t2_working;
583-
584-
# Cleanup
585-
drop tables t1, t1_working, t2, t2_working;
586-
587555
--echo #
588556
--echo # MDEV-35612 EXCHANGE PARTITION does not work for tables with unique blobs
589557
--echo #

sql/field.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,6 @@ class Virtual_column_info: public Sql_alloc,
660660
bool fix_and_check_expr(THD *thd, TABLE *table);
661661
bool check_access(THD *thd);
662662
inline bool is_equal(const Virtual_column_info* vcol) const;
663-
/* Same as is_equal() but for comparing with different table */
664-
bool is_equivalent(THD *thd, TABLE_SHARE *share, TABLE_SHARE *vcol_share,
665-
const Virtual_column_info* vcol, bool &error) const;
666663
inline void print(String*);
667664
};
668665

sql/item.cc

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -845,30 +845,6 @@ bool Item_field::rename_fields_processor(void *arg)
845845
return 0;
846846
}
847847

848-
/**
849-
Rename table and clean field for EXCHANGE comparison
850-
*/
851-
852-
bool Item_field::rename_table_processor(void *arg)
853-
{
854-
Item::func_processor_rename_table *p= (Item::func_processor_rename_table*) arg;
855-
856-
/* If (db_name, table_name) matches (p->old_db, p->old_table)
857-
rename to (p->new_db, p->new_table) */
858-
if (((!db_name.str && !p->old_db.str) ||
859-
db_name.streq(p->old_db)) &&
860-
((!table_name.str && !p->old_table.str) ||
861-
table_name.streq(p->old_table)))
862-
{
863-
db_name= p->new_db;
864-
table_name= p->new_table;
865-
}
866-
867-
/* Item_field equality is done by field pointer if it is set, we need to avoid that */
868-
field= NULL;
869-
return 0;
870-
}
871-
872848

873849
/**
874850
Check if an Item_field references some field from a list of fields.

sql/item.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,7 +2397,6 @@ class Item :public Value_source,
23972397
virtual bool check_partition_func_processor(void *arg) { return true; }
23982398
virtual bool post_fix_fields_part_expr_processor(void *arg) { return 0; }
23992399
virtual bool rename_fields_processor(void *arg) { return 0; }
2400-
virtual bool rename_table_processor(void *arg) { return 0; }
24012400
/*
24022401
TRUE if the function is knowingly TRUE or FALSE.
24032402
Not to be used for AND/OR formulas.
@@ -2426,13 +2425,6 @@ class Item :public Value_source,
24262425
LEX_CSTRING table_name;
24272426
List<Create_field> fields;
24282427
};
2429-
struct func_processor_rename_table
2430-
{
2431-
Lex_ident_db old_db;
2432-
Lex_ident_table old_table;
2433-
Lex_ident_db new_db;
2434-
Lex_ident_table new_table;
2435-
};
24362428
virtual bool check_vcol_func_processor(void *arg)
24372429
{
24382430
return mark_unsupported_function(full_name(), arg, VCOL_IMPOSSIBLE);
@@ -3892,7 +3884,6 @@ class Item_field :public Item_ident,
38923884
bool switch_to_nullable_fields_processor(void *arg) override;
38933885
bool update_vcol_processor(void *arg) override;
38943886
bool rename_fields_processor(void *arg) override;
3895-
bool rename_table_processor(void *arg) override;
38963887
bool check_vcol_func_processor(void *arg) override;
38973888
bool set_fields_as_dependent_processor(void *arg) override
38983889
{

sql/sql_partition_admin.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,6 @@ bool compare_table_with_partition(THD *thd, TABLE *table, TABLE *part_table,
241241
part_create_info.row_type= table->s->row_type;
242242
}
243243

244-
part_create_info.table= part_table;
245-
246244
/*
247245
NOTE: ha_blackhole does not support check_if_compatible_data,
248246
so this always fail for blackhole tables.

sql/sql_table.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7522,12 +7522,8 @@ bool mysql_compare_tables(TABLE *table, Alter_info *alter_info,
75227522
{
75237523
if (!tmp_new_field->field->vcol_info)
75247524
DBUG_RETURN(false);
7525-
bool err;
7526-
if (!field->vcol_info->is_equivalent(thd, table->s, create_info->table->s,
7527-
tmp_new_field->field->vcol_info, err))
7525+
if (!field->vcol_info->is_equal(tmp_new_field->field->vcol_info))
75287526
DBUG_RETURN(false);
7529-
if (err)
7530-
DBUG_RETURN(true);
75317527
}
75327528

75337529
/*

sql/table.cc

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,27 +3685,6 @@ bool Virtual_column_info::cleanup_session_expr()
36853685
}
36863686

36873687

3688-
bool
3689-
Virtual_column_info::is_equivalent(THD *thd, TABLE_SHARE *share, TABLE_SHARE *vcol_share,
3690-
const Virtual_column_info* vcol, bool &error) const
3691-
{
3692-
error= true;
3693-
Item *cmp_expr= vcol->expr->build_clone(thd);
3694-
if (!cmp_expr)
3695-
return false;
3696-
Item::func_processor_rename_table param;
3697-
param.old_db= Lex_ident_db(vcol_share->db);
3698-
param.old_table= Lex_ident_table(vcol_share->table_name);
3699-
param.new_db= Lex_ident_db(share->db);
3700-
param.new_table= Lex_ident_table(share->table_name);
3701-
cmp_expr->walk(&Item::rename_table_processor, 1, &param);
3702-
3703-
error= false;
3704-
return type_handler() == vcol->type_handler()
3705-
&& is_stored() == vcol->is_stored()
3706-
&& expr->eq(cmp_expr, true);
3707-
}
3708-
37093688

37103689
class Vcol_expr_context
37113690
{

0 commit comments

Comments
 (0)