summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-03-17 15:06:06 +0200
committerunknown <monty@narttu.mysql.fi>2003-03-17 15:06:06 +0200
commitec8e9125e0df422798bdb31ef60d9970de6b0731 (patch)
tree89c2cddedab130da0fd07ba77db571a22d84b51e
parent6a44ee4d0f87bbfd8e134527f986b1d86fd11ecc (diff)
parentb5eed2dcfe9cae031e93e19a720dbff8135b2212 (diff)
downloadmariadb-git-ec8e9125e0df422798bdb31ef60d9970de6b0731.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into narttu.mysql.fi:/my/mysql-4.1 sql/field.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/item.cc: Auto merged sql/log_event.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/slave.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged
-rw-r--r--sql/field.cc2
-rw-r--r--sql/ha_berkeley.cc8
-rw-r--r--sql/ha_innodb.cc2
-rw-r--r--sql/ha_myisam.cc8
-rw-r--r--sql/item.cc2
-rw-r--r--sql/log_event.cc28
-rw-r--r--sql/protocol.cc37
-rw-r--r--sql/protocol.h8
-rw-r--r--sql/repl_failsafe.cc8
-rw-r--r--sql/slave.cc16
-rw-r--r--sql/sql_acl.cc6
-rw-r--r--sql/sql_db.cc4
-rw-r--r--sql/sql_error.cc4
-rw-r--r--sql/sql_help.cc12
-rw-r--r--sql/sql_repl.cc4
-rw-r--r--sql/sql_select.cc5
-rw-r--r--sql/sql_show.cc123
-rw-r--r--sql/sql_string.cc4
-rw-r--r--sql/sql_table.cc57
19 files changed, 178 insertions, 160 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 133d7a6c21a..0c17209003c 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -204,7 +204,7 @@ bool Field::send_binary(Protocol *protocol)
char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),charset());
val_str(&tmp,&tmp);
- return protocol->store(tmp.ptr(), tmp.length());
+ return protocol->store(tmp.ptr(), tmp.length(), tmp.charset());
}
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index cdb5a8c1219..dbed955c0a9 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -257,15 +257,15 @@ int berkeley_show_logs(Protocol *protocol)
for (a = all_logs, f = free_logs; *a; ++a)
{
protocol->prepare_for_resend();
- protocol->store(*a);
- protocol->store("BDB", 3);
+ protocol->store(*a, system_charset_info);
+ protocol->store("BDB", 3, system_charset_info);
if (f && *f && strcmp(*a, *f) == 0)
{
f++;
- protocol->store(SHOW_LOG_STATUS_FREE);
+ protocol->store(SHOW_LOG_STATUS_FREE, system_charset_info);
}
else
- protocol->store(SHOW_LOG_STATUS_INUSE);
+ protocol->store(SHOW_LOG_STATUS_INUSE, system_charset_info);
if (protocol->write())
{
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index eaa088647c3..ce26ee705dd 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -4147,7 +4147,7 @@ innodb_show_status(
}
protocol->prepare_for_resend();
- protocol->store(buf, strlen(buf));
+ protocol->store(buf, strlen(buf), system_charset_info);
ut_free(buf);
if (protocol->write())
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 4f61ee48748..829ec5b0ade 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -77,10 +77,10 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) -
name);
protocol->prepare_for_resend();
- protocol->store(name, length);
- protocol->store(param->op_name);
- protocol->store(msg_type);
- protocol->store(msgbuf, msg_length);
+ protocol->store(name, length, system_charset_info);
+ protocol->store(param->op_name, system_charset_info);
+ protocol->store(msg_type, system_charset_info);
+ protocol->store(msgbuf, msg_length, system_charset_info);
if (protocol->write())
sql_print_error("Failed on my_net_write, writing to stderr instead: %s\n",
msgbuf);
diff --git a/sql/item.cc b/sql/item.cc
index ea0d21ad300..d362ff9ff40 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1012,7 +1012,7 @@ bool Item::send(Protocol *protocol, String *buffer)
{
String *res;
if ((res=val_str(buffer)))
- result= protocol->store(res->ptr(),res->length());
+ result= protocol->store(res->ptr(),res->length(),res->charset());
break;
}
case MYSQL_TYPE_TINY:
diff --git a/sql/log_event.cc b/sql/log_event.cc
index fabc02a3293..1f3a09ba93b 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -348,10 +348,10 @@ int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
log_name = p + 1;
protocol->prepare_for_resend();
- protocol->store(log_name);
+ protocol->store(log_name, system_charset_info);
protocol->store((ulonglong) pos);
event_type = get_type_str();
- protocol->store(event_type, strlen(event_type));
+ protocol->store(event_type, strlen(event_type), system_charset_info);
protocol->store((uint32) server_id);
protocol->store((ulonglong) log_pos);
pack_info(protocol);
@@ -731,7 +731,7 @@ void Query_log_event::pack_info(Protocol *protocol)
memcpy(pos, query, q_len);
pos+= q_len;
}
- protocol->store(buf, pos-buf);
+ protocol->store(buf, pos-buf, system_charset_info);
my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
}
#endif
@@ -1001,7 +1001,7 @@ void Start_log_event::pack_info(Protocol *protocol)
pos= strmov(pos, server_version);
pos= strmov(pos, ", Binlog ver: ");
pos=int10_to_str(binlog_version, pos, 10);
- protocol->store(buf, pos-buf);
+ protocol->store(buf, pos-buf, system_charset_info);
}
#endif
@@ -1200,7 +1200,7 @@ void Load_log_event::pack_info(Protocol *protocol)
*pos++= ')';
}
- protocol->store(buf, pos-buf);
+ protocol->store(buf, pos-buf, system_charset_info);
my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
}
#endif
@@ -1675,7 +1675,7 @@ void Rotate_log_event::pack_info(Protocol *protocol)
b_pos=longlong10_to_str(pos, b_pos, 10);
if (flags & LOG_EVENT_FORCED_ROTATE_F)
b_pos= strmov(b_pos ,"; forced by master");
- protocol->store(buf, b_pos-buf);
+ protocol->store(buf, b_pos-buf, system_charset_info);
my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
}
#endif
@@ -1810,7 +1810,7 @@ void Intvar_log_event::pack_info(Protocol *protocol)
pos= strmov(buf, get_var_type_name());
*(pos++)='=';
pos= longlong10_to_str(val, pos, -10);
- protocol->store(buf, pos-buf);
+ protocol->store(buf, pos-buf, system_charset_info);
}
#endif
@@ -1921,7 +1921,7 @@ void Rand_log_event::pack_info(Protocol *protocol)
pos= int10_to_str((long) seed1, pos, 10);
pos= strmov(pos, ",rand_seed2=");
pos= int10_to_str((long) seed2, pos, 10);
- protocol->store(buf1, (uint) (pos-buf1));
+ protocol->store(buf1, (uint) (pos-buf1), system_charset_info);
}
#endif
@@ -2023,7 +2023,7 @@ void User_var_log_event::pack_info(Protocol* protocol)
buf[0]= '@';
buf[1+name_len]= '=';
memcpy(buf+1, name, name_len);
- protocol->store(buf, event_len);
+ protocol->store(buf, event_len, system_charset_info);
my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
}
#endif // !MYSQL_CLIENT
@@ -2223,7 +2223,7 @@ void Slave_log_event::pack_info(Protocol *protocol)
pos= strmov(pos, master_log);
pos= strmov(pos, ",pos=");
pos= longlong10_to_str(master_pos, pos, 10);
- protocol->store(buf, pos-buf);
+ protocol->store(buf, pos-buf, system_charset_info);
}
#endif // !MYSQL_CLIENT
@@ -2557,7 +2557,7 @@ void Create_file_log_event::pack_info(Protocol *protocol)
pos= int10_to_str((long) file_id, pos, 10);
pos= strmov(pos, ";block_len=");
pos= int10_to_str((long) block_len, pos, 10);
- protocol->store(buf, pos-buf);
+ protocol->store(buf, pos-buf, system_charset_info);
}
#endif
@@ -2708,7 +2708,7 @@ void Append_block_log_event::pack_info(Protocol *protocol)
length= (uint) my_sprintf(buf,
(buf, ";file_id=%u;block_len=%u", file_id,
block_len));
- protocol->store(buf, (int32) length);
+ protocol->store(buf, (int32) length, system_charset_info);
}
#endif
@@ -2821,7 +2821,7 @@ void Delete_file_log_event::pack_info(Protocol *protocol)
char buf[64];
uint length;
length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id));
- protocol->store(buf, (int32) length);
+ protocol->store(buf, (int32) length, system_charset_info);
}
#endif
@@ -2920,7 +2920,7 @@ void Execute_load_log_event::pack_info(Protocol *protocol)
char buf[64];
uint length;
length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id));
- protocol->store(buf, (int32) length);
+ protocol->store(buf, (int32) length, system_charset_info);
}
/*****************************************************************************
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 454b8bae625..c7ce38eadac 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -528,18 +528,20 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
while ((item=it++))
{
char *pos;
+ CHARSET_INFO *cs= system_charset_info;
Send_field field;
item->make_field(&field);
prot.prepare_for_resend();
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{
- if (prot.store(field.db_name, (uint) strlen(field.db_name)) ||
- prot.store(field.table_name, (uint) strlen(field.table_name)) ||
+ if (prot.store(field.db_name, (uint) strlen(field.db_name), cs) ||
+ prot.store(field.table_name, (uint) strlen(field.table_name), cs) ||
prot.store(field.org_table_name,
- (uint) strlen(field.org_table_name)) ||
- prot.store(field.col_name, (uint) strlen(field.col_name)) ||
- prot.store(field.org_col_name, (uint) strlen(field.org_col_name)) ||
+ (uint) strlen(field.org_table_name), cs) ||
+ prot.store(field.col_name, (uint) strlen(field.col_name), cs) ||
+ prot.store(field.org_col_name,
+ (uint) strlen(field.org_col_name), cs) ||
packet->realloc(packet->length()+12))
goto err;
/* Store fixed length fields */
@@ -556,8 +558,8 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
}
else
{
- if (prot.store(field.table_name, (uint) strlen(field.table_name)) ||
- prot.store(field.col_name, (uint) strlen(field.col_name)) ||
+ if (prot.store(field.table_name, (uint) strlen(field.table_name), cs) ||
+ prot.store(field.col_name, (uint) strlen(field.col_name), cs) ||
packet->realloc(packet->length()+10))
goto err;
pos= (char*) packet->ptr()+packet->length();
@@ -639,12 +641,12 @@ bool Protocol::write()
1 error
*/
-bool Protocol::store(const char *from)
+bool Protocol::store(const char *from, CHARSET_INFO *cs)
{
if (!from)
return store_null();
uint length= strlen(from);
- return store(from, length);
+ return store(from, length, cs);
}
@@ -668,7 +670,7 @@ bool Protocol::store(I_List<i_string>* str_list)
}
if ((len= tmp.length()))
len--; // Remove last ','
- return store((char*) tmp.ptr(), len);
+ return store((char*) tmp.ptr(), len, tmp.charset());
}
@@ -701,7 +703,7 @@ bool Protocol_simple::store_null()
#endif
-bool Protocol_simple::store(const char *from, uint length)
+bool Protocol_simple::store(const char *from, uint length, CHARSET_INFO *cs)
{
#ifndef DEBUG_OFF
DBUG_ASSERT(field_types == 0 ||
@@ -712,7 +714,16 @@ bool Protocol_simple::store(const char *from, uint length)
#endif
if (convert)
return convert_str(from, length);
- return net_store_data(from, length);
+#if 0
+ if (cs != this->thd->charset())
+ {
+ String tmp;
+ tmp.copy(from, length, cs, this->thd->charset());
+ return net_store_data(tmp.ptr(), tmp.length());
+ }
+ else
+#endif
+ return net_store_data(from, length);
}
@@ -904,7 +915,7 @@ void Protocol_prep::prepare_for_resend()
}
-bool Protocol_prep::store(const char *from,uint length)
+bool Protocol_prep::store(const char *from,uint length, CHARSET_INFO *cs)
{
#ifndef DEBUG_OFF
DBUG_ASSERT(field_types == 0 ||
diff --git a/sql/protocol.h b/sql/protocol.h
index f57652af670..e9df013e81c 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -52,7 +52,7 @@ public:
bool send_fields(List<Item> *list, uint flag);
bool send_records_num(List<Item> *list, ulonglong records);
bool store(I_List<i_string> *str_list);
- bool store(const char *from);
+ bool store(const char *from, CHARSET_INFO *cs);
String *storage_packet() { return packet; }
inline void free() { packet->free(); }
bool write();
@@ -75,7 +75,7 @@ public:
virtual bool store_short(longlong from)=0;
virtual bool store_long(longlong from)=0;
virtual bool store_longlong(longlong from, bool unsigned_flag)=0;
- virtual bool store(const char *from, uint length)=0;
+ virtual bool store(const char *from, uint length, CHARSET_INFO *cs)=0;
virtual bool store(float from, uint32 decimals, String *buffer)=0;
virtual bool store(double from, uint32 decimals, String *buffer)=0;
virtual bool store(TIME *time)=0;
@@ -98,7 +98,7 @@ public:
virtual bool store_short(longlong from);
virtual bool store_long(longlong from);
virtual bool store_longlong(longlong from, bool unsigned_flag);
- virtual bool store(const char *from, uint length);
+ virtual bool store(const char *from, uint length, CHARSET_INFO *cs);
virtual bool store(TIME *time);
virtual bool store_date(TIME *time);
virtual bool store_time(TIME *time);
@@ -122,7 +122,7 @@ public:
virtual bool store_short(longlong from);
virtual bool store_long(longlong from);
virtual bool store_longlong(longlong from, bool unsigned_flag);
- virtual bool store(const char *from,uint length);
+ virtual bool store(const char *from,uint length, CHARSET_INFO *cs);
virtual bool store(TIME *time);
virtual bool store_date(TIME *time);
virtual bool store_time(TIME *time);
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 1be84723c1e..82fa87658ed 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -440,7 +440,7 @@ int show_new_master(THD* thd)
if (protocol->send_fields(&field_list, 1))
DBUG_RETURN(-1);
protocol->prepare_for_resend();
- protocol->store(lex_mi->log_file_name);
+ protocol->store(lex_mi->log_file_name, system_charset_info);
protocol->store((ulonglong) lex_mi->pos);
if (protocol->write())
DBUG_RETURN(-1);
@@ -638,11 +638,11 @@ int show_slave_hosts(THD* thd)
SLAVE_INFO* si = (SLAVE_INFO*) hash_element(&slave_list, i);
protocol->prepare_for_resend();
protocol->store((uint32) si->server_id);
- protocol->store(si->host);
+ protocol->store(si->host, system_charset_info);
if (opt_show_slave_auth_info)
{
- protocol->store(si->user);
- protocol->store(si->password);
+ protocol->store(si->user, system_charset_info);
+ protocol->store(si->password, system_charset_info);
}
protocol->store((uint32) si->port);
protocol->store((uint32) si->rpl_recovery_rank);
diff --git a/sql/slave.cc b/sql/slave.cc
index 6ab25959063..215da63a704 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1618,22 +1618,22 @@ int show_master_info(THD* thd, MASTER_INFO* mi)
pthread_mutex_lock(&mi->data_lock);
pthread_mutex_lock(&mi->rli.data_lock);
- protocol->store(mi->host);
- protocol->store(mi->user);
+ protocol->store(mi->host, system_charset_info);
+ protocol->store(mi->user, system_charset_info);
protocol->store((uint32) mi->port);
protocol->store((uint32) mi->connect_retry);
- protocol->store(mi->master_log_name);
+ protocol->store(mi->master_log_name, system_charset_info);
protocol->store((ulonglong) mi->master_log_pos);
protocol->store(mi->rli.relay_log_name +
- dirname_length(mi->rli.relay_log_name));
+ dirname_length(mi->rli.relay_log_name), system_charset_info);
protocol->store((ulonglong) mi->rli.relay_log_pos);
- protocol->store(mi->rli.master_log_name);
- protocol->store(mi->slave_running ? "Yes":"No");
- protocol->store(mi->rli.slave_running ? "Yes":"No");
+ protocol->store(mi->rli.master_log_name, system_charset_info);
+ protocol->store(mi->slave_running ? "Yes":"No", system_charset_info);
+ protocol->store(mi->rli.slave_running ? "Yes":"No", system_charset_info);
protocol->store(&replicate_do_db);
protocol->store(&replicate_ignore_db);
protocol->store((uint32) mi->rli.last_slave_errno);
- protocol->store(mi->rli.last_slave_error);
+ protocol->store(mi->rli.last_slave_error, system_charset_info);
protocol->store((uint32) mi->rli.slave_skip_counter);
protocol->store((ulonglong) mi->rli.master_log_pos);
protocol->store((ulonglong) mi->rli.log_space_total);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index fe443f6c882..5f8f71e1bd4 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -2954,7 +2954,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
}
}
protocol->prepare_for_resend();
- protocol->store(global.ptr(),global.length());
+ protocol->store(global.ptr(),global.length(),global.charset());
if (protocol->write())
{
error=-1;
@@ -3012,7 +3012,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
if (want_access & GRANT_ACL)
db.append(" WITH GRANT OPTION",18);
protocol->prepare_for_resend();
- protocol->store(db.ptr(),db.length());
+ protocol->store(db.ptr(),db.length(),db.charset());
if (protocol->write())
{
error=-1;
@@ -3100,7 +3100,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
if (want_access & GRANT_ACL)
global.append(" WITH GRANT OPTION",18);
protocol->prepare_for_resend();
- protocol->store(global.ptr(),global.length());
+ protocol->store(global.ptr(),global.length(),global.charset());
if (protocol->write())
{
error= -1;
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 99763d717fe..03ccf88316c 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -671,7 +671,7 @@ int mysqld_show_create_db(THD *thd, char *dbname,
DBUG_RETURN(1);
protocol->prepare_for_resend();
- protocol->store(dbname, strlen(dbname));
+ protocol->store(dbname, strlen(dbname), system_charset_info);
to= strxmov(path, "CREATE DATABASE ", NullS);
if (create_options & HA_LEX_CREATE_IF_NOT_EXISTS)
to= strxmov(to,"/*!32312 IF NOT EXISTS*/ ", NullS);
@@ -685,7 +685,7 @@ int mysqld_show_create_db(THD *thd, char *dbname,
cl ? " COLLATE " : "", cl ? create.table_charset->name : "",
" */",NullS);
}
- protocol->store(path, (uint) (to-path));
+ protocol->store(path, (uint) (to-path), system_charset_info);
if (protocol->write())
DBUG_RETURN(1);
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 5508be5167a..00c80a654cb 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -180,9 +180,9 @@ my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
}
protocol->prepare_for_resend();
protocol->store(warning_level_names[err->level],
- warning_level_length[err->level]);
+ warning_level_length[err->level], system_charset_info);
protocol->store((uint32) err->code);
- protocol->store(err->msg, strlen(err->msg));
+ protocol->store(err->msg, strlen(err->msg), system_charset_info);
if (protocol->write())
DBUG_RETURN(1);
if (!--limit)
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index def36665fb5..36c7ef87b17 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -201,8 +201,8 @@ int send_variant_2_list(Protocol *protocol, List<char> *names,
while ((cur_name= it++))
{
protocol->prepare_for_resend();
- protocol->store(cur_name);
- protocol->store(cat);
+ protocol->store(cur_name, system_charset_info);
+ protocol->store(cat, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
}
@@ -317,10 +317,10 @@ int send_answer_1(Protocol *protocol, const char *s1, const char *s2,
DBUG_RETURN(1);
protocol->prepare_for_resend();
- protocol->store(s1);
- protocol->store(s2);
- protocol->store(s3);
- protocol->store(s4);
+ protocol->store(s1, system_charset_info);
+ protocol->store(s2, system_charset_info);
+ protocol->store(s3, system_charset_info);
+ protocol->store(s4, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
DBUG_RETURN(0);
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 7b05d0d2b98..63ba519885f 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1109,7 +1109,7 @@ int show_binlog_info(THD* thd)
LOG_INFO li;
mysql_bin_log.get_current_log(&li);
int dir_len = dirname_length(li.log_file_name);
- protocol->store(li.log_file_name + dir_len);
+ protocol->store(li.log_file_name + dir_len, system_charset_info);
protocol->store((ulonglong) li.pos);
protocol->store(&binlog_do_db);
protocol->store(&binlog_ignore_db);
@@ -1166,7 +1166,7 @@ int show_binlogs(THD* thd)
protocol->prepare_for_resend();
int dir_len = dirname_length(fname);
/* The -1 is for removing newline from fname */
- protocol->store(fname + dir_len, length-1-dir_len);
+ protocol->store(fname + dir_len, length-1-dir_len, system_charset_info);
if (protocol->write())
goto err;
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 987857fd61b..6f3dfeb3558 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6725,8 +6725,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
NullS))
DBUG_RETURN(1);
- // BAR TODO: this must be fixed to use charset from "table" argument
- if (hash_init(&hash, default_charset_info, (uint) file->records, 0,
+ if (hash_init(&hash, &my_charset_bin, (uint) file->records, 0,
key_length,(hash_get_key) 0, 0, 0))
{
my_free((char*) key_buffer,MYF(0));
@@ -7703,7 +7702,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
if (_db_on_ && !item_field->name)
{
char buff[256];
- String str(buff,sizeof(buff),default_charset_info);
+ String str(buff,sizeof(buff),&my_charset_bin);
str.length(0);
item->print(&str);
item_field->name= sql_strmake(str.ptr(),str.length());
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 76f5a14c6ad..db4de2962b7 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -85,7 +85,7 @@ mysqld_show_dbs(THD *thd,const char *wild)
(grant_option && !check_grant_db(thd, file_name)))
{
protocol->prepare_for_resend();
- protocol->store(file_name);
+ protocol->store(file_name, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
}
@@ -120,8 +120,8 @@ int mysqld_show_open_tables(THD *thd,const char *wild)
for (; open_list ; open_list=open_list->next)
{
protocol->prepare_for_resend();
- protocol->store(open_list->db);
- protocol->store(open_list->table);
+ protocol->store(open_list->db, system_charset_info);
+ protocol->store(open_list->table, system_charset_info);
protocol->store_tiny((longlong) open_list->in_use);
protocol->store_tiny((longlong) open_list->locked);
if (protocol->write())
@@ -166,7 +166,7 @@ int mysqld_show_tables(THD *thd,const char *db,const char *wild)
while ((file_name=it++))
{
protocol->prepare_for_resend();
- protocol->store(file_name);
+ protocol->store(file_name, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
}
@@ -225,14 +225,14 @@ int mysqld_show_table_types(THD *thd)
for (types= sys_table_types; types->type; types++)
{
protocol->prepare_for_resend();
- protocol->store(types->type);
+ protocol->store(types->type, system_charset_info);
const char *option_name= show_comp_option_name[(int) *types->value];
if (*types->value == SHOW_OPTION_YES &&
!my_strcasecmp(system_charset_info, default_type_name, types->type))
option_name= "DEFAULT";
- protocol->store(option_name);
- protocol->store(types->comment);
+ protocol->store(option_name, system_charset_info);
+ protocol->store(types->comment, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
}
@@ -292,9 +292,9 @@ int mysqld_show_privileges(THD *thd)
for (privilege= sys_privileges; privilege->privilege ; privilege++)
{
protocol->prepare_for_resend();
- protocol->store(privilege->privilege);
- protocol->store(privilege->context);
- protocol->store(privilege->comment);
+ protocol->store(privilege->privilege, system_charset_info);
+ protocol->store(privilege->context, system_charset_info);
+ protocol->store(privilege->comment, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
}
@@ -367,20 +367,20 @@ int mysqld_show_column_types(THD *thd)
for (uint i=0; i < sizeof(sys_column_types)/sizeof(sys_column_types[0]); i++)
{
protocol->prepare_for_resend();
- protocol->store(sys_column_types[i].type);
+ protocol->store(sys_column_types[i].type, system_charset_info);
protocol->store((ulonglong) sys_column_types[i].size);
- protocol->store(sys_column_types[i].min_value);
- protocol->store(sys_column_types[i].max_value);
+ protocol->store(sys_column_types[i].min_value, system_charset_info);
+ protocol->store(sys_column_types[i].max_value, system_charset_info);
protocol->store_short((longlong) sys_column_types[i].precision);
protocol->store_short((longlong) sys_column_types[i].scale);
- protocol->store(sys_column_types[i].nullable);
- protocol->store(sys_column_types[i].auto_increment);
- protocol->store(sys_column_types[i].unsigned_attr);
- protocol->store(sys_column_types[i].zerofill);
- protocol->store(sys_column_types[i].searchable);
- protocol->store(sys_column_types[i].case_sensitivity);
- protocol->store(sys_column_types[i].default_value);
- protocol->store(sys_column_types[i].comment);
+ protocol->store(sys_column_types[i].nullable, system_charset_info);
+ protocol->store(sys_column_types[i].auto_increment, system_charset_info);
+ protocol->store(sys_column_types[i].unsigned_attr, system_charset_info);
+ protocol->store(sys_column_types[i].zerofill, system_charset_info);
+ protocol->store(sys_column_types[i].searchable, system_charset_info);
+ protocol->store(sys_column_types[i].case_sensitivity, system_charset_info);
+ protocol->store(sys_column_types[i].default_value, system_charset_info);
+ protocol->store(sys_column_types[i].comment, system_charset_info);
if (protocol->write())
DBUG_RETURN(-1);
}
@@ -524,7 +524,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
TABLE_LIST table_list;
bzero((char*) &table_list,sizeof(table_list));
protocol->prepare_for_resend();
- protocol->store(file_name);
+ protocol->store(file_name, system_charset_info);
table_list.db=(char*) db;
table_list.real_name= table_list.alias= file_name;
if (lower_case_table_names)
@@ -534,7 +534,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
for (uint i=2 ; i < field_list.elements ; i++)
protocol->store_null();
// Send error to Comment field
- protocol->store(thd->net.last_error);
+ protocol->store(thd->net.last_error, system_charset_info);
thd->net.last_error[0]=0;
}
else
@@ -543,12 +543,12 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
const char *str;
handler *file=table->file;
file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
- protocol->store(file->table_type());
+ protocol->store(file->table_type(), system_charset_info);
str= ((table->db_options_in_use & HA_OPTION_COMPRESS_RECORD) ?
"Compressed" :
(table->db_options_in_use & HA_OPTION_PACK_RECORD) ?
"Dynamic" : "Fixed");
- protocol->store(str);
+ protocol->store(str, system_charset_info);
protocol->store((ulonglong) file->records);
protocol->store((ulonglong) file->mean_rec_length);
protocol->store((ulonglong) file->data_file_length);
@@ -593,7 +593,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
protocol->store(&time);
}
str= (table->table_charset ? table->table_charset->name : "default");
- protocol->store(str);
+ protocol->store(str, system_charset_info);
{
char option_buff[350],*ptr;
ptr=option_buff;
@@ -631,11 +631,12 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
ptr=strmov(ptr,buff);
}
protocol->store(option_buff+1,
- (ptr == option_buff ? 0 : (uint) (ptr-option_buff)-1));
+ (ptr == option_buff ? 0 : (uint) (ptr-option_buff)-1)
+ , system_charset_info);
}
{
char *comment=table->file->update_table_comment(table->comment);
- protocol->store(comment);
+ protocol->store(comment, system_charset_info);
if (comment != table->comment)
my_free(comment,MYF(0));
}
@@ -710,43 +711,43 @@ 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->variables.thd_charset);
+ String type(tmp,sizeof(tmp), system_charset_info);
uint col_access;
bool null_default_value=0;
protocol->prepare_for_resend();
- protocol->store(field->field_name);
+ protocol->store(field->field_name, system_charset_info);
field->sql_type(type);
- protocol->store(type.ptr(), type.length());
- protocol->store(field->charset()->name);
+ protocol->store(type.ptr(), type.length(), system_charset_info);
+ protocol->store(field->charset()->name, system_charset_info);
pos=(byte*) ((flags & NOT_NULL_FLAG) &&
field->type() != FIELD_TYPE_TIMESTAMP ?
"" : "YES");
- protocol->store((const char*) pos);
+ protocol->store((const char*) pos, system_charset_info);
pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
(field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
(field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
- protocol->store((char*) pos);
+ protocol->store((char*) pos, system_charset_info);
if (field->type() == FIELD_TYPE_TIMESTAMP ||
field->unireg_check == Field::NEXT_NUMBER)
null_default_value=1;
if (!null_default_value && !field->is_null())
{ // Not null by default
- type.set(tmp,sizeof(tmp),&my_charset_bin);
+ type.set(tmp,sizeof(tmp),system_charset_info);
field->val_str(&type,&type);
- protocol->store(type.ptr(),type.length());
+ protocol->store(type.ptr(),type.length(),type.charset());
}
else if (field->maybe_null() || null_default_value)
protocol->store_null(); // Null as default
else
- protocol->store("",0); // empty string
+ protocol->store("",0, system_charset_info); // empty string
char *end=tmp;
if (field->unireg_check == Field::NEXT_NUMBER)
end=strmov(tmp,"auto_increment");
- protocol->store(tmp,(uint) (end-tmp));
+ protocol->store(tmp,(uint) (end-tmp), system_charset_info);
if (verbose)
{
@@ -761,8 +762,10 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
end=strmov(end,grant_types.type_names[bitnr]);
}
}
- protocol->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1));
- protocol->store(field->comment.str, field->comment.length);
+ protocol->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1),
+ system_charset_info);
+ protocol->store(field->comment.str, field->comment.length,
+ system_charset_info);
}
if (protocol->write())
DBUG_RETURN(1);
@@ -799,11 +802,11 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
if (protocol->send_fields(&field_list, 1))
DBUG_RETURN(1);
protocol->prepare_for_resend();
- protocol->store(table->table_name);
+ protocol->store(table->table_name, system_charset_info);
buffer.length(0);
if (store_create_info(thd, table, &buffer))
DBUG_RETURN(-1);
- protocol->store(buffer.ptr(), buffer.length());
+ protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
if (protocol->write())
DBUG_RETURN(1);
send_eof(thd);
@@ -884,16 +887,16 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
{
protocol->prepare_for_resend();
- protocol->store(table->table_name);
+ protocol->store(table->table_name, system_charset_info);
protocol->store_tiny((longlong) ((key_info->flags & HA_NOSAME) ? 0 :1));
- protocol->store(key_info->name);
+ protocol->store(key_info->name, system_charset_info);
protocol->store_tiny((longlong) (j+1));
str=(key_part->field ? key_part->field->field_name :
"?unknown field?");
- protocol->store(str);
+ protocol->store(str, system_charset_info);
if (table->file->index_flags(i) & HA_READ_ORDER)
protocol->store(((key_part->key_part_flag & HA_REVERSE_SORT) ?
- "D" : "A"), 1);
+ "D" : "A"), 1, system_charset_info);
else
protocol->store_null(); /* purecov: inspected */
KEY *key=table->key_info+i;
@@ -917,8 +920,8 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
/* Null flag */
uint flags= key_part->field ? key_part->field->flags : 0;
char *pos=(char*) ((flags & NOT_NULL_FLAG) ? "" : "YES");
- protocol->store((const char*) pos);
- protocol->store(table->file->index_type(i));
+ protocol->store((const char*) pos, system_charset_info);
+ protocol->store(table->file->index_type(i), system_charset_info);
/* Comment */
protocol->store("", 0);
if (protocol->write())
@@ -1387,19 +1390,19 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
{
protocol->prepare_for_resend();
protocol->store((ulonglong) thd_info->thread_id);
- protocol->store(thd_info->user);
- protocol->store(thd_info->host);
- protocol->store(thd_info->db);
+ protocol->store(thd_info->user, system_charset_info);
+ protocol->store(thd_info->host, system_charset_info);
+ protocol->store(thd_info->db, system_charset_info);
if (thd_info->proc_info)
- protocol->store(thd_info->proc_info);
+ protocol->store(thd_info->proc_info, system_charset_info);
else
- protocol->store(command_name[thd_info->command]);
+ protocol->store(command_name[thd_info->command], system_charset_info);
if (thd_info->start_time)
protocol->store((uint32) (now - thd_info->start_time));
else
protocol->store_null();
- protocol->store(thd_info->state_info);
- protocol->store(thd_info->query);
+ protocol->store(thd_info->state_info, system_charset_info);
+ protocol->store(thd_info->query, system_charset_info);
if (protocol->write())
break; /* purecov: inspected */
}
@@ -1438,13 +1441,13 @@ int mysqld_show_charsets(THD *thd, const char *wild)
wild_case_compare(system_charset_info,cs[0]->name,wild)))
{
protocol->prepare_for_resend();
- protocol->store(cs[0]->csname);
- protocol->store(cs[0]->name);
+ protocol->store(cs[0]->csname, system_charset_info);
+ protocol->store(cs[0]->name, system_charset_info);
protocol->store_short((longlong) cs[0]->number);
flags[0]='\0';
if (cs[0]->state & MY_CS_PRIMARY)
strcat(flags,"pri");
- protocol->store(flags);
+ protocol->store(flags, system_charset_info);
protocol->store_tiny((longlong) cs[0]->strxfrm_multiply);
protocol->store_tiny((longlong) cs[0]->mbmaxlen);
if (protocol->write())
@@ -1480,7 +1483,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
variables->name,wild)))
{
protocol->prepare_for_resend();
- protocol->store(variables->name);
+ protocol->store(variables->name, system_charset_info);
SHOW_TYPE show_type=variables->type;
char *value=variables->value;
const char *pos, *end;
@@ -1726,7 +1729,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
default:
break;
}
- if (protocol->store(pos, (uint32) (end - pos)) ||
+ if (protocol->store(pos, (uint32) (end - pos), system_charset_info) ||
protocol->write())
goto err; /* purecov: inspected */
}
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index b6425003af3..d796c53fb52 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -232,6 +232,10 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
bool String::copy(const char *str, uint32 arg_length,
CHARSET_INFO *from_cs, CHARSET_INFO *to_cs)
{
+ if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
+ {
+ return copy(str, arg_length, &my_charset_bin);
+ }
uint32 new_length= to_cs->mbmaxlen*arg_length;
if (alloc(new_length))
return TRUE;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index f8d7ba5d277..f4bcd6bd684 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1110,10 +1110,10 @@ static int send_check_errmsg(THD *thd, TABLE_LIST* table,
{
Protocol *protocol= thd->protocol;
protocol->prepare_for_resend();
- protocol->store(table->alias);
- protocol->store((char*) operator_name);
- protocol->store("error", 5);
- protocol->store(errmsg);
+ protocol->store(table->alias, system_charset_info);
+ protocol->store((char*) operator_name, system_charset_info);
+ protocol->store("error", 5, system_charset_info);
+ protocol->store(errmsg, system_charset_info);
thd->net.last_error[0]=0;
if (protocol->write())
return -1;
@@ -1303,12 +1303,12 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
{
const char *err_msg;
protocol->prepare_for_resend();
- protocol->store(table_name);
- protocol->store(operator_name);
- protocol->store("error",5);
+ protocol->store(table_name, system_charset_info);
+ protocol->store(operator_name, system_charset_info);
+ protocol->store("error",5, system_charset_info);
if (!(err_msg=thd->net.last_error))
err_msg=ER(ER_CHECK_NO_SUCH_TABLE);
- protocol->store(err_msg);
+ protocol->store(err_msg, system_charset_info);
thd->net.last_error[0]=0;
if (protocol->write())
goto err;
@@ -1318,11 +1318,11 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
{
char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE];
protocol->prepare_for_resend();
- protocol->store(table_name);
- protocol->store(operator_name);
- protocol->store("error", 5);
+ protocol->store(table_name, system_charset_info);
+ protocol->store(operator_name, system_charset_info);
+ protocol->store("error", 5, system_charset_info);
sprintf(buff, ER(ER_OPEN_AS_READONLY), table_name);
- protocol->store(buff);
+ protocol->store(buff, system_charset_info);
close_thread_tables(thd);
table->table=0; // For query cache
if (protocol->write())
@@ -1357,8 +1357,8 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
thd->net.last_errno= 0; // these errors shouldn't get client
#endif
protocol->prepare_for_resend();
- protocol->store(table_name);
- protocol->store(operator_name);
+ protocol->store(table_name, system_charset_info);
+ protocol->store(operator_name, system_charset_info);
switch (result_code) {
case HA_ADMIN_NOT_IMPLEMENTED:
@@ -1366,40 +1366,41 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
char buf[ERRMSGSIZE+20];
uint length=my_snprintf(buf, ERRMSGSIZE,
ER(ER_CHECK_NOT_IMPLEMENTED), operator_name);
- protocol->store("error", 5);
- protocol->store(buf, length);
+ protocol->store("error", 5, system_charset_info);
+ protocol->store(buf, length, system_charset_info);
}
break;
case HA_ADMIN_OK:
- protocol->store("status", 6);
- protocol->store("OK",2);
+ protocol->store("status", 6, system_charset_info);
+ protocol->store("OK",2, system_charset_info);
break;
case HA_ADMIN_FAILED:
- protocol->store("status", 6);
- protocol->store("Operation failed",16);
+ protocol->store("status", 6, system_charset_info);
+ protocol->store("Operation failed",16, system_charset_info);
break;
case HA_ADMIN_ALREADY_DONE:
- protocol->store("status", 6);
- protocol->store("Table is already up to date", 27);
+ protocol->store("status", 6, system_charset_info);
+ protocol->store("Table is already up to date", 27, system_charset_info);
break;
case HA_ADMIN_CORRUPT:
- protocol->store("error", 5);
- protocol->store("Corrupt", 8);
+ protocol->store("error", 5, system_charset_info);
+ protocol->store("Corrupt", 8, system_charset_info);
fatal_error=1;
break;
case HA_ADMIN_INVALID:
- protocol->store("error", 5);
- protocol->store("Invalid argument",16);
+ protocol->store("error", 5, system_charset_info);
+ protocol->store("Invalid argument",16, system_charset_info);
break;
default: // Probably HA_ADMIN_INTERNAL_ERROR
- protocol->store("error", 5);
- protocol->store("Unknown - internal error during operation", 41);
+ protocol->store("error", 5, system_charset_info);
+ protocol->store("Unknown - internal error during operation", 41
+ , system_charset_info);
fatal_error=1;
break;
}