| 1967 | */ |
| 1968 | |
| 1969 | bool 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 | /* |
no test coverage detected