@@ -1065,14 +1065,16 @@ static void dd_commit_inplace_no_change(const Table *old_dd_tab,
1065
1065
@param[in] old_table MySQL table as it is before the ALTER operation
1066
1066
@param[in] altered_table MySQL table that is being altered
1067
1067
@param[in] old_dd_tab Old dd::Table or dd::Partition
1068
- @param[in,out] new_dd_tab New dd::Table or dd::Partition */
1068
+ @param[in,out] new_dd_tab New dd::Table or dd::Partition
1069
+ @param[in] autoinc autoinc counter pointer if AUTO_INCREMENT
1070
+ is defined for the table, otherwise nullptr */
1069
1071
template <typename Table>
1070
1072
static void dd_commit_inplace_instant (Alter_inplace_info *ha_alter_info,
1071
1073
THD *thd, trx_t *trx, dict_table_t *table,
1072
1074
const TABLE *old_table,
1073
1075
const TABLE *altered_table,
1074
1076
const Table *old_dd_tab,
1075
- Table *new_dd_tab);
1077
+ Table *new_dd_tab, uint64_t *autoinc );
1076
1078
1077
1079
/* * Update table level instant metadata in commit phase
1078
1080
@param[in] table InnoDB table object
@@ -1220,7 +1222,10 @@ bool ha_innobase::commit_inplace_alter_table(TABLE *altered_table,
1220
1222
ut_ad (!res);
1221
1223
dd_commit_inplace_instant (ha_alter_info, m_user_thd, m_prebuilt->trx ,
1222
1224
m_prebuilt->table , table, altered_table,
1223
- old_dd_tab, new_dd_tab);
1225
+ old_dd_tab, new_dd_tab,
1226
+ altered_table->found_next_number_field != nullptr
1227
+ ? &m_prebuilt->table ->autoinc
1228
+ : nullptr );
1224
1229
} else if (!(ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE) ||
1225
1230
ctx == nullptr ) {
1226
1231
ut_ad (!res);
@@ -4012,7 +4017,7 @@ static void dd_commit_inplace_instant(Alter_inplace_info *ha_alter_info,
4012
4017
const TABLE *old_table,
4013
4018
const TABLE *altered_table,
4014
4019
const Table *old_dd_tab,
4015
- Table *new_dd_tab) {
4020
+ Table *new_dd_tab, uint64_t *autoinc ) {
4016
4021
ut_ad (is_instant (ha_alter_info));
4017
4022
4018
4023
Instant_Type type =
@@ -4056,6 +4061,14 @@ static void dd_commit_inplace_instant(Alter_inplace_info *ha_alter_info,
4056
4061
default :
4057
4062
ut_ad (0 );
4058
4063
}
4064
+
4065
+ if (autoinc != nullptr ) {
4066
+ ut_ad (altered_table->found_next_number_field != nullptr );
4067
+ if (!dd_table_is_partitioned (new_dd_tab->table ()) ||
4068
+ dd_part_is_first (reinterpret_cast <dd::Partition *>(new_dd_tab))) {
4069
+ dd_set_autoinc (new_dd_tab->table ().se_private_data (), *autoinc);
4070
+ }
4071
+ }
4059
4072
}
4060
4073
4061
4074
/* * Check if a new table's index will exceed the index limit for the table
@@ -9986,9 +9999,13 @@ bool ha_innopart::commit_inplace_alter_table(TABLE *altered_table,
9986
9999
static_cast <ha_innobase_inplace_ctx *>(ctx_parts->ctx_array [i]);
9987
10000
9988
10001
if (is_instant (ha_alter_info)) {
9989
- dd_commit_inplace_instant (ha_alter_info, m_user_thd, m_prebuilt->trx ,
9990
- m_part_share->get_table_part (i), table,
9991
- altered_table, old_part, new_part);
10002
+ dd_commit_inplace_instant (
10003
+ ha_alter_info, m_user_thd, m_prebuilt->trx ,
10004
+ m_part_share->get_table_part (i), table, altered_table, old_part,
10005
+ new_part,
10006
+ altered_table->found_next_number_field != nullptr
10007
+ ? reinterpret_cast <uint64_t *>(&m_part_share->next_auto_inc_val )
10008
+ : nullptr );
9992
10009
} else if (!(ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE) ||
9993
10010
ctx == nullptr ) {
9994
10011
dd_commit_inplace_no_change (old_part, new_part, true );
0 commit comments