The C API is distributed with MySQL. It is included in
the libmysqlclinet library. It allows C programs to access
a database.
Most of the other client APIs (all except Java) use this library to connect. So for example you can use the same environment variables.
The client has a maximum communication buffer size. This is automatically increased up to the maximum size (the default for this is 512Kb). As buffers are increased (but not decreased until close) on demand, it will not take any resources if one increases this. This size check is mostly a check for erroneous queries and communication packets.
The communication buffer must be big enough to contain a single SQL statement and one row of returned data (but of course not at the same time). Each thread's communication buffer is dynamically enlarged to handle any row or query up to the imposed limit.
So if you have BLOBs that contains data up to 16M you must have
at least 16M as your communication buffer limit. See section How does one change the size of MySQL buffers?.
MySQL shrinks each communication buffer to net_buffer_length
after each query.
| mysql_affected_rows | Retrieves the number of affected rows by the last UPDATE, DELETE or INSERT. |
| mysql_close | Closes a server connection. |
| mysql_connect | Establish a connection to a MySQL server. |
| mysql_create_db | Create a database. |
| mysql_data_seek | Seeks to an arbitrary row in a query result set. |
| mysql_drop_db | Drop a database. |
| mysql_eof | Determine if last row has been read. |
| mysql_escape_string | Escape a string for a SQL statement. See section Literals. How do you write strings and numbers? |
| mysql_error | The error message from last MySQL function. |
| mysql_fetch_field | Find out what type a table field is. |
| mysql_fetch_lengths | Returns the length of all columns in a query result set. |
| mysql_fetch_row | Fetch the 'next' row in the query result. |
| mysql_field_seek | Put the column cursor on column number field. |
| mysql_free_result | Free memory used to store a query result. |
| mysql_get_client_info | Return version information for the current client library. |
| mysql_get_host_info | Returns name of server host. |
| mysql_get_proto_info | Get protocol version used by connection. |
| mysql_get_server_info | Returns the version number of the server. |
| mysql_insert_id | Returns ID generated for a AUTO_INCREMENT field. |
| mysql_list_dbs | Return matching database names. |
| mysql_list_fields | Return matching field names. |
| mysql_list_processes | Get a list of the current server threads. |
| mysql_list_tables | Return matching table names. |
| mysql_num_fields | Return the number of columns in a result set. |
| mysql_num_rows | Returns the number of rows in result set. |
| mysql_query | Executes a SQL query. |
| mysql_real_query | Executes a SQL query with length information. |
| mysql_reload | Reload the user permissions table in the server. |
| mysql_select_db | Connect to a database. |
| mysql_shutdown | Shut down the database server. |
| mysql_stat | Return server status in a string. |
| mysql_store_result | Reads a result set to the client. |
| mysql_use_result |
Initiate a dynamic result set for each row. This uses much less memory than
mysql_store_result() but will put more strain on the server.
|
int mysql_affected_rows(MYSQL *mysql)
void mysql_close(MYSQL *mysql)
MYSQL *mysql_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd)
int mysql_create_db(MYSQL *mysql, const char *db)
void mysql_data_seek(MYSQL_RES *res, uint offset)
int mysql_drop_db(MYSQL *mysql, const char *db)
int mysql_eof(MYSQL_RES *)
char *mysql_error(MYSQL *mysql)
uint mysql_escape_string(char *to,char *from,uint length)
MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *handle)
BLOB without retreving a result,
MySQL returns the 'default blob length', which is 8192, when
doing a select on the table. When one retrevies a result,
column_object->max_length contains the real max_length for the specific
query.
The 8192 size is chosen because MySQL doesn't know the max length
for the BLOB. This should be made configurable sometime.
unsigned int *mysql_fetch_lengths(MYSQL_RES *mysql)
MYSQL_ROW mysql_fetch_row(MYSQL_RES *mysql)
void mysql_field_seek(MYSQL_RES *result, int field)
void mysql_free_result(MYSQL_RES *result)
char *mysql_get_client_info(void)
char *mysql_get_host_info(MYSQL *mysql)
int mysql_get_proto_info(MYSQL *mysql)
char *mysql_get_server_info(MYSQL *mysql)
unsigned long mysql_insert_id(MYSQL *mysql)
BIGINT columns. In this case
one has to use the LAST_INSERT_ID() SQL function.
MYSQL_RES *mysql_list_dbs(MYSQL *mysql, const char *wild)
MYSQL_RES *mysql_list_fields(MYSQL *mysql, const char *table, const char *wild)
MYSQL_RES *mysql_list_processes(MYSQL *mysql)
MYSQL_RES *mysql_list_tables(MYSQL *mysql, const char *wild)
int mysql_num_fields(MYSQL_RES *result)
int mysql_num_rows(MYSQL_RES *result)
int mysql_query(MYSQL *mysql, const char *query)
int mysql_real_query(MYSQL *mysql, const char *query, uint length)
int mysql_reload(MYSQL *mysql)
int mysql_select_db(MYSQL *mysql, const char *db)
int mysql_shutdown(MYSQL *mysql)
char *mysql_stat(MYSQL *mysql)
MYSQL_RES *mysql_store_result(MYSQL *mysql)
MYSQL_RES *mysql_use_result(MYSQL *mysql)
mysql_query() returns success, mysql_store_result() sometimes returns NULL.
mysql_use_result() and mysql_store_result() modes?
Go to the first, previous, next, last section, table of contents.