summaryrefslogtreecommitdiff
path: root/storage/federatedx/ha_federatedx.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/federatedx/ha_federatedx.cc')
-rw-r--r--storage/federatedx/ha_federatedx.cc41
1 files changed, 16 insertions, 25 deletions
diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc
index 20a78b8e3ce..d4ac808add9 100644
--- a/storage/federatedx/ha_federatedx.cc
+++ b/storage/federatedx/ha_federatedx.cc
@@ -1218,7 +1218,6 @@ bool ha_federatedx::create_where_from_key(String *to,
KEY *key_info,
const key_range *start_key,
const key_range *end_key,
- bool from_records_in_range,
bool eq_range)
{
bool both_not_null=
@@ -1239,7 +1238,6 @@ bool ha_federatedx::create_where_from_key(String *to,
MY_BITMAP *old_map= dbug_tmp_use_all_columns(table, &table->write_set);
for (uint i= 0; i <= 1; i++)
{
- bool needs_quotes;
KEY_PART_INFO *key_part;
if (ranges[i] == NULL)
continue;
@@ -1262,7 +1260,12 @@ bool ha_federatedx::create_where_from_key(String *to,
Field *field= key_part->field;
uint store_length= key_part->store_length;
uint part_length= MY_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
+ bool needs_quotes= field->str_needs_quotes();
+ bool reverse= key_part->key_part_flag & HA_REVERSE_SORT;
+ static const LEX_CSTRING lt={STRING_WITH_LEN(" < ") };
+ static const LEX_CSTRING gt={STRING_WITH_LEN(" > ") };
+ static const LEX_CSTRING le={STRING_WITH_LEN(" <= ") };
+ static const LEX_CSTRING ge={STRING_WITH_LEN(" >= ") };
DBUG_DUMP("key, start of loop", ptr, length);
if (key_part->null_bit)
@@ -1304,16 +1307,8 @@ bool ha_federatedx::create_where_from_key(String *to,
if (emit_key_part_name(&tmp, key_part))
goto err;
- if (from_records_in_range)
- {
- if (tmp.append(STRING_WITH_LEN(" >= ")))
- goto err;
- }
- else
- {
- if (tmp.append(STRING_WITH_LEN(" = ")))
- goto err;
- }
+ if (tmp.append(STRING_WITH_LEN(" = ")))
+ goto err;
if (emit_key_part_element(&tmp, key_part, needs_quotes, 0, ptr,
part_length))
@@ -1344,12 +1339,12 @@ bool ha_federatedx::create_where_from_key(String *to,
if (i > 0) /* end key */
{
- if (tmp.append(STRING_WITH_LEN(" <= ")))
+ if (tmp.append(reverse ? ge : le))
goto err;
}
else /* start key */
{
- if (tmp.append(STRING_WITH_LEN(" > ")))
+ if (tmp.append(reverse ? lt : gt))
goto err;
}
@@ -1364,7 +1359,7 @@ bool ha_federatedx::create_where_from_key(String *to,
case HA_READ_KEY_OR_NEXT:
DBUG_PRINT("info", ("federatedx HA_READ_KEY_OR_NEXT %d", i));
if (emit_key_part_name(&tmp, key_part) ||
- tmp.append(STRING_WITH_LEN(" >= ")) ||
+ tmp.append(reverse ? le : ge) ||
emit_key_part_element(&tmp, key_part, needs_quotes, 0, ptr,
part_length))
goto err;
@@ -1374,7 +1369,7 @@ bool ha_federatedx::create_where_from_key(String *to,
if (store_length >= length)
{
if (emit_key_part_name(&tmp, key_part) ||
- tmp.append(STRING_WITH_LEN(" < ")) ||
+ tmp.append(reverse ? gt : lt) ||
emit_key_part_element(&tmp, key_part, needs_quotes, 0, ptr,
part_length))
goto err;
@@ -1384,7 +1379,7 @@ bool ha_federatedx::create_where_from_key(String *to,
case HA_READ_KEY_OR_PREV:
DBUG_PRINT("info", ("federatedx HA_READ_KEY_OR_PREV %d", i));
if (emit_key_part_name(&tmp, key_part) ||
- tmp.append(STRING_WITH_LEN(" <= ")) ||
+ tmp.append(reverse ? ge : le) ||
emit_key_part_element(&tmp, key_part, needs_quotes, 0, ptr,
part_length))
goto err;
@@ -2639,10 +2634,7 @@ int ha_federatedx::index_read_idx_with_result_set(uchar *buf, uint index,
range.key= key;
range.length= key_len;
range.flag= find_flag;
- create_where_from_key(&index_string,
- &table->key_info[index],
- &range,
- NULL, 0, 0);
+ create_where_from_key(&index_string, &table->key_info[index], &range, 0, 0);
sql_query.append(index_string);
if ((retval= txn->acquire(share, ha_thd(), TRUE, &io)))
@@ -2721,9 +2713,8 @@ int ha_federatedx::read_range_first(const key_range *start_key,
sql_query.length(0);
sql_query.append(share->select_query);
- create_where_from_key(&sql_query,
- &table->key_info[active_index],
- start_key, end_key, 0, eq_range_arg);
+ create_where_from_key(&sql_query, &table->key_info[active_index],
+ start_key, end_key, eq_range_arg);
if ((retval= txn->acquire(share, ha_thd(), TRUE, &io)))
DBUG_RETURN(retval);