MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Field_temporal Class Reference
Inheritance diagram for Field_temporal:
Collaboration diagram for Field_temporal:

Public Member Functions

 Field_temporal (uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, uint32 len_arg, uint8 dec_arg)
 Field_temporal (bool maybe_null_arg, const char *field_name_arg, uint32 len_arg, uint8 dec_arg)
virtual Item_result result_type () const
virtual uint32 max_display_length ()
virtual bool str_needs_quotes ()
virtual uint is_equal (Create_field *new_field)
Item_result numeric_context_result_type () const
enum Item_result cmp_type () const
enum Derivation derivation () const
uint repertoire () const
const CHARSET_INFOcharset () const
bool can_be_compared_as_longlong () const
bool binary () const
type_conversion_status store (const char *str, uint len, const CHARSET_INFO *cs)
type_conversion_status store_decimal (const my_decimal *decimal)
type_conversion_status store (longlong nr, bool unsigned_val)
type_conversion_status store (double nr)
double val_real ()
my_decimalval_decimal (my_decimal *decimal_value)
- Public Member Functions inherited from Field
bool has_insert_default_function () const
bool has_update_default_function () const
 Field (uchar *ptr_arg, uint32 length_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg)
 This is used as a table name when the table structure is not set up.
virtual type_conversion_status store_packed (longlong nr)
virtual type_conversion_status store_time (MYSQL_TIME *ltime, uint8 dec)
type_conversion_status store_time (MYSQL_TIME *ltime)
type_conversion_status store (const char *to, uint length, const CHARSET_INFO *cs, enum_check_fields check_level)
virtual longlong val_int (void)=0
virtual longlong val_time_temporal ()
virtual longlong val_date_temporal ()
longlong val_temporal_by_field_type ()
Stringval_str (String *str)
virtual Stringval_str (String *, String *)=0
Stringval_int_as_str (String *val_buffer, my_bool unsigned_flag)
virtual Item_result cast_to_int_type () const
virtual bool eq (Field *field)
virtual bool eq_def (Field *field)
virtual uint32 pack_length () const
virtual uint32 pack_length_in_rec () const
virtual bool compatible_field_size (uint metadata, Relay_log_info *rli, uint16 mflags, int *order)
virtual uint pack_length_from_metadata (uint field_metadata)
virtual uint row_pack_length () const
virtual int save_field_metadata (uchar *first_byte)
virtual uint32 data_length ()
virtual uint32 sort_length () const
virtual uint32 max_data_length () const
virtual type_conversion_status reset (void)
virtual void reset_fields ()
virtual bool get_timestamp (struct timeval *tm, int *warnings)
virtual void store_timestamp (const timeval *tm)
void store_timestamp (my_time_t sec)
virtual void set_default ()
void evaluate_insert_default_function ()
void evaluate_update_default_function ()
virtual bool zero_pack () const
virtual enum ha_base_keytype key_type () const
virtual uint32 key_length () const
virtual enum_field_types type () const =0
virtual enum_field_types real_type () const
virtual enum_field_types binlog_type () const
int cmp (const uchar *str)
virtual int cmp_max (const uchar *a, const uchar *b, uint max_len)
virtual int cmp (const uchar *, const uchar *)=0
virtual int cmp_binary (const uchar *a, const uchar *b, uint32 max_length=~0L)
virtual int cmp_offset (uint row_offset)
virtual int cmp_binary_offset (uint row_offset)
virtual int key_cmp (const uchar *a, const uchar *b)
virtual int key_cmp (const uchar *str, uint length)
virtual uint decimals () const
virtual void sql_type (String &str) const =0
bool is_temporal () const
bool is_temporal_with_date () const
bool is_temporal_with_time () const
bool is_temporal_with_date_and_time () const
bool is_null (my_ptrdiff_t row_offset=0) const
bool is_real_null (my_ptrdiff_t row_offset=0) const
bool is_null_in_record (const uchar *record) const
void set_null (my_ptrdiff_t row_offset=0)
void set_notnull (my_ptrdiff_t row_offset=0)
bool maybe_null (void) const
bool real_maybe_null (void) const
uint null_offset (const uchar *record) const
uint null_offset () const
void set_null_ptr (uchar *p_null_ptr, uint p_null_bit)
size_t last_null_byte () const
virtual void make_field (Send_field *)
virtual void make_sort_key (uchar *buff, uint length)=0
virtual bool optimize_range (uint idx, uint part)
virtual void free ()
virtual Fieldnew_field (MEM_ROOT *root, TABLE *new_table, bool keep_type)
virtual Fieldnew_key_field (MEM_ROOT *root, TABLE *new_table, uchar *new_ptr, uchar *new_null_ptr, uint new_null_bit)
Fieldnew_key_field (MEM_ROOT *root, TABLE *new_table, uchar *new_ptr)
virtual Fieldclone () const =0
virtual Fieldclone (MEM_ROOT *mem_root) const =0
void move_field (uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg)
void move_field (uchar *ptr_arg)
virtual void move_field_offset (my_ptrdiff_t ptr_diff)
virtual void get_image (uchar *buff, uint length, const CHARSET_INFO *cs)
virtual void set_image (const uchar *buff, uint length, const CHARSET_INFO *cs)
virtual uint get_key_image (uchar *buff, uint length, imagetype type)
virtual void set_key_image (const uchar *buff, uint length)
longlong val_int_offset (uint row_offset)
longlong val_int (const uchar *new_ptr)
Stringval_str (String *str, const uchar *new_ptr)
virtual bool send_binary (Protocol *protocol)
virtual uchar * pack (uchar *to, const uchar *from, uint max_length, bool low_byte_first)
uchar * pack (uchar *to, const uchar *from)
virtual const uchar * unpack (uchar *to, const uchar *from, uint param_data, bool low_byte_first)
const uchar * unpack (uchar *to, const uchar *from)
virtual uint packed_col_length (const uchar *to, uint length)
virtual uint max_packed_col_length (uint max_length)
uint offset (uchar *record)
void copy_from_tmp (int offset)
uint fill_cache_field (struct st_cache_field *copy)
virtual bool get_date (MYSQL_TIME *ltime, uint fuzzydate)
virtual bool get_time (MYSQL_TIME *ltime)
virtual const CHARSET_INFOcharset_for_protocol (void) const
virtual const CHARSET_INFOsort_charset (void) const
virtual bool has_charset (void) const
virtual bool match_collation_to_optimize_range () const
virtual void set_derivation (enum Derivation derivation_arg)
bool set_warning (Sql_condition::enum_warning_level, unsigned int code, int cuted_increment) const
bool check_overflow (int op_result)
bool check_truncated (int op_result)
bool warn_if_overflow (int op_result)
void init (TABLE *table_arg)
longlong convert_decimal2longlong (const my_decimal *val, bool unsigned_flag, bool *has_overflow)
virtual uint32 char_length ()
virtual geometry_type get_geometry_type ()
void dbug_print ()
ha_storage_media field_storage_type () const
void set_storage_type (ha_storage_media storage_type_arg)
column_format_type column_format () const
void set_column_format (column_format_type column_format_arg)
virtual type_conversion_status validate_stored_val (THD *thd)
virtual void hash (ulong *nr, ulong *nr2)

