diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/log_event.cc | 34 | ||||
-rw-r--r-- | sql/log_event_old.cc | 34 |
2 files changed, 64 insertions, 4 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc index c9a015e8fba..29d1fd8a084 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -9168,8 +9168,38 @@ int Rows_log_event::find_row(const Relay_log_info *rli) */ if (table->key_info->flags & HA_NOSAME) { - table->file->ha_index_end(); - goto ok; + /* Unique does not have non nullable part */ + if (!(table->key_info->flags & (HA_NULL_PART_KEY))) + { + table->file->ha_index_end(); + goto ok; + } + else + { + KEY *keyinfo= table->key_info; + /* + Unique has nullable part. We need to check if there is any field in the + BI image that is null and part of UNNI. + */ + bool null_found= FALSE; + + for (uint i=0, fieldnr= keyinfo->key_part[i].fieldnr - 1 ; + (i < keyinfo->key_parts) && !null_found ; + i++, fieldnr= keyinfo->key_part[i].fieldnr - 1) + { + Field **f= table->field+fieldnr; + if ((*f)->is_null()) + null_found= TRUE; + } + + if (!null_found) + { + table->file->ha_index_end(); + goto ok; + } + + /* else fall through to index scan */ + } } /* diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 76eda43aa48..59cc2005f56 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -2339,8 +2339,38 @@ int Old_rows_log_event::find_row(const Relay_log_info *rli) */ if (table->key_info->flags & HA_NOSAME) { - table->file->ha_index_end(); - DBUG_RETURN(0); + /* Unique does not have non nullable part */ + if (!(table->key_info->flags & (HA_NULL_PART_KEY))) + { + table->file->ha_index_end(); + DBUG_RETURN(0); + } + else + { + KEY *keyinfo= table->key_info; + /* + Unique has nullable part. We need to check if there is any field in the + BI image that is null and part of UNNI. + */ + bool null_found= FALSE; + + for (uint i=0, fieldnr= keyinfo->key_part[i].fieldnr - 1 ; + (i < keyinfo->key_parts) && !null_found ; + i++, fieldnr= keyinfo->key_part[i].fieldnr - 1) + { + Field **f= table->field+fieldnr; + if ((*f)->is_null()) + null_found= TRUE; + } + + if (!null_found) + { + table->file->ha_index_end(); + DBUG_RETURN(0); + } + + /* else fall through to index scan */ + } } /* |