diff options
author | Alexander Barkov <bar@mariadb.org> | 2016-03-22 00:09:04 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2016-03-22 00:09:04 +0400 |
commit | 537fc572d451888d26c26d3e89c3237d1213be4d (patch) | |
tree | d72e910428039b1b1cdaf2bc511a2bc08ed7c236 /sql | |
parent | e8af217e16837000b8a3809e9fa48a5e75088cd0 (diff) | |
download | mariadb-git-537fc572d451888d26c26d3e89c3237d1213be4d.tar.gz |
MDEV-9516 type error when setting session variable
Allowing assigning of DECIMAL(N,0) values to INT-alike system variables.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/set_var.cc | 2 | ||||
-rw-r--r-- | sql/set_var.h | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc index 18f6cbc41fd..b5430c56865 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -739,7 +739,7 @@ int set_var::check(THD *thd) if ((!value->fixed && value->fix_fields(thd, &value)) || value->check_cols(1)) return -1; - if (var->check_update_type(value->result_type())) + if (var->check_update_type(value)) { my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name.str); return -1; diff --git a/sql/set_var.h b/sql/set_var.h index b8192e67ca9..cf86ecf18fa 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -137,8 +137,9 @@ public: bool is_set_stmt_ok() const { return !(flags & NO_SET_STATEMENT); } bool is_written_to_binlog(enum_var_type type) { return type != OPT_GLOBAL && binlog_status == SESSION_VARIABLE_IN_BINLOG; } - bool check_update_type(Item_result type) + bool check_update_type(const Item *item) { + Item_result type= item->result_type(); switch (option.var_type & GET_TYPE_MASK) { case GET_INT: case GET_UINT: @@ -146,7 +147,8 @@ public: case GET_ULONG: case GET_LL: case GET_ULL: - return type != INT_RESULT; + return type != INT_RESULT && + (type != DECIMAL_RESULT || item->decimals != 0); case GET_STR: case GET_STR_ALLOC: return type != STRING_RESULT; |