Protected Member Functions

uint8 normalize_dec (uint8 dec_arg)
virtual type_conversion_status store_internal (const MYSQL_TIME *ltime, int *error)=0
virtual type_conversion_status store_internal_with_round (MYSQL_TIME *ltime, int *warnings)=0
type_conversion_status store_lldiv_t (const lldiv_t *lld, int *warning)
virtual bool convert_str_to_TIME (const char *str, uint len, const CHARSET_INFO *cs, MYSQL_TIME *ltime, MYSQL_TIME_STATUS *status)=0
virtual type_conversion_status convert_number_to_TIME (longlong nr, bool unsigned_val, int nanoseconds, MYSQL_TIME *ltime, int *warning)=0
longlong convert_number_to_datetime (longlong nr, bool unsigned_val, MYSQL_TIME *ltime, int *warning)
void set_warnings (ErrConvString str, int warnings)
virtual ulonglong date_flags (const THD *thd)
ulonglong date_flags ()
void set_datetime_warning (Sql_condition::enum_warning_level level, uint code, ErrConvString str, timestamp_type ts_type, int cuted_increment)
- Protected Member Functions inherited from Field
uchar * pack_int16 (uchar *to, const uchar *from, bool low_byte_first_to)
const uchar * unpack_int16 (uchar *to, const uchar *from, bool low_byte_first_from)
uchar * pack_int24 (uchar *to, const uchar *from, bool low_byte_first_to)
const uchar * unpack_int24 (uchar *to, const uchar *from, bool low_byte_first_from)
uchar * pack_int32 (uchar *to, const uchar *from, bool low_byte_first_to)
const uchar * unpack_int32 (uchar *to, const uchar *from, bool low_byte_first_from)
uchar * pack_int64 (uchar *to, const uchar *from, bool low_byte_first_to)
const uchar * unpack_int64 (uchar *to, const uchar *from, bool low_byte_first_from)
bool field_flags_are_binary ()

