MySQL 9.1.0
Source Code Documentation
|
#include "sql/sql_reload.h"
#include <stddef.h>
#include <atomic>
#include "lex_string.h"
#include "map_helpers.h"
#include "my_base.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sys.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/binlog.h"
#include "sql/conn_handler/connection_handler_impl.h"
#include "sql/current_thd.h"
#include "sql/debug_sync.h"
#include "sql/handler.h"
#include "sql/hostname_cache.h"
#include "sql/log.h"
#include "sql/mdl.h"
#include "sql/mysqld.h"
#include "sql/opt_costconstantcache.h"
#include "sql/query_options.h"
#include "sql/rpl_replica.h"
#include "sql/rpl_source.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_connect.h"
#include "sql/sql_const.h"
#include "sql/sql_servers.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "string_with_len.h"
Functions | |
bool | is_reload_request_denied (THD *thd, unsigned long op_type) |
Check the privileges required to execute a FLUSH command. More... | |
bool | handle_reload_request (THD *thd, unsigned long options, Table_ref *tables, int *write_to_binlog) |
Reload/resets privileges and the different caches. More... | |
bool | flush_tables_with_read_lock (THD *thd, Table_ref *all_tables) |
Implementation of FLUSH TABLES <table_list> WITH READ LOCK. More... | |
bool | flush_tables_for_export (THD *thd, Table_ref *all_tables) |
Prepare tables for export (transportable tablespaces) by a) waiting until write transactions/DDL operations using these tables have completed. More... | |
Prepare tables for export (transportable tablespaces) by a) waiting until write transactions/DDL operations using these tables have completed.
b) block new write operations/DDL operations on these tables.
Once this is done, notify the storage engines using handler::extra().
Finally, enter LOCK TABLES mode, so that locks are held until UNLOCK TABLES is executed.
thd | Thread handler |
all_tables | Table_ref for tables to be exported |
false | Ok |
true | Error |
Implementation of FLUSH TABLES <table_list> WITH READ LOCK.
In brief: take exclusive locks, expel tables from the table cache, reopen the tables, enter the 'LOCKED TABLES' mode, downgrade the locks. Note: the function is written to be called from mysql_execute_command(), it is not reusable in arbitrary execution context.
Since the statement implicitly enters LOCK TABLES mode, it requires LOCK TABLES privilege on every table. But since the rest of FLUSH commands require the global RELOAD_ACL, it also requires RELOAD_ACL.
We don't wait for the GRL, since neither the 5.1 combination that this new statement is intended to replace (LOCK TABLE <list> WRITE; FLUSH TABLES;), nor FLUSH TABLES WITH READ LOCK do.
Bail out: i.e. don't perform an implicit UNLOCK TABLES. This is not consistent with LOCK TABLES statement, but is in line with behaviour of FLUSH TABLES WITH READ LOCK, and we try to not introduce any new statements with implicit semantics.
As a result, we will wait for all open transactions against the tables to complete. After the lock downgrade, new transactions will be able to read the tables, but not write to them.
You can only apply this command to existing base tables. If a view with such name exists, ER_WRONG_OBJECT is returned. If a temporary table with such name exists, it's ignored: if there is a base table, it's used, otherwise ER_NO_SUCH_TABLE is returned.
For MERGE table this statement will open and lock child tables for read (it is impossible to lock parent table without it). Child tables won't be flushed unless they are explicitly present in the statement's table list.
This statement causes an implicit commit before and after it.
If this connection has HANDLERs open against some of the tables being FLUSHed, these handlers are implicitly flushed (lose their position).
bool handle_reload_request | ( | THD * | thd, |
unsigned long | options, | ||
Table_ref * | tables, | ||
int * | write_to_binlog | ||
) |
Reload/resets privileges and the different caches.
thd | Thread handler (can be NULL!) |
options | What should be reset/reloaded (tables, privileges, slave...) |
tables | Tables to flush (if any) |
write_to_binlog | < 0 if there was an error while interacting with the binary log inside handle_reload_request, 0 if we should not write to the binary log, > 0 if we can write to the binlog. |
0 | Ok |
!=0 | Error; thd->killed is set or thd->is_error() is true |
bool is_reload_request_denied | ( | THD * | thd, |
unsigned long | op_type | ||
) |
Check the privileges required to execute a FLUSH command.
Generally checks for RELOAD_ACL. But for some sub-commands it does accept alternative privs too. Or warns about deprecated commands.
thd | the current thread |
op_type | a bitmask of COM_REFRESH Flags |
false | if granted |
true | if denied |