~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_check.c

  • Committer: Eric Herman
  • Date: 2008-12-06 19:42:46 UTC
  • mto: (656.1.6 devel)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: eric@mysql.com-20081206194246-5cdexuu81i366eek
removed trailing whitespace with simple script:

for file in $(find . -name "*.c") $(find . -name "*.cc") $(find . -name "*.h"); do ruby -pe 'gsub(/\s+$/, $/)' < $file > $file.out; mv $file.out $file; done;

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
    /* Don't count this as a real warning, as check can correct this ! */
121
121
    uint32_t save=param->warning_printed;
122
122
    mi_check_print_warning(param,
123
 
                           share->state.open_count==1 ? 
124
 
                           "%d client is using or hasn't closed the table properly" : 
 
123
                           share->state.open_count==1 ?
 
124
                           "%d client is using or hasn't closed the table properly" :
125
125
                           "%d clients are using or haven't closed the table properly",
126
126
                           share->state.open_count);
127
127
    /* If this will be fixed by the check, forget the warning */
441
441
    found_keys++;
442
442
 
443
443
    param->record_checksum=init_checksum;
444
 
    
 
444
 
445
445
    memset(&param->unique_count, 0, sizeof(param->unique_count));
446
446
    memset(&param->notnull_count, 0, sizeof(param->notnull_count));
447
447
 
547
547
    if (param->testflag & T_STATISTICS)
548
548
      update_key_parts(keyinfo, rec_per_key_part, param->unique_count,
549
549
                       param->stats_method == MI_STATS_METHOD_IGNORE_NULLS?
550
 
                       param->notnull_count: NULL, 
 
550
                       param->notnull_count: NULL,
551
551
                       (uint64_t)info->state->records);
552
552
  }
553
553
  if (param->testflag & T_INFO)
674
674
    1. Find out which prefix tuples of last_key don't contain NULLs, and
675
675
       update the array of notnull counters accordingly.
676
676
    2. Find the first keypart number where the prev_key and last_key tuples
677
 
       are different(A), or last_key has NULL value(B), and return it, so the 
678
 
       caller can count number of unique tuples for each key prefix. We don't 
679
 
       need (B) to be counted, and that is compensated back in 
 
677
       are different(A), or last_key has NULL value(B), and return it, so the
 
678
       caller can count number of unique tuples for each key prefix. We don't
 
679
       need (B) to be counted, and that is compensated back in
680
680
       update_key_parts().
681
681
 
682
682
  RETURN
691
691
  uint32_t first_null_seg, kp;
692
692
  HA_KEYSEG *seg;
693
693
 
694
 
  /* 
 
694
  /*
695
695
     Find the first keypart where values are different or either of them is
696
696
     NULL. We get results in diffs array:
697
697
     diffs[0]= 1 + number of first different keypart
699
699
                      last_key that is NULL or different from corresponding
700
700
                      value in prev_key.
701
701
  */
