My Project
|
Public Member Functions | |
Field_datetime (uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg) | |
Field_datetime (bool maybe_null_arg, const char *field_name_arg) | |
enum_field_types | type () const |
type_conversion_status | store (longlong nr, bool unsigned_val) |
type_conversion_status | store_packed (longlong nr) |
type_conversion_status | reset (void) |
longlong | val_int (void) |
String * | val_str (String *, String *) |
int | cmp (const uchar *, const uchar *) |
void | make_sort_key (uchar *buff, uint length) |
uint32 | pack_length () const |
void | sql_type (String &str) const |
bool | zero_pack () const |
bool | get_date (MYSQL_TIME *ltime, uint fuzzydate) |
Field_datetime * | clone (MEM_ROOT *mem_root) const |
Field_datetime * | clone () const |
uchar * | pack (uchar *to, const uchar *from, uint max_length __attribute__((unused)), bool low_byte_first) |
const uchar * | unpack (uchar *to, const uchar *from, uint param_data __attribute__((unused)), bool low_byte_first) |
Static Public Attributes | |
static const int | PACK_LENGTH = 8 |
Protected Member Functions | |
type_conversion_status | store_internal (const MYSQL_TIME *ltime, int *error) |
bool | get_date_internal (MYSQL_TIME *ltime) |
ulonglong | date_flags (const THD *thd) |
void | store_timestamp_internal (const struct timeval *tm) |
Field_datetime::Field_datetime | ( | uchar * | ptr_arg, |
uchar * | null_ptr_arg, | ||
uchar | null_bit_arg, | ||
enum utype | unireg_check_arg, | ||
const char * | field_name_arg | ||
) | [inline] |
DATETIME columns can be defined as having CURRENT_TIMESTAMP as the default value on inserts or updates. This constructor accepts a unireg_check value to initialize the column default expressions.
The implementation of function defaults is heavily entangled with the binary .frm file format. The utype
enum
is part of the file format specification but is declared a member of the Field class.
Four distinct unireg_check values are used for DATETIME columns to distinguish various cases of DEFAULT or ON UPDATE values. These values are:
Field_datetime* Field_datetime::clone | ( | MEM_ROOT * | mem_root | ) | const [inline, virtual] |
Makes a shallow copy of the Field object.
mem_root | MEM_ROOT to use for memory allocation. |
NULL | If memory allocation failed. |
Implements Field.
Field_datetime* Field_datetime::clone | ( | ) | const [inline, virtual] |
Makes a shallow copy of the Field object.
NULL | If memory allocation failed. |
Implements Field.
ulonglong Field_datetime::date_flags | ( | const THD * | thd | ) | [protected, virtual] |
Flags that are passed as "flag" argument to check_date(), number_to_datetime(), str_to_datetime().
Flags depend on the session sql_mode settings, such as MODE_NO_ZERO_DATE, MODE_NO_ZERO_IN_DATE. Also, Field_newdate, Field_datetime, Field_datetimef add TIME_FUZZY_DATE to the session sql_mode settings, to allow relaxed date format, while Field_timestamp, Field_timestampf do not.
thd | THD |
sql_mode | flags mixed with the field type flags. |
Reimplemented from Field_temporal.
bool Field_datetime::get_date_internal | ( | MYSQL_TIME * | ltime | ) | [protected, virtual] |
Low level function to get value into MYSQL_TIME, without checking for being valid.
Implements Field_temporal_with_date.
void Field_datetime::make_sort_key | ( | uchar * | buff, |
uint | length | ||
) | [virtual] |
Writes a copy of the current value in the record buffer, suitable for sorting using byte-by-byte comparison. Integers are always in big-endian regardless of hardware architecture. At most length bytes are written into the buffer.
buff | The buffer, assumed to be at least length bytes. |
length | Number of bytes to write. |
Implements Field.
type_conversion_status Field_datetime::store_internal | ( | const MYSQL_TIME * | ltime, |
int * | error | ||
) | [protected, virtual] |
Low level routine to store a MYSQL_TIME value into a field. The value must be already properly rounded or truncated and checked for being a valid TIME/DATE/DATETIME value.
IN | ltime MYSQL_TIME value. |
OUT | error Error flag vector, set in case of error. |
false | In case of success. |
true | In case of error. |
Implements Field_temporal.
type_conversion_status Field_datetime::store_packed | ( | longlong | nr | ) | [virtual] |
Store a temporal value in packed longlong format into a field. The packed value is compatible with TIME_to_longlong_time_packed(), TIME_to_longlong_date_packed() or TIME_to_longlong_datetime_packed(). Note, the value must be properly rounded or truncated according according to field->decimals().
nr | temporal value in packed longlong format. |
false | on success |
true | on error |
Reimplemented from Field.
void Field_datetime::store_timestamp_internal | ( | const struct timeval * | tm | ) | [protected, virtual] |
Store "struct timeval" value into field. The value must be properly rounded or truncated according to the number of fractional second digits.
Implements Field_temporal_with_date_and_time.