| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 2010, 2026, Oracle and/or its affiliates. |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify it under |
| 6 |
the terms of the GNU General Public License, version 2.0, as published by the |
| 7 |
Free Software Foundation. |
| 8 |
|
| 9 |
This program is designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
|
| 26 |
*****************************************************************************/ |
| 27 |
|
| 28 |
/** @file include/dict0priv.ic |
| 29 |
Data dictionary system private include file |
| 30 |
|
| 31 |
Created Wed 13 Oct 2010 16:10:14 EST Sunny Bains |
| 32 |
***********************************************************************/ |
| 33 |
|
| 34 |
#include "dict0dict.h" |
| 35 |
#include "dict0load.h" |
| 36 |
#include "dict0priv.h" |
| 37 |
|
| 38 |
inline dict_table_t *dict_table_get_low(const char *table_name, |
| 39 |
const std::string *prev_table) { |
| 40 |
dict_table_t *table; |
| 41 |
|
| 42 |
ut_ad(table_name); |
| 43 |
ut_ad(dict_sys_mutex_own()); |
| 44 |
|
| 45 |
table = dict_table_check_if_in_cache_low(table_name); |
| 46 |
|
| 47 |
if (table && table->is_corrupted()) { |
| 48 |
ib::error error(ER_IB_MSG_1229); |
| 49 |
error << "Table " << table->name << "is corrupted"; |
| 50 |
if (srv_load_corrupted) { |
| 51 |
error << ", but innodb_force_load_corrupted is set"; |
| 52 |
} else { |
| 53 |
return (nullptr); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
if (table == nullptr) { |
| 58 |
table = dict_load_table(table_name, true, DICT_ERR_IGNORE_NONE, prev_table); |
| 59 |
} |
| 60 |
|
| 61 |
ut_ad(!table || table->cached); |
| 62 |
|
| 63 |
return (table); |
| 64 |
} |
| 65 |
|
| 66 |
/** Checks if a table is in the dictionary cache. |
| 67 |
@return table, NULL if not found */ |
| 68 |
static inline dict_table_t *dict_table_check_if_in_cache_low( |
| 69 |
const char *table_name) /*!< in: table name */ |
| 70 |
{ |
| 71 |
dict_table_t *table; |
| 72 |
|
| 73 |
DBUG_TRACE; |
| 74 |
DBUG_PRINT("dict_table_check_if_in_cache_low", ("table: '%s'", table_name)); |
| 75 |
|
| 76 |
ut_ad(table_name); |
| 77 |
ut_ad(dict_sys_mutex_own()); |
| 78 |
|
| 79 |
/* Look for the table name in the hash table */ |
| 80 |
const auto table_name_hash_value = ut::hash_string(table_name); |
| 81 |
|
| 82 |
HASH_SEARCH(name_hash, dict_sys->table_hash, table_name_hash_value, |
| 83 |
dict_table_t *, table, ut_ad(table->cached), |
| 84 |
!strcmp(table->name.m_name, table_name)); |
| 85 |
return table; |
| 86 |
} |