![]()  | 
  
    MySQL 9.5.0
    
   Source Code Documentation 
   | 
 
Low level functions for storing data to be send to the MySQL client. More...
#include "sql/protocol_classic.h"#include <openssl/ssl.h>#include <string.h>#include <algorithm>#include <limits>#include "decimal.h"#include "lex_string.h"#include "m_string.h"#include "my_byteorder.h"#include "my_dbug.h"#include "my_inttypes.h"#include "my_sys.h"#include "my_time.h"#include "mysql/com_data.h"#include "mysql/my_loglevel.h"#include "mysql/psi/mysql_socket.h"#include "mysql/strings/dtoa.h"#include "mysql/strings/int2str.h"#include "mysql/strings/m_ctype.h"#include "mysqld_error.h"#include "mysys_err.h"#include "sql-common/my_decimal.h"#include "sql/field.h"#include "sql/item.h"#include "sql/item_func.h"#include "sql/mysqld.h"#include "sql/session_tracker.h"#include "sql/sql_class.h"#include "sql/sql_error.h"#include "sql/sql_lex.h"#include "sql/sql_list.h"#include "sql/sql_prepare.h"#include "sql/system_variables.h"#include "sql_string.h"#include "string_with_len.h"#include "strmake.h"#include "template_utils.h"Functions | |
| static bool | net_send_error_packet (THD *, uint, const char *, const char *) | 
| static bool | net_send_error_packet (NET *, uint, const char *, const char *, bool, ulong, const CHARSET_INFO *) | 
| static bool | write_eof_packet (THD *thd, NET *net, uint server_status, uint statement_warn_count) | 
| Format EOF packet according to the current protocol and write it to the network output buffer.  More... | |
| static ulong | get_ps_param_len (enum enum_field_types type, uchar *packet, ulong packet_left_len, ulong *header_len, bool *err) | 
| Returns the length of the encoded data.  More... | |
| static bool | ensure_packet_capacity (size_t length, String *packet) | 
| Ensures that the packet buffer has enough capacity to hold a string of the given length.  More... | |
| static bool | net_store_data (const uchar *from, size_t length, String *packet) | 
| Store length and data in a network packet buffer.  More... | |
| static bool | net_store_zero_padded_data (const char *data, size_t data_length, size_t padded_length, String *packet) | 
| Stores a string in the network buffer.  More... | |
| bool | net_send_error (THD *thd, uint sql_errno, const char *err) | 
| Send a error string to client.  More... | |
| bool | net_send_error (NET *net, uint sql_errno, const char *err) | 
| Send a error string to client using net struct.  More... | |
| static bool | net_send_ok (THD *thd, uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong id, const char *message, bool eof_identifier) | 
| Return OK to the client.  More... | |
| static bool | net_send_eof (THD *thd, uint server_status, uint statement_warn_count) | 
| Send eof (= end of result set) to the client.  More... | |
| static uchar * | net_store_length_fast (uchar *packet, size_t length) | 
| Faster net_store_length when we know that length is less than 65536.  More... | |
| uchar * | net_store_data (uchar *to, const uchar *from, size_t length) | 
| static bool | parse_query_bind_params (THD *thd, uint param_count, PS_PARAM **out_parameters, unsigned char *out_has_new_types, unsigned long *out_parameter_count, Prepared_statement *stmt_data, uchar **inout_read_pos, size_t *inout_packet_left, bool receive_named_params, bool receive_parameter_set_count) | 
| bool | store (Protocol *prot, I_List< i_string > *str_list) | 
| Send a set of strings as one long string with ',' in between.  More... | |
| static bool | store_integer (int64 value, bool unsigned_flag, uint32 zerofill, String *packet) | 
| Stores an integer in the protocol buffer for the text protocol.  More... | |
| static size_t | floating_point_to_text (double value, uint32 decimals, my_gcvt_arg_type gcvt_arg_type, char *buffer) | 
| Converts a floating-point value to text for the text protocol.  More... | |
| static bool | store_floating_point (double value, uint32 decimals, uint32 zerofill, my_gcvt_arg_type gcvt_arg_type, String *packet) | 
| Stores a floating-point value in the text protocol.  More... | |
| template<typename ToString > | |
| static bool | store_temporal (ToString to_string, String *packet) | 
| Stores a temporal value in the protocol buffer for the text protocol.  More... | |
| static ulong | get_param_length (uchar *packet, ulong packet_left_len, ulong *header_len) | 
| Read the length of the parameter data and return it back to the caller.  More... | |
Variables | |
| static const unsigned int | PACKET_BUFFER_EXTRA_ALLOC = 1024 | 
| static uchar | eof_buff [1] = {(uchar)254} | 
Low level functions for storing data to be send to the MySQL client.
The actual communication is handled by the net_xxx functions in net_serv.cc
      
  | 
  static | 
Ensures that the packet buffer has enough capacity to hold a string of the given length.
| length | the length of the string | |
| [in,out] | packet | the buffer | 
      
  | 
  static | 
