Skip to content

Commit 1f66aaa

Browse files
committed
WL#16221 : Revert all C API removals from 8.X and make it equivalent to 8.0
In MySQL 8.3 and 8.4, the following C-APIs were removed: - MYSQL_OPT_RECONNECT - mysql_stmt_bind_param() - mysql_shutdown() - mysql_ssl_set() - mysql_refresh() - mysql_reload() - mysql_list_fields() - mysql_list_processes() - mysql_kill() This WL intends to restore them back. Also, few of the above mentioned APIs used to have few deprecated COM_XXX commands which were removed in MySQL 8.3. In this implementation of the C-APIs, the deprecated commands are not being used, instead, mysql_real_query is used. Only for mysql_list_fields, COM_FIELD_LIST has been restored. main.kill has few tests disable within. They will be addressed via separate bug. Change-Id: I00bf6eb4c9cf29f3189f18fceb5b67b80719b979
1 parent 36443ea commit 1f66aaa

19 files changed

+1056
-170
lines changed

include/my_command.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ enum enum_server_command {
5151
Also used internally to mark the start of a session.
5252
*/
5353
COM_SLEEP,
54-
COM_QUIT, /**< See @ref page_protocol_com_quit */
55-
COM_INIT_DB, /**< See @ref page_protocol_com_init_db */
56-
COM_QUERY, /**< See @ref page_protocol_com_query */
57-
COM_UNUSED_3, /**< Removed, used to be COM_FIELD_LIST */
54+
COM_QUIT, /**< See @ref page_protocol_com_quit */
55+
COM_INIT_DB, /**< See @ref page_protocol_com_init_db */
56+
COM_QUERY, /**< See @ref page_protocol_com_query */
57+
COM_FIELD_LIST, /**< Deprecated. See @ref page_protocol_com_field_list */
5858
COM_CREATE_DB, /**< Currently refused by the server. See ::dispatch_command */
5959
COM_DROP_DB, /**< Currently refused by the server. See ::dispatch_command */
6060
COM_UNUSED_2, /**< Removed, used to be COM_REFRESH. */

include/mysql.h

+20-3
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ typedef struct MYSQL_FIELD {
125125
char *org_table; /* Org table name, if table was an alias */
126126
char *db; /* Database for table */
127127
char *catalog; /* Catalog for table */
128+
char *def; /* Default value (set by mysql_list_fields) */
128129
unsigned long length; /* Width of column (create length) */
129130
unsigned long max_length; /* Max width for selected set */
130131
unsigned int name_length;
@@ -133,6 +134,7 @@ typedef struct MYSQL_FIELD {
133134
unsigned int org_table_length;
134135
unsigned int db_length;
135136
unsigned int catalog_length;
137+
unsigned int def_length;
136138
unsigned int flags; /* Div flags */
137139
unsigned int decimals; /* Number of decimals in field */
138140
unsigned int charsetnr; /* Character set */
@@ -181,6 +183,7 @@ enum mysql_option {
181183
MYSQL_OPT_WRITE_TIMEOUT,
182184
MYSQL_OPT_USE_RESULT,
183185
MYSQL_REPORT_DATA_TRUNCATION,
186+
MYSQL_OPT_RECONNECT,
184187
MYSQL_PLUGIN_DIR,
185188
MYSQL_DEFAULT_AUTH,
186189
MYSQL_OPT_BIND,
@@ -317,7 +320,8 @@ typedef struct MYSQL {
317320
struct st_mysql_options options;
318321
enum mysql_status status;
319322
enum enum_resultset_metadata resultset_metadata;
320-
bool free_me; /* If free in mysql_close */
323+
bool free_me; /* If free in mysql_close */
324+
bool reconnect; /* set to 1 if automatic reconnect */
321325

322326
/* session-wide random string */
323327
char scramble[SCRAMBLE_LENGTH + 1];
@@ -465,6 +469,9 @@ const char *STDCALL mysql_character_set_name(MYSQL *mysql);
465469
int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname);
466470

467471
MYSQL *STDCALL mysql_init(MYSQL *mysql);
472+
bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
473+
const char *ca, const char *capath,
474+
const char *cipher);
468475
const char *STDCALL mysql_get_ssl_cipher(MYSQL *mysql);
469476
bool STDCALL mysql_get_ssl_session_reused(MYSQL *mysql);
470477
void *STDCALL mysql_get_ssl_session_data(MYSQL *mysql, unsigned int n_ticket,
@@ -518,7 +525,11 @@ void mysql_set_local_infile_handler(
518525
int (*local_infile_error)(void *, char *, unsigned int), void *);
519526

520527
void mysql_set_local_infile_default(MYSQL *mysql);
528+
int STDCALL mysql_shutdown(MYSQL *mysql,
529+
enum mysql_enum_shutdown_level shutdown_level);
521530
int STDCALL mysql_dump_debug_info(MYSQL *mysql);
531+
int STDCALL mysql_refresh(MYSQL *mysql, unsigned int refresh_options);
532+
int STDCALL mysql_kill(MYSQL *mysql, unsigned long pid);
522533
int STDCALL mysql_set_server_option(MYSQL *mysql,
523534
enum enum_mysql_set_option option);
524535
int STDCALL mysql_ping(MYSQL *mysql);
@@ -531,6 +542,7 @@ unsigned long STDCALL mysql_get_server_version(MYSQL *mysql);
531542
unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql);
532543
MYSQL_RES *STDCALL mysql_list_dbs(MYSQL *mysql, const char *wild);
533544
MYSQL_RES *STDCALL mysql_list_tables(MYSQL *mysql, const char *wild);
545+
MYSQL_RES *STDCALL mysql_list_processes(MYSQL *mysql);
534546
int STDCALL mysql_options(MYSQL *mysql, enum mysql_option option,
535547
const void *arg);
536548
int STDCALL mysql_options4(MYSQL *mysql, enum mysql_option option,
@@ -550,6 +562,8 @@ enum net_async_status STDCALL mysql_fetch_row_nonblocking(MYSQL_RES *res,
550562

551563
unsigned long *STDCALL mysql_fetch_lengths(MYSQL_RES *result);
552564
MYSQL_FIELD *STDCALL mysql_fetch_field(MYSQL_RES *result);
565+
MYSQL_RES *STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
566+
const char *wild);
553567
unsigned long STDCALL mysql_escape_string(char *to, const char *from,
554568
unsigned long from_length);
555569
unsigned long STDCALL mysql_hex_string(char *to, const char *from,
@@ -590,7 +604,7 @@ enum enum_mysql_stmt_state {
590604
internally by the client library.
591605
Public members with their descriptions are listed below
592606
(conventionally `On input' refers to the binds given to
593-
mysql_stmt_bind_named_param, `On output' refers to the binds given
607+
mysql_stmt_bind_param, `On output' refers to the binds given
594608
to mysql_stmt_bind_result):
595609
596610
buffer_type - One of the MYSQL_* types, used to describe
@@ -603,7 +617,7 @@ enum enum_mysql_stmt_state {
603617
output data.
604618
The type of memory pointed by buffer must correspond
605619
to buffer_type. See the correspondence table in
606-
the comment to mysql_stmt_bind_named_param.
620+
the comment to mysql_stmt_bind_param.
607621
608622
The two above members are mandatory for any kind of bind.
609623
@@ -759,6 +773,7 @@ bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
759773
bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
760774
enum enum_stmt_attr_type attr_type,
761775
void *attr);
776+
bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bnd);
762777
bool STDCALL mysql_stmt_bind_named_param(MYSQL_STMT *stmt, MYSQL_BIND *binds,
763778
unsigned n_params, const char **names);
764779
bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bnd);
@@ -797,6 +812,8 @@ void STDCALL mysql_reset_server_public_key(void);
797812
#define MYSQL_NO_DATA 100
798813
#define MYSQL_DATA_TRUNCATED 101
799814

815+
#define mysql_reload(mysql) mysql_refresh((mysql), REFRESH_GRANT)
816+
800817
#define HAVE_MYSQL_REAL_CONNECT
801818

802819
MYSQL *STDCALL mysql_real_connect_dns_srv(MYSQL *mysql,

include/mysql.h.pp

+16-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
COM_QUIT,
5959
COM_INIT_DB,
6060
COM_QUERY,
61-
COM_UNUSED_3,
61+
COM_FIELD_LIST,
6262
COM_CREATE_DB,
6363
COM_DROP_DB,
6464
COM_UNUSED_2,
@@ -386,6 +386,7 @@
386386
char *org_table;
387387
char *db;
388388
char *catalog;
389+
char *def;
389390
unsigned long length;
390391
unsigned long max_length;
391392
unsigned int name_length;
@@ -394,6 +395,7 @@
394395
unsigned int org_table_length;
395396
unsigned int db_length;
396397
unsigned int catalog_length;
398+
unsigned int def_length;
397399
unsigned int flags;
398400
unsigned int decimals;
399401
unsigned int charsetnr;
@@ -431,6 +433,7 @@
431433
MYSQL_OPT_WRITE_TIMEOUT,
432434
MYSQL_OPT_USE_RESULT,
433435
MYSQL_REPORT_DATA_TRUNCATION,
436+
MYSQL_OPT_RECONNECT,
434437
MYSQL_PLUGIN_DIR,
435438
MYSQL_DEFAULT_AUTH,
436439
MYSQL_OPT_BIND,
@@ -549,6 +552,7 @@
549552
enum mysql_status status;
550553
enum enum_resultset_metadata resultset_metadata;
551554
bool free_me;
555+
bool reconnect;
552556
char scramble[20 + 1];
553557
LIST *stmts;
554558
const struct MYSQL_METHODS *methods;
@@ -610,6 +614,9 @@
610614
const char * mysql_character_set_name(MYSQL *mysql);
611615
int mysql_set_character_set(MYSQL *mysql, const char *csname);
612616
MYSQL * mysql_init(MYSQL *mysql);
617+
bool mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
618+
const char *ca, const char *capath,
619+
const char *cipher);
613620
const char * mysql_get_ssl_cipher(MYSQL *mysql);
614621
bool mysql_get_ssl_session_reused(MYSQL *mysql);
615622
void * mysql_get_ssl_session_data(MYSQL *mysql, unsigned int n_ticket,
@@ -656,7 +663,11 @@
656663
void (*local_infile_end)(void *),
657664
int (*local_infile_error)(void *, char *, unsigned int), void *);
658665
void mysql_set_local_infile_default(MYSQL *mysql);
666+
int mysql_shutdown(MYSQL *mysql,
667+
enum mysql_enum_shutdown_level shutdown_level);
659668
int mysql_dump_debug_info(MYSQL *mysql);
669+
int mysql_refresh(MYSQL *mysql, unsigned int refresh_options);
670+
int mysql_kill(MYSQL *mysql, unsigned long pid);
660671
int mysql_set_server_option(MYSQL *mysql,
661672
enum enum_mysql_set_option option);
662673
int mysql_ping(MYSQL *mysql);
@@ -669,6 +680,7 @@
669680
unsigned int mysql_get_proto_info(MYSQL *mysql);
670681
MYSQL_RES * mysql_list_dbs(MYSQL *mysql, const char *wild);
671682
MYSQL_RES * mysql_list_tables(MYSQL *mysql, const char *wild);
683+
MYSQL_RES * mysql_list_processes(MYSQL *mysql);
672684
int mysql_options(MYSQL *mysql, enum mysql_option option,
673685
const void *arg);
674686
int mysql_options4(MYSQL *mysql, enum mysql_option option,
@@ -687,6 +699,8 @@
687699
MYSQL_ROW *row);
688700
unsigned long * mysql_fetch_lengths(MYSQL_RES *result);
689701
MYSQL_FIELD * mysql_fetch_field(MYSQL_RES *result);
702+
MYSQL_RES * mysql_list_fields(MYSQL *mysql, const char *table,
703+
const char *wild);
690704
unsigned long mysql_escape_string(char *to, const char *from,
691705
unsigned long from_length);
692706
unsigned long mysql_hex_string(char *to, const char *from,
@@ -786,6 +800,7 @@
786800
bool mysql_stmt_attr_get(MYSQL_STMT *stmt,
787801
enum enum_stmt_attr_type attr_type,
788802
void *attr);
803+
bool mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bnd);
789804
bool mysql_stmt_bind_named_param(MYSQL_STMT *stmt, MYSQL_BIND *binds,
790805
unsigned n_params, const char **names);
791806
bool mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bnd);

include/mysql/com_data.h

+8
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ struct COM_QUERY_DATA {
9494
unsigned long parameter_count;
9595
};
9696

97+
struct COM_FIELD_LIST_DATA {
98+
unsigned char *table_name;
99+
unsigned int table_name_length;
100+
const unsigned char *query;
101+
unsigned int query_length;
102+
};
103+
97104
union COM_DATA {
98105
COM_INIT_DB_DATA com_init_db;
99106
COM_SET_OPTION_DATA com_set_option;
@@ -104,6 +111,7 @@ union COM_DATA {
104111
COM_STMT_CLOSE_DATA com_stmt_close;
105112
COM_STMT_RESET_DATA com_stmt_reset;
106113
COM_QUERY_DATA com_query;
114+
COM_FIELD_LIST_DATA com_field_list;
107115
};
108116

109117
#endif /* PLUGIN_PROTOCOL_INCLUDED */

include/mysql/plugin_audit.h.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
COM_QUIT,
143143
COM_INIT_DB,
144144
COM_QUERY,
145-
COM_UNUSED_3,
145+
COM_FIELD_LIST,
146146
COM_CREATE_DB,
147147
COM_DROP_DB,
148148
COM_UNUSED_2,

include/mysql/services.h.pp

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
PS_PARAM *parameters;
5050
unsigned long parameter_count;
5151
};
52+
struct COM_FIELD_LIST_DATA {
53+
unsigned char *table_name;
54+
unsigned int table_name_length;
55+
const unsigned char *query;
56+
unsigned int query_length;
57+
};
5258
union COM_DATA {
5359
COM_INIT_DB_DATA com_init_db;
5460
COM_SET_OPTION_DATA com_set_option;
@@ -59,6 +65,7 @@
5965
COM_STMT_CLOSE_DATA com_stmt_close;
6066
COM_STMT_RESET_DATA com_stmt_reset;
6167
COM_QUERY_DATA com_query;
68+
COM_FIELD_LIST_DATA com_field_list;
6269
};
6370
#include "mysql/service_srv_session.h"
6471
#include "mysql/service_srv_session_bits.h"

include/sql_common.h

+4
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ struct MYSQL_METHODS {
212212
void (*flush_use_result)(MYSQL *mysql, bool flush_all_results);
213213
int (*read_change_user_result)(MYSQL *mysql);
214214
#if !defined(MYSQL_SERVER) && !defined(MYSQL_COMPONENT)
215+
MYSQL_FIELD *(*list_fields)(MYSQL *mysql);
215216
bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
216217
int (*stmt_execute)(MYSQL_STMT *stmt);
217218
int (*read_binary_rows)(MYSQL_STMT *stmt);
@@ -257,6 +258,9 @@ struct MYSQL_METHODS {
257258
1))
258259

259260
extern CHARSET_INFO *default_client_charset_info;
261+
MYSQL_FIELD *unpack_fields(MYSQL *mysql, MYSQL_ROWS *data, MEM_ROOT *alloc,
262+
uint fields, bool default_value,
263+
uint server_capabilities);
260264
MYSQL_FIELD *cli_read_metadata_ex(MYSQL *mysql, MEM_ROOT *alloc,
261265
unsigned long field_count,
262266
unsigned int fields);

libmysql/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ SET(CLIENT_API_FUNCTIONS
5656
mysql_info
5757
mysql_init
5858
mysql_insert_id
59+
mysql_kill
5960
mysql_list_dbs
61+
mysql_list_fields
62+
mysql_list_processes
6063
mysql_list_tables
6164
mysql_more_results
6265
mysql_next_result
@@ -66,6 +69,7 @@ SET(CLIENT_API_FUNCTIONS
6669
mysql_ping
6770
mysql_query
6871
mysql_set_server_option
72+
mysql_stmt_bind_param
6973
mysql_stmt_bind_named_param
7074
mysql_stmt_bind_result
7175
mysql_stmt_execute
@@ -82,6 +86,7 @@ SET(CLIENT_API_FUNCTIONS
8286
mysql_real_escape_string
8387
mysql_real_escape_string_quote
8488
mysql_real_query
89+
mysql_refresh
8590
mysql_rollback
8691
mysql_row_seek
8792
mysql_row_tell
@@ -108,7 +113,9 @@ SET(CLIENT_API_FUNCTIONS
108113
mysql_set_character_set
109114
mysql_set_local_infile_default
110115
mysql_set_local_infile_handler
116+
mysql_shutdown
111117
mysql_sqlstate
118+
mysql_ssl_set
112119
mysql_stat
113120
mysql_stmt_affected_rows
114121
mysql_stmt_attr_get

libmysql/client_settings.h

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ MYSQL *STDCALL cli_mysql_real_connect(MYSQL *mysql, const char *host,
6161

6262
void cli_mysql_close(MYSQL *mysql);
6363

64+
MYSQL_FIELD *cli_list_fields(MYSQL *mysql);
6465
bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt);
6566
MYSQL_DATA *cli_read_rows(MYSQL *mysql, MYSQL_FIELD *mysql_fields, uint fields);
6667
int cli_stmt_execute(MYSQL_STMT *stmt);

0 commit comments

Comments
 (0)