@@ -1065,14 +1065,16 @@ static void dd_commit_inplace_no_change(const Table *old_dd_tab,
10651065@param[in] old_table MySQL table as it is before the ALTER operation
10661066@param[in] altered_table MySQL table that is being altered
10671067@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 */
10691071template <typename Table>
10701072static void dd_commit_inplace_instant (Alter_inplace_info *ha_alter_info,
10711073 THD *thd, trx_t *trx, dict_table_t *table,
10721074 const TABLE *old_table,
10731075 const TABLE *altered_table,
10741076 const Table *old_dd_tab,
1075- Table *new_dd_tab);
1077+ Table *new_dd_tab, uint64_t *autoinc );
10761078
10771079/* * Update table level instant metadata in commit phase
10781080@param[in] table InnoDB table object
@@ -1220,7 +1222,10 @@ bool ha_innobase::commit_inplace_alter_table(TABLE *altered_table,
12201222 ut_ad (!res);
12211223 dd_commit_inplace_instant (ha_alter_info, m_user_thd, m_prebuilt->trx ,
12221224 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 );
12241229 } else if (!(ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE) ||
12251230 ctx == nullptr ) {
12261231 ut_ad (!res);
@@ -4012,7 +4017,7 @@ static void dd_commit_inplace_instant(Alter_inplace_info *ha_alter_info,
40124017 const TABLE *old_table,
40134018 const TABLE *altered_table,
40144019 const Table *old_dd_tab,
4015- Table *new_dd_tab) {
4020+ Table *new_dd_tab, uint64_t *autoinc ) {
40164021 ut_ad (is_instant (ha_alter_info));
40174022
40184023 Instant_Type type =
@@ -4056,6 +4061,14 @@ static void dd_commit_inplace_instant(Alter_inplace_info *ha_alter_info,
40564061 default :
40574062 ut_ad (0 );
40584063 }
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+ }
40594072}
40604073
40614074/* * 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,
99869999 static_cast <ha_innobase_inplace_ctx *>(ctx_parts->ctx_array [i]);
998710000
998810001 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 );
999210009 } else if (!(ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE) ||
999310010 ctx == nullptr ) {
999410011 dd_commit_inplace_no_change (old_part, new_part, true );
0 commit comments