Commit 34944e95 authored by unknown's avatar unknown

wl2126 - ndb - for for null in unique index wrt read_multi_range


sql/ha_ndbcluster.cc:
  New method for set_index_key
  Check null_in_key for read_multi_range
sql/ha_ndbcluster.h:
  New method for set_index_key
parent 924a803f
...@@ -1014,6 +1014,25 @@ int ha_ndbcluster::set_primary_key(NdbOperation *op) ...@@ -1014,6 +1014,25 @@ int ha_ndbcluster::set_primary_key(NdbOperation *op)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
int
ha_ndbcluster::set_index_key(NdbOperation *op,
const KEY *key_info,
const byte * key_ptr)
{
DBUG_ENTER("set_index_key");
uint i;
KEY_PART_INFO* key_part= key_info->key_part;
KEY_PART_INFO* end= key_part+key_info->key_parts;
for (i= 0; key_part != end; key_part++, i++)
{
if (set_ndb_key(op, key_part->field, i,
key_part->null_bit ? key_ptr + 1 : key_ptr))
ERR_RETURN(m_active_trans->getNdbError());
key_ptr+= key_part->store_length;
}
DBUG_RETURN(0);
}
/* /*
Read one record from NDB using primary key Read one record from NDB using primary key
...@@ -1158,11 +1177,6 @@ int ha_ndbcluster::unique_index_read(const byte *key, ...@@ -1158,11 +1177,6 @@ int ha_ndbcluster::unique_index_read(const byte *key,
int res; int res;
NdbConnection *trans= m_active_trans; NdbConnection *trans= m_active_trans;
NdbIndexOperation *op; NdbIndexOperation *op;
THD *thd= current_thd;
byte *key_ptr;
KEY* key_info;
KEY_PART_INFO *key_part, *end;
uint i;
DBUG_ENTER("unique_index_read"); DBUG_ENTER("unique_index_read");
DBUG_PRINT("enter", ("key_len: %u, index: %u", key_len, active_index)); DBUG_PRINT("enter", ("key_len: %u, index: %u", key_len, active_index));
DBUG_DUMP("key", (char*)key, key_len); DBUG_DUMP("key", (char*)key, key_len);
...@@ -1176,18 +1190,8 @@ int ha_ndbcluster::unique_index_read(const byte *key, ...@@ -1176,18 +1190,8 @@ int ha_ndbcluster::unique_index_read(const byte *key,
ERR_RETURN(trans->getNdbError()); ERR_RETURN(trans->getNdbError());
// Set secondary index key(s) // Set secondary index key(s)
key_ptr= (byte *) key; if((res= set_index_key(op, table->key_info + active_index, key)))
key_info= table->key_info + active_index; DBUG_RETURN(res);
DBUG_ASSERT(key_info->key_length == key_len);
end= (key_part= key_info->key_part) + key_info->key_parts;
for (i= 0; key_part != end; key_part++, i++)
{
if (set_ndb_key(op, key_part->field, i,
key_part->null_bit ? key_ptr + 1 : key_ptr))
ERR_RETURN(trans->getNdbError());
key_ptr+= key_part->store_length;
}
if((res= define_read_attrs(buf, op))) if((res= define_read_attrs(buf, op)))
DBUG_RETURN(res); DBUG_RETURN(res);
...@@ -4819,7 +4823,7 @@ ha_ndbcluster::read_multi_range_first(key_multi_range **found_range_p, ...@@ -4819,7 +4823,7 @@ ha_ndbcluster::read_multi_range_first(key_multi_range **found_range_p,
ranges[i].range_flag |= UNIQUE_RANGE; ranges[i].range_flag |= UNIQUE_RANGE;
if ((op= m_active_trans->getNdbIndexOperation(unique_idx, tab)) && if ((op= m_active_trans->getNdbIndexOperation(unique_idx, tab)) &&
!op->readTuple(lm) && !op->readTuple(lm) &&
!set_primary_key(op, ranges[i].start_key.key) && !set_index_key(op, key_info, ranges[i].start_key.key) &&
!define_read_attrs(curr, op) && !define_read_attrs(curr, op) &&
(op->setAbortOption(IgnoreError), true)) (op->setAbortOption(IgnoreError), true))
curr += reclength; curr += reclength;
...@@ -4834,7 +4838,9 @@ ha_ndbcluster::read_multi_range_first(key_multi_range **found_range_p, ...@@ -4834,7 +4838,9 @@ ha_ndbcluster::read_multi_range_first(key_multi_range **found_range_p,
goto range; goto range;
case UNIQUE_ORDERED_INDEX: case UNIQUE_ORDERED_INDEX:
if (ranges[i].start_key.length == key_info->key_length && if (ranges[i].start_key.length == key_info->key_length &&
ranges[i].start_key.flag == HA_READ_KEY_EXACT) ranges[i].start_key.flag == HA_READ_KEY_EXACT &&
!check_null_in_key(key_info, ranges[i].start_key.key,
ranges[i].start_key.length))
goto sk; goto sk;
goto range; goto range;
case ORDERED_INDEX: case ORDERED_INDEX:
......
...@@ -205,6 +205,7 @@ class ha_ndbcluster: public handler ...@@ -205,6 +205,7 @@ class ha_ndbcluster: public handler
int set_primary_key_from_old_data(NdbOperation *op, const byte *old_data); int set_primary_key_from_old_data(NdbOperation *op, const byte *old_data);
int set_bounds(NdbIndexScanOperation *ndb_op, const key_range *keys[2]); int set_bounds(NdbIndexScanOperation *ndb_op, const key_range *keys[2]);
int key_cmp(uint keynr, const byte * old_row, const byte * new_row); int key_cmp(uint keynr, const byte * old_row, const byte * new_row);
int set_index_key(NdbOperation *, const KEY *key_info, const byte *key_ptr);
void print_results(); void print_results();
ulonglong get_auto_increment(); ulonglong get_auto_increment();
......
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