~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-proposed

« back to all changes in this revision

Viewing changes to storage/myisam/mi_check.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB
 
1
/*
 
2
   Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
/* Describe, check and repair of MyISAM tables */
17
19
 
85
87
                                          uint buffer_length);
86
88
static ha_checksum mi_byte_checksum(const uchar *buf, uint length);
87
89
static void set_data_file_type(SORT_INFO *sort_info, MYISAM_SHARE *share);
 
90
static HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a);
88
91
 
89
92
void myisamchk_init(MI_CHECK *param)
90
93
{
1741
1744
                             MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
1742
1745
          mi_open_datafile(info,share,name,-1))
1743
1746
        got_error=1;
 
1747
 
 
1748
      param->retry_repair= 0;
1744
1749
    }
1745
1750
  }
1746
1751
  if (got_error)
3908
3913
  SORT_FT_BUF *ft_buf=sort_info->ft_buf;
3909
3914
  SORT_KEY_BLOCKS *key_block=sort_info->key_block;
3910
3915
 
3911
 
  val_len=HA_FT_WLEN+sort_info->info->s->base.rec_reflength;
 
3916
  val_len= HA_FT_WLEN + sort_info->info->s->rec_reflength;
3912
3917
  get_key_full_length_rdonly(a_len, (uchar *)a);
3913
3918
 
3914
3919
  if (!ft_buf)
3918
3923
      and row format is NOT static - for _mi_dpointer not to garble offsets
3919
3924
     */
3920
3925
    if ((sort_info->info->s->base.key_reflength <=
3921
 
         sort_info->info->s->base.rec_reflength) &&
 
3926
         sort_info->info->s->rec_reflength) &&
3922
3927
        (sort_info->info->s->options &
3923
3928
          (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)))
3924
3929
      ft_buf=(SORT_FT_BUF *)my_malloc(sort_param->keyinfo->block_length +
4737
4742
    share->delete_record=tmp.delete_record;
4738
4743
  }
4739
4744
}
 
4745
 
 
4746
/*
 
4747
  Find the first NULL value in index-suffix values tuple
 
4748
 
 
4749
  SYNOPSIS
 
4750
    ha_find_null()
 
4751
      keyseg     Array of keyparts for key suffix
 
4752
      a          Key suffix value tuple
 
4753
 
 
4754
  DESCRIPTION
 
4755
    Find the first NULL value in index-suffix values tuple.
 
4756
    TODO Consider optimizing this fuction or its use so we don't search for
 
4757
         NULL values in completely NOT NULL index suffixes.
 
4758
 
 
4759
  RETURN
 
4760
    First key part that has NULL as value in values tuple, or the last key part 
 
4761
    (with keyseg->type==HA_TYPE_END) if values tuple doesn't contain NULLs.
 
4762
*/
 
4763
 
 
4764
static HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
 
4765
{
 
4766
  for (; (enum ha_base_keytype) keyseg->type != HA_KEYTYPE_END; keyseg++)
 
4767
  {
 
4768
    uchar *end;
 
4769
    if (keyseg->null_bit)
 
4770
    {
 
4771
      if (!*a++)
 
4772
        return keyseg;
 
4773
    }
 
4774
    end= a+ keyseg->length;
 
4775
 
 
4776
   switch ((enum ha_base_keytype) keyseg->type) {
 
4777
    case HA_KEYTYPE_TEXT:
 
4778
    case HA_KEYTYPE_BINARY:
 
4779
    case HA_KEYTYPE_BIT:
 
4780
      if (keyseg->flag & HA_SPACE_PACK)
 
4781
      {
 
4782
        int a_length;
 
4783
        get_key_length(a_length, a);
 
4784
        a += a_length;
 
4785
        break;
 
4786
      }
 
4787
      else
 
4788
        a= end;
 
4789
      break;
 
4790
    case HA_KEYTYPE_VARTEXT1:
 
4791
    case HA_KEYTYPE_VARTEXT2:
 
4792
    case HA_KEYTYPE_VARBINARY1:
 
4793
    case HA_KEYTYPE_VARBINARY2:
 
4794
      {
 
4795
        int a_length;
 
4796
        get_key_length(a_length, a);
 
4797
        a+= a_length;
 
4798
        break;
 
4799
      }
 
4800
    case HA_KEYTYPE_NUM:
 
4801
      if (keyseg->flag & HA_SPACE_PACK)
 
4802
      {
 
4803
        int alength= *a++;
 
4804
        end= a+alength;
 
4805
      }
 
4806
      a= end;
 
4807
      break;
 
4808
    case HA_KEYTYPE_INT8:
 
4809
    case HA_KEYTYPE_SHORT_INT:
 
4810
    case HA_KEYTYPE_USHORT_INT:
 
4811
    case HA_KEYTYPE_LONG_INT:
 
4812
    case HA_KEYTYPE_ULONG_INT:
 
4813
    case HA_KEYTYPE_INT24:
 
4814
    case HA_KEYTYPE_UINT24:
 
4815
#ifdef HAVE_LONG_LONG
 
4816
    case HA_KEYTYPE_LONGLONG:
 
4817
    case HA_KEYTYPE_ULONGLONG:
 
4818
#endif
 
4819
    case HA_KEYTYPE_FLOAT:
 
4820
    case HA_KEYTYPE_DOUBLE:
 
4821
      a= end;
 
4822
      break;
 
4823
    case HA_KEYTYPE_END:                        /* purecov: inspected */
 
4824
      /* keep compiler happy */
 
4825
      DBUG_ASSERT(0);
 
4826
      break;
 
4827
    }
 
4828
  }
 
4829
  return keyseg;
 
4830
}