Protected Attributes

uint8 dec
- Protected Attributes inherited from Field
uchar * null_ptr

Additional Inherited Members

- Public Types inherited from Field
enum  utype {
  NONE, DATE, SHIELD, NOEMPTY,
  CASEUP, PNR, BGNR, PGNR,
  YES, NO, REL, CHECK,
  EMPTY, UNKNOWN_FIELD, CASEDN, NEXT_NUMBER,
  INTERVAL_FIELD, BIT_FIELD, TIMESTAMP_OLD_FIELD, CAPITALIZE,
  BLOB_FIELD, TIMESTAMP_DN_FIELD, TIMESTAMP_UN_FIELD, TIMESTAMP_DNUN_FIELD
}
enum  geometry_type {
  GEOM_GEOMETRY = 0, GEOM_POINT = 1, GEOM_LINESTRING = 2, GEOM_POLYGON = 3,
  GEOM_MULTIPOINT = 4, GEOM_MULTILINESTRING = 5, GEOM_MULTIPOLYGON = 6, GEOM_GEOMETRYCOLLECTION = 7
}
enum  imagetype { itRAW, itMBR }
enum  { LAST_NULL_BYTE_UNDEF = 0 }
- Static Public Member Functions inherited from Field
static void * operator new (size_t size) throw ()
static void * operator new (size_t size, MEM_ROOT *mem_root) throw ()
static void operator delete (void *ptr, MEM_ROOT *mem_root)
static void operator delete (void *ptr_arg, size_t size) throw ()
static bool type_can_have_key_part (enum_field_types)
static enum_field_types field_type_merge (enum_field_types, enum_field_types)
static Item_result result_merge_type (enum_field_types)
- Public Attributes inherited from Field
uchar * ptr
TABLEtable
TABLEorig_table
const char ** table_name
const char * field_name
LEX_STRING comment
key_map key_start
key_map part_of_key
key_map part_of_key_not_clustered
key_map part_of_sortkey
utype unireg_check
uint32 field_length
uint32 flags
uint16 field_index
uchar null_bit
bool is_created_from_null_item
- Static Protected Member Functions inherited from Field
static void handle_int16 (uchar *to, const uchar *from, bool low_byte_first_from, bool low_byte_first_to)
static void handle_int24 (uchar *to, const uchar *from, bool low_byte_first_from, bool low_byte_first_to)
static void handle_int32 (uchar *to, const uchar *from, bool low_byte_first_from, bool low_byte_first_to)
static void handle_int64 (uchar *to, const uchar *from, bool low_byte_first_from, bool low_byte_first_to)

Detailed Description

Definition at line 2117 of file field.h.

Constructor & Destructor Documentation

Field_temporal::Field_temporal ( uchar *  ptr_arg,
uchar *  null_ptr_arg,
uchar  null_bit_arg,
enum utype  unireg_check_arg,
const char *  field_name_arg,
uint32  len_arg,
uint8  dec_arg 
)
inline

Constructor for Field_temporal

Parameters
ptr_argSee Field definition
null_ptr_argSee Field definition
null_bit_argSee Field definition
unireg_check_argSee Field definition
field_name_argSee Field definition
len_argNumber of characters in the integer part.
dec_argNumber of second fraction digits, 0..6.

Definition at line 2270 of file field.h.

Field_temporal::Field_temporal ( bool  maybe_null_arg,
const char *  field_name_arg,
uint32  len_arg,
uint8  dec_arg 
)
inline

Constructor for Field_temporal

Parameters
maybe_null_argSee Field definition
field_name_argSee Field definition
len_argNumber of characters in the integer part.
dec_argNumber of second fraction digits, 0..6

Definition at line 2286 of file field.h.

Member Function Documentation

longlong Field_temporal::convert_number_to_datetime ( longlong  nr,
bool  unsigned_val,
MYSQL_TIME ltime,
int *  warnings 
)
protected

Convert an integer number into MYSQL_TIME, according to the field type.

Parameters
INnr Number
INunsigned_val SIGNED/UNSIGNED flag
OUTltime The value is stored here
Return values
falseOn success
trueOn error
-1Timestamp with wrong values
anythingelse DATETIME as integer in YYYYMMDDHHMMSS format

Definition at line 4937 of file field.cc.

virtual type_conversion_status Field_temporal::convert_number_to_TIME ( longlong  nr,
bool  unsigned_val,
int  nanoseconds,
MYSQL_TIME ltime,
int *  warning 
)
protectedpure virtual

Convert a number with fractional part with nanosecond precision into MYSQL_TIME, according to the field type. Nanoseconds are rounded to milliseconds and added to ltime->second_part.

Parameters
INnr Number
INunsigned_val SIGNED/UNSIGNED flag
INnanoseconds Fractional part in nanoseconds
OUTltime The value is stored here
OUTstatus Conversion status
Return values
falseOn success
trueOn error

Implemented in Field_time_common, and Field_temporal_with_date.

virtual bool Field_temporal::convert_str_to_TIME ( const char *  str,
uint  len,
const CHARSET_INFO cs,
MYSQL_TIME ltime,
MYSQL_TIME_STATUS status 
)
protectedpure virtual

Convert a string to MYSQL_TIME, according to the field type.

Parameters
INstr String
INlen String length
INcs String character set
OUTltime The value is stored here
OUTstatus Conversion status
Return values
falseConversion went fine, ltime contains a valid time
trueConversion failed, ltime was reset and contains nothing

Implemented in Field_time_common, and Field_temporal_with_date.

virtual ulonglong Field_temporal::date_flags ( const THD *  thd)
inlineprotectedvirtual

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.

Parameters
thdTHD
Return values
sql_modeflags mixed with the field type flags.

Reimplemented in Field_datetimef, Field_datetime, Field_newdate, Field_timestampf, and Field_timestamp.

Definition at line 2233 of file field.h.

ulonglong Field_temporal::date_flags ( )
inlineprotected

Flags that are passed as "flag" argument to check_date(), number_to_datetime(), str_to_datetime(). Similar to the above when we don't have a THD value.

Definition at line 2242 of file field.h.

uint Field_temporal::is_equal ( Create_field new_field)
virtual

Whether a field being created is compatible with a existing one.

Used by the ALTER TABLE code to evaluate whether the new definition of a table is compatible with the old definition so that it can determine if data needs to be copied over (table data change).

Reimplemented from Field.

