diff options
author | unknown <mskold/marty@mysql.com/linux.site> | 2006-11-30 22:52:23 +0100 |
---|---|---|
committer | unknown <mskold/marty@mysql.com/linux.site> | 2006-11-30 22:52:23 +0100 |
commit | ece3c40b31349fee7231059209cbbeecbf9d57ae (patch) | |
tree | 40319cb671d57ac5d4b330747853fb95e33dab04 /sql/ha_ndbcluster.cc | |
parent | 1cc765b311203c5334da92630e21c0461aaa289a (diff) | |
download | mariadb-git-ece3c40b31349fee7231059209cbbeecbf9d57ae.tar.gz |
bug#18487 UPDATE IGNORE not supported for unique constraint violation of non-primary key: only check pk if it is updated
Diffstat (limited to 'sql/ha_ndbcluster.cc')
-rw-r--r-- | sql/ha_ndbcluster.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 66ee52a54d3..ff5634d291c 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1610,7 +1610,7 @@ bool ha_ndbcluster::check_all_operations_for_error(NdbTransaction *trans, * primary key or unique index values */ -int ha_ndbcluster::peek_indexed_rows(const byte *record) +int ha_ndbcluster::peek_indexed_rows(const byte *record, bool check_pk) { NdbTransaction *trans= m_active_trans; NdbOperation *op; @@ -1623,7 +1623,7 @@ int ha_ndbcluster::peek_indexed_rows(const byte *record) (NdbOperation::LockMode)get_ndb_lock_type(m_lock.type); first= NULL; - if (table->s->primary_key != MAX_KEY) + if (check_pk && table->s->primary_key != MAX_KEY) { /* * Fetch any row with colliding primary key @@ -2216,7 +2216,7 @@ int ha_ndbcluster::write_row(byte *record) start_bulk_insert will set parameters to ensure that each write_row is committed individually */ - int peek_res= peek_indexed_rows(record); + int peek_res= peek_indexed_rows(record, true); if (!peek_res) { @@ -2385,15 +2385,17 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) NdbScanOperation* cursor= m_active_cursor; NdbOperation *op; uint i; + bool pk_update= (table->s->primary_key != MAX_KEY && + key_cmp(table->s->primary_key, old_data, new_data)); DBUG_ENTER("update_row"); /* * If IGNORE the ignore constraint violations on primary and unique keys, * but check that it is not part of INSERT ... ON DUPLICATE KEY UPDATE */ - if (m_ignore_dup_key && thd->lex->sql_command != SQLCOM_INSERT) + if (m_ignore_dup_key && thd->lex->sql_command == SQLCOM_UPDATE) { - int peek_res= peek_indexed_rows(new_data); + int peek_res= peek_indexed_rows(new_data, pk_update); if (!peek_res) { @@ -2412,8 +2414,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) } /* Check for update of primary key for special handling */ - if ((table->s->primary_key != MAX_KEY) && - (key_cmp(table->s->primary_key, old_data, new_data))) + if (pk_update) { int read_res, insert_res, delete_res, undo_res; |