~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handler.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
                               tx_isolation_names, NULL};
66
66
 
67
67
static TYPELIB known_extensions= {0,"known_exts", NULL, NULL};
68
 
uint known_extensions_id= 0;
 
68
uint32_t known_extensions_id= 0;
69
69
 
70
70
 
71
71
 
367
367
    break;
368
368
  case SHOW_OPTION_YES:
369
369
    {
370
 
      uint tmp;
 
370
      uint32_t tmp;
371
371
      /* now check the db_type for conflict */
372
372
      if (hton->db_type <= DB_TYPE_UNKNOWN ||
373
373
          hton->db_type >= DB_TYPE_DEFAULT ||
1649
1649
struct Ha_delete_table_error_handler: public Internal_error_handler
1650
1650
{
1651
1651
public:
1652
 
  virtual bool handle_error(uint sql_errno,
 
1652
  virtual bool handle_error(uint32_t sql_errno,
1653
1653
                            const char *message,
1654
1654
                            DRIZZLE_ERROR::enum_warning_level level,
1655
1655
                            THD *thd);
1659
1659
 
1660
1660
bool
1661
1661
Ha_delete_table_error_handler::
1662
 
handle_error(uint sql_errno  __attribute__((unused)),
 
1662
handle_error(uint32_t sql_errno  __attribute__((unused)),
1663
1663
             const char *message,
1664
1664
             DRIZZLE_ERROR::enum_warning_level level __attribute__((unused)),
1665
1665
             THD *thd __attribute__((unused)))
1843
1843
  This is never called for InnoDB tables, as these table types
1844
1844
  has the HA_STATS_RECORDS_IS_EXACT set.
1845
1845
*/
1846
 
int handler::read_first_row(unsigned char * buf, uint primary_key)
 
1846
int handler::read_first_row(unsigned char * buf, uint32_t primary_key)
1847
1847
{
1848
1848
  register int error;
1849
1849
 
2059
2059
        handler::estimation_rows_to_insert was set by
2060
2060
        handler::ha_start_bulk_insert(); if 0 it means "unknown".
2061
2061
      */
2062
 
      uint nb_already_reserved_intervals=
 
2062
      uint32_t nb_already_reserved_intervals=
2063
2063
        thd->auto_inc_intervals_in_cur_stmt_for_binlog.nb_elements();
2064
2064
      uint64_t nb_desired_values;
2065
2065
      /*
2266
2266
}
2267
2267
 
2268
2268
 
2269
 
void handler::print_keydup_error(uint key_nr, const char *msg)
 
2269
void handler::print_keydup_error(uint32_t key_nr, const char *msg)
2270
2270
{
2271
2271
  /* Write the duplicated key in the error message */
2272
2272
  char key[MAX_KEY_LENGTH];
2282
2282
  {
2283
2283
    /* Table is opened and defined at this point */
2284
2284
    key_unpack(&str,table,(uint) key_nr);
2285
 
    uint max_length=DRIZZLE_ERRMSG_SIZE-(uint) strlen(msg);
 
2285
    uint32_t max_length=DRIZZLE_ERRMSG_SIZE-(uint) strlen(msg);
2286
2286
    if (str.length() >= max_length)
2287
2287
    {
2288
2288
      str.length(max_length-4);
2326
2326
    break;
2327
2327
  case HA_ERR_FOUND_DUPP_KEY:
2328
2328
  {
2329
 
    uint key_nr=get_dup_key(error);
 
2329
    uint32_t key_nr=get_dup_key(error);
2330
2330
    if ((int) key_nr >= 0)
2331
2331
    {
2332
2332
      print_keydup_error(key_nr, ER(ER_DUP_ENTRY_WITH_KEY_NAME));
2337
2337
  }
2338
2338
  case HA_ERR_FOREIGN_DUPLICATE_KEY:
2339
2339
  {
2340
 
    uint key_nr= get_dup_key(error);
 
2340
    uint32_t key_nr= get_dup_key(error);
2341
2341
    if ((int) key_nr >= 0)
2342
2342
    {
2343
 
      uint max_length;
 
2343
      uint32_t max_length;
2344
2344
      /* Write the key in the error message */
2345
2345
      char key[MAX_KEY_LENGTH];
2346
2346
      String str(key,sizeof(key),system_charset_info);
2439
2439
  case HA_ERR_DROP_INDEX_FK:
2440
2440
  {
2441
2441
    const char *ptr= "???";
2442
 
    uint key_nr= get_dup_key(error);
 
2442
    uint32_t key_nr= get_dup_key(error);
2443
2443
    if ((int) key_nr >= 0)
2444
2444
      ptr= table->key_info[key_nr].name;
2445
2445
    my_error(ER_DROP_INDEX_FK, MYF(0), ptr);
2563
2563
  {
2564
2564
    unsigned char version[4];
2565
2565
    char *key= table->s->table_cache_key.str;
2566
 
    uint key_length= table->s->table_cache_key.length;
 
2566
    uint32_t key_length= table->s->table_cache_key.length;
2567
2567
    Table *entry;
2568
2568
    HASH_SEARCH_STATE state;
2569
2569
 
2592
2592
  @return
2593
2593
    key if error because of duplicated keys
2594
2594
*/
2595
 
uint handler::get_dup_key(int error)
 
2595
uint32_t handler::get_dup_key(int error)
2596
2596
{
2597
2597
  table->file->errkey  = (uint) -1;
2598
2598
  if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY ||
2758
2758
 
2759
2759
int
2760
2760
handler::ha_bulk_update_row(const unsigned char *old_data, unsigned char *new_data,
2761
 
                            uint *dup_key_found)
 
2761
                            uint32_t *dup_key_found)
2762
2762
{
2763
2763
  mark_trx_read_write();
2764
2764
 
2848
2848
*/
2849
2849
 
2850
2850
int
2851
 
handler::ha_disable_indexes(uint mode)
 
2851
handler::ha_disable_indexes(uint32_t mode)
2852
2852
{
2853
2853
  mark_trx_read_write();
2854
2854
 
2863
2863
*/
2864
2864
 
2865
2865
int
2866
 
handler::ha_enable_indexes(uint mode)
 
2866
handler::ha_enable_indexes(uint32_t mode)
2867
2867
{
2868
2868
  mark_trx_read_write();
2869
2869
 
3005
3005
  return(error);
3006
3006
}
3007
3007
 
3008
 
int handler::index_next_same(unsigned char *buf, const unsigned char *key, uint keylen)
 
3008
int handler::index_next_same(unsigned char *buf, const unsigned char *key, uint32_t keylen)
3009
3009
{
3010
3010
  int error;
3011
3011
  if (!(error=index_next(buf)))
3192
3192
  {
3193
3193
    pthread_mutex_lock(&LOCK_global_system_variables);
3194
3194
    uint32_t tmp_buff_size= (uint32_t) key_cache->param_buff_size;
3195
 
    uint tmp_block_size= (uint) key_cache->param_block_size;
3196
 
    uint division_limit= key_cache->param_division_limit;
3197
 
    uint age_threshold=  key_cache->param_age_threshold;
 
3195
    uint32_t tmp_block_size= (uint) key_cache->param_block_size;
 
3196
    uint32_t division_limit= key_cache->param_division_limit;
 
3197
    uint32_t age_threshold=  key_cache->param_age_threshold;
3198
3198
    pthread_mutex_unlock(&LOCK_global_system_variables);
3199
3199
    return(!init_key_cache(key_cache,
3200
3200
                                tmp_block_size,
3215
3215
    pthread_mutex_lock(&LOCK_global_system_variables);
3216
3216
    long tmp_buff_size= (long) key_cache->param_buff_size;
3217
3217
    long tmp_block_size= (long) key_cache->param_block_size;
3218
 
    uint division_limit= key_cache->param_division_limit;
3219
 
    uint age_threshold=  key_cache->param_age_threshold;
 
3218
    uint32_t division_limit= key_cache->param_division_limit;
 
3219
    uint32_t age_threshold=  key_cache->param_age_threshold;
3220
3220
    pthread_mutex_unlock(&LOCK_global_system_variables);
3221
3221
    return(!resize_key_cache(key_cache, tmp_block_size,
3222
3222
                                  tmp_buff_size,
3234
3234
  if (key_cache->key_cache_inited)
3235
3235
  {
3236
3236
    pthread_mutex_lock(&LOCK_global_system_variables);
3237
 
    uint division_limit= key_cache->param_division_limit;
3238
 
    uint age_threshold=  key_cache->param_age_threshold;
 
3237
    uint32_t division_limit= key_cache->param_division_limit;
 
3238
    uint32_t age_threshold=  key_cache->param_age_threshold;
3239
3239
    pthread_mutex_unlock(&LOCK_global_system_variables);
3240
3240
    change_key_cache_param(key_cache, division_limit, age_threshold);
3241
3241
  }
3390
3390
    Estimated cost of 'index only' scan
3391
3391
*/
3392
3392
 
3393
 
double handler::index_only_read_time(uint keynr, double records)
 
3393
double handler::index_only_read_time(uint32_t keynr, double records)
3394
3394
{
3395
3395
  double read_time;
3396
 
  uint keys_per_block= (stats.block_size/2/
 
3396
  uint32_t keys_per_block= (stats.block_size/2/
3397
3397
                        (table->key_info[keynr].key_length + ref_length) + 1);
3398
3398
  read_time=((double) (records + keys_per_block-1) /
3399
3399
             (double) keys_per_block);
3437
3437
*/
3438
3438
 
3439
3439
ha_rows
3440
 
handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
 
3440
handler::multi_range_read_info_const(uint32_t keyno, RANGE_SEQ_IF *seq,
3441
3441
                                     void *seq_init_param,
3442
 
                                     uint n_ranges_arg __attribute__((unused)),
3443
 
                                     uint *bufsz, uint *flags, COST_VECT *cost)
 
3442
                                     uint32_t n_ranges_arg __attribute__((unused)),
 
3443
                                     uint32_t *bufsz, uint32_t *flags, COST_VECT *cost)
3444
3444
{
3445
3445
  KEY_MULTI_RANGE range;
3446
3446
  range_seq_t seq_it;
3447
3447
  ha_rows rows, total_rows= 0;
3448
 
  uint n_ranges=0;
 
3448
  uint32_t n_ranges=0;
3449
3449
  THD *thd= current_thd;
3450
3450
  
3451
3451
  /* Default MRR implementation doesn't need buffer */
3528
3528
    other Error or can't perform the requested scan
3529
3529
*/
3530
3530
 
3531
 
int handler::multi_range_read_info(uint keyno, uint n_ranges, uint n_rows,
3532
 
                                   uint *bufsz, uint *flags, COST_VECT *cost)
 
3531
int handler::multi_range_read_info(uint32_t keyno, uint32_t n_ranges, uint32_t n_rows,
 
3532
                                   uint32_t *bufsz, uint32_t *flags, COST_VECT *cost)
3533
3533
{
3534
3534
  *bufsz= 0; /* Default implementation doesn't need a buffer */
3535
3535
 
3590
3590
 
3591
3591
int
3592
3592
handler::multi_range_read_init(RANGE_SEQ_IF *seq_funcs, void *seq_init_param,
3593
 
                               uint n_ranges, uint mode,
 
3593
                               uint32_t n_ranges, uint32_t mode,
3594
3594
                               HANDLER_BUFFER *buf __attribute__((unused)))
3595
3595
{
3596
3596
  mrr_iter= seq_funcs->init(seq_init_param, n_ranges, mode);
3692
3692
 
3693
3693
int DsMrr_impl::dsmrr_init(handler *h, KEY *key,
3694
3694
                           RANGE_SEQ_IF *seq_funcs, void *seq_init_param,
3695
 
                           uint n_ranges, uint mode, HANDLER_BUFFER *buf)
 
3695
                           uint32_t n_ranges, uint32_t mode, HANDLER_BUFFER *buf)
3696
3696
{
3697
 
  uint elem_size;
3698
 
  uint keyno;
 
3697
  uint32_t elem_size;
 
3698
  uint32_t keyno;
3699
3699
  Item *pushed_cond= NULL;
3700
3700
  handler *new_h2;
3701
3701
  keyno= h->active_index;
3834
3834
  dsmrr_eof= test(res == HA_ERR_END_OF_FILE);
3835
3835
 
3836
3836
  /* Sort the buffer contents by rowid */
3837
 
  uint elem_size= h->ref_length + (int)is_mrr_assoc * sizeof(void*);
3838
 
  uint n_rowids= (rowids_buf_cur - rowids_buf) / elem_size;
 
3837
  uint32_t elem_size= h->ref_length + (int)is_mrr_assoc * sizeof(void*);
 
3838
  uint32_t n_rowids= (rowids_buf_cur - rowids_buf) / elem_size;
3839
3839
  
3840
3840
  my_qsort2(rowids_buf, n_rowids, elem_size, (qsort2_cmp)rowid_cmp,
3841
3841
            (void*)h);
3893
3893
/**
3894
3894
  DS-MRR implementation: multi_range_read_info() function
3895
3895
*/
3896
 
int DsMrr_impl::dsmrr_info(uint keyno, uint n_ranges, uint rows, uint *bufsz,
3897
 
                           uint *flags, COST_VECT *cost)
 
3896
int DsMrr_impl::dsmrr_info(uint32_t keyno, uint32_t n_ranges, uint32_t rows, uint32_t *bufsz,
 
3897
                           uint32_t *flags, COST_VECT *cost)
3898
3898
{  
3899
3899
  int res;
3900
 
  uint def_flags= *flags;
3901
 
  uint def_bufsz= *bufsz;
 
3900
  uint32_t def_flags= *flags;
 
3901
  uint32_t def_bufsz= *bufsz;
3902
3902
 
3903
3903
  /* Get cost/flags/mem_usage of default MRR implementation */
3904
3904
  res= h->handler::multi_range_read_info(keyno, n_ranges, rows, &def_bufsz,
3920
3920
  DS-MRR Implementation: multi_range_read_info_const() function
3921
3921
*/
3922
3922
 
3923
 
ha_rows DsMrr_impl::dsmrr_info_const(uint keyno, RANGE_SEQ_IF *seq,
3924
 
                                 void *seq_init_param, uint n_ranges, 
3925
 
                                 uint *bufsz, uint *flags, COST_VECT *cost)
 
3923
ha_rows DsMrr_impl::dsmrr_info_const(uint32_t keyno, RANGE_SEQ_IF *seq,
 
3924
                                 void *seq_init_param, uint32_t n_ranges, 
 
3925
                                 uint32_t *bufsz, uint32_t *flags, COST_VECT *cost)
3926
3926
{
3927
3927
  ha_rows rows;
3928
 
  uint def_flags= *flags;
3929
 
  uint def_bufsz= *bufsz;
 
3928
  uint32_t def_flags= *flags;
 
3929
  uint32_t def_bufsz= *bufsz;
3930
3930
  /* Get cost/flags/mem_usage of default MRR implementation */
3931
3931
  rows= h->handler::multi_range_read_info_const(keyno, seq, seq_init_param,
3932
3932
                                                n_ranges, &def_bufsz, 
3974
3974
  @retval false  No
3975
3975
*/
3976
3976
 
3977
 
bool DsMrr_impl::key_uses_partial_cols(uint keyno)
 
3977
bool DsMrr_impl::key_uses_partial_cols(uint32_t keyno)
3978
3978
{
3979
3979
  KEY_PART_INFO *kp= table->key_info[keyno].key_part;
3980
3980
  KEY_PART_INFO *kp_end= kp + table->key_info[keyno].key_parts;
4010
4010
  @retval false  DS-MRR implementation should be used
4011
4011
*/
4012
4012
 
4013
 
bool DsMrr_impl::choose_mrr_impl(uint keyno, ha_rows rows, uint *flags,
4014
 
                                 uint *bufsz, COST_VECT *cost)
 
4013
bool DsMrr_impl::choose_mrr_impl(uint32_t keyno, ha_rows rows, uint32_t *flags,
 
4014
                                 uint32_t *bufsz, COST_VECT *cost)
4015
4015
{
4016
4016
  COST_VECT dsmrr_cost;
4017
4017
  bool res;
4027
4027
    return true;
4028
4028
  }
4029
4029
  
4030
 
  uint add_len= table->key_info[keyno].key_length + h->ref_length; 
 
4030
  uint32_t add_len= table->key_info[keyno].key_length + h->ref_length; 
4031
4031
  *bufsz -= add_len;
4032
4032
  if (get_disk_sweep_mrr_cost(keyno, rows, *flags, bufsz, &dsmrr_cost))
4033
4033
    return true;
4077
4077
                 for even 1 rowid)
4078
4078
*/
4079
4079
 
4080
 
bool DsMrr_impl::get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags,
4081
 
                                         uint *buffer_size, COST_VECT *cost)
 
4080
bool DsMrr_impl::get_disk_sweep_mrr_cost(uint32_t keynr, ha_rows rows, uint32_t flags,
 
4081
                                         uint32_t *buffer_size, COST_VECT *cost)
4082
4082
{
4083
4083
  uint32_t max_buff_entries, elem_size;
4084
4084
  ha_rows rows_in_full_step, rows_in_last_step;
4085
 
  uint n_full_steps;
 
4085
  uint32_t n_full_steps;
4086
4086
  double index_read_cost;
4087
4087
 
4088
4088
  elem_size= h->ref_length + sizeof(void*) * (!test(flags & HA_MRR_NO_ASSOCIATION));
4368
4368
  return cmp;
4369
4369
}
4370
4370
 
4371
 
int handler::index_read_idx_map(unsigned char * buf, uint index, const unsigned char * key,
 
4371
int handler::index_read_idx_map(unsigned char * buf, uint32_t index, const unsigned char * key,
4372
4372
                                key_part_map keypart_map,
4373
4373
                                enum ha_rkey_function find_flag)
4374
4374
{
4452
4452
}
4453
4453
 
4454
4454
 
4455
 
static bool stat_print(THD *thd, const char *type, uint type_len,
4456
 
                       const char *file, uint file_len,
4457
 
                       const char *status, uint status_len)
 
4455
static bool stat_print(THD *thd, const char *type, uint32_t type_len,
 
4456
                       const char *file, uint32_t file_len,
 
4457
                       const char *status, uint32_t status_len)
4458
4458
{
4459
4459
  Protocol *protocol= thd->protocol;
4460
4460
  protocol->prepare_for_resend();
4547
4547
    locks[0]= thd->extra_lock;
4548
4548
    locks[1]= thd->lock;
4549
4549
    locks[2]= thd->locked_tables;
4550
 
    for (uint i= 0 ; i < sizeof(locks)/sizeof(*locks) ; ++i )
 
4550
    for (uint32_t i= 0 ; i < sizeof(locks)/sizeof(*locks) ; ++i )
4551
4551
    {
4552
4552
      DRIZZLE_LOCK const *const lock= locks[i];
4553
4553
      if (lock == NULL)