1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

MDEV-30984 Online ALTER table is denied with non-informative error messages

Group all the checks in online_alter_check_supported().

There is now two groups of checks:
1. A technical availability of online, that is checked before open_tables,
and affects table_list->lock_type. It's supposed to be safe to make it
TL_READ even if COPY algorithm will fall back to not-online, since MDL is
SHARED_UPGRADEABLE anyway.
2. An 'online' availability for a COPY algorithm. It can be done as late as
just before the copy_data_between_tables call. The lock_type influence is
disclosed above, so the only other place it affects is
Alter_info::supports_lock, where `online` flag is only used to decide
whether to report the error at the inplace preparation stage. We'd want to
make that at the last resort, which is COPY preparation, if no algorithm is
chosen by the user. So it's event better now.

Some changes are required to the autoinc support detection, as the check
now happens after mysql_prepare_alter_table:
* alter_info->drop_list is empty
* instead, dropped columns are in tmp_set
* alter_info->create_list now has every field that's in the new table.
* the column definition's change.str will be nonnull whether the column
  remains in the new table (vs whether it was changed, as before).
  But it also has `field` field set.
* IF EXISTS doesn't have to be dealt anymore

This infers that the changes are now checked in more detail: a field's
definition shouldn't be changed, vs a field shouldn't be mentioned in
the CHANGE list, as it was before. This is reflected by the line 193 test.
This commit is contained in:
Nikita Malyavin
2023-05-15 19:39:21 +03:00
committed by Sergei Golubchik
parent b3f988d260
commit c382de72ea
5 changed files with 105 additions and 72 deletions

View File

@@ -1233,6 +1233,16 @@ public:
{ return strdup_root(mem_root,str); }
inline char *strmake(const char *str, size_t size) const
{ return strmake_root(mem_root,str,size); }
inline LEX_CSTRING strcat(const LEX_CSTRING &a, const LEX_CSTRING &b) const
{
char *buf= (char*)alloc(a.length + b.length + 1);
if (unlikely(!buf))
return null_clex_str;
memcpy(buf, a.str, a.length);
memcpy(buf + a.length, b.str, b.length);
buf[a.length + b.length] = 0;
return {buf, a.length + b.length};
}
inline void *memdup(const void *str, size_t size) const
{ return memdup_root(mem_root,str,size); }
inline void *memdup_w_gap(const void *str, size_t size, size_t gap) const