Skip to content

Commit ae58cd6

Browse files
committed
Simple cleanups (no logic changes)
1 parent 9207a83 commit ae58cd6

File tree

12 files changed

+50
-75
lines changed

12 files changed

+50
-75
lines changed

client/mysqltest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9972,7 +9972,7 @@ void do_get_replace(struct st_command *command)
99729972
char *buff, *start;
99739973
char word_end_chars[256], *pos;
99749974
POINTER_ARRAY to_array, from_array;
9975-
DBUG_ENTER("get_replace");
9975+
DBUG_ENTER("do_get_replace");
99769976

99779977
free_replace();
99789978

sql/handler.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ int ha_init()
683683
binary log (which is considered a transaction-capable storage engine in
684684
counting total_ha)
685685
*/
686-
opt_using_transactions= total_ha>(ulong)opt_bin_log;
686+
opt_using_transactions= total_ha > (ulong) opt_bin_log;
687687
savepoint_alloc_size+= sizeof(SAVEPOINT);
688688
DBUG_RETURN(error);
689689
}
@@ -693,7 +693,6 @@ int ha_end()
693693
int error= 0;
694694
DBUG_ENTER("ha_end");
695695

696-
697696
/*
698697
This should be eventualy based on the graceful shutdown flag.
699698
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)
68706869
DBUG_RETURN(res);
68716870
}
68726871

6872+
/*****************************************************************************
6873+
VERSIONING functions
6874+
******************************************************************************/
6875+
68736876
bool Vers_parse_info::is_start(const char *name) const
68746877
{
68756878
DBUG_ASSERT(name);

sql/mdl.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,17 +1368,23 @@ void MDL_lock::reschedule_waiters()
13681368

13691369
/**
13701370
Compatibility (or rather "incompatibility") matrices for scoped metadata
1371-
lock. Arrays of bitmaps which elements specify which granted/waiting locks
1371+
lock.
1372+
Scoped locks are GLOBAL READ LOCK, COMMIT and database (or schema) locks.
1373+
Arrays of bitmaps which elements specify which granted/waiting locks
13721374
are incompatible with type of lock being requested.
13731375
13741376
The first array specifies if particular type of request can be satisfied
13751377
if there is granted scoped lock of certain type.
13761378
1379+
(*) Since intention shared scoped locks (IS) are compatible with all other
1380+
type of locks, they don't need to be implemented and there is no code
1381+
for them.
1382+
13771383
| Type of active |
13781384
Request | scoped lock |
13791385
type | IS(*) IX S X |
13801386
---------+------------------+
1381-
IS | + + + + |
1387+
IS(*) | + + + + |
13821388
IX | + + - - |
13831389
S | + - + - |
13841390
X | + - - - |
@@ -1391,17 +1397,14 @@ void MDL_lock::reschedule_waiters()
13911397
Request | scoped lock |
13921398
type | IS(*) IX S X |
13931399
---------+-----------------+
1394-
IS | + + + + |
1400+
IS(*) | + + + + |
13951401
IX | + + - - |
13961402
S | + + + - |
13971403
X | + + + + |
13981404
13991405
Here: "+" -- means that request can be satisfied
14001406
"-" -- means that request can't be satisfied and should wait
14011407
1402-
(*) Since intention shared scoped locks are compatible with all other
1403-
type of locks we don't even have any accounting for them.
1404-
14051408
Note that relation between scoped locks and objects locks requested
14061409
by statement is not straightforward and is therefore fully defined
14071410
by SQL-layer.

sql/mdl.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,25 @@ class MDL_context_owner
112112
113113
@sa Comments for MDL_object_lock::can_grant_lock() and
114114
MDL_scoped_lock::can_grant_lock() for details.
115+
116+
Scoped locks are GLOBAL READ LOCK, COMMIT and database (or schema) locks.
117+
The object locks are for tables, triggers etc.
115118
*/
116119

117120
enum enum_mdl_type {
118121
/*
119-
An intention exclusive metadata lock. Used only for scoped locks.
122+
An intention exclusive metadata lock (IX). Used only for scoped locks.
120123
Owner of this type of lock can acquire upgradable exclusive locks on
121124
individual objects.
122125
Compatible with other IX locks, but is incompatible with scoped S and
123126
X locks.
127+
IX lock is taken in SCHEMA namespace when we intend to modify
128+
object metadata. Object may refer table, stored procedure, trigger,
129+
view/etc.
124130
*/
125131
MDL_INTENTION_EXCLUSIVE= 0,
126132
/*
127-
A shared metadata lock.
133+
A shared metadata lock (S).
128134
To be used in cases when we are interested in object metadata only
129135
and there is no intention to access object data (e.g. for stored
130136
routines or during preparing prepared statements).
@@ -144,6 +150,9 @@ enum enum_mdl_type {
144150
use SNRW locks for them. It also does not arise when S locks are used
145151
during PREPARE calls as table-level locks are not acquired in this
146152
case.
153+
This lock is taken for global read lock, when caching a stored
154+
procedure in memory for the duration of the transaction and for
155+
tables used by prepared statements.
147156
*/
148157
MDL_SHARED,
149158
/*
@@ -164,8 +173,8 @@ enum enum_mdl_type {
164173
*/
165174
MDL_SHARED_HIGH_PRIO,
166175
/*
167-
A shared metadata lock for cases when there is an intention to read data
168-
from table.
176+
A shared metadata lock (SR) for cases when there is an intention to read
177+
data from table.
169178
A connection holding this kind of lock can read table metadata and read
170179
table data (after acquiring appropriate table and row-level locks).
171180
This means that one can only acquire TL_READ, TL_READ_NO_INSERT, and
@@ -175,7 +184,7 @@ enum enum_mdl_type {
175184
*/
176185
MDL_SHARED_READ,
177186
/*
178-
A shared metadata lock for cases when there is an intention to modify
187+
A shared metadata lock (SW) for cases when there is an intention to modify
179188
(and not just read) data in the table.
180189
A connection holding SW lock can read table metadata and modify or read
181190
table data (after acquiring appropriate table and row-level locks).
@@ -185,8 +194,8 @@ enum enum_mdl_type {
185194
*/
186195
MDL_SHARED_WRITE,
187196
/*
188-
An upgradable shared metadata lock for cases when there is an intention
189-
to modify (and not just read) data in the table.
197+
An upgradable shared metadata lock for cases when there is an
198+
intention to modify (and not just read) data in the table.
190199
Can be upgraded to MDL_SHARED_NO_WRITE and MDL_EXCLUSIVE.
191200
A connection holding SU lock can read table metadata and modify or read
192201
table data (after acquiring appropriate table and row-level locks).
@@ -226,15 +235,16 @@ enum enum_mdl_type {
226235
*/
227236
MDL_SHARED_NO_READ_WRITE,
228237
/*
229-
An exclusive metadata lock.
238+
An exclusive metadata lock (X).
230239
A connection holding this lock can modify both table's metadata and data.
231240
No other type of metadata lock can be granted while this lock is held.
232241
To be used for CREATE/DROP/RENAME TABLE statements and for execution of
233242
certain phases of other DDL statements.
234243
*/
235244
MDL_EXCLUSIVE,
236245
/* This should be the last !!! */
237-
MDL_TYPE_END};
246+
MDL_TYPE_END
247+
};
238248

