~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/time/date.h

  • Committer: Jay Pipes
  • Date: 2008-12-18 15:55:03 UTC
  • mto: This revision was merged to the branch mainline in revision 717.
  • Revision ID: jpipes@serialcoder-20081218155503-u45ygyunrdyyvquq
Fix for Bug#308457.  Gave UTF8 enclosure and escape character on LOAD DATA INFILE and changed the error message to be more descriptive

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
22
22
 
23
23
#include <drizzled/function/func.h>
24
24
#include <drizzled/function/str/strfunc.h>
25
 
#include <drizzled/temporal.h>
26
 
 
27
 
namespace drizzled
28
 
{
29
 
 
30
 
/* A function which evaluates to a Date */
 
25
/*
 
26
  This can't be a Item_str_func, because the val_real() functions are special
 
27
*/
 
28
 
31
29
class Item_date :public Item_func
32
30
{
33
31
public:
34
 
  using Item_func::tmp_table_field;
35
 
 
36
32
  Item_date() :Item_func() {}
37
33
  Item_date(Item *a) :Item_func(a) {}
38
34
  enum Item_result result_type () const { return STRING_RESULT; }
45
41
  {
46
42
    collation.set(&my_charset_bin);
47
43
    decimals=0;
48
 
    max_length=Date::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
 
44
    max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
49
45
  }
50
 
  /**
51
 
   * All functions which inherit from Item_date must implement
52
 
   * their own get_temporal() method, which takes a supplied
53
 
   * Date reference and populates it with a correct
54
 
   * date based on the semantics of the function.
55
 
   *
56
 
   * Returns whether the function was able to correctly fill
57
 
   * the supplied date temporal with a proper date.
58
 
   *
59
 
   * @param Reference to a Date to populate
60
 
   */
61
 
  virtual bool get_temporal(Date &temporal)= 0;
62
46
  Field *tmp_table_field(Table *table)
63
47
  {
64
48
    return tmp_table_field_from_field_type(table, 0);
65
49
  }
66
50
  bool result_as_int64_t() { return true; }
67
 
  type::Decimal *val_decimal(type::Decimal *decimal_value)
 
51
  my_decimal *val_decimal(my_decimal *decimal_value)
68
52
  {
69
53
    assert(fixed == 1);
70
54
    return  val_decimal_from_date(decimal_value);
71
55
  }
72
56
  int save_in_field(Field *field,
73
 
                    bool )
 
57
                    bool no_conversions __attribute__((unused)))
74
58
  {
75
59
    return save_date_in_field(field);
76
60
  }
84
68
  Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {}
85
69
  Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {}
86
70
  enum_field_types field_type() const { return DRIZZLE_TYPE_DATETIME; }
87
 
 
88
 
  using Item_func::tmp_table_field;
89
71
  Field *tmp_table_field(Table *table)
90
72
  {
91
73
    return tmp_table_field_from_field_type(table, 0);
92
74
  }
93
75
  bool result_as_int64_t() { return true; }
94
76
  double val_real() { return (double) val_int(); }
95
 
  type::Decimal *val_decimal(type::Decimal *decimal_value)
 
77
  my_decimal *val_decimal(my_decimal *decimal_value)
96
78
  {
97
79
    assert(fixed == 1);
98
80
    return  val_decimal_from_date(decimal_value);
99
81
  }
100
82
  int save_in_field(Field *field,
101
 
                    bool )
 
83
                    bool no_conversions __attribute__((unused)))
102
84
  {
103
85
    return save_date_in_field(field);
104
86
  }
105
87
};
106
88
 
107
 
} /* namespace drizzled */
108
 
 
109
89
#endif /* DRIZZLED_FUNCTION_TIME_DATE_H */