summaryrefslogtreecommitdiffstats
path: root/storage/innobase/handler/handler0alter.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 13:22:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 13:22:53 +0000
commit347c164c35eddab388009470e6848cb361ac93f8 (patch)
tree2c0c44eac690f510bb0a35b2a13b36d606b77b6b /storage/innobase/handler/handler0alter.cc
parentReleasing progress-linux version 1:10.11.7-4~progress7.99u1. (diff)
downloadmariadb-347c164c35eddab388009470e6848cb361ac93f8.tar.xz
mariadb-347c164c35eddab388009470e6848cb361ac93f8.zip
Merging upstream version 1:10.11.8.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'storage/innobase/handler/handler0alter.cc')
-rw-r--r--storage/innobase/handler/handler0alter.cc71
1 files changed, 39 insertions, 32 deletions
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 1401136f..6689b9ef 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -864,6 +864,9 @@ my_error_innodb(
case DB_DEADLOCK:
my_error(ER_LOCK_DEADLOCK, MYF(0));
break;
+ case DB_RECORD_CHANGED:
+ my_error(ER_CHECKREAD, MYF(0), table);
+ break;
case DB_LOCK_WAIT_TIMEOUT:
my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0));
break;
@@ -1458,11 +1461,6 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
}
};
-/********************************************************************//**
-Get the upper limit of the MySQL integral and floating-point type.
-@return maximum allowed value for the field */
-ulonglong innobase_get_int_col_max_value(const Field *field);
-
/** Determine if fulltext indexes exist in a given table.
@param table MySQL table
@return number of fulltext indexes */
@@ -1730,11 +1728,9 @@ instant_alter_column_possible(
ut_ad(!is_null || nullable);
n_nullable += nullable;
n_add++;
- uint l;
+ uint l = (*af)->pack_length();
switch ((*af)->type()) {
case MYSQL_TYPE_VARCHAR:
- l = reinterpret_cast<const Field_varstring*>
- (*af)->get_length();
variable_length:
if (l >= min_local_len) {
max_size += blob_prefix
@@ -1748,7 +1744,6 @@ instant_alter_column_possible(
if (!is_null) {
min_size += l;
}
- l = (*af)->pack_length();
max_size += l;
lenlen += l > 255 ? 2 : 1;
}
@@ -1762,7 +1757,6 @@ instant_alter_column_possible(
((*af))->get_length();
goto variable_length;
default:
- l = (*af)->pack_length();
if (l > 255 && ib_table.not_redundant()) {
goto variable_length;
}
@@ -2748,6 +2742,9 @@ cannot_create_many_fulltext_index:
online = false;
}
+ static constexpr const char *not_implemented
+ = "Not implemented for system-versioned operations";
+
if (ha_alter_info->handler_flags
& ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX) {
/* ADD FULLTEXT|SPATIAL INDEX requires a lock.
@@ -2775,6 +2772,12 @@ cannot_create_many_fulltext_index:
goto cannot_create_many_fulltext_index;
}
+ if (altered_table->versioned()) {
+ ha_alter_info->unsupported_reason
+ = not_implemented;
+ DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
+ }
+
add_fulltext = true;
if (ha_alter_info->online
&& !ha_alter_info->unsupported_reason) {
@@ -2811,12 +2814,18 @@ cannot_create_many_fulltext_index:
}
}
+ if (m_prebuilt->table->is_stats_table()) {
+ if (ha_alter_info->online) {
+ ha_alter_info->unsupported_reason =
+ table_share->table_name.str;
+ }
+ online= false;
+ }
+
// FIXME: implement Online DDL for system-versioned operations
if (ha_alter_info->handler_flags & INNOBASE_ALTER_VERSIONED_REBUILD) {
-
if (ha_alter_info->online) {
- ha_alter_info->unsupported_reason =
- "Not implemented for system-versioned operations";
+ ha_alter_info->unsupported_reason = not_implemented;
}
online = false;
@@ -7444,6 +7453,7 @@ error_handled:
row_mysql_lock_data_dictionary(ctx->trx);
} else {
row_merge_drop_indexes(ctx->trx, user_table, true);
+ user_table->indexes.start->online_log = nullptr;
ctx->trx->commit();
}
@@ -9865,13 +9875,7 @@ commit_set_autoinc(
const dict_col_t* autoinc_col
= dict_table_get_nth_col(ctx->old_table,
innodb_col_no(ai));
- dict_index_t* index
- = dict_table_get_first_index(ctx->old_table);
- while (index != NULL
- && index->fields[0].col != autoinc_col) {
- index = dict_table_get_next_index(index);
- }
-
+ auto index = ctx->old_table->get_index(*autoinc_col);
ut_ad(index);
ib_uint64_t max_in_table = index
@@ -10246,6 +10250,7 @@ when rebuilding the table.
@param ctx In-place ALTER TABLE context
@param altered_table MySQL table that is being altered
@param old_table MySQL table as it is before the ALTER operation
+@param statistics_exist whether to update InnoDB persistent statistics
@param trx Data dictionary transaction
@param table_name Table name in MySQL
@retval true Failure
@@ -10519,6 +10524,7 @@ when not rebuilding the table.
@param ha_alter_info Data used during in-place alter
@param ctx In-place ALTER TABLE context
@param old_table MySQL table as it is before the ALTER operation
+@param statistics_exist whether to update InnoDB persistent statistics
@param trx Data dictionary transaction
@param table_name Table name in MySQL
@retval true Failure
@@ -10532,6 +10538,7 @@ commit_try_norebuild(
ha_innobase_inplace_ctx*ctx,
TABLE* altered_table,
const TABLE* old_table,
+ bool statistics_exist,
trx_t* trx,
const char* table_name)
{
@@ -10646,6 +10653,10 @@ commit_try_norebuild(
goto handle_error;
}
+ if (!statistics_exist) {
+ continue;
+ }
+
error = dict_stats_delete_from_index_stats(db, table,
index->name, trx);
switch (error) {
@@ -10657,7 +10668,8 @@ commit_try_norebuild(
}
}
- if (const size_t size = ha_alter_info->rename_keys.size()) {
+ if (!statistics_exist) {
+ } else if (const size_t size = ha_alter_info->rename_keys.size()) {
char tmp_name[5];
char db[MAX_DB_UTF8_LEN], table[MAX_TABLE_UTF8_LEN];
@@ -11224,16 +11236,7 @@ ha_innobase::commit_inplace_alter_table(
fts_optimize_remove_table(ctx->old_table);
}
- dict_sys.freeze(SRW_LOCK_CALL);
- for (auto f : ctx->old_table->referenced_set) {
- if (dict_table_t* child = f->foreign_table) {
- error = lock_table_for_trx(child, trx, LOCK_X);
- if (error != DB_SUCCESS) {
- break;
- }
- }
- }
- dict_sys.unfreeze();
+ error = lock_table_children(ctx->old_table, trx);
if (ctx->new_table->fts) {
ut_ad(!ctx->new_table->fts->add_wq);
@@ -11413,6 +11416,8 @@ err_index:
}
}
+ DEBUG_SYNC(m_user_thd, "innodb_commit_inplace_before_lock");
+
DBUG_EXECUTE_IF("stats_lock_fail",
error = DB_LOCK_WAIT_TIMEOUT;
trx_rollback_for_mysql(trx););
@@ -11496,7 +11501,9 @@ fail:
goto fail;
}
} else if (commit_try_norebuild(ha_alter_info, ctx,
- altered_table, table, trx,
+ altered_table, table,
+ table_stats && index_stats,
+ trx,
table_share->table_name.str)) {
goto fail;
}