1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Fix for CONC-735

If a reconnect occurs, we need to check if mysql->options.host was
already set and pass NULL instead of the previous host name.
This commit is contained in:
Georg Richter
2024-10-22 13:26:50 +02:00
parent 3b29ff9c91
commit 6635e4bdd6

View File

@@ -1452,8 +1452,8 @@ mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
if (!mysql->options.extension || !mysql->options.extension->status_callback)
mysql_optionsv(mysql, MARIADB_OPT_STATUS_CALLBACK, NULL, NULL);
/* if host contains a semicolon, we need to parse connection string */
if (host && strchr(host, ';'))
/* if host contains a semicolon or equal sign, we need to parse connection string */
if (host && (strchr(host, ';') || strchr(host, '=')))
{
if (parse_connection_string(mysql, NULL, host, strlen(host)))
return NULL;
@@ -2109,7 +2109,9 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql)
my_context_install_suspend_resume_hook(ctxt, my_suspend_hook, &hook_data);
}
if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
if (!mysql_real_connect(&tmp_mysql,
mysql->options.host ? NULL : mysql->host,
mysql->user,mysql->passwd,
mysql->db, mysql->port, mysql->unix_socket,
mysql->client_flag | CLIENT_REMEMBER_OPTIONS) ||
mysql_set_character_set(&tmp_mysql, mysql->charset->csname))