include/mysql_com.h:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/protocol.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
libmysqld/libmysqld.c:
  e
  merging with vva's code.
This commit is contained in:
unknown 2002-12-19 14:57:24 +04:00
commit 1bc932384b
27 changed files with 150 additions and 117 deletions

View File

@ -57,6 +57,7 @@ enum enum_server_command
#define BLOB_FLAG 16 /* Field is a blob */ #define BLOB_FLAG 16 /* Field is a blob */
#define UNSIGNED_FLAG 32 /* Field is unsigned */ #define UNSIGNED_FLAG 32 /* Field is unsigned */
#define ZEROFILL_FLAG 64 /* Field is zerofill */ #define ZEROFILL_FLAG 64 /* Field is zerofill */
#define BINARY_FLAG 128 /* Field is binary */
/* The following are only sent to new clients */ /* The following are only sent to new clients */
#define ENUM_FLAG 256 /* field is an enum */ #define ENUM_FLAG 256 /* field is an enum */

View File

@ -937,7 +937,7 @@ static TYPELIB option_types={array_elements(default_options)-1,
static int add_init_command(struct st_mysql_options *options, const char *cmd) static int add_init_command(struct st_mysql_options *options, const char *cmd)
{ {
char **ptr, *tmp; char *tmp;
if (!options->init_commands) if (!options->init_commands)
{ {
@ -947,7 +947,7 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
} }
if (!(tmp= my_strdup(cmd,MYF(MY_WME))) || if (!(tmp= my_strdup(cmd,MYF(MY_WME))) ||
insert_dynamic(options->init_commands, &tmp)) insert_dynamic(options->init_commands, (byte*)&tmp))
{ {
my_free(tmp, MYF(MY_ALLOW_ZERO_PTR)); my_free(tmp, MYF(MY_ALLOW_ZERO_PTR));
return 1; return 1;

View File

@ -231,7 +231,7 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
} }
if (!(tmp= my_strdup(cmd,MYF(MY_WME))) || if (!(tmp= my_strdup(cmd,MYF(MY_WME))) ||
insert_dynamic(options->init_commands, (gptr)&tmp)) insert_dynamic(options->init_commands, (byte*)&tmp))
{ {
my_free(tmp, MYF(MY_ALLOW_ZERO_PTR)); my_free(tmp, MYF(MY_ALLOW_ZERO_PTR));
return 1; return 1;

View File

@ -1,6 +1,6 @@
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
comment CHAR(32) CHARACTER SET latin1 NOT NULL, comment CHAR(32) ASCII NOT NULL,
koi8_ru_f CHAR(32) CHARACTER SET koi8_ru NOT NULL koi8_ru_f CHAR(32) CHARACTER SET koi8_ru NOT NULL
) CHARSET=latin5; ) CHARSET=latin5;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
@ -1291,7 +1291,8 @@ CYR CAPIT YA CYR CAPIT YA
CYR CAPIT YA CYR SMALL YA CYR CAPIT YA CYR SMALL YA
CYR SMALL YA CYR CAPIT YA CYR SMALL YA CYR CAPIT YA
CYR SMALL YA CYR SMALL YA CYR SMALL YA CYR SMALL YA
ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2 NOT NULL; ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2;
ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL;
INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA'); INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA');
INSERT INTO t1 (ucs2_f,comment) VALUES (0x0392,'GREEK CAPIT BETA'); INSERT INTO t1 (ucs2_f,comment) VALUES (0x0392,'GREEK CAPIT BETA');
INSERT INTO t1 (ucs2_f,comment) VALUES (0x0393,'GREEK CAPIT GAMMA'); INSERT INTO t1 (ucs2_f,comment) VALUES (0x0393,'GREEK CAPIT GAMMA');

View File

@ -1,7 +1,7 @@
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
comment CHAR(32) CHARACTER SET latin1 NOT NULL, comment CHAR(32) ASCII NOT NULL,
koi8_ru_f CHAR(32) CHARACTER SET koi8_ru NOT NULL koi8_ru_f CHAR(32) CHARACTER SET koi8_ru NOT NULL
) CHARSET=latin5; ) CHARSET=latin5;
@ -156,7 +156,8 @@ FROM t1 t11,t1 t12
WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8_ru) WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8_ru)
ORDER BY t12.utf8_f,t11.comment,t12.comment; ORDER BY t12.utf8_f,t11.comment,t12.comment;
ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2 NOT NULL; ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2;
ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL;
INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA'); INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA');
INSERT INTO t1 (ucs2_f,comment) VALUES (0x0392,'GREEK CAPIT BETA'); INSERT INTO t1 (ucs2_f,comment) VALUES (0x0392,'GREEK CAPIT BETA');

View File

@ -34,6 +34,8 @@ static int initialized;
1 Error 1 Error
*/ */
#define des_cs my_charset_latin1
bool bool
load_des_key_file(const char *file_name) load_des_key_file(const char *file_name)
{ {
@ -70,10 +72,10 @@ load_des_key_file(const char *file_name)
{ {
offset=(char) (offset - '0'); offset=(char) (offset - '0');
// Remove newline and possible other control characters // Remove newline and possible other control characters
for (start=buf+1 ; my_isspace(system_charset_info, *start) ; start++) ; for (start=buf+1 ; my_isspace(des_cs, *start) ; start++) ;
end=buf+length; end=buf+length;
for (end=strend(buf) ; for (end=strend(buf) ;
end > start && !my_isgraph(system_charset_info, end[-1]) ; end--) ; end > start && !my_isgraph(des_cs, end[-1]) ; end--) ;
if (start != end) if (start != end)
{ {

View File

@ -287,7 +287,7 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
bool Field::get_date(TIME *ltime,bool fuzzydate) bool Field::get_date(TIME *ltime,bool fuzzydate)
{ {
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff),default_charset_info),tmp2,*res; String tmp(buff,sizeof(buff),my_charset_latin1),tmp2,*res;
if (!(res=val_str(&tmp,&tmp2)) || if (!(res=val_str(&tmp,&tmp2)) ||
str_to_TIME(res->ptr(),res->length(),ltime,fuzzydate) == TIMESTAMP_NONE) str_to_TIME(res->ptr(),res->length(),ltime,fuzzydate) == TIMESTAMP_NONE)
return 1; return 1;
@ -297,7 +297,7 @@ bool Field::get_date(TIME *ltime,bool fuzzydate)
bool Field::get_time(TIME *ltime) bool Field::get_time(TIME *ltime)
{ {
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff),default_charset_info),tmp2,*res; String tmp(buff,sizeof(buff),my_charset_latin1),tmp2,*res;
if (!(res=val_str(&tmp,&tmp2)) || if (!(res=val_str(&tmp,&tmp2)) ||
str_to_time(res->ptr(),res->length(),ltime)) str_to_time(res->ptr(),res->length(),ltime))
return 1; return 1;
@ -404,6 +404,12 @@ void Field_decimal::overflow(bool negative)
int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs) int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
{ {
String l1from;
l1from.copy(from,len,cs,my_charset_latin1);
from=l1from.ptr();
len=l1from.length();
const char *end= from+len; const char *end= from+len;
/* The pointer where the field value starts (i.e., "where to write") */ /* The pointer where the field value starts (i.e., "where to write") */
char *to=ptr; char *to=ptr;
@ -463,7 +469,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
tmp_dec++; tmp_dec++;
/* skip pre-space */ /* skip pre-space */
while (from != end && my_isspace(system_charset_info,*from)) while (from != end && my_isspace(my_charset_latin1,*from))
from++; from++;
if (from == end) if (from == end)
{ {
@ -500,13 +506,13 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
for (; from!=end && *from == '0'; from++) ; // Read prezeros for (; from!=end && *from == '0'; from++) ; // Read prezeros
pre_zeros_end=int_digits_from=from; pre_zeros_end=int_digits_from=from;
/* Read non zero digits at the left of '.'*/ /* Read non zero digits at the left of '.'*/
for (; from != end && my_isdigit(system_charset_info, *from) ; from++) ; for (; from != end && my_isdigit(my_charset_latin1, *from) ; from++) ;
int_digits_end=from; int_digits_end=from;
if (from!=end && *from == '.') // Some '.' ? if (from!=end && *from == '.') // Some '.' ?
from++; from++;
frac_digits_from= from; frac_digits_from= from;
/* Read digits at the right of '.' */ /* Read digits at the right of '.' */
for (;from!=end && my_isdigit(system_charset_info, *from); from++) ; for (;from!=end && my_isdigit(my_charset_latin1, *from); from++) ;
frac_digits_end=from; frac_digits_end=from;
// Some exponentiation symbol ? // Some exponentiation symbol ?
if (from != end && (*from == 'e' || *from == 'E')) if (from != end && (*from == 'e' || *from == 'E'))
@ -522,7 +528,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
exponents will become small (e.g. 1e4294967296 will become 1e0, and the exponents will become small (e.g. 1e4294967296 will become 1e0, and the
field will finally contain 1 instead of its max possible value). field will finally contain 1 instead of its max possible value).
*/ */
for (;from!=end && my_isdigit(system_charset_info, *from); from++) for (;from!=end && my_isdigit(my_charset_latin1, *from); from++)
{ {
exponent=10*exponent+(*from-'0'); exponent=10*exponent+(*from-'0');
if (exponent>MAX_EXPONENT) if (exponent>MAX_EXPONENT)
@ -540,7 +546,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
if (current_thd->count_cuted_fields) if (current_thd->count_cuted_fields)
{ {
// Skip end spaces // Skip end spaces
for (;from != end && my_isspace(system_charset_info, *from); from++) ; for (;from != end && my_isspace(my_charset_latin1, *from); from++) ;
if (from != end) // If still something left, warn if (from != end) // If still something left, warn
{ {
current_thd->cuted_fields++; current_thd->cuted_fields++;
@ -849,12 +855,13 @@ String *Field_decimal::val_str(String *val_buffer __attribute__((unused)),
String *val_ptr) String *val_ptr)
{ {
char *str; char *str;
CHARSET_INFO *cs=current_thd->variables.thd_charset;
for (str=ptr ; *str == ' ' ; str++) ; for (str=ptr ; *str == ' ' ; str++) ;
uint tmp_length=(uint) (str-ptr); uint tmp_length=(uint) (str-ptr);
if (field_length < tmp_length) // Error in data if (field_length < tmp_length) // Error in data
val_ptr->length(0); val_ptr->length(0);
else else
val_ptr->set((const char*) str,field_length-tmp_length,default_charset_info); val_ptr->copy((const char*) str,field_length-tmp_length,my_charset_latin1,cs);
return val_ptr; return val_ptr;
} }
@ -871,9 +878,9 @@ int Field_decimal::cmp(const char *a_ptr,const char *b_ptr)
for (end=a_ptr+field_length; for (end=a_ptr+field_length;
a_ptr != end && a_ptr != end &&
(*a_ptr == *b_ptr || (*a_ptr == *b_ptr ||
((my_isspace(system_charset_info,*a_ptr) || *a_ptr == '+' || ((my_isspace(my_charset_latin1,*a_ptr) || *a_ptr == '+' ||
*a_ptr == '0') && *a_ptr == '0') &&
(my_isspace(system_charset_info,*b_ptr) || *b_ptr == '+' || (my_isspace(my_charset_latin1,*b_ptr) || *b_ptr == '+' ||
*b_ptr == '0'))); *b_ptr == '0')));
a_ptr++,b_ptr++) a_ptr++,b_ptr++)
{ {
@ -901,7 +908,7 @@ void Field_decimal::sort_string(char *to,uint length)
char *str,*end; char *str,*end;
for (str=ptr,end=ptr+length; for (str=ptr,end=ptr+length;
str != end && str != end &&
((my_isspace(system_charset_info,*str) || *str == '+' || ((my_isspace(my_charset_latin1,*str) || *str == '+' ||
*str == '0')) ; *str == '0')) ;
str++) str++)
*to++=' '; *to++=' ';
@ -913,7 +920,7 @@ void Field_decimal::sort_string(char *to,uint length)
*to++=1; // Smaller than any number *to++=1; // Smaller than any number
str++; str++;
while (str != end) while (str != end)
if (my_isdigit(system_charset_info,*str)) if (my_isdigit(my_charset_latin1,*str))
*to++= (char) ('9' - *str++); *to++= (char) ('9' - *str++);
else else
*to++= *str++; *to++= *str++;
@ -1091,7 +1098,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 +1337,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 +1581,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 +1817,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 +2042,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 +4439,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());
} }

View File

@ -132,7 +132,7 @@ public:
tmp->key_start= tmp->part_of_key= tmp->part_of_sortkey= 0; tmp->key_start= tmp->part_of_key= tmp->part_of_sortkey= 0;
tmp->unireg_check=Field::NONE; tmp->unireg_check=Field::NONE;
tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG | tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG |
ZEROFILL_FLAG | ENUM_FLAG | SET_FLAG); ZEROFILL_FLAG | BINARY_FLAG | ENUM_FLAG | SET_FLAG);
tmp->table_name= new_table->table_name; tmp->table_name= new_table->table_name;
tmp->reset_fields(); tmp->reset_fields();
} }
@ -260,7 +260,11 @@ public:
struct st_table *table_arg,CHARSET_INFO *charset) struct st_table *table_arg,CHARSET_INFO *charset)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg) unireg_check_arg, field_name_arg, table_arg)
{ field_charset=charset; } {
field_charset=charset;
if (binary())
flags|=BINARY_FLAG;
}
Item_result result_type () const { return STRING_RESULT; } Item_result result_type () const { return STRING_RESULT; }
void add_binary_or_charset(String &res) const; void add_binary_or_charset(String &res) const;
uint decimals() const { return NOT_FIXED_DEC; } uint decimals() const { return NOT_FIXED_DEC; }

View File

@ -272,7 +272,7 @@ static void do_conv_blob(Copy_field *copy)
static void do_save_blob(Copy_field *copy) static void do_save_blob(Copy_field *copy)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String res(buff,sizeof(buff),default_charset_info); String res(buff,sizeof(buff),copy->tmp.charset());
copy->from_field->val_str(&res,&res); copy->from_field->val_str(&res,&res);
copy->tmp.copy(res); copy->tmp.copy(res);
((Field_blob *) copy->to_field)->store(copy->tmp.ptr(), ((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
@ -284,7 +284,7 @@ static void do_save_blob(Copy_field *copy)
static void do_field_string(Copy_field *copy) static void do_field_string(Copy_field *copy)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
copy->tmp.set_quick(buff,sizeof(buff),default_charset_info); copy->tmp.set_quick(buff,sizeof(buff),copy->tmp.charset());
copy->from_field->val_str(&copy->tmp,&copy->tmp); copy->from_field->val_str(&copy->tmp,&copy->tmp);
copy->to_field->store(copy->tmp.c_ptr_quick(),copy->tmp.length(),copy->tmp.charset()); copy->to_field->store(copy->tmp.c_ptr_quick(),copy->tmp.length(),copy->tmp.charset());
} }
@ -313,7 +313,7 @@ static void do_cut_string(Copy_field *copy)
ptr != end ; ptr != end ;
ptr++) ptr++)
{ {
if (!my_isspace(system_charset_info, *ptr)) if (!my_isspace(system_charset_info, *ptr)) // QQ: ucs incompatible
{ {
current_thd->cuted_fields++; // Give a warning current_thd->cuted_fields++; // Give a warning
break; break;
@ -555,7 +555,7 @@ void field_conv(Field *to,Field *from)
to->type() == FIELD_TYPE_DECIMAL) to->type() == FIELD_TYPE_DECIMAL)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String result(buff,sizeof(buff),default_charset_info); String result(buff,sizeof(buff),from->charset());
from->val_str(&result,&result); from->val_str(&result,&result);
to->store(result.c_ptr_quick(),result.length(),to->charset()); to->store(result.c_ptr_quick(),result.length(),to->charset());
// QQ: what to do if "from" and "to" are of dirrent charsets? // QQ: what to do if "from" and "to" are of dirrent charsets?

View File

@ -221,10 +221,10 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors)
/* Don't accept hostnames that starts with digits because they may be /* Don't accept hostnames that starts with digits because they may be
false ip:s */ false ip:s */
if (my_isdigit(system_charset_info,name[0])) if (my_isdigit(my_charset_latin1,name[0]))
{ {
char *pos; char *pos;
for (pos= name+1 ; my_isdigit(system_charset_info,*pos); pos++) ; for (pos= name+1 ; my_isdigit(my_charset_latin1,*pos); pos++) ;
if (*pos == '.') if (*pos == '.')
{ {
DBUG_PRINT("error",("mysqld doesn't accept hostnames that starts with a number followed by a '.'")); DBUG_PRINT("error",("mysqld doesn't accept hostnames that starts with a number followed by a '.'"));

View File

@ -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)

View File

@ -878,7 +878,7 @@ String *Item_func_case::val_str(String *str)
longlong Item_func_case::val_int() longlong Item_func_case::val_int()
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String dummy_str(buff,sizeof(buff),default_charset_info); String dummy_str(buff,sizeof(buff),thd_charset());
Item *item=find_item(&dummy_str); Item *item=find_item(&dummy_str);
longlong res; longlong res;
@ -895,7 +895,7 @@ longlong Item_func_case::val_int()
double Item_func_case::val() double Item_func_case::val()
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String dummy_str(buff,sizeof(buff),default_charset_info); String dummy_str(buff,sizeof(buff),thd_charset());
Item *item=find_item(&dummy_str); Item *item=find_item(&dummy_str);
double res; double res;

View File

@ -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;

View File

@ -64,21 +64,21 @@ static String day_names[] =
** DAY_TO_SECOND as "D MM:HH:SS", "MM:HH:SS" "HH:SS" or as seconds. ** DAY_TO_SECOND as "D MM:HH:SS", "MM:HH:SS" "HH:SS" or as seconds.
*/ */
bool get_interval_info(const char *str,uint length,uint count, bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs,
long *values) uint count, long *values)
{ {
const char *end=str+length; const char *end=str+length;
uint i; uint i;
while (str != end && !my_isdigit(system_charset_info,*str)) while (str != end && !my_isdigit(cs,*str))
str++; str++;
for (i=0 ; i < count ; i++) for (i=0 ; i < count ; i++)
{ {
long value; long value;
for (value=0; str != end && my_isdigit(system_charset_info,*str) ; str++) for (value=0; str != end && my_isdigit(cs,*str) ; str++)
value=value*10L + (long) (*str - '0'); value=value*10L + (long) (*str - '0');
values[i]= value; values[i]= value;
while (str != end && !my_isdigit(system_charset_info,*str)) while (str != end && !my_isdigit(cs,*str))
str++; str++;
if (str == end && i != count-1) if (str == end && i != count-1)
{ {
@ -306,6 +306,7 @@ static bool get_interval_value(Item *args,interval_type int_type,
const char *str; const char *str;
uint32 length; uint32 length;
LINT_INIT(value); LINT_INIT(str); LINT_INIT(length); LINT_INIT(value); LINT_INIT(str); LINT_INIT(length);
CHARSET_INFO *cs=str_value->charset();
bzero((char*) t,sizeof(*t)); bzero((char*) t,sizeof(*t));
if ((int) int_type <= INTERVAL_SECOND) if ((int) int_type <= INTERVAL_SECOND)
@ -328,7 +329,7 @@ static bool get_interval_value(Item *args,interval_type int_type,
/* record negative intervalls in t->neg */ /* record negative intervalls in t->neg */
str=res->ptr(); str=res->ptr();
const char *end=str+res->length(); const char *end=str+res->length();
while (str != end && my_isspace(system_charset_info,*str)) while (str != end && my_isspace(cs,*str))
str++; str++;
if (str != end && *str == '-') if (str != end && *str == '-')
{ {
@ -358,26 +359,26 @@ static bool get_interval_value(Item *args,interval_type int_type,
t->second=value; t->second=value;
break; break;
case INTERVAL_YEAR_MONTH: // Allow YEAR-MONTH YYYYYMM case INTERVAL_YEAR_MONTH: // Allow YEAR-MONTH YYYYYMM
if (get_interval_info(str,length,2,array)) if (get_interval_info(str,length,cs,2,array))
return (1); return (1);
t->year=array[0]; t->year=array[0];
t->month=array[1]; t->month=array[1];
break; break;
case INTERVAL_DAY_HOUR: case INTERVAL_DAY_HOUR:
if (get_interval_info(str,length,2,array)) if (get_interval_info(str,length,cs,2,array))
return (1); return (1);
t->day=array[0]; t->day=array[0];
t->hour=array[1]; t->hour=array[1];
break; break;
case INTERVAL_DAY_MINUTE: case INTERVAL_DAY_MINUTE:
if (get_interval_info(str,length,3,array)) if (get_interval_info(str,length,cs,3,array))
return (1); return (1);
t->day=array[0]; t->day=array[0];
t->hour=array[1]; t->hour=array[1];
t->minute=array[2]; t->minute=array[2];
break; break;
case INTERVAL_DAY_SECOND: case INTERVAL_DAY_SECOND:
if (get_interval_info(str,length,4,array)) if (get_interval_info(str,length,cs,4,array))
return (1); return (1);
t->day=array[0]; t->day=array[0];
t->hour=array[1]; t->hour=array[1];
@ -385,20 +386,20 @@ static bool get_interval_value(Item *args,interval_type int_type,
t->second=array[3]; t->second=array[3];
break; break;
case INTERVAL_HOUR_MINUTE: case INTERVAL_HOUR_MINUTE:
if (get_interval_info(str,length,2,array)) if (get_interval_info(str,length,cs,2,array))
return (1); return (1);
t->hour=array[0]; t->hour=array[0];
t->minute=array[1]; t->minute=array[1];
break; break;
case INTERVAL_HOUR_SECOND: case INTERVAL_HOUR_SECOND:
if (get_interval_info(str,length,3,array)) if (get_interval_info(str,length,cs,3,array))
return (1); return (1);
t->hour=array[0]; t->hour=array[0];
t->minute=array[1]; t->minute=array[1];
t->second=array[2]; t->second=array[2];
break; break;
case INTERVAL_MINUTE_SECOND: case INTERVAL_MINUTE_SECOND:
if (get_interval_info(str,length,2,array)) if (get_interval_info(str,length,cs,2,array))
return (1); return (1);
t->minute=array[0]; t->minute=array[0];
t->second=array[1]; t->second=array[1];

View File

@ -59,6 +59,7 @@ static SYMBOL symbols[] = {
{ "ANY", SYM(ANY_SYM),0,0}, { "ANY", SYM(ANY_SYM),0,0},
{ "AS", SYM(AS),0,0}, { "AS", SYM(AS),0,0},
{ "ASC", SYM(ASC),0,0}, { "ASC", SYM(ASC),0,0},
{ "ASCII", SYM(ASCII_SYM),0,0},
{ "AVG", SYM(AVG_SYM),0,0}, { "AVG", SYM(AVG_SYM),0,0},
{ "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH),0,0}, { "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH),0,0},
{ "AUTO_INCREMENT", SYM(AUTO_INC),0,0}, { "AUTO_INCREMENT", SYM(AUTO_INC),0,0},
@ -374,6 +375,7 @@ static SYMBOL symbols[] = {
{ "TYPE", SYM(TYPE_SYM),0,0}, { "TYPE", SYM(TYPE_SYM),0,0},
{ "TYPES", SYM(TYPES_SYM),0,0}, { "TYPES", SYM(TYPES_SYM),0,0},
{ "UNCOMMITTED", SYM(UNCOMMITTED_SYM),0,0}, { "UNCOMMITTED", SYM(UNCOMMITTED_SYM),0,0},
{ "UNICODE", SYM(UNICODE_SYM),0,0},
{ "UNION", SYM(UNION_SYM),0,0}, { "UNION", SYM(UNION_SYM),0,0},
{ "UNIQUE", SYM(UNIQUE_SYM),0,0}, { "UNIQUE", SYM(UNIQUE_SYM),0,0},
{ "UNLOCK", SYM(UNLOCK_SYM),0,0}, { "UNLOCK", SYM(UNLOCK_SYM),0,0},
@ -412,7 +414,6 @@ static SYMBOL sql_functions[] = {
{ "AES_ENCRYPT", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_aes_encrypt)}, { "AES_ENCRYPT", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_aes_encrypt)},
{ "AES_DECRYPT", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_aes_decrypt)}, { "AES_DECRYPT", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_aes_decrypt)},
{ "AREA", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_area)}, { "AREA", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_area)},
{ "ASCII", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ascii)},
{ "ASIN", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_asin)}, { "ASIN", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_asin)},
{ "ASTEXT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_as_text)}, { "ASTEXT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_as_text)},
{ "ATAN", SYM(ATAN),0,0}, { "ATAN", SYM(ATAN),0,0},

View File

@ -33,6 +33,7 @@
#include <m_ctype.h> // For test_if_number #include <m_ctype.h> // For test_if_number
#include <assert.h> #include <assert.h>
#define files_charset_info my_charset_latin1
MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
extern I_List<i_string> binlog_do_db, binlog_ignore_db; extern I_List<i_string> binlog_do_db, binlog_ignore_db;
@ -1494,7 +1495,7 @@ static bool test_if_number(register const char *str,
while (*str++ == ' ') ; while (*str++ == ' ') ;
if (*--str == '-' || *str == '+') if (*--str == '-' || *str == '+')
str++; str++;
while (my_isdigit(system_charset_info,*str) || (allow_wildcards && while (my_isdigit(files_charset_info,*str) || (allow_wildcards &&
(*str == wild_many || *str == wild_one))) (*str == wild_many || *str == wild_one)))
{ {
flag=1; flag=1;
@ -1503,7 +1504,7 @@ static bool test_if_number(register const char *str,
if (*str == '.') if (*str == '.')
{ {
for (str++ ; for (str++ ;
my_isdigit(system_charset_info,*str) || my_isdigit(files_charset_info,*str) ||
(allow_wildcards && (*str == wild_many || *str == wild_one)) ; (allow_wildcards && (*str == wild_many || *str == wild_one)) ;
str++, flag=1) ; str++, flag=1) ;
} }

View File

@ -26,6 +26,8 @@
#include <assert.h> #include <assert.h>
#define log_cs my_charset_latin1
/***************************************************************************** /*****************************************************************************
my_b_safe_write() my_b_safe_write()
@ -691,7 +693,7 @@ void Log_event::set_log_pos(MYSQL_LOG* log)
void Query_log_event::pack_info(Protocol *protocol) void Query_log_event::pack_info(Protocol *protocol)
{ {
char buf[256]; char buf[256];
String tmp(buf, sizeof(buf), system_charset_info); String tmp(buf, sizeof(buf), log_cs);
tmp.length(0); tmp.length(0);
if (db && db_len) if (db && db_len)
{ {
@ -949,7 +951,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
void Start_log_event::pack_info(Protocol *protocol) void Start_log_event::pack_info(Protocol *protocol)
{ {
char buf1[256]; char buf1[256];
String tmp(buf1, sizeof(buf1), system_charset_info); String tmp(buf1, sizeof(buf1), log_cs);
tmp.length(0); tmp.length(0);
char buf[22]; char buf[22];
@ -1064,7 +1066,7 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli)
void Load_log_event::pack_info(Protocol *protocol) void Load_log_event::pack_info(Protocol *protocol)
{ {
char buf[256]; char buf[256];
String tmp(buf, sizeof(buf), system_charset_info); String tmp(buf, sizeof(buf), log_cs);
tmp.length(0); tmp.length(0);
if (db && db_len) if (db && db_len)
{ {
@ -1478,15 +1480,11 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
handle_dup = DUP_REPLACE; handle_dup = DUP_REPLACE;
sql_exchange ex((char*)fname, sql_ex.opt_flags && sql_exchange ex((char*)fname, sql_ex.opt_flags &&
DUMPFILE_FLAG ); DUMPFILE_FLAG );
String field_term(sql_ex.field_term,sql_ex.field_term_len, String field_term(sql_ex.field_term,sql_ex.field_term_len,log_cs);
system_charset_info); String enclosed(sql_ex.enclosed,sql_ex.enclosed_len,log_cs);
String enclosed(sql_ex.enclosed,sql_ex.enclosed_len, String line_term(sql_ex.line_term,sql_ex.line_term_len,log_cs);
system_charset_info); String line_start(sql_ex.line_start,sql_ex.line_start_len,log_cs);
String line_term(sql_ex.line_term,sql_ex.line_term_len, String escaped(sql_ex.escaped,sql_ex.escaped_len, log_cs);
system_charset_info);
String line_start(sql_ex.line_start,sql_ex.line_start_len,
system_charset_info);
String escaped(sql_ex.escaped,sql_ex.escaped_len, system_charset_info);
ex.opt_enclosed = (sql_ex.opt_flags & OPT_ENCLOSED_FLAG); ex.opt_enclosed = (sql_ex.opt_flags & OPT_ENCLOSED_FLAG);
if (sql_ex.empty_flags & FIELD_TERM_EMPTY) if (sql_ex.empty_flags & FIELD_TERM_EMPTY)
@ -1574,7 +1572,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
void Rotate_log_event::pack_info(Protocol *protocol) void Rotate_log_event::pack_info(Protocol *protocol)
{ {
char buf1[256], buf[22]; char buf1[256], buf[22];
String tmp(buf1, sizeof(buf1), system_charset_info); String tmp(buf1, sizeof(buf1), log_cs);
tmp.length(0); tmp.length(0);
tmp.append(new_log_ident, ident_len); tmp.append(new_log_ident, ident_len);
tmp.append(";pos="); tmp.append(";pos=");
@ -1716,7 +1714,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
void Intvar_log_event::pack_info(Protocol *protocol) void Intvar_log_event::pack_info(Protocol *protocol)
{ {
char buf1[256], buf[22]; char buf1[256], buf[22];
String tmp(buf1, sizeof(buf1), system_charset_info); String tmp(buf1, sizeof(buf1), log_cs);
tmp.length(0); tmp.length(0);
tmp.append(get_var_type_name()); tmp.append(get_var_type_name());
tmp.append('='); tmp.append('=');
@ -1933,7 +1931,7 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli)
void Slave_log_event::pack_info(Protocol *protocol) void Slave_log_event::pack_info(Protocol *protocol)
{ {
char buf1[256], buf[22], *end; char buf1[256], buf[22], *end;
String tmp(buf1, sizeof(buf1), system_charset_info); String tmp(buf1, sizeof(buf1), log_cs);
tmp.length(0); tmp.length(0);
tmp.append("host="); tmp.append("host=");
tmp.append(master_host); tmp.append(master_host);
@ -2283,7 +2281,7 @@ void Create_file_log_event::print(FILE* file, bool short_form,
void Create_file_log_event::pack_info(Protocol *protocol) void Create_file_log_event::pack_info(Protocol *protocol)
{ {
char buf1[256],buf[22], *end; char buf1[256],buf[22], *end;
String tmp(buf1, sizeof(buf1), system_charset_info); String tmp(buf1, sizeof(buf1), log_cs);
tmp.length(0); tmp.length(0);
tmp.append("db="); tmp.append("db=");
tmp.append(db, db_len); tmp.append(db, db_len);

View File

@ -725,7 +725,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());
} }
@ -735,7 +735,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());
} }

View File

@ -453,7 +453,7 @@ public:
{ {
Item_field *item= (Item_field*) value_arg; Item_field *item= (Item_field*) value_arg;
if (!(value=new Item_string(item->field_name, strlen(item->field_name), if (!(value=new Item_string(item->field_name, strlen(item->field_name),
system_charset_info))) item->charset())))
value=value_arg; /* Give error message later */ value=value_arg; /* Give error message later */
} }
else else

View File

@ -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;

View File

@ -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;
@ -192,6 +191,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;

View File

@ -381,6 +381,7 @@ struct system_variables
my_bool low_priority_updates; my_bool low_priority_updates;
CONVERT *convert_set; CONVERT *convert_set;
CHARSET_INFO *thd_charset;
}; };
@ -496,7 +497,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];

View File

@ -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);
} }

View File

@ -23,6 +23,8 @@
#include <my_dir.h> #include <my_dir.h>
#include <assert.h> #include <assert.h>
#define files_charset_info system_charset_info
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
#include "ha_innodb.h" #include "ha_innodb.h"
#endif #endif
@ -1231,7 +1233,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break; break;
} }
if (lower_case_table_names) if (lower_case_table_names)
my_casedn_str(system_charset_info, db); my_casedn_str(files_charset_info, db);
if (check_access(thd,CREATE_ACL,db,0,1)) if (check_access(thd,CREATE_ACL,db,0,1))
break; break;
mysql_log.write(thd,command,packet); mysql_log.write(thd,command,packet);
@ -1249,7 +1251,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break; break;
} }
if (lower_case_table_names) if (lower_case_table_names)
my_casedn_str(system_charset_info, db); my_casedn_str(files_charset_info, db);
if (thd->locked_tables || thd->active_transaction()) if (thd->locked_tables || thd->active_transaction())
{ {
send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION);
@ -2527,7 +2529,7 @@ mysql_execute_command(THD *thd)
break; break;
} }
if (lower_case_table_names) if (lower_case_table_names)
my_casedn_str(system_charset_info, lex->name); my_casedn_str(files_charset_info, lex->name);
if (check_access(thd,CREATE_ACL,lex->name,0,1)) if (check_access(thd,CREATE_ACL,lex->name,0,1))
break; break;
res=mysql_create_db(thd,lex->name,&lex->create_info,0); res=mysql_create_db(thd,lex->name,&lex->create_info,0);
@ -2541,7 +2543,7 @@ mysql_execute_command(THD *thd)
break; break;
} }
if (lower_case_table_names) if (lower_case_table_names)
my_casedn_str(system_charset_info, lex->name); my_casedn_str(files_charset_info, lex->name);
if (check_access(thd,DROP_ACL,lex->name,0,1)) if (check_access(thd,DROP_ACL,lex->name,0,1))
break; break;
if (thd->locked_tables || thd->active_transaction()) if (thd->locked_tables || thd->active_transaction())
@ -2629,7 +2631,7 @@ mysql_execute_command(THD *thd)
if (user->password.str && if (user->password.str &&
(strcmp(thd->user,user->user.str) || (strcmp(thd->user,user->user.str) ||
user->host.str && user->host.str &&
my_strcasecmp(system_charset_info, my_strcasecmp(my_charset_latin1,
user->host.str, thd->host_or_ip))) user->host.str, thd->host_or_ip)))
{ {
if (check_access(thd, UPDATE_ACL, "mysql",0,1)) if (check_access(thd, UPDATE_ACL, "mysql",0,1))
@ -3624,8 +3626,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
ptr->alias= alias_str; ptr->alias= alias_str;
if (lower_case_table_names) if (lower_case_table_names)
{ {
my_casedn_str(system_charset_info,ptr->db); my_casedn_str(files_charset_info,ptr->db);
my_casedn_str(system_charset_info,table->table.str); my_casedn_str(files_charset_info,table->table.str);
} }
ptr->real_name=table->table.str; ptr->real_name=table->table.str;
ptr->real_name_length=table->table.length; ptr->real_name_length=table->table.length;

View File

@ -711,7 +711,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;

View File

@ -361,6 +361,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token UDF_SYM %token UDF_SYM
%token UNCOMMITTED_SYM %token UNCOMMITTED_SYM
%token UNDERSCORE_CHARSET %token UNDERSCORE_CHARSET
%token UNICODE_SYM
%token UNION_SYM %token UNION_SYM
%token UNIQUE_SYM %token UNIQUE_SYM
%token USAGE %token USAGE
@ -380,6 +381,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token ERRORS %token ERRORS
%token WARNINGS %token WARNINGS
%token ASCII_SYM
%token BIGINT %token BIGINT
%token BLOB_SYM %token BLOB_SYM
%token CHAR_SYM %token CHAR_SYM
@ -1257,11 +1259,20 @@ opt_db_default_character_set:
opt_binary: opt_binary:
/* empty */ { Lex->charset=NULL; } /* empty */ { Lex->charset=NULL; }
| ASCII_SYM { Lex->charset=my_charset_latin1; }
| BYTE_SYM { Lex->charset=my_charset_bin; } | BYTE_SYM { Lex->charset=my_charset_bin; }
| BINARY { Lex->charset=my_charset_bin; } | BINARY { Lex->charset=my_charset_bin; }
| UNICODE_SYM
{
if (!(Lex->charset=get_charset_by_name("ucs2",MYF(0))))
{
net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,"ucs2");
YYABORT;
}
}
| COLLATE_SYM charset_name { Lex->charset=$2; }
| CHAR_SYM SET charset_name { Lex->charset=$3; } ; | CHAR_SYM SET charset_name { Lex->charset=$3; } ;
opt_primary: opt_primary:
/* empty */ /* empty */
| PRIMARY_SYM | PRIMARY_SYM
@ -2014,6 +2025,7 @@ simple_expr:
| MATCH ident_list_arg AGAINST '(' expr IN_SYM BOOLEAN_SYM MODE_SYM ')' | MATCH ident_list_arg AGAINST '(' expr IN_SYM BOOLEAN_SYM MODE_SYM ')'
{ Select->add_ftfunc_to_list((Item_func_match *) { Select->add_ftfunc_to_list((Item_func_match *)
($$=new Item_func_match_bool(*$2,$5))); } ($$=new Item_func_match_bool(*$2,$5))); }
| ASCII_SYM '(' expr ')' { $$= new Item_func_ascii($3); }
| BINARY expr %prec NEG { $$= new Item_func_set_collation($2,my_charset_bin); } | BINARY expr %prec NEG { $$= new Item_func_set_collation($2,my_charset_bin); }
| CAST_SYM '(' expr AS cast_type ')' { $$= create_func_cast($3, $5); } | CAST_SYM '(' expr AS cast_type ')' { $$= create_func_cast($3, $5); }
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END | CASE_SYM opt_expr WHEN_SYM when_list opt_else END
@ -3588,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);
@ -3721,6 +3733,7 @@ keyword:
| AGAINST {} | AGAINST {}
| AGGREGATE_SYM {} | AGGREGATE_SYM {}
| ANY_SYM {} | ANY_SYM {}
| ASCII_SYM {}
| AUTO_INC {} | AUTO_INC {}
| AVG_ROW_LENGTH {} | AVG_ROW_LENGTH {}
| AVG_SYM {} | AVG_SYM {}
@ -3872,6 +3885,7 @@ keyword:
| TYPE_SYM {} | TYPE_SYM {}
| UDF_SYM {} | UDF_SYM {}
| UNCOMMITTED_SYM {} | UNCOMMITTED_SYM {}
| UNICODE_SYM {}
| USE_FRM {} | USE_FRM {}
| VARIABLES {} | VARIABLES {}
| VALUE_SYM {} | VALUE_SYM {}

