Move all ddl log code to ddl_log.cc and ddl_log.h
Part of prepration for: MDEV-17567 Atomic DDL No notable code changes except moving code around
This commit is contained in:
parent
a28ea028af
commit
02b6cef45e
@ -86,6 +86,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
|
||||
../sql/sql_show.cc ../sql/sql_state.c
|
||||
../sql/sql_statistics.cc ../sql/sql_string.cc
|
||||
../sql/sql_tablespace.cc ../sql/sql_table.cc ../sql/sql_test.cc
|
||||
../sql/ddl_log.cc
|
||||
../sql/sql_trigger.cc ../sql/sql_udf.cc ../sql/sql_union.cc
|
||||
../sql/sql_update.cc ../sql/sql_view.cc ../sql/sql_profile.cc
|
||||
../sql/gcalc_tools.cc ../sql/gcalc_slicescan.cc
|
||||
|
@ -122,10 +122,12 @@ SET (SQL_SOURCE
|
||||
group_by_handler.cc derived_handler.cc select_handler.cc
|
||||
sql_statistics.cc sql_string.cc lex_string.h
|
||||
sql_table.cc sql_test.cc sql_trigger.cc sql_udf.cc sql_union.cc
|
||||
ddl_log.cc ddl_log.h
|
||||
sql_update.cc sql_view.cc strfunc.cc table.cc thr_malloc.cc
|
||||
sql_time.cc tztime.cc unireg.cc item_xmlfunc.cc
|
||||
uniques.cc
|
||||
rpl_tblmap.cc sql_binlog.cc event_scheduler.cc event_data_objects.cc
|
||||
rpl_tblmap.cc sql_binlog.cc event_scheduler.cc
|
||||
event_data_objects.cc
|
||||
event_queue.cc event_db_repository.cc
|
||||
sql_tablespace.cc events.cc ../sql-common/my_user.c
|
||||
partition_info.cc rpl_utility.cc rpl_utility_server.cc
|
||||
|
1158
sql/ddl_log.cc
Normal file
1158
sql/ddl_log.cc
Normal file
File diff suppressed because it is too large
Load Diff
111
sql/ddl_log.h
Normal file
111
sql/ddl_log.h
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2020, MariaDB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
|
||||
*/
|
||||
|
||||
/* External interfaces to ddl log functions */
|
||||
|
||||
#ifndef DDL_LOG_INCLUDED
|
||||
#define DDL_LOG_INCLUDED
|
||||
|
||||
enum ddl_log_entry_code
|
||||
{
|
||||
/*
|
||||
DDL_LOG_EXECUTE_CODE:
|
||||
This is a code that indicates that this is a log entry to
|
||||
be executed, from this entry a linked list of log entries
|
||||
can be found and executed.
|
||||
DDL_LOG_ENTRY_CODE:
|
||||
An entry to be executed in a linked list from an execute log
|
||||
entry.
|
||||
DDL_IGNORE_LOG_ENTRY_CODE:
|
||||
An entry that is to be ignored
|
||||
*/
|
||||
DDL_LOG_EXECUTE_CODE = 'e',
|
||||
DDL_LOG_ENTRY_CODE = 'l',
|
||||
DDL_IGNORE_LOG_ENTRY_CODE = 'i'
|
||||
};
|
||||
|
||||
enum ddl_log_action_code
|
||||
{
|
||||
/*
|
||||
The type of action that a DDL_LOG_ENTRY_CODE entry is to
|
||||
perform.
|
||||
DDL_LOG_DELETE_ACTION:
|
||||
Delete an entity
|
||||
DDL_LOG_RENAME_ACTION:
|
||||
Rename an entity
|
||||
DDL_LOG_REPLACE_ACTION:
|
||||
Rename an entity after removing the previous entry with the
|
||||
new name, that is replace this entry.
|
||||
DDL_LOG_EXCHANGE_ACTION:
|
||||
Exchange two entities by renaming them a -> tmp, b -> a, tmp -> b.
|
||||
*/
|
||||
DDL_LOG_DELETE_ACTION = 'd',
|
||||
DDL_LOG_RENAME_ACTION = 'r',
|
||||
DDL_LOG_REPLACE_ACTION = 's',
|
||||
DDL_LOG_EXCHANGE_ACTION = 'e'
|
||||
};
|
||||
|
||||
enum enum_ddl_log_exchange_phase {
|
||||
EXCH_PHASE_NAME_TO_TEMP= 0,
|
||||
EXCH_PHASE_FROM_TO_NAME= 1,
|
||||
EXCH_PHASE_TEMP_TO_FROM= 2
|
||||
};
|
||||
|
||||
|
||||
typedef struct st_ddl_log_entry
|
||||
{
|
||||
const char *name;
|
||||
const char *from_name;
|
||||
const char *handler_name;
|
||||
const char *tmp_name;
|
||||
uint next_entry;
|
||||
uint entry_pos;
|
||||
enum ddl_log_entry_code entry_type;
|
||||
enum ddl_log_action_code action_type;
|
||||
/*
|
||||
Most actions have only one phase. REPLACE does however have two
|
||||
phases. The first phase removes the file with the new name if
|
||||
there was one there before and the second phase renames the
|
||||
old name to the new name.
|
||||
*/
|
||||
char phase;
|
||||
} DDL_LOG_ENTRY;
|
||||
|
||||
typedef struct st_ddl_log_memory_entry
|
||||
{
|
||||
uint entry_pos;
|
||||
struct st_ddl_log_memory_entry *next_log_entry;
|
||||
struct st_ddl_log_memory_entry *prev_log_entry;
|
||||
struct st_ddl_log_memory_entry *next_active_log_entry;
|
||||
} DDL_LOG_MEMORY_ENTRY;
|
||||
|
||||
|
||||
bool write_ddl_log_entry(DDL_LOG_ENTRY *ddl_log_entry,
|
||||
DDL_LOG_MEMORY_ENTRY **active_entry);
|
||||
bool write_execute_ddl_log_entry(uint first_entry,
|
||||
bool complete,
|
||||
DDL_LOG_MEMORY_ENTRY **active_entry);
|
||||
bool deactivate_ddl_log_entry(uint entry_no);
|
||||
void release_ddl_log_memory_entry(DDL_LOG_MEMORY_ENTRY *log_entry);
|
||||
bool sync_ddl_log();
|
||||
void release_ddl_log();
|
||||
void execute_ddl_log_recovery();
|
||||
bool execute_ddl_log_entry(THD *thd, uint first_entry);
|
||||
|
||||
extern mysql_mutex_t LOCK_gdl;
|
||||
#endif /* DDL_LOG_INCLUDED */
|
@ -59,6 +59,7 @@
|
||||
#include "sql_show.h" // append_identifier
|
||||
#include "sql_admin.h" // SQL_ADMIN_MSG_TEXT_SIZE
|
||||
#include "sql_select.h"
|
||||
#include "ddl_log.h"
|
||||
|
||||
#include "debug_sync.h"
|
||||
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "sql_manager.h" // stop_handle_manager, start_handle_manager
|
||||
#include "sql_expression_cache.h" // subquery_cache_miss, subquery_cache_hit
|
||||
#include "sys_vars_shared.h"
|
||||
#include "ddl_log.h"
|
||||
|
||||
#include <m_ctype.h>
|
||||
#include <my_dir.h>
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include "sql_alter.h" // Alter_table_ctx
|
||||
#include "sql_select.h"
|
||||
#include "sql_tablespace.h" // check_tablespace_name
|
||||
#include "ddl_log.h"
|
||||
#include "tztime.h" // my_tz_OFFSET0
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "ha_partition.h" // ha_partition
|
||||
#endif
|
||||
#include "sql_base.h" // open_and_lock_tables
|
||||
#include "ddl_log.h"
|
||||
|
||||
#ifndef WITH_PARTITION_STORAGE_ENGINE
|
||||
|
||||
|
1133
sql/sql_table.cc
1133
sql/sql_table.cc
File diff suppressed because it is too large
Load Diff
@ -38,80 +38,6 @@ typedef struct st_key_cache KEY_CACHE;
|
||||
typedef struct st_lock_param_type ALTER_PARTITION_PARAM_TYPE;
|
||||
typedef struct st_order ORDER;
|
||||
|
||||
enum ddl_log_entry_code
|
||||
{
|
||||
/*
|
||||
DDL_LOG_EXECUTE_CODE:
|
||||
This is a code that indicates that this is a log entry to
|
||||
be executed, from this entry a linked list of log entries
|
||||
can be found and executed.
|
||||
DDL_LOG_ENTRY_CODE:
|
||||
An entry to be executed in a linked list from an execute log
|
||||
entry.
|
||||
DDL_IGNORE_LOG_ENTRY_CODE:
|
||||
An entry that is to be ignored
|
||||
*/
|
||||
DDL_LOG_EXECUTE_CODE = 'e',
|
||||
DDL_LOG_ENTRY_CODE = 'l',
|
||||
DDL_IGNORE_LOG_ENTRY_CODE = 'i'
|
||||
};
|
||||
|
||||
enum ddl_log_action_code
|
||||
{
|
||||
/*
|
||||
The type of action that a DDL_LOG_ENTRY_CODE entry is to
|
||||
perform.
|
||||
DDL_LOG_DELETE_ACTION:
|
||||
Delete an entity
|
||||
DDL_LOG_RENAME_ACTION:
|
||||
Rename an entity
|
||||
DDL_LOG_REPLACE_ACTION:
|
||||
Rename an entity after removing the previous entry with the
|
||||
new name, that is replace this entry.
|
||||
DDL_LOG_EXCHANGE_ACTION:
|
||||
Exchange two entities by renaming them a -> tmp, b -> a, tmp -> b.
|
||||
*/
|
||||
DDL_LOG_DELETE_ACTION = 'd',
|
||||
DDL_LOG_RENAME_ACTION = 'r',
|
||||
DDL_LOG_REPLACE_ACTION = 's',
|
||||
DDL_LOG_EXCHANGE_ACTION = 'e'
|
||||
};
|
||||
|
||||
enum enum_ddl_log_exchange_phase {
|
||||
EXCH_PHASE_NAME_TO_TEMP= 0,
|
||||
EXCH_PHASE_FROM_TO_NAME= 1,
|
||||
EXCH_PHASE_TEMP_TO_FROM= 2
|
||||
};
|
||||
|
||||
|
||||
typedef struct st_ddl_log_entry
|
||||
{
|
||||
const char *name;
|
||||
const char *from_name;
|
||||
const char *handler_name;
|
||||
const char *tmp_name;
|
||||
uint next_entry;
|
||||
uint entry_pos;
|
||||
enum ddl_log_entry_code entry_type;
|
||||
enum ddl_log_action_code action_type;
|
||||
/*
|
||||
Most actions have only one phase. REPLACE does however have two
|
||||
phases. The first phase removes the file with the new name if
|
||||
there was one there before and the second phase renames the
|
||||
old name to the new name.
|
||||
*/
|
||||
char phase;
|
||||
} DDL_LOG_ENTRY;
|
||||
|
||||
typedef struct st_ddl_log_memory_entry
|
||||
{
|
||||
uint entry_pos;
|
||||
struct st_ddl_log_memory_entry *next_log_entry;
|
||||
struct st_ddl_log_memory_entry *prev_log_entry;
|
||||
struct st_ddl_log_memory_entry *next_active_log_entry;
|
||||
} DDL_LOG_MEMORY_ENTRY;
|
||||
|
||||
|
||||
enum enum_explain_filename_mode
|
||||
{
|
||||
EXPLAIN_ALL_VERBOSE= 0,
|
||||
@ -264,17 +190,6 @@ int write_bin_log(THD *thd, bool clear_error,
|
||||
bool is_trans= FALSE);
|
||||
int write_bin_log_with_if_exists(THD *thd, bool clear_error,
|
||||
bool is_trans, bool add_if_exists);
|
||||
bool write_ddl_log_entry(DDL_LOG_ENTRY *ddl_log_entry,
|
||||
DDL_LOG_MEMORY_ENTRY **active_entry);
|
||||
bool write_execute_ddl_log_entry(uint first_entry,
|
||||
bool complete,
|
||||
DDL_LOG_MEMORY_ENTRY **active_entry);
|
||||
bool deactivate_ddl_log_entry(uint entry_no);
|
||||
void release_ddl_log_memory_entry(DDL_LOG_MEMORY_ENTRY *log_entry);
|
||||
bool sync_ddl_log();
|
||||
void release_ddl_log();
|
||||
void execute_ddl_log_recovery();
|
||||
bool execute_ddl_log_entry(THD *thd, uint first_entry);
|
||||
|
||||
template<typename T> class List;
|
||||
void promote_first_timestamp_column(List<Create_field> *column_definitions);
|
||||
@ -287,7 +202,6 @@ uint explain_filename(THD* thd, const char *from, char *to, uint to_length,
|
||||
|
||||
|
||||
extern MYSQL_PLUGIN_IMPORT const LEX_CSTRING primary_key_name;
|
||||
extern mysql_mutex_t LOCK_gdl;
|
||||
|
||||
bool check_engine(THD *, const char *, const char *, HA_CREATE_INFO *);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user