We
When using MySQL c api, the MySQL structure is used most. Undoubtedly, this structure is the core of MySQL C/C ++ programming.
The following is the definition of the structure:
Typedef struct st_mysql {
Netnet;/* network connection parameters */
Gptrconnector_fd;/* SSL connection handle */
Char * Host, * user, * passwd, * unix_socket, * server_version, * host_info, * info, * dB; // connection Parameter
Unsigned intport, client_flag, server_capabilities; // connection Parameter
Unsigned intprotocol_version;
Unsigned intfield_count; // Number of Columns
Unsigned int server_status ;//
Unsigned long thread_id;/* ID for connection in server */
My_ulonglong affected_rows;
My_ulonglong insert_id;/* ID if insert on table with nextnr */
My_ulonglong extra_info;/* used by mysqlshow */
Unsigned long packet_length;
Enum mysql_status status;
Mysql_field * fields; // The Field info
Mem_rootfield_alloc; // The field memory
My_boolfree_me;/* If free in mysql_close */
My_boolreconnect;/* set to 1 If Automatic reconnect */
Struct st_mysql_options options; // Option
Char scramble_buff [9]; // ???
Struct charset_info_st * charset; // charset info.
Unsigned int server_language; // server language/
} MySQL;
The following is the definition of net. This structure is used for network read/write:
Typedef struct st_net {
Vio * vio;
My_socket FD;/* For Perl DBI/DBD */
Int fcntl;
Unsigned char * buff, * buff_end, * write_pos, * read_pos;
Char last_error [mysql_errmsg_size];
Unsigned int last_errno, max_packet, timeout, pkt_nr;
Unsigned char error;
My_bool return_errno, compress;
My_bool no_send_ OK;/* needed if we are doing several
Queries in one command (as in load table... from Master ),
And do not want to confuse the client with OK at the wrong time
*/
Unsigned long remain_in_buf, length, buf_length, where_ B;
Unsigned int * return_status;
Unsigned char reading_or_writing;
Char save_char;
} Net;
During MySQL connection and query, the MySQL structure is used as a carrier for transmitting information.
Capi that frequently uses the MySQL structure:
Mysql_connect ();
Mysql_real_connect ();
Mysql_query ();
Mysql_store_result ();
Mysql_use_result ();
Mysql_error ()
If you are interested, you can take a look at the implementation of these functions, with unexpected gains!