Converts a floating-point value to text for the text protocol.
| value | the floating point value | 
| decimals | the precision of the value | 
| gcvt_arg_type | the type of the floating-point value | 
| buffer | a buffer large enough to hold FLOATING_POINT_BUFFER characters plus a terminating zero character | 
      
  | 
  static | 
Read the length of the parameter data and return it back to the caller.
| packet | a pointer to the data | 
| packet_left_len | remaining packet length | 
| header_len | size of the header stored at the beginning of the packet and used to specify the length of the data. | 
      
  | 
  static | 
Returns the length of the encoded data.
| [in] | type | parameter data type | 
| [in] | packet | network buffer | 
| [in] | packet_left_len | number of bytes left in packet | 
| [out] | header_len | the size of the header(bytes to be skipped) | 
| [out] | err | boolean to store if an error occurred | 
      
  | 
  static | 
Send eof (= end of result set) to the client.
See EOF_Packet packet for the structure of the packet.
note The warning count will not be sent if 'no_flush' is set as we don't want to report the warning count until all data is sent to the client.
| thd | Thread handler | 
| server_status | The server status | 
| statement_warn_count | Total number of warnings | 
| false | The message was successfully sent | 
| true | An error occurred and the message wasn't sent properly | 
| bool net_send_error | ( | NET * | net, | 
| uint | sql_errno, | ||
| const char * | err | ||
| ) | 
Send a error string to client using net struct.
This is used initial connection handling code.
| net | Low-level net struct | 
| sql_errno | The error code to send | 
| err | A pointer to the error message | 
| false | The message was sent to the client | 
| true | An error occurred and the message wasn't sent properly | 
| bool net_send_error | ( | THD * | thd, | 
| uint | sql_errno, | ||
| const char * | err | ||
| ) | 
Send a error string to client.
Design note:
net_printf_error and net_send_error are low-level functions that shall be used only when a new connection is being established or at server startup.
For SIGNAL/RESIGNAL and GET DIAGNOSTICS functionality it's critical that every error that can be intercepted is issued in one place only, my_message_sql.
| thd | Thread handler | 
| sql_errno | The error code to send | 
| err | A pointer to the error message | 
| false | The message was sent to the client | 
| true | An error occurred and the message wasn't sent properly | 
      
  | 
  static | 
| net | Low-level NET struct | 
| sql_errno | The error code to send | 
| err | A pointer to the error message | 
| sqlstate | SQL state | 
| bootstrap | Server is started in bootstrap mode | 
| client_capabilities | Client capabilities flag | 
| character_set_results | Char set info | 
| false | The message was successfully sent | 
| true | An error occurred and the messages wasn't sent properly | 
See also ERR_Packet
      
  | 
  static | 
| thd | Thread handler | 
| sql_errno | The error code to send | 
| err | A pointer to the error message | 
| sqlstate | SQL state | 
| false | The message was successfully sent | 
| true | An error occurred and the messages wasn't sent properly | 
See also ERR_Packet
      
  | 
  static | 
Return OK to the client.
See OK_Packet for the OK packet structure.
| thd | Thread handler | 
| server_status | The server status | 
| statement_warn_count | Total number of warnings | 
| affected_rows | Number of rows changed by statement | 
| id | Auto_increment id for first row (if used) | 
| message | Message to send to the client (Used by mysql_status) | 
| eof_identifier | when true [FE] will be set in OK header else [00] will be used | 
| false | The message was successfully sent | 
| true | An error occurred and the messages wasn't sent properly | 
Store length and data in a network packet buffer.
| from | the data to store | |
| length | the length of the data | |
| [in,out] | packet | the buffer | 
Faster net_store_length when we know that length is less than 65536.
We keep a separate version for that range because it's widely used in libmysql.
uint is used as argument type because of MySQL type conventions:
      
  | 
  static | 
Stores a string in the network buffer.
The string is padded with zeros if it is shorter than the specified padded length.
| data | the string to store | |
| data_length | the length of the string | |
| padded_length | the length of the zero-padded string | |
| [in,out] | packet | the network buffer | 
      
  | 
  static | 
Send a set of strings as one long string with ',' in between.
      
  | 
  static | 
Stores a floating-point value in the text protocol.
| value | the floating point value | 
| decimals | the precision of the value | 
| zerofill | the length up to which the value should be zero-padded, or 0 if no zero-padding should be used | 
| gcvt_arg_type | the type of the floating-point value | 
| packet | the destination buffer | 
      
  | 
  static | 
Stores an integer in the protocol buffer for the text protocol.
| value | the integer value to convert to a string | 
| unsigned_flag | true if the integer is unsigned | 
| zerofill | the length up to which the value should be zero-padded | 
| packet | the destination buffer | 
      
  | 
  static | 
Stores a temporal value in the protocol buffer for the text protocol.
| to_string | the function that converts the temporal value to a string | 
| packet | the destination buffer | 
      
  | 
  static | 
Format EOF packet according to the current protocol and write it to the network output buffer.
See also ERR_Packet
| thd | The thread handler | 
| net | The network handler | 
| server_status | The server status | 
| statement_warn_count | The number of warnings | 
| false | The message was sent successfully | 
| true | An error occurred and the messages wasn't sent properly | 
      
  | 
  static |