summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/ha_ndbcluster.cc15
-rw-r--r--sql/ha_ndbcluster.h2
2 files changed, 11 insertions, 6 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 4f35bf07cc1..e14d4b13311 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -1113,7 +1113,7 @@ int ha_ndbcluster::set_primary_key(NdbOperation *op, const byte *key)
}
-int ha_ndbcluster::set_primary_key_from_record(NdbOperation *op, const byte *old_data)
+int ha_ndbcluster::set_primary_key_from_record(NdbOperation *op, const byte *record)
{
KEY* key_info= table->key_info + table->primary_key;
KEY_PART_INFO* key_part= key_info->key_part;
@@ -1124,7 +1124,7 @@ int ha_ndbcluster::set_primary_key_from_record(NdbOperation *op, const byte *old
{
Field* field= key_part->field;
if (set_ndb_key(op, field,
- key_part->fieldnr-1, old_data+key_part->offset))
+ key_part->fieldnr-1, record+key_part->offset))
ERR_RETURN(op->getNdbError());
}
DBUG_RETURN(0);
@@ -2009,7 +2009,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
if ((table->primary_key != MAX_KEY) &&
(key_cmp(table->primary_key, old_data, new_data)))
{
- int read_res, insert_res, delete_res;
+ int read_res, insert_res, delete_res, undo_res;
DBUG_PRINT("info", ("primary key update, doing pk read+delete+insert"));
// Get all old fields, since we optimize away fields not in query
@@ -2038,9 +2038,14 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
DBUG_PRINT("info", ("insert failed"));
if (trans->commitStatus() == NdbConnection::Started)
{
- // Undo write_row(new_data)
+ // Undo delete_row(old_data)
m_primary_key_update= TRUE;
- insert_res= write_row((byte *)old_data);
+ undo_res= write_row((byte *)old_data);
+ if (undo_res)
+ push_warning(current_thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ undo_res,
+ "NDB failed undoing delete at primary key update");
m_primary_key_update= FALSE;
}
DBUG_RETURN(insert_res);
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index 8e44733f905..4b3a30fb9b9 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -196,7 +196,7 @@ class ha_ndbcluster: public handler
friend int g_get_ndb_blobs_value(NdbBlob *ndb_blob, void *arg);
int get_ndb_blobs_value(NdbBlob *last_ndb_blob);
int set_primary_key(NdbOperation *op, const byte *key);
- int set_primary_key_from_record(NdbOperation *op, const byte *old_data);
+ int set_primary_key_from_record(NdbOperation *op, const byte *record);
int set_bounds(NdbIndexScanOperation *ndb_op, const key_range *keys[2]);
int key_cmp(uint keynr, const byte * old_row, const byte * new_row);
void print_results();