summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/log_event.cc34
-rw-r--r--sql/log_event_old.cc34
2 files changed, 64 insertions, 4 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 2cc594d85b4..c07bb573188 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -9015,8 +9015,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 60b0df5253a..5f2d55d6477 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -2428,8 +2428,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 */
+ }
}
/*