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

Function mysql_ha_open

sql/sql_handler.cc:258–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256*/
257
258bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
259{
260 SQL_HANDLER *sql_handler= 0;
261 uint counter;
262 bool error;
263 TABLE *table, *backup_open_tables;
264 MDL_savepoint mdl_savepoint;
265 Query_arena backup_arena;
266 DBUG_ENTER("mysql_ha_open");
267 DBUG_PRINT("enter",("'%s'.'%s' as '%s' reopen: %d",
268 tables->db.str, tables->table_name.str, tables->alias.str,
269 reopen != 0));
270
271 if (thd->locked_tables_mode)
272 {
273 my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
274 DBUG_RETURN(TRUE);
275 }
276 if (tables->schema_table)
277 {
278 my_error(ER_WRONG_USAGE, MYF(0), "HANDLER OPEN",
279 INFORMATION_SCHEMA_NAME.str);
280 DBUG_PRINT("exit",("ERROR"));
281 DBUG_RETURN(TRUE);
282 }
283
284 if (! my_hash_inited(&thd->handler_tables_hash))
285 {
286 /*
287 HASH entries are of type SQL_HANDLER
288 */
289 if (my_hash_init(key_memory_THD_handler_tables_hash,
290 &thd->handler_tables_hash, &my_charset_latin1,
291 HANDLER_TABLES_HASH_SIZE, 0, 0, mysql_ha_hash_get_key,
292 mysql_ha_hash_free, 0))
293 {
294 DBUG_PRINT("exit",("ERROR"));
295 DBUG_RETURN(TRUE);
296 }
297 }
298 else if (! reopen) /* Otherwise we have 'tables' already. */
299 {
300 if (my_hash_search(&thd->handler_tables_hash, (uchar*) tables->alias.str,
301 tables->alias.length + 1))
302 {
303 DBUG_PRINT("info",("duplicate '%s'", tables->alias.str));
304 DBUG_PRINT("exit",("ERROR"));
305 my_error(ER_NONUNIQ_TABLE, MYF(0), tables->alias.str);
306 DBUG_RETURN(TRUE);
307 }
308 }
309
310 /*
311 Save and reset the open_tables list so that open_tables() won't
312 be able to access (or know about) the previous list. And on return
313 from open_tables(), thd->open_tables will contain only the opened
314 table.
315

Callers 2

mysql_ha_find_handlerFunction · 0.85
sql_parse.ccFile · 0.85

Calls 15

my_errorFunction · 0.85
my_hash_searchFunction · 0.85
init_alloc_rootFunction · 0.85
my_multi_mallocFunction · 0.85
my_hash_insertFunction · 0.85
get_lock_dataFunction · 0.85
my_okFunction · 0.85
close_thread_tablesFunction · 0.85
my_hash_deleteFunction · 0.85
set_open_tablesMethod · 0.80
mdl_savepointMethod · 0.80
open_temporary_tablesMethod · 0.80

Tested by

no test coverage detected