MySQL Connection Structure

Source: Internet
Author: User
Tags ssl connection

 

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!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.