Creating a new class in_string::Item_string_for_in_vector

and moving set_value() from Item_string to Item_string_for_in_vector,
as set_value() updates the members incompletely
(e.g. does not update max_length),
so it was dangerous to have set_value() available in Item_string.
This commit is contained in:
Alexander Barkov 2014-09-04 12:43:41 +04:00
commit bf4347eba0
2 changed files with 16 additions and 7 deletions

View file

@ -883,6 +883,18 @@ class in_string :public in_vector
{
char buff[STRING_BUFFER_USUAL_SIZE];
String tmp;
class Item_string_for_in_vector: public Item_string
{
public:
Item_string_for_in_vector(CHARSET_INFO *cs):
Item_string(cs)
{ }
void set_value(const String *str)
{
str_value= *str;
collation.set(str->charset());
}
};
public:
in_string(uint elements,qsort2_cmp cmp_func, CHARSET_INFO *cs);
~in_string();
@ -890,12 +902,12 @@ public:
uchar *get_value(Item *item);
Item* create_item()
{
return new Item_string(collation);
return new Item_string_for_in_vector(collation);
}
void value_to_item(uint pos, Item *item)
{
String *str=((String*) base)+pos;
Item_string *to= (Item_string*)item;
Item_string_for_in_vector *to= (Item_string_for_in_vector*) item;
to->set_value(str);
}
Item_result result_type() { return STRING_RESULT; }