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

cleanup: RAII helper for swapping of thd->security_ctx

This commit is contained in:
Sergei Golubchik
2019-09-10 17:24:34 +02:00
parent d752a97ebb
commit 42ada91542
2 changed files with 22 additions and 25 deletions

View File

@ -5967,6 +5967,22 @@ class Sql_mode_save
sql_mode_t old_mode; // SQL mode saved at construction time.
};
class Switch_to_definer_security_ctx
{
public:
Switch_to_definer_security_ctx(THD *thd, TABLE_LIST *table) :
m_thd(thd), m_sctx(thd->security_ctx)
{
if (table->security_ctx)
thd->security_ctx= table->security_ctx;
}
~Switch_to_definer_security_ctx() { m_thd->security_ctx = m_sctx; }
private:
THD *m_thd;
Security_context *m_sctx;
};
#endif /* MYSQL_SERVER */
#endif /* SQL_CLASS_INCLUDED */