Commit 76b4f4d3 authored by Michael Erickson's avatar Michael Erickson Committed by Sergei Petrunia

make table discovery work

parent cd2da606
......@@ -1467,10 +1467,13 @@ static int xpand_discover_table_names(handlerton *hton, LEX_CSTRING *db,
{
xpand_connection *xpand_net = new xpand_connection();
int error_code = xpand_net->connect();
if (error_code)
if (error_code) {
if (error_code == HA_ERR_NO_CONNECTION)
error_code = 0;
goto err;
}
xpand_net->populate_table_list(db, result);
error_code = xpand_net->populate_table_list(db, result);
err:
delete xpand_net;
......@@ -1481,8 +1484,11 @@ int xpand_discover_table(handlerton *hton, THD *thd, TABLE_SHARE *share)
{
xpand_connection *xpand_net = new xpand_connection();
int error_code = xpand_net->connect();
if (error_code)
if (error_code) {
if (error_code == HA_ERR_NO_CONNECTION)
error_code = HA_ERR_NO_SUCH_TABLE;
goto err;
}
error_code = xpand_net->discover_table_details(&share->db, &share->table_name,
thd, share);
......
......@@ -141,7 +141,7 @@ int xpand_connection::connect()
mysql_rwlock_rdlock(&xpand_hosts_lock);
//search for available host
int error_code = ER_BAD_HOST_ERROR;
int error_code = HA_ERR_NO_CONNECTION;
for (int i = 0; i < xpand_hosts->hosts_len; i++) {
char *host = xpand_hosts->hosts[(start + i) % xpand_hosts->hosts_len];
error_code = connect_direct(host);
......@@ -196,12 +196,9 @@ int xpand_connection::connect_direct(char *host)
NULL, xpand_port, xpand_socket,
CLIENT_MULTI_STATEMENTS))
{
error_code = mysql_errno(&xpand_net);
sql_print_error("Error connecting to xpand: %s", mysql_error(&xpand_net));
disconnect();
}
if (error_code && error_code != ER_CON_COUNT_ERROR) {
error_code = ER_CONNECT_TO_FOREIGN_DATA_SOURCE;
error_code = HA_ERR_NO_CONNECTION;
}
DBUG_RETURN(error_code);
......
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