mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Added support for more functions when using partitioned S3 tables
MDEV-22088 S3 partitioning support All ALTER PARTITION commands should now work on S3 tables except REBUILD PARTITION TRUNCATE PARTITION REORGANIZE PARTITION In addition, PARTIONED S3 TABLES can also be replicated. This is achived by storing the partition tables .frm and .par file on S3 for partitioned shared (S3) tables. The discovery methods are enchanced by allowing engines that supports discovery to also support of the partitioned tables .frm and .par file Things in more detail - The .frm and .par files of partitioned tables are stored in S3 and kept in sync. - Added hton callback create_partitioning_metadata to inform handler that metadata for a partitoned file has changed - Added back handler::discover_check_version() to be able to check if a table's or a part table's definition has changed. - Added handler::check_if_updates_are_ignored(). Needed for partitioning. - Renamed rebind() -> rebind_psi(), as it was before. - Changed CHF_xxx hadnler flags to an enum - Changed some checks from using table->file->ht to use table->file->partition_ht() to get discovery to work with partitioning. - If TABLE_SHARE::init_from_binary_frm_image() fails, ensure that we don't leave any .frm or .par files around. - Fixed that writefrm() doesn't leave unusable .frm files around - Appended extension to path for writefrm() to be able to reuse to function for creating .par files. - Added DBUG_PUSH("") to a a few functions that caused a lot of not critical tracing.
This commit is contained in:
@ -29,7 +29,8 @@
|
||||
#include "lock.h" // mysql_unlock_tables
|
||||
#include "strfunc.h" // find_type2, find_set
|
||||
#include "sql_truncate.h" // regenerate_locked_table
|
||||
#include "sql_partition.h" // mem_alloc_error,
|
||||
#include "ha_partition.h" // PAR_EXT
|
||||
// mem_alloc_error,
|
||||
// partition_info
|
||||
// NOT_A_PARTITION_ID
|
||||
#include "sql_db.h" // load_db_opt_by_name
|
||||
@ -1106,9 +1107,6 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
|
||||
int error= TRUE;
|
||||
char to_path[FN_REFLEN];
|
||||
char from_path[FN_REFLEN];
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
char *par_ext= (char*)".par";
|
||||
#endif
|
||||
handlerton *hton;
|
||||
DBUG_ENTER("execute_ddl_log_action");
|
||||
|
||||
@ -1162,7 +1160,7 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
|
||||
break;
|
||||
}
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
strxmov(to_path, ddl_log_entry->name, par_ext, NullS);
|
||||
strxmov(to_path, ddl_log_entry->name, PAR_EXT, NullS);
|
||||
(void) mysql_file_delete(key_file_partition_ddl_log, to_path, MYF(MY_WME));
|
||||
#endif
|
||||
}
|
||||
@ -1199,8 +1197,8 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
|
||||
if (mysql_file_rename(key_file_frm, from_path, to_path, MYF(MY_WME)))
|
||||
break;
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
strxmov(to_path, ddl_log_entry->name, par_ext, NullS);
|
||||
strxmov(from_path, ddl_log_entry->from_name, par_ext, NullS);
|
||||
strxmov(to_path, ddl_log_entry->name, PAR_EXT, NullS);
|
||||
strxmov(from_path, ddl_log_entry->from_name, PAR_EXT, NullS);
|
||||
(void) mysql_file_rename(key_file_partition_ddl_log, from_path, to_path, MYF(MY_WME));
|
||||
#endif
|
||||
}
|
||||
@ -1857,8 +1855,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
|
||||
goto end;
|
||||
}
|
||||
|
||||
int error= writefrm(shadow_path, lpt->db.str, lpt->table_name.str,
|
||||
lpt->create_info->tmp_table(), frm.str, frm.length);
|
||||
int error= writefile(shadow_frm_name, lpt->db.str, lpt->table_name.str,
|
||||
lpt->create_info->tmp_table(), frm.str, frm.length);
|
||||
my_free(const_cast<uchar*>(frm.str));
|
||||
|
||||
if (unlikely(error) ||
|
||||
@ -1895,13 +1893,13 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
|
||||
if (mysql_file_delete(key_file_frm, frm_name, MYF(MY_WME)) ||
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
lpt->table->file->ha_create_partitioning_metadata(path, shadow_path,
|
||||
CHF_DELETE_FLAG) ||
|
||||
CHF_DELETE_FLAG) ||
|
||||
deactivate_ddl_log_entry(part_info->frm_log_entry->entry_pos) ||
|
||||
(sync_ddl_log(), FALSE) ||
|
||||
mysql_file_rename(key_file_frm,
|
||||
shadow_frm_name, frm_name, MYF(MY_WME)) ||
|
||||
lpt->table->file->ha_create_partitioning_metadata(path, shadow_path,
|
||||
CHF_RENAME_FLAG))
|
||||
CHF_RENAME_FLAG))
|
||||
#else
|
||||
mysql_file_rename(key_file_frm,
|
||||
shadow_frm_name, frm_name, MYF(MY_WME)))
|
||||
@ -2499,6 +2497,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
table_type->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE)
|
||||
log_if_exists= 1;
|
||||
|
||||
thd->replication_flags= 0;
|
||||
if ((error= ha_delete_table(thd, table_type, path, &db,
|
||||
&table->table_name, !dont_log_query)))
|
||||
{
|
||||
@ -2528,6 +2527,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
DBUG_ASSERT(frm_delete_error);
|
||||
}
|
||||
}
|
||||
if (thd->replication_flags & OPTION_IF_EXISTS)
|
||||
log_if_exists= 1;
|
||||
|
||||
if (likely(!error))
|
||||
{
|
||||
@ -2769,7 +2770,7 @@ bool log_drop_table(THD *thd, const LEX_CSTRING *db_name,
|
||||
|
||||
|
||||
/**
|
||||
Quickly remove a table.
|
||||
Quickly remove a table without bin logging
|
||||
|
||||
@param thd Thread context.
|
||||
@param base The handlerton handle.
|
||||
@ -5880,7 +5881,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
||||
when the slave executes the command.
|
||||
*/
|
||||
force_generated_create=
|
||||
(((src_table->table->s->db_type()->flags &
|
||||
(((src_table->table->file->partition_ht()->flags &
|
||||
HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE) &&
|
||||
src_table->table->s->db_type() != local_create_info.db_type));
|
||||
#endif
|
||||
@ -7929,7 +7930,7 @@ static bool mysql_inplace_alter_table(THD *thd,
|
||||
|
||||
/* Notify the engine that the table definition has changed */
|
||||
|
||||
hton= table->file->ht;
|
||||
hton= table->file->partition_ht();
|
||||
if (hton->notify_tabledef_changed)
|
||||
{
|
||||
char db_buff[FN_REFLEN], table_buff[FN_REFLEN];
|
||||
@ -9815,7 +9816,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
|
||||
Alter_table_ctx alter_ctx(thd, table_list, tables_opened, new_db, new_name);
|
||||
mdl_ticket= table->mdl_ticket;
|
||||
|
||||
if (ha_check_if_updates_are_ignored(thd, table->s->db_type(), "ALTER"))
|
||||
if (table->file->check_if_updates_are_ignored("ALTER"))
|
||||
{
|
||||
/*
|
||||
Table is a shared table. Remove the .frm file. Discovery will create
|
||||
@ -9825,12 +9826,14 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
|
||||
MDL_EXCLUSIVE,
|
||||
thd->variables.lock_wait_timeout))
|
||||
DBUG_RETURN(1);
|
||||
quick_rm_table(thd, 0, &table_list->db, &table_list->table_name,
|
||||
FRM_ONLY, 0);
|
||||
quick_rm_table(thd, table->file->ht, &table_list->db,
|
||||
&table_list->table_name,
|
||||
NO_HA_TABLE, 0);
|
||||
goto end_inplace;
|
||||
}
|
||||
if (!if_exists &&
|
||||
(table->s->db_type()->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE))
|
||||
(table->file->partition_ht()->flags &
|
||||
HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE))
|
||||
{
|
||||
/*
|
||||
Table is a shared table that may not exist on the slave.
|
||||
@ -10551,8 +10554,9 @@ do_continue:;
|
||||
write the CREATE TABLE statement for the new table to the log and
|
||||
log all inserted rows to the table.
|
||||
*/
|
||||
if ((table->s->db_type()->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE) &&
|
||||
(table->s->db_type() != new_table->s->db_type()) &&
|
||||
if ((table->file->partition_ht()->flags &
|
||||
HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE) &&
|
||||
(table->file->partition_ht() != new_table->file->partition_ht()) &&
|
||||
(mysql_bin_log.is_open() &&
|
||||
(thd->variables.option_bits & OPTION_BIN_LOG)))
|
||||
{
|
||||
|
Reference in New Issue
Block a user