Skip to content

Commit 8c9c302

Browse files
kevgsmidenok
authored andcommitted
SQL: fix implicit sys fields for implicit engine of partitioned table [#366]
1 parent 03b54a6 commit 8c9c302

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

mysql-test/suite/versioning/r/partition.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,10 @@ x
287287
select * from t1 partition (p1sp1) for system_time all;
288288
x
289289
2
290+
create or replace table t1 (a bigint)
291+
with system versioning
292+
partition by range (a)
293+
(partition p0 values less than (20) engine innodb,
294+
partition p1 values less than maxvalue engine innodb);
295+
insert into t1 values (1);
290296
drop table t1;

mysql-test/suite/versioning/t/partition.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ select * from t1 partition (p0sp1) for system_time all;
229229
select * from t1 partition (p1sp0) for system_time all;
230230
select * from t1 partition (p1sp1) for system_time all;
231231

232+
create or replace table t1 (a bigint)
233+
with system versioning
234+
partition by range (a)
235+
(partition p0 values less than (20) engine innodb,
236+
partition p1 values less than maxvalue engine innodb);
237+
insert into t1 values (1);
238+
232239
drop table t1;
233240

234241
-- source suite/versioning/common_finish.inc

sql/handler.cc

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6872,7 +6872,25 @@ bool Vers_parse_info::check_and_fix_implicit(
68726872
}
68736873
}
68746874

6875-
bool integer_fields= create_info->db_type->flags & HTON_NATIVE_SYS_VERSIONING;
6875+
bool integer_fields= ha_check_storage_engine_flag(create_info->db_type,
6876+
HTON_NATIVE_SYS_VERSIONING);
6877+
6878+
#ifdef WITH_PARTITION_STORAGE_ENGINE
6879+
if (partition_info *info= thd->work_part_info)
6880+
{
6881+
if (!(create_info->used_fields & HA_CREATE_USED_ENGINE) &&
6882+
info->partitions.elements)
6883+
{
6884+
partition_element *element=
6885+
static_cast<partition_element *>(info->partitions.elem(0));
6886+
handlerton *hton= element->engine_type;
6887+
if (hton && ha_check_storage_engine_flag(hton, HTON_NATIVE_SYS_VERSIONING))
6888+
{
6889+
integer_fields= true;
6890+
}
6891+
}
6892+
}
6893+
#endif
68766894

68776895
if (fix_implicit(thd, alter_info, integer_fields))
68786896
return true;
@@ -6947,8 +6965,8 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
69476965
TABLE *table)
69486966
{
69496967
TABLE_SHARE *share= table->s;
6950-
bool integer_fields=
6951-
create_info->db_type->flags & HTON_NATIVE_SYS_VERSIONING;
6968+
bool integer_fields= ha_check_storage_engine_flag(create_info->db_type,
6969+
HTON_NATIVE_SYS_VERSIONING);
69526970
const char *table_name= share->table_name.str;
69536971

69546972
if (!need_check() && !share->versioned)

sql/sql_table.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8854,13 +8854,17 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
88548854

88558855
if (versioned)
88568856
{
8857-
if (create_info->db_type &&
8858-
table->s->db_type() != create_info->db_type && (
8859-
table->file->native_versioned() ||
8860-
create_info->db_type->flags & HTON_NATIVE_SYS_VERSIONING))
8857+
if (handlerton *hton1= create_info->db_type)
88618858
{
8862-
my_error(ER_VERS_ALTER_ENGINE_PROHIBITED, MYF(0), table_list->db, table_list->table_name);
8863-
DBUG_RETURN(true);
8859+
handlerton *hton2= table->file->ht;
8860+
if (hton1 != hton2 &&
8861+
(ha_check_storage_engine_flag(hton1, HTON_NATIVE_SYS_VERSIONING) ||
8862+
ha_check_storage_engine_flag(hton2, HTON_NATIVE_SYS_VERSIONING)))
8863+
{
8864+
my_error(ER_VERS_ALTER_ENGINE_PROHIBITED, MYF(0), table_list->db,
8865+
table_list->table_name);
8866+
DBUG_RETURN(true);
8867+
}
88648868
}
88658869
bool vers_data_mod= alter_info->data_modifying();
88668870
if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_SURVIVE)

0 commit comments

Comments
 (0)