diff options
author | unknown <gkodinov/kgeorge@magare.gmz> | 2008-02-15 18:34:03 +0200 |
---|---|---|
committer | unknown <gkodinov/kgeorge@magare.gmz> | 2008-02-15 18:34:03 +0200 |
commit | 0529125af1c23e4789b113262b50db03d8f464cf (patch) | |
tree | 14359ab736eed2d5e3ff861ee8f1b6fe976dc237 /sql/item.cc | |
parent | c4fc5b096e582f23bac8bc14cb93f6ade63f476f (diff) | |
parent | cc2e929ac4b787220118f6d4dc4a72b796bf4ea0 (diff) | |
download | mariadb-git-0529125af1c23e4789b113262b50db03d8f464cf.tar.gz |
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/autopush/B31887-5.0-opt
sql/item.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
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 6b008f7dbb9..b8e3889fda4 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4083,6 +4083,30 @@ bool Item_field::subst_argument_checker(byte **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) @@ -4131,6 +4155,13 @@ Item *Item_field::equal_fields_propagator(byte *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; } |