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

Method initialize_tables

sql/sql_update.cc:2171–2318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2169*/
2170
2171bool
2172multi_update::initialize_tables(JOIN *join)
2173{
2174 TABLE_LIST *table_ref;
2175 DBUG_ENTER("initialize_tables");
2176
2177 if (unlikely((thd->variables.option_bits & OPTION_SAFE_UPDATES) &&
2178 error_if_full_join(join)))
2179 DBUG_RETURN(1);
2180 if (join->implicit_grouping ||
2181 join->select_lex->have_window_funcs())
2182 {
2183 my_error(ER_INVALID_GROUP_FUNC_USE, MYF(0));
2184 DBUG_RETURN(1);
2185 }
2186 main_table=join->join_tab->table;
2187 table_to_update= 0;
2188
2189 /* Any update has at least one pair (field, value) */
2190 DBUG_ASSERT(fields->elements);
2191 /*
2192 Only one table may be modified by UPDATE of an updatable view.
2193 For an updatable view first_table_for_update indicates this
2194 table.
2195 For a regular multi-update it refers to some updated table.
2196 */
2197 TABLE *first_table_for_update= ((Item_field *) fields->head())->field->table;
2198
2199 /* Create a temporary table for keys to all tables, except main table */
2200 for (table_ref= update_tables; table_ref; table_ref= table_ref->next_local)
2201 {
2202 TABLE *table=table_ref->table;
2203 uint index= table_ref->shared;
2204 List<Item> temp_fields;
2205 ORDER group;
2206 TMP_TABLE_PARAM *tmp_param;
2207
2208 table->file->prepare_for_modify(true, true);
2209
2210 if (ignore)
2211 table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
2212 if (table == main_table) // First table in join
2213 {
2214 if (safe_update_on_fly(thd, join->join_tab, table_ref, all_tables))
2215 {
2216 table_to_update= table; // Update table on the fly
2217 has_vers_fields= table->vers_check_update(*fields);
2218 continue;
2219 }
2220 }
2221 table->prepare_for_position();
2222 join->map2table[table->tablenr]->keep_current_rowid= true;
2223
2224 /*
2225 enable uncacheable flag if we update a view with check option
2226 and check option has a subselect, otherwise, the check option
2227 can be evaluated after the subselect was freed as independent
2228 (See full_local in JOIN::join_free()).

Callers

nothing calls this directly

Calls 15

error_if_full_joinFunction · 0.85
my_errorFunction · 0.85
safe_update_on_flyFunction · 0.85
calc_group_bufferFunction · 0.85
create_tmp_tableFunction · 0.85
have_window_funcsMethod · 0.80
prepare_for_modifyMethod · 0.80
vers_check_updateMethod · 0.80
prepare_for_positionMethod · 0.80
first_inner_unitMethod · 0.80
next_unitMethod · 0.80
first_selectMethod · 0.80

Tested by

no test coverage detected