Commit 67231642 authored by unknown's avatar unknown

thd_charset has been moved to variables structure

parent 29a9295d
......@@ -1091,7 +1091,7 @@ longlong Field_tiny::val_int(void)
String *Field_tiny::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
CHARSET_INFO *cs=current_thd->thd_charset;
CHARSET_INFO *cs=current_thd->variables.thd_charset;
uint length;
uint mlength=max(field_length+1,5*cs->mbmaxlen);
val_buffer->alloc(mlength);
......@@ -1330,7 +1330,7 @@ longlong Field_short::val_int(void)
String *Field_short::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
CHARSET_INFO *cs=current_thd->thd_charset;
CHARSET_INFO *cs=current_thd->variables.thd_charset;
uint length;
uint mlength=max(field_length+1,7*cs->mbmaxlen);
val_buffer->alloc(mlength);
......@@ -1574,7 +1574,7 @@ longlong Field_medium::val_int(void)
String *Field_medium::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
CHARSET_INFO *cs=current_thd->thd_charset;
CHARSET_INFO *cs=current_thd->variables.thd_charset;
uint length;
uint mlength=max(field_length+1,10*cs->mbmaxlen);
val_buffer->alloc(mlength);
......@@ -1810,7 +1810,7 @@ longlong Field_long::val_int(void)
String *Field_long::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
CHARSET_INFO *cs=current_thd->thd_charset;
CHARSET_INFO *cs=current_thd->variables.thd_charset;
uint length;
uint mlength=max(field_length+1,12*cs->mbmaxlen);
val_buffer->alloc(mlength);
......@@ -2035,7 +2035,7 @@ longlong Field_longlong::val_int(void)
String *Field_longlong::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
CHARSET_INFO *cs=current_thd->thd_charset;
CHARSET_INFO *cs=current_thd->variables.thd_charset;
uint length;
uint mlength=max(field_length+1,22*cs->mbmaxlen);
val_buffer->alloc(mlength);
......@@ -4432,14 +4432,14 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
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());
}
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());
}
......
......@@ -151,7 +151,7 @@ bool Item::get_time(TIME *ltime)
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)
......
......@@ -1383,14 +1383,14 @@ String *Item_func_database::val_str(String *str)
str->length(0);
else
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;
}
String *Item_func_user::val_str(String *str)
{
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 : "";
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)
DBUG_ASSERT(field_types == 0 ||
field_types[field_pos++] == MYSQL_TYPE_FLOAT);
#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());
}
......@@ -697,7 +697,7 @@ bool Protocol_simple::store(double from, uint32 decimals, String *buffer)
DBUG_ASSERT(field_types == 0 ||
field_types[field_pos++] == MYSQL_TYPE_DOUBLE);
#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());
}
......
......@@ -898,14 +898,14 @@ int collect_real(double *element, element_count count __attribute__((unused)),
TREE_INFO *info)
{
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)
info->str->append(',');
else
info->found = 1;
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('\'');
return 0;
......
......@@ -105,7 +105,6 @@ THD::THD():user_time(0), fatal_error(0),
cond_count=0;
warn_id= 0;
db_charset=default_charset_info;
thd_charset=default_charset_info;
mysys_var=0;
#ifndef DBUG_OFF
dbug_sentry=THD_SENTRY_MAGIC;
......@@ -190,6 +189,7 @@ void THD::init(void)
{
pthread_mutex_lock(&LOCK_global_system_variables);
variables= global_system_variables;
variables.thd_charset=default_charset_info;
pthread_mutex_unlock(&LOCK_global_system_variables);
server_status= SERVER_STATUS_AUTOCOMMIT;
options= thd_startup_options;
......
......@@ -374,6 +374,7 @@ struct system_variables
my_bool low_priority_updates;
CONVERT *convert_set;
CHARSET_INFO *thd_charset;
};
......@@ -487,7 +488,6 @@ class THD :public ilink {
table_map used_tables;
USER_CONN *user_connect;
CHARSET_INFO *db_charset;
CHARSET_INFO *thd_charset;
List<Item> *possible_loops; // Items that may cause loops in subselects
List <MYSQL_ERROR> warn_list;
uint warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END];
......
......@@ -599,7 +599,7 @@ bool mysql_change_db(THD *thd, const char *name)
strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE);
load_db_opt(path, &create);
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);
}
......
......@@ -713,7 +713,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
{
byte *pos;
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;
bool null_default_value=0;
......
......@@ -3600,13 +3600,13 @@ opt_ignore_lines:
/* Common definitions */
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); }
| text_literal TEXT_STRING
{ ((Item_string*) $1)->append($2.str,$2.length); };
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
{
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