View File

@ -268,13 +268,13 @@ void find_date(string pos,uint *vek,uint flag)
DBUG_PRINT("enter",("pos: '%s' flag: %d",pos,flag)); DBUG_PRINT("enter",("pos: '%s' flag: %d",pos,flag));
bzero((char*) vek,sizeof(int)*4); bzero((char*) vek,sizeof(int)*4);
while (*pos && !my_isdigit(system_charset_info,*pos)) while (*pos && !my_isdigit(my_charset_latin1,*pos))
pos++; pos++;
length=(uint) strlen(pos); length=(uint) strlen(pos);
for (uint i=0 ; i< 3; i++) for (uint i=0 ; i< 3; i++)
{ {
start=pos; value=0; start=pos; value=0;
while (my_isdigit(system_charset_info,pos[0]) && while (my_isdigit(my_charset_latin1,pos[0]) &&
((pos-start) < 2 || ((pos-start) < 4 && length >= 8 && ((pos-start) < 2 || ((pos-start) < 4 && length >= 8 &&
!(flag & 3)))) !(flag & 3))))
{ {
@ -282,8 +282,8 @@ void find_date(string pos,uint *vek,uint flag)
pos++; pos++;
} }
vek[flag & 3]=value; flag>>=2; vek[flag & 3]=value; flag>>=2;
while (*pos && (my_ispunct(system_charset_info,*pos) || while (*pos && (my_ispunct(my_charset_latin1,*pos) ||
my_isspace(system_charset_info,*pos))) my_isspace(my_charset_latin1,*pos)))
pos++; pos++;
} }
DBUG_PRINT("exit",("year: %d month: %d day: %d",vek[0],vek[1],vek[2])); DBUG_PRINT("exit",("year: %d month: %d day: %d",vek[0],vek[1],vek[2]));
@ -452,7 +452,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
DBUG_PRINT("enter",("str: %.*s",length,str)); DBUG_PRINT("enter",("str: %.*s",length,str));
// Skip garbage // Skip garbage
for (; str != end && !my_isdigit(system_charset_info, *str) ; str++) ; for (; str != end && !my_isdigit(my_charset_latin1, *str) ; str++) ;
if (str == end) if (str == end)
DBUG_RETURN(TIMESTAMP_NONE); DBUG_RETURN(TIMESTAMP_NONE);
/* /*
@ -460,15 +460,15 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
If length= 8 or >= 14 then year is of format YYYY. If length= 8 or >= 14 then year is of format YYYY.
(YYYY-MM-DD, YYYYMMDD, YYYYYMMDDHHMMSS) (YYYY-MM-DD, YYYYMMDD, YYYYYMMDDHHMMSS)
*/ */
for (pos=str; pos != end && my_isdigit(system_charset_info,*pos) ; pos++) ; for (pos=str; pos != end && my_isdigit(my_charset_latin1,*pos) ; pos++) ;
digits= (uint) (pos-str); digits= (uint) (pos-str);
year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2; year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2;
field_length=year_length-1; field_length=year_length-1;
not_zero_date= 0; not_zero_date= 0;
for (i=0 ; i < 6 && str != end && my_isdigit(system_charset_info,*str) ; i++) for (i=0 ; i < 6 && str != end && my_isdigit(my_charset_latin1,*str) ; i++)
{ {
uint tmp_value=(uint) (uchar) (*str++ - '0'); uint tmp_value=(uint) (uchar) (*str++ - '0');
while (str != end && my_isdigit(system_charset_info,str[0]) && while (str != end && my_isdigit(my_charset_latin1,str[0]) &&
field_length--) field_length--)
{ {
tmp_value=tmp_value*10 + (uint) (uchar) (*str - '0'); tmp_value=tmp_value*10 + (uint) (uchar) (*str - '0');
@ -481,11 +481,11 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
else if ( i != 5 ) // Skip inter-field delimiters else if ( i != 5 ) // Skip inter-field delimiters
{ {
while (str != end && while (str != end &&
(my_ispunct(system_charset_info,*str) || (my_ispunct(my_charset_latin1,*str) ||
my_isspace(system_charset_info,*str))) my_isspace(my_charset_latin1,*str)))
{ {
// Only allow space between days and hours // Only allow space between days and hours
if (my_isspace(system_charset_info,*str) && i != 2) if (my_isspace(my_charset_latin1,*str) && i != 2)
DBUG_RETURN(TIMESTAMP_NONE); DBUG_RETURN(TIMESTAMP_NONE);
str++; str++;
} }
@ -494,12 +494,12 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
} }
/* Handle second fractions */ /* Handle second fractions */
if (i == 6 && (uint) (end-str) >= 2 && *str == '.' && if (i == 6 && (uint) (end-str) >= 2 && *str == '.' &&
my_isdigit(system_charset_info,str[1])) my_isdigit(my_charset_latin1,str[1]))
{ {
str++; str++;
uint tmp_value=(uint) (uchar) (*str - '0'); uint tmp_value=(uint) (uchar) (*str - '0');
field_length=3; field_length=3;
while (str++ != end && my_isdigit(system_charset_info,str[0]) && while (str++ != end && my_isdigit(my_charset_latin1,str[0]) &&
field_length--) field_length--)
tmp_value=tmp_value*10 + (uint) (uchar) (*str - '0'); tmp_value=tmp_value*10 + (uint) (uchar) (*str - '0');
date[6]=tmp_value; date[6]=tmp_value;
@ -522,7 +522,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
{ {
for (; str != end ; str++) for (; str != end ; str++)
{ {
if (!my_isspace(system_charset_info, *str)) if (!my_isspace(my_charset_latin1, *str))
{ {
not_zero_date= 1; // Give warning not_zero_date= 1; // Give warning
break; break;
@ -537,7 +537,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
{ {
for (; str != end ; str++) for (; str != end ; str++)
{ {
if (!my_isspace(system_charset_info,*str)) if (!my_isspace(my_charset_latin1,*str))
{ {
current_thd->cuted_fields++; current_thd->cuted_fields++;
break; break;
@ -599,7 +599,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
l_time->neg=0; l_time->neg=0;
for (; str != end && for (; str != end &&
!my_isdigit(system_charset_info,*str) && *str != '-' ; str++) !my_isdigit(my_charset_latin1,*str) && *str != '-' ; str++)
length--; length--;
if (str != end && *str == '-') if (str != end && *str == '-')
{ {
@ -618,7 +618,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
} }
/* Not a timestamp. Try to get this as a DAYS_TO_SECOND string */ /* Not a timestamp. Try to get this as a DAYS_TO_SECOND string */
for (value=0; str != end && my_isdigit(system_charset_info,*str) ; str++) for (value=0; str != end && my_isdigit(my_charset_latin1,*str) ; str++)
value=value*10L + (long) (*str - '0'); value=value*10L + (long) (*str - '0');
if (*str == ' ') if (*str == ' ')
@ -630,7 +630,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
LINT_INIT(state); LINT_INIT(state);
found_days=found_hours=0; found_days=found_hours=0;
if ((uint) (end-str) > 1 && (*str == ' ' && if ((uint) (end-str) > 1 && (*str == ' ' &&
my_isdigit(system_charset_info,str[1]))) my_isdigit(my_charset_latin1,str[1])))
{ // days ! { // days !
date[0]=value; date[0]=value;
state=1; // Assume next is hours state=1; // Assume next is hours
@ -638,7 +638,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
str++; // Skip space; str++; // Skip space;
} }
else if ((end-str) > 1 && *str == ':' && else if ((end-str) > 1 && *str == ':' &&
my_isdigit(system_charset_info,str[1])) my_isdigit(my_charset_latin1,str[1]))
{ {
date[0]=0; // Assume we found hours date[0]=0; // Assume we found hours
date[1]=value; date[1]=value;
@ -660,11 +660,11 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
/* Read hours, minutes and seconds */ /* Read hours, minutes and seconds */
for (;;) for (;;)
{ {
for (value=0; str != end && my_isdigit(system_charset_info,*str) ; str++) for (value=0; str != end && my_isdigit(my_charset_latin1,*str) ; str++)
value=value*10L + (long) (*str - '0'); value=value*10L + (long) (*str - '0');
date[state++]=value; date[state++]=value;
if (state == 4 || (end-str) < 2 || *str != ':' || if (state == 4 || (end-str) < 2 || *str != ':' ||
!my_isdigit(system_charset_info,str[1])) !my_isdigit(my_charset_latin1,str[1]))
break; break;
str++; // Skip ':' str++; // Skip ':'
} }
@ -684,12 +684,12 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
fractional: fractional:
/* Get fractional second part */ /* Get fractional second part */
if ((end-str) >= 2 && *str == '.' && my_isdigit(system_charset_info,str[1])) if ((end-str) >= 2 && *str == '.' && my_isdigit(my_charset_latin1,str[1]))
{ {
uint field_length=3; uint field_length=3;
str++; value=(uint) (uchar) (*str - '0'); str++; value=(uint) (uchar) (*str - '0');
while (++str != end && while (++str != end &&
my_isdigit(system_charset_info,str[0]) && my_isdigit(my_charset_latin1,str[0]) &&
field_length--) field_length--)
value=value*10 + (uint) (uchar) (*str - '0'); value=value*10 + (uint) (uchar) (*str - '0');
date[4]=value; date[4]=value;
@ -715,7 +715,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
{ {
do do
{ {
if (!my_isspace(system_charset_info,*str)) if (!my_isspace(my_charset_latin1,*str))
{ {
current_thd->cuted_fields++; current_thd->cuted_fields++;
break; break;