Skip to content

Commit

Permalink
Fix AutoInitCopy #2
Browse files Browse the repository at this point in the history
Upstream commit ID : fb-mysql-5.6.35/911d1a387a0d80f3ba52b7432c1abdbd7e8cb220
PS-6867 : Merge fb-prod201905

Summary: Missed a few in earlier fixes for AutoInitCopy rule. Also added a few fixes for anoymous class rule and local shadowing rule.

Reviewed By: luqun

Differential Revision: D15467213

fbshipit-source-id: 9325852dbdd
  • Loading branch information
yizhang82 authored and inikep committed Jan 16, 2025
1 parent 7693a61 commit 32a38ed
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion storage/rocksdb/event_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static std::vector<Rdb_index_stats> extract_index_stats(
const std::vector<std::string> &files,
const rocksdb::TablePropertiesCollection &props) {
std::vector<Rdb_index_stats> ret;
for (auto fn : files) {
for (const auto &fn : files) {
const auto it = props.find(fn);
assert(it != props.end());
std::vector<Rdb_index_stats> stats;
Expand Down
4 changes: 0 additions & 4 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3423,8 +3423,6 @@ static void set_tx_on_thd(THD *const thd, Rdb_transaction *trx) {
return get_ha_data(thd)->set_trx(trx);
}

namespace {

class Rdb_perf_context_guard {
Rdb_io_perf m_io_perf;
Rdb_io_perf *m_io_perf_ptr;
Expand Down Expand Up @@ -3460,8 +3458,6 @@ class Rdb_perf_context_guard {
}
};

} // anonymous namespace

/*
TODO: maybe, call this in external_lock() and store in ha_rocksdb..
*/
Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/properties_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ rocksdb::UserCollectedProperties Rdb_tbl_prop_coll::GetReadableProperties()
s.append(" records...]");
#else
bool first = true;
for (auto it : m_stats) {
for (const auto &it : m_stats) {
if (first) {
first = false;
} else {
Expand Down
4 changes: 2 additions & 2 deletions storage/rocksdb/rdb_cf_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Rdb_cf_manager::init(
}

void Rdb_cf_manager::cleanup() {
for (auto it : m_cf_name_map) {
for (const auto &it : m_cf_name_map) {
delete it.second;
}
mysql_mutex_destroy(&m_mutex);
Expand Down Expand Up @@ -174,7 +174,7 @@ std::vector<std::string> Rdb_cf_manager::get_cf_names(void) const {
std::vector<std::string> names;

RDB_MUTEX_LOCK_CHECK(m_mutex);
for (auto it : m_cf_name_map) {
for (const auto &it : m_cf_name_map) {
names.push_back(it.first);
}
RDB_MUTEX_UNLOCK_CHECK(m_mutex);
Expand Down
26 changes: 16 additions & 10 deletions storage/rocksdb/rdb_datadic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3562,6 +3562,8 @@ int Rdb_key_def::unpack_simple(Rdb_field_packing *const fpi,
// See Rdb_charset_space_info::spaces_xfrm
const int RDB_SPACE_XFRM_SIZE = 32;

namespace {

// A class holding information about how space character is represented in a
// charset.
class Rdb_charset_space_info {
Expand All @@ -3582,6 +3584,8 @@ class Rdb_charset_space_info {
size_t space_mb_len;
};

} // namespace

static std::array<std::unique_ptr<Rdb_charset_space_info>, MY_ALL_CHARSETS_SIZE>
rdb_mem_comparable_space;

Expand Down Expand Up @@ -4817,7 +4821,7 @@ Rdb_ddl_manager::safe_find(GL_INDEX_ID gl_index_id) {

mysql_rwlock_rdlock(&m_rwlock);

auto it = m_index_num_to_keydef.find(gl_index_id);
const auto it = m_index_num_to_keydef.find(gl_index_id);
if (it != m_index_num_to_keydef.end()) {
const auto table_def = find(it->second.first, false);
if (table_def && it->second.second < table_def->m_key_count) {
Expand All @@ -4827,9 +4831,10 @@ Rdb_ddl_manager::safe_find(GL_INDEX_ID gl_index_id) {
}
}
} else {
auto it = m_index_num_to_uncommitted_keydef.find(gl_index_id);
if (it != m_index_num_to_uncommitted_keydef.end()) {
const auto &kd = it->second;
const auto uncommitted_it =
m_index_num_to_uncommitted_keydef.find(gl_index_id);
if (uncommitted_it != m_index_num_to_uncommitted_keydef.end()) {
const auto &kd = uncommitted_it->second;
if (kd->max_storage_fmt_length() != 0) {
ret = kd;
}
Expand All @@ -4844,18 +4849,19 @@ Rdb_ddl_manager::safe_find(GL_INDEX_ID gl_index_id) {
// this method assumes at least read-only lock on m_rwlock
const std::shared_ptr<Rdb_key_def> &
Rdb_ddl_manager::find(GL_INDEX_ID gl_index_id) {
auto it = m_index_num_to_keydef.find(gl_index_id);
const auto it = m_index_num_to_keydef.find(gl_index_id);
if (it != m_index_num_to_keydef.end()) {
auto table_def = find(it->second.first, false);
const auto table_def = find(it->second.first, false);
if (table_def) {
if (it->second.second < table_def->m_key_count) {
return table_def->m_key_descr_arr[it->second.second];
}
}
} else {
auto it = m_index_num_to_uncommitted_keydef.find(gl_index_id);
if (it != m_index_num_to_uncommitted_keydef.end()) {
return it->second;
const auto uncommitted_it =
m_index_num_to_uncommitted_keydef.find(gl_index_id);
if (uncommitted_it != m_index_num_to_uncommitted_keydef.end()) {
return uncommitted_it->second;
}
}

Expand All @@ -4881,7 +4887,7 @@ Rdb_ddl_manager::safe_get_table_name(const GL_INDEX_ID &gl_index_id) {
void Rdb_ddl_manager::set_stats(
const std::unordered_map<GL_INDEX_ID, Rdb_index_stats> &stats) {
mysql_rwlock_wrlock(&m_rwlock);
for (auto src : stats) {
for (const auto &src : stats) {
const auto &keydef = find(src.second.m_gl_index_id);
if (keydef) {
keydef->m_stats = src.second;
Expand Down
4 changes: 2 additions & 2 deletions storage/rocksdb/rdb_i_s.cc
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ static int rdb_i_s_cfoptions_fill_table(
std::vector<std::string> table_options =
split_into_vector(opts.table_factory->GetPrintableTableOptions(), '\n');

for (auto option : table_options) {
for (std::string option : table_options) {
option.erase(std::remove(option.begin(), option.end(), ' '),
option.end());

Expand Down Expand Up @@ -868,7 +868,7 @@ static int rdb_i_s_compact_stats_fill_table(

Rdb_cf_manager &cf_manager = rdb_get_cf_manager();

for (auto cf_name : cf_manager.get_cf_names()) {
for (const auto &cf_name : cf_manager.get_cf_names()) {
rocksdb::ColumnFamilyHandle *cfh = cf_manager.get_cf(cf_name);

if (cfh == nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/rdb_sst_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Rdb_sst_info::Rdb_sst_info(rocksdb::DB *const db, const std::string &tablename,
Rdb_sst_info::~Rdb_sst_info() {
assert(m_sst_file == nullptr);

for (auto sst_file : m_committed_files) {
for (const auto &sst_file : m_committed_files) {
// In case something went wrong attempt to delete the temporary file.
// If everything went fine that file will have been renamed and this
// function call will fail.
Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/rdb_sst_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class Rdb_sst_info {

void reset() {
if (!m_committed) {
for (auto sst_file : m_committed_files) {
for (const auto &sst_file : m_committed_files) {
// In case something went wrong attempt to delete the temporary file.
// If everything went fine that file will have been renamed and this
// function call will fail.
Expand Down

0 comments on commit 32a38ed

Please sign in to comment.