diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_ndbcluster.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 93722da574c..55c45f6c687 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -588,6 +588,25 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans) err.code, res)); if (res == HA_ERR_FOUND_DUPP_KEY) { + uint error_data= (uint) err.details; + uint dupkey= MAX_KEY; + + for (uint i= 0; i < MAX_KEY; i++) + { + if (m_index[i].type == UNIQUE_INDEX || + m_index[i].type == UNIQUE_ORDERED_INDEX) + { + const NDBINDEX *unique_index= + (const NDBINDEX *) m_index[i].unique_index; + if (unique_index && + unique_index->getIndexTable() && + (uint) unique_index->getObjectId() == error_data) + { + dupkey= i; + break; + } + } + } if (m_rows_to_insert == 1) { /* @@ -595,7 +614,7 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans) violations here, so we need to return MAX_KEY for non-primary to signal that key is unknown */ - m_dupkey= err.code == 630 ? table_share->primary_key : MAX_KEY; + m_dupkey= err.code == 630 ? table_share->primary_key : dupkey; } else { |