MySQL 8.4.2
Source Code Documentation
Field_typed_array Class Referencefinal

Field that stores array of values of the same type. More...

#include <field.h>

Inheritance diagram for Field_typed_array:
[legend]

Public Member Functions

 Field_typed_array (const Field_typed_array &other)
 Constructs a Field_typed_array that is a copy of another Field_typed_array. More...
 
 Field_typed_array (enum_field_types elt_type, bool elt_is_unsigned, size_t elt_length, uint elt_decimals, uchar *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg, uchar auto_flags_arg, const char *field_name_arg, TABLE_SHARE *share, uint blob_pack_length, const CHARSET_INFO *cs)
 Constructs a Field_typed_array object. More...
 
uint32 char_length () const override
 maximum possible character length for blob. More...
 
void init (TABLE *table_arg) override
 
enum_field_types type () const override
 
enum_field_types real_type () const override
 
enum_field_types binlog_type () const override
 
uint32 key_length () const override
 
Field_typed_arrayclone (MEM_ROOT *mem_root) const override
 Create a shallow clone of this field in the specified MEM_ROOT. More...
 
bool is_unsigned () const final
 Whether the field is signed or not. More...
 
bool is_array () const override
 Whether the field is a typed array. More...
 
Item_result result_type () const override
 
uint decimals () const override
 
bool binary () const override
 
const CHARSET_INFOcharset () const override
 Return a text charset so that string functions automatically convert the field value to string and treat it as a non-binary string. More...
 
type_conversion_status store (const char *to, size_t length, const CHARSET_INFO *charset) override
 Store data in this JSON field. More...
 
type_conversion_status store (double nr) override
 Store a double in a JSON field. Will raise an error for now. More...
 
type_conversion_status store (longlong nr, bool unsigned_val) override
 Store an integer in a JSON field. Will raise an error for now. More...
 
type_conversion_status store_array (const Json_wrapper *data, Json_array *array)
 Store a value as an array. More...
 
size_t get_key_image (uchar *buff, size_t length, imagetype type) const override
 
Fieldnew_key_field (MEM_ROOT *root, TABLE *new_table, uchar *new_ptr, uchar *, uint) const override
 
int key_cmp (const uchar *, const uchar *) const override
 These methods are used by handler to prevent returning a row past the end_range during range access. More...
 
int key_cmp (const uchar *key_ptr, uint key_length) const override
 This function will behave similarly to MEMBER OF json operation, unlike regular key_cmp. More...
 
bool match_collation_to_optimize_range () const override
 Multi-valued index always works only as a pre-filter for actual condition check, and the latter always use binary collation, so no point to match collations in optimizer. More...
 
bool coerce_json_value (const Json_wrapper *wr, bool no_error, Json_wrapper *coerced) const
 Convert arbitrary JSON value to the array's type using the conversion field. More...
 
const char * get_index_name () const
 Get name of the index defined over this field. More...
 
uint32 get_length_bytes () const override
 Return number of bytes the field's length takes. More...
 
size_t make_sort_key (uchar *to, size_t max_len) const override
 Writes a copy of the current value in the record buffer, suitable for sorting using byte-by-byte comparison. More...
 
size_t make_sort_key (Json_wrapper *wr, uchar *to, size_t length) const
 Create sort key out of given JSON value according to array's element type. More...
 
int do_save_field_metadata (uchar *metadata_ptr) const override
 Save the field metadata for typed array fields. More...
 
uint pack_length_from_metadata (uint) const override
 
void sql_type (String &str) const final
 Get the type of this field (json). More...
 
void make_send_field (Send_field *field) const final
 Populates a Send_field object with metadata about the column represented by this Field object. More...
 
void set_field_index (uint16 f_index) final
 Sets field index. More...
 
Fieldget_conv_field ()
 
size_t make_sort_key (uchar *to, size_t length) const override
 Writes a copy of the current value in the record buffer, suitable for sorting using byte-by-byte comparison. More...
 
size_t make_sort_key (uchar *buff, size_t length) const override
 Writes a copy of the current value in the record buffer, suitable for sorting using byte-by-byte comparison. More...
 
size_t make_sort_key (uchar *to, size_t length, size_t trunc_pos) const final
 Writes a copy of the current value in the record buffer, suitable for sorting using byte-by-byte comparison. More...
 
- Public Member Functions inherited from Field_json
 Field_json (uchar *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg, uchar auto_flags_arg, const char *field_name_arg, TABLE_SHARE *share, uint blob_pack_length)
 
 Field_json (uint32 len_arg, bool is_nullable_arg, const char *field_name_arg)
 
const CHARSET_INFOsort_charset () const final
 Sort should treat the field as binary and not attempt any conversions. More...
 
bool has_charset () const final
 JSON columns don't have an associated charset. More...
 
type_conversion_status store_decimal (const my_decimal *) final
 Store a decimal in a JSON field. Will raise an error for now. More...
 
type_conversion_status store_json (const Json_wrapper *json)
 Store a JSON value as binary. More...
 
type_conversion_status store_time (MYSQL_TIME *ltime, uint8 dec_arg) final
 Store a TIME value in a JSON field. Will raise an error for now. More...
 
type_conversion_status store (const Field_json *field)
 Copy the contents of a non-null JSON field into this field. More...
 
bool pack_diff (uchar **to, ulonglong value_options) const final
 Write the field for the binary log in diff format. More...
 
longlong get_diff_vector_and_length (ulonglong value_options, const Json_diff_vector **diff_vector_p=nullptr) const
 Return the length of this field, taking into consideration that it may be in partial format. More...
 
bool is_before_image_equal_to_after_image () const
 Return true if the before-image and after-image for this field are equal. More...
 
bool unpack_diff (const uchar **from)
 Read the binary diff from the given buffer, and apply it to this field. More...
 
bool val_json (Json_wrapper *wr) const
 Retrieve the field's value as a JSON wrapper. More...
 
longlong val_int () const final
 Retrieve the JSON as an int if possible. More...
 
double val_real () const final
 Retrieve the JSON as a double if possible. More...
 
Stringval_str (String *buf1, String *buf2) const final
 Retrieve the JSON value stored in this field as text. More...
 
my_decimalval_decimal (my_decimal *m) const final
 
bool get_time (MYSQL_TIME *ltime) const final
 
bool get_date (MYSQL_TIME *ltime, my_time_flags_t fuzzydate) const final
 
uint is_equal (const Create_field *new_field) const final
 Check if a new field is compatible with this one. More...
 
Item_result cast_to_int_type () const final
 
int cmp_binary (const uchar *a, const uchar *b, uint32 max_length=~0L) const final
 
ulonglong make_hash_key (ulonglong hash_val) const
 Make a hash key that can be used by sql_executor.cc/unique_hash in order to support SELECT DISTINCT. More...
 
const char * get_binary (ptrdiff_t row_offset=0) const
 Get a read-only pointer to the binary representation of the JSON document in this field. More...
 
- Public Member Functions inherited from Field_blob
 Field_blob (uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, uchar auto_flags_arg, const char *field_name_arg, TABLE_SHARE *share, uint blob_pack_length, const CHARSET_INFO *cs)
 
 Field_blob (uint32 len_arg, bool is_nullable_arg, const char *field_name_arg, const CHARSET_INFO *cs, bool set_packlength)
 
 Field_blob (const Field_blob &field)
 Copy static information and reset dynamic information. More...
 
 Field_blob (uint32 packlength_arg)
 
enum ha_base_keytype key_type () const override
 
type_conversion_status store (const Field *from)
 
int cmp_max (const uchar *, const uchar *, uint max_length) const final
 
int cmp (const uchar *a, const uchar *b) const final
 
int cmp (const uchar *a, uint32 a_length, const uchar *b, uint32 b_length) const
 
uint32 pack_length () const final
 
uint32 pack_length_no_ptr () const
 Return the packed length without the pointer size added. More...
 
uint row_pack_length () const final
 
uint32 max_data_length () const final
 Get the maximum size of the data in packed format. More...
 
size_t get_field_buffer_size ()
 
void store_length (uchar *i_ptr, uint i_packlength, uint32 i_number)
 
void store_length (uint32 number)
 
uint32 data_length (ptrdiff_t row_offset=0) const final
 
uint32 get_length (ptrdiff_t row_offset=0) const
 
uint32 get_length (const uchar *ptr, uint packlength) const
 
uint32 get_length (const uchar *ptr_arg) const
 
const ucharget_blob_data () const
 Get a const pointer to the BLOB data of this field. More...
 
ucharget_blob_data (ptrdiff_t row_offset=0)
 Get a non-const pointer to the BLOB data of this field. More...
 
const uchardata_ptr () const final
 Get a const pointer to the BLOB data of this field. More...
 
void set_ptr (const uchar *length, const uchar *data)
 
void set_ptr_offset (ptrdiff_t ptr_diff, uint32 length, const uchar *data)
 
void set_ptr (uint32 length, const uchar *data)
 
void set_key_image (const uchar *buff, size_t length) final
 
bool copy ()
 
ucharpack (uchar *to, const uchar *from, size_t max_length) const final
 Pack the field into a format suitable for storage and transfer. More...
 
ucharpack_with_metadata_bytes (uchar *to, const uchar *from, uint max_length) const final
 This function does the same thing as pack(), except for the difference that max_length does not mean the number of bytes in the output, but the maximum field length from the input (which must be exactly field->max_field_length()). More...
 
const ucharunpack (uchar *, const uchar *from, uint param_data) final
 Unpack a blob field from row data. More...
 
uint max_packed_col_length () const final
 This is a wrapper around pack_length() used by filesort() to determine how many bytes we need for packing "addon fields". More...
 
void mem_free () final
 
uint32 max_display_length () const final
 maximum possible display length for blob. More...
 
bool copy_blob_value (MEM_ROOT *mem_root)
 This function creates a separate copy of blob value. More...
 
bool is_text_key_type () const final
 
void set_keep_old_value (bool old_value_flag)
 Mark that the BLOB stored in value should be copied before updating it. More...
 
void keep_old_value ()
 Save the current BLOB value to avoid that it gets overwritten. More...
 
void store_in_allocated_space (const char *from, uint32 length)
 Use to store the blob value into an allocated space. More...
 
bool backup_blob_field ()
 Backup data stored in 'value' into the backup_value. More...
 
void restore_blob_backup ()
 Restore backup value. More...
 
- Public Member Functions inherited from Field_longstr
 Field_longstr (uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, uchar auto_flags_arg, const char *field_name_arg, const CHARSET_INFO *charset_arg)
 
bool is_updatable () const final
 Checks whether a string field is part of write_set. More...
 
- Public Member Functions inherited from Field_str
 Field_str (uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, uchar auto_flags_arg, const char *field_name_arg, const CHARSET_INFO *charset)
 
Item_result numeric_context_result_type () const final
 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...
 
uint repertoire () const final
 
void set_charset (const CHARSET_INFO *charset_arg)
 
void set_field_length (uint32 length) final
 
enum Derivation derivation () const final
 
void set_derivation (enum Derivation derivation_arg) final
 
bool str_needs_quotes () const final
 
void add_to_cost (CostOfItem *cost) const override
 Update '*cost' with the fact that this Field is accessed. More...
 
- Public Member Functions inherited from Field
 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...
 
bool has_insert_default_constant_expression () const
 Checks if the field is marked as having a constant expression to generate default values. More...
 
ucharget_null_ptr ()
 
bool is_flag_set (unsigned flag) const
 
void set_flag (unsigned flag)
 
void clear_flag (unsigned flag)
 
uint32 all_flags () const
 
virtual bool is_wrapper_field () const
 If true, it's a Create_field_wrapper (a sub-class of Field used during CREATE/ALTER that we mustn't cast to other sub-classes of Field that aren't on a direct path of inheritance, e.g. More...
 
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 () const
 
bool is_hidden_by_system () const
 
bool is_hidden_by_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_packed (longlong nr)
 Store a temporal value in packed longlong format 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 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...
 
virtual longlong val_time_temporal_at_utc () const
 
virtual longlong val_date_temporal_at_utc () const
 
longlong val_temporal_by_field_type () const
 Returns "native" packed longlong representation of a TIME or DATE/DATETIME field depending on field type. More...
 
Stringval_str (String *str) const
 
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 Item_result cmp_type () const
 
bool gcol_expr_is_equal (const Create_field *field) const
 Check whether generated columns' expressions are the same. More...
 
virtual bool eq (const Field *field) const
 
virtual bool eq_def (const Field *field) 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...
 
int save_field_metadata (uchar *first_byte)
 
virtual type_conversion_status reset ()
 
virtual bool get_timestamp (my_timeval *tm, int *warnings) const
 Returns a UTC component in struct timeval format. More...
 
virtual void store_timestamp (const my_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 zero_pack () const
 
int cmp (const uchar *str) const
 
virtual int cmp_offset (ptrdiff_t row_offset) const
 
virtual int cmp_binary_offset (ptrdiff_t row_offset) 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_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 is_nullable () const
 
uint null_offset (const uchar *record) const
 
uint null_offset () const
 
void set_null_ptr (uchar *p_null_ptr, uint p_null_bit)
 
virtual bool optimize_range (uint idx, uint part) const
 Whether this field can be used for index range scans when in the given keypart of the given index. More...
 
virtual bool can_be_compared_as_longlong () const
 
virtual Fieldnew_field (MEM_ROOT *root, TABLE *new_table) const
 
Fieldnew_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
 
void move_field (uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_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 *)
 
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...
 
ucharpack (uchar *to) const
 
const ucharunpack (const uchar *from)
 
uint offset (uchar *record) const
 
void copy_data (ptrdiff_t src_record_offset)
 
const CHARSET_INFOcharset_for_protocol () const
 
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...
 
longlong convert_decimal2longlong (const my_decimal *val, bool unsigned_flag, bool *has_overflow)
 Conversion from decimal to longlong. More...
 
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...
 
const ucharfield_ptr () const
 Return a const pointer to where the field is stored in the record buffer. More...
 
ucharfield_ptr ()
 Return a pointer to where the field is stored in the record buffer. More...
 
void set_field_ptr (uchar *ptr_arg)
 
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...
 
bool handle_old_value () const
 Whether field's old valued have to be handled. More...
 
uint16 field_index () const
 Returns field index. More...
 

Private Attributes

Item_fieldm_conv_item {nullptr}
 Conversion item_field. More...
 
enum_field_types m_elt_type
 The array element's real type. More...
 
uint m_elt_decimals
 Element's decimals. More...
 
const CHARSET_INFOm_elt_charset
 Element's charset. More...
 
const bool unsigned_flag
 

Additional Inherited Members

- Public Types inherited from Field
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 }
 
- Static Public Member Functions inherited from Field
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 inherited from Field_str
uint32 char_length_cache
 
- Public Attributes inherited from Field
TABLEtable
 Pointer to TABLE object that owns this field. More...
 
const char * orig_db_name {nullptr}
 Pointer to original database name, only non-NULL for a temporary table. More...
 
const char * orig_table_name {nullptr}
 Pointer to original table name, only non-NULL for a temporary table. More...
 
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
 
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...
 
LEX_CSTRING m_engine_attribute = EMPTY_CSTR
 
LEX_CSTRING m_secondary_engine_attribute = EMPTY_CSTR
 
Value_generatorgcol_info {nullptr}
 
bool stored_in_db
 Indication that the field is physically stored in tables rather than just generated on SQL queries. More...
 
Value_generatorm_default_val_expr {nullptr}
 Holds the expression to be used to generate default values. More...
 
- Static Public Attributes inherited from Field
static constexpr size_t MAX_VARCHAR_WIDTH {65535}
 
static constexpr size_t MAX_TINY_BLOB_WIDTH {255}
 
static constexpr size_t MAX_SHORT_BLOB_WIDTH {65535}
 
static constexpr size_t MAX_MEDIUM_BLOB_WIDTH {16777215}
 
static constexpr size_t MAX_LONG_BLOB_WIDTH {4294967295}
 
- Protected Member Functions inherited from Field_blob
void store_ptr_and_length (const char *from, uint32 length)
 Store ptr and length. More...
 
- Protected Member Functions inherited from Field_longstr
type_conversion_status check_string_copy_error (const char *well_formed_error_pos, const char *cannot_convert_error_pos, const char *from_end_pos, const char *end, bool count_spaces, const CHARSET_INFO *cs)
 Report "not well formed" or "cannot convert" error after storing a character string info a field. More...
 
- Protected Member Functions inherited from Field
ucharpack_int16 (uchar *to, const uchar *from, size_t max_length) const
 
const ucharunpack_int16 (uchar *to, const uchar *from) const
 
ucharpack_int24 (uchar *to, const uchar *from, size_t max_length) const
 
const ucharunpack_int24 (uchar *to, const uchar *from) const
 
ucharpack_int32 (uchar *to, const uchar *from, size_t max_length) const
 
const ucharunpack_int32 (uchar *to, const uchar *from) const
 
ucharpack_int64 (uchar *to, const uchar *from, size_t max_length) const
 
const ucharunpack_int64 (uchar *to, const uchar *from) const
 
- Static Protected Member Functions inherited from Field_blob
static ucharget_blob_data (const uchar *position)
 Get the BLOB data pointer stored at the specified position in the record buffer. More...
 
- Protected Attributes inherited from Field_blob
uint packlength
 The number of bytes used to represent the length of the blob. More...
 
String value
 The 'value'-object is a cache fronting the storage engine. More...
 
- Protected Attributes inherited from Field_str
const CHARSET_INFOfield_charset
 
enum Derivation field_derivation
 
- Protected Attributes inherited from Field
ucharptr
 Holds the position to the field in record. More...
 
- Static Protected Attributes inherited from Field
static uchar dummy_null_buffer = ' '
 

Detailed Description

Field that stores array of values of the same type.

This Field class is used together with Item_func_array_cast class (CAST( .. AS .. ARRAY) function) in implementation of multi-valued index. Effectively it's a JSON field that contains a single JSON array. When a JSON value is stored, it's checked to be either a scalar, or an array. All source values are converted using the internal conversion field and stored as an array. Field_typed_array ensures that all values stored in the array have the same type and precision - the one specified by user. This way InnoDB doesn't have to do the conversion on its own and can easily index them.

The Field_typed_array always reports type of its element and from this point of view it's undistinguishable from regular field having the same type. Due to that, fields are differentiated by is_array() property. Field_typed_array returns true, all other fields - false.

For conversion and index applicability tests, Field_typed_array employs a conversion field, which is a regular Field class of array's element type. It's stored in the m_conv_field. All Field_typed_array::store_*() methods store values to the conversion field. Conversion field and typed array field are sharing same field_index, to allow correct read/write_set checks. So the field always have to be marked for read in order to allow read of conversions' results.

See also
Item_func_array_cast

Constructor & Destructor Documentation

◆ Field_typed_array() [1/2]

Field_typed_array::Field_typed_array ( const Field_typed_array other)

Constructs a Field_typed_array that is a copy of another Field_typed_array.

Parameters
otherthe other Field_typed_array object

◆ Field_typed_array() [2/2]

Field_typed_array::Field_typed_array ( enum_field_types  elt_type,
bool  elt_is_unsigned,
size_t  elt_length,
uint  elt_decimals,
uchar ptr_arg,
uchar null_ptr_arg,
uint  null_bit_arg,
uchar  auto_flags_arg,
const char *  field_name_arg,
TABLE_SHARE share,
uint  blob_pack_length,
const CHARSET_INFO cs 
)

Constructs a Field_typed_array object.

Member Function Documentation

◆ binary()

bool Field_typed_array::binary ( ) const
inlineoverridevirtual

Reimplemented from Field_str.

◆ binlog_type()

enum_field_types Field_typed_array::binlog_type ( ) const
inlineoverridevirtual

Reimplemented from Field.

◆ char_length()

uint32 Field_typed_array::char_length ( ) const
inlineoverridevirtual

maximum possible character length for blob.

This method is used in Item_field::set_field to calculate max_length for Item.

For example: CREATE TABLE t2 SELECT CONCAT(tinyblob_utf8_column) FROM t1; must create a "VARCHAR(255) CHARACTER SET utf8" column.

Returns
length

Reimplemented from Field_blob.

◆ charset()

const CHARSET_INFO * Field_typed_array::charset ( ) const
inlineoverridevirtual

Return a text charset so that string functions automatically convert the field value to string and treat it as a non-binary string.

Reimplemented from Field_json.

◆ clone()

Field_typed_array * Field_typed_array::clone ( MEM_ROOT mem_root) const
overridevirtual

Create a shallow clone of this field in the specified MEM_ROOT.

Reimplemented from Field_json.

◆ coerce_json_value()

bool Field_typed_array::coerce_json_value ( const Json_wrapper wr,
bool  no_error,
Json_wrapper coerced 
) const

Convert arbitrary JSON value to the array's type using the conversion field.

If conversion fails and it's not a coercion test (no_error= false) then an error is thrown. The converted value is guaranteed to match the field's type and can be indexed by SE without any additional handling.

Parameters
[in]wrSource data
[in]no_errorWhether an error should be thrown if value can't be coerced. Error should be thrown when inserting data into the index, and shouldn't be thrown when the range optimizer tests index applicability.
[out]coercedThe converted value. Can be nullptr if no_error is true.
Returns
true conversion failed false conversion succeeded

◆ decimals()

uint Field_typed_array::decimals ( ) const
inlineoverridevirtual

Reimplemented from Field_str.

◆ do_save_field_metadata()

int Field_typed_array::do_save_field_metadata ( uchar metadata_ptr) const
overridevirtual

Save the field metadata for typed array fields.

Saved metadata contains element type (1 byte) and up to 3 bytes of metadata - the same as each respective Field class saves (e.g Field_new_decimal for DECIMAL type). The only difference is that for VARCHAR type length is stored in 3 bytes. This allows to store longer strings, as its supported by JSON storage.

Parameters
metadata_ptrFirst byte of field metadata
Returns
number of bytes written to metadata_ptr

Reimplemented from Field_blob.

◆ get_conv_field()

Field * Field_typed_array::get_conv_field ( )

◆ get_index_name()

const char * Field_typed_array::get_index_name ( ) const

Get name of the index defined over this field.

Since typed array fields can be created only as an underlying GC field of a multi-valued functional index, there's always only one index defined over the field.

Returns
name of the index defined over the field.

◆ get_key_image()

size_t Field_typed_array::get_key_image ( uchar buff,
size_t  length,
imagetype  type 
) const
overridevirtual

Reimplemented from Field_blob.

◆ get_length_bytes()

uint32 Field_typed_array::get_length_bytes ( ) const
inlineoverridevirtual

Return number of bytes the field's length takes.

Valid only for varchar and typed arrays of varchar

Reimplemented from Field.

◆ init()

void Field_typed_array::init ( TABLE table_arg)
overridevirtual

Reimplemented from Field.

◆ is_array()

bool Field_typed_array::is_array ( ) const
inlineoverridevirtual

Whether the field is a typed array.

Reimplemented from Field.

◆ is_unsigned()

bool Field_typed_array::is_unsigned ( ) const
inlinefinalvirtual

Whether the field is signed or not.

Meaningful only for numeric fields and numeric arrays.

Reimplemented from Field.

◆ key_cmp() [1/2]

int Field_typed_array::key_cmp ( const uchar ,
const uchar  
) const
inlineoverridevirtual

These methods are used by handler to prevent returning a row past the end_range during range access.

Since there's no order defined for sorting set of arrays, always return -1 here, allowing all records fetched from SE to be returned to server. They will be filtered by WHERE condition later.

Reimplemented from Field_blob.

◆ key_cmp() [2/2]

int Field_typed_array::key_cmp ( const uchar key_ptr,
uint  key_length 
) const
overridevirtual

This function will behave similarly to MEMBER OF json operation, unlike regular key_cmp.

The key value will be checked against members of the array and the presence of the key will be considered as the record matching the given key. This particular definition is used in descending ref index scans. Descending index scan uses handler::ha_index_prev() function to read from the storage engine which does not compare the index key with the search key [unlike handler::ha_index_next_same()]. Hence each retrieved record needs to be validated to find a stop point. Refer key_cmp_if_same() and RefIterator<true>::Read() for more details.

Parameters
key_ptrPointer to the key
key_lengthKey length
Returns
0 Key found in the record -1 Key not found in the record

Reimplemented from Field_blob.

◆ key_length()

uint32 Field_typed_array::key_length ( ) const
overridevirtual

Reimplemented from Field_blob.

◆ make_send_field()

void Field_typed_array::make_send_field ( Send_field send_field) const
finalvirtual

Populates a Send_field object with metadata about the column represented by this Field object.

The Send_field object is used for sending column metadata to the client.

Parameters
[out]send_fieldthe Send_field object to populate

Reimplemented from Field_str.

◆ make_sort_key() [1/5]

size_t Field_typed_array::make_sort_key ( Json_wrapper wr,
uchar to,
size_t  length 
) const

Create sort key out of given JSON value according to array's element type.

Parameters
wrJSON value to create sort key from
tobuffer to create sort key in
lengthbuffer's length
Returns
actual sort key length

◆ make_sort_key() [2/5]

size_t Field_blob::make_sort_key ( uchar buff,
size_t  length 
) const
overridevirtual

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
This is now only used by replication; filesort makes its own sort keys based off of Items, not Fields.

Reimplemented from Field_json.

◆ make_sort_key() [3/5]

size_t Field_json::make_sort_key ( uchar buff,
size_t  length 
) const
overridevirtual

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
This is now only used by replication; filesort makes its own sort keys based off of Items, not Fields.

Reimplemented from Field_json.

◆ make_sort_key() [4/5]

size_t Field_blob::make_sort_key ( uchar buff,
size_t  length,
size_t  trunc_pos 
) const
finalvirtual

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. Field_string, Field_varstring and Field_blob classes are truncated after pos number of characters.

Parameters
buffThe buffer, assumed to be at least length bytes.
lengthNumber of bytes to write.
trunc_posNumber of characters which should be included before truncation.
Return values
Thenumber of bytes actually written.
Note
This is now only used by replication; filesort makes its own sort keys based off of Items, not Fields.

Reimplemented from Field_json.

◆ make_sort_key() [5/5]

size_t Field_typed_array::make_sort_key ( uchar buff,
size_t  length 
) const
inlineoverridevirtual

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
This is now only used by replication; filesort makes its own sort keys based off of Items, not Fields.

Reimplemented from Field_json.

◆ match_collation_to_optimize_range()

bool Field_typed_array::match_collation_to_optimize_range ( ) const
inlineoverridevirtual

Multi-valued index always works only as a pre-filter for actual condition check, and the latter always use binary collation, so no point to match collations in optimizer.

Reimplemented from Field_blob.

◆ new_key_field()

Field * Field_typed_array::new_key_field ( MEM_ROOT root,
TABLE new_table,
uchar new_ptr,
uchar ,
uint   
) const
overridevirtual

Reimplemented from Field.

◆ pack_length_from_metadata()

uint Field_typed_array::pack_length_from_metadata ( uint  ) const
inlineoverridevirtual

Reimplemented from Field.

◆ real_type()

enum_field_types Field_typed_array::real_type ( ) const
inlineoverridevirtual

Reimplemented from Field.

◆ result_type()

Item_result Field_typed_array::result_type ( ) const
overridevirtual

Reimplemented from Field_str.

◆ set_field_index()

void Field_typed_array::set_field_index ( uint16  field_index)
finalvirtual

Sets field index.

Parameters
[in]field_indexField index.

Reimplemented from Field.

◆ sql_type()

void Field_typed_array::sql_type ( String str) const
finalvirtual

Get the type of this field (json).

Parameters
strthe string that receives the type

Reimplemented from Field_json.

◆ store() [1/3]

type_conversion_status Field_typed_array::store ( const char *  from,
size_t  length,
const CHARSET_INFO cs 
)
overridevirtual

Store data in this JSON field.

JSON data is usually stored using store(Field_json*) or store_json(), so this function will only be called if non-JSON data is attempted stored in a JSON field. This results in an error in most cases.

It will attempt to parse the string (unless it's binary) as JSON text, and store a binary representation of JSON document if the string could be parsed.

Note that we override store() and not store_internal() because Field_blob::store() contains logic that bypasses store_internal() in some cases we care about. In particular:

  • When supplied an empty string, we want to raise a JSON syntax error instead of silently inserting an empty byte string.
  • When called from GROUP_CONCAT with ORDER BY or DISTINCT, we want to do the same data conversion as usual, whereas Field_blob::store() jumps directly to Field_blob::store_to_mem() with the unprocessed input data.
Parameters
fromthe start of the data to be stored
lengththe length of the data
csthe character set of the data
Returns
zero on success, non-zero on failure

Reimplemented from Field_json.

◆ store() [2/3]

type_conversion_status Field_typed_array::store ( double  nr)
overridevirtual

Store a double in a JSON field. Will raise an error for now.

Reimplemented from Field_json.

◆ store() [3/3]

type_conversion_status Field_typed_array::store ( longlong  nr,
bool  unsigned_val 
)
overridevirtual

Store an integer in a JSON field. Will raise an error for now.

Reimplemented from Field_json.

◆ store_array()

type_conversion_status Field_typed_array::store_array ( const Json_wrapper data,
Json_array array 
)

Store a value as an array.

Parameters
datathe value to store as an array
arrayscratch space for building the array to store
Returns
the status of the operation

◆ type()

enum_field_types Field_typed_array::type ( ) const
inlineoverridevirtual

Reimplemented from Field_json.

Member Data Documentation

◆ m_conv_item

Item_field* Field_typed_array::m_conv_item {nullptr}
private

Conversion item_field.

◆ m_elt_charset

const CHARSET_INFO* Field_typed_array::m_elt_charset
private

Element's charset.

◆ m_elt_decimals

uint Field_typed_array::m_elt_decimals
private

Element's decimals.

◆ m_elt_type

enum_field_types Field_typed_array::m_elt_type
private

The array element's real type.

◆ unsigned_flag

const bool Field_typed_array::unsigned_flag
private

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