#include "protocol.h"#include "messages.h"#include <mysql_com.h>#include <m_string.h>Include dependency graph for protocol.cc:

Go to the source code of this file.
Functions | |
| int | net_send_ok (struct st_net *net, unsigned long connection_id, const char *message) |
| int | net_send_error (struct st_net *net, uint sql_errno) |
| int | net_send_error_323 (struct st_net *net, uint sql_errno) |
| char * | net_store_length (char *pkg, uint length) |
| int | store_to_protocol_packet (Buffer *buf, const char *string, uint *position, uint string_len) |
| int | store_to_protocol_packet (Buffer *buf, const char *string, uint *position) |
| int | send_eof (struct st_net *net) |
| int | send_fields (struct st_net *net, LIST *fields) |
Variables | |
| static char | eof_buff [1] = { (char) 254 } |
| static const char | ERROR_PACKET_CODE = (char) 255 |
Definition at line 69 of file protocol.cc.
References err, errno_to_sqlstate(), int2store, memcpy, message(), my_net_write(), MYSQL_ERRMSG_SIZE, net_flush(), pos(), SQLSTATE_LENGTH, and strmake().
Referenced by Mysql_connection_thread::check_connection(), check_user(), close_connection(), dispatch_command(), Mysql_connection_thread::dispatch_command(), do_command(), Mysql_connection_thread::do_command(), get_or_create_user_conn(), handle_bootstrap(), and handle_one_connection().
00070 { 00071 const char *err= message(sql_errno); 00072 char buff[1 + // packet type code 00073 2 + // sql error number 00074 1 + SQLSTATE_LENGTH + // sql state 00075 MYSQL_ERRMSG_SIZE]; // message 00076 char *pos= buff; 00077 00078 *pos++= ERROR_PACKET_CODE; 00079 int2store(pos, sql_errno); 00080 pos+= 2; 00081 /* The first # is to make the protocol backward compatible */ 00082 *pos++= '#'; 00083 memcpy(pos, errno_to_sqlstate(sql_errno), SQLSTATE_LENGTH); 00084 pos+= SQLSTATE_LENGTH; 00085 pos= strmake(pos, err, MYSQL_ERRMSG_SIZE - 1) + 1; 00086 return my_net_write(net, buff, pos - buff) || net_flush(net); 00087 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 90 of file protocol.cc.
References err, int2store, message(), my_net_write(), MYSQL_ERRMSG_SIZE, net_flush(), pos(), and strmake().
Referenced by Mysql_connection_thread::check_connection().
00091 { 00092 const char *err= message(sql_errno); 00093 char buff[1 + // packet type code 00094 2 + // sql error number 00095 MYSQL_ERRMSG_SIZE]; // message 00096 char *pos= buff; 00097 00098 *pos++= ERROR_PACKET_CODE; 00099 int2store(pos, sql_errno); 00100 pos+= 2; 00101 pos= strmake(pos, err, MYSQL_ERRMSG_SIZE - 1) + 1; 00102 return my_net_write(net, buff, pos - buff) || net_flush(net); 00103 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int net_send_ok | ( | struct st_net * | net, | |
| unsigned long | connection_id, | |||
| const char * | message | |||
| ) |
Definition at line 29 of file protocol.cc.
References Buffer::buffer, int2store, my_net_write(), net_flush(), net_store_length(), NULL, pos(), Buffer::reserve(), st_net::return_status, store_to_protocol_packet(), and strlen().
Referenced by Mysql_connection_thread::check_connection(), Mysql_connection_thread::dispatch_command(), Create_instance::execute(), Flush_instances::execute(), Abstract_option_cmd::execute_impl(), Drop_instance::send_ok_response(), Stop_instance::send_ok_response(), and Start_instance::send_ok_response().
00031 { 00032 /* 00033 The format of a packet 00034 1 packet type code 00035 1-9 affected rows count 00036 1-9 connection id 00037 2 thread return status 00038 2 warning count 00039 1-9 + message length message to send (isn't stored if no message) 00040 */ 00041 Buffer buff; 00042 char *pos= buff.buffer; 00043 00044 /* check that we have space to hold mandatory fields */ 00045 buff.reserve(0, 23); 00046 00047 enum { OK_PACKET_CODE= 0 }; 00048 *pos++= OK_PACKET_CODE; 00049 pos= net_store_length(pos, (ulonglong) 0); 00050 pos= net_store_length(pos, (ulonglong) connection_id); 00051 int2store(pos, *net->return_status); 00052 pos+= 2; 00053 /* We don't support warnings, so store 0 for total warning count */ 00054 int2store(pos, 0); 00055 pos+= 2; 00056 00057 uint position= pos - buff.buffer; /* we might need it for message */ 00058 00059 if (message != NULL) 00060 { 00061 buff.reserve(position, 9 + strlen(message)); 00062 store_to_protocol_packet(&buff, message, &position); 00063 } 00064 00065 return my_net_write(net, buff.buffer, position) || net_flush(net); 00066 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* net_store_length | ( | char * | pkg, | |
| uint | length | |||
| ) |
| int send_eof | ( | struct st_net * | net | ) |
Definition at line 148 of file protocol.cc.
Referenced by dispatch_command(), Event_scheduler::dump_internal_status(), Show_instances::execute(), ha_show_status(), mysql_admin_table(), mysql_checksum_table(), mysql_xa_recover(), mysqld_help(), mysqld_list_processes(), mysqld_show_authors(), mysqld_show_column_types(), mysqld_show_contributors(), mysqld_show_create(), mysqld_show_create_db(), mysqld_show_privileges(), mysqld_show_storage_engines(), mysqld_show_warnings(), Show_instance_log_files::send_ok_response(), Show_instance_log::send_ok_response(), Show_instance_options::send_ok_response(), Show_instance_status::send_ok_response(), Events::show_create_event(), sp_head::show_create_function(), sp_head::show_create_procedure(), and sp_head::show_routine_code().
00149 { 00150 uchar buff[1 + /* eof packet code */ 00151 2 + /* warning count */ 00152 2]; /* server status */ 00153 00154 buff[0]=254; 00155 int2store(buff+1, 0); 00156 int2store(buff+3, 0); 00157 return my_net_write(net, (char*) buff, sizeof buff); 00158 }
Here is the caller graph for this function:

Definition at line 160 of file protocol.cc.
References Buffer::buffer, st_list::data, eof_buff, err, FIELD_TYPE_STRING, int2store, int4store, Buffer::is_error(), LEX_STRING::length, list_length(), list_rest, my_net_write(), net_store_length(), Buffer::reserve(), store_to_protocol_packet(), and LEX_STRING::str.
Referenced by JOIN::make_sum_func_list(), Select_fetch_protocol_prep::send_fields(), Show_instance_log_files::write_header(), Show_instance_log::write_header(), Show_instance_options::write_header(), Show_instance_status::write_header(), and Show_instances::write_header().
00161 { 00162 LIST *tmp= fields; 00163 Buffer send_buff; 00164 char small_buff[4]; 00165 uint position= 0; 00166 LEX_STRING *field; 00167 00168 /* send the number of fileds */ 00169 net_store_length(small_buff, (uint) list_length(fields)); 00170 if (my_net_write(net, small_buff, (uint) 1)) 00171 goto err; 00172 00173 while (tmp) 00174 { 00175 position= 0; 00176 field= (LEX_STRING *) tmp->data; 00177 00178 store_to_protocol_packet(&send_buff, 00179 (char*) "", &position); /* catalog name */ 00180 store_to_protocol_packet(&send_buff, 00181 (char*) "", &position); /* db name */ 00182 store_to_protocol_packet(&send_buff, 00183 (char*) "", &position); /* table name */ 00184 store_to_protocol_packet(&send_buff, 00185 (char*) "", &position); /* table name alias */ 00186 store_to_protocol_packet(&send_buff, 00187 field->str, &position); /* column name */ 00188 store_to_protocol_packet(&send_buff, 00189 field->str, &position); /* column name alias */ 00190 send_buff.reserve(position, 12); 00191 if (send_buff.is_error()) 00192 goto err; 00193 send_buff.buffer[position++]= 12; 00194 int2store(send_buff.buffer + position, 1); /* charsetnr */ 00195 int4store(send_buff.buffer + position + 2, 00196 field->length); /* field length */ 00197 send_buff.buffer[position+6]= (char) FIELD_TYPE_STRING; /* type */ 00198 int2store(send_buff.buffer + position + 7, 0); /* flags */ 00199 send_buff.buffer[position + 9]= (char) 0; /* decimals */ 00200 send_buff.buffer[position + 10]= 0; 00201 send_buff.buffer[position + 11]= 0; 00202 position+= 12; 00203 if (my_net_write(net, send_buff.buffer, (uint) position+1)) 00204 goto err; 00205 tmp= list_rest(tmp); 00206 } 00207 00208 if (my_net_write(net, eof_buff, 1)) 00209 goto err; 00210 return 0; 00211 00212 err: 00213 return 1; 00214 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 139 of file protocol.cc.
00140 { 00141 uint string_len; 00142 00143 string_len= strlen(string); 00144 return store_to_protocol_packet(buf, string, position, string_len); 00145 }
| int store_to_protocol_packet | ( | Buffer * | buf, | |
| const char * | string, | |||
| uint * | position, | |||
| uint | string_len | |||
| ) |
Definition at line 119 of file protocol.cc.
Referenced by net_send_ok(), send_fields(), store_to_protocol_packet(), Show_instance_log::write_data(), Show_instance_options::write_data(), Show_instance_status::write_data(), and Show_instances::write_data().
00121 { 00122 uint currpos; 00123 00124 /* reserve max amount of bytes needed to store length */ 00125 if (buf->reserve(*position, 9)) 00126 goto err; 00127 currpos= (net_store_length(buf->buffer + *position, 00128 (ulonglong) string_len) - buf->buffer); 00129 if (buf->append(currpos, string, string_len)) 00130 goto err; 00131 *position= *position + string_len + (currpos - *position); 00132 00133 return 0; 00134 err: 00135 return 1; 00136 }
Here is the caller graph for this function:

char eof_buff[1] = { (char) 254 } [static] |
const char ERROR_PACKET_CODE = (char) 255 [static] |
Definition at line 26 of file protocol.cc.
1.4.7

