MySQL 8.4.3
Source Code Documentation
TABLE Struct Reference

#include <table.h>

Public Types

enum  Set_operator_type {
  SOT_NONE , SOT_UNION_ALL , SOT_UNION_DISTINCT , SOT_INTERSECT_ALL ,
  SOT_INTERSECT_DISTINCT , SOT_EXCEPT_ALL , SOT_EXCEPT_DISTINCT
}
 

Public Member Functions

bool is_union_or_table () const
 Test if this tmp table stores the result of a UNION set operation or a single table. More...
 
void set_use_hash_map (bool use_hash_map)
 
bool uses_hash_map () const
 
Set_operator_type set_op_type ()
 Returns the set operation type. More...
 
bool is_intersect () const
 
bool is_except () const
 
bool is_distinct () const
 
void set_set_op (Field_longlong *set_counter, bool except, bool distinct)
 Initialize the set counter field pointer and the type of set operation other than UNION*. More...
 
Field_longlongset_counter ()
 
void reset ()
 Reset state of fields after optimization and execution. More...
 
void init (THD *thd, Table_ref *tl)
 Initialize TABLE instance (newly created, or coming either from table cache or THD::temporary_tables list) and prepare it for further use during statement execution. More...
 
bool init_tmp_table (THD *thd, TABLE_SHARE *share, MEM_ROOT *m_root, CHARSET_INFO *charset, const char *alias, Field **fld, uint *blob_fld, bool is_virtual)
 Initialize table as internal tmp table. More...
 
bool fill_item_list (mem_root_deque< Item * > *item_list) const
 Create Item_field for each column in the table. More...
 
void clear_column_bitmaps (void)
 
void prepare_for_position (void)
 Tell handler we are going to call position() and rnd_pos() later. More...
 
void mark_column_used (Field *field, enum enum_mark_columns mark)
 Mark column as either read or written (or none) according to mark_used. More...
 
void mark_columns_used_by_index_no_reset (uint index, MY_BITMAP *map, uint key_parts=0) const
 mark columns used by key, but don't reset other fields More...
 
void mark_columns_used_by_index (uint index)
 
void mark_auto_increment_column (void)
 Mark auto-increment fields as used fields in both read and write maps. More...
 
void mark_columns_needed_for_update (THD *thd, bool mark_binlog_columns)
 Mark columns needed for doing an update of a row. More...
 
void mark_columns_needed_for_delete (THD *thd)
 
void mark_columns_needed_for_insert (THD *thd)
 
void mark_columns_per_binlog_row_image (THD *thd)
 
void mark_generated_columns (bool is_update)
 Update the write/read_set for generated columns when doing update and insert operation. More...
 
void mark_gcol_in_maps (const Field *field)
 Adds a generated column and its dependencies to the read_set/write_set bitmaps. More...
 
void mark_check_constraint_columns (bool is_update)
 Update the read_map with columns needed for check constraint evaluation when doing update and insert operations. More...
 
void column_bitmaps_set (MY_BITMAP *read_set_arg, MY_BITMAP *write_set_arg)
 
void column_bitmaps_set_no_signal (MY_BITMAP *read_set_arg, MY_BITMAP *write_set_arg)
 
void use_all_columns ()
 
void default_column_bitmaps ()
 
void invalidate_dict ()
 
void invalidate_stats ()
 
bool has_invalid_dict () const
 
bool has_invalid_stats ()
 
Field ** visible_field_ptr () const
 
uint visible_field_count () const
 
bool alloc_tmp_keys (uint new_key_count, uint new_key_part_count, bool modify_share)
 Allocate space for keys, for a materialized derived table. More...
 
bool add_tmp_key (Field_map *key_parts, bool invisible, bool modify_share)
 Add one key to a materialized derived table. More...
 
void move_tmp_key (int old_idx, bool modify_share)
 For a materialized derived table: moves a KEY definition from a position to the first not-yet-used position (which is lower). More...
 
void drop_unused_tmp_keys (bool modify_share)
 For a materialized derived table: after move_tmp_key() has moved all definitions of used KEYs, in TABLE::key_info we have a head of used keys followed by a tail of unused keys; this function chops the tail. More...
 
void set_keyread (bool flag)
 
bool index_contains_some_virtual_gcol (uint index_no) const
 Check whether the given index has a virtual generated columns. More...
 
void update_const_key_parts (Item *conds)
 Update TABLE::const_key_parts for single table UPDATE/DELETE query. More...
 
bool check_read_removal (uint index)
 Read removal is possible if the selected quick read method is using full unique index. More...
 
ptrdiff_t default_values_offset () const
 
bool has_storage_handler () const
 
void set_storage_handler (handler *file_arg)
 Set storage handler for temporary table. More...
 
bool is_created () const
 Return true if table is instantiated, and false otherwise. More...
 
void set_created ()
 Set the table as "created", and enable flags in storage engine that could not be enabled without an instantiated table. More...
 
void set_deleted ()
 Set the contents of table to be "deleted", ie "not created", after having deleted the contents. More...
 
void set_nullable ()
 Set table as nullable, ie it is inner wrt some outer join. More...
 
bool is_nullable () const
 Return whether table is nullable. More...
 
bool has_gcol () const
 
void set_not_started ()
 Life cycle of the row buffer is as follows: More...
 
bool is_started () const
 
void set_found_row ()
 Set status for row buffer: contains row. More...
 
void set_no_row ()
 Set status for row buffer: contains no row. More...
 
void set_row_status_from_handler (int status)
 Set "row found" status from handler result. More...
 
void set_null_row ()
 Set current row as "null row", for use in null-complemented outer join. More...
 
void reset_null_row ()
 Clear "null row" status for the current row. More...
 
void set_updated_row ()
 Set "updated" property for the current row. More...
 
void set_deleted_row ()
 Set "deleted" property for the current row. More...
 
bool has_row () const
 
bool has_null_row () const
 
bool has_updated_row () const
 
bool has_deleted_row () const
 
void save_null_flags ()
 Save the NULL flags of the current row into the designated buffer. More...
 
void restore_null_flags ()
 Restore the NULL flags of the current row from the designated buffer. More...
 
bool empty_result_table ()
 Empties internal temporary table (deletes rows, closes scan) More...
 
void init_cost_model (const Cost_model_server *cost_model_server)
 Initialize the optimizer cost model. More...
 
const Cost_model_tablecost_model () const
 Return the cost model object for this table. More...
 
void bind_value_generators_to_fields ()
 Bind all the table's value generator columns in all the forms: stored/virtual GC, default expressions and checked constraints. More...
 
void cleanup_value_generator_items ()
 Clean any state in items associated with generated columns to be ready for the next statement. More...
 
void set_tmp_table_seq_id (uint arg)
 
void update_covering_prefix_keys (Field *field, uint16 key_read_length, Key_map *covering_prefix_keys)
 Update covering keys depending on max read key length. More...
 
handlerget_primary_handler () const
 Returns the primary engine handler for the table. More...
 
bool has_binary_diff_columns () const
 Does this table have any columns that can be updated using partial update in the current row? More...
 
const Binary_diff_vectorget_binary_diffs (const Field *field) const
 Get the list of binary diffs that have been collected for a given column in the current row, or nullptr if partial update cannot be used for that column. More...
 
bool mark_column_for_partial_update (const Field *field)
 Mark a given column as one that can potentially be updated using partial update during execution of an update statement. More...
 
bool is_marked_for_partial_update (const Field *field) const
 Has this column been marked for partial update? More...
 
bool has_columns_marked_for_partial_update () const
 Does this table have any columns that were marked with mark_column_for_partial_update()? More...
 
bool setup_partial_update (bool logical_diffs)
 Enable partial update of JSON columns in this table. More...
 
bool setup_partial_update ()
 
bool add_binary_diff (const Field *field, size_t offset, size_t length)
 Add a binary diff for a column that is updated using partial update. More...
 
void clear_partial_update_diffs ()
 Clear the diffs that have been collected for partial update of JSON columns, and re-enable partial update for any columns where partial update was temporarily disabled for the current row. More...
 
void cleanup_partial_update ()
 Clean up state used for partial update of JSON columns. More...
 
void disable_binary_diffs_for_current_row (const Field *field)
 Temporarily disable collection of binary diffs for a column in the current row. More...
 
void disable_logical_diffs_for_current_row (const Field *field) const
 Temporarily disable collection of Json_diff objects describing the logical changes of a JSON column in the current row. More...
 
Stringget_partial_update_buffer ()
 Get a buffer that can be used to hold the partially updated column value while performing partial update. More...
 
void add_logical_diff (const Field_json *field, const Json_seekable_path &path, enum_json_diff_operation operation, const Json_wrapper *new_value)
 Add a logical JSON diff describing a logical change to a JSON column in partial update. More...
 
const Json_diff_vectorget_logical_diffs (const Field_json *field) const
 Get the list of JSON diffs that have been collected for a given column in the current row, or nullptr if partial update cannot be used for that column. More...
 
bool is_binary_diff_enabled (const Field *field) const
 Is partial update using binary diffs enabled on this JSON column? More...
 
bool is_logical_diff_enabled (const Field *field) const
 Is partial update using logical diffs enabled on this JSON column? More...
 
void blobs_need_not_keep_old_value ()
 Virtual fields of type BLOB have a flag m_keep_old_value. More...
 
void set_binlog_drop_if_temp (bool should_binlog)
 Set the variable should_binlog_drop_if_temp_flag, so that the logging of temporary tables can be decided. More...
 
bool should_binlog_drop_if_temp (void) const
 
const histograms::Histogramfind_histogram (uint field_index) const
 Find the histogram for the given field index. More...
 

Public Attributes

TABLE_SHAREs {nullptr}
 
handlerfile {nullptr}
 
TABLEnext {nullptr}
 
TABLEprev {nullptr}
 
const Table_histogramshistograms {nullptr}
 
MY_BITMAP fields_for_functional_indexes
 A bitmap marking the hidden generated columns that exists for functional indexes. More...
 
THDin_use {nullptr}
 The current session using this table object. More...
 
Field ** field {nullptr}
 
uint hidden_field_count {0}
 Count of hidden fields, if internal temporary table; 0 otherwise. More...
 
ucharrecord [2] {nullptr, nullptr}
 
ucharwrite_row_record {nullptr}
 
ucharinsert_values {nullptr}
 
Record_buffer m_record_buffer {0, 0, nullptr}
 Buffer for use in multi-row reads. Initially empty. More...
 
Key_map covering_keys
 
Key_map quick_keys
 
Key_map merge_keys
 
Key_map possible_quick_keys
 
Key_map keys_in_use_for_query
 
Key_map keys_in_use_for_group_by
 
Key_map keys_in_use_for_order_by
 
KEYkey_info {nullptr}
 
KEY_PART_INFObase_key_parts {nullptr}
 Key part array for generated keys, used for materialized derived tables. More...
 
Fieldnext_number_field {nullptr}
 
Fieldfound_next_number_field {nullptr}
 
Field ** vfield {nullptr}
 Pointer to generated columns. More...
 
Field ** gen_def_fields_ptr {nullptr}
 Pointer to fields having the default value generated. More...
 
Fieldhash_field {nullptr}
 Field used by unique constraint. More...
 
ha_rows m_limit_rows {HA_POS_ERROR}
 A priori unlimited. More...
 
Fieldfts_doc_id_field {nullptr}
 
Table_trigger_dispatchertriggers {nullptr}
 
Table_refpos_in_table_list {nullptr}
 
Table_refpos_in_locked_tables {nullptr}
 
ORDERgroup {nullptr}
 
const char * alias {nullptr}
 alias or table name More...
 
ucharnull_flags {nullptr}
 Pointer to the null flags of record[0]. More...
 
ucharnull_flags_saved
 Saved null_flags while null_row is true. More...
 
MY_BITMAP def_read_set
 
MY_BITMAP def_write_set
 
MY_BITMAP tmp_set
 
MY_BITMAP pack_row_tmp_set
 
MY_BITMAP cond_set
 
MY_BITMAP def_fields_set_during_insert
 Bitmap of table fields (columns), which are explicitly set in the INSERT INTO statement. More...
 
MY_BITMAPread_set {nullptr}
 The read set contains the set of columns that the execution engine needs to process the query. More...
 
MY_BITMAPwrite_set {nullptr}
 
MY_BITMAP read_set_internal
 A bitmap of fields that are explicitly referenced by the query. More...
 
MY_BITMAPfields_set_during_insert {nullptr}
 A pointer to the bitmap of table fields (columns), which are explicitly set in the INSERT INTO statement. More...
 
query_id_t query_id {0}
 
ha_rows quick_rows [MAX_KEY] {0}
 
key_part_map const_key_parts [MAX_KEY] {0}
 
uint quick_key_parts [MAX_KEY] {0}
 
uint quick_n_ranges [MAX_KEY] {0}
 
ha_rows quick_condition_rows {0}
 
uint lock_position {0}
 
uint lock_data_start {0}
 
uint lock_count {0}
 
uint db_stat {0}
 
int current_lock {0}
 
Sql_table_check_constraint_listtable_check_constraint_list {nullptr}
 
bool null_row {false}
 
bool copy_blobs {false}
 
bool force_index {false}
 
bool force_index_order {false}
 Flag set when the statement contains FORCE INDEX FOR ORDER BY See Table_ref::process_index_hints(). More...
 
bool force_index_group {false}
 Flag set when the statement contains FORCE INDEX FOR GROUP BY See Table_ref::process_index_hints(). More...
 
bool const_table {false}
 
bool no_rows {false}
 True if writes to this table should not write rows and just write keys. More...
 
bool key_read {false}
 If set, the optimizer has found that row retrieval should access index tree only. More...
 
bool no_keyread {false}
 Certain statements which need the full row, set this to ban index-only access. More...
 
bool no_replicate {false}
 If set, indicate that the table is not replicated by the server. More...
 
bool open_by_handler {false}
 
bool autoinc_field_has_explicit_non_null_value {false}
 To indicate that value of the auto_increment field was provided explicitly by the user or from some other source (e.g. More...
 
bool alias_name_used {false}
 
bool get_fields_in_item_tree {false}
 
bool materialized {false}
 For a materializable derived or SJ table: true if has been materialized. More...
 
struct {
   class JOIN_TAB *   join_tab {nullptr}
 
   class QEP_TAB *   qep_tab {nullptr}
 
   thr_lock_type   lock_type {TL_UNLOCK}
 
   bool   not_exists_optimize {false}
 
   bool   impossible_range {false}
 
reginfo
 
MEM_ROOT mem_root
 
Blob_mem_storageblob_storage {nullptr}
 Initialized in Item_func_group_concat::setup for appropriate temporary table if GROUP_CONCAT is used with ORDER BY | DISTINCT and BLOB field count > 0. More...
 
SortingIteratorsorting_iterator {nullptr}
 Not owned by the TABLE; used only from filesort_free_buffers(). More...
 
SortingIteratorduplicate_removal_iterator {nullptr}
 
Sort_result unique_result
 The result of applying a unique operation (by row ID) to the table, if done. More...
 
partition_infopart_info {nullptr}
 
bool all_partitions_pruned_away {false}
 
MDL_ticketmdl_ticket {nullptr}
 

Private Attributes

TABLEcache_next {nullptr}
 Links for the lists of used/unused TABLE objects for the particular table in the specific instance of Table_cache (in other words for specific Table_cache_element object). More...
 
TABLE ** cache_prev {nullptr}
 
Field_longlongm_set_counter {nullptr}
 The set counter. More...
 
bool m_last_operation_is_distinct {false}
 If m_set_counter is set: true if last block has DISTINCT semantics, either because it is marked as such, or because we have computed this to give an equivalent answer. More...
 
bool m_deduplicate_with_hash_map {false}
 If false, any de-duplication happens via an index on this table (e.g. More...
 
Set_operator_type m_set_op_type {SOT_NONE}
 Holds the set operation type. More...
 
bool nullable {false}
 If true, this table is inner w.r.t. More...
 
uint8 m_status {0}
 
bool m_invalid_dict {false}
 This TABLE object is invalid and cannot be reused. More...
 
bool m_invalid_stats {false}
 This TABLE object is invalid and cannot be reused as it has outdated rec_per_key and handler stats. More...
 
bool created {false}
 For tmp tables. More...
 
Cost_model_table m_cost_model
 Cost model object for operations on this table. More...
 
uint tmp_table_seq_id {0}
 Internal tmp table sequential number. More...
 
MY_BITMAPm_partial_update_columns {nullptr}
 Bitmap that tells which columns are eligible for partial update in an update statement. More...
 
Partial_update_infom_partial_update_info {nullptr}
 Object which contains execution time state used for partial update of JSON columns. More...
 
bool should_binlog_drop_if_temp_flag {false}
 This flag decides whether or not we should log the drop temporary table command. More...
 

Friends

class Table_cache_element
 

Member Enumeration Documentation

◆ Set_operator_type

Enumerator
SOT_NONE 
SOT_UNION_ALL 
SOT_UNION_DISTINCT 
SOT_INTERSECT_ALL 
SOT_INTERSECT_DISTINCT 
SOT_EXCEPT_ALL 
SOT_EXCEPT_DISTINCT 

Member Function Documentation

◆ add_binary_diff()

bool TABLE::add_binary_diff ( const Field field,
size_t  offset,
size_t  length 
)

Add a binary diff for a column that is updated using partial update.

Parameters
fieldthe column that is being updated
offsetthe offset of the changed portion
lengththe length of the changed portion
Return values
falseon success
trueon out-of-memory

◆ add_logical_diff()

void TABLE::add_logical_diff ( const Field_json field,
const Json_seekable_path path,
enum_json_diff_operation  operation,
const Json_wrapper new_value 
)

Add a logical JSON diff describing a logical change to a JSON column in partial update.

Parameters
fieldthe column that is updated
paththe JSON path that is changed
operationthe operation to perform
new_valuethe new value in the path
Exceptions
std::bad_allocif memory cannot be allocated

◆ add_tmp_key()

bool TABLE::add_tmp_key ( Field_map key_parts,
bool  invisible,
bool  modify_share 
)

Add one key to a materialized derived table.

Parameters
key_partsbitmap of fields that take a part in the key.
invisibleIf true, set up bitmaps so the key is never used by this TABLE
modify_shareDo modifications to TABLE_SHARE.
See also
alloc_tmp_keys
Returns
true if key successfully created, false if not (key too long)

Creates a key for this table from fields which corresponds the bits set to 1 in the 'key_parts' bitmap. In the key, columns are in the same order as in the table. Space for the key has already been allocated by alloc_tmp_keys().

See also
add_derived_key

◆ alloc_tmp_keys()

bool TABLE::alloc_tmp_keys ( uint  new_key_count,
uint  new_key_part_count,
bool  modify_share 
)

Allocate space for keys, for a materialized derived table.

Parameters
new_key_countNumber of wanted keys.
new_key_part_countNumber of wanted key parts.
modify_shareDo modificationts to TABLE_SHARE.

This function is called when more keys (or keyparts) are required than already allocated. They key array and supportings arrays are all stored contiguously, thus when more space is needed, new arrays are created and old information is copied into them. Some space is wasted due to this, but generally, only a few keys are needed. Notice that no or little extra allocation is required for repeated executions, as one optimization is able to reuse space allocated in the previous optimization.

When modifying TABLE, modifications to TABLE_SHARE are needed, so that both objects remain consistent. Even if several TABLEs point to the same TABLE_SHARE, those modifications must be done only once (consider for example, incremementing TABLE_SHARE::keys). Should they be done when processing the first TABLE, or the second, or? In case this function, when updating TABLE, relies on TABLE_SHARE members which are the subject of modifications, we follow this rule: do those TABLE_SHARE member modifications first: thus, TABLE-modifying code can be identical for all TABLEs. So the first TABLE calling this function, only, should pass 'true': all next ones should not modify the TABLE_SHARE.

Returns
false if success, true if error

◆ bind_value_generators_to_fields()

void TABLE::bind_value_generators_to_fields ( )

Bind all the table's value generator columns in all the forms: stored/virtual GC, default expressions and checked constraints.

When a table is opened from the dictionary, the Value Generator expressions are bound during opening (see fix_value_generator_fields()). After query execution, Item::cleanup() is called on them (see cleanup_value_generator_items()). When the table is opened from the table cache, the Value Generetor(s) need to be bound again and this function does that.

◆ blobs_need_not_keep_old_value()

void TABLE::blobs_need_not_keep_old_value ( )

Virtual fields of type BLOB have a flag m_keep_old_value.

This flag is set to false for all such fields in this table.

◆ check_read_removal()

bool TABLE::check_read_removal ( uint  index)

Read removal is possible if the selected quick read method is using full unique index.

See also
HA_READ_BEFORE_WRITE_REMOVAL
Parameters
indexNumber of the index used for read
Return values
truesuccess, read removal started
falseread removal not started

◆ cleanup_partial_update()

void TABLE::cleanup_partial_update ( )

Clean up state used for partial update of JSON columns.

This function should be called at the end of each statement execution.

◆ cleanup_value_generator_items()

void TABLE::cleanup_value_generator_items ( )

Clean any state in items associated with generated columns to be ready for the next statement.

◆ clear_column_bitmaps()

void TABLE::clear_column_bitmaps ( void  )

◆ clear_partial_update_diffs()

void TABLE::clear_partial_update_diffs ( )

Clear the diffs that have been collected for partial update of JSON columns, and re-enable partial update for any columns where partial update was temporarily disabled for the current row.

Should be called between each row that is updated.

◆ column_bitmaps_set()

void TABLE::column_bitmaps_set ( MY_BITMAP read_set_arg,
MY_BITMAP write_set_arg 
)

◆ column_bitmaps_set_no_signal()

void TABLE::column_bitmaps_set_no_signal ( MY_BITMAP read_set_arg,
MY_BITMAP write_set_arg 
)
inline

◆ cost_model()

const Cost_model_table * TABLE::cost_model ( ) const
inline

Return the cost model object for this table.

◆ default_column_bitmaps()

void TABLE::default_column_bitmaps ( )
inline

◆ default_values_offset()

ptrdiff_t TABLE::default_values_offset ( ) const
inline

◆ disable_binary_diffs_for_current_row()

void TABLE::disable_binary_diffs_for_current_row ( const Field field)

Temporarily disable collection of binary diffs for a column in the current row.

This function is called during execution to disable partial update of a column that was previously marked as eligible for partial update with mark_column_for_partial_update() during preparation.

Partial update of this column will be re-enabled when we go to the next row.

Parameters
fieldthe column to stop collecting binary diffs for

◆ disable_logical_diffs_for_current_row()

void TABLE::disable_logical_diffs_for_current_row ( const Field field) const

Temporarily disable collection of Json_diff objects describing the logical changes of a JSON column in the current row.

Collection of logical JSON diffs is re-enabled when we go to the next row.

Parameters
fieldthe column to stop collecting logical JSON diffs for

◆ drop_unused_tmp_keys()

void TABLE::drop_unused_tmp_keys ( bool  modify_share)

For a materialized derived table: after move_tmp_key() has moved all definitions of used KEYs, in TABLE::key_info we have a head of used keys followed by a tail of unused keys; this function chops the tail.

Parameters
modify_shareDo modifications to TABLE_SHARE.
See also
alloc_tmp_keys

◆ empty_result_table()

bool TABLE::empty_result_table ( )

Empties internal temporary table (deletes rows, closes scan)

◆ fill_item_list()

bool TABLE::fill_item_list ( mem_root_deque< Item * > *  item_list) const

Create Item_field for each column in the table.

SYNPOSIS TABLE::fill_item_list() item_list a pointer to an empty list used to store items

Create Item_field object for each column in the table and initialize it with the corresponding Field. New items are created in the current THD memory root.

Return values
0success
1out of memory

◆ find_histogram()

const histograms::Histogram * TABLE::find_histogram ( uint  field_index) const

Find the histogram for the given field index.

Note
If this is called on a TABLE object that belongs to a secondary engine, it will take a round-trip through the handler in order to obtain the histogram from the TABLE object associated with the primary engine. This is done to avoid storing histograms on both the primary and secondary TABLE_SHARE.
Parameters
field_indexThe index of the field we want to find a histogram for.
Return values
nullptrif no histogram is found.
Pointerto a histogram if one is found.

◆ get_binary_diffs()

const Binary_diff_vector * TABLE::get_binary_diffs ( const Field field) const

Get the list of binary diffs that have been collected for a given column in the current row, or nullptr if partial update cannot be used for that column.

Parameters
fieldthe column to get binary diffs for
Returns
the list of binary diffs for the column, or nullptr if the column cannot be updated using partial update

◆ get_logical_diffs()

const Json_diff_vector * TABLE::get_logical_diffs ( const Field_json field) const

Get the list of JSON diffs that have been collected for a given column in the current row, or nullptr if partial update cannot be used for that column.

Parameters
fieldthe column to get JSON diffs for
Returns
the list of JSON diffs for the column, or nullptr if the column cannot be updated using partial update

◆ get_partial_update_buffer()

String * TABLE::get_partial_update_buffer ( )

Get a buffer that can be used to hold the partially updated column value while performing partial update.

◆ get_primary_handler()

handler * TABLE::get_primary_handler ( ) const

Returns the primary engine handler for the table.

If none exist, nullptr is returned.

◆ has_binary_diff_columns()

bool TABLE::has_binary_diff_columns ( ) const

Does this table have any columns that can be updated using partial update in the current row?

Returns
whether any columns in the current row can be updated using partial update

◆ has_columns_marked_for_partial_update()

bool TABLE::has_columns_marked_for_partial_update ( ) const

Does this table have any columns that were marked with mark_column_for_partial_update()?

Note that this only tells if any of the columns satisfy the syntactical requirements for being partially updated. Use has_binary_diff_columns(), is_binary_diff_enabled() or is_logical_diff_enabled() instead to see if partial update should be used on a column.

◆ has_deleted_row()

bool TABLE::has_deleted_row ( ) const
inline
Returns
true if current row has been deleted (multi-table delete)

◆ has_gcol()

bool TABLE::has_gcol ( ) const
inline
Returns
true if table contains one or more generated columns

◆ has_invalid_dict()

bool TABLE::has_invalid_dict ( ) const
inline
Note
Can be called by thread owning table without additional locking, and by any other thread which has acquired owner's THD::LOCK_thd_data lock.

◆ has_invalid_stats()

bool TABLE::has_invalid_stats ( )
inline
Note
Can be called by thread owning Table_cache::m_lock

◆ has_null_row()

bool TABLE::has_null_row ( ) const
inline
Returns
true if current row is null-extended

◆ has_row()

bool TABLE::has_row ( ) const
inline
Returns
true if there is a row in row buffer

◆ has_storage_handler()

bool TABLE::has_storage_handler ( ) const
inline
Returns
true if a storage engine handler object is assigned to table

◆ has_updated_row()

bool TABLE::has_updated_row ( ) const
inline
Returns
true if current row has been updated (multi-table update)

◆ index_contains_some_virtual_gcol()

bool TABLE::index_contains_some_virtual_gcol ( uint  index_no) const
inline

Check whether the given index has a virtual generated columns.

Parameters
index_nothe given index to check
Returns
true if if index is defined over at least one virtual generated column

◆ init()

void TABLE::init ( THD thd,
Table_ref tl 
)

Initialize TABLE instance (newly created, or coming either from table cache or THD::temporary_tables list) and prepare it for further use during statement execution.

Set the 'alias' attribute from the specified Table_ref element. Remember the Table_ref element in the TABLE::pos_in_table_list member.

Parameters
thdThread context.
tlTable_ref element.

◆ init_cost_model()

void TABLE::init_cost_model ( const Cost_model_server cost_model_server)
inline

Initialize the optimizer cost model.

This function should be called each time a new query is started.

Parameters
cost_model_serverthe main cost model object for the query

◆ init_tmp_table()

bool TABLE::init_tmp_table ( THD thd,
TABLE_SHARE share,
MEM_ROOT m_root,
CHARSET_INFO charset,
const char *  alias_arg,
Field **  fld,
uint *  blob_fld,
bool  is_virtual 
)

Initialize table as internal tmp table.

Parameters
thdthread handle
sharetable share
m_roottable's mem root
charsettable's charset
alias_argtable's alias
fldtable's fields array
blob_fldbuffer for blob field index
is_virtualtrue <=> it's a virtual tmp table
Returns
true OOM false otherwise

◆ invalidate_dict()

void TABLE::invalidate_dict ( )

◆ invalidate_stats()

void TABLE::invalidate_stats ( )

◆ is_binary_diff_enabled()

bool TABLE::is_binary_diff_enabled ( const Field field) const

Is partial update using binary diffs enabled on this JSON column?

Parameters
fieldthe column to check
Returns
whether the column can be updated with binary diffs

◆ is_created()

bool TABLE::is_created ( ) const
inline

Return true if table is instantiated, and false otherwise.

◆ is_distinct()

bool TABLE::is_distinct ( ) const
inline

◆ is_except()

bool TABLE::is_except ( ) const
inline

◆ is_intersect()

bool TABLE::is_intersect ( ) const
inline

◆ is_logical_diff_enabled()

bool TABLE::is_logical_diff_enabled ( const Field field) const

Is partial update using logical diffs enabled on this JSON column?

Parameters
fieldthe column to check
Returns
whether the column can be updated with JSON diffs

◆ is_marked_for_partial_update()

bool TABLE::is_marked_for_partial_update ( const Field field) const

Has this column been marked for partial update?

Note that this only tells if the column satisfies the syntactical requirements for being partially updated. Use is_binary_diff_enabled() or is_logical_diff_enabled() instead to see if partial update should be used on the column.

Parameters
fieldthe column to check
Returns
whether the column has been marked for partial update

◆ is_nullable()

bool TABLE::is_nullable ( ) const
inline

Return whether table is nullable.

◆ is_started()

bool TABLE::is_started ( ) const
inline
Returns
true if a row operation has been done

◆ is_union_or_table()

bool TABLE::is_union_or_table ( ) const
inline

Test if this tmp table stores the result of a UNION set operation or a single table.

Returns
true if so, else false.

◆ mark_auto_increment_column()

void TABLE::mark_auto_increment_column ( void  )

Mark auto-increment fields as used fields in both read and write maps.

Note
This is needed in insert & update as the auto-increment field is always set and sometimes read.

◆ mark_check_constraint_columns()

void TABLE::mark_check_constraint_columns ( bool  is_update)

Update the read_map with columns needed for check constraint evaluation when doing update and insert operations.

The read_map is filled with the base columns and generated columns to be read to evaluate check constraints. Prerequisites for UPDATE is, write_map is filled with the base columns to be updated and generated columns that are dependent on updated base columns.

Parameters
is_updatetrue means the operation is UPDATE. false means it's INSERT.

◆ mark_column_for_partial_update()

bool TABLE::mark_column_for_partial_update ( const Field field)

Mark a given column as one that can potentially be updated using partial update during execution of an update statement.

Whether it is actually updated using partial update, is not determined until execution time, since that depends both on the data that is in the column and the new data that is written to the column.

This function should be called during preparation of an update statement.

Parameters
fielda column which is eligible for partial update
Return values
falseon success
trueon out-of-memory

◆ mark_column_used()

void TABLE::mark_column_used ( Field field,
enum enum_mark_columns  mark 
)

Mark column as either read or written (or none) according to mark_used.

Note
If TABLE::get_fields_in_item_tree is set, set the flag bit GET_FIXED_FIELDS_FLAG for the field.
Parameters
fieldThe column to be marked as used
mark=MARK_COLUMNS_NONE: Only update flag field, if applicable =MARK_COLUMNS_READ: Mark column as read =MARK_COLUMNS_WRITE: Mark column as written =MARK_COLUMNS_TEMP: Mark column as read, used by filesort() and processing of generated columns

◆ mark_columns_needed_for_delete()

void TABLE::mark_columns_needed_for_delete ( THD thd)

◆ mark_columns_needed_for_insert()

void TABLE::mark_columns_needed_for_insert ( THD thd)

◆ mark_columns_needed_for_update()

void TABLE::mark_columns_needed_for_update ( THD thd,
bool  mark_binlog_columns 
)

Mark columns needed for doing an update of a row.

Some engines needs to have all columns in an update (to be able to build a complete row). If this is the case, we mark all not updated columns to be read.

If this is not the case, we do like in the delete case and mark if needed, either the primary key column or all columns to be read. (see mark_columns_needed_for_delete() for details)

If the engine has HA_REQUIRES_KEY_COLUMNS_FOR_DELETE, we will mark all USED key columns as 'to-be-read'. This allows the engine to loop over the given record to find all changed keys and doesn't have to retrieve the row again.

Unlike other similar methods, it doesn't mark fields used by triggers, that is the responsibility of the caller to do, by using Table_trigger_dispatcher::mark_used_fields(TRG_EVENT_UPDATE)!

Note: Marking additional columns as per binlog_row_image requirements will influence query execution plan. For example in the case of binlog_row_image=FULL the entire read_set and write_set needs to be flagged. This will influence update query to think that 'used key is being modified' and query will create a temporary table to process the update operation. Which will result in performance degradation. Hence callers who don't want their query execution to be influenced as per binlog_row_image requirements can skip marking binlog specific columns here and they should make an explicit call to 'mark_columns_per_binlog_row_image()' function to mark binlog_row_image specific columns.

◆ mark_columns_per_binlog_row_image()

void TABLE::mark_columns_per_binlog_row_image ( THD thd)

◆ mark_columns_used_by_index()

void TABLE::mark_columns_used_by_index ( uint  index)

◆ mark_columns_used_by_index_no_reset()

void TABLE::mark_columns_used_by_index_no_reset ( uint  index,
MY_BITMAP bitmap,
uint  key_parts = 0 
) const

mark columns used by key, but don't reset other fields

The parameter key_parts is used for controlling how many of the key_parts that will be marked in the bitmap. It has the following interpretation:

= 0: Use all regular key parts from the key (user_defined_key_parts) >= actual_key_parts: Use all regular and extended columns < actual_key_parts: Use this exact number of key parts

To use all regular key parts, the caller can use the default value (0). To use all regular and extended key parts, use UINT_MAX.

Note
The bit map is not cleared by this function. Only bits corresponding to a column used by the index will be set. Bits representing columns not used by the index will not be changed.
Parameters
indexindex number
bitmapbitmap to mark
key_partsnumber of leading key parts to mark. Default is 0.

◆ mark_gcol_in_maps()

void TABLE::mark_gcol_in_maps ( const Field field)

Adds a generated column and its dependencies to the read_set/write_set bitmaps.

If the value of a generated column (gcol) must be calculated, it needs to be in write_set (to satisfy the assertion in Field::store); the value of its underlying base columns is necessary to the calculation so those must be in read_set.

A gcol must be calculated in two cases:

  • we're sending the gcol to the engine
  • the gcol is virtual and we're reading it from the engine without using a covering index on it.

◆ mark_generated_columns()

void TABLE::mark_generated_columns ( bool  is_update)

Update the write/read_set for generated columns when doing update and insert operation.

Parameters
is_updatetrue means the operation is UPDATE. false means it's INSERT.

Prerequisites for INSERT:

  • write_map is filled with all base columns.
  • read_map is filled with base columns and generated columns to be read. Otherwise, it is empty. covering_keys and merge_keys are adjusted according to read_map.

Actions for INSERT:

  • Fill write_map with all generated columns. Stored columns are needed because their values will be stored. Virtual columns are needed because their values must be checked against constraints and it might be referenced by latter generated columns.
  • Fill read_map with base columns for all generated columns. This has no technical reason, but is required because the function that evaluates generated functions asserts that base columns are in the read_map. covering_keys and merge_keys are adjusted according to read_map.

Prerequisites for UPDATE:

  • write_map is filled with base columns to be updated.
  • read_map is filled with base columns and generated columns to be read prior to the row update. covering_keys and merge_keys are adjusted according to read_map.

Actions for UPDATE:

  • Fill write_map with generated columns that are dependent on updated base columns and all virtual generated columns. Stored columns are needed because their values will be stored. Virtual columns are needed because their values must be checked against constraints and might be referenced by latter generated columns.

◆ move_tmp_key()

void TABLE::move_tmp_key ( int  old_idx,
bool  modify_share 
)

For a materialized derived table: moves a KEY definition from a position to the first not-yet-used position (which is lower).

Note
memset operations are used to invalidate old entries, in order to trap invalid accesses after the move. memset is considered cheap in this context.

The function needs to move the following entries:

  • The KEY (both for TABLE and TABLE_SHARE)
  • The KEY_PART_INFO objects (TABLE only, TABLE_SHARE shares with first TABLE)
  • The key names (TABLE_SHARE only)
  • rec per key information (TABLE_SHARE only)
Parameters
old_idxsource position
modify_shareDo modifications to TABLE_SHARE.
See also
alloc_tmp_keys

◆ prepare_for_position()

void TABLE::prepare_for_position ( void  )

Tell handler we are going to call position() and rnd_pos() later.

This is needed for handlers that uses the primary key to find the row. In this case we have to extend the read bitmap with the primary key fields.

Note
: Calling this function does not initialize the table for reading using rnd_pos(). rnd_init() still has to be called before rnd_pos().

◆ reset()

void TABLE::reset ( void  )

Reset state of fields after optimization and execution.

◆ reset_null_row()

void TABLE::reset_null_row ( )
inline

Clear "null row" status for the current row.

◆ restore_null_flags()

void TABLE::restore_null_flags ( )
inline

Restore the NULL flags of the current row from the designated buffer.

◆ save_null_flags()

void TABLE::save_null_flags ( )
inline

Save the NULL flags of the current row into the designated buffer.

This should be done before null-complementing a table accessed with EQRefIterator or a const table, as they need to be able to restore the original contents of the record buffer before reading the next row. This is necessary because of their special code for avoiding table access if the same row should be accessed by the next read.

◆ set_binlog_drop_if_temp()

void TABLE::set_binlog_drop_if_temp ( bool  should_binlog)

Set the variable should_binlog_drop_if_temp_flag, so that the logging of temporary tables can be decided.

Parameters
should_binlogthe value to set flag should_binlog_drop_if_temp_flag

◆ set_counter()

Field_longlong * TABLE::set_counter ( )
inline

◆ set_created()

void TABLE::set_created ( )

Set the table as "created", and enable flags in storage engine that could not be enabled without an instantiated table.

◆ set_deleted()

void TABLE::set_deleted ( )
inline

Set the contents of table to be "deleted", ie "not created", after having deleted the contents.

◆ set_deleted_row()

void TABLE::set_deleted_row ( )
inline

Set "deleted" property for the current row.

◆ set_found_row()

void TABLE::set_found_row ( )
inline

Set status for row buffer: contains row.

◆ set_keyread()

void TABLE::set_keyread ( bool  flag)

◆ set_no_row()

void TABLE::set_no_row ( )
inline

Set status for row buffer: contains no row.

This is set when

  • A lookup operation finds no row
  • A scan operation scans past the last row of the range.
  • An error in generating key values before calling storage engine.

◆ set_not_started()

void TABLE::set_not_started ( )
inline

Life cycle of the row buffer is as follows:

  • The initial state is "not started".
  • When reading a row through the storage engine handler, the status is set as "has row" or "no row", depending on whether a row was found or not. The "not started" state is cleared, as well as the "null row" state, the updated state and the deleted state.
  • When making a row available in record[0], make sure to update row status similarly to how the storage engine handler does it.
  • If a NULL-extended row is needed in join execution, the "null row" state is set. Note that this can be combined with "has row" if a row was read but condition on it was evaluated to false (happens for single-row lookup), or "no row" if no more rows could be read. Note also that for the "null row" state, the NULL bits inside the row are set to one, so the row inside the row buffer is no longer usable, unless the NULL bits are saved in a separate buffer.
  • The "is updated" and "is deleted" states are set when row is updated or deleted, respectively. Set status for row buffer as "not started"

◆ set_null_row()

void TABLE::set_null_row ( )
inline

Set current row as "null row", for use in null-complemented outer join.

The row buffer may or may not contain a valid row. set_null_row() and reset_null_row() are used by the join executor to signal the presence or absence of a NULL-extended row for an outer joined table. Null rows may also be used to specify rows that are all NULL in grouing operations.

Note
this is a destructive operation since the NULL value bit vector is overwritten. Caching operations must be aware of this.

◆ set_nullable()

void TABLE::set_nullable ( )
inline

Set table as nullable, ie it is inner wrt some outer join.

◆ set_op_type()

Set_operator_type TABLE::set_op_type ( )
inline

Returns the set operation type.

◆ set_row_status_from_handler()

void TABLE::set_row_status_from_handler ( int  status)
inline

Set "row found" status from handler result.

Parameters
status0 if row was found, <> 0 if row was not found

◆ set_set_op()

void TABLE::set_set_op ( Field_longlong set_counter,
bool  except,
bool  distinct 
)
inline

Initialize the set counter field pointer and the type of set operation other than UNION*.

Parameters
set_counterthe field in the materialized table that holds the counter we use to compute intersect or except
exceptif true, EXCEPT, else INTERSECT
distinctif true, the set operation is DISTINCT, else ALL

◆ set_storage_handler()

void TABLE::set_storage_handler ( handler file_arg)
inline

Set storage handler for temporary table.

◆ set_tmp_table_seq_id()

void TABLE::set_tmp_table_seq_id ( uint  arg)
inline

◆ set_updated_row()

void TABLE::set_updated_row ( )
inline

Set "updated" property for the current row.

◆ set_use_hash_map()

void TABLE::set_use_hash_map ( bool  use_hash_map)
inline

◆ setup_partial_update() [1/2]

bool TABLE::setup_partial_update ( )
See also
setup_partial_update(bool)

This is a wrapper that auto-computes the value of the parameter logical_diffs.

Return values
falseon success
trueon out-of-memory

◆ setup_partial_update() [2/2]

bool TABLE::setup_partial_update ( bool  logical_diffs)

Enable partial update of JSON columns in this table.

It is only enabled for the columns that have previously been marked for partial update using mark_column_for_partial_update().

Parameters
logical_diffsshould logical JSON diffs be collected in addition to the physical binary diffs?

This function should be called once per statement execution, when the update statement is optimized.

Return values
falseon success
trueon out-of-memory

◆ should_binlog_drop_if_temp()

bool TABLE::should_binlog_drop_if_temp ( void  ) const
Returns
whether should_binlog_drop_if_temp_flag flag is set or not

◆ update_const_key_parts()

void TABLE::update_const_key_parts ( Item conds)

Update TABLE::const_key_parts for single table UPDATE/DELETE query.

Parameters
condsWHERE clause condition
Note
Set const_key_parts bits if key fields are equal to constants in the WHERE condition.

◆ update_covering_prefix_keys()

void TABLE::update_covering_prefix_keys ( Field field,
uint16  key_read_length,
Key_map covering_prefix_keys 
)

Update covering keys depending on max read key length.

Update available covering keys for the table, based on a constrained field and the identified covering prefix keys: If the matched part of field is longer than the index prefix, the prefix index cannot be used as a covering index.

Parameters
[in]fieldPointer to field object
[in]key_read_lengthMax read key length
[in]covering_prefix_keysCovering prefix keys

◆ use_all_columns()

void TABLE::use_all_columns ( )
inline

◆ uses_hash_map()

bool TABLE::uses_hash_map ( ) const
inline

◆ visible_field_count()

uint TABLE::visible_field_count ( ) const
inline
Returns
count of visible fields

◆ visible_field_ptr()

Field ** TABLE::visible_field_ptr ( ) const
inline
Returns
first non-hidden column

Friends And Related Function Documentation

◆ Table_cache_element

friend class Table_cache_element
friend

Member Data Documentation

◆ alias

const char* TABLE::alias {nullptr}

alias or table name

◆ alias_name_used

bool TABLE::alias_name_used {false}

◆ all_partitions_pruned_away

bool TABLE::all_partitions_pruned_away {false}

◆ autoinc_field_has_explicit_non_null_value

bool TABLE::autoinc_field_has_explicit_non_null_value {false}

To indicate that value of the auto_increment field was provided explicitly by the user or from some other source (e.g.

in case of INSERT ... SELECT, ALTER TABLE or LOAD DATA) and not as default or result of conversion from NULL value.

Note
Since auto_increment fields are always non-NULL we can't find out using methods of Field class if 0 value stored in such field was provided explicitly or is result of applying default/conversion from NULL value. In the former case no new auto_increment value needs to be generated in MODE_NO_AUTO_VALUE_ON_ZERO mode, while the latter cases require new value generation. Hence the need for this flag.
Used only in the MODE_NO_AUTO_VALUE_ON_ZERO mode and only by handler::write_row().

◆ base_key_parts

KEY_PART_INFO* TABLE::base_key_parts {nullptr}

Key part array for generated keys, used for materialized derived tables.

This is a contiguous array, with size given by s->max_tmp_key_parts.

◆ blob_storage

Blob_mem_storage* TABLE::blob_storage {nullptr}

Initialized in Item_func_group_concat::setup for appropriate temporary table if GROUP_CONCAT is used with ORDER BY | DISTINCT and BLOB field count > 0.

◆ cache_next

TABLE* TABLE::cache_next {nullptr}
private

Links for the lists of used/unused TABLE objects for the particular table in the specific instance of Table_cache (in other words for specific Table_cache_element object).

Declared as private to avoid direct manipulation with those objects. One should use methods of I_P_List template instead.

◆ cache_prev

TABLE ** TABLE::cache_prev {nullptr}
private

◆ cond_set

MY_BITMAP TABLE::cond_set

◆ const_key_parts

key_part_map TABLE::const_key_parts[MAX_KEY] {0}

◆ const_table

bool TABLE::const_table {false}

◆ copy_blobs

bool TABLE::copy_blobs {false}

◆ covering_keys

Key_map TABLE::covering_keys

◆ created

bool TABLE::created {false}
private

For tmp tables.

true <=> tmp table has been instantiated. Also indicates that table was successfully opened since we immediately delete tmp tables which we fail to open.

◆ current_lock

int TABLE::current_lock {0}

◆ db_stat

uint TABLE::db_stat {0}

◆ def_fields_set_during_insert

MY_BITMAP TABLE::def_fields_set_during_insert

Bitmap of table fields (columns), which are explicitly set in the INSERT INTO statement.

It is declared here to avoid memory allocation on MEM_ROOT).

See also
fields_set_during_insert.

◆ def_read_set

MY_BITMAP TABLE::def_read_set

◆ def_write_set

MY_BITMAP TABLE::def_write_set

◆ duplicate_removal_iterator

SortingIterator* TABLE::duplicate_removal_iterator {nullptr}

◆ field

Field** TABLE::field {nullptr}

◆ fields_for_functional_indexes

MY_BITMAP TABLE::fields_for_functional_indexes

A bitmap marking the hidden generated columns that exists for functional indexes.

◆ fields_set_during_insert

MY_BITMAP* TABLE::fields_set_during_insert {nullptr}

A pointer to the bitmap of table fields (columns), which are explicitly set in the INSERT INTO statement.

fields_set_during_insert points to def_fields_set_during_insert for base (non-temporary) tables. In other cases, it is NULL. Triggers can not be defined for temporary tables, so this bitmap does not matter for temporary tables.

See also
def_fields_set_during_insert.

◆ file

handler* TABLE::file {nullptr}

◆ force_index

bool TABLE::force_index {false}

◆ force_index_group

bool TABLE::force_index_group {false}

Flag set when the statement contains FORCE INDEX FOR GROUP BY See Table_ref::process_index_hints().

◆ force_index_order

bool TABLE::force_index_order {false}

Flag set when the statement contains FORCE INDEX FOR ORDER BY See Table_ref::process_index_hints().

◆ found_next_number_field

Field* TABLE::found_next_number_field {nullptr}

◆ fts_doc_id_field

Field* TABLE::fts_doc_id_field {nullptr}

◆ gen_def_fields_ptr

Field** TABLE::gen_def_fields_ptr {nullptr}

Pointer to fields having the default value generated.

◆ get_fields_in_item_tree

bool TABLE::get_fields_in_item_tree {false}

◆ group

ORDER* TABLE::group {nullptr}

◆ hash_field

Field* TABLE::hash_field {nullptr}

Field used by unique constraint.

◆ hidden_field_count

uint TABLE::hidden_field_count {0}

Count of hidden fields, if internal temporary table; 0 otherwise.

◆ histograms

const Table_histograms* TABLE::histograms {nullptr}

◆ impossible_range

bool TABLE::impossible_range {false}

◆ in_use

THD* TABLE::in_use {nullptr}

The current session using this table object.

Should be NULL when object is not in use. For an internal temporary table, it is NULL when the table is closed. Used for two purposes:

  • Signal that the object is in use, and by which session.
  • Pass the thread handler to storage handlers. The field should NOT be used as a general THD reference, instead use a passed THD reference, or, if there is no such, current_thd. The reason for this is that we cannot guarantee the field is not NULL.

◆ insert_values

uchar* TABLE::insert_values {nullptr}

◆ join_tab

class JOIN_TAB* TABLE::join_tab {nullptr}

◆ key_info

KEY* TABLE::key_info {nullptr}

◆ key_read

bool TABLE::key_read {false}

If set, the optimizer has found that row retrieval should access index tree only.

◆ keys_in_use_for_group_by

Key_map TABLE::keys_in_use_for_group_by

◆ keys_in_use_for_order_by

Key_map TABLE::keys_in_use_for_order_by

◆ keys_in_use_for_query

Key_map TABLE::keys_in_use_for_query

◆ lock_count

uint TABLE::lock_count {0}

◆ lock_data_start

uint TABLE::lock_data_start {0}

◆ lock_position

uint TABLE::lock_position {0}

◆ lock_type

thr_lock_type TABLE::lock_type {TL_UNLOCK}

◆ m_cost_model

Cost_model_table TABLE::m_cost_model
private

Cost model object for operations on this table.

◆ m_deduplicate_with_hash_map

bool TABLE::m_deduplicate_with_hash_map {false}
private

If false, any de-duplication happens via an index on this table (e.g.

SELECT DISTINCT, set operation). If true, this table represents the output of a set operation, and de-duplication happens via an in-memory hash map, in which case we do not use any index, unless we get secondary overflow.

◆ m_invalid_dict

bool TABLE::m_invalid_dict {false}
private

This TABLE object is invalid and cannot be reused.

TABLE object might have inconsistent info or handler might not allow some operations.

For example, TABLE might have inconsistent info about partitioning. We also use this flag to avoid calling handler::reset() for partitioned InnoDB tables after in-place ALTER TABLE API commit phase and to force closing table after REPAIR TABLE has failed during its prepare phase as well.

Note
This member can be set only by thread that owns/has opened the table and while holding its THD::LOCK_thd_data lock. It can be read without locking by this owner thread, or by some other thread concurrently after acquiring owner's THD::LOCK_thd_data.
The TABLE will not be reopened under LOCK TABLES in close_thread_tables().

◆ m_invalid_stats

bool TABLE::m_invalid_stats {false}
private

This TABLE object is invalid and cannot be reused as it has outdated rec_per_key and handler stats.

Note
This member is protected from concurrent access to it by lock of Table Cache's partition to which this TABLE object belongs,

◆ m_last_operation_is_distinct

bool TABLE::m_last_operation_is_distinct {false}
private

If m_set_counter is set: true if last block has DISTINCT semantics, either because it is marked as such, or because we have computed this to give an equivalent answer.

If false, we have ALL semantics. It will be true if any DISTINCT is given in the merged N-ary set operation. See is_distinct().

◆ m_limit_rows

ha_rows TABLE::m_limit_rows {HA_POS_ERROR}

A priori unlimited.

We pass this on to TableScanIterator at construction time, q.v., to limit the number of rows out of an EXCEPT or INTERSECT. For these set operations, we do not know enough to enforce the limit at materialize time (as for UNION): only when reading the rows with TableScanIterator do we check the counters.

◆ m_partial_update_columns

MY_BITMAP* TABLE::m_partial_update_columns {nullptr}
private

Bitmap that tells which columns are eligible for partial update in an update statement.

The bitmap is lazily allocated in the TABLE's mem_root when mark_column_for_partial_update() is called.

◆ m_partial_update_info

Partial_update_info* TABLE::m_partial_update_info {nullptr}
private

Object which contains execution time state used for partial update of JSON columns.

It is allocated in the execution mem_root by setup_partial_update() if there are columns that have been marked as eligible for partial update.

◆ m_record_buffer

Record_buffer TABLE::m_record_buffer {0, 0, nullptr}

Buffer for use in multi-row reads. Initially empty.

◆ m_set_counter

Field_longlong* TABLE::m_set_counter {nullptr}
private

The set counter.

It points to the field in the materialized table holding the counter used to compute INTERSECT and EXCEPT, in record[0]. For EXCEPT [DISTINCT | ALL] and INTERSECT DISTINCT this is a simple 64 bits counter. For INTERSECT ALL, it is subdivided into two sub counters cf. class HalfCounter, cf. MaterializeOperand. See set_counter().

◆ m_set_op_type

Set_operator_type TABLE::m_set_op_type {SOT_NONE}
private

Holds the set operation type.

◆ m_status

uint8 TABLE::m_status {0}
private

◆ materialized

bool TABLE::materialized {false}

For a materializable derived or SJ table: true if has been materialized.

◆ mdl_ticket

MDL_ticket* TABLE::mdl_ticket {nullptr}

◆ mem_root

MEM_ROOT TABLE::mem_root

◆ merge_keys

Key_map TABLE::merge_keys

◆ next

TABLE* TABLE::next {nullptr}

◆ next_number_field

Field* TABLE::next_number_field {nullptr}

◆ no_keyread

bool TABLE::no_keyread {false}

Certain statements which need the full row, set this to ban index-only access.

◆ no_replicate

bool TABLE::no_replicate {false}

If set, indicate that the table is not replicated by the server.

◆ no_rows

bool TABLE::no_rows {false}

True if writes to this table should not write rows and just write keys.

◆ not_exists_optimize

bool TABLE::not_exists_optimize {false}

◆ null_flags

uchar* TABLE::null_flags {nullptr}

Pointer to the null flags of record[0].

◆ null_flags_saved

uchar* TABLE::null_flags_saved
Initial value:
{
nullptr}

Saved null_flags while null_row is true.

◆ null_row

bool TABLE::null_row {false}

◆ nullable

bool TABLE::nullable {false}
private

If true, this table is inner w.r.t.

some outer join operation, all columns are nullable (in the query), and null_row may be true.

◆ open_by_handler

bool TABLE::open_by_handler {false}

◆ pack_row_tmp_set

MY_BITMAP TABLE::pack_row_tmp_set

◆ part_info

partition_info* TABLE::part_info {nullptr}

◆ pos_in_locked_tables

Table_ref* TABLE::pos_in_locked_tables {nullptr}

◆ pos_in_table_list

Table_ref* TABLE::pos_in_table_list {nullptr}

◆ possible_quick_keys

Key_map TABLE::possible_quick_keys

◆ prev

TABLE * TABLE::prev {nullptr}

◆ qep_tab

class QEP_TAB* TABLE::qep_tab {nullptr}

◆ query_id

query_id_t TABLE::query_id {0}

◆ quick_condition_rows

ha_rows TABLE::quick_condition_rows {0}

◆ quick_key_parts

uint TABLE::quick_key_parts[MAX_KEY] {0}

◆ quick_keys

Key_map TABLE::quick_keys

◆ quick_n_ranges

uint TABLE::quick_n_ranges[MAX_KEY] {0}

◆ quick_rows

ha_rows TABLE::quick_rows[MAX_KEY] {0}

◆ read_set

MY_BITMAP* TABLE::read_set {nullptr}

The read set contains the set of columns that the execution engine needs to process the query.

In particular, it is used to tell the storage engine which columns are needed. For virtual generated columns, the underlying base columns are also added, since they are required in order to calculate the virtual generated columns.

Internal operations in the execution engine that need to move rows between buffers, such as aggregation, sorting, hash join and set operations, should rather use read_set_internal, since the virtual generated columns have already been calculated when the row was read from the storage engine.

Set during resolving; every field that gets resolved, sets its own bit in the read set. In some cases, we switch the read set around during various phases; note that it is a pointer.

In addition, for binary logging purposes, the bitmaps are set according to the settings of @binlog_row_image. Therefore, for logging purposes, some additional fields, to those specified by the optimizer, may be flagged in the read and write sets. TABLE::mark_columns_per_binlog_row_image for additional details.

◆ read_set_internal

MY_BITMAP TABLE::read_set_internal

A bitmap of fields that are explicitly referenced by the query.

This is mostly the same as read_set, but it does not include base columns of referenced virtual generated columns unless the base columns are referenced explicitly in the query.

This is the read set that should be used for determining which columns to store in join buffers, aggregation buffers, sort buffers, or similar operations internal to the execution engine. Both because it is unnecessary to store the implicitly read base columns in the buffer, since they won't ever be read out of the buffer anyways, and because the base columns may not even be possible to read, if a covering index scan is used and the index only contains the virtual column and not all its base columns.

◆ record

uchar* TABLE::record[2] {nullptr, nullptr}

◆ 

struct { ... } TABLE::reginfo

◆ s

TABLE_SHARE* TABLE::s {nullptr}

◆ should_binlog_drop_if_temp_flag

bool TABLE::should_binlog_drop_if_temp_flag {false}
private

This flag decides whether or not we should log the drop temporary table command.

◆ sorting_iterator

SortingIterator* TABLE::sorting_iterator {nullptr}

Not owned by the TABLE; used only from filesort_free_buffers().

See comments on SortingIterator::CleanupAfterQuery().

◆ table_check_constraint_list

Sql_table_check_constraint_list* TABLE::table_check_constraint_list {nullptr}

◆ tmp_set

MY_BITMAP TABLE::tmp_set

◆ tmp_table_seq_id

uint TABLE::tmp_table_seq_id {0}
private

Internal tmp table sequential number.

Increased in the order of creation. Used for debugging purposes when many tmp tables are used during execution (e.g several windows with window functions)

◆ triggers

Table_trigger_dispatcher* TABLE::triggers {nullptr}

◆ unique_result

Sort_result TABLE::unique_result

The result of applying a unique operation (by row ID) to the table, if done.

In particular, this is done in some forms of index merge.

◆ vfield

Field** TABLE::vfield {nullptr}

Pointer to generated columns.

◆ write_row_record

uchar* TABLE::write_row_record {nullptr}

◆ write_set

MY_BITMAP* TABLE::write_set {nullptr}

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