~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/num.cc

  • Committer: Stewart Smith
  • Author(s): Marko Mäkelä, Stewart Smith
  • Date: 2010-11-17 05:52:09 UTC
  • mto: (2021.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1971.
  • Revision ID: stewart@flamingspork.com-20101117055209-69m035q6h7e1txrc
Merge Revision revid:marko.makela@oracle.com-20100629113248-fvl48lnzr44z94gg from MySQL InnoDB

Original revid:marko.makela@oracle.com-20100629113248-fvl48lnzr44z94gg

Original Authors: Marko Mkel <marko.makela@oracle.com>
Original commit message:
Bug#52199 utf32: mbminlen=4, mbmaxlen=4, type->mbminlen=0, type->mbmaxlen=4

Merge and adjust a forgotten change to fix this bug.
rb://393 approved by Jimmy Yang
  ------------------------------------------------------------------------
  r3794 | marko | 2009-01-07 14:14:53 +0000 (Wed, 07 Jan 2009) | 18 lines

  branches/6.0: Allow the minimum length of a multi-byte character to be
  up to 4 bytes. (Bug #35391)

  dtype_t, dict_col_t: Replace mbminlen:2, mbmaxlen:3 with mbminmaxlen:5.
  In this way, the 5 bits can hold two values of 0..4, and the storage size
  of the fields will not cross the 64-bit boundary.  Encode the values as
  DATA_MBMAX * mbmaxlen + mbminlen.  Define the auxiliary macros
  DB_MBMINLEN(mbminmaxlen), DB_MBMAXLEN(mbminmaxlen), and
  DB_MINMAXLEN(mbminlen, mbmaxlen).

  Try to trim and pad UTF-16 and UTF-32 with spaces as appropriate.

  Alexander Barkov suggested the use of cs->cset->fill(cs, buff, len, 0x20).
  ha_innobase::store_key_val_for_row() now does that, but the added function
  row_mysql_pad_col() does not, because it doesn't have the MySQL TABLE object.

  rb://49 approved by Heikki Tuuri
  ------------------------------------------------------------------------

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
/**
33
33
  Numeric fields base class constructor.
34
34
*/
35
 
Field_num::Field_num(unsigned char *ptr_arg,
36
 
                     uint32_t len_arg,
37
 
                     unsigned char *null_ptr_arg,
38
 
                     unsigned char null_bit_arg,
39
 
                     utype unireg_check_arg,
 
35
Field_num::Field_num(unsigned char *ptr_arg,uint32_t len_arg, unsigned char *null_ptr_arg,
 
36
                     unsigned char null_bit_arg, utype unireg_check_arg,
40
37
                     const char *field_name_arg,
41
 
                     uint8_t dec_arg,
42
 
                     bool zero_arg,
43
 
                     bool unsigned_arg) :
44
 
  Field(ptr_arg,
45
 
        len_arg,
46
 
        null_ptr_arg,
47
 
        null_bit_arg,
48
 
        unireg_check_arg,
49
 
        field_name_arg),
50
 
  dec(dec_arg),
51
 
  decimal_precision(zero_arg),
52
 
  unsigned_flag(unsigned_arg)
53
 
  {
 
38
                     uint8_t dec_arg, bool zero_arg, bool unsigned_arg)
 
39
  :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
 
40
         unireg_check_arg, field_name_arg),
 
41
  dec(dec_arg),decimal_precision(zero_arg), unsigned_flag(unsigned_arg)
 
42
{
54
43
}
55
44
 
56
45
 
146
135
  if (getTable()->in_use->count_cuted_fields &&
147
136
      check_int(cs, from, len, end, error))
148
137
    return 1;
149
 
 
150
138
  return 0;
151
139
 
152
140
out_of_range:
168
156
    !=0  error
169
157
*/
170
158
 
171
 
int Field_num::store_decimal(const type::Decimal *val)
 
159
int Field_num::store_decimal(const my_decimal *val)
172
160
{
173
161
  int err= 0;
174
162
  int64_t i= convert_decimal2int64_t(val, false, &err);
189
177
    pointer to decimal buffer with value of field
190
178
*/
191
179
 
192
 
type::Decimal* Field_num::val_decimal(type::Decimal *decimal_value)
 
180
my_decimal* Field_num::val_decimal(my_decimal *decimal_value)
193
181
{
194
182
  assert(result_type() == INT_RESULT);
195
183
 
196
184
  int64_t nr= val_int();
197
 
  int2_class_decimal(E_DEC_FATAL_ERROR, nr, false, decimal_value);
 
185
  int2my_decimal(E_DEC_FATAL_ERROR, nr, false, decimal_value);
198
186
  return decimal_value;
199
187
}
200
188