Commit bae9fc07 authored by unknown's avatar unknown

bug#18487 UPDATE IGNORE not supported for unique constraint violation of...

bug#18487  UPDATE IGNORE not supported for unique constraint violation of non-primary key: only check pk if it is updated


parent 910b5c59
...@@ -1885,7 +1885,8 @@ bool ha_ndbcluster::check_all_operations_for_error(NdbTransaction *trans, ...@@ -1885,7 +1885,8 @@ bool ha_ndbcluster::check_all_operations_for_error(NdbTransaction *trans,
* primary key or unique index values * 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; NdbTransaction *trans= m_active_trans;
NdbOperation *op; NdbOperation *op;
...@@ -1897,7 +1898,7 @@ int ha_ndbcluster::peek_indexed_rows(const byte *record) ...@@ -1897,7 +1898,7 @@ int ha_ndbcluster::peek_indexed_rows(const byte *record)
NdbOperation::LockMode lm= NdbOperation::LockMode lm=
(NdbOperation::LockMode)get_ndb_lock_type(m_lock.type); (NdbOperation::LockMode)get_ndb_lock_type(m_lock.type);
first= NULL; 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 * Fetch any row with colliding primary key
...@@ -2622,7 +2623,7 @@ int ha_ndbcluster::write_row(byte *record) ...@@ -2622,7 +2623,7 @@ int ha_ndbcluster::write_row(byte *record)
start_bulk_insert will set parameters to ensure that each start_bulk_insert will set parameters to ensure that each
write_row is committed individually write_row is committed individually
*/ */
int peek_res= peek_indexed_rows(record); int peek_res= peek_indexed_rows(record, true);
if (!peek_res) if (!peek_res)
{ {
...@@ -2831,6 +2832,8 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) ...@@ -2831,6 +2832,8 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
uint32 old_part_id= 0, new_part_id= 0; uint32 old_part_id= 0, new_part_id= 0;
int error; int error;
longlong func_value; longlong func_value;
bool pk_update= (table_share->primary_key != MAX_KEY &&
key_cmp(table_share->primary_key, old_data, new_data));
DBUG_ENTER("update_row"); DBUG_ENTER("update_row");
m_write_op= TRUE; m_write_op= TRUE;
...@@ -2838,9 +2841,9 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) ...@@ -2838,9 +2841,9 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
* If IGNORE the ignore constraint violations on primary and unique keys, * If IGNORE the ignore constraint violations on primary and unique keys,
* but check that it is not part of INSERT ... ON DUPLICATE KEY UPDATE * 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) if (!peek_res)
{ {
...@@ -2870,9 +2873,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) ...@@ -2870,9 +2873,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
* Check for update of primary key or partition change * Check for update of primary key or partition change
* for special handling * for special handling
*/ */
if (((table_share->primary_key != MAX_KEY) && if (pk_update || old_part_id != new_part_id)
key_cmp(table_share->primary_key, old_data, new_data)) ||
(old_part_id != new_part_id))
{ {
int read_res, insert_res, delete_res, undo_res; int read_res, insert_res, delete_res, undo_res;
......
...@@ -846,7 +846,7 @@ static void set_tabname(const char *pathname, char *tabname); ...@@ -846,7 +846,7 @@ static void set_tabname(const char *pathname, char *tabname);
const NdbOperation *first, const NdbOperation *first,
const NdbOperation *last, const NdbOperation *last,
uint errcode); uint errcode);
int peek_indexed_rows(const byte *record); int peek_indexed_rows(const byte *record, bool check_pk);
int fetch_next(NdbScanOperation* op); int fetch_next(NdbScanOperation* op);
int next_result(byte *buf); int next_result(byte *buf);
int define_read_attrs(byte* buf, NdbOperation* op); int define_read_attrs(byte* buf, NdbOperation* op);
......
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