MXS-2644 Log reason if mysql_real_connect fails
If mysql_real_connect fails inside any of the open_conn_db... utility functions that will now be logged.
This commit is contained in:
@ -53,14 +53,20 @@ MYSQL* open_conn_db_flags(int port,
|
|||||||
// MXS-2568: This fixes mxs1828_double_local_infile
|
// MXS-2568: This fixes mxs1828_double_local_infile
|
||||||
mysql_optionsv(conn, MYSQL_OPT_LOCAL_INFILE, (void*)"1");
|
mysql_optionsv(conn, MYSQL_OPT_LOCAL_INFILE, (void*)"1");
|
||||||
|
|
||||||
mysql_real_connect(conn,
|
if (!mysql_real_connect(conn,
|
||||||
ip.c_str(),
|
ip.c_str(),
|
||||||
user.c_str(),
|
user.c_str(),
|
||||||
password.c_str(),
|
password.c_str(),
|
||||||
db.c_str(),
|
db.c_str(),
|
||||||
port,
|
port,
|
||||||
NULL,
|
NULL,
|
||||||
flag);
|
flag))
|
||||||
|
{
|
||||||
|
fprintf(stdout,
|
||||||
|
"Could not connect to %s:%d with user '%s' and password '%s', "
|
||||||
|
"and default database '%s': %s\n",
|
||||||
|
ip.c_str(), port, user.c_str(), password.c_str(), db.c_str(), mysql_error(conn));
|
||||||
|
}
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,14 +98,20 @@ MYSQL* open_conn_db_timeout(int port,
|
|||||||
set_ssl(conn);
|
set_ssl(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_real_connect(conn,
|
if (!mysql_real_connect(conn,
|
||||||
ip.c_str(),
|
ip.c_str(),
|
||||||
user.c_str(),
|
user.c_str(),
|
||||||
password.c_str(),
|
password.c_str(),
|
||||||
db.c_str(),
|
db.c_str(),
|
||||||
port,
|
port,
|
||||||
NULL,
|
NULL,
|
||||||
CLIENT_MULTI_STATEMENTS);
|
CLIENT_MULTI_STATEMENTS))
|
||||||
|
{
|
||||||
|
fprintf(stdout,
|
||||||
|
"Could not connect to %s:%d with user '%s' and password '%s', "
|
||||||
|
"and default database '%s': %s\n",
|
||||||
|
ip.c_str(), port, user.c_str(), password.c_str(), db.c_str(), mysql_error(conn));
|
||||||
|
}
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ int Mariadb_nodes::connect(int i, const std::string& db)
|
|||||||
nodes[i] = open_conn_db_timeout(port[i], IP[i], db.c_str(), user_name, password, 50, ssl);
|
nodes[i] = open_conn_db_timeout(port[i], IP[i], db.c_str(), user_name, password, 50, ssl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((nodes[i] != NULL) && (mysql_errno(nodes[i]) != 0))
|
if ((nodes[i] == NULL) || (mysql_errno(nodes[i]) != 0))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1015,8 +1015,7 @@ bool do_flush_hosts(MYSQL* conn)
|
|||||||
|
|
||||||
int Mariadb_nodes::flush_hosts()
|
int Mariadb_nodes::flush_hosts()
|
||||||
{
|
{
|
||||||
|
if (this->nodes[0] == NULL && (this->connect() != 0))
|
||||||
if (this->nodes[0] == NULL && this->connect())
|
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user