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

Method execute

sql/sql_table.cc:13534–13893  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13532
13533
13534bool Sql_cmd_create_table_like::execute(THD *thd)
13535{
13536 DBUG_ENTER("Sql_cmd_create_table::execute");
13537 LEX *lex= thd->lex;
13538 SELECT_LEX *select_lex= lex->first_select_lex();
13539 TABLE_LIST *first_table= select_lex->table_list.first;
13540 DBUG_ASSERT(first_table == lex->query_tables);
13541 DBUG_ASSERT(first_table != 0);
13542 bool link_to_local;
13543 TABLE_LIST *create_table= first_table;
13544 TABLE_LIST *select_tables= lex->create_last_non_select_table->next_global;
13545 /* most outer SELECT_LEX_UNIT of query */
13546 SELECT_LEX_UNIT *unit= &lex->unit;
13547 int res= 0;
13548
13549 const bool used_engine= lex->create_info.used_fields & HA_CREATE_USED_ENGINE;
13550 ulong binlog_format= thd->wsrep_binlog_format(thd->variables.binlog_format);
13551 DBUG_ASSERT((m_storage_engine_name.str != NULL) == used_engine);
13552
13553 if (lex->create_info.resolve_to_charset_collation_context(thd,
13554 thd->charset_collation_context_create_table_in_db(first_table->db.str)))
13555 DBUG_RETURN(true);
13556
13557 if (used_engine)
13558 {
13559 if (resolve_storage_engine_with_error(thd, &lex->create_info.db_type,
13560 lex->create_info.tmp_table()))
13561 DBUG_RETURN(true); // Engine not found, substitution is not allowed
13562
13563 if (!lex->create_info.db_type) // Not found, but substitution is allowed
13564 {
13565 lex->create_info.use_default_db_type(thd);
13566 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
13567 ER_WARN_USING_OTHER_HANDLER,
13568 ER_THD(thd, ER_WARN_USING_OTHER_HANDLER),
13569 hton_name(lex->create_info.db_type)->str,
13570 create_table->table_name.str);
13571 }
13572 }
13573
13574 if (lex->tmp_table())
13575 {
13576 status_var_decrement(thd->status_var.com_stat[SQLCOM_CREATE_TABLE]);
13577 status_var_increment(thd->status_var.com_create_tmp_table);
13578 }
13579
13580 /*
13581 Code below (especially in mysql_create_table() and select_create
13582 methods) may modify HA_CREATE_INFO structure in LEX, so we have to
13583 use a copy of this structure to make execution prepared statement-
13584 safe. A shallow copy is enough as this code won't modify any memory
13585 referenced from this structure.
13586 */
13587 Table_specification_st create_info(lex->create_info);
13588 /*
13589 We need to copy alter_info for the same reasons of re-execution
13590 safety, only in case of Alter_info we have to do (almost) a deep
13591 copy.

Callers

nothing calls this directly

Calls 15

push_warning_printfFunction · 0.85
hton_nameFunction · 0.85
wsrep_thd_is_toiFunction · 0.85
create_table_precheckFunction · 0.85
append_file_to_dirFunction · 0.85
wsrep_check_supportFunction · 0.85
push_warningFunction · 0.85
my_errorFunction · 0.85
my_okFunction · 0.85
unique_tableFunction · 0.85
handle_selectFunction · 0.85

Tested by

no test coverage detected