diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 5ba1307ccda..fedfb5862b4 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -467,9 +467,7 @@ 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_real_connect_local_func)(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); + MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); MYSQL *(STDCALL *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); @@ -484,9 +482,7 @@ extern struct sql_service_st { MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); void (STDCALL *mysql_close_func)(MYSQL *mysql); } *sql_service; -MYSQL *mysql_real_connect_local(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); +MYSQL *mysql_real_connect_local(MYSQL *mysql); } } struct st_mysql_xid { diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index 334c49304ce..f4adae35ffd 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -467,9 +467,7 @@ 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_real_connect_local_func)(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); + MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); MYSQL *(STDCALL *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); @@ -484,9 +482,7 @@ extern struct sql_service_st { MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); void (STDCALL *mysql_close_func)(MYSQL *mysql); } *sql_service; -MYSQL *mysql_real_connect_local(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); +MYSQL *mysql_real_connect_local(MYSQL *mysql); } } struct st_mysql_xid { diff --git a/include/mysql/plugin_data_type.h.pp b/include/mysql/plugin_data_type.h.pp index 9e7ddd6bec5..68333230b00 100644 --- a/include/mysql/plugin_data_type.h.pp +++ b/include/mysql/plugin_data_type.h.pp @@ -467,9 +467,7 @@ 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_real_connect_local_func)(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); + MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); MYSQL *(STDCALL *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); @@ -484,9 +482,7 @@ extern struct sql_service_st { MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); void (STDCALL *mysql_close_func)(MYSQL *mysql); } *sql_service; -MYSQL *mysql_real_connect_local(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); +MYSQL *mysql_real_connect_local(MYSQL *mysql); } } struct st_mysql_xid { diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp index f33d4ca0960..a7dca09334d 100644 --- a/include/mysql/plugin_encryption.h.pp +++ b/include/mysql/plugin_encryption.h.pp @@ -467,9 +467,7 @@ 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_real_connect_local_func)(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); + MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); MYSQL *(STDCALL *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); @@ -484,9 +482,7 @@ extern struct sql_service_st { MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); void (STDCALL *mysql_close_func)(MYSQL *mysql); } *sql_service; -MYSQL *mysql_real_connect_local(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); +MYSQL *mysql_real_connect_local(MYSQL *mysql); } } struct st_mysql_xid { diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index acdfef16298..3270f88defd 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -467,9 +467,7 @@ 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_real_connect_local_func)(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); + MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); MYSQL *(STDCALL *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); @@ -484,9 +482,7 @@ extern struct sql_service_st { MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); void (STDCALL *mysql_close_func)(MYSQL *mysql); } *sql_service; -MYSQL *mysql_real_connect_local(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); +MYSQL *mysql_real_connect_local(MYSQL *mysql); } } struct st_mysql_xid { diff --git a/include/mysql/plugin_function.h.pp b/include/mysql/plugin_function.h.pp index 715cb392a9a..4f0c15e74eb 100644 --- a/include/mysql/plugin_function.h.pp +++ b/include/mysql/plugin_function.h.pp @@ -467,9 +467,7 @@ 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_real_connect_local_func)(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); + MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); MYSQL *(STDCALL *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); @@ -484,9 +482,7 @@ extern struct sql_service_st { MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); void (STDCALL *mysql_close_func)(MYSQL *mysql); } *sql_service; -MYSQL *mysql_real_connect_local(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); +MYSQL *mysql_real_connect_local(MYSQL *mysql); } } struct st_mysql_xid { diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp index 0674591ade6..3220e2fc259 100644 --- a/include/mysql/plugin_password_validation.h.pp +++ b/include/mysql/plugin_password_validation.h.pp @@ -467,9 +467,7 @@ 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_real_connect_local_func)(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); + MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); MYSQL *(STDCALL *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); @@ -484,9 +482,7 @@ extern struct sql_service_st { MYSQL_ROW (STDCALL *mysql_fetch_row_func)(MYSQL_RES *result); void (STDCALL *mysql_close_func)(MYSQL *mysql); } *sql_service; -MYSQL *mysql_real_connect_local(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); +MYSQL *mysql_real_connect_local(MYSQL *mysql); } } struct st_mysql_xid { diff --git a/include/mysql/service_sql.h b/include/mysql/service_sql.h index 075b7794d49..ef6de8b34ef 100644 --- a/include/mysql/service_sql.h +++ b/include/mysql/service_sql.h @@ -48,9 +48,7 @@ extern "C" { extern struct sql_service_st { MYSQL *(STDCALL *mysql_init_func)(MYSQL *mysql); - MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); + MYSQL *(*mysql_real_connect_local_func)(MYSQL *mysql); MYSQL *(STDCALL *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); @@ -69,7 +67,7 @@ extern struct sql_service_st { #ifdef MYSQL_DYNAMIC_PLUGIN #define mysql_init(M) sql_service->mysql_init_func(M) -#define mysql_real_connect_local(M,H,U,D,F) sql_service->mysql_real_connect_local_func(M,H,U,D,F) +#define mysql_real_connect_local(M) sql_service->mysql_real_connect_local_func(M) #define mysql_real_connect(M,H,U,PW,D,P,S,F) sql_service->mysql_real_connect_func(M,H,U,PW,D,P,S,F) #define mysql_errno(M) sql_service->mysql_errno_func(M) #define mysql_error(M) sql_service->mysql_error_func(M) @@ -83,9 +81,14 @@ extern struct sql_service_st { #else -MYSQL *mysql_real_connect_local(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag); +/* + Establishes the connection to the 'local' server that started the plugin. + Like the mysql_real_connect() does for the remote server. + The established connection has no user/host associated to it, + neither it has the current db, so the queries should have + database/table name specified. +*/ +MYSQL *mysql_real_connect_local(MYSQL *mysql); /* The rest of the function declarations mest be taken from the mysql.h */ diff --git a/plugin/test_sql_service/test_sql_service.c b/plugin/test_sql_service/test_sql_service.c index 0e5b38df922..a5e47194df6 100644 --- a/plugin/test_sql_service/test_sql_service.c +++ b/plugin/test_sql_service/test_sql_service.c @@ -104,7 +104,7 @@ static int do_tests() int result= 1; mysql= mysql_init(NULL); - if (mysql_real_connect_local(mysql, NULL, NULL, NULL, 0) == NULL) + if (mysql_real_connect_local(mysql) == NULL) return 1; if (run_queries(mysql)) @@ -188,7 +188,7 @@ static int run_sql_local(MYSQL_THD thd, struct st_mysql_sys_var *var, void *save int result= 1; mysql= mysql_init(NULL); - if (mysql_real_connect_local(mysql, NULL, NULL, NULL, 0) == NULL) + if (mysql_real_connect_local(mysql) == NULL) return 1; if (run_sql(mysql, save, value)) @@ -217,7 +217,7 @@ static int test_sql_service_plugin_init(void *p __attribute__((unused))) global_mysql= mysql_init(NULL); if (!global_mysql || - mysql_real_connect_local(global_mysql, NULL, NULL, NULL, 0) == NULL) + mysql_real_connect_local(global_mysql) == NULL) return 1; init_done= 1; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 19ae176ddcb..fad11c9fbf9 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -6344,9 +6344,7 @@ static MYSQL_METHODS local_methods= Atomic_counter local_connection_thread_count; -extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql, - const char *host, const char *user, const char *db, - unsigned long clientflag) +extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql) { THD *thd_orig= current_thd; THD *new_thd; @@ -6360,17 +6358,7 @@ extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql, DBUG_RETURN(0); } - if (!host || !host[0]) - host= mysql->options.host; - mysql->methods= &local_methods; - - if (!db || !db[0]) - db=mysql->options.db; - - if (!user || !user[0]) - user=mysql->options.user; - mysql->user= NULL; mysql->info_buffer= (char *) my_malloc(PSI_INSTRUMENT_ME,