~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/string.h

  • Committer: Jay Pipes
  • Date: 2009-01-30 04:01:12 UTC
  • mto: This revision was merged to the branch mainline in revision 830.
  • Revision ID: jpipes@serialcoder-20090130040112-svbn774guj98pwi4
To remain in compatibility with MySQL, added ability to interpret
decimal arguments as datetime strings for temporal functions.

Fixed YEAR(), MONTH(), DAYOFMONTH(), DAYOFYEAR(), HOUR(), MINUTE(), SECOND(), and MICROSECOND()
to accept decimal parameters and interpret them the same way as MySQL.

Fixed an issue with the TemporalFormat::matches() method which was 
incorrectly assuming all microsecond arguments were specified as 6 digits.
Added power of 10 multiplier to usecond calculation. This fixes issues with
failures in type_date and func_sapdb test cases.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_ITEM_STRING_H
21
 
#define DRIZZLED_ITEM_STRING_H
 
20
#ifndef DRIZZLED_ITEM_ITEM_STRING_H
 
21
#define DRIZZLED_ITEM_ITEM_STRING_H
22
22
 
23
23
#include <drizzled/item/basic_constant.h>
24
24
 
25
 
namespace drizzled
26
 
{
27
 
 
28
25
class Item_string :public Item_basic_constant
29
26
{
30
27
public:
31
28
  Item_string(const char *str,uint32_t length,
32
 
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE)
 
29
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
 
30
              uint32_t repertoire= MY_REPERTOIRE_UNICODE30)
33
31
    : m_cs_specified(false)
34
32
  {
35
33
    str_value.set_or_copy_aligned(str, length, cs);
36
 
    collation.set(cs, dv);
 
34
    collation.set(cs, dv, repertoire);
37
35
    /*
38
36
      We have to have a different max_length than 'length' here to
39
37
      ensure that we get the right length if we do use the item
40
38
      to create a new table. In this case max_length must be the maximum
41
 
      number of chars for a string of this type because we in CreateField::
 
39
      number of chars for a string of this type because we in Create_field::
42
40
      divide the max_length with mbmaxlen).
43
41
    */
44
42
    max_length= str_value.numchars()*cs->mbmaxlen;
58
56
    fixed= 1;
59
57
  }
60
58
  Item_string(const char *name_par, const char *str, uint32_t length,
61
 
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE)
 
59
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
 
60
              uint32_t repertoire= MY_REPERTOIRE_UNICODE30)
62
61
    : m_cs_specified(false)
63
62
  {
64
63
    str_value.set_or_copy_aligned(str, length, cs);
65
 
    collation.set(cs, dv);
 
64
    collation.set(cs, dv, repertoire);
66
65
    max_length= str_value.numchars()*cs->mbmaxlen;
67
66
    set_name(name_par, 0, cs);
68
67
    decimals=NOT_FIXED_DEC;
69
68
    // it is constant => can be used without fix_fields (and frequently used)
70
69
    fixed= 1;
71
70
  }
 
71
  void set_repertoire_from_value()
 
72
  {
 
73
    collation.repertoire= my_string_repertoire(str_value.charset(),
 
74
                                               str_value.ptr(),
 
75
                                               str_value.length());
 
76
  }
72
77
  enum Type type() const { return STRING_ITEM; }
73
78
  double val_real();
74
79
  int64_t val_int();
134
139
  {
135
140
    m_cs_specified= cs_specified;
136
141
  }
 
142
  bool check_vcol_func_processor(unsigned char *)
 
143
  { return false; }
137
144
 
138
145
private:
139
146
  bool m_cs_specified;
155
162
  {
156
163
    str->append(func_name);
157
164
  }
 
165
  bool check_vcol_func_processor(unsigned char *)
 
166
  { return true; }
158
167
};
159
168
 
160
 
} /* namespace drizzled */
161
 
 
162
 
#endif /* DRIZZLED_ITEM_STRING_H */
 
169
#endif /* DRIZZLED_ITEM_ITEM_STRING_H */