Get the App
SLTechnology News&Howtos  ›  Database  › 

How to understand the effective point of sql_safe_updates in MySQL

Shulou Source: shulou.com Published: 2022-05-31 15:25:04 09月20日 Update

This article mainly explains "how to understand the sql_safe_updates effective point in MySQL", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to understand the sql_safe_updates effective point in MySQL"!

bool multi_delete_precheck(THD *thd, TABLE_LIST *tables){ SELECT_LEX *select_lex= thd->lex->select_lex; TABLE_LIST *aux_tables= thd->lex->auxiliary_table_list.first; TABLE_LIST **save_query_tables_own_last= thd->lex->query_tables_own_last; DBUG_ENTER("multi_delete_precheck"); /* sql_yacc guarantees that tables and aux_tables are not zero */ DBUG_ASSERT(aux_tables != 0); if (check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE)) DBUG_RETURN(TRUE); /* Since aux_tables list is not part of LEX::query_tables list we have to juggle with LEX::query_tables_own_last value to be able call check_table_access() safely. */ thd->lex->query_tables_own_last= 0; if (check_table_access(thd, DELETE_ACL, aux_tables, FALSE, UINT_MAX, FALSE)) { thd->lex->query_tables_own_last= save_query_tables_own_last; DBUG_RETURN(TRUE); } thd->lex->query_tables_own_last= save_query_tables_own_last; if ((thd->variables.option_bits & OPTION_SAFE_UPDATES) && ! select_lex->where_cond()) //Check whether the parameter is enabled and there is no where condition { my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0));//Error DBUG_RETURN(TRUE); } DBUG_RETURN(FALSE);}

A brief description of the function:

When SQL_SAFE_UPDATES = 1, update and delete statements without where and limit conditions cannot be executed, even update and delete statements with where and limit conditions but without key column cannot be executed.

When SQL_SAFE_UPDATES =0, update and delete operations will execute smoothly.

At this point, I believe that everyone has a deeper understanding of "how to understand the sql_safe_updates effective point in MySQL". Let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Conditions content learning practicality deeper interest function parameter at the same time practicality practicality simple operation method more friends website sentence channel query check Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology vpn OPPO Reno macOS