Commit d8c70089 authored by hf@deer.mysql.r18.ru's avatar hf@deer.mysql.r18.ru

Merging&testing

parent c1e69d2c
...@@ -420,6 +420,82 @@ bool send_fields(THD *thd, List<Item> &list, uint flag) ...@@ -420,6 +420,82 @@ bool send_fields(THD *thd, List<Item> &list, uint flag)
return 1; /* purecov: inspected */ return 1; /* purecov: inspected */
} }
bool Protocol::send_fields(List<Item> *list, uint flag)
{
List_iterator_fast<Item> it(*list);
Item *item;
MEM_ROOT *alloc;
MYSQL_FIELD *field, *client_field;
MYSQL *mysql= thd->mysql;
set_nfields(list->elements);
if (!(mysql->result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+
sizeof(ulong) * (n_fields + 1),
MYF(MY_WME | MY_ZEROFILL))))
goto err;
mysql->result->lengths= (ulong *)(mysql->result + 1);
mysql->field_count=n_fields;
alloc= &mysql->field_alloc;
field= (MYSQL_FIELD *)alloc_root(alloc, sizeof(MYSQL_FIELD) * n_fields);
if (!field)
goto err;
client_field= field;
while ((item= it++))
{
Send_field server_field;
item->make_field(&server_field);
client_field->table= strdup_root(alloc, server_field.table_name);
client_field->name= strdup_root(alloc,server_field.col_name);
client_field->length= server_field.length;
client_field->type= server_field.type;
client_field->flags= server_field.flags;
client_field->decimals= server_field.decimals;
if (INTERNAL_NUM_FIELD(client_field))
client_field->flags|= NUM_FLAG;
if (flag & 2)
{
char buff[80];
String tmp(buff, sizeof(buff), default_charset_info), *res;
if (!(res=item->val_str(&tmp)))
client_field->def= strdup_root(alloc, "");
else
client_field->def= strdup_root(alloc, tmp.ptr());
}
else
client_field->def=0;
client_field->max_length= 0;
++client_field;
}
mysql->result->fields = field;
if (!(mysql->result->data= (MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
MYF(MY_WME | MY_ZEROFILL))))
goto err;
init_alloc_root(&mysql->result->data->alloc,8192,0); /* Assume rowlength < 8192 */
mysql->result->data->alloc.min_malloc=sizeof(MYSQL_ROWS);
mysql->result->data->rows=0;
mysql->result->data->fields=n_fields;
mysql->result->field_count=n_fields;
mysql->result->data->prev_ptr= &mysql->result->data->data;
mysql->result->field_alloc= mysql->field_alloc;
mysql->result->current_field=0;
mysql->result->current_row=0;
return 0;
err:
send_error(thd, ER_OUT_OF_RESOURCES); /* purecov: inspected */
return 1; /* purecov: inspected */
}
/* Get the length of next field. Change parameter to point at fieldstart */ /* Get the length of next field. Change parameter to point at fieldstart */
static ulong static ulong
net_field_length(uchar **packet) net_field_length(uchar **packet)
...@@ -542,7 +618,7 @@ send_eof(THD *thd, bool no_flush) ...@@ -542,7 +618,7 @@ send_eof(THD *thd, bool no_flush)
} }
int embedded_send_row(THD *thd, int n_fields, char *data, int data_len) int embedded_send_row(THD *thd, int n_fields, const char *data, int data_len)
{ {
MYSQL *mysql= thd->mysql; MYSQL *mysql= thd->mysql;
MYSQL_DATA *result= mysql->result->data; MYSQL_DATA *result= mysql->result->data;
......
...@@ -255,6 +255,7 @@ int berkeley_show_logs(Protocol *protocol) ...@@ -255,6 +255,7 @@ int berkeley_show_logs(Protocol *protocol)
/* Error is 0 here */ /* Error is 0 here */
if (all_logs) if (all_logs)
{ {
protocol->set_nfields(3);
for (a = all_logs, f = free_logs; *a; ++a) for (a = all_logs, f = free_logs; *a; ++a)
{ {
protocol->prepare_for_resend(); protocol->prepare_for_resend();
...@@ -2075,6 +2076,7 @@ static void print_msg(THD *thd, const char *table_name, const char *op_name, ...@@ -2075,6 +2076,7 @@ static void print_msg(THD *thd, const char *table_name, const char *op_name,
msgbuf[sizeof(msgbuf) - 1] = 0; // healthy paranoia msgbuf[sizeof(msgbuf) - 1] = 0; // healthy paranoia
DBUG_PRINT(msg_type,("message: %s",msgbuf)); DBUG_PRINT(msg_type,("message: %s",msgbuf));
protocol->set_nfields(4);
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(table_name); protocol->store(table_name);
protocol->store(op_name); protocol->store(op_name);
......
...@@ -76,6 +76,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, ...@@ -76,6 +76,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
} }
length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) - length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) -
name); name);
protocol->set_nfields(4);
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(name, length); protocol->store(name, length);
protocol->store(param->op_name); protocol->store(param->op_name);
......
...@@ -880,7 +880,7 @@ inline void mark_as_null_row(TABLE *table) ...@@ -880,7 +880,7 @@ inline void mark_as_null_row(TABLE *table)
} }
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
int embedded_send_row(THD *thd, int n_fields, char *data, int data_len); int embedded_send_row(THD *thd, int n_fields, const char *data, int data_len);
#define SEND_ROW(thd, n_fields, data, data_len)\ #define SEND_ROW(thd, n_fields, data, data_len)\
embedded_send_row(thd, n_fields, data, data_len) embedded_send_row(thd, n_fields, data, data_len)
#else #else
......
...@@ -455,19 +455,6 @@ char *net_store_data(char *to,longlong from) ...@@ -455,19 +455,6 @@ char *net_store_data(char *to,longlong from)
Function called by my_net_init() to set some check variables Function called by my_net_init() to set some check variables
*/ */
extern "C" {
void my_net_local_init(NET *net)
{
net->max_packet= (uint) global_system_variables.net_buffer_length;
net->read_timeout= (uint) global_system_variables.net_read_timeout;
net->write_timeout=(uint) global_system_variables.net_write_timeout;
net->retry_count= (uint) global_system_variables.net_retry_count;
net->max_packet_size= max(global_system_variables.net_buffer_length,
global_system_variables.max_allowed_packet);
}
}
/***************************************************************************** /*****************************************************************************
Default Protocol functions Default Protocol functions
*****************************************************************************/ *****************************************************************************/
...@@ -504,6 +491,7 @@ void Protocol::init(THD *thd_arg) ...@@ -504,6 +491,7 @@ void Protocol::init(THD *thd_arg)
1 Error (Note that in this case the error is not sent to the client) 1 Error (Note that in this case the error is not sent to the client)
*/ */
#ifndef EMBEDDED_LIBRARY
bool Protocol::send_fields(List<Item> *list, uint flag) bool Protocol::send_fields(List<Item> *list, uint flag)
{ {
List_iterator_fast<Item> it(*list); List_iterator_fast<Item> it(*list);
...@@ -586,11 +574,12 @@ bool Protocol::send_fields(List<Item> *list, uint flag) ...@@ -586,11 +574,12 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
DBUG_RETURN(1); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */
} }
#endif
bool Protocol::write() bool Protocol::write()
{ {
DBUG_ENTER("Protocol::write"); DBUG_ENTER("Protocol::write");
DBUG_RETURN(my_net_write(&thd->net, packet->ptr(), packet->length())); DBUG_RETURN(SEND_ROW(thd, n_fields, packet->ptr(), packet->length()));
} }
...@@ -828,6 +817,7 @@ bool Protocol_simple::store_time(TIME *tm) ...@@ -828,6 +817,7 @@ bool Protocol_simple::store_time(TIME *tm)
bool Protocol_prep::prepare_for_send(List<Item> *item_list) bool Protocol_prep::prepare_for_send(List<Item> *item_list)
{ {
field_count=item_list->elements; field_count=item_list->elements;
set_nfields(item_list->elements);
bit_fields= (field_count+3)/8; bit_fields= (field_count+3)/8;
if (packet->alloc(bit_fields)) if (packet->alloc(bit_fields))
return 1; return 1;
......
...@@ -33,6 +33,9 @@ class Protocol ...@@ -33,6 +33,9 @@ class Protocol
#ifndef DEBUG_OFF #ifndef DEBUG_OFF
enum enum_field_types *field_types; enum enum_field_types *field_types;
#endif #endif
#ifdef EMBEDDED_LIBRARY
uint n_fields;
#endif
public: public:
CONVERT *convert; CONVERT *convert;
...@@ -53,6 +56,12 @@ class Protocol ...@@ -53,6 +56,12 @@ class Protocol
inline bool store(ulonglong from) inline bool store(ulonglong from)
{ return store_longlong((longlong) from, 1); } { return store_longlong((longlong) from, 1); }
#ifdef EMBEDDED_LIBRARY
inline void set_nfields(uint fields_count) { n_fields= fields_count; }
#else
inline void set_nfields(uint fields_count) {}
#endif
virtual bool prepare_for_send(List<Item> *item_list) { return 0;} virtual bool prepare_for_send(List<Item> *item_list) { return 0;}
virtual void prepare_for_resend()=0; virtual void prepare_for_resend()=0;
......
...@@ -1032,6 +1032,7 @@ static int send_check_errmsg(THD *thd, TABLE_LIST* table, ...@@ -1032,6 +1032,7 @@ static int send_check_errmsg(THD *thd, TABLE_LIST* table,
{ {
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
protocol->set_nfields(4);
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(table->alias); protocol->store(table->alias);
protocol->store((char*) operator_name); protocol->store((char*) operator_name);
......
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