Commit 3f20e69c authored by mskold@mysql.com's avatar mskold@mysql.com

Fixed ndbcluster_print_error to use table name from failed NdbOperation

parent c708619d
...@@ -1179,7 +1179,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) ...@@ -1179,7 +1179,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
int insert_res = write_row(new_data); int insert_res = write_row(new_data);
if (!insert_res) if (!insert_res)
{ {
DBUG_PRINT("info", ("delete succeded")); DBUG_PRINT("info", ("insert succeded"));
int delete_res = delete_row(old_data); int delete_res = delete_row(old_data);
if (!delete_res) if (!delete_res)
{ {
...@@ -2211,8 +2211,11 @@ int ndbcluster_commit(THD *thd, void *ndb_transaction) ...@@ -2211,8 +2211,11 @@ int ndbcluster_commit(THD *thd, void *ndb_transaction)
if (trans->execute(Commit) != 0) if (trans->execute(Commit) != 0)
{ {
const NdbError err= trans->getNdbError(); const NdbError err= trans->getNdbError();
const NdbOperation *error_op= trans->getNdbErrorOperation();
ERR_PRINT(err); ERR_PRINT(err);
res= ndb_to_mysql_error(&err); res= ndb_to_mysql_error(&err);
if (res != -1)
ndbcluster_print_error(res, error_op);
} }
ndb->closeTransaction(trans); ndb->closeTransaction(trans);
DBUG_RETURN(res); DBUG_RETURN(res);
...@@ -2238,8 +2241,11 @@ int ndbcluster_rollback(THD *thd, void *ndb_transaction) ...@@ -2238,8 +2241,11 @@ int ndbcluster_rollback(THD *thd, void *ndb_transaction)
if (trans->execute(Rollback) != 0) if (trans->execute(Rollback) != 0)
{ {
const NdbError err= trans->getNdbError(); const NdbError err= trans->getNdbError();
const NdbOperation *error_op= trans->getNdbErrorOperation();
ERR_PRINT(err); ERR_PRINT(err);
res= ndb_to_mysql_error(&err); res= ndb_to_mysql_error(&err);
if (res != -1)
ndbcluster_print_error(res, error_op);
} }
ndb->closeTransaction(trans); ndb->closeTransaction(trans);
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -2964,13 +2970,17 @@ bool ndbcluster_end() ...@@ -2964,13 +2970,17 @@ bool ndbcluster_end()
static handler method ndbcluster_commit static handler method ndbcluster_commit
and ndbcluster_rollback and ndbcluster_rollback
*/ */
void ndbcluster_print_error(int error)
void ndbcluster_print_error(int error, const NdbOperation *error_op)
{ {
DBUG_ENTER("ndbcluster_print_error"); DBUG_ENTER("ndbcluster_print_error");
TABLE tab; TABLE tab;
tab.table_name = NULL; const char *tab_name= (error_op) ? error_op->getTableName() : "";
tab.table_name= (char *) tab_name;
ha_ndbcluster error_handler(&tab); ha_ndbcluster error_handler(&tab);
tab.file= &error_handler;
error_handler.print_error(error, MYF(0)); error_handler.print_error(error, MYF(0));
DBUG_VOID_RETURN
} }
/* /*
......
...@@ -230,7 +230,7 @@ int ndbcluster_discover(const char* dbname, const char* name, ...@@ -230,7 +230,7 @@ int ndbcluster_discover(const char* dbname, const char* name,
const void** frmblob, uint* frmlen); const void** frmblob, uint* frmlen);
int ndbcluster_drop_database(const char* path); int ndbcluster_drop_database(const char* path);
void ndbcluster_print_error(int error); void ndbcluster_print_error(int error, const NdbOperation *error_op);
......
...@@ -495,9 +495,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans) ...@@ -495,9 +495,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
if ((error=ndbcluster_commit(thd,trans->ndb_tid))) if ((error=ndbcluster_commit(thd,trans->ndb_tid)))
{ {
if (error == -1) if (error == -1)
my_error(ER_ERROR_DURING_COMMIT, MYF(0), error); my_error(ER_ERROR_DURING_COMMIT, MYF(0));
else
ndbcluster_print_error(error);
error=1; error=1;
} }
if (trans == &thd->transaction.all) if (trans == &thd->transaction.all)
...@@ -564,9 +562,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) ...@@ -564,9 +562,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
if ((error=ndbcluster_rollback(thd, trans->ndb_tid))) if ((error=ndbcluster_rollback(thd, trans->ndb_tid)))
{ {
if (error == -1) if (error == -1)
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error); my_error(ER_ERROR_DURING_ROLLBACK, MYF(0));
else
ndbcluster_print_error(error);
error=1; error=1;
} }
trans->ndb_tid = 0; trans->ndb_tid = 0;
......
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