Commit caf31a07 authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

Preparing to client<->server autoconvert

parent e00c9fa7
......@@ -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());
}
......
......@@ -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())
{
......
......@@ -4123,7 +4123,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())
......
......@@ -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);
......
......@@ -1001,7 +1001,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:
......
......@@ -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);
......@@ -722,7 +722,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
......@@ -992,7 +992,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
......@@ -1191,7 +1191,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
......@@ -1665,7 +1665,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
......@@ -1800,7 +1800,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
......@@ -1911,7 +1911,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
......@@ -2013,7 +2013,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
......@@ -2213,7 +2213,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
......@@ -2547,7 +2547,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
......@@ -2698,7 +2698,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
......@@ -2811,7 +2811,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
......@@ -2910,7 +2910,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);
}
/*****************************************************************************
......
......@@ -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 ||
......
......@@ -52,7 +52,7 @@ class Protocol
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 @@ class Protocol
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 @@ class Protocol_simple :public Protocol
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 @@ class Protocol_prep :public Protocol
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);
......
......@@ -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);
......@@ -610,11 +610,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);
......
......@@ -1608,22 +1608,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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
......@@ -1103,7 +1103,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);
......@@ -1160,7 +1160,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;
}
......
......@@ -7687,7 +7687,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());
......
This diff is collapsed.
......@@ -1108,10 +1108,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;
......@@ -1301,12 +1301,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;
......@@ -1316,11 +1316,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())
......@@ -1355,8 +1355,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:
......@@ -1364,40 +1364,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;
}
......
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