Commit b29cc128 authored by unknown's avatar unknown

thd_charset has been moved to variables structure

parent a5ba7824
...@@ -1091,7 +1091,7 @@ longlong Field_tiny::val_int(void) ...@@ -1091,7 +1091,7 @@ longlong Field_tiny::val_int(void)
String *Field_tiny::val_str(String *val_buffer, String *Field_tiny::val_str(String *val_buffer,
String *val_ptr __attribute__((unused))) String *val_ptr __attribute__((unused)))
{ {
CHARSET_INFO *cs=current_thd->thd_charset; CHARSET_INFO *cs=current_thd->variables.thd_charset;
uint length; uint length;
uint mlength=max(field_length+1,5*cs->mbmaxlen); uint mlength=max(field_length+1,5*cs->mbmaxlen);
val_buffer->alloc(mlength); val_buffer->alloc(mlength);
...@@ -1330,7 +1330,7 @@ longlong Field_short::val_int(void) ...@@ -1330,7 +1330,7 @@ longlong Field_short::val_int(void)
String *Field_short::val_str(String *val_buffer, String *Field_short::val_str(String *val_buffer,
String *val_ptr __attribute__((unused))) String *val_ptr __attribute__((unused)))
{ {
CHARSET_INFO *cs=current_thd->thd_charset; CHARSET_INFO *cs=current_thd->variables.thd_charset;
uint length; uint length;
uint mlength=max(field_length+1,7*cs->mbmaxlen); uint mlength=max(field_length+1,7*cs->mbmaxlen);
val_buffer->alloc(mlength); val_buffer->alloc(mlength);
...@@ -1574,7 +1574,7 @@ longlong Field_medium::val_int(void) ...@@ -1574,7 +1574,7 @@ longlong Field_medium::val_int(void)
String *Field_medium::val_str(String *val_buffer, String *Field_medium::val_str(String *val_buffer,
String *val_ptr __attribute__((unused))) String *val_ptr __attribute__((unused)))
{ {
CHARSET_INFO *cs=current_thd->thd_charset; CHARSET_INFO *cs=current_thd->variables.thd_charset;
uint length; uint length;
uint mlength=max(field_length+1,10*cs->mbmaxlen); uint mlength=max(field_length+1,10*cs->mbmaxlen);
val_buffer->alloc(mlength); val_buffer->alloc(mlength);
...@@ -1810,7 +1810,7 @@ longlong Field_long::val_int(void) ...@@ -1810,7 +1810,7 @@ longlong Field_long::val_int(void)
String *Field_long::val_str(String *val_buffer, String *Field_long::val_str(String *val_buffer,
String *val_ptr __attribute__((unused))) String *val_ptr __attribute__((unused)))
{ {
CHARSET_INFO *cs=current_thd->thd_charset; CHARSET_INFO *cs=current_thd->variables.thd_charset;
uint length; uint length;
uint mlength=max(field_length+1,12*cs->mbmaxlen); uint mlength=max(field_length+1,12*cs->mbmaxlen);
val_buffer->alloc(mlength); val_buffer->alloc(mlength);
...@@ -2035,7 +2035,7 @@ longlong Field_longlong::val_int(void) ...@@ -2035,7 +2035,7 @@ longlong Field_longlong::val_int(void)
String *Field_longlong::val_str(String *val_buffer, String *Field_longlong::val_str(String *val_buffer,
String *val_ptr __attribute__((unused))) String *val_ptr __attribute__((unused)))
{ {
CHARSET_INFO *cs=current_thd->thd_charset; CHARSET_INFO *cs=current_thd->variables.thd_charset;
uint length; uint length;
uint mlength=max(field_length+1,22*cs->mbmaxlen); uint mlength=max(field_length+1,22*cs->mbmaxlen);
val_buffer->alloc(mlength); val_buffer->alloc(mlength);
...@@ -4432,14 +4432,14 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs) ...@@ -4432,14 +4432,14 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
int Field_blob::store(double nr) int Field_blob::store(double nr)
{ {
value.set(nr,2,current_thd->thd_charset); value.set(nr,2,current_thd->variables.thd_charset);
return Field_blob::store(value.ptr(),(uint) value.length(), value.charset()); return Field_blob::store(value.ptr(),(uint) value.length(), value.charset());
} }
int Field_blob::store(longlong nr) int Field_blob::store(longlong nr)
{ {
value.set(nr,current_thd->thd_charset); value.set(nr,current_thd->variables.thd_charset);
return Field_blob::store(value.ptr(), (uint) value.length(), value.charset()); return Field_blob::store(value.ptr(), (uint) value.length(), value.charset());
} }
......
...@@ -151,7 +151,7 @@ bool Item::get_time(TIME *ltime) ...@@ -151,7 +151,7 @@ bool Item::get_time(TIME *ltime)
CHARSET_INFO * Item::thd_charset() const CHARSET_INFO * Item::thd_charset() const
{ {
return current_thd->thd_charset; return current_thd->variables.thd_charset;
} }
Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name) Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name)
......
...@@ -1383,14 +1383,14 @@ String *Item_func_database::val_str(String *str) ...@@ -1383,14 +1383,14 @@ String *Item_func_database::val_str(String *str)
str->length(0); str->length(0);
else else
str->copy((const char*) thd->db,(uint) strlen(thd->db), str->copy((const char*) thd->db,(uint) strlen(thd->db),
system_charset_info, thd->thd_charset); system_charset_info, thd->variables.thd_charset);
return str; return str;
} }
String *Item_func_user::val_str(String *str) String *Item_func_user::val_str(String *str)
{ {
THD *thd=current_thd; THD *thd=current_thd;
CHARSET_INFO *cs=thd->thd_charset; CHARSET_INFO *cs=thd->variables.thd_charset;
const char *host=thd->host ? thd->host : thd->ip ? thd->ip : ""; const char *host=thd->host ? thd->host : thd->ip ? thd->ip : "";
uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen; uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen;
......
...@@ -687,7 +687,7 @@ bool Protocol_simple::store(float from, uint32 decimals, String *buffer) ...@@ -687,7 +687,7 @@ bool Protocol_simple::store(float from, uint32 decimals, String *buffer)
DBUG_ASSERT(field_types == 0 || DBUG_ASSERT(field_types == 0 ||
field_types[field_pos++] == MYSQL_TYPE_FLOAT); field_types[field_pos++] == MYSQL_TYPE_FLOAT);
#endif #endif
buffer->set((double) from, decimals, thd->thd_charset); buffer->set((double) from, decimals, thd->variables.thd_charset);
return net_store_data(packet,(char*) buffer->ptr(), buffer->length()); return net_store_data(packet,(char*) buffer->ptr(), buffer->length());
} }
...@@ -697,7 +697,7 @@ bool Protocol_simple::store(double from, uint32 decimals, String *buffer) ...@@ -697,7 +697,7 @@ bool Protocol_simple::store(double from, uint32 decimals, String *buffer)
DBUG_ASSERT(field_types == 0 || DBUG_ASSERT(field_types == 0 ||
field_types[field_pos++] == MYSQL_TYPE_DOUBLE); field_types[field_pos++] == MYSQL_TYPE_DOUBLE);
#endif #endif
buffer->set(from, decimals, thd->thd_charset); buffer->set(from, decimals, thd->variables.thd_charset);
return net_store_data(packet,(char*) buffer->ptr(), buffer->length()); return net_store_data(packet,(char*) buffer->ptr(), buffer->length());
} }
......
...@@ -898,14 +898,14 @@ int collect_real(double *element, element_count count __attribute__((unused)), ...@@ -898,14 +898,14 @@ int collect_real(double *element, element_count count __attribute__((unused)),
TREE_INFO *info) TREE_INFO *info)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String s(buff, sizeof(buff),current_thd->thd_charset); String s(buff, sizeof(buff),current_thd->variables.thd_charset);
if (info->found) if (info->found)
info->str->append(','); info->str->append(',');
else else
info->found = 1; info->found = 1;
info->str->append('\''); info->str->append('\'');
s.set(*element, info->item->decimals, current_thd->thd_charset); s.set(*element, info->item->decimals, current_thd->variables.thd_charset);
info->str->append(s); info->str->append(s);
info->str->append('\''); info->str->append('\'');
return 0; return 0;
......
...@@ -105,7 +105,6 @@ THD::THD():user_time(0), fatal_error(0), ...@@ -105,7 +105,6 @@ THD::THD():user_time(0), fatal_error(0),
cond_count=0; cond_count=0;
warn_id= 0; warn_id= 0;
db_charset=default_charset_info; db_charset=default_charset_info;
thd_charset=default_charset_info;
mysys_var=0; mysys_var=0;
#ifndef DBUG_OFF #ifndef DBUG_OFF
dbug_sentry=THD_SENTRY_MAGIC; dbug_sentry=THD_SENTRY_MAGIC;
...@@ -190,6 +189,7 @@ void THD::init(void) ...@@ -190,6 +189,7 @@ void THD::init(void)
{ {
pthread_mutex_lock(&LOCK_global_system_variables); pthread_mutex_lock(&LOCK_global_system_variables);
variables= global_system_variables; variables= global_system_variables;
variables.thd_charset=default_charset_info;
pthread_mutex_unlock(&LOCK_global_system_variables); pthread_mutex_unlock(&LOCK_global_system_variables);
server_status= SERVER_STATUS_AUTOCOMMIT; server_status= SERVER_STATUS_AUTOCOMMIT;
options= thd_startup_options; options= thd_startup_options;
......
...@@ -373,7 +373,8 @@ struct system_variables ...@@ -373,7 +373,8 @@ struct system_variables
my_bool log_warnings; my_bool log_warnings;
my_bool low_priority_updates; my_bool low_priority_updates;
CONVERT *convert_set; CONVERT *convert_set;
CHARSET_INFO *thd_charset;
}; };
...@@ -487,7 +488,6 @@ public: ...@@ -487,7 +488,6 @@ public:
table_map used_tables; table_map used_tables;
USER_CONN *user_connect; USER_CONN *user_connect;
CHARSET_INFO *db_charset; CHARSET_INFO *db_charset;
CHARSET_INFO *thd_charset;
List<Item> *possible_loops; // Items that may cause loops in subselects List<Item> *possible_loops; // Items that may cause loops in subselects
List <MYSQL_ERROR> warn_list; List <MYSQL_ERROR> warn_list;
uint warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END]; uint warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END];
......
...@@ -599,7 +599,7 @@ bool mysql_change_db(THD *thd, const char *name) ...@@ -599,7 +599,7 @@ bool mysql_change_db(THD *thd, const char *name)
strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE); strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE);
load_db_opt(path, &create); load_db_opt(path, &create);
thd->db_charset=create.table_charset; thd->db_charset=create.table_charset;
thd->thd_charset=thd->db_charset ? thd->db_charset : default_charset_info; thd->variables.thd_charset=thd->db_charset ? thd->db_charset : default_charset_info;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -713,7 +713,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, ...@@ -713,7 +713,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
{ {
byte *pos; byte *pos;
uint flags=field->flags; uint flags=field->flags;
String type(tmp,sizeof(tmp),current_thd->thd_charset); String type(tmp,sizeof(tmp),current_thd->variables.thd_charset);
uint col_access; uint col_access;
bool null_default_value=0; bool null_default_value=0;
......
...@@ -3600,13 +3600,13 @@ opt_ignore_lines: ...@@ -3600,13 +3600,13 @@ opt_ignore_lines:
/* Common definitions */ /* Common definitions */
text_literal: text_literal:
TEXT_STRING { $$ = new Item_string($1.str,$1.length,YYTHD->thd_charset); } TEXT_STRING { $$ = new Item_string($1.str,$1.length,YYTHD->variables.thd_charset); }
| UNDERSCORE_CHARSET TEXT_STRING { $$ = new Item_string($2.str,$2.length,Lex->charset); } | UNDERSCORE_CHARSET TEXT_STRING { $$ = new Item_string($2.str,$2.length,Lex->charset); }
| text_literal TEXT_STRING | text_literal TEXT_STRING
{ ((Item_string*) $1)->append($2.str,$2.length); }; { ((Item_string*) $1)->append($2.str,$2.length); };
text_string: text_string:
TEXT_STRING { $$= new String($1.str,$1.length,YYTHD->thd_charset); } TEXT_STRING { $$= new String($1.str,$1.length,YYTHD->variables.thd_charset); }
| HEX_NUM | HEX_NUM
{ {
Item *tmp = new Item_varbinary($1.str,$1.length); Item *tmp = new Item_varbinary($1.str,$1.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