Commit 66ac894c authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-10455: libmariadbclient18 + MySQL-python leaks memory on failed connections

Support of CLIENT_REMEMBER_OPTIONS and freeing options added.
parent b5fb2a68
...@@ -3644,6 +3644,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -3644,6 +3644,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
/* Free alloced memory */ /* Free alloced memory */
end_server(mysql); end_server(mysql);
mysql_close_free(mysql); mysql_close_free(mysql);
if (!(client_flag & CLIENT_REMEMBER_OPTIONS))
mysql_close_free_options(mysql);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -3714,7 +3716,7 @@ my_bool mysql_reconnect(MYSQL *mysql) ...@@ -3714,7 +3716,7 @@ my_bool mysql_reconnect(MYSQL *mysql)
} }
if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
mysql->db, mysql->port, mysql->unix_socket, mysql->db, mysql->port, mysql->unix_socket,
mysql->client_flag)) mysql->client_flag | CLIENT_REMEMBER_OPTIONS))
{ {
if (ctxt) if (ctxt)
my_context_install_suspend_resume_hook(ctxt, NULL, NULL); my_context_install_suspend_resume_hook(ctxt, NULL, NULL);
......
...@@ -6061,7 +6061,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, ...@@ -6061,7 +6061,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
#ifndef DBUG_OFF #ifndef DBUG_OFF
mi->events_till_disconnect = disconnect_slave_event_count; mi->events_till_disconnect = disconnect_slave_event_count;
#endif #endif
ulong client_flag= 0; ulong client_flag= CLIENT_REMEMBER_OPTIONS;
if (opt_slave_compressed_protocol) if (opt_slave_compressed_protocol)
client_flag=CLIENT_COMPRESS; /* We will use compression */ client_flag=CLIENT_COMPRESS; /* We will use compression */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment