summaryrefslogtreecommitdiff
path: root/sql/item_buff.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_buff.cc')
-rw-r--r--sql/item_buff.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/sql/item_buff.cc b/sql/item_buff.cc
index b0dbadcfda2..8c4224404d0 100644
--- a/sql/item_buff.cc
+++ b/sql/item_buff.cc
@@ -128,14 +128,20 @@ bool Cached_item_int::cmp(void)
bool Cached_item_field::cmp(void)
{
- bool tmp= field->cmp(buff) != 0; // This is not a blob!
- if (tmp)
- field->get_image(buff,length,field->charset());
+ bool tmp= FALSE; // Value is identical
+ /* Note that field can't be a blob here ! */
if (null_value != field->is_null())
{
null_value= !null_value;
- tmp=TRUE;
+ tmp= TRUE; // Value has changed
}
+
+ /*
+ If value is not null and value changed (from null to not null or
+ becasue of value change), then copy the new value to buffer.
+ */
+ if (! null_value && (tmp || (tmp= (field->cmp(buff) != 0))))
+ field->get_image(buff,length,field->charset());
return tmp;
}