diff options
author | gkodinov/kgeorge@magare.gmz <> | 2008-02-16 10:48:33 +0200 |
---|---|---|
committer | gkodinov/kgeorge@magare.gmz <> | 2008-02-16 10:48:33 +0200 |
commit | 047b1a66a09aa85cf5f9667fff81e75c74012119 (patch) | |
tree | b5e5a5e88d19830264f0b6b72d816c7b483049ca /sql/item.cc | |
parent | 6736c1b9e7bfde20314eeeaadb34a4f4b99c69eb (diff) | |
parent | 490ec62be470508b007b0edfd3d35421bb359a4e (diff) | |
download | mariadb-git-047b1a66a09aa85cf5f9667fff81e75c74012119.tar.gz |
Merge magare.gmz:/home/kgeorge/mysql/work/B31887-5.0-opt
into magare.gmz:/home/kgeorge/mysql/work/B31887-5.1-opt
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc index 0e1db376c1e..1dac5ed8c78 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4145,6 +4145,30 @@ bool Item_field::subst_argument_checker(uchar **arg) } +/** + Convert a numeric value to a zero-filled string + + @param[in,out] item the item to operate on + @param field The field that this value is equated to + + This function converts a numeric value to a string. In this conversion + the zero-fill flag of the field is taken into account. + This is required so the resulting string value can be used instead of + the field reference when propagating equalities. +*/ + +static void convert_zerofill_number_to_string(Item **item, Field_num *field) +{ + char buff[MAX_FIELD_WIDTH],*pos; + String tmp(buff,sizeof(buff), field->charset()), *res; + + res= (*item)->val_str(&tmp); + field->prepend_zeros(res); + pos= (char *) sql_strmake (res->ptr(), res->length()); + *item= new Item_string(pos, res->length(), field->charset()); +} + + /* Set a pointer to the multiple equality the field reference belongs to (if any) @@ -4193,6 +4217,13 @@ Item *Item_field::equal_fields_propagator(uchar *arg) if (!item || (cmp_context != (Item_result)-1 && item->cmp_context != cmp_context)) item= this; + else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type())) + { + if (item && cmp_context != INT_RESULT) + convert_zerofill_number_to_string(&item, (Field_num *)field); + else + item= this; + } return item; } |