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

Function open_only_one_table

sql/sql_admin.cc:345–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343#endif
344
345static bool open_only_one_table(THD* thd, TABLE_LIST* table,
346 bool repair_table_use_frm,
347 bool is_view_operator_func)
348{
349 LEX *lex= thd->lex;
350 SELECT_LEX *select= lex->first_select_lex();
351 TABLE_LIST *save_next_global, *save_next_local;
352 bool open_error;
353 save_next_global= table->next_global;
354 table->next_global= 0;
355 save_next_local= table->next_local;
356 table->next_local= 0;
357 select->table_list.first= table;
358 /*
359 Time zone tables and SP tables can be add to lex->query_tables list,
360 so it have to be prepared.
361 TODO: Investigate if we can put extra tables into argument instead of
362 using lex->query_tables
363 */
364 lex->query_tables= table;
365 lex->query_tables_last= &table->next_global;
366 lex->query_tables_own_last= 0;
367
368 DBUG_EXECUTE_IF("fail_2call_open_only_one_table", {
369 if (debug_fail_counter)
370 {
371 open_error= TRUE;
372 goto dbug_err;
373 }
374 else
375 debug_fail_counter++;
376 });
377
378 /*
379 CHECK TABLE command is allowed for views as well. Check on alter flags
380 to differentiate from ALTER TABLE...CHECK PARTITION on which view is not
381 allowed.
382 */
383 if (lex->alter_info.partition_flags & ALTER_PARTITION_ADMIN ||
384 !is_view_operator_func)
385 {
386 table->required_type= TABLE_TYPE_NORMAL;
387 DBUG_ASSERT(lex->table_type != TABLE_TYPE_VIEW);
388 }
389 else if (lex->table_type == TABLE_TYPE_VIEW)
390 {
391 table->required_type= lex->table_type;
392 }
393 else if ((lex->table_type != TABLE_TYPE_VIEW) &&
394 lex->sql_command == SQLCOM_REPAIR)
395 {
396 table->required_type= TABLE_TYPE_NORMAL;
397 }
398
399 if (lex->sql_command == SQLCOM_CHECK ||
400 lex->sql_command == SQLCOM_REPAIR ||
401 lex->sql_command == SQLCOM_ANALYZE ||
402 lex->sql_command == SQLCOM_OPTIMIZE)

Callers 1

mysql_admin_tableFunction · 0.85

Calls 6

first_select_lexMethod · 0.80
get_stmt_daMethod · 0.80
push_warning_infoMethod · 0.80
open_temporary_tablesMethod · 0.80
pop_warning_infoMethod · 0.80
open_and_lock_tablesFunction · 0.70

Tested by

no test coverage detected