diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2021-09-16 13:35:21 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2021-09-16 13:35:21 +0400 |
commit | a5ffaea3e714ee7b7d3d9c88db246149a45fe497 (patch) | |
tree | 4b8a37ce134622d646d1a68412389f89e2757d81 | |
parent | 7c38fc44d07156cfcba450b099e5ea9d7613b684 (diff) | |
download | mariadb-git-bb-10.7-mdev-19275-hf-review.tar.gz |
MDEV-19275 SQL service for plugins.bb-10.7-mdev-19275-hf-review
alt fix.
-rw-r--r-- | include/my_alloc.h | 2 | ||||
-rw-r--r-- | include/mysql.h | 53 | ||||
-rw-r--r-- | include/mysql.h.pp | 41 | ||||
-rw-r--r-- | include/mysql/plugin_audit.h.pp | 22 | ||||
-rw-r--r-- | include/mysql/plugin_auth.h.pp | 22 | ||||
-rw-r--r-- | include/mysql/plugin_data_type.h.pp | 22 | ||||
-rw-r--r-- | include/mysql/plugin_encryption.h.pp | 22 | ||||
-rw-r--r-- | include/mysql/plugin_ftparser.h.pp | 22 | ||||
-rw-r--r-- | include/mysql/plugin_function.h.pp | 22 | ||||
-rw-r--r-- | include/mysql/plugin_password_validation.h.pp | 22 | ||||
-rw-r--r-- | include/mysql/service_sql.h | 62 | ||||
-rw-r--r-- | plugin/server_audit/server_audit.c | 1 | ||||
-rw-r--r-- | plugin/type_mysql_json/type.cc | 2 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 3 |
14 files changed, 185 insertions, 133 deletions
diff --git a/include/my_alloc.h b/include/my_alloc.h index 659cc16ea14..3001c4efcec 100644 --- a/include/my_alloc.h +++ b/include/my_alloc.h @@ -20,7 +20,7 @@ #ifndef _my_alloc_h #define _my_alloc_h -typedef unsigned int PSI_memory_key; +#include <mysql/psi/psi_memory.h> #define ALLOC_MAX_BLOCK_TO_DROP 4096 #define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 diff --git a/include/mysql.h b/include/mysql.h index 4490f850f7c..7684e562f8d 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -325,12 +325,9 @@ typedef struct st_mysql_res { /* We should not define MYSQL_CLIENT when the mysql.h is included by the server or server plugins. - Now it is important only for the SQL service to work so we rely on - the MYSQL_SERVICE_SQL to check we're compiling the server/plugin - related file. */ -#if !defined(MYSQL_SERVICE_SQL) && !defined(MYSQL_CLIENT) +#if !defined(MYSQL_SERVICES_INCLUDED) && !defined(MYSQL_CLIENT) #define MYSQL_CLIENT #endif @@ -362,11 +359,39 @@ typedef struct st_mysql_parameters */ #define MYSQL_WAIT_TIMEOUT 8 -#if !defined(MYSQL_SERVICE_SQL) +#if !defined(MYSQL_SERVICES_INCLUDED) #define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet) #define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length) #endif +#ifdef MYSQL_CLIENT +/* + These functions are used by the server and provided + to the plugins by the SQL service. The SQL service + can redefine these names for it's needs. + So we delare them here for client users only. +*/ + +MYSQL * STDCALL mysql_init(MYSQL *mysql); +MYSQL * STDCALL 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 clientflag); +unsigned int STDCALL mysql_errno(MYSQL *mysql); +const char * STDCALL mysql_error(MYSQL *mysql); +int STDCALL mysql_real_query(MYSQL *mysql, const char *q, + unsigned long length); +my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql); +my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res); +MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql); +void STDCALL mysql_free_result(MYSQL_RES *result); +MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); +void STDCALL mysql_close(MYSQL *sock); +#endif /*MYSQL_CLIENT*/ + /* Set up and bring down the server; to ensure that applications will work when linked against either the standard client library or the @@ -403,7 +428,6 @@ void STDCALL mysql_thread_end(void); Should definitely be used if one uses shared libraries. */ -my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res); unsigned int STDCALL mysql_num_fields(MYSQL_RES *res); my_bool STDCALL mysql_eof(MYSQL_RES *res); MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res, @@ -421,10 +445,7 @@ int STDCALL mariadb_field_attr(MARIADB_CONST_STRING *attr, unsigned int STDCALL mysql_field_count(MYSQL *mysql); -my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql); my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql); -unsigned int STDCALL mysql_errno(MYSQL *mysql); -const char * STDCALL mysql_error(MYSQL *mysql); const char *STDCALL mysql_sqlstate(MYSQL *mysql); unsigned int STDCALL mysql_warning_count(MYSQL *mysql); const char * STDCALL mysql_info(MYSQL *mysql); @@ -436,7 +457,6 @@ int STDCALL mysql_set_character_set_start(int *ret, MYSQL *mysql, int STDCALL mysql_set_character_set_cont(int *ret, MYSQL *mysql, int status); -MYSQL * STDCALL mysql_init(MYSQL *mysql); my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher); @@ -449,13 +469,6 @@ int STDCALL mysql_change_user_start(my_bool *ret, MYSQL *mysql, const char *db); int STDCALL mysql_change_user_cont(my_bool *ret, MYSQL *mysql, int status); -MYSQL * STDCALL 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 clientflag); int STDCALL mysql_real_connect_start(MYSQL **ret, MYSQL *mysql, const char *host, const char *user, @@ -483,14 +496,11 @@ int STDCALL mysql_send_query_start(int *ret, MYSQL *mysql, unsigned long length); int STDCALL mysql_send_query_cont(int *ret, MYSQL *mysql, int status); -int STDCALL mysql_real_query(MYSQL *mysql, const char *q, - unsigned long length); int STDCALL mysql_real_query_start(int *ret, MYSQL *mysql, const char *q, unsigned long length); int STDCALL mysql_real_query_cont(int *ret, MYSQL *mysql, int status); -MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql); int STDCALL mysql_store_result_start(MYSQL_RES **ret, MYSQL *mysql); int STDCALL mysql_store_result_cont(MYSQL_RES **ret, MYSQL *mysql, int status); @@ -579,7 +589,6 @@ int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg); int STDCALL mysql_options4(MYSQL *mysql,enum mysql_option option, const void *arg1, const void *arg2); -void STDCALL mysql_free_result(MYSQL_RES *result); int STDCALL mysql_free_result_start(MYSQL_RES *result); int STDCALL mysql_free_result_cont(MYSQL_RES *result, int status); void STDCALL mysql_data_seek(MYSQL_RES *result, @@ -588,7 +597,6 @@ MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET offset); MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset); -MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); int STDCALL mysql_fetch_row_start(MYSQL_ROW *ret, MYSQL_RES *result); int STDCALL mysql_fetch_row_cont(MYSQL_ROW *ret, MYSQL_RES *result, @@ -877,7 +885,6 @@ int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt); int STDCALL mysql_stmt_next_result_start(int *ret, MYSQL_STMT *stmt); int STDCALL mysql_stmt_next_result_cont(int *ret, MYSQL_STMT *stmt, int status); void STDCALL mysql_close_slow_part(MYSQL *mysql); -void STDCALL mysql_close(MYSQL *sock); int STDCALL mysql_close_start(MYSQL *sock); int STDCALL mysql_close_cont(MYSQL *sock, int status); my_socket STDCALL mysql_get_socket(const MYSQL *mysql); diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 7ae47ac836e..e36f21938e7 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -238,7 +238,12 @@ typedef struct st_mysql_field { typedef char **MYSQL_ROW; typedef unsigned int MYSQL_FIELD_OFFSET; typedef unsigned long long my_ulonglong; +extern "C" { +} +extern "C" { +struct PSI_thread; typedef unsigned int PSI_memory_key; +} extern "C" { typedef struct st_used_mem { @@ -430,12 +435,29 @@ typedef struct st_mysql_parameters unsigned long *p_net_buffer_length; void *extension; } MYSQL_PARAMETERS; +MYSQL * mysql_init(MYSQL *mysql); +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 clientflag); +unsigned int mysql_errno(MYSQL *mysql); +const char * mysql_error(MYSQL *mysql); +int mysql_real_query(MYSQL *mysql, const char *q, + unsigned long length); +my_ulonglong mysql_affected_rows(MYSQL *mysql); +my_ulonglong mysql_num_rows(MYSQL_RES *res); +MYSQL_RES * mysql_store_result(MYSQL *mysql); +void mysql_free_result(MYSQL_RES *result); +MYSQL_ROW mysql_fetch_row(MYSQL_RES *result); +void mysql_close(MYSQL *sock); int mysql_server_init(int argc, char **argv, char **groups); void mysql_server_end(void); MYSQL_PARAMETERS * mysql_get_parameters(void); my_bool mysql_thread_init(void); void mysql_thread_end(void); -my_ulonglong mysql_num_rows(MYSQL_RES *res); unsigned int mysql_num_fields(MYSQL_RES *res); my_bool mysql_eof(MYSQL_RES *res); MYSQL_FIELD * mysql_fetch_field_direct(MYSQL_RES *res, @@ -447,10 +469,7 @@ int mariadb_field_attr(MARIADB_CONST_STRING *attr, const MYSQL_FIELD *field, enum mariadb_field_attr_t type); unsigned int mysql_field_count(MYSQL *mysql); -my_ulonglong mysql_affected_rows(MYSQL *mysql); my_ulonglong mysql_insert_id(MYSQL *mysql); -unsigned int mysql_errno(MYSQL *mysql); -const char * mysql_error(MYSQL *mysql); const char * mysql_sqlstate(MYSQL *mysql); unsigned int mysql_warning_count(MYSQL *mysql); const char * mysql_info(MYSQL *mysql); @@ -461,7 +480,6 @@ int mysql_set_character_set_start(int *ret, MYSQL *mysql, const char *csname); int mysql_set_character_set_cont(int *ret, MYSQL *mysql, int status); -MYSQL * mysql_init(MYSQL *mysql); my_bool mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher); @@ -474,13 +492,6 @@ int mysql_change_user_start(my_bool *ret, MYSQL *mysql, const char *db); int mysql_change_user_cont(my_bool *ret, MYSQL *mysql, int status); -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 clientflag); int mysql_real_connect_start(MYSQL **ret, MYSQL *mysql, const char *host, const char *user, @@ -508,14 +519,11 @@ int mysql_send_query_start(int *ret, MYSQL *mysql, unsigned long length); int mysql_send_query_cont(int *ret, MYSQL *mysql, int status); -int mysql_real_query(MYSQL *mysql, const char *q, - unsigned long length); int mysql_real_query_start(int *ret, MYSQL *mysql, const char *q, unsigned long length); int mysql_real_query_cont(int *ret, MYSQL *mysql, int status); -MYSQL_RES * mysql_store_result(MYSQL *mysql); int mysql_store_result_start(MYSQL_RES **ret, MYSQL *mysql); int mysql_store_result_cont(MYSQL_RES **ret, MYSQL *mysql, int status); @@ -596,7 +604,6 @@ int mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg); int mysql_options4(MYSQL *mysql,enum mysql_option option, const void *arg1, const void *arg2); -void mysql_free_result(MYSQL_RES *result); int mysql_free_result_start(MYSQL_RES *result); int mysql_free_result_cont(MYSQL_RES *result, int status); void mysql_data_seek(MYSQL_RES *result, @@ -605,7 +612,6 @@ MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET offset); MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset); -MYSQL_ROW mysql_fetch_row(MYSQL_RES *result); int mysql_fetch_row_start(MYSQL_ROW *ret, MYSQL_RES *result); int mysql_fetch_row_cont(MYSQL_ROW *ret, MYSQL_RES *result, @@ -782,7 +788,6 @@ int mysql_stmt_next_result(MYSQL_STMT *stmt); int mysql_stmt_next_result_start(int *ret, MYSQL_STMT *stmt); int mysql_stmt_next_result_cont(int *ret, MYSQL_STMT *stmt, int status); void mysql_close_slow_part(MYSQL *mysql); -void mysql_close(MYSQL *sock); int mysql_close_start(MYSQL *sock); int mysql_close_cont(MYSQL *sock, int status); my_socket mysql_get_socket(const MYSQL *mysql); diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index fedfb5862b4..bdb4512c7fd 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -466,21 +466,21 @@ int json_unescape_json(const char *json_str, const char *json_end, } extern "C" { extern struct sql_service_st { - MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql); + MYSQL *( *mysql_init_func)(MYSQL *mysql); MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); - MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host, + MYSQL *( *mysql_real_connect_func)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); - unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql); - const char *(STDCALL *mysql_error_func)(MYSQL *mysql); - int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q, + unsigned int( *mysql_errno_func)(MYSQL *mysql); + const char *( *mysql_error_func)(MYSQL *mysql); + int ( *mysql_real_query_func)(MYSQL *mysql, const char *q, unsigned long length); - my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql); - my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res); - MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql); - void (STDCALL *mysql_free_result_func)(MYSQL_RES *result); - MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); - void (STDCALL *mysql_close_func)(MYSQL *mysql); + my_ulonglong ( *mysql_affected_rows_func)(MYSQL *mysql); + my_ulonglong ( *mysql_num_rows_func)(MYSQL_RES *res); + MYSQL_RES *( *mysql_store_result_func)(MYSQL *mysql); + void ( *mysql_free_result_func)(MYSQL_RES *result); + MYSQL_ROW ( *mysql_fetch_row_func)(MYSQL_RES *result); + void ( *mysql_close_func)(MYSQL *mysql); } *sql_service; MYSQL *mysql_real_connect_local(MYSQL *mysql); } diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index f4adae35ffd..b3f2fb6b448 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -466,21 +466,21 @@ int json_unescape_json(const char *json_str, const char *json_end, } extern "C" { extern struct sql_service_st { - MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql); + MYSQL *( *mysql_init_func)(MYSQL *mysql); MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); - MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host, + MYSQL *( *mysql_real_connect_func)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); - unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql); - const char *(STDCALL *mysql_error_func)(MYSQL *mysql); - int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q, + unsigned int( *mysql_errno_func)(MYSQL *mysql); + const char *( *mysql_error_func)(MYSQL *mysql); + int ( *mysql_real_query_func)(MYSQL *mysql, const char *q, unsigned long length); - my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql); - my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res); - MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql); - void (STDCALL *mysql_free_result_func)(MYSQL_RES *result); - MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); - void (STDCALL *mysql_close_func)(MYSQL *mysql); + my_ulonglong ( *mysql_affected_rows_func)(MYSQL *mysql); + my_ulonglong ( *mysql_num_rows_func)(MYSQL_RES *res); + MYSQL_RES *( *mysql_store_result_func)(MYSQL *mysql); + void ( *mysql_free_result_func)(MYSQL_RES *result); + MYSQL_ROW ( *mysql_fetch_row_func)(MYSQL_RES *result); + void ( *mysql_close_func)(MYSQL *mysql); } *sql_service; MYSQL *mysql_real_connect_local(MYSQL *mysql); } diff --git a/include/mysql/plugin_data_type.h.pp b/include/mysql/plugin_data_type.h.pp index 68333230b00..8b2453fb03f 100644 --- a/include/mysql/plugin_data_type.h.pp +++ b/include/mysql/plugin_data_type.h.pp @@ -466,21 +466,21 @@ int json_unescape_json(const char *json_str, const char *json_end, } extern "C" { extern struct sql_service_st { - MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql); + MYSQL *( *mysql_init_func)(MYSQL *mysql); MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); - MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host, + MYSQL *( *mysql_real_connect_func)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); - unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql); - const char *(STDCALL *mysql_error_func)(MYSQL *mysql); - int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q, + unsigned int( *mysql_errno_func)(MYSQL *mysql); + const char *( *mysql_error_func)(MYSQL *mysql); + int ( *mysql_real_query_func)(MYSQL *mysql, const char *q, unsigned long length); - my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql); - my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res); - MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql); - void (STDCALL *mysql_free_result_func)(MYSQL_RES *result); - MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); - void (STDCALL *mysql_close_func)(MYSQL *mysql); + my_ulonglong ( *mysql_affected_rows_func)(MYSQL *mysql); + my_ulonglong ( *mysql_num_rows_func)(MYSQL_RES *res); + MYSQL_RES *( *mysql_store_result_func)(MYSQL *mysql); + void ( *mysql_free_result_func)(MYSQL_RES *result); + MYSQL_ROW ( *mysql_fetch_row_func)(MYSQL_RES *result); + void ( *mysql_close_func)(MYSQL *mysql); } *sql_service; MYSQL *mysql_real_connect_local(MYSQL *mysql); } diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp index a7dca09334d..a6d20175312 100644 --- a/include/mysql/plugin_encryption.h.pp +++ b/include/mysql/plugin_encryption.h.pp @@ -466,21 +466,21 @@ int json_unescape_json(const char *json_str, const char *json_end, } extern "C" { extern struct sql_service_st { - MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql); + MYSQL *( *mysql_init_func)(MYSQL *mysql); MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); - MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host, + MYSQL *( *mysql_real_connect_func)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); - unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql); - const char *(STDCALL *mysql_error_func)(MYSQL *mysql); - int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q, + unsigned int( *mysql_errno_func)(MYSQL *mysql); + const char *( *mysql_error_func)(MYSQL *mysql); + int ( *mysql_real_query_func)(MYSQL *mysql, const char *q, unsigned long length); - my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql); - my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res); - MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql); - void (STDCALL *mysql_free_result_func)(MYSQL_RES *result); - MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); - void (STDCALL *mysql_close_func)(MYSQL *mysql); + my_ulonglong ( *mysql_affected_rows_func)(MYSQL *mysql); + my_ulonglong ( *mysql_num_rows_func)(MYSQL_RES *res); + MYSQL_RES *( *mysql_store_result_func)(MYSQL *mysql); + void ( *mysql_free_result_func)(MYSQL_RES *result); + MYSQL_ROW ( *mysql_fetch_row_func)(MYSQL_RES *result); + void ( *mysql_close_func)(MYSQL *mysql); } *sql_service; MYSQL *mysql_real_connect_local(MYSQL *mysql); } diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 3270f88defd..97bfcc499b8 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -466,21 +466,21 @@ int json_unescape_json(const char *json_str, const char *json_end, } extern "C" { extern struct sql_service_st { - MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql); + MYSQL *( *mysql_init_func)(MYSQL *mysql); MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); - MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host, + MYSQL *( *mysql_real_connect_func)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); - unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql); - const char *(STDCALL *mysql_error_func)(MYSQL *mysql); - int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q, + unsigned int( *mysql_errno_func)(MYSQL *mysql); + const char *( *mysql_error_func)(MYSQL *mysql); + int ( *mysql_real_query_func)(MYSQL *mysql, const char *q, unsigned long length); - my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql); - my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res); - MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql); - void (STDCALL *mysql_free_result_func)(MYSQL_RES *result); - MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); - void (STDCALL *mysql_close_func)(MYSQL *mysql); + my_ulonglong ( *mysql_affected_rows_func)(MYSQL *mysql); + my_ulonglong ( *mysql_num_rows_func)(MYSQL_RES *res); + MYSQL_RES *( *mysql_store_result_func)(MYSQL *mysql); + void ( *mysql_free_result_func)(MYSQL_RES *result); + MYSQL_ROW ( *mysql_fetch_row_func)(MYSQL_RES *result); + void ( *mysql_close_func)(MYSQL *mysql); } *sql_service; MYSQL *mysql_real_connect_local(MYSQL *mysql); } diff --git a/include/mysql/plugin_function.h.pp b/include/mysql/plugin_function.h.pp index 4f0c15e74eb..61460edd6b6 100644 --- a/include/mysql/plugin_function.h.pp +++ b/include/mysql/plugin_function.h.pp @@ -466,21 +466,21 @@ int json_unescape_json(const char *json_str, const char *json_end, } extern "C" { extern struct sql_service_st { - MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql); + MYSQL *( *mysql_init_func)(MYSQL *mysql); MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); - MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host, + MYSQL *( *mysql_real_connect_func)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); - unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql); - const char *(STDCALL *mysql_error_func)(MYSQL *mysql); - int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q, + unsigned int( *mysql_errno_func)(MYSQL *mysql); + const char *( *mysql_error_func)(MYSQL *mysql); + int ( *mysql_real_query_func)(MYSQL *mysql, const char *q, unsigned long length); - my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql); - my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res); - MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql); - void (STDCALL *mysql_free_result_func)(MYSQL_RES *result); - MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); - void (STDCALL *mysql_close_func)(MYSQL *mysql); + my_ulonglong ( *mysql_affected_rows_func)(MYSQL *mysql); + my_ulonglong ( *mysql_num_rows_func)(MYSQL_RES *res); + MYSQL_RES *( *mysql_store_result_func)(MYSQL *mysql); + void ( *mysql_free_result_func)(MYSQL_RES *result); + MYSQL_ROW ( *mysql_fetch_row_func)(MYSQL_RES *result); + void ( *mysql_close_func)(MYSQL *mysql); } *sql_service; MYSQL *mysql_real_connect_local(MYSQL *mysql); } diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp index 3220e2fc259..4906f342c4c 100644 --- a/include/mysql/plugin_password_validation.h.pp +++ b/include/mysql/plugin_password_validation.h.pp @@ -466,21 +466,21 @@ int json_unescape_json(const char *json_str, const char *json_end, } extern "C" { extern struct sql_service_st { - MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql); + MYSQL *( *mysql_init_func)(MYSQL *mysql); MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); - MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host, + MYSQL *( *mysql_real_connect_func)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); - unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql); - const char *(STDCALL *mysql_error_func)(MYSQL *mysql); - int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q, + unsigned int( *mysql_errno_func)(MYSQL *mysql); + const char *( *mysql_error_func)(MYSQL *mysql); + int ( *mysql_real_query_func)(MYSQL *mysql, const char *q, unsigned long length); - my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql); - my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res); - MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql); - void (STDCALL *mysql_free_result_func)(MYSQL_RES *result); - MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); - void (STDCALL *mysql_close_func)(MYSQL *mysql); + my_ulonglong ( *mysql_affected_rows_func)(MYSQL *mysql); + my_ulonglong ( *mysql_num_rows_func)(MYSQL_RES *res); + MYSQL_RES *( *mysql_store_result_func)(MYSQL *mysql); + void ( *mysql_free_result_func)(MYSQL_RES *result); + MYSQL_ROW ( *mysql_fetch_row_func)(MYSQL_RES *result); + void ( *mysql_close_func)(MYSQL *mysql); } *sql_service; MYSQL *mysql_real_connect_local(MYSQL *mysql); } diff --git a/include/mysql/service_sql.h b/include/mysql/service_sql.h index ef6de8b34ef..8432c799d6e 100644 --- a/include/mysql/service_sql.h +++ b/include/mysql/service_sql.h @@ -16,9 +16,45 @@ #ifndef MYSQL_SERVICE_SQL #define MYSQL_SERVICE_SQL +#if !defined(_WIN32) +#define STDCALL_SQL +#else +#define STDCALL_SQL __stdcall +#endif + #ifndef MYSQL_ABI_CHECK -#include <mysql.h> +typedef struct st_mysql MYSQL; +typedef struct st_mysql_res MYSQL_RES; +typedef char **MYSQL_ROW; +#ifndef MY_GLOBAL_INCLUDED +#if defined(NO_CLIENT_LONG_LONG) +typedef unsigned long my_ulonglong; +#elif defined (_WIN32) +typedef unsigned __int64 my_ulonglong; +#else +typedef unsigned long long my_ulonglong; +#endif #endif +MYSQL * STDCALL_SQL mysql_init(MYSQL *mysql); +MYSQL * STDCALL_SQL 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 clientflag); +unsigned int STDCALL_SQL mysql_errno(MYSQL *mysql); +const char * STDCALL_SQL mysql_error(MYSQL *mysql); +int STDCALL_SQL mysql_real_query(MYSQL *mysql, const char *q, + unsigned long length); +my_ulonglong STDCALL_SQL mysql_affected_rows(MYSQL *mysql); +my_ulonglong STDCALL_SQL mysql_num_rows(MYSQL_RES *res); +MYSQL_RES * STDCALL_SQL mysql_store_result(MYSQL *mysql); +void STDCALL_SQL mysql_free_result(MYSQL_RES *result); +MYSQL_ROW STDCALL_SQL mysql_fetch_row(MYSQL_RES *result); +void STDCALL_SQL mysql_close(MYSQL *sock); + +#endif /*MYSQL_ABI_CHECK*/ /** @file @@ -47,21 +83,21 @@ extern "C" { #endif extern struct sql_service_st { - MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql); + MYSQL *(STDCALL_SQL *mysql_init_func)(MYSQL *mysql); MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); - MYSQL *(STDCALL *mysql_real_connect_func)(MYSQL *mysql, const char *host, + MYSQL *(STDCALL_SQL *mysql_real_connect_func)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); - unsigned int(STDCALL *mysql_errno_func)(MYSQL *mysql); - const char *(STDCALL *mysql_error_func)(MYSQL *mysql); - int (STDCALL *mysql_real_query_func)(MYSQL *mysql, const char *q, + unsigned int(STDCALL_SQL *mysql_errno_func)(MYSQL *mysql); + const char *(STDCALL_SQL *mysql_error_func)(MYSQL *mysql); + int (STDCALL_SQL *mysql_real_query_func)(MYSQL *mysql, const char *q, unsigned long length); - my_ulonglong (STDCALL *mysql_affected_rows_func)(MYSQL *mysql); - my_ulonglong (STDCALL *mysql_num_rows_func)(MYSQL_RES *res); - MYSQL_RES *(STDCALL *mysql_store_result_func)(MYSQL *mysql); - void (STDCALL *mysql_free_result_func)(MYSQL_RES *result); - MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); - void (STDCALL *mysql_close_func)(MYSQL *mysql); + my_ulonglong (STDCALL_SQL *mysql_affected_rows_func)(MYSQL *mysql); + my_ulonglong (STDCALL_SQL *mysql_num_rows_func)(MYSQL_RES *res); + MYSQL_RES *(STDCALL_SQL *mysql_store_result_func)(MYSQL *mysql); + void (STDCALL_SQL *mysql_free_result_func)(MYSQL_RES *result); + MYSQL_ROW (STDCALL_SQL *mysql_fetch_row_func)(MYSQL_RES *result); + void (STDCALL_SQL *mysql_close_func)(MYSQL *mysql); } *sql_service; #ifdef MYSQL_DYNAMIC_PLUGIN @@ -99,6 +135,6 @@ MYSQL *mysql_real_connect_local(MYSQL *mysql); } #endif +#undef STDCALL_SQL #endif /*MYSQL_SERVICE_SQL */ - diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index 864dd9e1222..49d41627275 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -1151,6 +1151,7 @@ static void setup_connection_simple(struct connection_info *ci) #define MAX_HOSTNAME (HOSTNAME_LENGTH + 1) /* len+1 in mysql.user */ +#define USERNAME_LENGTH 384 static void setup_connection_connect(MYSQL_THD thd,struct connection_info *cn, const struct mysql_event_connection *event) diff --git a/plugin/type_mysql_json/type.cc b/plugin/type_mysql_json/type.cc index 61507a24d92..8b79e039106 100644 --- a/plugin/type_mysql_json/type.cc +++ b/plugin/type_mysql_json/type.cc @@ -14,8 +14,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ -#include <mysql/plugin_data_type.h> #include <my_global.h> +#include <mysql/plugin_data_type.h> #include <sql_type.h> #include <field.h> #include <mysqld_error.h> diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index d80fa650c76..1f4f506c761 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -4859,6 +4859,7 @@ Prepared_statement::execute_server_runnable(Server_runnable *server_runnable) Statement stmt_backup; bool error; Query_arena *save_stmt_arena= thd->stmt_arena; + Reprepare_observer *save_reprepare_observer= thd->m_reprepare_observer; Item_change_list save_change_list; thd->Item_change_list::move_elements_to(&save_change_list); @@ -4871,11 +4872,13 @@ Prepared_statement::execute_server_runnable(Server_runnable *server_runnable) thd->set_n_backup_statement(this, &stmt_backup); thd->set_n_backup_active_arena(this, &stmt_backup); thd->stmt_arena= this; + thd->m_reprepare_observer= 0; error= server_runnable->execute_server_code(thd); thd->cleanup_after_query(); + thd->m_reprepare_observer= save_reprepare_observer; thd->restore_active_arena(this, &stmt_backup); thd->restore_backup_statement(this, &stmt_backup); thd->stmt_arena= save_stmt_arena; |