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

MDEV-27861: Creating partitioned tables should not be allowed with wsrep_osu_method=TOI and wsrep_strict_ddl=ON

Problem was incorrect handling of partitioned tables,
because db_type == DB_TYPE_PARTITION_DB
wsrep_should_replicate_ddl incorrectly marked
DDL as not replicatable. However, in partitioned
tables we should check implementing storage engine
from table->file->partition_ht() if available because
if partition handler is InnoDB all DDL should be allowed
even with wsrep_strict_ddl. For other storage engines
DDL should not be allowed and error should be issued.

This is 10.5 version of the fix.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
This commit is contained in:
Jan Lindström
2023-07-17 17:29:20 +03:00
committed by Julius Goryavsky
parent de216618e2
commit 22414d2ed0
10 changed files with 416 additions and 52 deletions

View File

@@ -2495,12 +2495,19 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
else
{
#ifdef WITH_WSREP
if (WSREP(thd) && hton && !wsrep_should_replicate_ddl(thd, hton->db_type))
if (WSREP(thd) && hton)
{
error= 1;
goto err;
handlerton *ht= hton;
// For partitioned tables resolve underlying handlerton
if (table->table && table->table->file->partition_ht())
ht= table->table->file->partition_ht();
if (!wsrep_should_replicate_ddl(thd, ht))
{
error= 1;
goto err;
}
}
#endif
#endif /* WITH_WSREP */
if (thd->locked_tables_mode == LTM_LOCK_TABLES ||
thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)
@@ -10564,10 +10571,21 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
if (WSREP(thd) && table &&
(thd->lex->sql_command == SQLCOM_ALTER_TABLE ||
thd->lex->sql_command == SQLCOM_CREATE_INDEX ||
thd->lex->sql_command == SQLCOM_DROP_INDEX) &&
!wsrep_should_replicate_ddl(thd, table->s->db_type()->db_type))
DBUG_RETURN(true);
#endif /* WITH_WSREP */
thd->lex->sql_command == SQLCOM_DROP_INDEX))
{
handlerton *ht= table->s->db_type();
// If alter used ENGINE= we use that
if (create_info->used_fields & HA_CREATE_USED_ENGINE)
ht= create_info->db_type;
// For partitioned tables resolve underlying handlerton
else if (table->file->partition_ht())
ht= table->file->partition_ht();
if (!wsrep_should_replicate_ddl(thd, ht))
DBUG_RETURN(true);
}
#endif
DEBUG_SYNC(thd, "alter_table_after_open_tables");