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

Function multi_delete_precheck

sql/sql_parse.cc:9573–9618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9571*/
9572
9573bool multi_delete_precheck(THD *thd, TABLE_LIST *tables)
9574{
9575 SELECT_LEX *select_lex= thd->lex->first_select_lex();
9576 TABLE_LIST *aux_tables= thd->lex->auxiliary_table_list.first;
9577 TABLE_LIST **save_query_tables_own_last= thd->lex->query_tables_own_last;
9578 DBUG_ENTER("multi_delete_precheck");
9579
9580 /*
9581 Temporary tables are pre-opened in 'tables' list only. Here we need to
9582 initialize TABLE instances in 'aux_tables' list.
9583 */
9584 for (TABLE_LIST *tl= aux_tables; tl; tl= tl->next_global)
9585 {
9586 if (tl->table)
9587 continue;
9588
9589 if (tl->correspondent_table)
9590 tl->table= tl->correspondent_table->table;
9591 }
9592
9593 /* sql_yacc guarantees that tables and aux_tables are not zero */
9594 DBUG_ASSERT(aux_tables != 0);
9595 if (check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE))
9596 DBUG_RETURN(TRUE);
9597
9598 /*
9599 Since aux_tables list is not part of LEX::query_tables list we
9600 have to juggle with LEX::query_tables_own_last value to be able
9601 call check_table_access() safely.
9602 */
9603 thd->lex->query_tables_own_last= 0;
9604 if (check_table_access(thd, DELETE_ACL, aux_tables, FALSE, UINT_MAX, FALSE))
9605 {
9606 thd->lex->query_tables_own_last= save_query_tables_own_last;
9607 DBUG_RETURN(TRUE);
9608 }
9609 thd->lex->query_tables_own_last= save_query_tables_own_last;
9610
9611 if ((thd->variables.option_bits & OPTION_SAFE_UPDATES) && !select_lex->where)
9612 {
9613 my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,
9614 ER_THD(thd, ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0));
9615 DBUG_RETURN(TRUE);
9616 }
9617 DBUG_RETURN(FALSE);
9618}
9619
9620
9621/*

Callers 1

precheckMethod · 0.85

Calls 3

my_messageFunction · 0.85
first_select_lexMethod · 0.80
check_table_accessFunction · 0.70

Tested by

no test coverage detected