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

Method prepare_inner

sql/sql_update.cc:3105–3272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3103*/
3104
3105bool Sql_cmd_update::prepare_inner(THD *thd)
3106{
3107 JOIN *join;
3108 int err= 0;
3109 SELECT_LEX *const select_lex = thd->lex->first_select_lex();
3110 TABLE_LIST *const table_list = select_lex->get_table_list();
3111 ulonglong select_options= select_lex->options;
3112 bool free_join= 1;
3113 DBUG_ENTER("Sql_cmd_update::prepare_inner");
3114
3115 (void) read_statistics_for_tables_if_needed(thd, table_list);
3116
3117 THD_STAGE_INFO(thd, stage_init_update);
3118
3119 if (!multitable)
3120 {
3121 if (mysql_handle_derived(lex, DT_INIT))
3122 DBUG_RETURN(TRUE);
3123 }
3124
3125 if (table_list->has_period() && table_list->is_view_or_derived())
3126 {
3127 my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str);
3128 DBUG_RETURN(TRUE);
3129 }
3130
3131 if (!multitable)
3132 {
3133 TABLE_LIST *update_source_table= 0;
3134
3135 if (((update_source_table=unique_table(thd, table_list,
3136 table_list->next_global, 0)) ||
3137 table_list->is_multitable()))
3138 {
3139 DBUG_ASSERT(update_source_table || table_list->view != 0);
3140 if (thd->lex->period_conditions.is_set())
3141 {
3142 my_error(ER_NOT_SUPPORTED_YET, MYF(0),
3143 "updating and querying the same temporal periods table");
3144 DBUG_RETURN(TRUE);
3145 }
3146 if (!table_list->is_multitable() &&
3147 !processing_as_multitable_update_prohibited(thd))
3148 multitable= true;
3149 }
3150 }
3151
3152 if(!multitable)
3153 {
3154 if (table_list->is_view_or_derived() &&
3155 select_lex->leaf_tables.elements > 1)
3156 multitable = true;
3157 }
3158
3159 if (!multitable)
3160 {
3161 if (lex->ignore)
3162 lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_UPDATE_IGNORE);

Callers

nothing calls this directly

Calls 15

mysql_handle_derivedFunction · 0.85
my_errorFunction · 0.85
unique_tableFunction · 0.85
setup_tablesFunction · 0.85
first_select_lexMethod · 0.80
get_table_listMethod · 0.80
has_periodMethod · 0.80
is_view_or_derivedMethod · 0.80
set_stmt_unsafeMethod · 0.80
vers_setup_condsMethod · 0.80
is_multitableMethod · 0.45

Tested by

no test coverage detected