Skip to content

Commit 7bf9187

Browse files
committed
Bug#30112842: REMOVE DEAD CODE IDENTIFIED BY FASTCOV [noclose]
Remove dead code from sql. Change-Id: I55a210526eaff0595977e4380351c5cf9217e483
1 parent 9f20262 commit 7bf9187

16 files changed

+2
-316
lines changed

Diff for: sql/binlog.cc

-25
Original file line numberDiff line numberDiff line change
@@ -2248,31 +2248,6 @@ bool Stage_manager::Mutex_queue::append(THD *first) {
22482248
return empty;
22492249
}
22502250

2251-
std::pair<bool, THD *> Stage_manager::Mutex_queue::pop_front() {
2252-
DBUG_TRACE;
2253-
lock();
2254-
THD *result = m_first;
2255-
bool more = true;
2256-
/*
2257-
We do not set next_to_commit to NULL here since this is only used
2258-
in the flush stage. We will have to call fetch_queue last here,
2259-
and will then "cut" the linked list by setting the end of that
2260-
queue to NULL.
2261-
*/
2262-
if (result) m_first = result->next_to_commit;
2263-
if (m_first == nullptr) {
2264-
more = false;
2265-
m_last = &m_first;
2266-
}
2267-
DBUG_ASSERT(m_size.load() > 0);
2268-
--m_size;
2269-
DBUG_ASSERT(m_first || m_last == &m_first);
2270-
unlock();
2271-
DBUG_PRINT("return",
2272-
("result: 0x%llx, more: %s", (ulonglong)result, YESNO(more)));
2273-
return std::make_pair(more, result);
2274-
}
2275-
22762251
bool Stage_manager::enroll_for(StageID stage, THD *thd,
22772252
mysql_mutex_t *stage_mutex) {
22782253
// If the queue was empty: we're the leader for this batch

Diff for: sql/binlog.h

-4
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,6 @@ class Stage_manager {
213213
*/
214214
bool enroll_for(StageID stage, THD *first, mysql_mutex_t *stage_mutex);
215215

216-
std::pair<bool, THD *> pop_front(StageID stage) {
217-
return m_queue[stage].pop_front();
218-
}
219-
220216
#ifndef DBUG_OFF
221217
/**
222218
The method ensures the follower's execution path can be preempted

Diff for: sql/handler.cc

-29
Original file line numberDiff line numberDiff line change
@@ -1512,35 +1512,6 @@ int commit_owned_gtids(THD *thd, bool all, bool *need_clear_owned_gtid_ptr) {
15121512
return error;
15131513
}
15141514

1515-
/**
1516-
The function is a wrapper of commit_owned_gtids(...). It is invoked
1517-
at committing a partially failed statement or transaction.
1518-
1519-
@param thd Thread context.
1520-
1521-
@retval -1 if error when persisting owned gtid.
1522-
@retval 0 if succeed to commit owned gtid.
1523-
@retval 1 if do not meet conditions to commit owned gtid.
1524-
*/
1525-
int commit_owned_gtid_by_partial_command(THD *thd) {
1526-
DBUG_TRACE;
1527-
bool need_clear_owned_gtid_ptr = false;
1528-
int ret = 0;
1529-
1530-
if (commit_owned_gtids(thd, true, &need_clear_owned_gtid_ptr)) {
1531-
/* Error when saving gtid into mysql.gtid_executed table. */
1532-
gtid_state->update_on_rollback(thd);
1533-
ret = -1;
1534-
} else if (need_clear_owned_gtid_ptr) {
1535-
gtid_state->update_on_commit(thd);
1536-
ret = 0;
1537-
} else {
1538-
ret = 1;
1539-
}
1540-
1541-
return ret;
1542-
}
1543-
15441515
/**
15451516
@param[in] thd Thread handle.
15461517
@param[in] all Session transaction if true, statement

Diff for: sql/handler.h

-1
Original file line numberDiff line numberDiff line change
@@ -6839,7 +6839,6 @@ bool ha_notify_alter_table(THD *thd, const MDL_key *mdl_key,
68396839
ha_notification_type notification_type);
68406840

68416841
int commit_owned_gtids(THD *thd, bool all, bool *need_clear_ptr);
6842-
int commit_owned_gtid_by_partial_command(THD *thd);
68436842
bool set_tx_isolation(THD *thd, enum_tx_isolation tx_isolation, bool one_shot);
68446843

68456844
/** Generate a string representation of an `ha_rkey_function` enum value.

Diff for: sql/set_var.cc

-34
Original file line numberDiff line numberDiff line change
@@ -389,40 +389,6 @@ bool sys_var::set_default(THD *thd, set_var *var) {
389389
return ret;
390390
}
391391

392-
bool sys_var::is_default(THD *, set_var *var) {
393-
DBUG_TRACE;
394-
bool ret = false;
395-
longlong def = option.def_value;
396-
switch (get_var_type()) {
397-
case GET_INT:
398-
case GET_UINT:
399-
case GET_LONG:
400-
case GET_ULONG:
401-
case GET_LL:
402-
case GET_ULL:
403-
case GET_BOOL:
404-
case GET_ENUM:
405-
case GET_SET:
406-
case GET_FLAGSET:
407-
case GET_ASK_ADDR:
408-
if (def == (longlong)var->save_result.ulonglong_value) ret = true;
409-
break;
410-
case GET_DOUBLE:
411-
if ((double)def == (double)var->save_result.double_value) ret = true;
412-
break;
413-
case GET_STR_ALLOC:
414-
case GET_STR:
415-
case GET_NO_ARG:
416-
case GET_PASSWORD:
417-
if ((def == (longlong)var->save_result.string_value.str) ||
418-
(((char *)def) &&
419-
!strcmp((char *)def, var->save_result.string_value.str)))
420-
ret = true;
421-
break;
422-
}
423-
return ret;
424-
}
425-
426392
void sys_var::set_user_host(THD *thd) {
427393
memset(user, 0, sizeof(user));
428394
DBUG_ASSERT(thd->security_context()->user().length < sizeof(user));

Diff for: sql/set_var.h

-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ class sys_var {
185185
option.def_value = new_def_value;
186186
}
187187
longlong get_default() { return option.def_value; }
188-
virtual bool is_default(THD *thd, set_var *var);
189188
virtual longlong get_min_value() { return option.min_value; }
190189
virtual ulonglong get_max_value() { return option.max_value; }
191190
/**

Diff for: sql/sql_class.cc

-4
Original file line numberDiff line numberDiff line change
@@ -2651,10 +2651,6 @@ bool add_item_to_list(THD *thd, Item *item) {
26512651
return thd->lex->select_lex->add_item_to_list(item);
26522652
}
26532653

2654-
void add_order_to_list(THD *thd, ORDER *order) {
2655-
thd->lex->select_lex->add_order_to_list(order);
2656-
}
2657-
26582654
THD::Transaction_state::Transaction_state()
26592655
: m_query_tables_list(new Query_tables_list()),
26602656
m_ha_data(PSI_NOT_INSTRUMENTED, m_ha_data.initial_capacity) {}

Diff for: sql/sql_class.h

-1
Original file line numberDiff line numberDiff line change
@@ -4273,7 +4273,6 @@ inline void my_eof(THD *thd) {
42734273
}
42744274

42754275
bool add_item_to_list(THD *thd, Item *item);
4276-
void add_order_to_list(THD *thd, ORDER *order);
42774276

42784277
/*************************************************************************/
42794278

Diff for: sql/sql_list.cc

-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727

2828
list_node end_of_list;
2929

30-
void free_list(I_List<i_string_pair> *list) {
31-
i_string_pair *tmp;
32-
while ((tmp = list->get())) delete tmp;
33-
}
34-
3530
void free_list(I_List<i_string> *list) {
3631
i_string *tmp;
3732
while ((tmp = list->get())) delete tmp;

Diff for: sql/sql_list.h

-7
Original file line numberDiff line numberDiff line change
@@ -820,13 +820,6 @@ class I_List_iterator : public base_ilist_iterator<T> {
820820
inline T *operator++(int) { return base_ilist_iterator<T>::next(); }
821821
};
822822

823-
void free_list(I_List<i_string_pair> *list);
824823
void free_list(I_List<i_string> *list);
825824

826-
template <class T>
827-
List<T> *List_merge(T *head, List<T> *tail) {
828-
tail->push_front(head);
829-
return tail;
830-
}
831-
832825
#endif // INCLUDES_MYSQL_SQL_LIST_H

Diff for: sql/sql_plugin_var.cc

-42
Original file line numberDiff line numberDiff line change
@@ -429,48 +429,6 @@ bool sys_var_pluginvar::global_update(THD *thd, set_var *var) {
429429
return rc;
430430
}
431431

432-
bool sys_var_pluginvar::is_default(THD *thd, set_var *var) {
433-
void *tgt = real_value_ptr(thd, var->type);
434-
435-
switch (plugin_var->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_THDLOCAL)) {
436-
case PLUGIN_VAR_INT:
437-
return (((sysvar_uint_t *)plugin_var)->def_val == *(uint *)tgt);
438-
case PLUGIN_VAR_LONG:
439-
return (((sysvar_ulong_t *)plugin_var)->def_val == *(ulong *)tgt);
440-
case PLUGIN_VAR_LONGLONG:
441-
return (((sysvar_ulonglong_t *)plugin_var)->def_val == *(ulonglong *)tgt);
442-
case PLUGIN_VAR_ENUM:
443-
return (((sysvar_enum_t *)plugin_var)->def_val == *(ulong *)tgt);
444-
case PLUGIN_VAR_SET:
445-
return (((sysvar_set_t *)plugin_var)->def_val == *(ulong *)tgt);
446-
case PLUGIN_VAR_BOOL:
447-
return (((sysvar_bool_t *)plugin_var)->def_val == *(bool *)tgt);
448-
case PLUGIN_VAR_STR:
449-
return !strcmp(pointer_cast<sysvar_str_t *>(plugin_var)->def_val,
450-
*static_cast<char **>(tgt));
451-
case PLUGIN_VAR_DOUBLE:
452-
return (((sysvar_double_t *)plugin_var)->def_val == *(double *)tgt);
453-
case PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL:
454-
return (((thdvar_uint_t *)plugin_var)->def_val == *(uint *)tgt);
455-
case PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL:
456-
return (((thdvar_ulong_t *)plugin_var)->def_val == *(ulong *)tgt);
457-
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL:
458-
return (((thdvar_ulonglong_t *)plugin_var)->def_val == *(ulonglong *)tgt);
459-
case PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL:
460-
return (((thdvar_enum_t *)plugin_var)->def_val == *(ulong *)tgt);
461-
case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:
462-
return (((thdvar_set_t *)plugin_var)->def_val == *(ulong *)tgt);
463-
case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:
464-
return (((thdvar_bool_t *)plugin_var)->def_val == *(bool *)tgt);
465-
case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL:
466-
return !strcmp(pointer_cast<thdvar_str_t *>(plugin_var)->def_val,
467-
*static_cast<char **>(tgt));
468-
case PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL:
469-
return (((thdvar_double_t *)plugin_var)->def_val == *(double *)tgt);
470-
}
471-
return 0;
472-
}
473-
474432
longlong sys_var_pluginvar::get_min_value() {
475433
switch (plugin_var->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_THDLOCAL)) {
476434
case PLUGIN_VAR_INT:

Diff for: sql/sql_plugin_var.h

-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ class sys_var_pluginvar : public sys_var {
279279
virtual void global_save_default(THD *, set_var *) {}
280280
bool session_update(THD *thd, set_var *var);
281281
bool global_update(THD *thd, set_var *var);
282-
bool is_default(THD *thd, set_var *var);
283282
longlong get_min_value();
284283
ulonglong get_max_value();
285284
void set_arg_source(get_opt_arg_source *src) {

Diff for: sql/sql_trigger.cc

-74
Original file line numberDiff line numberDiff line change
@@ -141,37 +141,6 @@ bool get_table_for_trigger(THD *thd, const LEX_CSTRING &db_name,
141141
return false;
142142
}
143143

144-
// Only used by NDB.
145-
bool drop_all_triggers(THD *thd, const char *db_name, const char *table_name) {
146-
// Check if there is at least one trigger for the given table.
147-
dd::cache::Dictionary_client::Auto_releaser releaser(thd->dd_client());
148-
149-
dd::Table *table = nullptr;
150-
if (thd->dd_client()->acquire_for_modification(db_name, table_name, &table)) {
151-
// Error is reported by the dictionary subsystem.
152-
return true;
153-
}
154-
155-
if (table == nullptr || !table->has_trigger()) return false;
156-
157-
#ifdef HAVE_PSI_SP_INTERFACE
158-
// Not very "transactional", but this is the same order it happens
159-
// during drop table.
160-
remove_all_triggers_from_perfschema(db_name, *table);
161-
#endif
162-
163-
for (const dd::Trigger *trigger : *table->triggers())
164-
table->drop_trigger(trigger);
165-
166-
if (thd->dd_client()->update(table)) {
167-
trans_rollback_stmt(thd);
168-
trans_rollback(thd);
169-
return true;
170-
}
171-
172-
return trans_commit_stmt(thd) || trans_commit(thd);
173-
}
174-
175144
#ifdef HAVE_PSI_SP_INTERFACE
176145
void remove_all_triggers_from_perfschema(const char *schema_name,
177146
const dd::Table &table) {
@@ -201,49 +170,6 @@ bool check_table_triggers_are_not_in_the_same_schema(const char *db_name,
201170
return false;
202171
}
203172

204-
// Only used by NDB
205-
bool reload_triggers_for_table(THD *thd, const char *db_name,
206-
const char *table_alias MY_ATTRIBUTE((unused)),
207-
const char *table_name MY_ATTRIBUTE((unused)),
208-
const char *new_db_name,
209-
const char *new_table_name) {
210-
// Check if there is at least one trigger for the given table.
211-
dd::cache::Dictionary_client::Auto_releaser releaser(thd->dd_client());
212-
213-
const dd::Table *table = nullptr;
214-
215-
if (thd->dd_client()->acquire(new_db_name, new_table_name, &table)) {
216-
// Error is reported by the dictionary subsystem.
217-
return true;
218-
}
219-
220-
if (table == nullptr || !table->has_trigger()) return false;
221-
222-
/*
223-
Since triggers should be in the same schema as their subject tables
224-
moving table with them between two schemas raises too many questions.
225-
(E.g. what should happen if in new schema we already have trigger
226-
with same name ?).
227-
*/
228-
229-
if (my_strcasecmp(table_alias_charset, db_name, new_db_name)) {
230-
my_error(ER_TRG_IN_WRONG_SCHEMA, MYF(0));
231-
return true;
232-
}
233-
234-
/*
235-
This method interfaces the mysql server code protected by
236-
an exclusive metadata lock.
237-
*/
238-
DBUG_ASSERT(thd->mdl_context.owns_equal_or_stronger_lock(
239-
MDL_key::TABLE, db_name, table_name, MDL_EXCLUSIVE));
240-
241-
DBUG_ASSERT(my_strcasecmp(table_alias_charset, table_alias, new_table_name));
242-
243-
return Table_trigger_dispatcher::check_n_load(thd, *table, new_db_name,
244-
new_table_name);
245-
}
246-
247173
bool acquire_mdl_for_trigger(THD *thd, const char *db, const char *trg_name,
248174
enum_mdl_type trigger_name_mdl_type) {
249175
DBUG_ASSERT(trg_name != nullptr);

Diff for: sql/sql_trigger.h

+1-41
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define SQL_TRIGGER_INCLUDED
33

44
/*
5-
Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
5+
Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
66
77
This program is free software; you can redistribute it and/or modify
88
it under the terms of the GNU General Public License, version 2.0,
@@ -74,20 +74,6 @@ bool get_table_for_trigger(THD *thd, const LEX_CSTRING &db_name,
7474
const LEX_STRING &trigger_name,
7575
bool continue_if_not_exist, TABLE_LIST **table);
7676

77-
/**
78-
Drop all triggers for table.
79-
80-
@param thd current thread context
81-
@param db_name name of the table schema
82-
@param table_name table name
83-
84-
@return Operation status.
85-
@retval false Success
86-
@retval true Failure
87-
*/
88-
89-
bool drop_all_triggers(THD *thd, const char *db_name, const char *table_name);
90-
9177
/**
9278
Check for table with triggers that old database name and new database name
9379
are the same. This functions is called while handling the statement
@@ -111,32 +97,6 @@ bool check_table_triggers_are_not_in_the_same_schema(const char *db_name,
11197
const dd::Table &table,
11298
const char *new_db_name);
11399

114-
/**
115-
Reload triggers from DD for specified table.
116-
117-
@param[in] thd Thread context
118-
@param[in] db_name Current database of subject table
119-
@param[in] table_alias Current alias of subject table
120-
@param[in] table_name Current name of subject table
121-
@param[in] new_db_name New database for subject table
122-
@param[in] new_table_name New name of subject table
123-
124-
@note
125-
This method assumes that subject table is not renamed to itself.
126-
127-
@note
128-
This method needs to be called under an exclusive table metadata lock.
129-
130-
@return Operation status.
131-
@retval false Success
132-
@retval true Failure
133-
*/
134-
135-
bool reload_triggers_for_table(THD *thd, const char *db_name,
136-
const char *table_alias, const char *table_name,
137-
const char *new_db_name,
138-
const char *new_table_name);
139-
140100
/**
141101
Acquire either exclusive or shared MDL lock for a trigger
142102
in specified schema.

0 commit comments

Comments
 (0)