@@ -1218,7 +1218,6 @@ bool ha_federatedx::create_where_from_key(String *to,
1218
1218
KEY *key_info,
1219
1219
const key_range *start_key,
1220
1220
const key_range *end_key,
1221
- bool from_records_in_range,
1222
1221
bool eq_range)
1223
1222
{
1224
1223
bool both_not_null=
@@ -1239,7 +1238,6 @@ bool ha_federatedx::create_where_from_key(String *to,
1239
1238
MY_BITMAP *old_map= dbug_tmp_use_all_columns (table, &table->write_set );
1240
1239
for (uint i= 0 ; i <= 1 ; i++)
1241
1240
{
1242
- bool needs_quotes;
1243
1241
KEY_PART_INFO *key_part;
1244
1242
if (ranges[i] == NULL )
1245
1243
continue ;
@@ -1262,7 +1260,11 @@ bool ha_federatedx::create_where_from_key(String *to,
1262
1260
Field *field= key_part->field ;
1263
1261
uint store_length= key_part->store_length ;
1264
1262
uint part_length= MY_MIN (store_length, length);
1265
- needs_quotes= field->str_needs_quotes ();
1263
+ bool needs_quotes= field->str_needs_quotes ();
1264
+ static const LEX_CSTRING lt={STRING_WITH_LEN (" < " ) };
1265
+ static const LEX_CSTRING gt={STRING_WITH_LEN (" > " ) };
1266
+ static const LEX_CSTRING le={STRING_WITH_LEN (" <= " ) };
1267
+ static const LEX_CSTRING ge={STRING_WITH_LEN (" >= " ) };
1266
1268
DBUG_DUMP (" key, start of loop" , ptr, length);
1267
1269
1268
1270
if (key_part->null_bit )
@@ -1304,16 +1306,8 @@ bool ha_federatedx::create_where_from_key(String *to,
1304
1306
if (emit_key_part_name (&tmp, key_part))
1305
1307
goto err;
1306
1308
1307
- if (from_records_in_range)
1308
- {
1309
- if (tmp.append (STRING_WITH_LEN (" >= " )))
1310
- goto err;
1311
- }
1312
- else
1313
- {
1314
- if (tmp.append (STRING_WITH_LEN (" = " )))
1315
- goto err;
1316
- }
1309
+ if (tmp.append (STRING_WITH_LEN (" = " )))
1310
+ goto err;
1317
1311
1318
1312
if (emit_key_part_element (&tmp, key_part, needs_quotes, 0 , ptr,
1319
1313
part_length))
@@ -1344,12 +1338,12 @@ bool ha_federatedx::create_where_from_key(String *to,
1344
1338
1345
1339
if (i > 0 ) /* end key */
1346
1340
{
1347
- if (tmp.append (STRING_WITH_LEN ( " <= " ) ))
1341
+ if (tmp.append (le ))
1348
1342
goto err;
1349
1343
}
1350
1344
else /* start key */
1351
1345
{
1352
- if (tmp.append (STRING_WITH_LEN ( " > " ) ))
1346
+ if (tmp.append (gt ))
1353
1347
goto err;
1354
1348
}
1355
1349
@@ -1364,7 +1358,7 @@ bool ha_federatedx::create_where_from_key(String *to,
1364
1358
case HA_READ_KEY_OR_NEXT:
1365
1359
DBUG_PRINT (" info" , (" federatedx HA_READ_KEY_OR_NEXT %d" , i));
1366
1360
if (emit_key_part_name (&tmp, key_part) ||
1367
- tmp.append (STRING_WITH_LEN ( " >= " ) ) ||
1361
+ tmp.append (ge ) ||
1368
1362
emit_key_part_element (&tmp, key_part, needs_quotes, 0 , ptr,
1369
1363
part_length))
1370
1364
goto err;
@@ -1374,7 +1368,7 @@ bool ha_federatedx::create_where_from_key(String *to,
1374
1368
if (store_length >= length)
1375
1369
{
1376
1370
if (emit_key_part_name (&tmp, key_part) ||
1377
- tmp.append (STRING_WITH_LEN ( " < " ) ) ||
1371
+ tmp.append (lt ) ||
1378
1372
emit_key_part_element (&tmp, key_part, needs_quotes, 0 , ptr,
1379
1373
part_length))
1380
1374
goto err;
@@ -1384,7 +1378,7 @@ bool ha_federatedx::create_where_from_key(String *to,
1384
1378
case HA_READ_KEY_OR_PREV:
1385
1379
DBUG_PRINT (" info" , (" federatedx HA_READ_KEY_OR_PREV %d" , i));
1386
1380
if (emit_key_part_name (&tmp, key_part) ||
1387
- tmp.append (STRING_WITH_LEN ( " <= " ) ) ||
1381
+ tmp.append (le ) ||
1388
1382
emit_key_part_element (&tmp, key_part, needs_quotes, 0 , ptr,
1389
1383
part_length))
1390
1384
goto err;
@@ -2639,10 +2633,7 @@ int ha_federatedx::index_read_idx_with_result_set(uchar *buf, uint index,
2639
2633
range.key = key;
2640
2634
range.length = key_len;
2641
2635
range.flag = find_flag;
2642
- create_where_from_key (&index_string,
2643
- &table->key_info [index],
2644
- &range,
2645
- NULL , 0 , 0 );
2636
+ create_where_from_key (&index_string, &table->key_info [index], &range, 0 , 0 );
2646
2637
sql_query.append (index_string);
2647
2638
2648
2639
if ((retval= txn->acquire (share, ha_thd (), TRUE , &io)))
@@ -2721,9 +2712,8 @@ int ha_federatedx::read_range_first(const key_range *start_key,
2721
2712
2722
2713
sql_query.length (0 );
2723
2714
sql_query.append (share->select_query );
2724
- create_where_from_key (&sql_query,
2725
- &table->key_info [active_index],
2726
- start_key, end_key, 0 , eq_range_arg);
2715
+ create_where_from_key (&sql_query, &table->key_info [active_index],
2716
+ start_key, end_key, eq_range_arg);
2727
2717
2728
2718
if ((retval= txn->acquire (share, ha_thd (), TRUE , &io)))
2729
2719
DBUG_RETURN (retval);
0 commit comments