2499
Multi delete query pre-check.
2501
@param session Thread handler
2502
@param tables Global/local table list
2510
bool multi_delete_precheck(Session *session, TableList *)
2512
Select_Lex *select_lex= &session->lex->select_lex;
2513
TableList **save_query_tables_own_last= session->lex->query_tables_own_last;
2515
session->lex->query_tables_own_last= 0;
2516
session->lex->query_tables_own_last= save_query_tables_own_last;
2518
if ((session->options & OPTION_SAFE_UPDATES) && !select_lex->where)
2520
my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,
2521
ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0));
2529
Given a table in the source list, find a correspondent table in the
2530
table references list.
2532
@param lex Pointer to LEX representing multi-delete.
2533
@param src Source table to match.
2534
@param ref Table references list.
2536
@remark The source table list (tables listed before the FROM clause
2537
or tables listed in the FROM clause before the USING clause) may
2538
contain table names or aliases that must match unambiguously one,
2539
and only one, table in the target table list (table references list,
2540
after FROM/USING clause).
2542
@return Matching table, NULL otherwise.
2545
static TableList *multi_delete_table_match(LEX *, TableList *tbl,
2548
TableList *match= NULL;
2550
for (TableList *elem= tables; elem; elem= elem->next_local)
2554
if (tbl->is_fqtn && elem->is_alias)
2555
continue; /* no match */
2556
if (tbl->is_fqtn && elem->is_fqtn)
2557
cmp= my_strcasecmp(table_alias_charset, tbl->table_name, elem->table_name) ||
2558
strcmp(tbl->db, elem->db);
2559
else if (elem->is_alias)
2560
cmp= my_strcasecmp(table_alias_charset, tbl->alias, elem->alias);
2562
cmp= my_strcasecmp(table_alias_charset, tbl->table_name, elem->table_name) ||
2563
strcmp(tbl->db, elem->db);
2570
my_error(ER_NONUNIQ_TABLE, MYF(0), elem->alias);
2578
my_error(ER_UNKNOWN_TABLE, MYF(0), tbl->table_name, "MULTI DELETE");
2585
Link tables in auxilary table list of multi-delete with corresponding
2586
elements in main table list, and set proper locks for them.
2588
@param lex pointer to LEX representing multi-delete
2596
bool multi_delete_set_locks_and_link_aux_tables(LEX *lex)
2598
TableList *tables= (TableList*)lex->select_lex.table_list.first;
2599
TableList *target_tbl;
2601
lex->table_count= 0;
2603
for (target_tbl= (TableList *)lex->auxiliary_table_list.first;
2604
target_tbl; target_tbl= target_tbl->next_local)
2607
/* All tables in aux_tables must be found in FROM PART */
2608
TableList *walk= multi_delete_table_match(lex, target_tbl, tables);
2613
target_tbl->table_name= walk->table_name;
2614
target_tbl->table_name_length= walk->table_name_length;
2616
walk->updating= target_tbl->updating;
2617
walk->lock_type= target_tbl->lock_type;
2618
target_tbl->correspondent_table= walk; // Remember corresponding table
2625
2500
simple INSERT query pre-check.