mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Simple cleanups (no logic changes)
This commit is contained in:
parent
9207a838ed
commit
ae58cd6b87
12 changed files with 50 additions and 75 deletions
|
@ -9972,7 +9972,7 @@ void do_get_replace(struct st_command *command)
|
|||
char *buff, *start;
|
||||
char word_end_chars[256], *pos;
|
||||
POINTER_ARRAY to_array, from_array;
|
||||
DBUG_ENTER("get_replace");
|
||||
DBUG_ENTER("do_get_replace");
|
||||
|
||||
free_replace();
|
||||
|
||||
|
|
|
@ -683,7 +683,7 @@ int ha_init()
|
|||
binary log (which is considered a transaction-capable storage engine in
|
||||
counting total_ha)
|
||||
*/
|
||||
opt_using_transactions= total_ha>(ulong)opt_bin_log;
|
||||
opt_using_transactions= total_ha > (ulong) opt_bin_log;
|
||||
savepoint_alloc_size+= sizeof(SAVEPOINT);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
@ -693,7 +693,6 @@ int ha_end()
|
|||
int error= 0;
|
||||
DBUG_ENTER("ha_end");
|
||||
|
||||
|
||||
/*
|
||||
This should be eventualy based on the graceful shutdown flag.
|
||||
So if flag is equal to HA_PANIC_CLOSE, the deallocate
|
||||
|
@ -6870,6 +6869,10 @@ int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info)
|
|||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
VERSIONING functions
|
||||
******************************************************************************/
|
||||
|
||||
bool Vers_parse_info::is_start(const char *name) const
|
||||
{
|
||||
DBUG_ASSERT(name);
|
||||
|
|
15
sql/mdl.cc
15
sql/mdl.cc
|
@ -1368,17 +1368,23 @@ void MDL_lock::reschedule_waiters()
|
|||
|
||||
/**
|
||||
Compatibility (or rather "incompatibility") matrices for scoped metadata
|
||||
lock. Arrays of bitmaps which elements specify which granted/waiting locks
|
||||
lock.
|
||||
Scoped locks are GLOBAL READ LOCK, COMMIT and database (or schema) locks.
|
||||
Arrays of bitmaps which elements specify which granted/waiting locks
|
||||
are incompatible with type of lock being requested.
|
||||
|
||||
The first array specifies if particular type of request can be satisfied
|
||||
if there is granted scoped lock of certain type.
|
||||
|
||||
(*) Since intention shared scoped locks (IS) are compatible with all other
|
||||
type of locks, they don't need to be implemented and there is no code
|
||||
for them.
|
||||
|
||||
| Type of active |
|
||||
Request | scoped lock |
|
||||
type | IS(*) IX S X |
|
||||
---------+------------------+
|
||||
IS | + + + + |
|
||||
IS(*) | + + + + |
|
||||
IX | + + - - |
|
||||
S | + - + - |
|
||||
X | + - - - |
|
||||
|
@ -1391,7 +1397,7 @@ void MDL_lock::reschedule_waiters()
|
|||
Request | scoped lock |
|
||||
type | IS(*) IX S X |
|
||||
---------+-----------------+
|
||||
IS | + + + + |
|
||||
IS(*) | + + + + |
|
||||
IX | + + - - |
|
||||
S | + + + - |
|
||||
X | + + + + |
|
||||
|
@ -1399,9 +1405,6 @@ void MDL_lock::reschedule_waiters()
|
|||
Here: "+" -- means that request can be satisfied
|
||||
"-" -- means that request can't be satisfied and should wait
|
||||
|
||||
(*) Since intention shared scoped locks are compatible with all other
|
||||
type of locks we don't even have any accounting for them.
|
||||
|
||||
Note that relation between scoped locks and objects locks requested
|
||||
by statement is not straightforward and is therefore fully defined
|
||||
by SQL-layer.
|
||||
|
|
28
sql/mdl.h
28
sql/mdl.h
|
@ -112,19 +112,25 @@ public:
|
|||
|
||||
@sa Comments for MDL_object_lock::can_grant_lock() and
|
||||
MDL_scoped_lock::can_grant_lock() for details.
|
||||
|
||||
Scoped locks are GLOBAL READ LOCK, COMMIT and database (or schema) locks.
|
||||
The object locks are for tables, triggers etc.
|
||||
*/
|
||||
|
||||
enum enum_mdl_type {
|
||||
/*
|
||||
An intention exclusive metadata lock. Used only for scoped locks.
|
||||
An intention exclusive metadata lock (IX). Used only for scoped locks.
|
||||
Owner of this type of lock can acquire upgradable exclusive locks on
|
||||
individual objects.
|
||||
Compatible with other IX locks, but is incompatible with scoped S and
|
||||
X locks.
|
||||
IX lock is taken in SCHEMA namespace when we intend to modify
|
||||
object metadata. Object may refer table, stored procedure, trigger,
|
||||
view/etc.
|
||||
*/
|
||||
MDL_INTENTION_EXCLUSIVE= 0,
|
||||
/*
|
||||
A shared metadata lock.
|
||||
A shared metadata lock (S).
|
||||
To be used in cases when we are interested in object metadata only
|
||||
and there is no intention to access object data (e.g. for stored
|
||||
routines or during preparing prepared statements).
|
||||
|
@ -144,6 +150,9 @@ enum enum_mdl_type {
|
|||
use SNRW locks for them. It also does not arise when S locks are used
|
||||
during PREPARE calls as table-level locks are not acquired in this
|
||||
case.
|
||||
This lock is taken for global read lock, when caching a stored
|
||||
procedure in memory for the duration of the transaction and for
|
||||
tables used by prepared statements.
|
||||
*/
|
||||
MDL_SHARED,
|
||||
/*
|
||||
|
@ -164,8 +173,8 @@ enum enum_mdl_type {
|
|||
*/
|
||||
MDL_SHARED_HIGH_PRIO,
|
||||
/*
|
||||
A shared metadata lock for cases when there is an intention to read data
|
||||
from table.
|
||||
A shared metadata lock (SR) for cases when there is an intention to read
|
||||
data from table.
|
||||
A connection holding this kind of lock can read table metadata and read
|
||||
table data (after acquiring appropriate table and row-level locks).
|
||||
This means that one can only acquire TL_READ, TL_READ_NO_INSERT, and
|
||||
|
@ -175,7 +184,7 @@ enum enum_mdl_type {
|
|||
*/
|
||||
MDL_SHARED_READ,
|
||||
/*
|
||||
A shared metadata lock for cases when there is an intention to modify
|
||||
A shared metadata lock (SW) for cases when there is an intention to modify
|
||||
(and not just read) data in the table.
|
||||
A connection holding SW lock can read table metadata and modify or read
|
||||
table data (after acquiring appropriate table and row-level locks).
|
||||
|
@ -185,8 +194,8 @@ enum enum_mdl_type {
|
|||
*/
|
||||
MDL_SHARED_WRITE,
|
||||
/*
|
||||
An upgradable shared metadata lock for cases when there is an intention
|
||||
to modify (and not just read) data in the table.
|
||||
An upgradable shared metadata lock for cases when there is an
|
||||
intention to modify (and not just read) data in the table.
|
||||
Can be upgraded to MDL_SHARED_NO_WRITE and MDL_EXCLUSIVE.
|
||||
A connection holding SU lock can read table metadata and modify or read
|
||||
table data (after acquiring appropriate table and row-level locks).
|
||||
|
@ -226,7 +235,7 @@ enum enum_mdl_type {
|
|||
*/
|
||||
MDL_SHARED_NO_READ_WRITE,
|
||||
/*
|
||||
An exclusive metadata lock.
|
||||
An exclusive metadata lock (X).
|
||||
A connection holding this lock can modify both table's metadata and data.
|
||||
No other type of metadata lock can be granted while this lock is held.
|
||||
To be used for CREATE/DROP/RENAME TABLE statements and for execution of
|
||||
|
@ -234,7 +243,8 @@ enum enum_mdl_type {
|
|||
*/
|
||||
MDL_EXCLUSIVE,
|
||||
/* This should be the last !!! */
|
||||
MDL_TYPE_END};
|
||||
MDL_TYPE_END
|
||||
};
|
||||
|
||||
|
||||
/** Duration of metadata lock. */
|
||||
|
|
|
@ -467,7 +467,8 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables,
|
|||
{
|
||||
if (thd->killed)
|
||||
break;
|
||||
if (tdc_wait_for_old_version(thd, table->db.str, table->table_name.str, timeout,
|
||||
if (tdc_wait_for_old_version(thd, table->db.str, table->table_name.str,
|
||||
timeout,
|
||||
MDL_wait_for_subgraph::DEADLOCK_WEIGHT_DDL,
|
||||
refresh_version))
|
||||
{
|
||||
|
@ -487,6 +488,7 @@ err_with_reopen:
|
|||
*/
|
||||
if (thd->locked_tables_list.reopen_tables(thd, false))
|
||||
result= true;
|
||||
|
||||
/*
|
||||
Since downgrade_lock() won't do anything with shared
|
||||
metadata lock it is much simpler to go through all open tables rather
|
||||
|
@ -632,7 +634,7 @@ static void mark_used_tables_as_free_for_reuse(THD *thd, TABLE *table)
|
|||
- The table is marked as closed in the
|
||||
locked_table_list but kept there so one can call
|
||||
locked_table_list->reopen_tables() to put it back.
|
||||
|
||||
|
||||
In case of drop/rename the documented behavior is to
|
||||
implicitly remove the table from LOCK TABLES
|
||||
list.
|
||||
|
@ -1891,7 +1893,6 @@ retry_share:
|
|||
if (mysql_make_view(thd, share, table_list, false))
|
||||
goto err_lock;
|
||||
|
||||
|
||||
/* TODO: Don't free this */
|
||||
tdc_release_share(share);
|
||||
|
||||
|
@ -1965,7 +1966,6 @@ retry_share:
|
|||
else
|
||||
{
|
||||
enum open_frm_error error;
|
||||
|
||||
/* make a new table */
|
||||
if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))
|
||||
goto err_lock;
|
||||
|
@ -3805,6 +3805,8 @@ lock_table_names(THD *thd, const DDL_options_st &options,
|
|||
for (table= tables_start; table && table != tables_end;
|
||||
table= table->next_global)
|
||||
{
|
||||
DBUG_PRINT("info", ("mdl_request.type: %d open_type: %d",
|
||||
table->mdl_request.type, table->open_type));
|
||||
if (table->mdl_request.type < MDL_SHARED_UPGRADABLE ||
|
||||
table->mdl_request.type == MDL_SHARED_READ_ONLY ||
|
||||
table->open_type == OT_TEMPORARY_ONLY ||
|
||||
|
|
|
@ -288,10 +288,6 @@ TABLE *open_system_table_for_update(THD *thd, TABLE_LIST *one_table);
|
|||
TABLE *open_log_table(THD *thd, TABLE_LIST *one_table, Open_tables_backup *backup);
|
||||
void close_log_table(THD *thd, Open_tables_backup *backup);
|
||||
|
||||
TABLE *open_performance_schema_table(THD *thd, TABLE_LIST *one_table,
|
||||
Open_tables_state *backup);
|
||||
void close_performance_schema_table(THD *thd, Open_tables_state *backup);
|
||||
|
||||
bool close_cached_tables(THD *thd, TABLE_LIST *tables,
|
||||
bool wait_for_refresh, ulong timeout);
|
||||
bool close_cached_connection_tables(THD *thd, LEX_CSTRING *connect_string);
|
||||
|
|
|
@ -276,8 +276,8 @@ functions:
|
|||
- Called before parsing and used to match a statement with the stored
|
||||
queries hash.
|
||||
If a match is found the cached result set is sent through repeated
|
||||
calls to net_real_write. (note: calling thread doesn't have a regis-
|
||||
tered result set writer: thd->net.query_cache_query=0)
|
||||
calls to net_real_write. (note: calling thread does not have a
|
||||
registered result set writer: thd->net.query_cache_query=0)
|
||||
2. Query_cache::store_query
|
||||
- Called just before handle_select() and is used to register a result
|
||||
set writer to the statement currently being processed
|
||||
|
|
|
@ -10541,7 +10541,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
|||
|
||||
if (!cleanup_done)
|
||||
{
|
||||
/* This happens if we get an error during initialzation of data */
|
||||
/* This happens if we get an error during initialization of data */
|
||||
DBUG_ASSERT(error);
|
||||
to->file->ha_end_bulk_insert();
|
||||
ha_enable_transaction(thd, TRUE);
|
||||
|
|
|
@ -232,7 +232,7 @@ static void intern_close_table(TABLE *table)
|
|||
uint tc_records(void)
|
||||
{
|
||||
ulong total= 0;
|
||||
for (ulong i= 0; i < tc_instances; i++)
|
||||
for (uint32 i= 0; i < tc_instances; i++)
|
||||
{
|
||||
mysql_mutex_lock(&tc[i].LOCK_table_cache);
|
||||
total+= tc[i].records;
|
||||
|
@ -277,7 +277,7 @@ static void tc_remove_all_unused_tables(TDC_element *element,
|
|||
*/
|
||||
if (mark_flushed)
|
||||
element->flushed= true;
|
||||
for (ulong i= 0; i < tc_instances; i++)
|
||||
for (uint32 i= 0; i < tc_instances; i++)
|
||||
{
|
||||
mysql_mutex_lock(&tc[i].LOCK_table_cache);
|
||||
while ((table= element->free_tables[i].list.pop_front()))
|
||||
|
@ -491,7 +491,7 @@ static void tdc_assert_clean_share(TDC_element *element)
|
|||
DBUG_ASSERT(element->m_flush_tickets.is_empty());
|
||||
DBUG_ASSERT(element->all_tables.is_empty());
|
||||
#ifndef DBUG_OFF
|
||||
for (ulong i= 0; i < tc_instances; i++)
|
||||
for (uint32 i= 0; i < tc_instances; i++)
|
||||
DBUG_ASSERT(element->free_tables[i].list.is_empty());
|
||||
#endif
|
||||
DBUG_ASSERT(element->all_tables_refs == 0);
|
||||
|
@ -564,7 +564,7 @@ static void lf_alloc_constructor(uchar *arg)
|
|||
mysql_cond_init(key_TABLE_SHARE_COND_release, &element->COND_release, 0);
|
||||
element->m_flush_tickets.empty();
|
||||
element->all_tables.empty();
|
||||
for (ulong i= 0; i < tc_instances; i++)
|
||||
for (uint32 i= 0; i < tc_instances; i++)
|
||||
element->free_tables[i].list.empty();
|
||||
element->all_tables_refs= 0;
|
||||
element->share= 0;
|
||||
|
|
|
@ -5,43 +5,4 @@
|
|||
#include "sql_class.h"
|
||||
#include "vers_string.h"
|
||||
|
||||
class MDL_auto_lock
|
||||
{
|
||||
THD *thd;
|
||||
TABLE_LIST &table;
|
||||
bool error;
|
||||
|
||||
public:
|
||||
MDL_auto_lock(THD *_thd, TABLE_LIST &_table) :
|
||||
thd(_thd), table(_table)
|
||||
{
|
||||
DBUG_ASSERT(thd);
|
||||
MDL_request protection_request;
|
||||
if (thd->global_read_lock.can_acquire_protection())
|
||||
{
|
||||
error= true;
|
||||
return;
|
||||
}
|
||||
protection_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE,
|
||||
MDL_EXPLICIT);
|
||||
error= thd->mdl_context.acquire_lock(&protection_request, thd->variables.lock_wait_timeout);
|
||||
if (error)
|
||||
return;
|
||||
|
||||
table.mdl_request.init(MDL_key::TABLE, table.db.str, table.table_name.str, MDL_EXCLUSIVE, MDL_EXPLICIT);
|
||||
error= thd->mdl_context.acquire_lock(&table.mdl_request, thd->variables.lock_wait_timeout);
|
||||
thd->mdl_context.release_lock(protection_request.ticket);
|
||||
}
|
||||
~MDL_auto_lock()
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
DBUG_ASSERT(table.mdl_request.ticket);
|
||||
thd->mdl_context.release_lock(table.mdl_request.ticket);
|
||||
table.mdl_request.ticket= NULL;
|
||||
}
|
||||
}
|
||||
bool acquire_error() const { return error; }
|
||||
};
|
||||
|
||||
#endif // VERS_UTILS_INCLUDED
|
||||
|
|
|
@ -1266,7 +1266,7 @@ wait_signal:
|
|||
mysql_mutex_unlock(mysql_bin_log.get_log_lock());
|
||||
}
|
||||
sst_disallow_writes (thd.ptr, false);
|
||||
thd.ptr->global_read_lock.unlock_global_read_lock (thd.ptr);
|
||||
thd.ptr->global_read_lock.unlock_global_read_lock(thd.ptr);
|
||||
locked= false;
|
||||
}
|
||||
err= 0;
|
||||
|
@ -1303,7 +1303,7 @@ wait_signal:
|
|||
mysql_mutex_unlock(mysql_bin_log.get_log_lock());
|
||||
}
|
||||
sst_disallow_writes (thd.ptr, false);
|
||||
thd.ptr->global_read_lock.unlock_global_read_lock (thd.ptr);
|
||||
thd.ptr->global_read_lock.unlock_global_read_lock(thd.ptr);
|
||||
}
|
||||
|
||||
// signal to donor that SST is over
|
||||
|
|
|
@ -352,7 +352,7 @@ void mdev17133()
|
|||
// random size 2nd read
|
||||
res= my_b_read(&info, buf_i + total + MY_MIN(19, curr_read_size),
|
||||
19 >= curr_read_size ? 0 : curr_read_size - 19);
|
||||
ok(res == 0, "rest of read %lu", curr_read_size - 19);
|
||||
ok(res == 0, "rest of read %lu", (ulong) (curr_read_size - 19));
|
||||
// mark read bytes in the used part of the cache buffer
|
||||
memset(info.buffer, 0, info.read_pos - info.buffer);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue