MySQL  8.0.18
Source Code Documentation
Field Class Referenceabstract

#include <field.h>

Inheritance diagram for Field:
Create_field_wrapper Field_bit Field_num Field_str Field_temporal Field_bit_as_char Field_long Field_longlong Field_medium Field_new_decimal Field_real Field_short Field_tiny Field_enum Field_longstr Field_null Field_temporal_with_date Field_time_common

Public Types

enum  enum_auto_flags {
  NONE = 0, NEXT_NUMBER = 1, DEFAULT_NOW = 2, ON_UPDATE_NOW = 4,
  GENERATED_FROM_EXPRESSION = 8
}
 Flags for Field::auto_flags / Create_field::auto_flags bitmaps. More...
 
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 }
 

Public Member Functions

 Field (const Field &)=default
 
void operator= (Field &)=delete
 
bool has_insert_default_general_value_expression () const
 Checks if the field is marked as having a general expression to generate default values. More...
 
bool has_insert_default_datetime_value_expression () const
 Checks if the field is marked as having a datetime value expression to generate default values on inserts. More...
 
bool has_update_default_datetime_value_expression () const
 Checks if the field is marked as having a datetime value expression to generate default values on updates. More...
 
virtual void set_field_length (uint32 length)
 
bool is_gcol () const
 
bool is_virtual_gcol () const
 
void set_hidden (dd::Column::enum_hidden_type hidden)
 Sets the hidden type for this field. More...
 
dd::Column::enum_hidden_type hidden () const
 
bool is_hidden_from_user () const
 
bool is_field_for_functional_index () const
 
 Field (uchar *ptr_arg, uint32 length_arg, uchar *null_ptr_arg, uchar null_bit_arg, uchar auto_flags_arg, const char *field_name_arg)
 This is used as a table name when the table structure is not set up. More...
 
virtual ~Field ()=default
 
void reset_warnings ()
 
void set_tmp_nullable ()
 Turn on temporary nullability for the field. More...
 
void reset_tmp_nullable ()
 Turn off temporary nullability for the field. More...
 
void reset_tmp_null ()
 Reset temporary NULL value for field. More...
 
void set_tmp_null ()
 Set field to temporary value NULL. More...
 
bool is_tmp_nullable () const
 
bool is_tmp_null () const
 
virtual type_conversion_status store (const char *to, size_t length, const CHARSET_INFO *cs)=0
 
virtual type_conversion_status store (double nr)=0
 
virtual type_conversion_status store (longlong nr, bool unsigned_val)=0
 
virtual type_conversion_status store_packed (longlong nr)
 Store a temporal value in packed longlong format into a field. More...
 
virtual type_conversion_status store_decimal (const my_decimal *d)=0
 
virtual type_conversion_status store_time (MYSQL_TIME *ltime, uint8 dec_arg)
 Store MYSQL_TIME value with the given amount of decimal digits into a field. More...
 
type_conversion_status store_time (MYSQL_TIME *ltime)
 Store MYSQL_TYPE value into a field when the number of fractional digits is not important or is not know. More...
 
type_conversion_status store (const char *to, size_t length, const CHARSET_INFO *cs, enum_check_fields check_level)
 
virtual double val_real () const =0
 
virtual longlong val_int () const =0
 
virtual longlong val_time_temporal () const
 Returns TIME value in packed longlong format. More...
 
virtual longlong val_date_temporal () const
 Returns DATE/DATETIME value in packed longlong format. More...
 
longlong val_temporal_by_field_type () const
 Returns "native" packed longlong representation of a TIME or DATE/DATETIME field depending on field type. More...
 
virtual my_decimalval_decimal (my_decimal *) const =0
 
Stringval_str (String *str) const
 
virtual Stringval_str (String *, String *) const =0
 
Stringval_int_as_str (String *val_buffer, bool unsigned_flag) const
 Interpret field value as an integer but return the result as a string. More...
 
virtual bool str_needs_quotes () const
 
virtual Item_result result_type () const =0
 
virtual Item_result numeric_context_result_type () const
 Returns Item_result type of a field when it appears in numeric context such as: SELECT time_column + 1; SELECT SUM(time_column); Examples: More...
 
virtual Item_result cmp_type () const
 
virtual Item_result cast_to_int_type () const
 
bool gcol_expr_is_equal (const Create_field *field) const
 Check whether generated columns' expressions are the same. More...
 
virtual bool eq (Field *field) const
 
virtual bool eq_def (const Field *field) const
 
virtual uint32 pack_length () const
 
virtual uint32 pack_length_in_rec () const
 
virtual bool compatible_field_size (uint metadata, Relay_log_info *, uint16, int *order) const
 Check to see if field size is compatible with destination. More...
 
virtual uint pack_length_from_metadata (uint field_metadata) const
 
virtual uint row_pack_length () const
 
int save_field_metadata (uchar *first_byte)
 
virtual uint32 data_length (ptrdiff_t row_offset=0) const
 
virtual uint32 sort_length () const
 
virtual uint32 max_data_length () const
 Get the maximum size of the data in packed format. More...
 
virtual type_conversion_status reset ()
 
virtual void reset_fields ()
 
virtual bool get_timestamp (struct timeval *tm, int *warnings) const
 Returns timestamp value in "struct timeval" format. More...
 
virtual void store_timestamp (const timeval *)
 
Stores a timestamp value in timeval format in a field. More...
 
virtual void set_default ()
 
void evaluate_insert_default_function ()
 Evaluates the INSERT default function and stores the result in the field. More...
 
void evaluate_update_default_function ()
 Evaluates the UPDATE default function, if one exists, and stores the result in the record buffer. More...
 
virtual bool binary () const
 
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
 
enum_field_types data_type () const
 For template-compatibility with Item. More...
 
virtual enum_field_types real_type () const
 
virtual enum_field_types binlog_type () const
 
int cmp (const uchar *str) const
 
virtual int cmp_max (const uchar *a, const uchar *b, uint max_len) const
 
virtual int cmp (const uchar *, const uchar *) const =0
 
virtual int cmp_binary (const uchar *a, const uchar *b, uint32 max_length=~0L) const
 
virtual int cmp_offset (ptrdiff_t row_offset) const
 
virtual int cmp_binary_offset (ptrdiff_t row_offset) const
 
virtual int key_cmp (const uchar *a, const uchar *b) const
 
virtual int key_cmp (const uchar *str, uint length) const
 
virtual uint decimals () const
 
virtual bool is_text_key_type () 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 (ptrdiff_t row_offset=0) const
 Check whether the full table's row is NULL or the Field has value NULL. More...
 
bool is_null_value () const
 For template-compatibility with Item. More...
 
bool update_null_value ()
 Same as above. Not actually used. More...
 
bool is_real_null (ptrdiff_t row_offset=0) const
 Check whether the Field has value NULL (temporary or actual). More...
 
bool is_null_in_record (const uchar *record) const
 Check if the Field has value NULL or the record specified by argument has value NULL for this Field. More...
 
void set_null (ptrdiff_t row_offset=0)
 Set field to value NULL. More...
 
void set_notnull (ptrdiff_t row_offset=0)
 Set field to value NOT NULL. More...
 
type_conversion_status check_constraints (int mysql_errno)
 Check NOT NULL constraint on the field after temporary nullability is disabled. More...
 
void set_check_for_truncated_fields (enum_check_fields check_for_truncated_fields)
 Remember the value of THD::check_for_truncated_fields to handle possible NOT-NULL constraint errors after BEFORE-trigger execution is finished. More...
 
bool maybe_null () const
 
bool real_maybe_null () 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 *) const
 
virtual bool sort_key_is_varlen () const
 Returns whether make_sort_key() writes variable-length sort keys, ie., whether it can return fewer bytes than it's asked for. More...
 
virtual size_t make_sort_key (uchar *buff, size_t length) const =0
 Writes a copy of the current value in the record buffer, suitable for sorting using byte-by-byte comparison. More...
 
virtual bool optimize_range (uint idx, uint part) const
 
virtual bool can_be_compared_as_longlong () const
 
virtual void mem_free ()
 
virtual Fieldnew_field (MEM_ROOT *root, TABLE *new_table, bool keep_type) const
 
virtual Fieldnew_key_field (MEM_ROOT *root, TABLE *new_table, uchar *new_ptr, uchar *new_null_ptr, uint new_null_bit) const
 
Fieldnew_key_field (MEM_ROOT *root, TABLE *new_table, uchar *new_ptr) const
 
virtual Fieldclone () const =0
 Makes a shallow copy of the Field object. More...
 
virtual Fieldclone (MEM_ROOT *mem_root) const =0
 Makes a shallow copy of the Field object. More...
 
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 (ptrdiff_t ptr_diff)
 
virtual void get_image (uchar *buff, size_t length, const CHARSET_INFO *) const
 
virtual void set_image (const uchar *buff, size_t length, const CHARSET_INFO *)
 
virtual size_t get_key_image (uchar *buff, size_t length, imagetype type) const
 
virtual void set_key_image (const uchar *buff, size_t length)
 
longlong val_int_offset (ptrdiff_t row_offset)
 
longlong val_int (uchar *new_ptr)
 
Stringval_str (String *str, uchar *new_ptr)
 
virtual bool send_to_protocol (Protocol *protocol) const
 Send the value of this field over the protocol using the correct Protocol::store*() function which matches the type of the field. More...
 
virtual ucharpack (uchar *to, const uchar *from, uint max_length, bool low_byte_first) const
 Pack the field into a format suitable for storage and transfer. More...
 
ucharpack (uchar *to, const uchar *from) const
 
virtual const ucharunpack (uchar *to, const uchar *from, uint param_data, bool low_byte_first)
 Unpack a field from row data. More...
 
const ucharunpack (uchar *to, const uchar *from)
 
virtual bool pack_diff (uchar **to, ulonglong value_options) const
 Write the field for the binary log in diff format. More...
 
virtual uint max_packed_col_length () const
 This is a wrapper around pack_length() used by filesort() to determine how many bytes we need for packing "addon fields". More...
 
uint offset (uchar *record) const
 
void copy_data (ptrdiff_t src_record_offset)
 
uint fill_cache_field (CACHE_FIELD *copy)
 
virtual bool get_date (MYSQL_TIME *ltime, my_time_flags_t fuzzydate) const
 
virtual bool get_time (MYSQL_TIME *ltime) const
 
virtual const CHARSET_INFOcharset () const
 
const CHARSET_INFOcharset_for_protocol () const
 
virtual const CHARSET_INFOsort_charset () const
 
virtual bool has_charset () const
 
virtual bool match_collation_to_optimize_range () const
 
virtual enum Derivation derivation () const
 
virtual uint repertoire () const
 
virtual void set_derivation (enum Derivation)
 
bool set_warning (Sql_condition::enum_severity_level level, unsigned int code, int cut_increment)
 Produce warning or note about data saved into field. More...
 
bool set_warning (Sql_condition::enum_severity_level level, uint code, int cut_increment, const char *view_db, const char *view_name)
 Produce warning or note about data saved into field. More...
 
bool warn_if_overflow (int op_result)
 Process decimal library return codes and issue warnings for overflow and truncation. More...
 
virtual void init (TABLE *table_arg)
 
virtual uint32 max_display_length () const =0
 
virtual uint is_equal (const Create_field *new_field) const
 Whether a field being created is type-compatible with an existing one. More...
 
longlong convert_decimal2longlong (const my_decimal *val, bool unsigned_flag, bool *has_overflow)
 Conversion from decimal to longlong. More...
 
virtual uint32 char_length () const
 
virtual geometry_type get_geometry_type () const
 
void dbug_print () const
 
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) const
 
virtual ulonglong get_max_int_value () const
 Get the upper limit of the MySQL integral and floating-point type. More...
 
virtual const ucharget_ptr () const
 Return a pointer to the actual data in memory. More...
 
virtual bool is_updatable () const
 Checks whether a string field is part of write_set. More...
 
bool is_part_of_actual_key (THD *thd, uint cur_index, KEY *cur_index_info) const
 Check whether field is part of the index taking the index extensions flag into account. More...
 
Key_map get_covering_prefix_keys () const
 Get covering prefix keys. More...
 
virtual bool is_array () const
 Whether the field is a typed array. More...
 
virtual uint32 get_length_bytes () const
 Return number of bytes the field's length takes. More...
 
bool handle_old_value () const
 Whether field's old valued have to be handled. More...
 

Static Public Member Functions

static bool type_can_have_key_part (enum_field_types)
 Check whether a field type can be partially indexed by a key. More...
 
static enum_field_types field_type_merge (enum_field_types, enum_field_types)
 Return type of which can carry value of both given types in UNION result. More...
 
static Item_result result_merge_type (enum_field_types)
 Detect Item_result by given field type of UNION merge result. More...
 

Public Attributes

ucharptr
 Holds the position to the field in record. More...
 
TABLEtable
 
TABLEorig_table
 
const char ** table_name
 
const char * field_name
 
LEX_CSTRING comment
 
Key_map key_start
 
Key_map part_of_key
 Keys that includes this field except of prefix keys. More...
 
Key_map part_of_prefixkey
 Prefix keys. More...
 
Key_map part_of_sortkey
 
Key_map part_of_key_not_extended
 All keys that include this field, but not extended by the storage engine to include primary key columns. More...
 
uint32 field_length
 
uint32 flags
 
uint16 field_index
 
uchar null_bit
 
uchar auto_flags
 Bitmap of flags indicating if field value is auto-generated by default and/or on update, and in which way. More...
 
bool is_created_from_null_item
 If true, this field was created in create_tmp_field_from_item from a NULL value. More...
 
bool m_indexed
 True if this field belongs to some index (unlike part_of_key, the index might have only a prefix). More...
 
Value_generatorgcol_info {nullptr}
 
bool stored_in_db
 
bool unsigned_flag
 Whether the field is signed or not. More...
 
Value_generatorm_default_val_expr {nullptr}
 Holds the expression to be used to generate default values. More...
 

Protected Member Functions

const ucharget_null_ptr () const
 
ucharget_null_ptr ()
 
ucharpack_int16 (uchar *to, const uchar *from, uint max_length, bool low_byte_first_to) const
 
const ucharunpack_int16 (uchar *to, const uchar *from, bool low_byte_first_from) const
 
ucharpack_int24 (uchar *to, const uchar *from, uint max_length, bool low_byte_first_to) const
 
const ucharunpack_int24 (uchar *to, const uchar *from, bool low_byte_first_from) const
 
ucharpack_int32 (uchar *to, const uchar *from, uint max_length, bool low_byte_first_to) const
 
const ucharunpack_int32 (uchar *to, const uchar *from, bool low_byte_first_from) const
 
ucharpack_int64 (uchar *to, const uchar *from, uint max_length, bool low_byte_first_to) const
 
const ucharunpack_int64 (uchar *to, const uchar *from, bool low_byte_first_from) const
 

Static Protected Attributes

static uchar dummy_null_buffer = ' '
 

Private Types

enum  enum_pushed_warnings { BAD_NULL_ERROR_PUSHED = 1, NO_DEFAULT_FOR_FIELD_PUSHED = 2, NO_DEFAULT_FOR_VIEW_FIELD_PUSHED = 4 }
 

Private Member Functions

virtual size_t do_last_null_byte () const
 
virtual int do_save_field_metadata (uchar *metadata_ptr) const
 Retrieve the field metadata for fields. More...
 

Private Attributes

dd::Column::enum_hidden_type m_hidden
 
ucharm_null_ptr
 Byte where the NULL bit is stored inside a record. More...
 
bool m_is_tmp_nullable
 Flag: if the NOT-NULL field can be temporary NULL. More...
 
bool m_is_tmp_null
 This is a flag with the following semantics: More...
 
enum_check_fields m_check_for_truncated_fields_saved
 The value of THD::check_for_truncated_fields at the moment of setting m_is_tmp_null attribute. More...
 
unsigned int m_warnings_pushed
 

Friends

class Copy_field
 
class Item_avg_field
 
class Item_std_field
 
class Item_sum_num
 
class Item_sum_sum
 
class Item_sum_str
 
class Item_sum_count
 
class Item_sum_avg
 
class Item_sum_std
 
class Item_sum_min
 
class Item_sum_max
 
class Item_func_group_concat
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
LAST_NULL_BYTE_UNDEF 

◆ enum_auto_flags

Flags for Field::auto_flags / Create_field::auto_flags bitmaps.

Note
NEXT_NUMBER and DEFAULT_NOW/ON_UPDATE_NOW/GENERATED flags should never be set at the same time. Also DEFAULT_NOW and GENERATED should not be set at the same time.
Warning
The values of this enum are used as bit masks for uchar Field::auto_flags.
Enumerator
NONE 
NEXT_NUMBER 

AUTO_INCREMENT.

DEFAULT_NOW 

DEFAULT CURRENT_TIMESTAMP.

ON_UPDATE_NOW 

ON UPDATE CURRENT_TIMESTAMP.

GENERATED_FROM_EXPRESSION 

DEFAULT (expression)

◆ enum_pushed_warnings

Enumerator
BAD_NULL_ERROR_PUSHED 
NO_DEFAULT_FOR_FIELD_PUSHED 
NO_DEFAULT_FOR_VIEW_FIELD_PUSHED 

◆ geometry_type

Enumerator
GEOM_GEOMETRY 
GEOM_POINT 
GEOM_LINESTRING 
GEOM_POLYGON 
GEOM_MULTIPOINT 
GEOM_MULTILINESTRING 
GEOM_MULTIPOLYGON 
GEOM_GEOMETRYCOLLECTION 

◆ imagetype

Enumerator
itRAW 
itMBR 

Constructor & Destructor Documentation

◆ Field() [1/2]

Field::Field ( const Field )
default

◆ Field() [2/2]

Field::Field ( uchar ptr_arg,
uint32  length_arg,
uchar null_ptr_arg,
uchar  null_bit_arg,
uchar  auto_flags_arg,
const char *  field_name_arg 
)

This is used as a table name when the table structure is not set up.

◆ ~Field()

virtual Field::~Field ( )
virtualdefault

Member Function Documentation

◆ binary()

virtual bool Field::binary ( ) const
inlinevirtual

Reimplemented in Field_typed_array, Field_temporal, and Field_str.

◆ binlog_type()

virtual enum_field_types Field::binlog_type ( ) const
inlinevirtual

◆ can_be_compared_as_longlong()

virtual bool Field::can_be_compared_as_longlong ( ) const
inlinevirtual

Reimplemented in Field_year, Field_temporal, and Field_longlong.

◆ cast_to_int_type()

virtual Item_result Field::cast_to_int_type ( ) const
inlinevirtual

Reimplemented in Field_enum, and Field_json.

◆ char_length()

virtual uint32 Field::char_length ( ) const
inlinevirtual

Reimplemented in Field_typed_array, and Field_blob.

◆ charset()

virtual const CHARSET_INFO* Field::charset ( ) const
inlinevirtual

◆ charset_for_protocol()

const CHARSET_INFO* Field::charset_for_protocol ( ) const
inline

◆ check_constraints()

type_conversion_status Field::check_constraints ( int  mysql_errno)

Check NOT NULL constraint on the field after temporary nullability is disabled.

Parameters
mysql_errnoWarning to report.
Returns
TYPE_OK if the value is Ok, or corresponding error code from the type_conversion_status enum.

◆ clone() [1/2]

virtual Field* Field::clone ( ) const
pure virtual

Makes a shallow copy of the Field object.

Note
This member function must be overridden in all concrete subclasses. Several of the Field subclasses are concrete even though they are not leaf classes, so the compiler will not always catch this.
Return values
NULLIf memory allocation failed.

Implemented in Field_bit_as_char, Field_bit, Field_set, Field_enum, Field_typed_array, Field_json, Field_geom, Field_blob, Field_varstring, Field_string, Field_datetimef, Field_datetime, Field_timef, Field_time, Field_newdate, Field_year, Field_timestampf, Field_timestamp, Field_null, Field_double, Field_float, Field_longlong, Field_long, Field_medium, Field_short, Field_tiny, Field_new_decimal, Field_decimal, and Create_field_wrapper.

◆ clone() [2/2]

virtual Field* Field::clone ( MEM_ROOT mem_root) const
pure virtual

Makes a shallow copy of the Field object.

Note
This member function must be overridden in all concrete subclasses. Several of the Field subclasses are concrete even though they are not leaf classes, so the compiler will not always catch this.
Parameters
mem_rootMEM_ROOT to use for memory allocation.
Return values
NULLIf memory allocation failed.

Implemented in Field_bit_as_char, Field_bit, Field_set, Field_enum, Field_typed_array, Field_json, Field_geom, Field_blob, Field_varstring, Field_string, Field_datetimef, Field_datetime, Field_timef, Field_time, Field_newdate, Field_year, Field_timestampf, Field_timestamp, Field_null, Field_double, Field_float, Field_longlong, Field_long, Field_medium, Field_short, Field_tiny, Field_new_decimal, Field_decimal, and Create_field_wrapper.

◆ cmp() [1/2]

int Field::cmp ( const uchar str) const
inline

◆ cmp() [2/2]

◆ cmp_binary()

virtual int Field::cmp_binary ( const uchar a,
const uchar b,
uint32  max_length = ~0L 
) const
inlinevirtual

Reimplemented in Field_json, Field_blob, and Field_varstring.

◆ cmp_binary_offset()

virtual int Field::cmp_binary_offset ( ptrdiff_t  row_offset) const
inlinevirtual

Reimplemented in Field_bit.

◆ cmp_max()

virtual int Field::cmp_max ( const uchar a,
const uchar b,
uint  max_len 
) const
inlinevirtual

Reimplemented in Field_bit, Field_blob, and Field_varstring.

◆ cmp_offset()

virtual int Field::cmp_offset ( ptrdiff_t  row_offset) const
inlinevirtual

Reimplemented in Field_bit.

◆ cmp_type()

virtual Item_result Field::cmp_type ( ) const
inlinevirtual

Reimplemented in Field_enum, and Field_temporal.

◆ column_format()

column_format_type Field::column_format ( ) const
inline

◆ compatible_field_size()

bool Field::compatible_field_size ( uint  field_metadata,
Relay_log_info ,
uint16  ,
int *  order_var 
) const
virtual

Check to see if field size is compatible with destination.

This method is used in row-based replication to verify that the slave's field size is less than or equal to the master's field size. The encoded field metadata (from the master or source) is decoded and compared to the size of this field (the slave or destination).

The comparison is made so that if the source data (from the master) is less than the target data (on the slave), -1 is returned in *order_var. This implies that a conversion is necessary, but that it is lossy and can result in truncation of the value.

If the source data is strictly greater than the target data, 1 is returned in *order_var. This implies that the source type can is contained in the target type and that a conversion is necessary but is non-lossy.

If no conversion is required to fit the source type in the target type, 0 is returned in *order_var.

Parameters
field_metadataEncoded size in field metadata
order_varPointer to variable where the order between the source field and this field will be returned.
Returns
true if this field's size is compatible with the master's field size, false otherwise.

Reimplemented in Field_bit, Field_string, and Field_new_decimal.

◆ convert_decimal2longlong()

longlong Field::convert_decimal2longlong ( const my_decimal val,
bool  unsigned_flag,
bool has_overflow 
)

Conversion from decimal to longlong.

Checks overflow and returns correct value (min/max) in case of overflow.

Parameters
valvalue to be converted
unsigned_flagtype of integer to which we convert val
has_overflowtrue if there is overflow
Returns
value converted from val

◆ copy_data()

void Field::copy_data ( ptrdiff_t  src_record_offset)

◆ data_length()

virtual uint32 Field::data_length ( ptrdiff_t  row_offset = 0) const
inlinevirtual

Reimplemented in Field_blob, and Field_varstring.

◆ data_type()

enum_field_types Field::data_type ( ) const
inline

For template-compatibility with Item.

◆ dbug_print()

void Field::dbug_print ( ) const
inline

◆ decimals()

virtual uint Field::decimals ( ) const
inlinevirtual

◆ derivation()

virtual enum Derivation Field::derivation ( ) const
inlinevirtual

Reimplemented in Field_temporal, Field_str, and Field_num.

◆ do_last_null_byte()

size_t Field::do_last_null_byte ( ) const
privatevirtual

Reimplemented in Field_bit.

◆ do_save_field_metadata()

virtual int Field::do_save_field_metadata ( uchar metadata_ptr) const
inlineprivatevirtual

Retrieve the field metadata for fields.

This default implementation returns 0 and saves 0 in the metadata_ptr value.

Parameters
metadata_ptrFirst byte of field metadata
Returns
0 no bytes written.

Reimplemented in Field_bit, Field_enum, Field_typed_array, Field_blob, Field_varstring, Field_string, Field_timef, Field_temporal_with_date_and_timef, Field_temporal_with_date_and_time, Field_double, Field_float, and Field_new_decimal.

◆ eq()

virtual bool Field::eq ( Field field) const
inlinevirtual

Reimplemented in Field_bit.

◆ eq_def()

bool Field::eq_def ( const Field field) const
virtual
Return values
1if the fields are equally defined
0if the fields are unequally defined

Reimplemented in Field_enum, and Field_num.

◆ evaluate_insert_default_function()

void Field::evaluate_insert_default_function ( )

Evaluates the INSERT default function and stores the result in the field.

If no such function exists for the column, or the function is not valid for the column's data type, invoking this function has no effect.

◆ evaluate_update_default_function()

void Field::evaluate_update_default_function ( )

Evaluates the UPDATE default function, if one exists, and stores the result in the record buffer.

If no such function exists for the column, or the function is not valid for the column's data type, invoking this function has no effect.

◆ field_storage_type()

ha_storage_media Field::field_storage_type ( ) const
inline

◆ field_type_merge()

enum_field_types Field::field_type_merge ( enum_field_types  a,
enum_field_types  b 
)
static

Return type of which can carry value of both given types in UNION result.

Parameters
atype for merging
btype for merging
Returns
type of field

◆ fill_cache_field()

uint Field::fill_cache_field ( CACHE_FIELD copy)

◆ gcol_expr_is_equal()

bool Field::gcol_expr_is_equal ( const Create_field field) const

Check whether generated columns' expressions are the same.

Parameters
fieldA new field to compare against
Returns
true means the same, otherwise not.

◆ get_covering_prefix_keys()

Key_map Field::get_covering_prefix_keys ( ) const

Get covering prefix keys.

Return values
coveringprefix keys.

◆ get_date()

◆ get_geometry_type()

virtual geometry_type Field::get_geometry_type ( ) const
inlinevirtual

Reimplemented in Field_geom.

◆ get_image()

virtual void Field::get_image ( uchar buff,
size_t  length,
const CHARSET_INFO  
) const
inlinevirtual

Reimplemented in Field_bit.

◆ get_key_image()

virtual size_t Field::get_key_image ( uchar buff,
size_t  length,
imagetype  type 
) const
inlinevirtual

◆ get_length_bytes()

virtual uint32 Field::get_length_bytes ( ) const
inlinevirtual

Return number of bytes the field's length takes.

Valid only for varchar and typed arrays of varchar

Reimplemented in Field_typed_array, and Field_varstring.

◆ get_max_int_value()

virtual ulonglong Field::get_max_int_value ( ) const
inlinevirtual

Get the upper limit of the MySQL integral and floating-point type.

Returns
maximum allowed value for the field

Reimplemented in Field_double, Field_float, Field_longlong, Field_long, Field_medium, Field_short, and Field_tiny.

◆ get_null_ptr() [1/2]

const uchar* Field::get_null_ptr ( ) const
inlineprotected

◆ get_null_ptr() [2/2]

uchar* Field::get_null_ptr ( )
inlineprotected

◆ get_ptr()

virtual const uchar* Field::get_ptr ( ) const
inlinevirtual

Return a pointer to the actual data in memory.

Reimplemented in Field_blob, and Field_varstring.

◆ get_time()

bool Field::get_time ( MYSQL_TIME ltime) const
virtual

◆ get_timestamp()

bool Field::get_timestamp ( struct timeval *  tm,
int *  warnings 
) const
virtual

Returns timestamp value in "struct timeval" format.

This method is used in "SELECT UNIX_TIMESTAMP(field)" to avoid conversion from timestamp to MYSQL_TIME and back.

Reimplemented in Field_timestampf, and Field_timestamp.

◆ handle_old_value()

bool Field::handle_old_value ( ) const
inline

Whether field's old valued have to be handled.

Returns
true if field is virtual an either one of BLOB types or typed array false otherwise

◆ has_charset()

virtual bool Field::has_charset ( ) const
inlinevirtual

◆ has_insert_default_datetime_value_expression()

bool Field::has_insert_default_datetime_value_expression ( ) const
inline

Checks if the field is marked as having a datetime value expression to generate default values on inserts.

Return values
trueThe field has datetime expression as default
falseThe field doesn't have a datime value expression as default

◆ has_insert_default_general_value_expression()

bool Field::has_insert_default_general_value_expression ( ) const
inline

Checks if the field is marked as having a general expression to generate default values.

Return values
trueThe field has general expression as default
falseThe field doesn't have any general expression as default

◆ has_update_default_datetime_value_expression()

bool Field::has_update_default_datetime_value_expression ( ) const
inline

Checks if the field is marked as having a datetime value expression to generate default values on updates.

Return values
trueThe field has datetime expression as default for on update
falseThe field doesn't have a datime value expression as default for on update

◆ hash()

void Field::hash ( ulong nr,
ulong nr2 
) const
virtual

Reimplemented in Field_bit, and Field_varstring.

◆ hidden()

dd::Column::enum_hidden_type Field::hidden ( ) const
inline
Returns
the hidden type for this field.

◆ init()

void Field::init ( TABLE table_arg)
virtual

Reimplemented in Field_typed_array.

◆ is_array()

virtual bool Field::is_array ( ) const
inlinevirtual

Whether the field is a typed array.

Reimplemented in Field_typed_array.

◆ is_equal()

uint Field::is_equal ( const Create_field new_field) const
virtual

Whether a field being created is type-compatible with an 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). Constraints and generation clause (default value, generation expression) are not checked by this function.

Parameters
new_fieldnew field definition from alter.
Return values
IS_EQUAL_YESif there is no change.
IS_EQUAL_PACK_LENGTHif the data are unchanged, but the length requirements have changed
IS_EQUAL_NOif there is an incompatible change requiring copy.

Reimplemented in Field_bit, Field_enum, Field_json, Field_geom, Field_blob, Field_varstring, Field_temporal, Field_new_decimal, Field_str, and Field_num.

◆ is_field_for_functional_index()

bool Field::is_field_for_functional_index ( ) const
inline
Returns
true if this is a hidden field that is used for implementing functional indexes. Note that if we need different types of hidden fields in the future (like invisible columns), this function needs to be changed so it can distinguish between the different "types" of hidden.

◆ is_gcol()

bool Field::is_gcol ( ) const
inline

◆ is_hidden_from_user()

bool Field::is_hidden_from_user ( ) const
inline
Return values
trueif this field should be hidden away from users.
falseis this field is visible to the user.

◆ is_null()

bool Field::is_null ( ptrdiff_t  row_offset = 0) const
inline

Check whether the full table's row is NULL or the Field has value NULL.

Returns
true if the full table's row is NULL or the Field has value NULL false if neither table's row nor the Field has value NULL

◆ is_null_in_record()

bool Field::is_null_in_record ( const uchar record) const
inline

Check if the Field has value NULL or the record specified by argument has value NULL for this Field.

Returns
true if the Field has value NULL or the record has value NULL for thois Field.

◆ is_null_value()

bool Field::is_null_value ( ) const
inline

For template-compatibility with Item.

◆ is_part_of_actual_key()

bool Field::is_part_of_actual_key ( THD thd,
uint  cur_index,
KEY cur_index_info 
) const

Check whether field is part of the index taking the index extensions flag into account.

Index extensions are also not applicable to UNIQUE indexes for loose index scans.

Parameters
[in]thdTHD object
[in]cur_indexIndex of the key
[in]cur_index_infokey_info object
Return values
trueField is part of the key
falseotherwise

◆ is_real_null()

bool Field::is_real_null ( ptrdiff_t  row_offset = 0) const
inline

Check whether the Field has value NULL (temporary or actual).

Returns
true if the Field has value NULL (temporary or actual) false if the Field has value NOT NULL.

◆ is_temporal()

bool Field::is_temporal ( ) const
inline

◆ is_temporal_with_date()

bool Field::is_temporal_with_date ( ) const
inline

◆ is_temporal_with_date_and_time()

bool Field::is_temporal_with_date_and_time ( ) const
inline

◆ is_temporal_with_time()

bool Field::is_temporal_with_time ( ) const
inline

◆ is_text_key_type()

virtual bool Field::is_text_key_type ( ) const
inlinevirtual

Reimplemented in Field_blob, Field_varstring, and Field_string.

◆ is_tmp_null()

bool Field::is_tmp_null ( ) const
inline
Returns
whether Field has temporary value NULL.
Return values
trueif the Field has temporary value NULL.
falseif the Field's value is NOT NULL, or if the temporary NULL-ability flag is reset.

◆ is_tmp_nullable()

bool Field::is_tmp_nullable ( ) const
inline
Returns
temporary NULL-ability flag.
Return values
trueif NULL can be assigned temporary to the Field.
falseif NULL can not be assigned even temporary to the Field.

◆ is_updatable()

virtual bool Field::is_updatable ( ) const
inlinevirtual

Checks whether a string field is part of write_set.

Returns
false - If field is not char/varchar/....
  • If field is char/varchar/.. and is not part of write set. true - If field is char/varchar/.. and is part of write set.

Reimplemented in Field_longstr.

◆ is_virtual_gcol()

bool Field::is_virtual_gcol ( ) const
inline

◆ key_cmp() [1/2]

virtual int Field::key_cmp ( const uchar a,
const uchar b 
) const
inlinevirtual

◆ key_cmp() [2/2]

virtual int Field::key_cmp ( const uchar str,
uint  length 
) const
inlinevirtual

◆ key_length()

virtual uint32 Field::key_length ( ) const
inlinevirtual

◆ key_type()

◆ last_null_byte()

size_t Field::last_null_byte ( ) const

◆ make_field()

void Field::make_field ( Send_field field) const
virtual

Reimplemented in Field_str.

◆ make_sort_key()

virtual size_t Field::make_sort_key ( uchar buff,
size_t  length 
) const
pure 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.

Parameters
buffThe buffer, assumed to be at least length bytes.
lengthNumber of bytes to write.
Return values
Thenumber of bytes actually written. Note that unless sort_key_is_varlen() returns true, this must be exactly the same as length.

Implemented in Field_bit, Field_enum, Field_typed_array, Field_json, Field_blob, Field_varstring, Field_string, Field_datetime, Field_timef, Field_time, Field_newdate, Field_timestamp, Field_temporal_with_date_and_timef, Field_null, Field_double, Field_float, Field_longlong, Field_long, Field_medium, Field_short, Field_tiny, Field_new_decimal, Field_decimal, and Create_field_wrapper.

◆ match_collation_to_optimize_range()

virtual bool Field::match_collation_to_optimize_range ( ) const
inlinevirtual

◆ max_data_length()

virtual uint32 Field::max_data_length ( ) const
inlinevirtual

Get the maximum size of the data in packed format.

Returns
Maximum data length of the field when packed using the Field::pack() function.

Reimplemented in Field_bit, Field_blob, and Field_longstr.

◆ max_display_length()

◆ max_packed_col_length()

virtual uint Field::max_packed_col_length ( ) const
inlinevirtual

This is a wrapper around pack_length() used by filesort() to determine how many bytes we need for packing "addon fields".

Returns
maximum size of a row when stored in the filesort buffer.

Reimplemented in Field_blob, and Field_string.

◆ maybe_null()

bool Field::maybe_null ( ) const

◆ mem_free()

virtual void Field::mem_free ( )
inlinevirtual

Reimplemented in Field_blob.

◆ move_field() [1/2]

void Field::move_field ( uchar ptr_arg,
uchar null_ptr_arg,
uchar  null_bit_arg 
)
inline

◆ move_field() [2/2]

void Field::move_field ( uchar ptr_arg)
inline

◆ move_field_offset()

virtual void Field::move_field_offset ( ptrdiff_t  ptr_diff)
inlinevirtual

Reimplemented in Field_bit.

◆ new_field()

Field * Field::new_field ( MEM_ROOT root,
TABLE new_table,
bool  keep_type 
) const
virtual

Reimplemented in Field_enum, Field_varstring, and Field_string.

◆ new_key_field() [1/2]

Field * Field::new_key_field ( MEM_ROOT root,
TABLE new_table,
uchar new_ptr,
uchar new_null_ptr,
uint  new_null_bit 
) const
virtual

Reimplemented in Field_bit, Field_typed_array, and Field_varstring.

◆ new_key_field() [2/2]

Field* Field::new_key_field ( MEM_ROOT root,
TABLE new_table,
uchar new_ptr 
) const
inline

◆ null_offset() [1/2]

uint Field::null_offset ( const uchar record) const
inline

◆ null_offset() [2/2]

uint Field::null_offset ( ) const

◆ numeric_context_result_type()

virtual Item_result Field::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 in Field_temporal, Field_str, and Create_field_wrapper.

◆ offset()

uint Field::offset ( uchar record) const
inline

◆ operator=()

void Field::operator= ( Field )
delete

◆ optimize_range()

bool Field::optimize_range ( uint  idx,
uint  part 
) const
virtual

Reimplemented in Field_enum.

◆ pack() [1/2]

Field::pack ( uchar to,
const uchar from,
uint  max_length,
bool  low_byte_first 
) const
virtual

Pack the field into a format suitable for storage and transfer.

To implement packing functionality, only the virtual function should be overridden. The other functions are just convenience functions and hence should not be overridden.

The value of low_byte_first is dependent on how the packed data is going to be used: for local use, e.g., temporary store on disk or in memory, use the native format since that is faster. For data that is going to be transfered to other machines (e.g., when writing data to the binary log), data should always be stored in little-endian format.

Note
The default method for packing fields just copy the raw bytes of the record into the destination, but never more than max_length characters.
Parameters
toPointer to memory area where representation of field should be put.
fromPointer to memory area where record representation of field is stored.
max_lengthMaximum length of the field, as given in the column definition. For example, for CHAR(1000), the max_length is 1000. This information is sometimes needed to decide how to pack the data.
low_byte_firsttrue if integers should be stored little-endian, false if native format should be used. Note that for little-endian machines, the value of this flag is a moot point since the native format is little-endian.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented in Field_bit, Field_enum, Field_blob, Field_varstring, Field_string, Field_datetime, Field_timestamp, Field_longlong, Field_long, Field_medium, Field_short, Field_tiny, Field_decimal, and Field_real.

◆ pack() [2/2]

uchar* Field::pack ( uchar to,
const uchar from 
) const
inline

◆ pack_diff()

virtual bool Field::pack_diff ( uchar **  to,
ulonglong  value_options 
) const
inlinevirtual

Write the field for the binary log in diff format.

This should only write the field if the diff format is smaller than the full format. Otherwise it should leave the buffer untouched.

Parameters
[in,out]toPointer to buffer where the field will be written. This will be changed to point to the next byte after the last byte that was written.
value_optionsbitmap that indicates if full or partial JSON format is to be used.
Return values
trueThe field was not written, either because the data type does not support it, or because it was disabled according to value_options, or because there was no diff information available from the optimizer, or because the the diff format was bigger than the full format. The 'to' parameter is unchanged in this case.
falseThe field was written.

Reimplemented in Field_json.

◆ pack_int16()

uchar * Field::pack_int16 ( uchar to,
const uchar from,
uint  max_length,
bool  low_byte_first_to 
) const
protected

◆ pack_int24()

uchar * Field::pack_int24 ( uchar to,
const uchar from,
uint  max_length,
bool  low_byte_first_to 
) const
protected

◆ pack_int32()

uchar * Field::pack_int32 ( uchar to,
const uchar from,
uint  max_length,
bool  low_byte_first_to 
) const
protected

◆ pack_int64()

uchar * Field::pack_int64 ( uchar to,
const uchar from,
uint  max_length,
bool  low_byte_first_to 
) const
protected

◆ pack_length()

◆ pack_length_from_metadata()

virtual uint Field::pack_length_from_metadata ( uint  field_metadata) const
inlinevirtual

◆ pack_length_in_rec()

virtual uint32 Field::pack_length_in_rec ( ) const
inlinevirtual

Reimplemented in Field_bit.

◆ real_maybe_null()

bool Field::real_maybe_null ( ) const
inline
Returns
true if this field is NULL-able, false otherwise.

◆ real_type()

virtual enum_field_types Field::real_type ( ) const
inlinevirtual

◆ repertoire()

virtual uint Field::repertoire ( ) const
inlinevirtual

Reimplemented in Field_temporal, Field_str, and Field_num.

◆ reset()

◆ reset_fields()

virtual void Field::reset_fields ( )
inlinevirtual

Reimplemented in Field_blob.

◆ reset_tmp_null()

void Field::reset_tmp_null ( )
inline

Reset temporary NULL value for field.

◆ reset_tmp_nullable()

void Field::reset_tmp_nullable ( )
inline

Turn off temporary nullability for the field.

◆ reset_warnings()

void Field::reset_warnings ( )
inline

◆ result_merge_type()

Item_result Field::result_merge_type ( enum_field_types  field_type)
static

Detect Item_result by given field type of UNION merge result.

Parameters
field_typegiven field type
Returns
Item_result (type of internal MySQL expression result)

◆ result_type()

◆ row_pack_length()

◆ save_field_metadata()

int Field::save_field_metadata ( uchar first_byte)
inline

◆ send_to_protocol()

bool Field::send_to_protocol ( Protocol protocol) const
virtual

Send the value of this field over the protocol using the correct Protocol::store*() function which matches the type of the field.

Reimplemented in Field_time_common, Field_newdate, Field_year, Field_temporal_with_date, Field_double, Field_float, Field_longlong, Field_long, Field_medium, Field_short, Field_tiny, and Field_new_decimal.

◆ set_check_for_truncated_fields()

void Field::set_check_for_truncated_fields ( enum_check_fields  check_for_truncated_fields)
inline

Remember the value of THD::check_for_truncated_fields to handle possible NOT-NULL constraint errors after BEFORE-trigger execution is finished.

We should save the value of THD::check_for_truncated_fields before starting BEFORE-trigger processing since during triggers execution the value of THD::check_for_truncated_fields could be changed.

◆ set_column_format()

void Field::set_column_format ( column_format_type  column_format_arg)
inline

◆ set_default()

void Field::set_default ( )
virtual

Reimplemented in Field_bit.

◆ set_derivation()

virtual void Field::set_derivation ( enum Derivation  )
inlinevirtual

Reimplemented in Field_str.

◆ set_field_length()

virtual void Field::set_field_length ( uint32  length)
inlinevirtual

Reimplemented in Field_str.

◆ set_hidden()

void Field::set_hidden ( dd::Column::enum_hidden_type  hidden)
inline

Sets the hidden type for this field.

Parameters
hiddenthe new hidden type to set.

◆ set_image()

virtual void Field::set_image ( const uchar buff,
size_t  length,
const CHARSET_INFO  
)
inlinevirtual

Reimplemented in Field_bit.

◆ set_key_image()

virtual void Field::set_key_image ( const uchar buff,
size_t  length 
)
inlinevirtual

Reimplemented in Field_bit, Field_blob, and Field_varstring.

◆ set_notnull()

void Field::set_notnull ( ptrdiff_t  row_offset = 0)

Set field to value NOT NULL.

Parameters
row_offsetThis is the offset between the row being updated and table->record[0]

◆ set_null()

void Field::set_null ( ptrdiff_t  row_offset = 0)

Set field to value NULL.

Parameters
row_offsetThis is the offset between the row being updated and table->record[0]

◆ set_null_ptr()

void Field::set_null_ptr ( uchar p_null_ptr,
uint  p_null_bit 
)
inline

◆ set_storage_type()

void Field::set_storage_type ( ha_storage_media  storage_type_arg)
inline

◆ set_tmp_null()

void Field::set_tmp_null ( )

Set field to temporary value NULL.

◆ set_tmp_nullable()

void Field::set_tmp_nullable ( )
inline

Turn on temporary nullability for the field.

◆ set_warning() [1/2]

bool Field::set_warning ( Sql_condition::enum_severity_level  level,
unsigned int  code,
int  cut_increment 
)
inline

Produce warning or note about data saved into field.

Parameters
level- level of message (Note/Warning/Error)
code- error code of message to be produced
cut_increment- whenever we should increase cut fields count
Note
This function won't produce warning and increase cut fields counter if check_for_truncated_fields == CHECK_FIELD_IGNORE for current thread.

if check_for_truncated_fields == CHECK_FIELD_IGNORE then we ignore notes. This allows us to avoid notes in optimization, like convert_constant_item().

Return values
1if check_for_truncated_fields == CHECK_FIELD_IGNORE and error level is not NOTE
0otherwise

◆ set_warning() [2/2]

bool Field::set_warning ( Sql_condition::enum_severity_level  level,
uint  code,
int  truncate_increment,
const char *  view_db_name,
const char *  view_name 
)

Produce warning or note about data saved into field.

Parameters
level- level of message (Note/Warning/Error)
code- error code of message to be produced
truncate_increment- whether we should increase truncated fields count
view_db_name- if set this is the database name for view that causes the warning
view_name- if set this is the name of view that causes the warning
Note
This function won't produce warning and increase cut fields counter if check_for_truncated_fields == CHECK_FIELD_IGNORE for current thread.

if check_for_truncated_fields == CHECK_FIELD_IGNORE then we ignore notes. This allows us to avoid notes in optimisation, like convert_constant_item().

In case of execution statements INSERT/INSERT SELECT/REPLACE/REPLACE SELECT the method emits only one warning message for the following types of warning: ER_BAD_NULL_ERROR, ER_WARN_NULL_TO_NOTNULL, ER_NO_DEFAULT_FOR_FIELD.

Return values
1if check_for_truncated_fields == CHECK_FIELD_IGNORE and error level is not NOTE
0otherwise

◆ sort_charset()

virtual const CHARSET_INFO* Field::sort_charset ( ) const
inlinevirtual

◆ sort_key_is_varlen()

virtual bool Field::sort_key_is_varlen ( ) const
inlinevirtual

Returns whether make_sort_key() writes variable-length sort keys, ie., whether it can return fewer bytes than it's asked for.

Reimplemented in Field_json, Field_blob, and Field_varstring.

◆ sort_length()

virtual uint32 Field::sort_length ( ) const
inlinevirtual

Reimplemented in Field_blob, and Field_varstring.

◆ sql_type()

◆ store() [1/4]

◆ store() [2/4]

◆ store() [3/4]

◆ store() [4/4]

type_conversion_status Field::store ( const char *  to,
size_t  length,
const CHARSET_INFO cs,
enum_check_fields  check_level 
)

◆ store_decimal()

◆ store_packed()

virtual type_conversion_status Field::store_packed ( longlong  nr)
inlinevirtual

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().

Parameters
nrtemporal value in packed longlong format.
Return values
falseon success
trueon error

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

◆ store_time() [1/2]

type_conversion_status Field::store_time ( MYSQL_TIME ltime,
uint8  dec_arg 
)
virtual

Store MYSQL_TIME value with the given amount of decimal digits into a field.

This is called when storing a date in a string.

Note, the "dec" parameter represents number of digits of the Item that previously created the MYSQL_TIME value. It's needed when we store the value into a CHAR/VARCHAR/TEXT field to display the proper amount of fractional digits. For other field types the "dec" value does not matter and is ignored.

Parameters
ltimeTime, date or datetime value.
dec_argNumber of decimals in ltime.
Return values
falseon success
trueon error
Note
Needs to be changed if/when we want to support different time formats.

Reimplemented in Field_json, Field_time_common, Field_year, Field_temporal_with_date, Field_new_decimal, Field_real, and Field_num.

◆ store_time() [2/2]

type_conversion_status Field::store_time ( MYSQL_TIME ltime)
inline

Store MYSQL_TYPE value into a field when the number of fractional digits is not important or is not know.

Parameters
ltimeTime, date or datetime value.
Return values
falseon success
trueon error

◆ store_timestamp()

virtual void Field::store_timestamp ( const timeval *  )
inlinevirtual


Stores a timestamp value in timeval format in a field.

Note
  • store_timestamp(), get_timestamp() and store_time() do not depend on timezone and always work "in UTC".
  • The default implementation of this interface expects that storing the value will not fail. For most Field descendent classes, this is not the case. However, this interface is only used when the function CURRENT_TIMESTAMP is used as a column default expression, and currently we only allow TIMESTAMP and DATETIME columns to be declared with this as the column default. Hence it is enough that the classes implementing columns with these types either override this interface, or that store_time(MYSQL_TIME*, uint8) does not fail.
  • The column types above interpret decimals() to mean the scale of the fractional seconds.
  • We also have the limitation that the scale of a column must be the same as the scale of the CURRENT_TIMESTAMP. I.e. we only allow
[ TIMESTAMP | DATETIME ] (n) [ DEFAULT | ON UPDATE ] CURRENT_TIMESTAMP (n)

Since this interface relies on the caller to truncate the value according to this Field's scale, it will work with all constructs that we currently allow.

◆ str_needs_quotes()

virtual bool Field::str_needs_quotes ( ) const
inlinevirtual

Reimplemented in Field_bit, Field_temporal, and Field_str.

◆ type()

◆ type_can_have_key_part()

bool Field::type_can_have_key_part ( enum_field_types  type)
static

Check whether a field type can be partially indexed by a key.

This is a static method, rather than a virtual function, because we need to check the type of a non-Field in mysql_alter_table().

Parameters
typefield type
Return values
trueType can have a prefixed key
falseType can not have a prefixed key

◆ unpack() [1/2]

Field::unpack ( uchar to,
const uchar from,
uint  param_data,
bool  low_byte_first 
)
virtual

Unpack a field from row data.

This method is used to unpack a field from a master whose size of the field is less than that of the slave.

The param_data parameter is a two-byte integer (stored in the least significant 16 bits of the unsigned integer) usually consisting of two parts: the real type in the most significant byte and a original pack length in the least significant byte.

The exact layout of the param_data field is given by the Table_map_log_event::save_field_metadata().

This is the default method for unpacking a field. It just copies the memory block in byte order (of original pack length bytes or length of field, whichever is smaller).

Parameters
toDestination of the data
fromSource of the data
param_dataReal type and original pack length of the field data
low_byte_firstIf this flag is true, all composite entities (e.g., lengths) should be unpacked in little-endian format; otherwise, the entities are unpacked in native order.
Returns
New pointer into memory based on from + length of the data

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented in Field_bit, Field_enum, Field_blob, Field_varstring, Field_string, Field_datetime, Field_timestamp, Field_longlong, Field_long, Field_medium, Field_short, Field_tiny, Field_new_decimal, Field_decimal, and Field_real.

◆ unpack() [2/2]

const uchar* Field::unpack ( uchar to,
const uchar from 
)
inline

◆ unpack_int16()

const uchar * Field::unpack_int16 ( uchar to,
const uchar from,
bool  low_byte_first_from 
) const
protected

◆ unpack_int24()

const uchar * Field::unpack_int24 ( uchar to,
const uchar from,
bool  low_byte_first_from 
) const
protected

◆ unpack_int32()

const uchar * Field::unpack_int32 ( uchar to,
const uchar from,
bool  low_byte_first_from 
) const
protected

◆ unpack_int64()

const uchar * Field::unpack_int64 ( uchar to,
const uchar from,
bool  low_byte_first_from 
) const
protected

◆ update_null_value()

bool Field::update_null_value ( )
inline

Same as above. Not actually used.

◆ val_date_temporal()

virtual longlong Field::val_date_temporal ( ) const
inlinevirtual

Returns DATE/DATETIME value in packed longlong format.

This method should not be called for non-temporal types. Temporal field types override the default method.

Reimplemented in Field_datetimef, Field_time_common, Field_newdate, and Field_temporal_with_date.

◆ val_decimal()

◆ val_int() [1/2]

◆ val_int() [2/2]

longlong Field::val_int ( uchar new_ptr)
inline

◆ val_int_as_str()

String * Field::val_int_as_str ( String val_buffer,
bool  unsigned_val 
) const

Interpret field value as an integer but return the result as a string.

This is used for printing bit_fields as numbers while debugging.

◆ val_int_offset()

longlong Field::val_int_offset ( ptrdiff_t  row_offset)
inline

◆ val_real()

◆ val_str() [1/3]

String* Field::val_str ( String str) const
inline

◆ val_str() [2/3]

◆ val_str() [3/3]

String* Field::val_str ( String str,
uchar new_ptr 
)
inline

◆ val_temporal_by_field_type()

longlong Field::val_temporal_by_field_type ( ) const
inline

Returns "native" packed longlong representation of a TIME or DATE/DATETIME field depending on field type.

◆ val_time_temporal()

virtual longlong Field::val_time_temporal ( ) const
inlinevirtual

Returns TIME value in packed longlong format.

This method should not be called for non-temporal types. Temporal field types override the default method.

Reimplemented in Field_timef, Field_time, Field_newdate, and Field_temporal_with_date.

◆ validate_stored_val()

virtual type_conversion_status Field::validate_stored_val ( THD thd)
inlinevirtual

◆ warn_if_overflow()

bool Field::warn_if_overflow ( int  op_result)

Process decimal library return codes and issue warnings for overflow and truncation.

Parameters
op_resultdecimal library return code (E_DEC_* see include/decimal.h)
Return values
0No error or some other errors except overflow
1There was overflow

◆ zero_pack()

Friends And Related Function Documentation

◆ Copy_field

friend class Copy_field
friend

◆ Item_avg_field

friend class Item_avg_field
friend

◆ Item_func_group_concat

friend class Item_func_group_concat
friend

◆ Item_std_field

friend class Item_std_field
friend

◆ Item_sum_avg

friend class Item_sum_avg
friend

◆ Item_sum_count

friend class Item_sum_count
friend

◆ Item_sum_max

friend class Item_sum_max
friend

◆ Item_sum_min

friend class Item_sum_min
friend

◆ Item_sum_num

friend class Item_sum_num
friend

◆ Item_sum_std

friend class Item_sum_std
friend

◆ Item_sum_str

friend class Item_sum_str
friend

◆ Item_sum_sum

friend class Item_sum_sum
friend

Member Data Documentation

◆ auto_flags

uchar Field::auto_flags

Bitmap of flags indicating if field value is auto-generated by default and/or on update, and in which way.

See also
Field::enum_auto_flags for possible options.
Field::utype and Field::unireg_check in pre-8.0 versions of server for historical perspective.

◆ comment

LEX_CSTRING Field::comment

◆ dummy_null_buffer

uchar Field::dummy_null_buffer = ' '
staticprotected

◆ field_index

uint16 Field::field_index

◆ field_length

uint32 Field::field_length

◆ field_name

const char * Field::field_name

◆ flags

uint32 Field::flags

◆ gcol_info

Value_generator* Field::gcol_info {nullptr}

◆ is_created_from_null_item

bool Field::is_created_from_null_item

If true, this field was created in create_tmp_field_from_item from a NULL value.

This means that the type of the field is just a guess, and the type may be freely coerced to another type.

See also
create_tmp_field_from_item
Item_type_holder::get_real_type

◆ key_start

Key_map Field::key_start

◆ m_check_for_truncated_fields_saved

enum_check_fields Field::m_check_for_truncated_fields_saved
private

The value of THD::check_for_truncated_fields at the moment of setting m_is_tmp_null attribute.

◆ m_default_val_expr

Value_generator* Field::m_default_val_expr {nullptr}

Holds the expression to be used to generate default values.

◆ m_hidden

dd::Column::enum_hidden_type Field::m_hidden
private

◆ m_indexed

bool Field::m_indexed

True if this field belongs to some index (unlike part_of_key, the index might have only a prefix).

◆ m_is_tmp_null

bool Field::m_is_tmp_null
private

This is a flag with the following semantics:

  • it can be changed only when m_is_tmp_nullable is true;
  • it specifies if this field in the first current record (TABLE::record[0]) was set to NULL (temporary NULL).

This flag is used for trigger handling.

◆ m_is_tmp_nullable

bool Field::m_is_tmp_nullable
private

Flag: if the NOT-NULL field can be temporary NULL.

◆ m_null_ptr

uchar* Field::m_null_ptr
private

Byte where the NULL bit is stored inside a record.

If this Field is a NOT NULL field, this member is NULL.

◆ m_warnings_pushed

unsigned int Field::m_warnings_pushed
private

◆ null_bit

uchar Field::null_bit

◆ orig_table

TABLE* Field::orig_table

◆ part_of_key

Key_map Field::part_of_key

Keys that includes this field except of prefix keys.

◆ part_of_key_not_extended

Key_map Field::part_of_key_not_extended

All keys that include this field, but not extended by the storage engine to include primary key columns.

◆ part_of_prefixkey

Key_map Field::part_of_prefixkey

Prefix keys.

◆ part_of_sortkey

Key_map Field::part_of_sortkey

◆ ptr

uchar* Field::ptr

Holds the position to the field in record.

◆ stored_in_db

bool Field::stored_in_db

◆ table

TABLE* Field::table

◆ table_name

const char** Field::table_name

◆ unsigned_flag

bool Field::unsigned_flag

Whether the field is signed or not.

Meaningful only for numeric fields and numeric arrays.


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