diff options
author | unknown <mskold/marty@mysql.com/quadfish.(none)> | 2007-12-06 17:15:21 +0100 |
---|---|---|
committer | unknown <mskold/marty@mysql.com/quadfish.(none)> | 2007-12-06 17:15:21 +0100 |
commit | f9bae745058e8eeb27c8a55744effb8afc38474b (patch) | |
tree | aa4869373d31aa5f1ecf96103d3d79d859b6d901 /sql/ha_ndbcluster.cc | |
parent | 4a4f68937f2a2940cc63b8255d9b23ba1dfd9ddc (diff) | |
download | mariadb-git-f9bae745058e8eeb27c8a55744effb8afc38474b.tar.gz |
bug#21072 Duplicate key error in NDB references wrong key: Return correct key for non-batching inserts
Diffstat (limited to 'sql/ha_ndbcluster.cc')
-rw-r--r-- | sql/ha_ndbcluster.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index d29e9345c11..478347e4175 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -540,6 +540,27 @@ 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; + + DBUG_PRINT("info", ("HA_ERR_FOUND_DUPP_KEY, index table %u", error_data)); + 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->getIndexTable()->getTableId() == error_data) + { + DBUG_PRINT("info", ("Found violated key %u", i)); + dupkey= i; + break; + } + } + } if (m_rows_to_insert == 1) { /* @@ -547,7 +568,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->s->primary_key : MAX_KEY; + m_dupkey= err.code == 630 ? table->s->primary_key : dupkey; } else { |