Definition at line 4751 of file field.cc.

uint8 Field_temporal::normalize_dec ( uint8  dec_arg)
inlineprotected

Adjust number of decimal digits from NOT_FIXED_DEC to DATETIME_MAX_DECIMALS

Definition at line 2124 of file field.h.

Item_result Field_temporal::numeric_context_result_type ( ) const
inlinevirtual

Returns Item_result type of a field when it appears in numeric context such as: SELECT time_column + 1; SELECT SUM(time_column); Examples:

  • a column of type TIME, DATETIME, TIMESTAMP act as INT.
  • a column of type TIME(1), DATETIME(1), TIMESTAMP(1) act as DECIMAL with 1 fractional digits.

Reimplemented from Field.

Definition at line 2297 of file field.h.

void Field_temporal::set_datetime_warning ( Sql_condition::enum_warning_level  level,
uint  code,
ErrConvString  val,
timestamp_type  ts_type,
int  cut_increment 
)
protected

Set a single warning using make_truncated_value_warning().

Parameters
INlevel Warning level (error, warning, note)
INcode Warning code
INstr Warning parameter
INts_type Timestamp type (time, date, datetime, none)
INcuted_inctement Incrementing of cut field counter

Produce warning or note about double datetime data saved into field.

Parameters
levellevel of message (Note/Warning/Error)
codeerror code of message to be produced
valerror parameter (the value)
ts_typetype of datetime value (datetime/date/time)
cut_incrementwhenever we should increase cut fields count
Note
This function will always produce some warning but won't increase cut fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current thread.

Definition at line 10614 of file field.cc.

Here is the call graph for this function:

void Field_temporal::set_warnings ( ErrConvString  str,
int  warnings 
)
protected

Set a warning according to warning bit flag vector. Multiple warnings are possible at the same time. Every warning in the bit vector is set by an individual set_datetime_warning() call.

Parameters
strWarning parameter
warningsWarning bit flag

Set warnings from a warning vector. Note, multiple warnings can be set at the same time.

Parameters
strValue.
warningsWarning vector.

Definition at line 4775 of file field.cc.

Here is the caller graph for this function:

type_conversion_status Field_temporal::store ( const char *  str,
uint  len,
const CHARSET_INFO cs 
)
virtual

Store string into a date/time/datetime field.

Parameters
fromDate/time string
lenLength of the string
csCharacter set of the string
Return values
TYPE_OKStorage of value went fine without warnings or errors
!TYPE_OKWarning/error as indicated by type_conversion_status enum value

Implements Field.

Definition at line 4895 of file field.cc.

virtual type_conversion_status Field_temporal::store_internal ( const MYSQL_TIME ltime,
int *  error 
)
protectedpure 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.

Parameters
INltime MYSQL_TIME value.
OUTerror Error flag vector, set in case of error.
Return values
falseIn case of success.
trueIn case of error.

Implemented in Field_datetimef, Field_datetime, Field_timef, Field_time, Field_time_common, Field_newdate, Field_timestampf, and Field_timestamp.

virtual type_conversion_status Field_temporal::store_internal_with_round ( MYSQL_TIME ltime,
int *  warnings 
)
protectedpure virtual

Low level routine to store a MYSQL_TIME value into a field with rounding according to the field decimals() value.

Parameters
INltime MYSQL_TIME value.
OUTerror Error flag vector, set in case of error.
Return values
falseIn case of success.
trueIn case of error.

Implemented in Field_time_common, and Field_temporal_with_date.

type_conversion_status Field_temporal::store_lldiv_t ( const lldiv_t *  lld,
int *  warning 
)
protected

Store a temporal value in lldiv_t into a field, with rounding according to the field decimals() value.

Parameters
INlld Temporal value.
OUTwarning Warning flag vector.
Return values
falseIn case of success.
trueIn case of error.

Definition at line 4835 of file field.cc.


The documentation for this class was generated from the following files: