summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/debug_sync.cc4
-rw-r--r--sql/event_db_repository.cc4
-rw-r--r--sql/field.cc4
-rw-r--r--sql/ha_partition.cc3
-rw-r--r--sql/item.cc3
-rw-r--r--sql/partition_info.cc6
-rw-r--r--sql/sp.cc13
-rw-r--r--sql/sp_head.cc4
-rw-r--r--sql/sql_acl.cc8
-rw-r--r--sql/sql_class.h39
-rw-r--r--sql/sql_help.cc4
-rw-r--r--sql/sql_insert.cc4
-rw-r--r--sql/sql_partition.cc4
-rw-r--r--sql/sql_prepare.cc5
-rw-r--r--sql/sql_table.cc8
-rw-r--r--sql/sql_view.cc5
-rw-r--r--sql/table.cc18
17 files changed, 65 insertions, 71 deletions
diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc
index bf721bddb85..19ea40106df 100644
--- a/sql/debug_sync.cc
+++ b/sql/debug_sync.cc
@@ -1451,12 +1451,10 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
if (unlikely(error == ETIMEDOUT || error == ETIME))
{
// We should not make the statement fail, even if in strict mode.
- const bool save_abort_on_warning= thd->abort_on_warning;
- thd->abort_on_warning= false;
+ Abort_on_warning_instant_set aws(thd, false);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
ER_DEBUG_SYNC_TIMEOUT,
ER_THD(thd, ER_DEBUG_SYNC_TIMEOUT));
- thd->abort_on_warning= save_abort_on_warning;
DBUG_EXECUTE_IF("debug_sync_abort_on_timeout", DBUG_ASSERT(0););
break;
}
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index dc47ed0b2e1..6783338ab10 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -1061,7 +1061,6 @@ Event_db_repository::load_named_event(THD *thd, const LEX_CSTRING *dbname,
Event_basic *etn)
{
bool ret;
- ulonglong saved_mode= thd->variables.sql_mode;
Open_tables_backup open_tables_backup;
TABLE_LIST event_table;
@@ -1072,7 +1071,7 @@ Event_db_repository::load_named_event(THD *thd, const LEX_CSTRING *dbname,
event_table.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_EVENT_NAME, 0, TL_READ);
/* Reset sql_mode during data dictionary operations. */
- thd->variables.sql_mode= 0;
+ Sql_mode_instant_set sms(thd, 0);
/*
We don't use open_event_table() here to make sure that SHOW
@@ -1097,7 +1096,6 @@ Event_db_repository::load_named_event(THD *thd, const LEX_CSTRING *dbname,
close_system_tables(thd, &open_tables_backup);
}
- thd->variables.sql_mode= saved_mode;
DBUG_RETURN(ret);
}
diff --git a/sql/field.cc b/sql/field.cc
index e486f8ddf1f..92c3f997186 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -11230,8 +11230,7 @@ bool Field::val_str_nopad(MEM_ROOT *mem_root, LEX_CSTRING *to)
StringBuffer<MAX_FIELD_WIDTH> str;
bool rc= false;
THD *thd= get_thd();
- sql_mode_t sql_mode_backup= thd->variables.sql_mode;
- thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+ Sql_mode_instant_remove sms(thd, MODE_PAD_CHAR_TO_FULL_LENGTH);
val_str(&str);
if (!(to->length= str.length()))
@@ -11239,6 +11238,5 @@ bool Field::val_str_nopad(MEM_ROOT *mem_root, LEX_CSTRING *to)
else if ((rc= !(to->str= strmake_root(mem_root, str.ptr(), str.length()))))
to->length= 0;
- thd->variables.sql_mode= sql_mode_backup;
return rc;
}
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 733bc1953ba..8f5e4e33e47 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -4256,7 +4256,7 @@ int ha_partition::write_row(uchar * buf)
bool have_auto_increment= table->next_number_field && buf == table->record[0];
my_bitmap_map *old_map;
THD *thd= ha_thd();
- sql_mode_t saved_sql_mode= thd->variables.sql_mode;
+ Sql_mode_save sms(thd);
bool saved_auto_inc_field_not_null= table->auto_increment_field_not_null;
DBUG_ENTER("ha_partition::write_row");
DBUG_PRINT("enter", ("partition this: %p", this));
@@ -4322,7 +4322,6 @@ int ha_partition::write_row(uchar * buf)
reenable_binlog(thd);
exit:
- thd->variables.sql_mode= saved_sql_mode;
table->auto_increment_field_not_null= saved_auto_inc_field_not_null;
DBUG_RETURN(error);
}
diff --git a/sql/item.cc b/sql/item.cc
index b793f3eb783..84fd4dc6fb7 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1411,7 +1411,7 @@ int Item::save_in_field_no_warnings(Field *field, bool no_conversions)
THD *thd= table->in_use;
enum_check_fields tmp= thd->count_cuted_fields;
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
- sql_mode_t sql_mode= thd->variables.sql_mode;
+ Sql_mode_save sms(thd);
thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
thd->variables.sql_mode|= MODE_INVALID_DATES;
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
@@ -1420,7 +1420,6 @@ int Item::save_in_field_no_warnings(Field *field, bool no_conversions)
thd->count_cuted_fields= tmp;
dbug_tmp_restore_column_map(table->write_set, old_map);
- thd->variables.sql_mode= sql_mode;
return res;
}
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index ba6fc8a49ec..66216493de8 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -2146,7 +2146,6 @@ bool partition_info::fix_column_value_functions(THD *thd,
{
uchar *val_ptr;
uint len= field->pack_length();
- sql_mode_t save_sql_mode;
bool save_got_warning;
if (!(column_item= get_column_item(column_item, field)))
@@ -2154,20 +2153,17 @@ bool partition_info::fix_column_value_functions(THD *thd,
result= TRUE;
goto end;
}
- save_sql_mode= thd->variables.sql_mode;
- thd->variables.sql_mode= 0;
+ Sql_mode_instant_set sms(thd, 0);
save_got_warning= thd->got_warning;
thd->got_warning= 0;
if (column_item->save_in_field(field, TRUE) ||
thd->got_warning)
{
my_error(ER_WRONG_TYPE_COLUMN_VALUE_ERROR, MYF(0));
- thd->variables.sql_mode= save_sql_mode;
result= TRUE;
goto end;
}
thd->got_warning= save_got_warning;
- thd->variables.sql_mode= save_sql_mode;
if (!(val_ptr= (uchar*) thd->memdup(field->ptr, len)))
{
result= TRUE;
diff --git a/sql/sp.cc b/sql/sp.cc
index 8568bc16c00..c9d1e2e3c4a 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -683,7 +683,7 @@ Sp_handler::db_find_routine(THD *thd,
longlong modified;
Sp_chistics chistics;
bool saved_time_zone_used= thd->time_zone_used;
- sql_mode_t sql_mode, saved_mode= thd->variables.sql_mode;
+ sql_mode_t sql_mode;
Open_tables_backup open_tables_state_backup;
Stored_program_creation_ctx *creation_ctx;
AUTHID definer;
@@ -698,7 +698,7 @@ Sp_handler::db_find_routine(THD *thd,
DBUG_RETURN(SP_OPEN_TABLE_FAILED);
/* Reset sql_mode during data dictionary operations. */
- thd->variables.sql_mode= 0;
+ Sql_mode_instant_set sms(thd, 0);
if ((ret= db_find_routine_aux(thd, name, table)) != SP_OK)
goto done;
@@ -755,7 +755,6 @@ Sp_handler::db_find_routine(THD *thd,
thd->time_zone_used= saved_time_zone_used;
if (table)
close_system_tables(thd, &open_tables_state_backup);
- thd->variables.sql_mode= saved_mode;
DBUG_RETURN(ret);
}
@@ -1524,8 +1523,7 @@ Sp_handler_package::show_create_sp(THD *thd, String *buf,
const DDL_options_st ddl_options,
sql_mode_t sql_mode) const
{
- sql_mode_t old_sql_mode= thd->variables.sql_mode;
- thd->variables.sql_mode= sql_mode;
+ Sql_mode_instant_set sms(thd, sql_mode);
bool rc=
buf->append(STRING_WITH_LEN("CREATE ")) ||
(ddl_options.or_replace() &&
@@ -1542,7 +1540,6 @@ Sp_handler_package::show_create_sp(THD *thd, String *buf,
append_package_chistics(buf, chistics) ||
buf->append(" ", 1) ||
buf->append(body.str, body.length);
- thd->variables.sql_mode= old_sql_mode;
return rc;
}
@@ -2914,7 +2911,6 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
const DDL_options_st ddl_options,
sql_mode_t sql_mode) const
{
- sql_mode_t old_sql_mode= thd->variables.sql_mode;
size_t agglen= (chistics.agg_type == GROUP_AGGREGATE)? 10 : 0;
LEX_CSTRING tmp;
@@ -2925,7 +2921,7 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
agglen + USER_HOST_BUFF_SIZE))
return true;
- thd->variables.sql_mode= sql_mode;
+ Sql_mode_instant_set sms(thd, sql_mode);
buf->append(STRING_WITH_LEN("CREATE "));
if (ddl_options.or_replace())
buf->append(STRING_WITH_LEN("OR REPLACE "));
@@ -2976,7 +2972,6 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
append_suid(buf, chistics.suid);
append_comment(buf, chistics.comment);
buf->append(body.str, body.length); // Not \0 terminated
- thd->variables.sql_mode= old_sql_mode;
return false;
}
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 1a014f6acca..889e0b42698 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -3819,10 +3819,8 @@ sp_instr_set_trigger_field::execute(THD *thd, uint *nextp)
int
sp_instr_set_trigger_field::exec_core(THD *thd, uint *nextp)
{
- bool sav_abort_on_warning= thd->abort_on_warning;
- thd->abort_on_warning= thd->is_strict_mode() && !thd->lex->ignore;
+ Abort_on_warning_instant_set aws(thd, thd->is_strict_mode() && !thd->lex->ignore);
const int res= (trigger_field->set_value(thd, &value) ? -1 : 0);
- thd->abort_on_warning= sav_abort_on_warning;
*nextp = m_ip+1;
return res;
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index aab41dd00ef..7a82d89f1bb 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -7607,10 +7607,9 @@ static bool grant_load(THD *thd,
TABLE *t_table, *c_table, *p_table;
bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
MEM_ROOT *save_mem_root= thd->mem_root;
- sql_mode_t old_sql_mode= thd->variables.sql_mode;
DBUG_ENTER("grant_load");
- thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+ Sql_mode_instant_remove sms(thd, MODE_PAD_CHAR_TO_FULL_LENGTH);
(void) my_hash_init(&column_priv_hash, &my_charset_utf8_bin,
0,0,0, (my_hash_get_key) get_grant_table,
@@ -7735,7 +7734,6 @@ end_unlock:
t_table->file->ha_index_end();
thd->mem_root= save_mem_root;
end_index_init:
- thd->variables.sql_mode= old_sql_mode;
DBUG_RETURN(return_val);
}
@@ -10722,7 +10720,6 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list, bool handle_as_role)
LEX_USER *user_name, *tmp_user_name;
List_iterator <LEX_USER> user_list(list);
bool binlog= false;
- sql_mode_t old_sql_mode= thd->variables.sql_mode;
DBUG_ENTER("mysql_drop_user");
DBUG_PRINT("entry", ("Handle as %s", handle_as_role ? "role" : "user"));
@@ -10734,7 +10731,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list, bool handle_as_role)
if ((result= tables.open_and_lock(thd, tables_to_open, TL_WRITE)))
DBUG_RETURN(result != 1);
- thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+ Sql_mode_instant_remove sms(thd, MODE_PAD_CHAR_TO_FULL_LENGTH);
mysql_rwlock_wrlock(&LOCK_grant);
mysql_mutex_lock(&acl_cache->lock);
@@ -10809,7 +10806,6 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list, bool handle_as_role)
result |= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
mysql_rwlock_unlock(&LOCK_grant);
- thd->variables.sql_mode= old_sql_mode;
DBUG_RETURN(result);
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index a2615aa0c7f..63f964e96ce 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -6677,6 +6677,45 @@ class Sql_mode_save
};
+class Sql_mode_instant_set: public Sql_mode_save
+{
+public:
+ Sql_mode_instant_set(THD *thd, sql_mode_t temporary_value)
+ :Sql_mode_save(thd)
+ {
+ thd->variables.sql_mode= temporary_value;
+ }
+};
+
+
+class Sql_mode_instant_remove: public Sql_mode_save
+{
+public:
+ Sql_mode_instant_remove(THD *thd, sql_mode_t temporary_remove_flags)
+ :Sql_mode_save(thd)
+ {
+ thd->variables.sql_mode&= ~temporary_remove_flags;
+ }
+};
+
+
+class Abort_on_warning_instant_set
+{
+ THD *m_thd;
+ bool m_save_abort_on_warning;
+public:
+ Abort_on_warning_instant_set(THD *thd, bool temporary_value)
+ :m_thd(thd), m_save_abort_on_warning(thd->abort_on_warning)
+ {
+ thd->abort_on_warning= temporary_value;
+ }
+ ~Abort_on_warning_instant_set()
+ {
+ m_thd->abort_on_warning= m_save_abort_on_warning;
+ }
+};
+
+
/**
This class resembles the SQL Standard schema qualified object name:
<schema qualified name> ::= [ <schema name> <period> ] <qualified identifier>
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index e3e22bf38fb..c9307b578fc 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -856,9 +856,7 @@ error2:
bool mysqld_help(THD *thd, const char *mask)
{
- sql_mode_t sql_mode_backup= thd->variables.sql_mode;
- thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+ Sql_mode_instant_remove sms(thd, MODE_PAD_CHAR_TO_FULL_LENGTH);
bool rc= mysqld_help_internal(thd, mask);
- thd->variables.sql_mode= sql_mode_backup;
return rc;
}
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index d25d831cac1..1c0c0301e7d 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -3655,10 +3655,8 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if (!res && fields->elements)
{
- bool saved_abort_on_warning= thd->abort_on_warning;
- thd->abort_on_warning= !info.ignore && thd->is_strict_mode();
+ Abort_on_warning_instant_set aws(thd, !info.ignore && thd->is_strict_mode());
res= check_that_all_fields_are_given_values(thd, table_list->table, table_list);
- thd->abort_on_warning= saved_abort_on_warning;
}
if (info.handle_duplicates == DUP_UPDATE && !res)
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 811d7fd2529..e24a8962dcd 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -2584,11 +2584,9 @@ char *generate_partition_syntax_for_frm(THD *thd, partition_info *part_info,
HA_CREATE_INFO *create_info,
Alter_info *alter_info)
{
- sql_mode_t old_mode= thd->variables.sql_mode;
- thd->variables.sql_mode &= ~MODE_ANSI_QUOTES;
+ Sql_mode_instant_remove sms(thd, MODE_ANSI_QUOTES);
char *res= generate_partition_syntax(thd, part_info, buf_length,
true, create_info, alter_info);
- thd->variables.sql_mode= old_mode;
return res;
}
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 8088b6923f2..68c9edc9283 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -4499,12 +4499,11 @@ Prepared_statement::reprepare()
TRUE, &cur_db_changed)))
return TRUE;
- sql_mode_t save_sql_mode= thd->variables.sql_mode;
- thd->variables.sql_mode= m_sql_mode;
+ Sql_mode_instant_set sms(thd, m_sql_mode);
+
error= ((name.str && copy.set_name(&name)) ||
copy.prepare(query(), query_length()) ||
validate_metadata(&copy));
- thd->variables.sql_mode= save_sql_mode;
if (cur_db_changed)
mysql_change_db(thd, (LEX_CSTRING*) &saved_cur_db_name, TRUE);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index a025bca286b..95bc483bc39 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -10408,14 +10408,12 @@ err_new_table_cleanup:
/* Shouldn't get here. */
DBUG_ASSERT(0);
}
- bool save_abort_on_warning= thd->abort_on_warning;
- thd->abort_on_warning= true;
+ Abort_on_warning_instant_set aws(thd, true);
thd->push_warning_truncated_value_for_field(Sql_condition::WARN_LEVEL_WARN,
f_type, f_val,
new_table->s,
alter_ctx.datetime_field->
field_name.str);
- thd->abort_on_warning= save_abort_on_warning;
}
if (new_table)
@@ -10620,14 +10618,12 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
to->file->ha_table_flags() & HA_TABLE_SCAN_ON_INDEX)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
- bool save_abort_on_warning= thd->abort_on_warning;
- thd->abort_on_warning= false;
+ Abort_on_warning_instant_set aws(thd, false);
my_snprintf(warn_buff, sizeof(warn_buff),
"ORDER BY ignored as there is a user-defined clustered index"
" in the table '%-.192s'", from->s->table_name.str);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
warn_buff);
- thd->abort_on_warning= save_abort_on_warning;
}
else
{
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 04cdfbcb5bf..ca66da1fd0d 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -926,16 +926,13 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
view_query.length(0);
is_query.length(0);
{
- sql_mode_t sql_mode= thd->variables.sql_mode & MODE_ANSI_QUOTES;
- thd->variables.sql_mode&= ~MODE_ANSI_QUOTES;
+ Sql_mode_instant_remove sms(thd, MODE_ANSI_QUOTES);
lex->unit.print(&view_query, enum_query_type(QT_VIEW_INTERNAL |
QT_ITEM_ORIGINAL_FUNC_NULLIF));
lex->unit.print(&is_query, enum_query_type(QT_TO_SYSTEM_CHARSET |
QT_WITHOUT_INTRODUCERS |
QT_ITEM_ORIGINAL_FUNC_NULLIF));
-
- thd->variables.sql_mode|= sql_mode;
}
DBUG_PRINT("info", ("View: %.*s", view_query.length(), view_query.ptr()));
diff --git a/sql/table.cc b/sql/table.cc
index 3609ae50d71..70df668ab2b 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1077,7 +1077,6 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
Field **vfield_ptr= table->vfield;
Field **dfield_ptr= table->default_field;
Virtual_column_info **check_constraint_ptr= table->check_constraints;
- sql_mode_t saved_mode= thd->variables.sql_mode;
Query_arena backup_arena;
Virtual_column_info *vcol= 0;
StringBuffer<MAX_FIELD_WIDTH> expr_str;
@@ -1103,7 +1102,7 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
thd->stmt_arena= table->expr_arena;
thd->update_charset(&my_charset_utf8mb4_general_ci, table->s->table_charset);
expr_str.append(&parse_vcol_keyword);
- thd->variables.sql_mode &= ~MODE_NO_BACKSLASH_ESCAPES;
+ Sql_mode_instant_remove sms(thd, MODE_NO_BACKSLASH_ESCAPES);
while (pos < end)
{
@@ -1271,7 +1270,6 @@ end:
thd->stmt_arena= backup_stmt_arena_ptr;
if (save_character_set_client)
thd->update_charset(save_character_set_client, save_collation);
- thd->variables.sql_mode= saved_mode;
DBUG_RETURN(res);
}
@@ -3063,7 +3061,6 @@ static bool sql_unusable_for_discovery(THD *thd, handlerton *engine,
int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
const char *sql, size_t sql_length)
{
- sql_mode_t saved_mode= thd->variables.sql_mode;
CHARSET_INFO *old_cs= thd->variables.character_set_client;
Parser_state parser_state;
bool error;
@@ -3091,7 +3088,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
if (parser_state.init(thd, sql_copy, sql_length))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
- thd->variables.sql_mode= MODE_NO_ENGINE_SUBSTITUTION | MODE_NO_DIR_IN_CREATE;
+ Sql_mode_instant_set sms(thd, MODE_NO_ENGINE_SUBSTITUTION | MODE_NO_DIR_IN_CREATE);
thd->variables.character_set_client= system_charset_info;
tmp_disable_binlog(thd);
old_lex= thd->lex;
@@ -3140,7 +3137,6 @@ ret:
if (arena)
thd->restore_active_arena(arena, &backup);
reenable_binlog(thd);
- thd->variables.sql_mode= saved_mode;
thd->variables.character_set_client= old_cs;
if (unlikely(thd->is_error() || error))
{
@@ -4390,21 +4386,17 @@ bool get_field(MEM_ROOT *mem, Field *field, String *res)
StringBuffer<MAX_FIELD_WIDTH> str;
bool rc;
THD *thd= field->get_thd();
- sql_mode_t sql_mode_backup= thd->variables.sql_mode;
- thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+ Sql_mode_instant_remove sms(thd, MODE_PAD_CHAR_TO_FULL_LENGTH);
field->val_str(&str);
if ((rc= !str.length() ||
!(to= strmake_root(mem, str.ptr(), str.length()))))
{
res->length(0);
- goto ex;
+ return rc;
}
res->set(to, str.length(), field->charset());
-
-ex:
- thd->variables.sql_mode= sql_mode_backup;
- return rc;
+ return false;
}