summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2020-03-09 22:43:59 +0300
committerSergei Petrunia <psergey@askmonty.org>2020-03-09 22:50:11 +0300
commita0e275fbc90e296483bbf065c0dece29857567c5 (patch)
treece033a2cde471154c55061fcb549122854564365
parente322f234dfbb836015ec86b0ef17c3578c0ae90b (diff)
downloadmariadb-git-bb-10.5-clustrixdb-merged.tar.gz
XPand PR#73: Better behavior with offline clusterbb-10.5-clustrixdb-merged
Patches from Michael Erickson: remove my_error and my_printf_error make table discovery work add more debug attempt to fix dup key error
-rw-r--r--storage/xpand/ha_xpand.cc22
-rw-r--r--storage/xpand/xpand_connection.cc43
2 files changed, 27 insertions, 38 deletions
diff --git a/storage/xpand/ha_xpand.cc b/storage/xpand/ha_xpand.cc
index 78a84b7c049..72605fad230 100644
--- a/storage/xpand/ha_xpand.cc
+++ b/storage/xpand/ha_xpand.cc
@@ -114,7 +114,7 @@ static void update_hosts(MYSQL_THD thd, struct st_mysql_sys_var *var,
int error_code = list->fill(from_save);
if (error_code) {
my_free(list);
- my_printf_error(error_code, "Unhandled error setting xpand hostlist", MYF(0));
+ sql_print_error("Unhandled error %d setting xpand hostlist", error_code);
DBUG_VOID_RETURN;
}
@@ -1173,7 +1173,7 @@ err:
int ha_xpand::rnd_end()
{
- DBUG_ENTER("ha_xpand::rnd_end()");
+ DBUG_ENTER("ha_xpand::rnd_end");
int error_code = 0;
THD *thd = ha_thd();
if (thd->lex->sql_command == SQLCOM_UPDATE)
@@ -1439,31 +1439,39 @@ static int xpand_discover_table_names(handlerton *hton, LEX_CSTRING *db,
MY_DIR *dir,
handlerton::discovered_list *result)
{
+ DBUG_ENTER("xpand_discover_table_names");
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;
- return error_code;
+ DBUG_RETURN(error_code);
}
int xpand_discover_table(handlerton *hton, THD *thd, TABLE_SHARE *share)
{
+ DBUG_ENTER("xpand_discover_table");
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);
err:
delete xpand_net;
- return error_code;
+ DBUG_RETURN(error_code);
}
static int xpand_init(void *p)
diff --git a/storage/xpand/xpand_connection.cc b/storage/xpand/xpand_connection.cc
index 28e545fff6d..a4eb18c0bb6 100644
--- a/storage/xpand/xpand_connection.cc
+++ b/storage/xpand/xpand_connection.cc
@@ -156,7 +156,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);
@@ -164,9 +164,6 @@ int xpand_connection::connect()
break;
}
mysql_rwlock_unlock(&xpand_hosts_lock);
- if (error_code)
- my_error(error_code, MYF(0), "clustrix");
-
DBUG_RETURN(error_code);
}
@@ -214,12 +211,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);
@@ -243,8 +237,6 @@ int xpand_connection::begin_command(uchar command)
int xpand_connection::send_command()
{
- my_bool com_error;
-
/*
Please note:
* The transaction state is set before the command is sent because rolling
@@ -260,32 +252,18 @@ int xpand_connection::send_command()
*/
trans_state = XPAND_TRANS_STARTED;
- com_error = simple_command(&xpand_net,
- (enum_server_command)XPAND_SERVER_REQUEST,
- command_buffer, command_length, TRUE);
-
- if (com_error)
- {
- int error_code = mysql_errno(&xpand_net);
- my_printf_error(error_code, "Xpand error: %s", MYF(0),
- mysql_error(&xpand_net));
- return error_code;
- }
-
+ if (simple_command(&xpand_net,
+ (enum_server_command)XPAND_SERVER_REQUEST,
+ command_buffer, command_length, TRUE))
+ return mysql_errno(&xpand_net);
return 0;
}
int xpand_connection::read_query_response()
{
- my_bool comerr = xpand_net.methods->read_query_result(&xpand_net);
int error_code = 0;
- if (comerr)
- {
+ if (xpand_net.methods->read_query_result(&xpand_net))
error_code = mysql_errno(&xpand_net);
- my_printf_error(error_code, "Xpand error: %s", MYF(0),
- mysql_error(&xpand_net));
- }
-
auto_commit_closed();
return error_code;
}
@@ -422,8 +400,11 @@ int xpand_connection::write_row(ulonglong xpand_table_oid, uchar *packed_row,
if ((error_code = send_command()))
return error_code;
- if ((error_code = read_query_response()))
+ if ((error_code = read_query_response())) {
+ if (error_code == ER_DUP_ENTRY)
+ return HA_ERR_FOUND_DUPP_KEY;
return error_code;
+ }
*last_insert_id = xpand_net.insert_id;
return error_code;