MySQL 9.1.0
Source Code Documentation
|
#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_longlong * | set_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_table * | cost_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... | |
handler * | get_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_vector * | 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. 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... | |
String * | get_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_vector * | 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. 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::Histogram * | find_histogram (uint field_index) const |
Find the histogram for the given field index. More... | |
Public Attributes | |
TABLE_SHARE * | s {nullptr} |
handler * | file {nullptr} |
TABLE * | next {nullptr} |
TABLE * | prev {nullptr} |
const Table_histograms * | histograms {nullptr} |
MY_BITMAP | fields_for_functional_indexes |
A bitmap marking the hidden generated columns that exists for functional indexes. More... | |
THD * | in_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... | |
uchar * | record [2] {nullptr, nullptr} |
uchar * | write_row_record {nullptr} |
uchar * | insert_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 |
KEY * | key_info {nullptr} |
KEY_PART_INFO * | base_key_parts {nullptr} |
Key part array for generated keys, used for materialized derived tables. More... | |
Field * | next_number_field {nullptr} |
Field * | found_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... | |
Field * | hash_field {nullptr} |
Field used by unique constraint. More... | |
ha_rows | m_limit_rows {HA_POS_ERROR} |
A priori unlimited. More... | |
bool | m_charset_conversion_is_strict {false} |
True if character set conversions are always strict. More... | |
Field * | fts_doc_id_field {nullptr} |
Table_trigger_dispatcher * | triggers {nullptr} |
Table_ref * | pos_in_table_list {nullptr} |
Table_ref * | pos_in_locked_tables {nullptr} |
ORDER * | group {nullptr} |
const char * | alias {nullptr} |
alias or table name More... | |
uchar * | null_flags {nullptr} |
Pointer to the null flags of record[0]. More... | |
uchar * | null_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_BITMAP * | read_set {nullptr} |
The read set contains the set of columns that the execution engine needs to process the query. More... | |
MY_BITMAP * | write_set {nullptr} |
MY_BITMAP | read_set_internal |
A bitmap of fields that are explicitly referenced by the query. More... | |
MY_BITMAP * | fields_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_list * | table_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_storage * | 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. More... | |
SortingIterator * | sorting_iterator {nullptr} |
Not owned by the TABLE; used only from filesort_free_buffers(). More... | |
SortingIterator * | duplicate_removal_iterator {nullptr} |
Sort_result | unique_result |
The result of applying a unique operation (by row ID) to the table, if done. More... | |
partition_info * | part_info {nullptr} |
bool | all_partitions_pruned_away {false} |
MDL_ticket * | mdl_ticket {nullptr} |
Private Attributes | |
TABLE * | cache_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} |
TABLE * | triggers_lru_next {nullptr} |
Links for the LRU list of unused TABLE objects with fully loaded triggers in the specific instance of Table_cache. More... | |
TABLE ** | triggers_lru_prev {nullptr} |
Field_longlong * | m_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_BITMAP * | m_partial_update_columns {nullptr} |
Bitmap that tells which columns are eligible for partial update in an update statement. More... | |
Partial_update_info * | m_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 |
class | Table_cache |
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.
field | the column that is being updated |
offset | the offset of the changed portion |
length | the length of the changed portion |
false | on success |
true | on out-of-memory |
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.
field | the column that is updated |
path | the JSON path that is changed |
operation | the operation to perform |
new_value | the new value in the path |
std::bad_alloc | if memory cannot be allocated |
bool TABLE::add_tmp_key | ( | Field_map * | key_parts, |
bool | invisible, | ||
bool | modify_share | ||
) |
Add one key to a materialized derived table.
key_parts | bitmap of fields that take a part in the key. |
invisible | If true, set up bitmaps so the key is never used by this TABLE |
modify_share | Do modifications to TABLE_SHARE. |
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().
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.
new_key_count | Number of wanted keys. |
new_key_part_count | Number of wanted key parts. |
modify_share | Do 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.
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.
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.
bool TABLE::check_read_removal | ( | uint | index | ) |
Read removal is possible if the selected quick read method is using full unique index.
index | Number of the index used for read |
true | success, read removal started |
false | read removal not started |
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.
void TABLE::cleanup_value_generator_items | ( | ) |
Clean any state in items associated with generated columns to be ready for the next statement.
void TABLE::clear_column_bitmaps | ( | void | ) |
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.
|
inline |
|
inline |
Return the cost model object for this table.
|
inline |
|
inline |
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.
field | the column to stop collecting binary diffs for |
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.
field | the column to stop collecting logical JSON diffs for |
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.
modify_share | Do modifications to TABLE_SHARE. |
bool TABLE::empty_result_table | ( | ) |
Empties internal temporary table (deletes rows, closes scan)
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.
0 | success |
1 | out of memory |
const histograms::Histogram * TABLE::find_histogram | ( | uint | field_index | ) | const |
Find the histogram for the given field index.
field_index | The index of the field we want to find a histogram for. |
nullptr | if no histogram is found. |
Pointer | to a histogram if one is found. |
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.
field | the column to get binary diffs for |
nullptr
if the column cannot be updated using partial update 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.
field | the column to get JSON diffs for |
nullptr
if the column cannot be updated using partial update String * TABLE::get_partial_update_buffer | ( | ) |
Get a buffer that can be used to hold the partially updated column value while performing partial update.
handler * TABLE::get_primary_handler | ( | ) | const |
Returns the primary engine handler for the table.
If none exist, nullptr is returned.
bool TABLE::has_binary_diff_columns | ( | ) | const |
Does this table have any columns that can be updated using partial update in the current row?
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Check whether the given index has a virtual generated columns.
index_no | the given index to check |
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.
thd | Thread context. |
tl | Table_ref element. |
|
inline |
Initialize the optimizer cost model.
This function should be called each time a new query is started.
cost_model_server | the main cost model object for the query |
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.
thd | thread handle |
share | table share |
m_root | table's mem root |
charset | table's charset |
alias_arg | table's alias |
fld | table's fields array |
blob_fld | buffer for blob field index |
is_virtual | true <=> it's a virtual tmp table |
void TABLE::invalidate_dict | ( | ) |
void TABLE::invalidate_stats | ( | ) |
bool TABLE::is_binary_diff_enabled | ( | const Field * | field | ) | const |
Is partial update using binary diffs enabled on this JSON column?
field | the column to check |
|
inline |
Return true if table is instantiated, and false otherwise.
|
inline |
|
inline |
|
inline |
bool TABLE::is_logical_diff_enabled | ( | const Field * | field | ) | const |
Is partial update using logical diffs enabled on this JSON column?
field | the column to check |
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.
field | the column to check |
|
inline |
Return whether table is nullable.
|
inline |
|
inline |
Test if this tmp table stores the result of a UNION set operation or a single table.
void TABLE::mark_auto_increment_column | ( | void | ) |
Mark auto-increment fields as used fields in both read and write maps.
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.
is_update | true means the operation is UPDATE. false means it's INSERT. |
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.
field | a column which is eligible for partial update |
false | on success |
true | on out-of-memory |
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.
field | The 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 |
void TABLE::mark_columns_needed_for_delete | ( | THD * | thd | ) |
void TABLE::mark_columns_needed_for_insert | ( | THD * | thd | ) |
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.
void TABLE::mark_columns_per_binlog_row_image | ( | THD * | thd | ) |
void TABLE::mark_columns_used_by_index | ( | uint | index | ) |
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.
index | index number |
bitmap | bitmap to mark |
key_parts | number of leading key parts to mark. Default is 0. |
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:
void TABLE::mark_generated_columns | ( | bool | is_update | ) |
Update the write/read_set for generated columns when doing update and insert operation.
is_update | true means the operation is UPDATE. false means it's INSERT. |
Prerequisites for INSERT:
Actions for INSERT:
Prerequisites for UPDATE:
Actions for UPDATE:
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).
The function needs to move the following entries:
old_idx | source position |
modify_share | Do modifications to TABLE_SHARE. |
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.
void TABLE::reset | ( | void | ) |
Reset state of fields after optimization and execution.
|
inline |
Clear "null row" status for the current row.
|
inline |
Restore the NULL flags of the current row from the designated buffer.
|
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.
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.
should_binlog | the value to set flag should_binlog_drop_if_temp_flag |
|
inline |
void TABLE::set_created | ( | ) |
Set the table as "created", and enable flags in storage engine that could not be enabled without an instantiated table.
|
inline |
Set the contents of table to be "deleted", ie "not created", after having deleted the contents.
|
inline |
Set "deleted" property for the current row.
|
inline |
Set status for row buffer: contains row.
void TABLE::set_keyread | ( | bool | flag | ) |
|
inline |
Set status for row buffer: contains no row.
This is set when
|
inline |
Life cycle of the row buffer is as follows:
|
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.
|
inline |
Set table as nullable, ie it is inner wrt some outer join.
|
inline |
Returns the set operation type.
|
inline |
Set "row found" status from handler result.
status | 0 if row was found, <> 0 if row was not found |
|
inline |
Initialize the set counter field pointer and the type of set operation other than UNION*.
set_counter | the field in the materialized table that holds the counter we use to compute intersect or except |
except | if true, EXCEPT, else INTERSECT |
distinct | if true, the set operation is DISTINCT, else ALL |
|
inline |
Set storage handler for temporary table.
|
inline |
|
inline |
Set "updated" property for the current row.
|
inline |
bool TABLE::setup_partial_update | ( | ) |
This is a wrapper that auto-computes the value of the parameter logical_diffs.
false | on success |
true | on out-of-memory |
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().
logical_diffs | should 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.
false | on success |
true | on out-of-memory |
bool TABLE::should_binlog_drop_if_temp | ( | void | ) | const |
void TABLE::update_const_key_parts | ( | Item * | conds | ) |
Update TABLE::const_key_parts for single table UPDATE/DELETE query.
conds | WHERE clause condition |
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.
[in] | field | Pointer to field object |
[in] | key_read_length | Max read key length |
[in] | covering_prefix_keys | Covering prefix keys |
|
inline |
|
inline |
|
inline |
|
inline |
|
friend |
|
friend |
const char* TABLE::alias {nullptr} |
alias or table name
bool TABLE::alias_name_used {false} |
bool TABLE::all_partitions_pruned_away {false} |
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.
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_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.
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.
MY_BITMAP TABLE::cond_set |
key_part_map TABLE::const_key_parts[MAX_KEY] {0} |
bool TABLE::const_table {false} |
bool TABLE::copy_blobs {false} |
Key_map TABLE::covering_keys |
|
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.
int TABLE::current_lock {0} |
uint TABLE::db_stat {0} |
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).
MY_BITMAP TABLE::def_read_set |
MY_BITMAP TABLE::def_write_set |
SortingIterator* TABLE::duplicate_removal_iterator {nullptr} |
MY_BITMAP TABLE::fields_for_functional_indexes |
A bitmap marking the hidden generated columns that exists for functional indexes.
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.
bool TABLE::force_index {false} |
bool TABLE::force_index_group {false} |
Flag set when the statement contains FORCE INDEX FOR GROUP BY See Table_ref::process_index_hints().
bool TABLE::force_index_order {false} |
Flag set when the statement contains FORCE INDEX FOR ORDER BY See Table_ref::process_index_hints().
bool TABLE::get_fields_in_item_tree {false} |
uint TABLE::hidden_field_count {0} |
Count of hidden fields, if internal temporary table; 0 otherwise.
const Table_histograms* TABLE::histograms {nullptr} |
bool TABLE::impossible_range {false} |
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:
bool TABLE::key_read {false} |
If set, the optimizer has found that row retrieval should access index tree only.
Key_map TABLE::keys_in_use_for_group_by |
Key_map TABLE::keys_in_use_for_order_by |
Key_map TABLE::keys_in_use_for_query |
uint TABLE::lock_count {0} |
uint TABLE::lock_data_start {0} |
uint TABLE::lock_position {0} |
thr_lock_type TABLE::lock_type {TL_UNLOCK} |
bool TABLE::m_charset_conversion_is_strict {false} |
True if character set conversions are always strict.
|
private |
Cost model object for operations on this table.
|
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.
|
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.
|
private |
This TABLE object is invalid and cannot be reused as it has outdated rec_per_key and handler stats.
|
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().
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.
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.
|
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.
Record_buffer TABLE::m_record_buffer {0, 0, nullptr} |
Buffer for use in multi-row reads. Initially empty.
|
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().
|
private |
Holds the set operation type.
|
private |
bool TABLE::materialized {false} |
For a materializable derived or SJ table: true if has been materialized.
MDL_ticket* TABLE::mdl_ticket {nullptr} |
MEM_ROOT TABLE::mem_root |
Key_map TABLE::merge_keys |
bool TABLE::no_keyread {false} |
Certain statements which need the full row, set this to ban index-only access.
bool TABLE::no_replicate {false} |
If set, indicate that the table is not replicated by the server.
bool TABLE::no_rows {false} |
True if writes to this table should not write rows and just write keys.
bool TABLE::not_exists_optimize {false} |
uchar* TABLE::null_flags_saved |
Saved null_flags while null_row is true.
bool TABLE::null_row {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.
bool TABLE::open_by_handler {false} |
MY_BITMAP TABLE::pack_row_tmp_set |
partition_info* TABLE::part_info {nullptr} |
Key_map TABLE::possible_quick_keys |
query_id_t TABLE::query_id {0} |
ha_rows TABLE::quick_condition_rows {0} |
uint TABLE::quick_key_parts[MAX_KEY] {0} |
Key_map TABLE::quick_keys |
uint TABLE::quick_n_ranges[MAX_KEY] {0} |
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.
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.
struct { ... } TABLE::reginfo |
TABLE_SHARE* TABLE::s {nullptr} |
|
private |
This flag decides whether or not we should log the drop temporary table command.
SortingIterator* TABLE::sorting_iterator {nullptr} |
Not owned by the TABLE; used only from filesort_free_buffers().
See comments on SortingIterator::CleanupAfterQuery().
Sql_table_check_constraint_list* TABLE::table_check_constraint_list {nullptr} |
MY_BITMAP TABLE::tmp_set |
|
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)
Table_trigger_dispatcher* TABLE::triggers {nullptr} |
Links for the LRU list of unused TABLE objects with fully loaded triggers in the specific instance of Table_cache.
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.