summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mnogosearch.org>2014-09-04 12:43:41 +0400
committerAlexander Barkov <bar@mnogosearch.org>2014-09-04 12:43:41 +0400
commitbf4347eba07a7e8f11af07a684381d48d673e028 (patch)
treec12216ff78e4408f781d5e4cae94c293091a0f0d
parentc9d3b27d299ab7f52e7d15147bef92062e13b4df (diff)
downloadmariadb-git-bf4347eba07a7e8f11af07a684381d48d673e028.tar.gz
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.
-rw-r--r--sql/item.h7
-rw-r--r--sql/item_cmpfunc.h16
2 files changed, 16 insertions, 7 deletions
diff --git a/sql/item.h b/sql/item.h
index 2647f0b20bd..9d07fedfbce 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2762,6 +2762,7 @@ public:
decimals= NOT_FIXED_DEC;
fixed= 1;
}
+protected:
/* Just create an item and do not fill string representation */
Item_string(CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
: m_cs_specified(FALSE)
@@ -2772,6 +2773,7 @@ public:
decimals= NOT_FIXED_DEC;
fixed= 1;
}
+public:
Item_string(const char *name_par, const char *str, uint length,
CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
uint repertoire= MY_REPERTOIRE_UNICODE30)
@@ -2785,11 +2787,6 @@ public:
// it is constant => can be used without fix_fields (and frequently used)
fixed= 1;
}
- void set_value(const String *str)
- {
- str_value= *str;
- collation.set(str->charset());
- }
void copy_value(const char *str, uint32 length, CHARSET_INFO *fromcs,
CHARSET_INFO *tocs, uint *cnv_errors)
{
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 2ff0a4e5e2f..71674c61d47 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -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; }