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