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

Method initialize_tables

sql/sql_delete.cc:1256–1367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1254}
1255
1256bool
1257multi_delete::initialize_tables(JOIN *join)
1258{
1259 TABLE_LIST *walk;
1260 DBUG_ENTER("initialize_tables");
1261
1262 if (unlikely((thd->variables.option_bits & OPTION_SAFE_UPDATES) &&
1263 error_if_full_join(join)))
1264 DBUG_RETURN(1);
1265 main_table=join->join_tab->table;
1266
1267 table_map tables_to_delete_from= 0;
1268 delete_while_scanning= true;
1269 for (walk= delete_tables; walk; walk= walk->next_local)
1270 {
1271 TABLE_LIST *tbl= walk->correspondent_table->find_table_for_update();
1272 tables_to_delete_from|= tbl->table->map;
1273
1274 /*
1275 Ensure that filesort re-reads the row from the engine before
1276 delete is called.
1277 */
1278 join->map2table[tbl->table->tablenr]->keep_current_rowid= true;
1279
1280 if (delete_while_scanning &&
1281 unique_table(thd, tbl, join->tables_list, 0))
1282 {
1283 /*
1284 If the table we are going to delete from appears
1285 in join, we need to defer delete. So the delete
1286 doesn't interfere with the scanning of results.
1287 */
1288 delete_while_scanning= false;
1289 }
1290 }
1291
1292 walk= delete_tables;
1293 uint index= 0;
1294 for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_BUSH_ROOTS,
1295 WITH_CONST_TABLES);
1296 tab;
1297 tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
1298 {
1299 if (!tab->bush_children && tab->table->map & tables_to_delete_from)
1300 {
1301 /* We are going to delete from this table */
1302 TABLE *tbl=walk->table=tab->table;
1303 TABLE_LIST *prior= walk;
1304 walk= walk->next_local;
1305 /* Don't use KEYREAD optimization on this table */
1306 tbl->no_keyread=1;
1307 /* Don't use record cache */
1308 tbl->no_cache= 1;
1309 tbl->covering_keys.clear_all();
1310 if (tbl->file->has_transactions())
1311 transactional_tables= 1;
1312 else
1313 normal_tables= 1;

Callers

nothing calls this directly

Calls 15

error_if_full_joinFunction · 0.85
unique_tableFunction · 0.85
first_linear_tabFunction · 0.85
next_linear_tabFunction · 0.85
calc_group_bufferFunction · 0.85
create_tmp_tableFunction · 0.85
init_ftfuncsFunction · 0.85
find_table_for_updateMethod · 0.80
clear_allMethod · 0.80
has_transactionsMethod · 0.80
prepare_for_positionMethod · 0.80

Tested by

no test coverage detected