mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Define a helper class to allow for saving sql_mode using RAII
On construction the Sql_mode_save class stores the current THD's sql_mode. On destruction, the THD's mode is restored.
This commit is contained in:
@ -5712,6 +5712,22 @@ inline bool binlog_should_compress(ulong len)
|
||||
len >= opt_bin_log_compress_min_len;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Save thd sql_mode on instantiation.
|
||||
On destruction it resets the mode to the previously stored value.
|
||||
*/
|
||||
class Sql_mode_save
|
||||
{
|
||||
public:
|
||||
Sql_mode_save(THD *thd) : thd(thd), old_mode(thd->variables.sql_mode) {}
|
||||
~Sql_mode_save() { thd->variables.sql_mode = old_mode; }
|
||||
|
||||
private:
|
||||
THD *thd;
|
||||
sql_mode_t old_mode; // SQL mode saved at construction time.
|
||||
};
|
||||
|
||||
#endif /* MYSQL_SERVER */
|
||||
|
||||
#endif /* SQL_CLASS_INCLUDED */
|
||||
|
Reference in New Issue
Block a user