MySQL  8.0.15
Source Code Documentation
TABLE Struct Reference

#include <table.h>

Public Member Functions

void init (THD *thd, TABLE_LIST *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 (List< Item > *item_list) const
 Create Item_field for each column in the table. More...
 
void reset_item_list (List< Item > *item_list) const
 Reset an existing list of Item_field items to point to the Fields of this 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 (THD *thd, 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)
 
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)
 
bool is_field_used_by_generated_columns (uint field_index, int *error_no)
 
void mark_gcol_in_maps (Field *field)
 Adds a generated column and its dependencies to the read_set/write_set bitmaps. 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 ()
 
bool needs_reopen ()
 Should this instance of the table be reopened? More...
 
Field ** visible_field_ptr () const
 
uint visible_field_count () const
 
bool alloc_tmp_keys (uint key_count, bool modify_share)
 Allocate space for keys, for a materialized derived table. More...
 
bool add_tmp_key (Field_map *key_parts, char *key_name, bool invisible, bool modify_share)
 Add one key to a materialized derived table. More...
 
void copy_tmp_key (int old_idx, bool modify_share)
 For a materialized derived table: copies 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 copy_tmp_key() has copied 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)
 Check whether the given index has a virtual generated columns. More...
 
bool 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...
 
my_ptrdiff_t default_values_offset () const
 
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...
 
bool refix_value_generator_items (THD *thd)
 Fix table's generated columns' (GC) and/or default expressions. More...
 
bool refix_inner_value_generator_items (THD *thd, Value_generator *g_expr, Field *field, TABLE *table, bool is_gen_col)
 Helper function for refix_value_generator_items() that fixes one column's expression (be it GC or default expression). 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...
 
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
 

Public Attributes

TABLE_SHAREs {nullptr}
 
handlerfile {nullptr}
 
TABLEnext {nullptr}
 
TABLEprev {nullptr}
 
MY_BITMAP fields_for_functional_indexes
 A bitmap marking the hidden generated columns that exists for functional indexes. More...
 
THDin_use {nullptr}
 
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}
 
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...
 
Fieldfts_doc_id_field {nullptr}
 
Table_trigger_dispatchertriggers {nullptr}
 
TABLE_LISTpos_in_table_list {nullptr}
 
TABLE_LISTpos_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}
 
MY_BITMAPwrite_set {nullptr}
 
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}
 
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_LIST::process_index_hints(). More...
 
bool force_index_group {false}
 Flag set when the statement contains FORCE INDEX FOR GROUP BY See TABLE_LIST::process_index_hints(). More...
 
bool is_distinct {false}
 Whether this is a temporary table that already has a UNIQUE index (removing duplicate rows on insert), so that the optimizer does not need to run DISTINCT itself. 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 fulltext_searched {false}
 
bool no_cache {false}
 
bool open_by_handler {false}
 
bool auto_increment_field_not_null {false}
 
bool alias_name_used {false}
 
bool get_fields_in_item_tree {false}
 
bool m_needs_reopen {false}
 This table must be reopened and is not to be reused. More...
 
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}
 
   thr_locked_row_action   locked_row_action {THR_DEFAULT}
 
   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...
 
Filesort_info sort
 
Sort_result unique_result
 The result of applying a unique opertion (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}
 
bool nullable {false}
 If true, this table is inner w.r.t. More...
 
uint8 m_status {0}
 
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 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,
char *  key_name,
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.
key_namename of the key
invisibleIf true, set up bitmaps so the key is never used by this TABLE
modify_share
See also
alloc_tmp_keys

Creates a key for this table from fields which corresponds the bits set to 1 in the 'key_parts' bitmap. The 'key_name' name is given to the newly created key. In the key, columns are in the same order as in the table.

See also
add_derived_key
Returns
true OOM error.
false the key was created or ignored (too long key).

◆ alloc_tmp_keys()

bool TABLE::alloc_tmp_keys ( uint  key_count,
bool  modify_share 
)

Allocate space for keys, for a materialized derived table.

Parameters
key_countNumber of keys to allocate.
modify_shareDo modificationts to TABLE_SHARE.

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
true if error

◆ 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

◆ copy_tmp_key()

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

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

Parameters
old_idxsource position
modify_share
See also
alloc_tmp_keys

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

my_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 copy_tmp_key() has copied 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_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 ( List< 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

◆ 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.

◆ 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_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_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)
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_LIST 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_LIST element. Remember the TABLE_LIST element in the TABLE::pos_in_table_list member.

