summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@gleb.loc>2007-11-18 00:02:55 +0400
committerunknown <gshchepa/uchum@gleb.loc>2007-11-18 00:02:55 +0400
commit99054db64c8a41acbe570756e286a8d78811197c (patch)
treeacce2ade0392c10725743341a35697fc72c70260 /sql/item_cmpfunc.cc
parent4b48eb6f1e4565ba31982f73908664108ba0fb7b (diff)
downloadmariadb-git-99054db64c8a41acbe570756e286a8d78811197c.tar.gz
Fixed bug #32335.
Comparison of a BIGINT NOT NULL column with a constant arithmetic expression that evaluates to NULL caused error 1048: "Column '...' cannot be null". Made convert_constant_item() check if the constant expression is NULL before attempting to store it in a field. Attempts to store NULL in a NOT NULL field caused query errors. sql/item_cmpfunc.cc: Fixed bug #32335. 1. Made convert_constant_item() check if the constant expression is NULL before attempting to store it in a field. Attempts to store NULL in a NOT NULL field caused query errors. 2. Also minor bug has been fixed: the thd->count_cuted_fields value was not restored in case of successful conversion. mysql-test/t/select.test: Added test case for bug #32335. mysql-test/r/select.result: Added test case for bug #32335.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 85ec8fa40d6..f9744baf19e 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -350,11 +350,12 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
thd->variables.sql_mode= (orig_sql_mode & ~MODE_NO_ZERO_DATE) |
MODE_INVALID_DATES;
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
- if (!(*item)->save_in_field(field, 1) && !((*item)->null_value))
+ if (!(*item)->is_null() && !(*item)->save_in_field(field, 1))
{
Item *tmp=new Item_int_with_ref(field->val_int(), *item,
test(field->flags & UNSIGNED_FLAG));
thd->variables.sql_mode= orig_sql_mode;
+ thd->count_cuted_fields= orig_count_cuted_fields;
if (tmp)
thd->change_item_tree(item, tmp);
return 1; // Item was replaced