1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-34928 CREATE TABLE does not check valid engine for log tables

Log tables cannot work with transactional InnoDB or Aria, that is
checked by ALTER TABLE for ER_UNSUPORTED_LOG_ENGINE. But it was
possible to circumvent this check with CREATE TABLE. The patch makes
the check of supported engine common for ALTER TABLE and CREATE TABLE.
This commit is contained in:
Aleksey Midenkov
2025-06-25 14:14:50 +03:00
parent 1dedd2a3b9
commit 7ab205b009
5 changed files with 82 additions and 14 deletions

View File

@@ -4629,6 +4629,12 @@ int create_table_impl(THD *thd,
goto err;
}
TABLE_LIST table_list;
table_list.init_one_table(&db, &table_name, 0, TL_WRITE_ALLOW_WRITE);
int log_table= check_if_log_table(&table_list);
if (log_table && create_info->check_if_valid_log_table())
goto err;
handlerton *db_type;
if (!internal_tmp_table &&
ha_table_exists(thd, &db, &table_name,
@@ -4645,12 +4651,13 @@ int create_table_impl(THD *thd,
{
(void) delete_statistics_for_table(thd, &db, &table_name);
TABLE_LIST table_list;
table_list.init_one_table(&db, &table_name, 0, TL_WRITE_ALLOW_WRITE);
table_list.table= create_info->table;
if (check_if_log_table(&table_list, TRUE, "CREATE OR REPLACE"))
if (log_table && logger.is_log_table_enabled(log_table))
{
my_error(ER_BAD_LOG_STATEMENT, MYF(0), "CREATE OR REPLACE");
goto err;
}
/*
Rollback the empty transaction started in mysql_create_table()
@@ -10417,7 +10424,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
it is the case.
TODO: this design is obsolete and will be removed.
*/
int table_kind= check_if_log_table(table_list, FALSE, NullS);
int table_kind= check_if_log_table(table_list);
const bool used_engine= create_info->used_fields & HA_CREATE_USED_ENGINE;
if (table_kind)
@@ -10432,17 +10439,8 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
/* Disable alter of log tables to unsupported engine */
if ((used_engine) &&
(!create_info->db_type || /* unknown engine */
!(create_info->db_type->flags & HTON_SUPPORT_LOG_TABLES)))
{
unsupported:
my_error(ER_UNSUPORTED_LOG_ENGINE, MYF(0),
hton_name(create_info->db_type)->str);
create_info->check_if_valid_log_table()))
DBUG_RETURN(true);
}
if (create_info->db_type == maria_hton &&
create_info->transactional != HA_CHOICE_NO)
goto unsupported;
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (alter_info->partition_flags & ALTER_PARTITION_INFO)