Commit 1b9becc3 authored by unknown's avatar unknown

Fixed CAST( xxx as CHAR)

sql/item.h:
  Made some virtual functions non virtual (as they are not used virtually)
sql/item_strfunc.cc:
  Optimizations.
sql/item_strfunc.h:
  Fixed BINARY handling
sql/sql_string.h:
  Indentation cleanups
parent 0985653c
......@@ -85,12 +85,14 @@ public:
virtual bool get_date(TIME *ltime,bool fuzzydate);
virtual bool get_time(TIME *ltime);
virtual bool is_null() { return 0; };
virtual CHARSET_INFO *thd_charset() const;
virtual CHARSET_INFO *charset() const { return str_value.charset(); };
virtual bool binary() const { return str_value.charset()->state & MY_CS_BINSORT ? 1 : 0 ; }
virtual void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); }
virtual bool check_loop(uint id);
virtual void top_level_item() {}
virtual bool binary() const
{ return str_value.charset()->state & MY_CS_BINSORT ? 1 : 0 ; }
CHARSET_INFO *thd_charset() const;
CHARSET_INFO *charset() const { return str_value.charset(); };
void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); }
};
......
......@@ -1363,17 +1363,19 @@ String *Item_func_decode::val_str(String *str)
String *Item_func_database::val_str(String *str)
{
if (!current_thd->db)
THD *thd= current_thd;
if (!thd->db)
str->length(0);
else
str->copy((const char*) current_thd->db,(uint) strlen(current_thd->db), system_charset_info, thd_charset());
str->copy((const char*) thd->db,(uint) strlen(thd->db),
system_charset_info, thd->thd_charset);
return str;
}
String *Item_func_user::val_str(String *str)
{
THD *thd=current_thd;
CHARSET_INFO *cs=thd_charset();
CHARSET_INFO *cs=thd->thd_charset;
const char *host=thd->host ? thd->host : thd->ip ? thd->ip : "";
uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen;
......@@ -2128,7 +2130,8 @@ String *Item_func_charset::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
str->copy(res->charset()->name,strlen(res->charset()->name),my_charset_latin1,thd_charset());
str->copy(res->charset()->name,strlen(res->charset()->name),
my_charset_latin1, thd_charset());
return str;
}
......
......@@ -494,8 +494,9 @@ public:
{
String *tmp=args[0]->val_str(a);
null_value=args[0]->null_value;
tmp->set_charset(my_charset_bin);
return tmp;
}
}
void fix_length_and_dec()
{
set_charset(my_charset_bin);
......
......@@ -534,8 +534,17 @@ public:
Item_typecast(Item *a) :Item_str_func(a) {}
const char *func_name() const { return "char"; }
String *val_str(String *a)
{ a=args[0]->val_str(a); null_value=args[0]->null_value; return a; }
void fix_length_and_dec() { max_length=args[0]->max_length; }
{
String *tmp=args[0]->val_str(a);
null_value=args[0]->null_value;
tmp->set_charset(charset());
return tmp;
}
void fix_length_and_dec()
{
set_charset(thd_charset());
max_length=args[0]->max_length;
}
void print(String *str);
};
......@@ -544,7 +553,11 @@ class Item_char_typecast :public Item_typecast
{
public:
Item_char_typecast(Item *a) :Item_typecast(a) {}
void fix_length_and_dec() { binary=0; max_length=args[0]->max_length; }
void fix_length_and_dec()
{
set_charset(thd_charset());
max_length=args[0]->max_length;
}
};
......
......@@ -72,7 +72,7 @@ public:
{ sql_element_free(ptr_arg); }
~String() { free(); }
inline void set_charset(CHARSET_INFO *charset) { str_charset=charset; }
inline void set_charset(CHARSET_INFO *charset) { str_charset= charset; }
inline CHARSET_INFO *charset() const { return str_charset; }
inline uint32 length() const { return str_length;}
inline uint32 alloced_length() const { return Alloced_length;}
......@@ -177,7 +177,8 @@ public:
bool copy(); // Alloc string if not alloced
bool copy(const String &s); // Allocate new string
bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string
bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom, CHARSET_INFO *csto);
bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom,
CHARSET_INFO *csto);
bool append(const String &s);
bool append(const char *s,uint32 arg_length=0);
bool append(IO_CACHE* file, uint32 arg_length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment