The world's most popular open source database
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| class | Protocol |
| class | Protocol_simple |
| class | Protocol_prep |
Typedefs | |
| typedef st_mysql_field | MYSQL_FIELD |
| typedef st_mysql_rows | MYSQL_ROWS |
Functions | |
| void | send_warning (THD *thd, uint sql_errno, const char *err=0) |
| void | net_printf_error (THD *thd, uint sql_errno,...) |
| void | net_send_error (THD *thd, uint sql_errno=0, const char *err=0) |
| void | send_ok (THD *thd, ha_rows affected_rows=0L, ulonglong id=0L, const char *info=0) |
| void | send_eof (THD *thd) |
| bool | send_old_password_request (THD *thd) |
| char * | net_store_length (char *packet, uint length) |
| char * | net_store_data (char *to, const char *from, uint length) |
| char * | net_store_data (char *to, int32 from) |
| char * | net_store_data (char *to, longlong from) |
| typedef struct st_mysql_field MYSQL_FIELD |
Definition at line 24 of file protocol.h.
| typedef struct st_mysql_rows MYSQL_ROWS |
Definition at line 25 of file protocol.h.
| void net_printf_error | ( | THD * | thd, | |
| uint | sql_errno, | |||
| ... | ||||
| ) |
Definition at line 123 of file protocol.cc.
References args, st_net::buff, st_net::buff_end, CLIENT_PROTOCOL_41, st_net::compress, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, ER, ER_UNKNOWN_ERROR, format(), int2store, int3store, KILL_CONNECTION, st_net::last_errno, st_net::last_error, memcpy, min, my_const_cast, my_vsnprintf(), mysql_errno_to_sqlstate(), NET_HEADER_SIZE, net_real_write(), st_net::no_send_error, offset, st_net::pkt_nr, pos(), push_warning(), query_cache_abort(), st_net::return_errno, st_net::sqlstate, SQLSTATE_LENGTH, strmake(), st_net::vio, VOID, and MYSQL_ERROR::WARN_LEVEL_ERROR.
Referenced by check_for_max_user_connections(), check_mqh(), check_user(), create_new_thread(), and handle_one_connection().
00124 { 00125 va_list args; 00126 uint length,offset; 00127 const char *format; 00128 #ifndef EMBEDDED_LIBRARY 00129 const char *text_pos; 00130 int head_length= NET_HEADER_SIZE; 00131 #else 00132 char text_pos[1024]; 00133 #endif 00134 NET *net= &thd->net; 00135 00136 DBUG_ENTER("net_printf_error"); 00137 DBUG_PRINT("enter",("message: %u",errcode)); 00138 00139 if (net && net->no_send_error) 00140 { 00141 thd->clear_error(); 00142 DBUG_PRINT("info", ("sending error messages prohibited")); 00143 DBUG_VOID_RETURN; 00144 } 00145 00146 if (thd->spcont && thd->spcont->find_handler(errcode, 00147 MYSQL_ERROR::WARN_LEVEL_ERROR)) 00148 { 00149 if (! thd->spcont->found_handler_here()) 00150 thd->net.report_error= 1; /* Make "select" abort correctly */ 00151 DBUG_VOID_RETURN; 00152 } 00153 thd->query_error= 1; // needed to catch query errors during replication 00154 #ifndef EMBEDDED_LIBRARY 00155 query_cache_abort(net); // Safety 00156 #endif 00157 va_start(args,errcode); 00158 /* 00159 The following is needed to make net_printf_error() work with 0 argument 00160 for errorcode and use the argument after that as the format string. This 00161 is useful for rare errors that are not worth the hassle to put in 00162 errmsg.sys, but at the same time, the message is not fixed text 00163 */ 00164 if (errcode) 00165 format= ER(errcode); 00166 else 00167 { 00168 format=va_arg(args,char*); 00169 errcode= ER_UNKNOWN_ERROR; 00170 } 00171 offset= (net->return_errno ? 00172 ((thd->client_capabilities & CLIENT_PROTOCOL_41) ? 00173 2+SQLSTATE_LENGTH+1 : 2) : 0); 00174 #ifndef EMBEDDED_LIBRARY 00175 text_pos=(char*) net->buff + head_length + offset + 1; 00176 length= (uint) ((char*)net->buff_end - text_pos); 00177 #else 00178 length=sizeof(text_pos)-1; 00179 #endif 00180 length=my_vsnprintf(my_const_cast(char*) (text_pos), 00181 min(length, sizeof(net->last_error)), 00182 format,args); 00183 va_end(args); 00184 00185 /* Replication slave relies on net->last_* to see if there was error */ 00186 net->last_errno= errcode; 00187 strmake(net->last_error, text_pos, sizeof(net->last_error)-1); 00188 00189 #ifndef EMBEDDED_LIBRARY 00190 if (net->vio == 0) 00191 { 00192 if (thd->bootstrap) 00193 { 00194 /* 00195 In bootstrap it's ok to print on stderr 00196 This may also happen when we get an error from a slave thread 00197 */ 00198 fprintf(stderr,"ERROR: %d %s\n",errcode,text_pos); 00199 thd->fatal_error(); 00200 } 00201 DBUG_VOID_RETURN; 00202 } 00203 00204 int3store(net->buff,length+1+offset); 00205 net->buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++); 00206 net->buff[head_length]=(uchar) 255; // Error package 00207 if (offset) 00208 { 00209 uchar *pos= net->buff+head_length+1; 00210 int2store(pos, errcode); 00211 if (thd->client_capabilities & CLIENT_PROTOCOL_41) 00212 { 00213 pos[2]= '#'; /* To make the protocol backward compatible */ 00214 memcpy(pos+3, mysql_errno_to_sqlstate(errcode), SQLSTATE_LENGTH); 00215 } 00216 } 00217 VOID(net_real_write(net,(char*) net->buff,length+head_length+1+offset)); 00218 #else 00219 net->last_errno= errcode; 00220 strmake(net->last_error, text_pos, length); 00221 strmake(net->sqlstate, mysql_errno_to_sqlstate(errcode), SQLSTATE_LENGTH); 00222 #endif 00223 if (thd->killed != THD::KILL_CONNECTION) 00224 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, errcode, 00225 text_pos ? text_pos : ER(errcode)); 00226 thd->is_fatal_error=0; // Error message is given 00227 DBUG_VOID_RETURN; 00228 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void net_send_error | ( | THD * | thd, | |
| uint | sql_errno = 0, |
|||
| const char * | err = 0 | |||
| ) |
Definition at line 58 of file protocol.cc.
References DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, ER, ER_UNKNOWN_ERROR, KILL_CONNECTION, st_net::last_errno, st_net::last_error, net_send_error_packet(), st_net::no_send_error, push_warning(), SERVER_MORE_RESULTS_EXISTS, and MYSQL_ERROR::WARN_LEVEL_ERROR.
00059 { 00060 NET *net= &thd->net; 00061 bool generate_warning= thd->killed != THD::KILL_CONNECTION; 00062 DBUG_ENTER("net_send_error"); 00063 DBUG_PRINT("enter",("sql_errno: %d err: %s", sql_errno, 00064 err ? err : net->last_error[0] ? 00065 net->last_error : "NULL")); 00066 00067 if (net && net->no_send_error) 00068 { 00069 thd->clear_error(); 00070 DBUG_PRINT("info", ("sending error messages prohibited")); 00071 DBUG_VOID_RETURN; 00072 } 00073 if (thd->spcont && thd->spcont->find_handler(sql_errno, 00074 MYSQL_ERROR::WARN_LEVEL_ERROR)) 00075 { 00076 if (! thd->spcont->found_handler_here()) 00077 thd->net.report_error= 1; /* Make "select" abort correctly */ 00078 DBUG_VOID_RETURN; 00079 } 00080 thd->query_error= 1; // needed to catch query errors during replication 00081 if (!err) 00082 { 00083 if (sql_errno) 00084 err=ER(sql_errno); 00085 else 00086 { 00087 if ((err=net->last_error)[0]) 00088 { 00089 sql_errno=net->last_errno; 00090 generate_warning= 0; // This warning has already been given 00091 } 00092 else 00093 { 00094 sql_errno=ER_UNKNOWN_ERROR; 00095 err=ER(sql_errno); /* purecov: inspected */ 00096 } 00097 } 00098 } 00099 00100 if (generate_warning) 00101 { 00102 /* Error that we have not got with my_error() */ 00103 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, err); 00104 } 00105 00106 net_send_error_packet(thd, sql_errno, err); 00107 00108 thd->is_fatal_error=0; // Error message is given 00109 thd->net.report_error= 0; 00110 00111 /* Abort multi-result sets */ 00112 thd->server_status&= ~SERVER_MORE_RESULTS_EXISTS; 00113 DBUG_VOID_RETURN; 00114 }
Here is the call graph for this function:

| char* net_store_data | ( | char * | to, | |
| longlong | from | |||
| ) |
Definition at line 486 of file protocol.cc.
References longlong10_to_str, memcpy, and net_store_length().
00487 { 00488 char buff[22]; 00489 uint length=(uint) (longlong10_to_str(from,buff,10)-buff); 00490 to=net_store_length(to,length); 00491 memcpy(to,buff,length); 00492 return to+length; 00493 }
Here is the call graph for this function:

| char* net_store_data | ( | char * | to, | |
| int32 | from | |||
| ) |
Definition at line 477 of file protocol.cc.
References int10_to_str(), memcpy, and net_store_length().
00478 { 00479 char buff[20]; 00480 uint length=(uint) (int10_to_str(from,buff,10)-buff); 00481 to=net_store_length(to,length); 00482 memcpy(to,buff,length); 00483 return to+length; 00484 }
Here is the call graph for this function:

| char* net_store_data | ( | char * | to, | |
| const char * | from, | |||
| uint | length | |||
| ) |
Definition at line 470 of file protocol.cc.
References memcpy, and net_store_length().
00471 { 00472 to=net_store_length(to,length); 00473 memcpy(to,from,length); 00474 return to+length; 00475 }
Here is the call graph for this function:

| char* net_store_length | ( | char * | packet, | |
| uint | length | |||
| ) |
Definition at line 105 of file protocol.cc.
References int2store.
00106 { 00107 uchar *packet=(uchar*) pkg; 00108 if (length < 251) 00109 { 00110 *packet=(uchar) length; 00111 return (char*) packet+1; 00112 } 00113 *packet++=252; 00114 int2store(packet,(uint) length); 00115 return (char*) packet+2; 00116 }
| void send_eof | ( | THD * | thd | ) |
Definition at line 333 of file protocol.cc.
References DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, net_flush(), st_net::no_send_eof, st_net::vio, VOID, and write_eof_packet().
00334 { 00335 NET *net= &thd->net; 00336 DBUG_ENTER("send_eof"); 00337 if (net->vio != 0 && !net->no_send_eof) 00338 { 00339 write_eof_packet(thd, net); 00340 VOID(net_flush(net)); 00341 thd->net.no_send_error= 1; 00342 DBUG_PRINT("info", ("EOF sent, so no more error sending allowed")); 00343 } 00344 DBUG_VOID_RETURN; 00345 }
Here is the call graph for this function:

Definition at line 258 of file protocol.cc.
References CLIENT_PROTOCOL_41, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, int2store, min, my_net_write(), MYSQL_ERRMSG_SIZE, net_flush(), net_store_data(), net_store_length(), st_net::no_send_ok, pos(), st_net::return_status, strlen(), st_net::vio, and VOID.
Referenced by check_user(), dispatch_command(), mysql_alter_db(), mysql_alter_table(), mysql_client_binlog_statement(), mysql_create_db(), mysql_create_or_drop_trigger(), mysql_delete(), mysql_discard_or_import_tablespace(), mysql_do(), mysql_drop_view(), mysql_execute_command(), mysql_grant(), mysql_ha_close(), mysql_ha_open(), mysql_insert(), mysql_load(), mysql_rename_tables(), mysql_rm_db(), mysql_rm_table(), mysql_routine_grant(), mysql_sql_stmt_close(), mysql_sql_stmt_prepare(), mysql_stmt_reset(), mysql_table_grant(), mysql_truncate(), and sql_kill().
00259 { 00260 NET *net= &thd->net; 00261 char buff[MYSQL_ERRMSG_SIZE+10],*pos; 00262 DBUG_ENTER("send_ok"); 00263 00264 if (net->no_send_ok || !net->vio) // hack for re-parsing queries 00265 { 00266 DBUG_PRINT("info", ("no send ok: %s, vio present: %s", 00267 (net->no_send_ok ? "YES" : "NO"), 00268 (net->vio ? "YES" : "NO"))); 00269 DBUG_VOID_RETURN; 00270 } 00271 00272 buff[0]=0; // No fields 00273 pos=net_store_length(buff+1,(ulonglong) affected_rows); 00274 pos=net_store_length(pos, (ulonglong) id); 00275 if (thd->client_capabilities & CLIENT_PROTOCOL_41) 00276 { 00277 DBUG_PRINT("info", 00278 ("affected_rows: %lu id: %lu status: %u warning_count: %u", 00279 (ulong) affected_rows, 00280 (ulong) id, 00281 (uint) (thd->server_status & 0xffff), 00282 (uint) thd->total_warn_count)); 00283 int2store(pos,thd->server_status); 00284 pos+=2; 00285 00286 /* We can only return up to 65535 warnings in two bytes */ 00287 uint tmp= min(thd->total_warn_count, 65535); 00288 int2store(pos, tmp); 00289 pos+= 2; 00290 } 00291 else if (net->return_status) // For 4.0 protocol 00292 { 00293 int2store(pos,thd->server_status); 00294 pos+=2; 00295 } 00296 if (message) 00297 pos=net_store_data((char*) pos, message, strlen(message)); 00298 VOID(my_net_write(net,buff,(uint) (pos-buff))); 00299 VOID(net_flush(net)); 00300 /* We can't anymore send an error to the client */ 00301 thd->net.report_error= 0; 00302 thd->net.no_send_error= 1; 00303 DBUG_PRINT("info", ("OK sent, so no more error sending allowed")); 00304 00305 DBUG_VOID_RETURN; 00306 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool send_old_password_request | ( | THD * | thd | ) |
Definition at line 390 of file protocol.cc.
References my_net_write(), and net_flush().
Referenced by check_user().
00391 { 00392 NET *net= &thd->net; 00393 return my_net_write(net, eof_buff, 1) || net_flush(net); 00394 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void send_warning | ( | THD * | thd, | |
| uint | sql_errno, | |||
| const char * | err = 0 | |||
| ) |
1.4.7

