diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 4 | ||||
-rw-r--r-- | sql/item.cc | 3 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 4 | ||||
-rw-r--r-- | sql/set_var.cc | 4 | ||||
-rw-r--r-- | sql/sp_head.cc | 4 | ||||
-rw-r--r-- | sql/sql_class.h | 9 | ||||
-rw-r--r-- | sql/sql_insert.cc | 22 | ||||
-rw-r--r-- | sql/sql_load.cc | 5 | ||||
-rw-r--r-- | sql/sql_signal.cc | 6 | ||||
-rw-r--r-- | sql/sql_table.cc | 13 | ||||
-rw-r--r-- | sql/sql_update.cc | 9 | ||||
-rw-r--r-- | sql/unireg.cc | 6 |
12 files changed, 29 insertions, 60 deletions
diff --git a/sql/field.cc b/sql/field.cc index 0ca3f1b6ad6..e0ecd6ab74f 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9004,9 +9004,7 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, A default other than '' is always an error, and any non-NULL specified default is an error in strict mode. */ - if (res->length() || (thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES))) + if (res->length() || thd->is_strict_mode()) { my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), fld_name); /* purecov: inspected */ diff --git a/sql/item.cc b/sql/item.cc index 216ef628271..5f4b34ea552 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5514,8 +5514,7 @@ String *Item::check_well_formed_result(String *str, bool send_error) cs->csname, hexbuf); return 0; } - if ((thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))) + if (thd->is_strict_mode()) { null_value= 1; str= 0; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index c2a7edb735a..021a793618f 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -124,9 +124,7 @@ bool Item_str_func::fix_fields(THD *thd, Item **ref) In Item_str_func::check_well_formed_result() we may set null_value flag on the same condition as in test() below. */ - maybe_null= (maybe_null || - test(thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))); + maybe_null= maybe_null || thd->is_strict_mode(); return res; } diff --git a/sql/set_var.cc b/sql/set_var.cc index bf18ca49b37..be624351731 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -311,7 +311,7 @@ bool throw_bounds_warning(THD *thd, const char *name, else llstr(v, buf); - if (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) + if (thd->is_strict_mode()) { my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buf); return true; @@ -331,7 +331,7 @@ bool throw_bounds_warning(THD *thd, const char *name, bool fixed, double v) my_gcvt(v, MY_GCVT_ARG_DOUBLE, sizeof(buf) - 1, buf, NULL); - if (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) + if (thd->is_strict_mode()) { my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buf); return true; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index bde54ea2443..2ab5f96d4cb 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -385,9 +385,7 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr) */ thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; - thd->abort_on_warning= - thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES); + thd->abort_on_warning= thd->is_strict_mode(); thd->transaction.stmt.modified_non_trans_table= FALSE; /* Save the value in the field. Convert the value if needed. */ diff --git a/sql/sql_class.h b/sql/sql_class.h index c061e6c2bb2..3dbccf9b41e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2564,6 +2564,11 @@ public: mysql_mutex_unlock(&mysys_var->mutex); return; } + inline bool is_strict_mode() const + { + return variables.sql_mode & (MODE_STRICT_TRANS_TABLES | + MODE_STRICT_ALL_TABLES); + } inline my_time_t query_start() { query_start_used=1; return start_time; } inline ulong query_start_sec_part() { query_start_sec_part_used=1; return start_time_sec_part; } @@ -3337,7 +3342,7 @@ my_eof(THD *thd) const my_bool strict_date_checking= 0; -inline ulong sql_mode_for_dates(THD *thd) +inline ulonglong sql_mode_for_dates(THD *thd) { if (strict_date_checking) return (thd->variables.sql_mode & @@ -3346,7 +3351,7 @@ inline ulong sql_mode_for_dates(THD *thd) return (thd->variables.sql_mode & MODE_INVALID_DATES); } -inline ulong sql_mode_for_dates() +inline ulonglong sql_mode_for_dates() { return sql_mode_for_dates(current_thd); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 599a892da9f..25c696bc476 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -790,9 +790,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, FALSE, (fields.elements || !value_count || table_list->view != 0), - !ignore && (thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES)))) + !ignore && thd->is_strict_mode())) goto abort; /* mysql_prepare_insert set table_list->table if it was not set */ @@ -904,9 +902,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, } } - thd->abort_on_warning= (!ignore && (thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES))); + thd->abort_on_warning= !ignore && thd->is_strict_mode(); prepare_triggers_for_insert_stmt(table); @@ -3339,9 +3335,7 @@ 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->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES)); + thd->abort_on_warning= !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; @@ -3456,10 +3450,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE); if (info.handle_duplicates == DUP_UPDATE) table->file->extra(HA_EXTRA_INSERT_WITH_UPDATE); - thd->abort_on_warning= (!info.ignore && - (thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES))); + thd->abort_on_warning= !info.ignore && thd->is_strict_mode(); res= (table_list->prepare_where(thd, 0, TRUE) || table_list->prepare_check_option(thd)); @@ -4076,10 +4067,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u) table->file->extra(HA_EXTRA_INSERT_WITH_UPDATE); if (thd->locked_tables_mode <= LTM_LOCK_TABLES) table->file->ha_start_bulk_insert((ha_rows) 0); - thd->abort_on_warning= (!info.ignore && - (thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES))); + thd->abort_on_warning= !info.ignore && thd->is_strict_mode(); if (check_that_all_fields_are_given_values(thd, table, table_list)) DBUG_RETURN(1); table->mark_columns_needed_for_insert(); diff --git a/sql/sql_load.cc b/sql/sql_load.cc index e2c744401b9..daa9298d52d 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -487,10 +487,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, table->file->ha_start_bulk_insert((ha_rows) 0); table->copy_blobs=1; - thd->abort_on_warning= (!ignore && - (thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES))); + thd->abort_on_warning= !ignore && thd->is_strict_mode(); thd_progress_init(thd, 2); if (ex->filetype == FILETYPE_XML) /* load xml */ diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc index c9f1f42159f..9da10f5b2f5 100644 --- a/sql/sql_signal.cc +++ b/sql/sql_signal.cc @@ -243,8 +243,7 @@ static int assign_condition_item(MEM_ROOT *mem_root, const char* name, THD *thd, truncated= assign_fixed_string(mem_root, & my_charset_utf8_bin, 64, ci, str); if (truncated) { - if (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES)) + if (thd->is_strict_mode()) { thd->raise_error_printf(ER_COND_ITEM_TOO_LONG, name); DBUG_RETURN(1); @@ -348,8 +347,7 @@ int Signal_common::eval_signal_informations(THD *thd, MYSQL_ERROR *cond) & utf8_text, str); if (truncated) { - if (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES)) + if (thd->is_strict_mode()) { thd->raise_error_printf(ER_COND_ITEM_TOO_LONG, "MESSAGE_TEXT"); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f74d5427266..66e3b0b2544 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2552,8 +2552,7 @@ bool check_duplicates_in_interval(const char *set_or_name, { THD *thd= current_thd; ErrConvString err(*cur_value, *cur_length, cs); - if ((current_thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))) + if (current_thd->is_strict_mode()) { my_error(ER_DUPLICATED_VALUE_IN_TYPE, MYF(0), name, err.ptr(), set_or_name); @@ -3734,8 +3733,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, if (tmp_len < key->key_create_info.comment.length) { - if ((thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))) + if (thd->is_strict_mode()) { my_error(ER_TOO_LONG_INDEX_COMMENT, MYF(0), key_info->name, static_cast<ulong>(INDEX_COMMENT_MAXLEN)); @@ -3873,8 +3871,7 @@ static bool prepare_blob_field(THD *thd, Create_field *sql_field) /* Convert long VARCHAR columns to TEXT or BLOB */ char warn_buff[MYSQL_ERRMSG_SIZE]; - if (sql_field->def || (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES))) + if (sql_field->def || thd->is_strict_mode()) { my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), sql_field->field_name, static_cast<ulong>(MAX_FIELD_VARCHARLENGTH / @@ -7354,9 +7351,7 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to, alter_table_manage_keys(to, from->file->indexes_are_disabled(), keys_onoff); /* We can abort alter table for any table type */ - thd->abort_on_warning= !ignore && test(thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES)); + thd->abort_on_warning= !ignore && thd->is_strict_mode(); from->file->info(HA_STATUS_VARIABLE); to->file->ha_start_bulk_insert(from->file->stats.records); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index c131db1bffc..42e2eb6cbfd 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -643,10 +643,7 @@ int mysql_update(THD *thd, THD_STAGE_INFO(thd, stage_updating); transactional_table= table->file->has_transactions(); - thd->abort_on_warning= test(!ignore && - (thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES))); + thd->abort_on_warning= !ignore && thd->is_strict_mode(); if (table->triggers && table->triggers->has_triggers(TRG_EVENT_UPDATE, TRG_ACTION_AFTER)) @@ -1391,9 +1388,7 @@ bool mysql_multi_update(THD *thd, DBUG_RETURN(TRUE); } - thd->abort_on_warning= test(thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | - MODE_STRICT_ALL_TABLES)); + thd->abort_on_warning= thd->is_strict_mode(); List<Item> total_list; diff --git a/sql/unireg.cc b/sql/unireg.cc index edcfe9eb934..72dbbf973e0 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -241,8 +241,7 @@ bool mysql_create_frm(THD *thd, const char *file_name, (real_table_name= field->field->table->s->table_name.str)) break; } - if ((thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))) + if (thd->is_strict_mode()) { my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0), real_table_name, static_cast<ulong>(TABLE_COMMENT_MAXLEN)); @@ -707,8 +706,7 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type, COLUMN_COMMENT_MAXLEN); if (tmp_len < field->comment.length) { - if ((current_thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))) + if (current_thd->is_strict_mode()) { my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name, static_cast<ulong>(COLUMN_COMMENT_MAXLEN)); |