libmysqlclient
libmysqlclient
libmysqlclient
libmysqlclient
libmysqlclient
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | |||
erlang-mysql-driver | libmysqlclient | erlang-mysql-driver | |
hsql-mysql | libmysqlclient | ||
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | |||
DBI
| libmysqlclient | ||
Net::MySQL | Net::MySQL | ||
mysql
| libmysqlclient | ||
mysqli
| libmysqlclient | ||
PDO_MYSQL | libmysqlclient | ||
libmysqlclient | |||
libmysqlclient | |||
libmysqlclient | libmysqlclient | ||
Myscsh | libmysqlclient | Myscsh | |
sql_mysql | libmysqlclient | sql_mysql | |
libmysqlclient |
libmysqlclient
libmysqlclient
Commands out of sync
libmysqlclient.a
libmysqlclient.so.18
BLOB
max_allowed_packet
net_buffer_length
libmysqlclient
libmysqlclient.a
libmysqlclient.dylib
mysqlclient.lib
libmysql.lib
lib/debug
_r
_r
_r
/usr/local
/usr/local/mysql-5.6.11-osx10.7-x86_64/ /usr/local/mysql-connector-c-6.1.0-osx10.7-x86/
/opt/mysql/mysql /opt/mysql/connector-c
/usr/bin
shared
shared
shared
client
-I
-I/usr/local/mysql/include
-lmysqlclient
/usr/local/mysql/lib
L /usr/local \ lmysqlclient MySQL / lib
-I
shell>mysql_config --cflags
shell>mysql_config --libs
shell>gcc -c `mysql_config --cflags` progname.c
shell>gcc -o progname progname.o `mysql_config --libs`
/usr/local/mysql/lib
内核> gcc -o progname progname.o /usr/local/mysql/lib/libmysqlclient.a
shell> gcc -o progname progname.o `mysql_config --variable=pkglibdir`/libmysqlclient.a
-lnsl -lsocket
mysql_config --cflags pkg-config --cflags mysqlclient mysql_config --libs pkg-config --libs mysqlclient
pkg-config --static --libs mysqlclient
mysqlclient.lib
libmysql.lib
/MT
/MT
/MD
/MT
/MT
/MT
/MTd
-lssl
mysql_
/甲氧苄啶/ ccfksdpa。阿`主要功能:/甲氧苄啶/ ccfksdpa。O(文本0xb):对` mysql_init /甲氧苄啶/ ccfksdpa未定义的引用。O(文本0x31):对` mysql_real_connect /甲氧苄啶/ ccfksdpa未定义的引用。O(文本0x69):对` mysql_error“/甲氧苄啶/ ccfksdpa未定义的引用。O(文本0x9a):对` mysql_close '未定义的引用
-L
dir_path
-lmysqlclientdir_path
内核> mysql_config --libs
shell> gcc -o progname progname.o `mysql_config --libs`
floor
connect()
mf_format.o(.text+0x201): undefined reference to `__lxstat'
mysqlclient.pc
mysql_config --cflags pkg-config --cflags mysqlclient mysql_config --libs pkg-config --libs mysqlclient
pkg-config --static --libs mysqlclient
--static
PKG_CONFIG_PATH
pkgconfig
export PKG_CONFIG_PATH=/usr/local/mysql/lib/pkgconfig # sh, bash, ...setenv PKG_CONFIG_PATH /usr/local/mysql/lib/pkgconfig # csh, tcsh, ...
mysqlconfig.pc
INSTALL_PKGCONFIGDIR
--variable
pkg-config --variable=prefix mysqlclient # installation prefix directorypkg-config --variable=includedir mysqlclient # header file directorypkg-config --variable=libdir mysqlclient # library directory
--variable
PKG - TKG - Print - Print - Print -变量Mysql客户端
gcc -c `pkg-config --cflags mysqlclient` progname.c gcc -o progname progname.o `pkg-config --libs mysqlclient`
sql/net_serv.cc
SIGPIPE
mysql_library_init()
mysql_init()
mysql_connect()
mysql_library_init()
libmysqlclient
mysql_query()
mysql_store_result()
mysql_query()
mysql_store_result()
mysql_store_result()
pthread_mutex_lock()
mysql_store_result()
mysql_use_result()
mysql_store_result()
mysql_init()
mysql_init()
mysql_library_init()
mysql_thread_init()
mysql_init()
mysql_thread_init()
mysql_thread_end()
mysql_init()
mysql_connect()
mysql_init()
Commands out of sync
libmysqlclient.a
libmysqlclient.so.18
libmysqlclient.so.18.1.0
mysql_
libmysqlclient.so
libmysqlclient.so
LD_LIBRARY
libmysqlclient.dylib
libmysqlclient.so
ldconfig
MYSQL_SERVER_VERSION
mysql_get_server_info()
mysql_get_server_version()
MYSQL_SERVER_VERSION
mysql_get_client_info()
mysql_get_client_version()
LIBMYSQL_VERSION
MYSQL_SERVER_VERSION
LIBMYSQL_VERSION
mysql_get_client_info()
mysql_get_client_version()
MYSQL_SERVER_VERSION
MYSQL
SELECT
SHOW
DESCRIBE
EXPLAIN
mysql_fetch_row()
MYSQL_FIELD
mysql_fetch_field()
mysql_field_seek()
mysql_affected_rows()
mysql_num_rows()
mysql_insert_id()
1.84e19
(my_ulonglong)-1
my_ulonglong
%lu
printf(“行数:%lu \n”(长整型)mysql_num_rows(结果));
my_bool
int
my_bool
mysql.h
MYSQL_FIELD
SELECT
OUT
CALL
char * name
AS
char * org_name
char * table
table
AS
UNION
char * org_table
org_table
org_table
UNION
char * db
db
UNION
char * catalog
"def"
char * def
mysql_list_fields()
unsigned long length
length
unsigned long max_length
mysql_store_result()
mysql_list_fields()
mysql_use_result()
max_length
FLOAT
-12.345
'-12.345'
max_length
max_length
mysql_stmt_attr_set()
mysql_stmt_store_result()
unsigned int name_length
name
unsigned int org_name_length
org_name
unsigned int table_length
table
unsigned int org_table_length
org_table
unsigned int db_length
db
unsigned int catalog_length
catalog
unsigned int def_length
def
unsigned int flags
flags
NOT_NULL_FLAG | NULL |
PRI_KEY_FLAG | |
UNIQUE_KEY_FLAG | |
MULTIPLE_KEY_FLAG | |
UNSIGNED_FLAG | UNSIGNED |
ZEROFILL_FLAG | ZEROFILL |
BINARY_FLAG | BINARY |
AUTO_INCREMENT_FLAG | AUTO_INCREMENT |
ENUM_FLAG | ENUM |
SET_FLAG | SET |
BLOB_FLAG | BLOB TEXT |
TIMESTAMP_FLAG | TIMESTAMP |
NUM_FLAG | |
NO_DEFAULT_VALUE_FLAG |
MYSQL_TYPE_
xxx
NUM_FLAG
MYSQL_TYPE_NEWDECIMAL
MYSQL_TYPE_SHORT
MYSQL_TYPE_FLOAT
MYSQL_TYPE_NULL
MYSQL_TYPE_INT24
NO_DEFAULT_VALUE_FLAG
NULL
AUTO_INCREMENT
flags
如果(场->国旗和not_null_flag)printf(“字段不能为空”);
flags
unsigned int decimals
unsigned int charsetnr
character_set_results
character_set_results
charsetnr
charsetnr
BINARY
CHAR
VARBINARY
VARCHAR
BLOB
TEXT
charsetnr
SHOW COLLATION
INFORMATION_SCHEMA
COLLATIONS
mysql>SHOW COLLATION WHERE Id = 63;
+-----------+---------+----+---------+----------+---------+ | Collation | Charset | Id | Default | Compiled | Sortlen | +-----------+---------+----+---------+----------+---------+ | binary | binary | 63 | Yes | Yes | 1 | +-----------+---------+----+---------+----------+---------+ mysql>SELECT COLLATION_NAME, CHARACTER_SET_NAME
->FROM INFORMATION_SCHEMA.COLLATIONS WHERE ID = 33;
+-----------------+--------------------+ | COLLATION_NAME | CHARACTER_SET_NAME | +-----------------+--------------------+ | utf8_general_ci | utf8 | +-----------------+--------------------+
enum enum_field_types type
type
MYSQL_TYPE_TINY | TINYINT |
MYSQL_TYPE_SHORT | SMALLINT |
MYSQL_TYPE_LONG | INTEGER |
MYSQL_TYPE_INT24 | MEDIUMINT |
MYSQL_TYPE_LONGLONG | BIGINT |
MYSQL_TYPE_DECIMAL | DECIMAL NUMERIC |
MYSQL_TYPE_NEWDECIMAL | DECIMAL NUMERIC |
MYSQL_TYPE_FLOAT | FLOAT |
MYSQL_TYPE_DOUBLE | DOUBLE REAL |
MYSQL_TYPE_BIT | BIT |
MYSQL_TYPE_TIMESTAMP | TIMESTAMP |
MYSQL_TYPE_DATE | DATE |
MYSQL_TYPE_TIME | TIME |
MYSQL_TYPE_DATETIME | DATETIME |
MYSQL_TYPE_YEAR | YEAR |
MYSQL_TYPE_STRING | CHAR BINARY |
MYSQL_TYPE_VAR_STRING | VARCHAR VARBINARY |
MYSQL_TYPE_BLOB | BLOB TEXT
|
MYSQL_TYPE_SET | SET |
MYSQL_TYPE_ENUM | ENUM |
MYSQL_TYPE_GEOMETRY | |
MYSQL_TYPE_NULL | NULL |
MYSQL_TYPE_TIME2
MYSQL_TYPE_TIMESTAMP2
MYSQL_TYPE_DATETIME
IS_NUM()
IS_NUM()
如果(is_num(场->型))printf(“字段是数值\n”);
ENUM
SET
MYSQL_TYPE_STRING
SET_FLAG
my_init()
mysql_affected_rows()
UPDATE
DELETE
INSERT
mysql_autocommit()
mysql_change_user()
mysql_character_set_name()
mysql_client_find_plugin()
mysql_close()
mysql_commit()
mysql_connect()
mysql_real_connect()
mysql_create_db()
CREATE DATABASE
mysql_data_seek()
mysql_debug()
mysql_drop_db()
DROP DATABASE
mysql_dump_debug_info()
mysql_eof()
mysql_errno()
mysql_error()
mysql_errno()
mysql_error()
mysql_escape_string()
mysql_fetch_field()
mysql_fetch_field_direct()
mysql_fetch_fields()
mysql_fetch_lengths()
mysql_fetch_row()
mysql_field_count()
mysql_field_seek()
mysql_field_tell()
mysql_fetch_field()
mysql_free_result()
mysql_get_character_set_info()
mysql_get_client_info()
mysql_get_client_version()
mysql_get_host_info()
mysql_get_proto_info()
mysql_get_server_info()
mysql_get_server_version()
mysql_get_ssl_cipher()
mysql_hex_string()
mysql_info()
mysql_init()
mysql_insert_id()
mysql_kill()
mysql_library_end()
mysql_library_init()
mysql_list_dbs()
mysql_list_fields()
mysql_list_processes()
mysql_list_tables()
mysql_load_plugin()
mysql_load_plugin_v()
mysql_more_results()
mysql_next_result()
mysql_num_fields()
mysql_num_rows()
mysql_ping()
mysql_plugin_options()
mysql_query()
mysql_real_connect()
mysql_real_escape_string()
mysql_real_escape_string_quote()
mysql_real_query()
mysql_refresh()
mysql_reload()
mysql_reset_connection()
mysql_reset_server_public_key()
mysql_result_metadata()
mysql_rollback()
mysql_row_seek()
mysql_row_tell()
mysql_row_tell()
mysql_select_db()
mysql_server_end()
mysql_server_init()
mysql_session_track_get_first()
mysql_session_track_get_next()
mysql_set_character_set()
mysql_set_local_infile_default()
LOAD DATA
LOCAL INFILE
mysql_set_local_infile_handler()
LOAD DATA LOCAL
INFILE
mysql_set_server_option()
mysql_sqlstate()
mysql_shutdown()
mysql_ssl_set()
mysql_stat()
mysql_store_result()
mysql_thread_end()
mysql_thread_id()
mysql_thread_init()
mysql_thread_safe()
mysql_use_result()
mysql_warning_count()
mysql_library_init()
mysql_init()
mysql_real_connect()
mysql_close()
mysql_library_end()
mysql_library_init()
mysql_library_end()
mysql_library_end()
mysql_library_init()
mysql_init()
mysql_library_init()
mysql_init()
mysql_library_init()
mysql_library_init()
mysql_library_init()
mysql_init()
mysql_init()
mysql_real_connect()
mysql_real_connect()
MYSQL
0
MYSQL_OPT_RECONNECT
mysql_options()
mysql_close()
mysql_query()
mysql_real_query()
mysql_query()
mysql_real_query()
mysql_real_query()
SELECT
INSERT
UPDATE
DELETE
mysql_affected_rows()
SELECT
SELECT
SHOW
DESCRIBE
EXPLAIN
SELECT
mysql_store_result()
mysql_use_result()
mysql_fetch_row()
mysql_store_result()
mysql_fetch_row()
mysql_use_result()
mysql_fetch_row()
mysql_fetch_lengths()
mysql_free_result()
mysql_store_result()
mysql_store_result()
mysql_data_seek()
mysql_row_seek()
mysql_num_rows()
mysql_store_result()
mysql_use_result()
mysql_use_result()
SELECT
mysql_store_result()
mysql_query()
mysql_real_query()
SELECT
mysql_field_count()
mysql_field_count()
INSERT
UPDATE
DELETE
mysql_field_count()
SELECT
mysql_field_count()
mysql_store_result()
mysql_use_result()
mysql_fetch_field()
mysql_fetch_field_direct()
mysql_field_seek()
mysql_fetch_field()
mysql_fetch_fields()
mysql_errno()
mysql_error()
NULL
NULL
NULL
if (result) /* correct */ ... error ... if (result < 0) /* incorrect */ ... error ... if (result == -1) /* incorrect */ ... error ...
mysql_errno()
mysql_error()
my_ulonglong mysql_affected_rows(MYSQL
*mysql)
mysql_affected_rows()
mysql_query()
mysql_real_query()
UPDATE
DELETE
INSERT
SELECT
mysql_affected_rows()
mysql_num_rows()
UPDATE
mysql_real_connect()
WHERE
REPLACE
INSERT
... ON DUPLICATE KEY UPDATE
CALL
mysql_affected_rows()
-1
ROW_COUNT()
mysql_affected_rows()
ROW_COUNT()
UPDATE
SELECT
mysql_affected_rows()
mysql_store_result()
mysql_affected_rows()
(my_ulonglong)~0
bool mysql_change_user(MYSQL *mysql, const char *user,
const char *password, const char *db)
db
mysql_change_user()
db
ROLLBACK
HANDLER
GET_LOCK()
mysql_reset_connection()
mysql_real_connect()
void mysql_close(MYSQL *mysql)
mysql_close()
mysql_init()
mysql_connect()
bool mysql_commit(MYSQL *mysql)
completion_type
completion_type
mysql_close()
MYSQL *mysql_connect(MYSQL *mysql, const char *host,
const char *user, const char *passwd)
mysql_real_connect()
mysql_connect()
mysql_connect()
mysql_get_client_info()
mysql_real_connect()
mysql_close()
mysql_errno()
mysql_error()
void mysql_data_seek(MYSQL_RES *result, my_ulonglong
offset)
offset
mysql_num_rows(result)-1
mysql_data_seek()
mysql_store_result()
mysql_use_result()
void mysql_debug(const char *debug)
DBUG_PUSH
mysql_debug()
int mysql_dump_debug_info(MYSQL *mysql)
SUPER
bool mysql_eof(MYSQL_RES *result)
mysql_errno()
mysql_error()
mysql_eof()
mysql_store_result()
mysql_fetch_row()
mysql_eof()
mysql_store_result()
mysql_eof()
mysql_use_result()
mysql_fetch_row()
mysql_fetch_row()
mysql_eof()
mysql_eof()
mysql_eof()
mysql_errno()
mysql_error()
mysql_eof()
mysql_eof()
mysql_eof()
mysql_query(&mysql,"SELECT * FROM some_table");result = mysql_use_result(&mysql);while((row = mysql_fetch_row(result))){ // do something with data}if(!mysql_eof(result)) // mysql_fetch_row() failed due to an error{ fprintf(stderr, "Error: %s\n", mysql_error(&mysql));}
mysql_query(&mysql,"SELECT * FROM some_table"); result = mysql_use_result(&mysql); while((row = mysql_fetch_row(result))) { // do something with data } if(mysql_errno(&mysql)) // mysql_fetch_row() failed due to an error { fprintf(stderr, "Error: %s\n", mysql_error(&mysql)); }
unsigned int mysql_errno(MYSQL *mysql)
mysql
mysql_errno()
mysqld_error.h
mysql_fetch_row()
mysql_errno()
mysql_errno()
mysql_errno()
mysql_sqlstate()
1146
mysql_errno()
mysql_sqlstate()
内核> SELECT * FROM no_such_table;
错误1146(42s02):表”测试。no_such_table”不存在
const char *mysql_error(MYSQL *mysql)
mysql
mysql_error()
mysql_error()
mysql_error()
mysql_error()
如果(* mysql_error(和MySQL)){ //发生错误}如果(mysql_error(和MySQL)[ 0 ]){ //发生错误}
mysql_escape_string()
mysql_real_escape_string_quote()
MYSQL_FIELD *mysql_fetch_field(MYSQL_RES
*result)
MYSQL_FIELD
mysql_fetch_field()
NULL
resultset_metadata
mysql_result_metadata()
mysql_fetch_field()
SELECT
mysql_fetch_field()
mysql_field_seek()
mysql_query()
SELECT
mysql_store_result()
mysql_fetch_field()
BLOB
BLOB
MYSQL_FIELD *mysql_fetch_field_direct(MYSQL_RES
*result, unsigned int fieldnr)
fieldnr
fieldnr
mysql_num_fields(result)-1
NULL
resultset_metadata
mysql_result_metadata()
MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES
*result)
MYSQL_FIELD
NULL
resultset_metadata
mysql_result_metadata()
unsigned long *mysql_fetch_lengths(MYSQL_RES
*result)
strlen()
strlen()
NULL
mysql_fetch_row()
mysql_fetch_lengths()
mysql_fetch_row()
MYSQL_ROW row; unsigned long *lengths; unsigned int num_fields; unsigned int i; row = mysql_fetch_row(result); if (row) { num_fields = mysql_num_fields(result); lengths = mysql_fetch_lengths(result); for(i = 0; i < num_fields; i++) { printf("Column %u is %lu bytes in length.\n", i, lengths[i]); } }
MYSQL_ROW mysql_fetch_row(MYSQL_RES *result)
mysql_store_result()
mysql_fetch_row()
mysql_use_result()
mysql_fetch_row()
mysql_num_fields(result)
mysql_fetch_row()
row[mysql_num_fields(result)-1]
NULL
mysql_fetch_lengths()
NULL
MYSQL_ROW row; unsigned int num_fields; unsigned int i; num_fields = mysql_num_fields(result); while ((row = mysql_fetch_row(result))) { unsigned long *lengths; lengths = mysql_fetch_lengths(result); for(i = 0; i < num_fields; i++) { printf("[%.*s] ", (int) lengths[i], row[i] ? row[i] : "NULL"); } printf("\n"); }
unsigned int mysql_field_count(MYSQL *mysql)
mysql_store_result()
mysql_field_count()
mysql_store_result()
SELECT
SELECT
MYSQL_RES *result; unsigned int num_fields; unsigned int num_rows; if (mysql_query(&mysql,query_string)) { // error } else // query succeeded, process any data returned by it { result = mysql_store_result(&mysql); if (result) // there are rows { num_fields = mysql_num_fields(result); // retrieve rows, then call mysql_free_result(result) } else // mysql_store_result() returned nothing; should it have? { if(mysql_field_count(&mysql) == 0) { // query does not return data // (it was not a SELECT) num_rows = mysql_affected_rows(&mysql); } else // mysql_store_result() should have returned data { fprintf(stderr, "Error: %s\n", mysql_error(&mysql)); } } }
mysql_field_count(&mysql)
mysql_errno(&mysql)
mysql_store_result()
mysql_field_count()
SELECT
MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES
*result)
mysql_fetch_field()
mysql_field_seek()
void mysql_free_result(MYSQL_RES *result)
mysql_store_result()
mysql_use_result()
mysql_list_dbs()
mysql_free_result()
void mysql_get_character_set_info(MYSQL *mysql,
MY_CHARSET_INFO *cs)
mysql_set_character_set()
MY_CHARSET_INFO
if (!mysql_set_character_set(&mysql, "utf8")){ MY_CHARSET_INFO cs; mysql_get_character_set_info(&mysql, &cs); printf("character set information:\n"); printf("character set+collation number: %d\n", cs.number); printf("character set name: %s\n", cs.name); printf("collation name: %s\n", cs.csname); printf("comment: %s\n", cs.comment); printf("directory: %s\n", cs.dir); printf("multi byte character min. length: %d\n", cs.mbminlen); printf("multi byte character max. length: %d\n", cs.mbmaxlen);}
unsigned long mysql_get_client_version(void)
XYYZZ
YY
major_version*10000 + release_level*100 + sub_version
"8.0.14"
int mysql_get_option(MYSQL *mysql, enum mysql_option
option, const void *arg)
mysql_options()
option
arg
option
arg | option |
---|---|
unsigned int | MYSQL_OPT_CONNECT_TIMEOUT
MYSQL_OPT_READ_TIMEOUT
MYSQL_OPT_SSL_FIPS_MODE
MYSQL_OPT_WRITE_TIMEOUT |
unsigned long | MYSQL_OPT_MAX_ALLOWED_PACKET
|
bool | MYSQL_ENABLE_CLEARTEXT_PLUGIN
MYSQL_OPT_GET_SERVER_PUBLIC_KEY
MYSQL_OPT_OPTIONAL_RESULTSET_METADATA
MYSQL_REPORT_DATA_TRUNCATION |
const char * | MYSQL_DEFAULT_AUTH
MYSQL_OPT_SSL_CA
MYSQL_OPT_SSL_CERT
MYSQL_OPT_SSL_CRL
MYSQL_OPT_SSL_KEY
MYSQL_PLUGIN_DIR
MYSQL_READ_DEFAULT_GROUP
MYSQL_SET_CHARSET_DIR
MYSQL_SHARED_MEMORY_BASE_NAME |
MYSQL_OPT_COMPRESS | |
MYSQL_INIT_COMMAND
MYSQL_OPT_CONNECT_ATTR_RESET
|
unsigned long mysql_get_server_version(MYSQL
*mysql)
XYYZZ
YY
major_version*10000 + release_level*100 + sub_version
"8.0.14"
const char *mysql_get_ssl_cipher(MYSQL
*mysql)
mysql_get_ssl_cipher()
mysql_init()
unsigned long mysql_hex_string(char *to, const char
*from, unsigned long length)
from
from
to
mysql_hex_string()
X'
value
'value
0x
char query[1000],*end; end = strmov(query,"INSERT INTO test_table values("); end = strmov(end,"X'"); end += mysql_hex_string(end,"What is this",12); end = strmov(end,"',X'"); end += mysql_hex_string(end,"binary data: \0\r\n",16); end = strmov(end,"')"); if (mysql_real_query(&mysql,query,(unsigned int) (end - query))) { fprintf(stderr, "Failed to insert row, Error: %s\n", mysql_error(&mysql)); }
strmov()
strcpy()
const char *mysql_info(MYSQL *mysql)
mysql_info()
Records: 100 Duplicates: 0
Warnings: 0
INSERT INTO ... VALUES
(...),(...),(...)...
Records: 3 Duplicates: 0 Warnings:
0
Records: 1 Deleted: 0 Skipped: 0
Warnings: 0
Records: 3 Duplicates: 0 Warnings:
0
Rows matched: 40 Changed: 40
Warnings: 0
mysql_info()
INSERT ...
VALUES
MYSQL *mysql_init(MYSQL *mysql)
MYSQL
mysql_real_connect()
NULL
mysql_init()
mysql_close()
mysql_init()
mysql_library_init()
mysql_library_init()
mysql_init()
mysql_init()
mysql_library_init()
mysql_library_init()
my_ulonglong mysql_insert_id(MYSQL *mysql)
AUTO_INCREMENT
INSERT
UPDATE
INSERT
INSERT
UPDATE
LAST_INSERT_ID(
expr
)
mysql_insert_id()
INSERT
NULL
INSERT
mysql_insert_id()
mysql_insert_id()
INSERT ...
SELECT
mysql_insert_id()
INSERT ...
SELECT
LAST_INSERT_ID(
expr
)mysql_insert_id()
expr
INSERT
LAST_INSERT_ID(
expr
)LAST_INSERT_ID(
expr
)
mysql_insert_id()
mysql_insert_id()
AUTO_INCREMENT
LAST_INSERT_ID(
expr
)expr
INSERT
AUTO_INCREMENT
INSERT
... ON DUPLICATE KEY UPDATE
AUTO_INCREMENT
mysql_insert_id()
AUTO_INCREMENT
mysql_insert_id()
mysql_insert_id()
LAST_INSERT_ID()
LAST_INSERT_ID()
mysql_insert_id()
LAST_INSERT_ID()
mysql_insert_id()
CALL
mysql_insert_id()
CALL
LAST_INSERT_ID()
LAST_INSERT_ID()
mysql_insert_id()
LAST_INSERT_ID()
mysql_insert_id()
mysql_insert_id()
COM_REFRESH
AUTO_INCREMENT
INSERT
int mysql_kill(MYSQL *mysql, unsigned long
pid)
mysql_kill()
mysql_query()
KILL
pid
mysql_query()
KILL
mysql_kill()
mysql_kill()
CR_INVALID_CONN_HANDLE
ER_DATA_OUT_OF_RANGE
mysql_kill()
mysql_kill()
pid
mysql_kill()
void mysql_library_end(void)
mysql_library_end()
int mysql_library_init(int argc, char **argv, char
**groups)
mysql_library_end()
mysql_library_init()
mysql_init()
mysql_library_init()
mysql_init()
mysql_library_init()
mysql_library_init()
mysql_library_init()
mysql_init()
argc
groups
mysql_library_init(0, NULL,
NULL)
#include <mysql.h>#include <stdlib.h>int main(void) { if (mysql_library_init(0, NULL, NULL)) { fprintf(stderr, "could not initialize MySQL client library\n"); exit(1); } /* Use any MySQL API functions here */ mysql_library_end(); return EXIT_SUCCESS;}
MYSQL_RES *mysql_list_dbs(MYSQL *mysql, const char
*wild)
wild
%
NULL
mysql_list_dbs()
wild
mysql_free_result()
MYSQL_RES *mysql_list_fields(MYSQL *mysql, const char
*table, const char *wild)
mysql_list_fields()
mysql_query()
SHOW COLUMNS
wild
%
NULL
mysql_list_fields()
tbl_name
wild
SHOW COLUMNS FROM
tbl_name
mysql_list_fields()
mysql_free_result()
int i; MYSQL_RES *tbl_cols = mysql_list_fields(mysql, "mytbl", "f%"); unsigned int field_cnt = mysql_num_fields(tbl_cols); printf("Number of columns: %d\n", field_cnt); for (i=0; i < field_cnt; ++i) { /* col describes i-th column of the table */ MYSQL_FIELD *col = mysql_fetch_field_direct(tbl_cols, i); printf ("Column %d: %s\n", i, col->name); } mysql_free_result(tbl_cols);
MYSQL_RES *mysql_list_processes(MYSQL *mysql)
mysql_list_processes()
mysql_query()
SHOW PROCESSLIST
SHOW PROCESSLIST
mysql_free_result()
MYSQL_RES *mysql_list_tables(MYSQL *mysql, const char
*wild)
wild
%
NULL
mysql_list_tables()
wild
mysql_free_result()
bool mysql_more_results(MYSQL *mysql)
CALL
mysql_more_results()
mysql_next_result()
TRUE
mysql_next_result()
int mysql_next_result(MYSQL *mysql)
CALL
mysql_next_result()
mysql_next_result()
mysql_next_result()
mysql_free_result()
mysql_next_result()
mysql_real_query()
mysql_query()
mysql_store_result()
mysql_warning_count()
mysql_affected_rows()
CALL
CALL
CALL
mysql_next_result()
CLIENT_MULTI_RESULTS
mysql_real_connect()
CLIENT_MULTI_STATEMENTS
CLIENT_MULTI_RESULTS
mysql_more_results()
mysql_next_result()
mysql_next_result()
mysql_use_result()
unsigned int mysql_num_fields(MYSQL_RES
*result)
MYSQL*
mysql_store_result()
mysql_use_result()
mysql_field_count()
mysql_store_result()
SELECT
SELECT
MYSQL_RES *result; unsigned int num_fields; unsigned int num_rows; if (mysql_query(&mysql,query_string)) { // error } else // query succeeded, process any data returned by it { result = mysql_store_result(&mysql); if (result) // there are rows { num_fields = mysql_num_fields(result); // retrieve rows, then call mysql_free_result(result) } else // mysql_store_result() returned nothing; should it have? { if (mysql_errno(&mysql)) { fprintf(stderr, "Error: %s\n", mysql_error(&mysql)); } else if (mysql_field_count(&mysql) == 0) { // query does not return data // (it was not a SELECT) num_rows = mysql_affected_rows(&mysql); } } }
mysql_errno(&mysql)
mysql_field_count(&mysql)
my_ulonglong mysql_num_rows(MYSQL_RES
*result)
mysql_num_rows()
mysql_store_result()
mysql_use_result()
mysql_store_result()
mysql_num_rows()
mysql_use_result()
mysql_num_rows()
mysql_num_rows()
SELECT
INSERT
UPDATE
DELETE
mysql_affected_rows()
int mysql_options(MYSQL *mysql, enum mysql_option
option, const void *arg)
mysql_get_option()
mysql_options()
mysql_init()
mysql_connect()
mysql_real_connect()
option
arg
arg
MYSQL_DEFAULT_AUTH
MYSQL_ENABLE_CLEARTEXT_PLUGIN
mysql_clear_password
MYSQL_INIT_COMMAND
MYSQL_OPT_BIND
MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS
MYSQL_OPT_COMPRESS
MYSQL_OPT_CONNECT_ATTR_DELETE
MYSQL_OPT_CONNECT_ATTR_RESET
mysql_options4()
session_connect_attrs
session_account_connect_attrs
MYSQL_OPT_CONNECT_ATTR_RESET
MYSQL_OPT_CONNECT_ATTR_DELETE
mysql_options4()
session_connect_attrs
session_account_connect_attrs
MYSQL_OPT_CONNECT_TIMEOUT
MYSQL_OPT_GET_SERVER_PUBLIC_KEY
caching_sha2_password
MYSQL_SERVER_PUBLIC_KEY
caching_sha2_password
MYSQL_OPT_LOCAL_INFILE
LOCAL
LOAD DATA
mysql_options()
LOCAL
LOCAL
LOCAL
MYSQL_OPT_MAX_ALLOWED_PACKET
max_allowed_packet
NULL
NULL
MYSQL_OPT_NAMED_PIPE
MYSQL_OPT_NET_BUFFER_LENGTH
net_buffer_length
NULL
NULL
MYSQL_OPT_OPTIONAL_RESULTSET_METADATA
CLIENT_OPTIONAL_RESULTSET_METADATA
mysql_real_connect()
MYSQL_OPT_PROTOCOL
mysql_protocol_type
MYSQL_OPT_READ_TIMEOUT
Close_Wait_Timeout
MYSQL_OPT_RECONNECT
MYSQL_OPT_RETRY_COUNT
MYSQL_OPT_SSL_CA
MYSQL_OPT_SSL_CAPATH
MYSQL_OPT_SSL_CERT
MYSQL_OPT_SSL_CIPHER
MYSQL_OPT_SSL_CRL
MYSQL_OPT_SSL_CRLPATH
MYSQL_OPT_SSL_FIPS_MODE
MYSQL_OPT_SSL_FIPS_MODE
xxx
SSL_FIPS_MODE_OFF
SSL_FIPS_MODE_STRICT
MYSQL_OPT_SSL_FIPS_MODE
MYSQL_OPT_SSL_FIPS_MODE
SSL_FIPS_MODE_STRICT
MYSQL_OPT_SSL_KEY
MYSQL_OPT_SSL_MODE
SSL_MODE_DISABLED
SSL_MODE_REQUIRED
SSL_MODE_VERIFY_IDENTITY
mysql_ssl_mode
--ssl-mode
MYSQL_OPT_TLS_VERSION
MYSQL_OPT_USE_RESULT
MYSQL_OPT_WRITE_TIMEOUT
MYSQL_PLUGIN_DIR
MYSQL_READ_DEFAULT_FILE
my.cnf
MYSQL_READ_DEFAULT_GROUP
my.cnf
MYSQL_REPORT_DATA_TRUNCATION
error
MYSQL_SERVER_PUBLIC_KEY
sha256_password
MYSQL_SERVER_PUBLIC_KEY
sha256_password
MYSQL_SET_CHARSET_DIR
MYSQL_SET_CHARSET_NAME
MYSQL_AUTODETECT_CHARSET_NAME
MYSQL_SHARED_MEMORY_BASE_NAME
--shared-memory-base-name
client
MYSQL_READ_DEFAULT_GROUP
character-sets-dir= | |
compress | |
connect-timeout= | |
database= | |
debug | |
default-character-set= | |
disable-local-infile | LOAD DATA
LOCAL INFILE |
enable-cleartext-plugin | mysql_clear_password |
host= | |
init-command= | |
interactive-timeout= | CLIENT_INTERACTIVE mysql_real_connect() |
local-infile[={0|1}] | LOAD DATA
LOCAL |
max_allowed_packet= | |
multi-queries
| |
multi-statements | ; |
password= | |
pipe | |
port= | |
protocol={TCP|SOCKET|PIPE|MEMORY} | |
return-found-rows | mysql_info() UPDATE |
shared-memory-base-name= | |
socket={ | |
ssl-ca= | |
ssl-capath= | |
ssl-cert= | |
ssl-cipher= | |
ssl-key= | |
timeout= | connect-timeout |
user |
timeout
timeout
mysql_options()
MYSQL mysql; mysql_init(&mysql); mysql_options(&mysql,MYSQL_OPT_COMPRESS,0); mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"odbc"); mysql_options(&mysql,MYSQL_INIT_COMMAND,"SET autocommit=0"); if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0)) { fprintf(stderr, "Failed to connect to database: Error: %s\n", mysql_error(&mysql)); }
int mysql_options4(MYSQL *mysql, enum mysql_option
option, const void *arg1, const void *arg2)
mysql_options4()
mysql_options()
arg1
MYSQL_OPT_CONNECT_ATTR_ADD
_
mysql_options4()
CR_INVALID_PARAMETER_NO
session_connect_attrs
session_account_connect_attrs
MYSQL_OPT_CONNECT_ATTR_RESET
mysql_options()
MYSQL mysql; mysql_init(&mysql); mysql_options(&mysql,MYSQL_OPT_CONNECT_ATTR_RESET, 0); mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, "key1", "value1"); mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, "key2", "value2"); mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, "key3", "value3"); mysql_options(&mysql,MYSQL_OPT_CONNECT_ATTR_DELETE, "key1"); if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0)) { fprintf(stderr, "Failed to connect to database: Error: %s\n", mysql_error(&mysql)); }
int mysql_ping(MYSQL *mysql)
mysql_ping()
mysql_options()
mysql_ping()
mysql_ping()
mysql_thread_id()
mysql_ping()
mysql_thread_id()
int mysql_query(MYSQL *mysql, const char
*stmt_str)
stmt_str
\g
mysql_query()
mysql_real_query()
mysql_query()
mysql_field_count()
MYSQL *mysql_real_connect(MYSQL *mysql, const char
*host, const char *user, const char *passwd, const char *db,
unsigned int port, const char *unix_socket, unsigned long
client_flag)
mysql_real_connect()
mysql_real_connect()
MYSQL
mysql_real_connect()
mysql_init()
mysql_options()
host
NULL
MYSQL_OPT_PROTOCOL
mysql_options()
"."
user
NULL
passwd
passwd
user
mysql_real_connect()
user
MYSQL
mysql_options(mysql,
MYSQL_SET_CHARSET_NAME,
"
charset_name
")
db
NULL
port
unix_socket
host
client_flag
CAN_HANDLE_EXPIRED_PASSWORDS
CLIENT_COMPRESS
CLIENT_FOUND_ROWS
CLIENT_IGNORE_SIGPIPE
CLIENT_IGNORE_SPACE
CLIENT_INTERACTIVE
interactive_timeout
wait_timeout
wait_timeout
interactive_timeout
CLIENT_LOCAL_FILES
LOAD DATA
LOCAL
CLIENT_MULTI_RESULTS
CLIENT_MULTI_STATEMENTS
CLIENT_NO_SCHEMA
db_name.tbl_name.col_name
CLIENT_ODBC
CLIENT_OPTIONAL_RESULTSET_METADATA
CLIENT_SSL
mysql_options()
mysql_ssl_set()
mysql_real_connect()
CLIENT_REMEMBER_OPTIONS
mysql_options()
mysql_real_connect()
mysql_options()
mysql_options()
CALL
CALL
CALL
mysql_next_result()
CLIENT_MULTI_RESULTS
mysql_real_connect()
CLIENT_MULTI_STATEMENTS
CLIENT_MULTI_RESULTS
CLIENT_MULTI_STATEMENTS
mysql_query()
mysql_real_query()
mysql_next_result()
mysql_real_connect()
mysql_options()
MYSQL_READ_DEFAULT_GROUP
mysql_real_connect()
mysql_real_connect()
host
""
user
passwd
mysql_real_connect()
db
port
unix_socket
connect_timeout
connect_timeout
MYSQL
MYSQL mysql; mysql_init(&mysql); mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"your_prog_name"); if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0)) { fprintf(stderr, "Failed to connect to database: Error: %s\n", mysql_error(&mysql)); }
mysql_options()
[your_prog_name]
mysql_real_connect()
MYSQL
0
MYSQL_OPT_RECONNECT
mysql_options()
unsigned long mysql_real_escape_string(MYSQL *mysql,
char *to, const char *from, unsigned long length)
mysql_real_escape_string()
CR_INSECURE_API_ERR
NO_BACKSLASH_ESCAPES
mysql_real_escape_string_quote()
mysql
from
\
"
\n
mysql_real_escape_string()
QUOTE()
from
to
mysql_real_escape_string()
mysql_set_character_set()
SET
NAMES
SET CHARACTER
SET
mysql_set_character_set()
SET NAMES
mysql_real_escape_string()
SET NAMES
INSERT
char query[1000],*end;end = my_stpcpy(query,"INSERT INTO test_table VALUES('");end += mysql_real_escape_string(&mysql,end,"What is this",12);end = my_stpcpy(end,"','");end += mysql_real_escape_string(&mysql,end,"binary data: \0\r\n",16);end = my_stpcpy(end,"')");if (mysql_real_query(&mysql,query,(unsigned int) (end - query))){ fprintf(stderr, "Failed to insert row, Error: %s\n", mysql_error(&mysql));}
my_stpcpy()
strcpy()
to
mysql_real_escape_string()
(unsigned long)~0
NO_BACKSLASH_ESCAPES
mysql_real_escape_string()
mysql_real_escape_string_quote()
unsigned long mysql_real_escape_string_quote(MYSQL
*mysql, char *to, const char *from, unsigned long length, char
quote)
mysql
from
\
"
\n
`
mysql_real_escape_string_quote()
QUOTE()
ANSI_QUOTES
mysql_real_escape_string_quote()
from
to
mysql_real_escape_string_quote()
quote
str
1) SELECT * FROM table WHERE name = 'str
'2) SELECT * FROM table WHERE name = "str
3)选择*从` str
` WHERE id = 103
mysql_real_escape_string_quote()
1) len = mysql_real_escape_string_quote(&mysql,to,from,from_len,'\'');2) len = mysql_real_escape_string_quote(&mysql,to,from,from_len,'"');3) len = mysql_real_escape_string_quote(&mysql,to,from,from_len,'`');
mysql_set_character_set()
SET
NAMES
SET CHARACTER
SET
mysql_set_character_set()
SET NAMES
mysql_real_escape_string_quote()
SET NAMES
INSERT
char query[1000],*end;end = my_stpcpy(query,"INSERT INTO test_table VALUES('");end += mysql_real_escape_string_quote(&mysql,end,"What is this",12,'\'');end = my_stpcpy(end,"','");end += mysql_real_escape_string_quote(&mysql,end,"binary data: \0\r\n",16,'\'');end = my_stpcpy(end,"')");if (mysql_real_query(&mysql,query,(unsigned int) (end - query))){ fprintf(stderr, "Failed to insert row, Error: %s\n", mysql_error(&mysql));}
my_stpcpy()
strcpy()
int mysql_real_query(MYSQL *mysql, const char
*stmt_str, unsigned long length)
stmt_str
;
mysql_query()
mysql_real_query()
mysql_query()
mysql_real_query()
mysql_query()
mysql_field_count()
int mysql_refresh(MYSQL *mysql, unsigned int
options)
mysql_refresh()
mysql_query()
FLUSH
RELOAD
options
REFRESH_GRANT
FLUSH
PRIVILEGES
REFRESH_LOG
FLUSH
LOGS
REFRESH_TABLES
FLUSH
TABLES
REFRESH_HOSTS
FLUSH
HOSTS
REFRESH_STATUS
FLUSH
STATUS
REFRESH_THREADS
REFRESH_SLAVE
RESET SLAVE
REFRESH_MASTER
RESET
MASTER
int mysql_reset_connection(MYSQL *mysql)
mysql_reset_connection()
mysql_change_user()
TEMPORARY
SET NAMES
HANDLER
LAST_INSERT_ID()
GET_LOCK()
void mysql_reset_server_public_key(void)
mysql_options()
mysql_reset_server_public_key()
mysql_reset_server_public_key()
mysql_options()
MYSQL_SERVER_PUBLIC_KEY
MYSQL_SERVER_PUBLIC_KEY
enum enum_resultset_metadata
mysql_result_metadata(MYSQL_RES *result)
mysql_result_metadata()
resultset_metadata
mysql_result_metadata()
mysql_result_metadata()
enum enum_resultset_metadata { RESULTSET_METADATA_NONE= 0, RESULTSET_METADATA_FULL= 1};
bool mysql_rollback(MYSQL *mysql)
completion_type
completion_type
mysql_close()
MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES *result,
MYSQL_ROW_OFFSET offset)
offset
mysql_row_tell()
mysql_row_seek()
mysql_data_seek()
mysql_row_seek()
mysql_store_result()
mysql_use_result()
mysql_row_seek()
MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES
*result)
mysql_fetch_row()
mysql_row_seek()
mysql_row_tell()
mysql_store_result()
mysql_use_result()
int mysql_select_db(MYSQL *mysql, const char
*db)
db
mysql_select_db()
void mysql_server_end(void)
mysql_server_end()
mysql_library_end()
mysql_server_end()
mysql_library_end()
int mysql_server_init(int argc, char **argv, char
**groups)
mysql_server_init()
mysql_library_init()
mysql_server_end()
mysql_library_end()
int mysql_session_track_get_first(MYSQL *mysql, enum
enum_session_state_type type, const char **data, size_t
*length)
mysql_session_track_get_first()
mysql_session_track_get_next()
mysql_session_track_get_first()
mysql_session_track_get_next()
session_track_
xxx
session_track_state_change
session_track_schema
session_track_system_variables
mysql_session_track_get_next()
mysql
type
mysql_com.h
枚举enum_session_state_type { session_track_system_variables,/ * * / session_track_schema会话系统变量,/ *电流模式* / session_track_state_change,/ * * / session_track_gtids会话状态的变化,gtids / * * / / * session_track_transaction_characteristics,交易特征* / session_track_transaction_state /* */ }交易状态;
SESSION_TRACK_BEGIN
enum_session_state_type
data
length
data
data
type
SESSION_TRACK_SCHEMA
length
session_track_schema
SESSION_TRACK_SYSTEM_VARIABLES
length
length
time_zone
autocommit
character_set_client
character_set_results
character_set_connection
session_track_schema
SESSION_TRACK_STATE_CHANGE
length
0x01
session_track_state_change
SESSION_TRACK_GTIDS
length
session_track_gtids
SESSION_TRACK_TRANSACTION_CHARACTERISTICS
length
SET TRANSACTION
START
TRANSACTION
READ
WRITE
START
TRANSACTION
SET
TRANSACTION
SET TRANSACTION
session_track_transaction_info
SESSION_TRACK_TRANSACTION_STATE
SESSION_TRACK_TRANSACTION_STATE
length
T
I
autocommit=0
_
r
_
R
_
w
_
W
_
s
UUID()
_
S
_
LOCK
TABLES
L
LOCK TABLES
_
LOCK
TABLES
SET @@session.session_track_transaction_info='STATE'; START TRANSACTION; SELECT 1; INSERT INTO t1 () VALUES(); INSERT INTO t1 () VALUES(1, UUID_SHORT()); COMMIT;
data
_ _ _ _ _ _ _ _ T _ _ _ _ _ _ _ T _ _ _ _ _ _ T S W S _ _ _ _ _ T _ _ _ WSS _ _ _ _ _ _ _ _ _
session_track_transaction_info
mysql_session_track_get_first()
mysql_session_track_get_next()
printf("Execute: %s\n", stmt_str); if (mysql_query(mysql, stmt_str) != 0) { fprintf(stderr, "Error %u: %s\n", mysql_errno(mysql), mysql_error(mysql)); return; } MYSQL_RES *result = mysql_store_result(mysql); if (result) /* there is a result set to fetch */ { /* ... process rows here ... */ printf("Number of rows returned: %lu\n", (unsigned long) mysql_num_rows(result)); mysql_free_result(result); } else /* there is no result set */ { if (mysql_field_count(mysql) == 0) { printf("Number of rows affected: %lu\n", (unsigned long) mysql_affected_rows(mysql)); } else /* an error occurred */ { fprintf(stderr, "Error %u: %s\n", mysql_errno(mysql), mysql_error(mysql)); } } /* extract any available session state-change information */ enum enum_session_state_type type; for (type = SESSION_TRACK_BEGIN; type <= SESSION_TRACK_END; type++) { const char *data; size_t length; if (mysql_session_track_get_first(mysql, type, &data, &length) == 0) { /* print info type and initial data */ printf("Type=%d:\n", type); printf("mysql_session_track_get_first(): length=%d; data=%*.*s\n", (int) length, (int) length, (int) length, data); /* check for more data */ while (mysql_session_track_get_next(mysql, type, &data, &length) == 0) { printf("mysql_session_track_get_next(): length=%d; data=%*.*s\n", (int) length, (int) length, (int) length, data); } } }
int mysql_session_track_get_next(MYSQL *mysql, enum
enum_session_state_type type, const char **data, size_t
*length)
mysql_session_track_get_first()
mysql_session_track_get_next()
mysql_session_track_get_first()
mysql_session_track_get_first()
mysql_session_track_get_next()
mysql_session_track_get_next()
mysql_session_track_get_first()
int mysql_set_character_set(MYSQL *mysql, const char
*csname)
csname
SET
NAMES
mysql_real_escape_string()
MYSQL mysql; mysql_init(&mysql); if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0)) { fprintf(stderr, "Failed to connect to database: Error: %s\n", mysql_error(&mysql)); } if (!mysql_set_character_set(&mysql, "utf8")) { printf("New client character set: %s\n", mysql_character_set_name(&mysql)); }
void mysql_set_local_infile_default(MYSQL
*mysql);
LOAD DATA
LOCAL INFILE
mysql_set_local_infile_handler()
void mysql_set_local_infile_handler(MYSQL *mysql, int
(*local_infile_init)(void **, const char *, void *), int
(*local_infile_read)(void *, char *, unsigned int), void
(*local_infile_end)(void *), int (*local_infile_error)(void *,
char*, unsigned int), void *userdata);
LOAD
DATA LOCAL INFILE
mysql_set_local_infile_handler()
从intlocal _ _ init(void *指针,const char* filename,无效*用户数据);
void**
void*
mysql_set_local_infile_handler()
int local_infile_read(void *ptr, char *buf, unsigned int buf_len);
buf
void local_infile_end(void *ptr)
local_infile_read()
int local_infile_error(void *ptr, char *error_msg, unsigned int error_msg_len);
error_msg
error_msg_len
ptr
error_msg
mysql_set_local_infile_handler()
LOAD DATA LOCAL
INFILE
mysql_query()
LOAD
DATA LOCAL INFILE
int mysql_set_server_option(MYSQL *mysql, enum
enum_mysql_set_option option)
option
MYSQL_OPTION_MULTI_STATEMENTS_ON | |
MYSQL_OPTION_MULTI_STATEMENTS_OFF |
mysql_query()
mysql_real_query()
mysql_next_result()
MYSQL_OPTION_MULTI_STATEMENTS_ON
mysql_real_connect()
CLIENT_MULTI_RESULTS
CALL
CALL
mysql_set_server_option()
int mysql_shutdown(MYSQL *mysql, enum
mysql_enum_shutdown_level shutdown_level)
mysql_shutdown()
mysql_query()
SHUTDOWN
SHUTDOWN
SHUTDOWN_DEFAULT
mysql_shutdown()
mysql_shutdown()
SHUTDOWN
const char *mysql_sqlstate(MYSQL *mysql)
'00000'
mysql_sqlstate()
mysql_errno()
1146
mysql_errno()
mysql_sqlstate()
内核> SELECT * FROM no_such_table;
错误1146(42s02):表”测试。no_such_table”不存在
'HY000'
mysql_sqlstate()
mysql_real_connect()
mysql_sqlstate()
bool mysql_ssl_set(MYSQL *mysql, const char *key, const
char *cert, const char *ca, const char *capath, const char
*cipher)
mysql_ssl_set()
NULL
mysql_ssl_set()
mysql_real_connect()
mysql_ssl_set()
mysql_ssl_set()
mysql_ssl_set()
mysql_ssl_set()
mysql_ssl_set()
mysql_options()
MySQL(MySQL,MySQL _ _选项选择_ _ SSL密钥,密钥);MySQL(MySQL,MySQL _ _选项选择_ SSL _证书,证书);MySQL(MySQL,MySQL _ _选项选择_ _ SSL CA,CA);MySQL(MySQL,MySQL _ _选项选择_ SSL _ capath capath);_,MySQL(MySQL,MySQL选项选择_ _ _ SSL密码,密码);
mysql_ssl_set()
mysql_options()
mysql_options()
mysql_ssl_set()
MYSQL_OPT_TLS_VERSION
mysql
mysql_init()
key
cert
ca
capath
cipher
0
mysql_real_connect()
const char *mysql_stat(MYSQL *mysql)
MYSQL_RES *mysql_store_result(MYSQL *mysql)
mysql_query()
mysql_real_query()
mysql_store_result()
mysql_use_result()
SELECT
SHOW
DESCRIBE
EXPLAIN
CHECK TABLE
mysql_free_result()
mysql_store_result()
mysql_use_result()
mysql_store_result()
mysql_store_result()
mysql_query()
mysql_real_query()
mysql_next_result()
mysql_field_count()
mysql_store_result()
mysql_store_result()
INSERT
mysql_store_result()
mysql_error()
mysql_errno()
mysql_field_count()
mysql_store_result()
mysql_num_rows()
mysql_fetch_row()
mysql_row_seek()
mysql_row_tell()
mysql_store_result()
mysql_error()
mysql_errno()
unsigned long mysql_thread_id(MYSQL *mysql)
mysql_kill()
mysql_ping()
mysql_thread_id()
MYSQL_RES *mysql_use_result(MYSQL *mysql)
mysql_query()
mysql_real_query()
mysql_store_result()
mysql_use_result()
SELECT
SHOW
DESCRIBE
EXPLAIN
CHECK TABLE
mysql_free_result()
mysql_use_result()
mysql_store_result()
mysql_fetch_row()
mysql_store_result()
max_allowed_packet
mysql_use_result()
mysql_use_result()
mysql_fetch_row()
Commands out of
sync; you can't run this command now
mysql_data_seek()
mysql_row_seek()
mysql_row_tell()
mysql_num_rows()
mysql_affected_rows()
mysql_use_result()
mysql_use_result()
mysql_num_rows()
mysql_free_result()
mysql_use_result()
mysql_error()
mysql_errno()
MYSQL_STMT
mysql_stmt_init()
MYSQL
mysql_stmt_init()
MYSQL_STMT
mysql_stmt_prepare()
MYSQL_BIND
mysql_stmt_bind_param()
mysql_stmt_bind_result()
MYSQL_TIME
mysql_stmt_init()
mysql_stmt_close()
MYSQL_STMT
MYSQL_BIND
mysql_stmt_bind_param()
mysql_stmt_execute()
MYSQL_BIND
mysql_stmt_bind_result()
mysql_stmt_fetch()
MYSQL_BIND
MYSQL_BIND bind[3]; memset(bind, 0, sizeof(bind));
MYSQL_BIND
enum enum_field_types buffer_type
buffer_type
void *buffer
buffer
mysql_stmt_execute()
buffer
mysql_stmt_fetch()
buffer
unsigned
buffer
buffer
unsigned long buffer_length
*buffer
*buffer
mysql_stmt_bind_param()
mysql_stmt_bind_result()
unsigned long *length
unsigned long
length
*length
mysql_stmt_execute()
*length
mysql_stmt_fetch()
mysql_stmt_fetch()
*length
MYSQL_DATA_TRUNCATED
*length
length
bool *is_null
bool
NULL
NULL
is_null
NULL
NULL
buffer_type
is_null
NOT
NULL
is_null = (bool*) 0
is_null
NULL
is_null
bool is_unsigned
unsigned
short int
long long int
buffer
signed char
MYSQL_TYPE_TINY
unsigned char
char
unsigned char
is_unsigned
BIGINT UNSIGNED
int
BIGINT
unsigned int
bool *error
bool
mysql_stmt_fetch()
*error
mysql_options()
DATE
TIME
DATETIME
TIMESTAMP
MYSQL_TIME
MYSQL_BIND
MYSQL_TYPE_DATE
MYSQL_TYPE_TIMESTAMP
MYSQL_TIME
unsigned int year | |
unsigned int month | |
unsigned int day | |
unsigned int hour | |
unsigned int minute | |
unsigned int second | |
bool neg | |
unsigned long second_part |
MYSQL_TIME
month
DATE
DATETIME
TIMESTAMP
minute
TIME
DATETIME
TIMESTAMP
buffer_type
buffer_type
buffer_type
buffer_type
buffer_type | ||
---|---|---|
signed char | MYSQL_TYPE_TINY | TINYINT |
short int | MYSQL_TYPE_SHORT | SMALLINT |
int | MYSQL_TYPE_LONG | INT |
long long int | MYSQL_TYPE_LONGLONG | BIGINT |
float | MYSQL_TYPE_FLOAT | FLOAT |
double | MYSQL_TYPE_DOUBLE | DOUBLE |
MYSQL_TIME | MYSQL_TYPE_TIME | TIME |
MYSQL_TIME | MYSQL_TYPE_DATE | DATE |
MYSQL_TIME | MYSQL_TYPE_DATETIME | DATETIME |
MYSQL_TIME | MYSQL_TYPE_TIMESTAMP | TIMESTAMP |
char[] | MYSQL_TYPE_STRING | TEXT CHAR VARCHAR |
char[] | MYSQL_TYPE_BLOB | BLOB BINARY VARBINARY |
MYSQL_TYPE_NULL | NULL |
MYSQL_TYPE_NULL
MYSQL_TYPE_STRING
MYSQL_TYPE_STRING
character_set_client
MYSQL_TYPE_BLOB
buffer_type
MYSQL_BIND
is_unsigned
buffer_type | ||
---|---|---|
TINYINT | MYSQL_TYPE_TINY | signed char |
SMALLINT | MYSQL_TYPE_SHORT | short int |
MEDIUMINT | MYSQL_TYPE_INT24 | int |
INT | MYSQL_TYPE_LONG | int |
BIGINT | MYSQL_TYPE_LONGLONG | long long int |
FLOAT | MYSQL_TYPE_FLOAT | float |
DOUBLE | MYSQL_TYPE_DOUBLE | double |
DECIMAL | MYSQL_TYPE_NEWDECIMAL | char[] |
YEAR | MYSQL_TYPE_SHORT | short int |
TIME | MYSQL_TYPE_TIME | MYSQL_TIME |
DATE | MYSQL_TYPE_DATE | MYSQL_TIME |
DATETIME | MYSQL_TYPE_DATETIME | MYSQL_TIME |
TIMESTAMP | MYSQL_TYPE_TIMESTAMP | MYSQL_TIME |
CHAR BINARY | MYSQL_TYPE_STRING | char[] |
VARCHAR VARBINARY | MYSQL_TYPE_VAR_STRING | char[] |
TINYBLOB TINYTEXT | MYSQL_TYPE_TINY_BLOB | char[] |
BLOB TEXT | MYSQL_TYPE_BLOB | char[] |
MEDIUMBLOB MEDIUMTEXT | MYSQL_TYPE_MEDIUM_BLOB | char[] |
LONGBLOB LONGTEXT | MYSQL_TYPE_LONG_BLOB | char[] |
BIT | MYSQL_TYPE_BIT | char[] |
buffer_type
MYSQL_TYPE_LONG
FLOAT
MEDIUMINT
MYSQL_TYPE_LONGLONG
MEDIUMINT
char[4]
MYSQL_TYPE_STRING
DECIMAL
12.345
MYSQL_TYPE_NEWDECIMAL
mysql_stmt_fetch()
mysql_stmt_fetch()
DECIMAL
MYSQL_TYPE_BIT
BIT
SELECT bit_col + 0 FROM t SELECT CAST(bit_col AS UNSIGNED) FROM t
MYSQL_BIND
mysql_stmt_result_metadata()
mysql_stmt_execute()
charsetnr
binary
BINARY
CHAR
VARBINARY
VARCHAR
BLOB
TEXT
max_length
mysql_stmt_attr_set()
max_length
max_length
signed char
mysql_stmt_affected_rows()
UPDATE
DELETE
INSERT
mysql_stmt_attr_get()
mysql_stmt_attr_set()
mysql_stmt_bind_param()
mysql_stmt_bind_result()
mysql_stmt_close()
mysql_stmt_data_seek()
mysql_stmt_errno()
mysql_stmt_error()
mysql_stmt_execute()
mysql_stmt_fetch()
mysql_stmt_fetch_column()
mysql_stmt_field_count()
mysql_stmt_free_result()
mysql_stmt_init()
mysql_stmt_insert_id()
mysql_stmt_next_result()
mysql_stmt_num_rows()
mysql_stmt_param_count()
mysql_stmt_param_metadata()
mysql_stmt_prepare()
mysql_stmt_reset()
mysql_stmt_result_metadata()
mysql_stmt_row_seek()
mysql_stmt_row_tell()
mysql_stmt_row_tell()
mysql_stmt_send_long_data()
mysql_stmt_sqlstate()
mysql_stmt_store_result()
mysql_stmt_init()
mysql_stmt_prepare()
mysql_stmt_bind_param()
mysql_stmt_execute()
mysql_stmt_execute()
mysql_stmt_bind_param()
mysql_stmt_send_long_data()
SELECT
mysql_stmt_prepare()
mysql_stmt_result_metadata()
mysql_stmt_bind_result()
mysql_stmt_fetch()
mysql_stmt_close()
SELECT
mysql_stmt_result_metadata()
mysql_free_result()
mysql_stmt_init()
mysql_stmt_prepare()
mysql_stmt_result_metadata()
mysql_stmt_bind_param()
mysql_stmt_execute()
mysql_stmt_bind_result()
mysql_stmt_fetch()
mysql_stmt_prepare()
mysql_stmt_execute()
mysql_stmt_fetch()
mysql_stmt_errno()
mysql_stmt_error()
mysql_stmt_sqlstate()
mysql_stmt_prepare()
mysql_stmt_execute()
Execute
mysql_stmt_prepare()
mysql_stmt_bind_param()
mysql_stmt_execute()
Prepare [1] SELECT ? Execute [1] SELECT 3
Prepare
[
N
]N
N
?
MYSQL_STMT
MYSQL_STMT
mysql_stmt_init()
my_ulonglong mysql_stmt_affected_rows(MYSQL_STMT
*stmt)
mysql_stmt_affected_rows()
mysql_stmt_execute()
mysql_affected_rows()
bool mysql_stmt_attr_get(MYSQL_STMT *stmt, enum
enum_stmt_attr_type option, void *arg)
option
arg
bool mysql_stmt_attr_set(MYSQL_STMT *stmt, enum
enum_stmt_attr_type option, const void *arg)
option
arg
option
STMT_ATTR_UPDATE_MAX_LENGTH | bool * | mysql_stmt_store_result()
|
STMT_ATTR_CURSOR_TYPE | unsigned long * | mysql_stmt_execute()
CURSOR_TYPE_NO_CURSOR
|
STMT_ATTR_PREFETCH_ROWS | unsigned long * | *arg
|
STMT_ATTR_CURSOR_TYPE
mysql_stmt_execute()
mysql_stmt_execute()
mysql_stmt_reset()
mysql_stmt_free_result()
mysql_stmt_store_result()
MYSQL_STMT *stmt; int rc; unsigned long type; unsigned long prefetch_rows = 5; stmt = mysql_stmt_init(mysql); type = (unsigned long) CURSOR_TYPE_READ_ONLY; rc = mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type); /* ... check return value ... */ rc = mysql_stmt_attr_set(stmt, STMT_ATTR_PREFETCH_ROWS, (void*) &prefetch_rows); /* ... check return value ... */
bool mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND
*bind)
mysql_stmt_bind_param()
mysql_stmt_prepare()
bind
?
INSERT INTO mytbl VALUES(?,?,?)
MYSQL_BIND
MySQL _卷卷[ 3 ];
MYSQL_BIND
buffer_type
bool mysql_stmt_bind_result(MYSQL_STMT *stmt,
MYSQL_BIND *bind)
mysql_stmt_bind_result()
mysql_stmt_fetch()
mysql_stmt_fetch()
MYSQL_BIND
mysql_stmt_fetch()
mysql_stmt_fetch()
mysql_stmt_fetch()
mysql_stmt_fetch()
mysql_stmt_bind_result()
MYSQL_BIND
buffer_type
bool mysql_stmt_close(MYSQL_STMT *stmt)
mysql_stmt_close()
mysql_stmt_close()
mysql_stmt_error()
mysql_stmt_errno()
mysql_stmt_sqlstate()
mysql_stmt_close()
mysql_error()
mysql_errno()
mysql_sqlstate()
void mysql_stmt_data_seek(MYSQL_STMT *stmt,
my_ulonglong offset)
offset
mysql_stmt_num_rows(stmt)-1
mysql_stmt_data_seek()
mysql_stmt_store_result()
unsigned int mysql_stmt_errno(MYSQL_STMT
*stmt)
stmt
mysql_stmt_errno()
mysqld_error.h
mysql_stmt_close()
mysql_stmt_errno()
mysql_stmt_close()
mysql_errno()
const char *mysql_stmt_error(MYSQL_STMT
*stmt)
stmt
mysql_stmt_error()
if(*mysql_stmt_errno(stmt)) { // an error occurred } if (mysql_stmt_error(stmt)[0]) { // an error occurred }
mysql_stmt_close()
mysql_stmt_error()
mysql_stmt_close()
mysql_error()
int mysql_stmt_execute(MYSQL_STMT *stmt)
mysql_stmt_execute()
mysql_stmt_execute()
UPDATE
DELETE
INSERT
mysql_stmt_affected_rows()
SELECT
mysql_stmt_fetch()
mysql_stmt_execute()
mysql_store_result()
mysql_use_result()
mysql_stmt_execute()
mysql_stmt_attr_set()
mysql_stmt_execute()
mysql_stmt_init()
mysql_stmt_prepare()
mysql_stmt_param_count()
mysql_stmt_bind_param()
mysql_stmt_execute()
mysql_stmt_affected_rows()
#define STRING_SIZE 50 #define DROP_SAMPLE_TABLE "DROP TABLE IF EXISTS test_table" #define CREATE_SAMPLE_TABLE "CREATE TABLE test_table(col1 INT,\ col2 VARCHAR(40),\ col3 SMALLINT,\ col4 TIMESTAMP)" #define INSERT_SAMPLE "INSERT INTO \ test_table(col1,col2,col3) \ VALUES(?,?,?)" MYSQL_STMT *stmt; MYSQL_BIND bind[3]; my_ulonglong affected_rows; int param_count; short small_data; int int_data; char str_data[STRING_SIZE]; unsigned long str_length; bool is_null; if (mysql_query(mysql, DROP_SAMPLE_TABLE)) { fprintf(stderr, " DROP TABLE failed\n"); fprintf(stderr, " %s\n", mysql_error(mysql)); exit(0); } if (mysql_query(mysql, CREATE_SAMPLE_TABLE)) { fprintf(stderr, " CREATE TABLE failed\n"); fprintf(stderr, " %s\n", mysql_error(mysql)); exit(0); } /* Prepare an INSERT query with 3 parameters */ /* (the TIMESTAMP column is not named; the server */ /* sets it to the current date and time) */ stmt = mysql_stmt_init(mysql); if (!stmt) { fprintf(stderr, " mysql_stmt_init(), out of memory\n"); exit(0); } if (mysql_stmt_prepare(stmt, INSERT_SAMPLE, strlen(INSERT_SAMPLE))) { fprintf(stderr, " mysql_stmt_prepare(), INSERT failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); exit(0); } fprintf(stdout, " prepare, INSERT successful\n"); /* Get the parameter count from the statement */ param_count= mysql_stmt_param_count(stmt); fprintf(stdout, " total parameters in INSERT: %d\n", param_count); if (param_count != 3) /* validate parameter count */ { fprintf(stderr, " invalid parameter count returned by MySQL\n"); exit(0); } /* Bind the data for all 3 parameters */ memset(bind, 0, sizeof(bind)); /* INTEGER PARAM */ /* This is a number type, so there is no need to specify buffer_length */ bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer= (char *)&int_data; bind[0].is_null= 0; bind[0].length= 0; /* STRING PARAM */ bind[1].buffer_type= MYSQL_TYPE_STRING; bind[1].buffer= (char *)str_data; bind[1].buffer_length= STRING_SIZE; bind[1].is_null= 0; bind[1].length= &str_length; /* SMALLINT PARAM */ bind[2].buffer_type= MYSQL_TYPE_SHORT; bind[2].buffer= (char *)&small_data; bind[2].is_null= &is_null; bind[2].length= 0; /* Bind the buffers */ if (mysql_stmt_bind_param(stmt, bind)) { fprintf(stderr, " mysql_stmt_bind_param() failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); exit(0); } /* Specify the data values for the first row */ int_data= 10; /* integer */ strncpy(str_data, "MySQL", STRING_SIZE); /* string */ str_length= strlen(str_data); /* INSERT SMALLINT data as NULL */ is_null= 1; /* Execute the INSERT statement - 1*/ if (mysql_stmt_execute(stmt)) { fprintf(stderr, " mysql_stmt_execute(), 1 failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); exit(0); } /* Get the number of affected rows */ affected_rows= mysql_stmt_affected_rows(stmt); fprintf(stdout, " total affected rows(insert 1): %lu\n", (unsigned long) affected_rows); if (affected_rows != 1) /* validate affected rows */ { fprintf(stderr, " invalid affected rows by MySQL\n"); exit(0); } /* Specify data values for second row, then re-execute the statement */ int_data= 1000; strncpy(str_data, " The most popular Open Source database", STRING_SIZE); str_length= strlen(str_data); small_data= 1000; /* smallint */ is_null= 0; /* reset */ /* Execute the INSERT statement - 2*/ if (mysql_stmt_execute(stmt)) { fprintf(stderr, " mysql_stmt_execute, 2 failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); exit(0); } /* Get the total rows affected */ affected_rows= mysql_stmt_affected_rows(stmt); fprintf(stdout, " total affected rows(insert 2): %lu\n", (unsigned long) affected_rows); if (affected_rows != 1) /* validate affected rows */ { fprintf(stderr, " invalid affected rows by MySQL\n"); exit(0); } /* Close the statement */ if (mysql_stmt_close(stmt)) { /* mysql_stmt_close() invalidates stmt, so call */ /* mysql_error(mysql) rather than mysql_stmt_error(stmt) */ fprintf(stderr, " failed while closing the statement\n"); fprintf(stderr, " %s\n", mysql_error(mysql)); exit(0); }
tests/mysql_client_test.c
int mysql_stmt_fetch(MYSQL_STMT *stmt)
mysql_stmt_fetch()
mysql_stmt_execute()
SELECT
mysql_stmt_fetch()
mysql_stmt_bind_result()
mysql_stmt_fetch()
mysql_stmt_store_result()
mysql_stmt_fetch()
NULL
MYSQL_BIND
*length
MYSQL_TYPE_TINY | |
MYSQL_TYPE_SHORT | |
MYSQL_TYPE_LONG | |
MYSQL_TYPE_LONGLONG | |
MYSQL_TYPE_FLOAT | |
MYSQL_TYPE_DOUBLE | |
MYSQL_TYPE_TIME | sizeof(MYSQL_TIME) |
MYSQL_TYPE_DATE | sizeof(MYSQL_TIME) |
MYSQL_TYPE_DATETIME | sizeof(MYSQL_TIME) |
MYSQL_TYPE_STRING | data length |
MYSQL_TYPE_BLOB | data_length |
mysql_stmt_fetch()
BLOB
mysql_stmt_fetch()
mysql_stmt_attr_set()
mysql_stmt_store_result()
max_length
mysql_stmt_result_metadata()
mysql_stmt_fetch()
mysql_stmt_fetch_column()
real_length= 0;bind[0].buffer= 0;bind[0].buffer_length= 0;bind[0].length= &real_lengthmysql_stmt_bind_result(stmt, bind);mysql_stmt_fetch(stmt);if (real_length > 0){ data= malloc(real_length); bind[0].buffer= data; bind[0].buffer_length= real_length; mysql_stmt_fetch_column(stmt, bind, 0, 0);}
mysql_stmt_errno() mysql_stmt_error() | |
MYSQL_NO_DATA | |
MYSQL_DATA_TRUNCATED |
MYSQL_DATA_TRUNCATED
MYSQL_BIND
mysql_options()
MYSQL_TYPE_DATE
MYSQL_TYPE_DATETIME
DATE
TIME
DATETIME
TIMESTAMP
mysql_stmt_bind_result()
mysql_stmt_result_metadata()
mysql_stmt_bind_result()
mysql_stmt_fetch()
mysql
#define STRING_SIZE 50#define SELECT_SAMPLE "SELECT col1, col2, col3, col4 \ FROM test_table"MYSQL_STMT *stmt;MYSQL_BIND bind[4];MYSQL_RES *prepare_meta_result;MYSQL_TIME ts;unsigned long length[4];int param_count, column_count, row_count;short small_data;int int_data;char str_data[STRING_SIZE];bool is_null[4];bool error[4];/* Prepare a SELECT query to fetch data from test_table */stmt = mysql_stmt_init(mysql);if (!stmt){ fprintf(stderr, " mysql_stmt_init(), out of memory\n"); exit(0);}if (mysql_stmt_prepare(stmt, SELECT_SAMPLE, strlen(SELECT_SAMPLE))){ fprintf(stderr, " mysql_stmt_prepare(), SELECT failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); exit(0);}fprintf(stdout, " prepare, SELECT successful\n");/* Get the parameter count from the statement */param_count= mysql_stmt_param_count(stmt);fprintf(stdout, " total parameters in SELECT: %d\n", param_count);if (param_count != 0) /* validate parameter count */{ fprintf(stderr, " invalid parameter count returned by MySQL\n"); exit(0);}/* Fetch result set meta information */prepare_meta_result = mysql_stmt_result_metadata(stmt);if (!prepare_meta_result){ fprintf(stderr, " mysql_stmt_result_metadata(), \ returned no meta information\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); exit(0);}/* Get total columns in the query */column_count= mysql_num_fields(prepare_meta_result);fprintf(stdout, " total columns in SELECT statement: %d\n", column_count);if (column_count != 4) /* validate column count */{ fprintf(stderr, " invalid column count returned by MySQL\n"); exit(0);}/* Execute the SELECT query */if (mysql_stmt_execute(stmt)){ fprintf(stderr, " mysql_stmt_execute(), failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); exit(0);}/* Bind the result buffers for all 4 columns before fetching them */memset(bind, 0, sizeof(bind));/* INTEGER COLUMN */bind[0].buffer_type= MYSQL_TYPE_LONG;bind[0].buffer= (char *)&int_data;bind[0].is_null= &is_null[0];bind[0].length= &length[0];bind[0].error= &error[0];/* STRING COLUMN */bind[1].buffer_type= MYSQL_TYPE_STRING;bind[1].buffer= (char *)str_data;bind[1].buffer_length= STRING_SIZE;bind[1].is_null= &is_null[1];bind[1].length= &length[1];bind[1].error= &error[1];/* SMALLINT COLUMN */bind[2].buffer_type= MYSQL_TYPE_SHORT;bind[2].buffer= (char *)&small_data;bind[2].is_null= &is_null[2];bind[2].length= &length[2];bind[2].error= &error[2];/* TIMESTAMP COLUMN */bind[3].buffer_type= MYSQL_TYPE_TIMESTAMP;bind[3].buffer= (char *)&ts;bind[3].is_null= &is_null[3];bind[3].length= &length[3];bind[3].error= &error[3];/* Bind the result buffers */if (mysql_stmt_bind_result(stmt, bind)){ fprintf(stderr, " mysql_stmt_bind_result() failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); exit(0);}/* Now buffer all results to client (optional step) */if (mysql_stmt_store_result(stmt)){ fprintf(stderr, " mysql_stmt_store_result() failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); exit(0);}/* Fetch all rows */row_count= 0;fprintf(stdout, "Fetching results ...\n");while (!mysql_stmt_fetch(stmt)){ row_count++; fprintf(stdout, " row %d\n", row_count); /* column 1 */ fprintf(stdout, " column1 (integer) : "); if (is_null[0]) fprintf(stdout, " NULL\n"); else fprintf(stdout, " %d(%ld)\n", int_data, length[0]); /* column 2 */ fprintf(stdout, " column2 (string) : "); if (is_null[1]) fprintf(stdout, " NULL\n"); else fprintf(stdout, " %s(%ld)\n", str_data, length[1]); /* column 3 */ fprintf(stdout, " column3 (smallint) : "); if (is_null[2]) fprintf(stdout, " NULL\n"); else fprintf(stdout, " %d(%ld)\n", small_data, length[2]); /* column 4 */ fprintf(stdout, " column4 (timestamp): "); if (is_null[3]) fprintf(stdout, " NULL\n"); else fprintf(stdout, " %04d-%02d-%02d %02d:%02d:%02d (%ld)\n", ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second, length[3]); fprintf(stdout, "\n");}/* Validate rows fetched */fprintf(stdout, " total rows fetched: %d\n", row_count);if (row_count != 2){ fprintf(stderr, " MySQL failed to return all rows\n"); exit(0);}/* Free the prepared result metadata */mysql_free_result(prepare_meta_result);/* Close the statement */if (mysql_stmt_close(stmt)){ /* mysql_stmt_close() invalidates stmt, so call */ /* mysql_error(mysql) rather than mysql_stmt_error(stmt) */ fprintf(stderr, " failed while closing the statement\n"); fprintf(stderr, " %s\n", mysql_error(mysql)); exit(0);}
int mysql_stmt_fetch_column(MYSQL_STMT *stmt,
MYSQL_BIND *bind, unsigned int column, unsigned long
offset)
bind
mysql_stmt_bind_result()
offset
unsigned int mysql_stmt_field_count(MYSQL_STMT
*stmt)
INSERT
DELETE
mysql_stmt_field_count()
mysql_stmt_prepare()
bool mysql_stmt_free_result(MYSQL_STMT *stmt)
mysql_stmt_free_result()
my_ulonglong mysql_stmt_insert_id(MYSQL_STMT
*stmt)
AUTO_INCREMENT
INSERT
UPDATE
INSERT
AUTO_INCREMENT
LAST_INSERT_ID(
expr
)
int mysql_stmt_next_result(MYSQL_STMT *mysql)
CALL
mysql_stmt_next_result()
INOUT
mysql_stmt_next_result()
mysql_stmt_next_result()
mysql_stmt_next_result()
mysql_stmt_free_result()
mysql_stmt_next_result()
mysql_stmt_execute()
mysql_stmt_bind_result()
mysql_stmt_affected_rows()
mysql_more_results()
mysql_stmt_next_result()
mysql_stmt_next_result()
my_ulonglong mysql_stmt_num_rows(MYSQL_STMT
*stmt)
mysql_stmt_num_rows()
mysql_stmt_store_result()
mysql_stmt_store_result()
mysql_stmt_num_rows()
mysql_stmt_num_rows()
SELECT
INSERT
UPDATE
DELETE
mysql_stmt_affected_rows()
int mysql_stmt_prepare(MYSQL_STMT *stmt, const char
*stmt_str, unsigned long length)
mysql_stmt_init()
length
\g
?
VALUES()
INSERT
=
mysql_stmt_bind_param()
mysql_stmt_prepare()
mysql_stmt_error()
bool mysql_stmt_reset(MYSQL_STMT *stmt)
mysql_stmt_send_long_data()
mysql_stmt_prepare()
MYSQL_RES *mysql_stmt_result_metadata(MYSQL_STMT
*stmt)
mysql_stmt_prepare()
mysql_stmt_result_metadata()
mysql_free_result()
mysql_store_result()
mysql_stmt_result_metadata()
mysql_stmt_fetch()
MYSQL_ROW_OFFSET mysql_stmt_row_seek(MYSQL_STMT *stmt,
MYSQL_ROW_OFFSET offset)
offset
mysql_stmt_row_tell()
mysql_stmt_row_seek()
mysql_stmt_data_seek()
mysql_stmt_row_seek()
mysql_stmt_store_result()
mysql_stmt_row_seek()
MYSQL_ROW_OFFSET mysql_stmt_row_tell(MYSQL_STMT
*stmt)
mysql_stmt_fetch()
mysql_stmt_row_seek()
bool mysql_stmt_send_long_data(MYSQL_STMT *stmt,
unsigned int parameter_number, const char *data, unsigned long
length)
mysql_stmt_bind_param()
mysql_stmt_execute()
TEXT
BLOB
parameter_number
length
mysql_stmt_execute()
mysql_stmt_send_long_data()
mysql_stmt_execute()
mysql_stmt_reset()
mysql_stmt_reset()
max_allowed_packet
mysql_stmt_send_long_data()
TEXT
text_column
#define INSERT_QUERY "INSERT INTO \ test_long_data(text_column) VALUES(?)" MYSQL_BIND bind[1]; long length; stmt = mysql_stmt_init(mysql); if (!stmt) { fprintf(stderr, " mysql_stmt_init(), out of memory\n"); exit(0); } if (mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY))) { fprintf(stderr, "\n mysql_stmt_prepare(), INSERT failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } memset(bind, 0, sizeof(bind)); bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].length= &length; bind[0].is_null= 0; /* Bind the buffers */ if (mysql_stmt_bind_param(stmt, bind)) { fprintf(stderr, "\n param bind failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } /* Supply data in chunks to server */ if (mysql_stmt_send_long_data(stmt,0,"MySQL",5)) { fprintf(stderr, "\n send_long_data failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } /* Supply the next piece of data */ if (mysql_stmt_send_long_data(stmt,0, " - The most popular Open Source database",40)) { fprintf(stderr, "\n send_long_data failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } /* Now, execute the query */ if (mysql_stmt_execute(stmt)) { fprintf(stderr, "\n mysql_stmt_execute failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); }
const char *mysql_stmt_sqlstate(MYSQL_STMT
*stmt)
stmt
mysql_stmt_sqlstate()
"HY000"
mysql_stmt_close()
mysql_stmt_sqlstate()
mysql_stmt_close()
mysql_sqlstate()
int mysql_stmt_store_result(MYSQL_STMT *stmt)
mysql_stmt_execute()
SELECT
SHOW
DESCRIBE
EXPLAIN
mysql_stmt_fetch()
mysql_stmt_store_result()
mysql_stmt_bind_result()
mysql_stmt_fetch()
mysql_stmt_store_result()
mysql_stmt_data_seek()
mysql_stmt_row_seek()
mysql_stmt_row_tell()
mysql_stmt_store_result()
mysql_stmt_result_metadata()
MYSQL_FIELD->max_length
mysql_stmt_store_result()
mysql_stmt_store_result()
max_length
mysql_stmt_attr_set(MYSQL_STMT,
STMT_ATTR_UPDATE_MAX_LENGTH, &flag)
void mysql_thread_end(void)
pthread_exit()
mysql_thread_init()
mysql_thread_end()
mysql_thread_end()
mysql_thread_init()
mysql_thread_end()
mysql_thread_init()
bool mysql_thread_init(void)
mysql_thread_init()
mysql_init()
mysql_library_init()
mysql_server_init()
mysql_connect()
mysql_thread_init()
st_mysql_client_plugin
mysql_options()
MYSQL_PLUGIN_DIR
char *plugin_dir = "path_to_plugin_dir
";char *default_auth = "plugin_name
“;/*…过程命令行选项。* / MySQL(MySQL和MySQL _选项,你_ _插件插件,你_);_ options(MySQL和MySQL,MySQL _ _ AUTH的违约,违约_ auth);
--plugin-dir
struct st_mysql_client_plugin
*mysql_client_find_plugin(MYSQL *mysql, const char *name, int
type)
mysql
name
type
struct st_mysql_client_plugin
*mysql_client_register_plugin(MYSQL *mysql, struct
st_mysql_client_plugin *plugin)
mysql
plugin
struct st_mysql_client_plugin *mysql_load_plugin(MYSQL
*mysql, const char *name, int type, int argc, ...)
mysql
name
type
argc
LIBMYSQL_PLUGINS
shell> export LIBMYSQL_PLUGINS="myplugin1;myplugin2"
LIBMYSQL_PLUGINS
mysql_library_init()
LIBMYSQL_PLUGIN_DIR
--plugin-dir
mysql_load_plugin()
mysql_load_plugin_v()
--plugin-dir
mysql_load_plugin()
mysql_load_plugin_v()
MYSQL mysql; if(!mysql_load_plugin(&mysql, "myplugin", MYSQL_CLIENT_AUTHENTICATION_PLUGIN, 0)) { fprintf(stderr, "Error: %s\n", mysql_error(&mysql)); exit(-1); }
struct st_mysql_client_plugin
*mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
int argc, va_list args)
mysql_load_plugin()
MYSQL_RPL
MYSQL *
MYSQL *mysql = mysql_real_connect(...); MYSQL_RPL rpl; # ... initialize MYSQL_RPL members ... int result = mysql_binlog_open(mysql, &rpl);
MYSQL_RPL
MYSQL_RPL
mysql_binlog_open()
file_name_length
flags
gtid_set_encoded_size
mysql_binlog_fetch()
buffer
MYSQL_RPL
file_name_length
file_name
file_name
file_name
file_name_length
file_name
file_name_length
file_name
file_name
start_position
start_position
server_id
flags
MYSQL_RPL_SKIP_HEARTBEAT
mysql_binlog_fetch()
MYSQL_RPL_GTID
MYSQL_RPL
gtid_set_arg
mysql_binlog_open()
mysqlbinlog.cc
gtid_set_encoded_size
fix_gtid_set
mysql_binlog_open()
void my_callback
(MYSQL_RPL *rpl, unsigned char *packet_gtid_set);
gtid_set_arg
fix_gtid_set
fix_gtid_set
gtid_set_arg
size
mysql_binlog_fetch()
buffer
mysql_binlog_fetch()
mysql_binlog_close() | |
mysql_binlog_fetch() | |
mysql_binlog_open() |
mysql
SET
if (mysql_query(mysql, "SET @master_binlog_checksum='ALL'")) { fprintf(stderr, "mysql_query() failed\n"); fprintf(stderr, "Error %u: %s\n", mysql_errno(mysql), mysql_error(mysql)); exit(1); } MYSQL_RPL rpl; rpl.file_name_length = 0; rpl.file_name = NULL; rpl.start_position = 4; rpl.server_id = 0; rpl.flags = 0; if (mysql_binlog_open(mysql, &rpl)) { fprintf(stderr, "mysql_binlog_open() failed\n"); fprintf(stderr, "Error %u: %s\n", mysql_errno(mysql), mysql_error(mysql)); exit(1); } for (;;) /* read events until error or EOF */ { if (mysql_binlog_fetch(mysql, &rpl)) { fprintf(stderr, "mysql_binlog_fetch() failed\n"); fprintf(stderr, "Error %u: %s\n", mysql_errno(mysql), mysql_error(mysql)); break; } if (rpl.size == 0) /* EOF */ { fprintf(stderr, "EOF event received\n"); break; } fprintf(stderr, "Event received of size %lu.\n", rpl.size); } mysql_binlog_close(mysql, &rpl);
mysqlbinlog.cc
mysql_client_test.c
void mysql_binlog_close(MYSQL *mysql, MYSQL_RPL
*rpl)
mysql
mysql_init()
mysql_binlog_close()
rpl
mysql_binlog_close()
mysql_binlog_open()
int mysql_binlog_fetch(MYSQL *mysql, MYSQL_RPL
*rpl)
mysql
mysql_init()
rpl
size
int mysql_binlog_open(MYSQL *mysql, MYSQL_RPL
*rpl)
mysql
mysql_init()
rpl
mysql_options()
mysql_real_connect()
mysql_get_ssl_cipher()
NULL
mysql_options()
MYSQL_OPT_SSL_CA
MYSQL_OPT_SSL_CAPATH
MYSQL_OPT_SSL_CERT
MYSQL_OPT_SSL_CIPHER
MYSQL_OPT_SSL_CRL
MYSQL_OPT_SSL_CRLPATH
MYSQL_OPT_SSL_KEY
MYSQL_OPT_SSL_MODE
MYSQL_OPT_TLS_VERSION
mysql_ssl_set()
mysql_options()
mysql_options()
mysql_options()
mysql_options()
SSL_MODE_REQUIRED
mysql_real_connect()
mysql_options()
MYSQL_OPT_SSL_CAPATH
mysql_options()
SSL_MODE_VERIFY_CA
mysql_options()
SSL_MODE_VERIFY_IDENTITY
mysql_query()
mysql_real_query()
SELECT
INSERT
UPDATE
;
mysql_real_connect()
mysql_set_server_option()
mysql_more_results()
mysql_next_result()
CALL
SELECT
mysql_query()
mysql_real_query()
mysql_real_connect()
CLIENT_MULTI_RESULTS
CALL
proc_name
CLIENT_MULTI_STATEMENTS
mysql_query()
mysql_real_query()
flags
mysql_real_connect()
CLIENT_MULTI_STATEMENTS
mysql_set_server_option()
MYSQL_OPTION_MULTI_STATEMENTS_OFF
CLIENT_MULTI_STATEMENTS
mysql_real_connect()
mysql_query()
mysql_real_query()
mysql_next_result()
mysql_next_result()
/* connect to server with the CLIENT_MULTI_STATEMENTS option */if (mysql_real_connect (mysql, host_name, user_name, password, db_name, port_num, socket_name, CLIENT_MULTI_STATEMENTS) == NULL){ printf("mysql_real_connect() failed\n"); mysql_close(mysql); exit(1);}/* execute multiple statements */status = mysql_query(mysql, "DROP TABLE IF EXISTS test_table;\ CREATE TABLE test_table(id INT);\ INSERT INTO test_table VALUES(10);\ UPDATE test_table SET id=20 WHERE id=10;\ SELECT * FROM test_table;\ DROP TABLE test_table");if (status){ printf("Could not execute statement(s)"); mysql_close(mysql); exit(0);}/* process each statement result */do { /* did current statement return data? */ result = mysql_store_result(mysql); if (result) { /* yes; process rows and free the result set */ process_result_set(mysql, result); mysql_free_result(result); } else /* no result set or error */ { if (mysql_field_count(mysql) == 0) { printf("%lld rows affected\n", mysql_affected_rows(mysql)); } else /* some error occurred */ { printf("Could not retrieve result set\n"); break; } } /* more results? -1 = no, >0 = error, 0 = yes (keep looping) */ if ((status = mysql_next_result(mysql)) > 0) printf("Could not execute statement\n");} while (status == 0);mysql_close(mysql);
DATE
TIME
DATETIME
TIMESTAMP
mysql_stmt_prepare()
mysql_stmt_execute()
mysql_stmt_bind_param()
mysql_stmt_execute()
buffer_type
MYSQL_TIME
mysql_stmt_bind_result()
mysql_stmt_execute()
DATE
TIME
TIMESTAMP
MYSQL_TIME ts; MYSQL_BIND bind[3]; MYSQL_STMT *stmt; strmov(query, "INSERT INTO test_table(date_field, time_field, \ timestamp_field) VALUES(?,?,?"); stmt = mysql_stmt_init(mysql); if (!stmt) { fprintf(stderr, " mysql_stmt_init(), out of memory\n"); exit(0); } if (mysql_stmt_prepare(mysql, query, strlen(query))) { fprintf(stderr, "\n mysql_stmt_prepare(), INSERT failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } /* set up input buffers for all 3 parameters */ bind[0].buffer_type= MYSQL_TYPE_DATE; bind[0].buffer= (char *)&ts; bind[0].is_null= 0; bind[0].length= 0; ... bind[1]= bind[2]= bind[0]; ... mysql_stmt_bind_param(stmt, bind); /* supply the data to be sent in the ts structure */ ts.year= 2002; ts.month= 02; ts.day= 03; ts.hour= 10; ts.minute= 45; ts.second= 20; mysql_stmt_execute(stmt); ..
CALL
CALL
OUT
OUT
CALL
PREPARE
EXECUTE
CALL
mysql_stmt_next_result()
OUT
SERVER_PS_OUT_PARAMS
MYSQL
MySQL -> server_status和server_ps_out_params
CALL
INOUT
OUT
MYSQL_STMT *stmt; MYSQL_BIND ps_params[3]; /* input parameter buffers */ int int_data[3]; /* input/output values */ bool is_null[3]; /* output value nullability */ int status; /* set up stored procedure */ status = mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1"); test_error(mysql, status); status = mysql_query(mysql, "CREATE PROCEDURE p1(" " IN p_in INT, " " OUT p_out INT, " " INOUT p_inout INT) " "BEGIN " " SELECT p_in, p_out, p_inout; " " SET p_in = 100, p_out = 200, p_inout = 300; " " SELECT p_in, p_out, p_inout; " "END"); test_error(mysql, status); /* initialize and prepare CALL statement with parameter placeholders */ stmt = mysql_stmt_init(mysql); if (!stmt) { printf("Could not initialize statement\n"); exit(1); } status = mysql_stmt_prepare(stmt, "CALL p1(?, ?, ?)", 16); test_stmt_error(stmt, status); /* initialize parameters: p_in, p_out, p_inout (all INT) */ memset(ps_params, 0, sizeof (ps_params)); ps_params[0].buffer_type = MYSQL_TYPE_LONG; ps_params[0].buffer = (char *) &int_data[0]; ps_params[0].length = 0; ps_params[0].is_null = 0; ps_params[1].buffer_type = MYSQL_TYPE_LONG; ps_params[1].buffer = (char *) &int_data[1]; ps_params[1].length = 0; ps_params[1].is_null = 0; ps_params[2].buffer_type = MYSQL_TYPE_LONG; ps_params[2].buffer = (char *) &int_data[2]; ps_params[2].length = 0; ps_params[2].is_null = 0; /* bind parameters */ status = mysql_stmt_bind_param(stmt, ps_params); test_stmt_error(stmt, status); /* assign values to parameters and execute statement */ int_data[0]= 10; /* p_in */ int_data[1]= 20; /* p_out */ int_data[2]= 30; /* p_inout */ status = mysql_stmt_execute(stmt); test_stmt_error(stmt, status); /* process results until there are no more */ do { int i; int num_fields; /* number of columns in result */ MYSQL_FIELD *fields; /* for result set metadata */ MYSQL_BIND *rs_bind; /* for output buffers */ /* the column count is > 0 if there is a result set */ /* 0 if the result is only the final status packet */ num_fields = mysql_stmt_field_count(stmt); if (num_fields > 0) { /* there is a result set to fetch */ printf("Number of columns in result: %d\n", (int) num_fields); /* what kind of result set is this? */ printf("Data: "); if(mysql->server_status & SERVER_PS_OUT_PARAMS) printf("this result set contains OUT/INOUT parameters\n"); else printf("this result set is produced by the procedure\n"); MYSQL_RES *rs_metadata = mysql_stmt_result_metadata(stmt); test_stmt_error(stmt, rs_metadata == NULL); fields = mysql_fetch_fields(rs_metadata); rs_bind = (MYSQL_BIND *) malloc(sizeof (MYSQL_BIND) * num_fields); if (!rs_bind) { printf("Cannot allocate output buffers\n"); exit(1); } memset(rs_bind, 0, sizeof (MYSQL_BIND) * num_fields); /* set up and bind result set output buffers */ for (i = 0; i < num_fields; ++i) { rs_bind[i].buffer_type = fields[i].type; rs_bind[i].is_null = &is_null[i]; switch (fields[i].type) { case MYSQL_TYPE_LONG: rs_bind[i].buffer = (char *) &(int_data[i]); rs_bind[i].buffer_length = sizeof (int_data); break; default: fprintf(stderr, "ERROR: unexpected type: %d.\n", fields[i].type); exit(1); } } status = mysql_stmt_bind_result(stmt, rs_bind); test_stmt_error(stmt, status); /* fetch and display result set rows */ while (1) { status = mysql_stmt_fetch(stmt); if (status == 1 || status == MYSQL_NO_DATA) break; for (i = 0; i < num_fields; ++i) { switch (rs_bind[i].buffer_type) { case MYSQL_TYPE_LONG: if (*rs_bind[i].is_null) printf(" val[%d] = NULL;", i); else printf(" val[%d] = %ld;", i, (long) *((int *) rs_bind[i].buffer)); break; default: printf(" unexpected type (%d)\n", rs_bind[i].buffer_type); } } printf("\n"); } mysql_free_result(rs_metadata); /* free metadata */ free(rs_bind); /* free output buffers */ } else { /* no columns = final status packet */ printf("End of procedure output\n"); } /* more results? -1 = no, >0 = error, 0 = yes (keep looking) */ status = mysql_stmt_next_result(stmt); if (status > 0) test_stmt_error(stmt, status); } while (status == 0); mysql_stmt_close(stmt);
Number of columns in result: 3 Data: this result set is produced by the procedure val[0] = 10; val[1] = NULL; val[2] = 30; Number of columns in result: 3 Data: this result set is produced by the procedure val[0] = 100; val[1] = 200; val[2] = 300; Number of columns in result: 2 Data: this result set contains OUT/INOUT parameters val[0] = 200; val[1] = 300; End of procedure output
test_error()
static void test_error(MYSQL *mysql, int status) { if (status) { fprintf(stderr, "Error: %s (errno: %d)\n", mysql_error(mysql), mysql_errno(mysql)); exit(1); } } static void test_stmt_error(MYSQL_STMT *stmt, int status) { if (status) { fprintf(stderr, "Error: %s (errno: %d)\n", mysql_stmt_error(stmt), mysql_stmt_errno(stmt)); exit(1); } }
TIME
TIMESTAMP
DATETIME
DATE_FORMAT()
ZEROFILL
MIN(
number-with-zerofill
)
;
CALL
MYSQL_FIELD
mysql_fetch_field()
mysql_fetch_field_direct()
mysql_fetch_fields()
CLIENT_OPTIONAL_RESULTSET_METADATA
mysql_real_connect()
MYSQL_OPT_OPTIONAL_RESULTSET_METADATA
mysql_options()
resultset_metadata
NONE
mysql_fetch_field()
mysql_fetch_field_direct()
mysql_fetch_fields()
resultset_metadata
mysql_result_metadata()
RESULTSET_METADATA_NONE
mysql_result_metadata()
resultset_metadata
mysql_result_metadata()
resultset_metadata
mysql_options()
bool reconnect = 0; mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect);
mysql_ping()
mysql_ping()
--skip-reconnect
mysql_ping()
mysql_thread_id()
mysql_ping()
mysql_thread_id()
TEMPORARY
SET NAMES
HANDLER
LAST_INSERT_ID()
GET_LOCK()
threads
threads
mysql_options()
mysql_kill()
mysql_store_result()
mysql_query()
mysql_field_count()
mysql_field_count()
INSERT
DELETE
mysql_field_count()
mysql_field_count()
mysql_error()
mysql_errno()
mysql_affected_rows()
INSERT
UPDATE
DELETE
TRUNCATE
TABLE
mysql_num_rows()
mysql_store_result()
mysql_num_rows()
mysql_store_result()
mysql_use_result()
mysql_num_rows()
mysql_fetch_row()
mysql_insert_id()
LOAD DATA INFILE
...
INSERT INTO
... SELECT ...
UPDATE
mysql_info()
mysql_info()
mysql_info()
AUTO_INCREMENT
mysql_insert_id()
AUTO_INCREMENT
INSERT
if ((result = mysql_store_result(&mysql)) == 0 && mysql_field_count(&mysql) == 0 && mysql_insert_id(&mysql) != 0) { used_id = mysql_insert_id(&mysql); }
AUTO_INCREMENT
mysql_query()
LAST_INSERT_ID()
NULL
LAST_INSERT_ID()
INSERT INTO foo (auto,text) VALUES(NULL,'text'); # generate ID by inserting NULL INSERT INTO foo2 (id,text) VALUES(LAST_INSERT_ID(),'text'); # use ID in second table
mysql_insert_id()
NULL
LAST_INSERT_ID()
NULL
LAST_INSERT_ID()
AUTO_INCREMENT
LAST_INSERT_ID()
mysql_insert_id()
AUTO_INCREMENT
DBI
DBI
DBD::mysql
mysqlperl
DBI
perldoc
内核> perldoc DBI
内核> perldoc DBI::FAQ
内核> perldoc DBD::mysql
pod2man
DBD::mysql
MySQLdb
libmysqlclient
MySQLtcl