Parameters
thdThread context.
tlTABLE_LIST 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

◆ 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_field_used_by_generated_columns()

bool TABLE::is_field_used_by_generated_columns ( uint  field_index,
int *  error_no 
)

◆ 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

◆ 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_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 ( THD thd,
Field field,
enum enum_mark_columns  mark 
)

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

Note
If marking a written field, set thd->dup_field if the column is already marked.
If TABLE::get_fields_in_item_tree is set, set the flag bit GET_FIXED_FIELDS_FLAG for the field.
Parameters
thdThread handler (only used for duplicate handling)
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 neeed, 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)

If in RBR we may need to mark some extra columns, depending on the binlog-row-image command line argument.

◆ 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 map,
uint  key_parts = 0 
)

◆ mark_gcol_in_maps()

void TABLE::mark_gcol_in_maps ( 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)

◆ needs_reopen()

bool TABLE::needs_reopen ( )
inline

Should this instance of the table be reopened?

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

◆ refix_inner_value_generator_items()

bool TABLE::refix_inner_value_generator_items ( THD thd,
Value_generator g_expr,
Field field,
TABLE table,
bool  is_gen_col 
)

Helper function for refix_value_generator_items() that fixes one column's expression (be it GC or default expression).

Parameters
[in]thdcurrent thread
[in,out]g_exprthe expression who's items needs to be fixed
[in]tablethe table it blongs to
[in]fieldthe column it blongs to
[in]is_gen_colif it is a generated column or default expression
Returns
true if error, else false

◆ refix_value_generator_items()

bool TABLE::refix_value_generator_items ( THD thd)

Fix table's generated columns' (GC) and/or default expressions.

When a table is opened from the dictionary, the Value Generator expressions are fixed during opening (see fix_value_generators_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 fixed again and this function does that.

Parameters
[in]thdthe current thread
Returns
true if error, else false

◆ reset_item_list()

void TABLE::reset_item_list ( List< Item > *  item_list) const

Reset an existing list of Item_field items to point to the Fields of this table.

SYNPOSIS TABLE::reset_item_list() item_list a non-empty list with Item_fields

This is a counterpart of fill_item_list used to redirect Item_fields to the fields of a newly created table.

◆ 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.

◆ 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_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_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_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.

◆ setup_partial_update() [1/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

◆ setup_partial_update() [2/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

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

bool TABLE::update_const_key_parts ( Item conds)

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

Parameters
condsWHERE clause expression
Return values
trueerror (OOM)
falsesuccess
Note
Set const_key_parts bits if key fields are equal to constants in the WHERE expression.

◆ 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

◆ 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}

◆ auto_increment_field_not_null

bool TABLE::auto_increment_field_not_null {false}

◆ 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

◆ 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_LIST::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_LIST::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}

◆ fulltext_searched

bool TABLE::fulltext_searched {false}

◆ 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.

◆ impossible_range

bool TABLE::impossible_range {false}

◆ in_use

THD* TABLE::in_use {nullptr}

◆ insert_values

uchar* TABLE::insert_values {nullptr}

◆ is_distinct

bool TABLE::is_distinct {false}

Whether this is a temporary table that already has a UNIQUE index (removing duplicate rows on insert), so that the optimizer does not need to run DISTINCT itself.

◆ 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}

◆ locked_row_action

thr_locked_row_action TABLE::locked_row_action {THR_DEFAULT}

◆ m_cost_model

Cost_model_table TABLE::m_cost_model
private

Cost model object for operations on this table.

◆ m_needs_reopen

bool TABLE::m_needs_reopen {false}

This table must be reopened and is not to be reused.

NOTE: The TABLE will not be reopened during LOCK TABLES in close_thread_tables!!!

◆ 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_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

That makes it impossible for any function that does memory allocation to take a const reference to a TABLE object.

◆ merge_keys

Key_map TABLE::merge_keys

◆ next

TABLE* TABLE::next {nullptr}

◆ next_number_field

Field* TABLE::next_number_field {nullptr}

◆ no_cache

bool TABLE::no_cache {false}

◆ 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_LIST* TABLE::pos_in_locked_tables {nullptr}

◆ pos_in_table_list

TABLE_LIST* 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}

◆ record

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

◆ reginfo

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.

◆ sort

Filesort_info TABLE::sort

◆ 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 opertion (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: