1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-22441 implement a generic way to change a value of a variable in a scope

Example:
{
  auto _= make_scope_value(var, tmp_value);
}

make_scope_value(): a function which returns RAII object which temporary
changes a value of a variable

detail::Scope_value: actual implementation of such RAII class.
It shouldn't be used directly! That's why it's inside a namespace detail.
This commit is contained in:
Eugene Kosov
2025-01-13 15:40:58 +03:00
committed by Aleksey Midenkov
parent b337e14440
commit 52dd489515
3 changed files with 51 additions and 4 deletions

View File

@ -54,6 +54,7 @@
#include "sql_array.h"
#include "sql_hset.h"
#include "password.h"
#include "scope.h"
#include "sql_plugin_compat.h"
#include "wsrep_mysqld.h"
@ -2552,10 +2553,11 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
{
READ_RECORD read_record_info;
char tmp_name[SAFE_NAME_LEN+1];
Sql_mode_save old_mode_save(thd);
DBUG_ENTER("acl_load");
thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
auto _= make_scope_value(thd->variables.sql_mode,
thd->variables.sql_mode &
~MODE_PAD_CHAR_TO_FULL_LENGTH);
grant_version++; /* Privileges updated */