~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/ha_myisam.cc

Merged trunk, fixed some leftover InnoDB ICP code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1278
1278
  return mi_delete(file,buf);
1279
1279
}
1280
1280
 
1281
 
#ifdef __cplusplus
1282
 
extern "C" {
1283
 
#endif
1284
 
 
1285
 
bool index_cond_func_myisam(void *arg)
1286
 
{
1287
 
  ha_myisam *h= (ha_myisam*)arg;
1288
 
  /*if (h->in_range_read)*/
1289
 
  if (h->end_range)
1290
 
  {
1291
 
    if (h->compare_key2(h->end_range) > 0)
1292
 
      return 2; /* caller should return HA_ERR_END_OF_FILE already */
1293
 
  }
1294
 
  return (bool)h->pushed_idx_cond->val_int();
1295
 
}
1296
 
 
1297
 
#ifdef __cplusplus
1298
 
}
1299
 
#endif
1300
 
 
1301
1281
 
1302
1282
int ha_myisam::index_init(uint32_t idx, bool )
1303
1283
{
1304
1284
  active_index=idx;
1305
1285
  //in_range_read= false;
1306
 
  if (pushed_idx_cond_keyno == idx)
1307
 
    mi_set_index_cond_func(file, index_cond_func_myisam, this);
1308
1286
  return 0;
1309
1287
}
1310
1288
 
1312
1290
int ha_myisam::index_end()
1313
1291
{
1314
1292
  active_index=MAX_KEY;
1315
 
  //pushed_idx_cond_keyno= MAX_KEY;
1316
 
  mi_set_index_cond_func(file, NULL, 0);
1317
 
  in_range_check_pushed_down= false;
1318
1293
  return 0;
1319
1294
}
1320
1295
 
1502
1477
    if (share->tmp_table == NO_TMP_TABLE)
1503
1478
      pthread_mutex_lock(&share->mutex);
1504
1479
    set_prefix(share->keys_in_use, share->keys);
1505
 
    share->keys_in_use&= misam_info.key_map;
 
1480
    /*
 
1481
     * Due to bug 394932 (32-bit solaris build failure), we need
 
1482
     * to convert the uint64_t key_map member of the misam_info
 
1483
     * structure in to a std::bitset so that we can logically and
 
1484
     * it with the share->key_in_use key_map.
 
1485
     */
 
1486
    ostringstream ostr;
 
1487
    string binary_key_map;
 
1488
    uint64_t num= misam_info.key_map;
 
1489
    /*
 
1490
     * Convert the uint64_t to a binary
 
1491
     * string representation of it.
 
1492
     */
 
1493
    while (num > 0)
 
1494
    {
 
1495
      uint64_t bin_digit= num % 2;
 
1496
      ostr << bin_digit;
 
1497
      num/= 2;
 
1498
    }
 
1499
    binary_key_map.append(ostr.str());
 
1500
    /*
 
1501
     * Now we have the binary string representation of the
 
1502
     * flags, we need to fill that string representation out
 
1503
     * with the appropriate number of bits. This is needed
 
1504
     * since key_map is declared as a std::bitset of a certain bit
 
1505
     * width that depends on the MAX_INDEXES variable. 
 
1506
     */
 
1507
    if (MAX_INDEXES <= 64)
 
1508
    {
 
1509
      size_t len= 72 - binary_key_map.length();
 
1510
      string all_zeros(len, '0');
 
1511
      binary_key_map.insert(binary_key_map.begin(),
 
1512
                            all_zeros.begin(),
 
1513
                            all_zeros.end());
 
1514
    }
 
1515
    else
 
1516
    {
 
1517
      size_t len= (MAX_INDEXES + 7) / 8 * 8;
 
1518
      string all_zeros(len, '0');
 
1519
      binary_key_map.insert(binary_key_map.begin(),
 
1520
                            all_zeros.begin(),
 
1521
                            all_zeros.end());
 
1522
    }
 
1523
    key_map tmp_map(binary_key_map);
 
1524
    share->keys_in_use&= tmp_map;
1506
1525
    share->keys_for_keyread&= share->keys_in_use;
1507
1526
    share->db_record_offset= misam_info.record_offset;
1508
1527
    if (share->key_parts)
1547
1566
 
1548
1567
int ha_myisam::reset(void)
1549
1568
{
1550
 
  pushed_idx_cond= NULL;
1551
 
  pushed_idx_cond_keyno= MAX_KEY;
1552
 
  mi_set_index_cond_func(file, NULL, 0);
1553
1569
  return mi_reset(file);
1554
1570
}
1555
1571
 
1780
1796
  return mi_panic(HA_PANIC_CLOSE);
1781
1797
}
1782
1798
 
1783
 
 
1784
 
/* Index condition pushdown implementation*/
1785
 
 
1786
 
 
1787
 
Item *ha_myisam::idx_cond_push(uint32_t keyno_arg, Item* idx_cond_arg)
1788
 
{
1789
 
  pushed_idx_cond_keyno= keyno_arg;
1790
 
  pushed_idx_cond= idx_cond_arg;
1791
 
  in_range_check_pushed_down= true;
1792
 
  if (active_index == pushed_idx_cond_keyno)
1793
 
    mi_set_index_cond_func(file, index_cond_func_myisam, this);
1794
 
  return NULL;
1795
 
}
1796
 
 
1797
1799
static DRIZZLE_SYSVAR_UINT(block_size, block_size,
1798
1800
                           PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
1799
1801
                           N_("Block size to be used for MyISAM index pages."),