702
 
  ha_key_cmp(keyseg, prev_key, last_key, USE_WHOLE_KEY, 
 
702
  ha_key_cmp(keyseg, prev_key, last_key, USE_WHOLE_KEY,
703
703
             SEARCH_FIND | SEARCH_NULL_ARE_NOT_EQUAL, diffs);
704
704
  seg= keyseg + diffs[0] - 1;
705
705
 
708
708
  for (kp= 0; kp < first_null_seg; kp++)
709
709
    notnull[kp]++;
710
710
 
711
 
  /* 
 
711
  /*
712
712
    Return 1+ number of first key part where values differ. Don't care if
713
713
    these were NULLs and not .... We compensate for that in
714
714
    update_key_parts.
799
799
                     diff_pos);
800
800
        else if (param->stats_method == MI_STATS_METHOD_IGNORE_NULLS)
801
801
        {
802
 
          diff_pos[0]= mi_collect_stats_nonulls_next(keyinfo->seg, 
 
802
          diff_pos[0]= mi_collect_stats_nonulls_next(keyinfo->seg,
803
803
                                                  param->notnull_count,
804
804
                                                  info->lastkey, key);
805
805
        }
806
806
        param->unique_count[diff_pos[0]-1]++;
807
807
      }
808
808
      else
809
 
      {  
 
809
      {
810
810
        if (param->stats_method == MI_STATS_METHOD_IGNORE_NULLS)
811
811
          mi_collect_stats_nonulls_first(keyinfo->seg, param->notnull_count,
812
812
                                         key);
2144
2144
  sort_param.sort_info=&sort_info;
2145
2145
  sort_param.fix_datafile= (bool) (! rep_quick);
2146
2146
  sort_param.master =1;
2147
 
  
 
2147
 
2148
2148
  del=info->state->del;
2149
2149
  param->glob_crc=0;
2150
2150
  if (param->testflag & T_CALC_CHECKSUM)
3407
3407
                   diff_pos);
3408
3408
    if (param->stats_method == MI_STATS_METHOD_NULLS_NOT_EQUAL)
3409
3409
      ha_key_cmp(sort_param->seg,sort_info->key_block->lastkey,
3410
 
                 (unsigned char*) a, USE_WHOLE_KEY, 
 
3410
                 (unsigned char*) a, USE_WHOLE_KEY,
3411
3411
                 SEARCH_FIND | SEARCH_NULL_ARE_NOT_EQUAL, diff_pos);
3412
3412
    else if (param->stats_method == MI_STATS_METHOD_IGNORE_NULLS)
3413
3413
    {
3954
3954
      !(param->testflag & T_REP))
3955
3955
    printf("Updating MyISAM file: %s\n", param->isam_file_name);
3956
3956
  /*
3957
 
    We have to use an allocated buffer instead of info->rec_buff as 
 
3957
    We have to use an allocated buffer instead of info->rec_buff as
3958
3958
    _mi_put_key_in_record() may use info->rec_buff
3959
3959
  */
3960
3960
  if (!mi_alloc_rec_buff(info, -1, &record))
4002
4002
      records               Number of records in the table
4003
4003
 
4004
4004
  DESCRIPTION
4005
 
    This function is called produce index statistics values from unique and 
 
4005
    This function is called produce index statistics values from unique and
4006
4006
    notnull_tuples arrays after these arrays were produced with sequential
4007
4007
    index scan (the scan is done in two places: chk_index() and
4008
4008
    sort_key_write()).
4016
4016
 
4017
4017
    For MI_STATS_METHOD_IGNORE_NULLS method, notnull_tuples is an array too:
4018
4018
      notnull_tuples[0]= (#of {keypart1} tuples such that keypart1 is not NULL)
4019
 
      notnull_tuples[1]= (#of {keypart1,keypart2} tuples such that all 
 
4019
      notnull_tuples[1]= (#of {keypart1,keypart2} tuples such that all
4020
4020
                          keypart{i} are not NULL)
4021
4021
      ...
4022
4022
    For all other statistics collection methods notnull_tuples==NULL.
4023
4023
 
4024
4024
    Output is an array:
4025
 
    rec_per_key_part[k] = 
4026
 
     = E(#records in the table such that keypart_1=c_1 AND ... AND 
4027
 
         keypart_k=c_k for arbitrary constants c_1 ... c_k) 
4028
 
     
 
4025
    rec_per_key_part[k] =
 
4026
     = E(#records in the table such that keypart_1=c_1 AND ... AND
 
4027
         keypart_k=c_k for arbitrary constants c_1 ... c_k)
 
4028
 
4029
4029
     = {assuming that values have uniform distribution and index contains all
4030
4030
        tuples from the domain (or that {c_1, ..., c_k} tuple is choosen from
4031
4031
        index tuples}
4032
 
     
 
4032
 
4033
4033
     = #tuples-in-the-index / #distinct-tuples-in-the-index.
4034
 
    
4035
 
    The #tuples-in-the-index and #distinct-tuples-in-the-index have different 
 
4034
 
 
4035
    The #tuples-in-the-index and #distinct-tuples-in-the-index have different
4036
4036
    meaning depending on which statistics collection method is used:
4037
 
    
 
4037
 
4038
4038
    MI_STATS_METHOD_*  how are nulls compared?  which tuples are counted?
4039
4039
     NULLS_EQUAL            NULL == NULL           all tuples in table
4040
4040
     NULLS_NOT_EQUAL        NULL != NULL           all tuples in table
4051
4051
  for (parts=0 ; parts < keyinfo->keysegs  ; parts++)
4052
4052
  {
4053
4053
    count+=unique[parts];
4054
 
    unique_tuples= count + 1;    
 
4054
    unique_tuples= count + 1;
4055
4055
    if (notnull)
4056
4056
    {
4057
4057
      tuples= notnull[parts];
4058
 
      /* 
4059
 
        #(unique_tuples not counting tuples with NULLs) = 
4060
 
          #(unique_tuples counting tuples with NULLs as different) - 
 
4058
      /*
 
4059
        #(unique_tuples not counting tuples with NULLs) =
 
4060
          #(unique_tuples counting tuples with NULLs as different) -
4061
4061
          #(tuples with NULLs)
4062
4062
      */
4063
4063
      unique_tuples -= (records - notnull[parts]);
4064
4064
    }
4065
 
    
 
4065
 
4066
4066
    if (unique_tuples == 0)
4067
4067
      tmp= 1;
4068
4068
    else if (count == 0)
4070
4070
    else
4071
4071
      tmp= (tuples + unique_tuples/2) / unique_tuples;
4072
4072
 
4073
 
    /* 
4074
 
      for some weird keys (e.g. FULLTEXT) tmp can be <1 here. 
 
4073
    /*
 
4074
      for some weird keys (e.g. FULLTEXT) tmp can be <1 here.
4075
4075
      let's ensure it is not
4076
4076
    */
4077
4077
    set_if_bigger(tmp,1);