239249

240250
/** Duration of metadata lock. */

sql/sql_base.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables,
467467
{
468468
if (thd->killed)
469469
break;
470-
if (tdc_wait_for_old_version(thd, table->db.str, table->table_name.str, timeout,
470+
if (tdc_wait_for_old_version(thd, table->db.str, table->table_name.str,
471+
timeout,
471472
MDL_wait_for_subgraph::DEADLOCK_WEIGHT_DDL,
472473
refresh_version))
473474
{
@@ -487,6 +488,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables,
487488
*/
488489
if (thd->locked_tables_list.reopen_tables(thd, false))
489490
result= true;
491+
490492
/*
491493
Since downgrade_lock() won't do anything with shared
492494
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)
632634
- The table is marked as closed in the
633635
locked_table_list but kept there so one can call
634636
locked_table_list->reopen_tables() to put it back.
635-
637+
636638
In case of drop/rename the documented behavior is to
637639
implicitly remove the table from LOCK TABLES
638640
list.
@@ -1891,7 +1893,6 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
18911893
if (mysql_make_view(thd, share, table_list, false))
18921894
goto err_lock;
18931895

1894-
18951896
/* TODO: Don't free this */
18961897
tdc_release_share(share);
18971898

@@ -1965,7 +1966,6 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
19651966
else
19661967
{
19671968
enum open_frm_error error;
1968-
19691969
/* make a new table */
19701970
if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))
19711971
goto err_lock;
@@ -3805,6 +3805,8 @@ lock_table_names(THD *thd, const DDL_options_st &options,
38053805
for (table= tables_start; table && table != tables_end;
38063806
table= table->next_global)
38073807
{
3808+
DBUG_PRINT("info", ("mdl_request.type: %d open_type: %d",
3809+
table->mdl_request.type, table->open_type));
38083810
if (table->mdl_request.type < MDL_SHARED_UPGRADABLE ||
38093811
table->mdl_request.type == MDL_SHARED_READ_ONLY ||
38103812
table->open_type == OT_TEMPORARY_ONLY ||

sql/sql_base.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,6 @@ TABLE *open_system_table_for_update(THD *thd, TABLE_LIST *one_table);
288288
TABLE *open_log_table(THD *thd, TABLE_LIST *one_table, Open_tables_backup *backup);
289289
void close_log_table(THD *thd, Open_tables_backup *backup);
290290

291-
TABLE *open_performance_schema_table(THD *thd, TABLE_LIST *one_table,
292-
Open_tables_state *backup);
293-
void close_performance_schema_table(THD *thd, Open_tables_state *backup);
294-
295291
bool close_cached_tables(THD *thd, TABLE_LIST *tables,
296292
bool wait_for_refresh, ulong timeout);
297293
bool close_cached_connection_tables(THD *thd, LEX_CSTRING *connect_string);

sql/sql_cache.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ The query cache interfaces with the rest of the server code through 7
276276
- Called before parsing and used to match a statement with the stored
277277
queries hash.
278278
If a match is found the cached result set is sent through repeated
279-
calls to net_real_write. (note: calling thread doesn't have a regis-
280-
tered result set writer: thd->net.query_cache_query=0)
279+
calls to net_real_write. (note: calling thread does not have a
280+
registered result set writer: thd->net.query_cache_query=0)
281281
2. Query_cache::store_query
282282
- Called just before handle_select() and is used to register a result
283283
set writer to the statement currently being processed

sql/sql_table.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10541,7 +10541,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
1054110541

1054210542
if (!cleanup_done)
1054310543
{
10544-
/* This happens if we get an error during initialzation of data */
10544+
/* This happens if we get an error during initialization of data */
1054510545
DBUG_ASSERT(error);
1054610546
to->file->ha_end_bulk_insert();
1054710547
ha_enable_transaction(thd, TRUE);

sql/table_cache.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static void intern_close_table(TABLE *table)
232232
uint tc_records(void)
233233
{
234234
ulong total= 0;
235-
for (ulong i= 0; i < tc_instances; i++)
235+
for (uint32 i= 0; i < tc_instances; i++)
236236
{
237237
mysql_mutex_lock(&tc[i].LOCK_table_cache);
238238
total+= tc[i].records;
@@ -277,7 +277,7 @@ static void tc_remove_all_unused_tables(TDC_element *element,
277277
*/
278278
if (mark_flushed)
279279
element->flushed= true;
280-
for (ulong i= 0; i < tc_instances; i++)
280+
for (uint32 i= 0; i < tc_instances; i++)
281281
{
282282
mysql_mutex_lock(&tc[i].LOCK_table_cache);
283283
while ((table= element->free_tables[i].list.pop_front()))
@@ -491,7 +491,7 @@ static void tdc_assert_clean_share(TDC_element *element)
491491
DBUG_ASSERT(element->m_flush_tickets.is_empty());
492492
DBUG_ASSERT(element->all_tables.is_empty());
493493
#ifndef DBUG_OFF
494-
for (ulong i= 0; i < tc_instances; i++)
494+
for (uint32 i= 0; i < tc_instances; i++)
495495
DBUG_ASSERT(element->free_tables[i].list.is_empty());
496496
#endif
497497
DBUG_ASSERT(element->all_tables_refs == 0);
@@ -564,7 +564,7 @@ static void lf_alloc_constructor(uchar *arg)
564564
mysql_cond_init(key_TABLE_SHARE_COND_release, &element->COND_release, 0);
565565
element->m_flush_tickets.empty();
566566
element->all_tables.empty();
567-
for (ulong i= 0; i < tc_instances; i++)
567+
for (uint32 i= 0; i < tc_instances; i++)
568568
element->free_tables[i].list.empty();
569569
element->all_tables_refs= 0;
570570
element->share= 0;

sql/vers_utils.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,4 @@
55
#include "sql_class.h"
66
#include "vers_string.h"
77

8-
class MDL_auto_lock
9-
{
10-
THD *thd;
11-
TABLE_LIST &table;
12-
bool error;
13-
14-
public:
15-
MDL_auto_lock(THD *_thd, TABLE_LIST &_table) :
16-
thd(_thd), table(_table)
17-
{
18-
DBUG_ASSERT(thd);
19-
MDL_request protection_request;
20-
if (thd->global_read_lock.can_acquire_protection())
21-
{
22-
error= true;
23-
return;
24-
}
25-
protection_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE,
26-
MDL_EXPLICIT);
27-
error= thd->mdl_context.acquire_lock(&protection_request, thd->variables.lock_wait_timeout);
28-
if (error)
29-
return;
30-
31-
table.mdl_request.init(MDL_key::TABLE, table.db.str, table.table_name.str, MDL_EXCLUSIVE, MDL_EXPLICIT);
32-
error= thd->mdl_context.acquire_lock(&table.mdl_request, thd->variables.lock_wait_timeout);
33-
thd->mdl_context.release_lock(protection_request.ticket);
34-
}
35-
~MDL_auto_lock()
36-
{
37-
if (!error)
38-
{
39-
DBUG_ASSERT(table.mdl_request.ticket);
40-
thd->mdl_context.release_lock(table.mdl_request.ticket);
41-
table.mdl_request.ticket= NULL;
42-
}
43-
}
44-
bool acquire_error() const { return error; }
45-
};
46-
478
#endif // VERS_UTILS_INCLUDED

0 commit comments

Comments
 (0)