MCPcopy Create free account
hub / github.com/MariaDB/server / open_table

Function open_table

sql/sql_base.cc:1969–2503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1967*/
1968
1969bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
1970{
1971 TABLE *table;
1972 const char *key;
1973 uint key_length;
1974 const LEX_CSTRING &alias= table_list->alias;
1975 uint flags= ot_ctx->get_flags();
1976 MDL_ticket *mdl_ticket;
1977 TABLE_SHARE *share;
1978 uint gts_flags;
1979 bool from_share= false;
1980 bool is_write_lock_request= table_list->mdl_request.is_write_lock_request();
1981#ifdef WITH_PARTITION_STORAGE_ENGINE
1982 int part_names_error=0;
1983#endif
1984 DBUG_ENTER("open_table");
1985
1986 /*
1987 The table must not be opened already. The table can be pre-opened for
1988 some statements if it is a temporary table.
1989
1990 open_temporary_table() must be used to open temporary tables.
1991 */
1992 DBUG_ASSERT(!table_list->table);
1993
1994 /* an open table operation needs a lot of the stack space */
1995 if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (uchar *)&alias))
1996 DBUG_RETURN(TRUE);
1997
1998 if (!(flags & MYSQL_OPEN_IGNORE_KILLED) && thd->killed)
1999 {
2000 thd->send_kill_message();
2001 DBUG_RETURN(TRUE);
2002 }
2003
2004 /*
2005 Check if we're trying to take a write lock in a read only transaction.
2006
2007 Note that we allow write locks on log tables as otherwise logging
2008 to general/slow log would be disabled in read only transactions.
2009 */
2010 if (is_write_lock_request &&
2011 thd->tx_read_only &&
2012 !(flags & (MYSQL_LOCK_LOG_TABLE | MYSQL_OPEN_HAS_MDL_LOCK)))
2013 {
2014 my_error(ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION, MYF(0));
2015 DBUG_RETURN(true);
2016 }
2017
2018 if (!table_list->db.str)
2019 {
2020 my_error(ER_NO_DB_ERROR, MYF(0));
2021 DBUG_RETURN(true);
2022 }
2023
2024 key_length= get_table_def_key(table_list, &key);
2025
2026 /*

Callers 12

open_purge_tableFunction · 0.70
mysql_create_like_tableFunction · 0.70
prepare_for_repairFunction · 0.70
reopen_tablesMethod · 0.70
open_and_process_tableFunction · 0.70
open_ltableFunction · 0.70
cmd_openMethod · 0.50
wrapper_openMethod · 0.50
storage_openMethod · 0.50

Calls 15

check_stack_overrunFunction · 0.85
my_errorFunction · 0.85
get_table_def_keyFunction · 0.85
Lex_ident_tableClass · 0.85
set_partitions_as_usedFunction · 0.85
is_locked_viewFunction · 0.85
open_table_get_mdl_lockFunction · 0.85
ha_table_existsFunction · 0.85
tdc_acquire_shareFunction · 0.85
mysql_make_viewFunction · 0.85
tdc_release_shareFunction · 0.85

Tested by

no test coverage detected