MySQL 8.4.2
Source Code Documentation
dict_index_t Struct Reference

Data structure for an index. More...

#include <dict0mem.h>

Public Member Functions

 UT_LIST_NODE_T (dict_index_t) indexes
 list of indexes of the table More...
 
void set_instant_nullable (uint16_t n)
 Set instant nullable. More...
 
uint16_t get_instant_nullable () const
 Get instant nullable. More...
 
uint16_t get_nullable_before_instant_add_drop () const
 Get the nullable fields before any INSTANT ADD/DROP. More...
 
bool is_committed () const
 Determine if the index has been committed to the data dictionary. More...
 
void set_committed (bool committed)
 Flag an index committed or uncommitted. More...
 
const dict_index_tnext () const
 Get the next index. More...
 
dict_index_tnext ()
 Get the next index. More...
 
bool is_corrupted () const
 Check whether the index is corrupted. More...
 
bool is_clustered () const
 
bool is_multi_value () const
 Check whether the index is the multi-value index. More...
 
ulint get_min_size () const
 Returns the minimum data size of an index record. More...
 
bool is_usable (const trx_t *trx) const
 Check whether index can be used by transaction. More...
 
bool has_instant_cols () const
 Check whether index has any instantly added columns. More...
 
bool has_row_versions () const
 Check whether index belongs to a table having row versions. More...
 
bool has_instant_cols_or_row_versions () const
 check if either instant or versioned. More...
 
bool is_tuple_instant_format (const uint16_t n_fields_in_tuple) const
 Check if tuple is having instant format. More...
 
uint32_t get_n_nullable_before (uint32_t nth) const
 Returns the number of nullable fields before specified nth field. More...
 
uint32_t get_n_total_fields () const
 Returns total fields including INSTANT DROP fields. More...
 
uint32_t get_instant_fields () const
 Returns the number of fields before first instant ADD COLUMN. More...
 
size_t calculate_n_instant_nullable (size_t _n_fields) const
 
void create_nullables (uint32_t current_row_version)
 Create nullables array. More...
 
uint32_t get_nullable_in_version (uint8_t version) const
 Return nullable in a specific row version. More...
 
void create_fields_array ()
 Create fields array sorted by phy_pos of field in row. More...
 
void destroy_fields_array ()
 
void add_field (const char *name_arg, ulint prefix_len, bool is_ascending)
 Adds a field definition to an index. More...
 
dict_field_tget_physical_field (size_t pos) const
 Gets the nth physical pos field. More...
 
dict_field_tget_field (ulint pos) const
 Gets the nth field of an index. More...
 
uint16_t get_logical_pos (uint16_t phy_pos) const
 Given the physical position, find the logical position of field. More...
 
uint16_t get_field_off_pos (ulint pos) const
 Get the physical position of a field on a row. More...
 
uint16_t get_field_phy_pos (ulint pos, uint8_t version) const
 
const dict_col_tget_col (ulint pos) const
 Gets pointer to the nth column in an index. More...
 
ulint get_col_no (ulint pos) const
 Gets the column number the nth field in an index. More...
 
ulint get_sys_col_pos (ulint type) const
 Returns the position of a system column in an index. More...
 
ulint get_col_pos (ulint n, bool inc_prefix=false, bool is_virtual=false) const
 Looks for column n in an index. More...
 
const byteget_nth_default (ulint nth, ulint *length) const
 Get the default value of nth field and its length if exists. More...
 
void fill_srid_value (uint32_t srid_value, bool srid_is_valid_value)
 Sets srid and srid_is_valid values. More...
 
bool is_compressed () const
 Check if the underlying table is compressed. More...
 
uint32_t has_multi_value_col (const dict_v_col_t *mv_col) const
 Check if a multi-value index is built on specified multi-value virtual column. More...
 
page_size_t get_page_size () const
 Get the page size of the tablespace to which this index belongs. More...
 
space_id_t space_id () const
 Get the space id of the tablespace to which this index belongs. More...
 

Public Attributes

space_index_t id
 id of the index More...
 
mem_heap_theap
 memory heap More...
 
id_name_t name
 index name More...
 
const char * table_name
 table name More...
 
dict_table_ttable
 back pointer to table More...
 
unsigned space: 32
 space where the index tree is placed More...
 
unsigned page: 32
 index tree root page number More...
 
unsigned merge_threshold: 6
 In the pessimistic delete, if the page data size drops below this limit in percent, merging it to a neighbor is tried. More...
 
unsigned type: DICT_IT_BITS
 index type (DICT_CLUSTERED, DICT_UNIQUE, DICT_IBUF, DICT_CORRUPT) More...
 
unsigned trx_id_offset: MAX_KEY_LENGTH_BITS
 position of the trx id column in a clustered index record, if the fields before it are known to be of a fixed size, 0 otherwise More...
 
unsigned n_user_defined_cols: 10
 number of columns the user defined to be in the index: in the internal representation we add more columns More...
 
unsigned allow_duplicates: 1
 if true, allow duplicate values even if index is created with unique constraint More...
 
unsigned nulls_equal: 1
 if true, SQL NULL == SQL NULL More...
 
unsigned disable_ahi: 1
 if true, then disable AHI. More...
 
unsigned n_uniq: 10
 number of fields from the beginning which are enough to determine an index entry uniquely More...
 
unsigned n_def: 10
 number of fields defined so far More...
 
unsigned n_fields: 10
 number of fields in the index More...
 
unsigned n_total_fields: 10
 number of total fields in the index (including INSTANT dropped fields) More...
 
unsigned n_nullable: 10
 number of nullable fields More...
 
unsigned n_instant_nullable: 10
 number of nullable fields before first instant ADD COLUMN applied to this table. More...
 
unsigned cached: 1
 true if the index object is in the dictionary cache More...
 
unsigned to_be_dropped: 1
 true if the index is to be dropped; protected by dict_operation_lock More...
 
unsigned online_status: 2
 enum online_index_status. More...
 
unsigned uncommitted: 1
 a flag that is set for secondary indexes that have not been committed to the data dictionary yet More...
 
unsigned instant_cols: 1
 true if the index is clustered index and it has some instant columns More...
 
unsigned row_versions: 1
 true if the index is clustered index and table has row versions More...
 
uint32_t srid
 spatial reference id More...
 
bool srid_is_valid
 says whether SRID is valid - it cane be undefined More...
 
std::unique_ptr< dd::Spatial_reference_systemrtr_srs
 Cached spatial reference system dictionary entry used by R-tree indexes. More...
 
uint32_t magic_n
 magic number More...
 
dict_field_tfields
 array of field descriptions More...
 
std::vector< uint16_t > fields_array
 Array of field pos sorted as per their physical pos in record. More...
 
uint32_t nullables [MAX_ROW_VERSION+1] = {0}
 Number of nullable columns in each version. More...
 
st_mysql_ftparserparser
 fulltext parser plugin More...
 
bool is_ngram
 true if it's ngram parser More...
 
bool has_new_v_col
 whether it has a newly added virtual column in ALTER More...
 
bool hidden
 if the index is an hidden index More...
 
btr_search_tsearch_info
 info used in optimistic searches More...
 
row_log_tonline_log
 the log of modifications during online index creation; valid when online_status is ONLINE_INDEX_CREATION More...
 
last_ops_cur_tlast_ins_cur
 cache the last insert position. More...
 
last_ops_cur_tlast_sel_cur
 cache the last selected position. More...
 
rec_cache_t rec_cache
 cache the field that needs to be re-computed on each insert. More...
 
rtr_ssn_t rtr_ssn
 Node sequence number for RTree. More...
 
rtr_info_track_trtr_track
 tracking all R-Tree search cursors More...
 
trx_id_t trx_id
 id of the transaction that created this index, or 0 if the index existed when InnoDB was started up More...
 
zip_pad_info_t zip_pad
 Information about state of compression failures and successes. More...
 
rw_lock_t lock
 read-write lock protecting the upper levels of the index tree More...
 
bool fill_dd
 Flag whether need to fill dd tables when it's a fulltext index. More...
 
uint64_t * stat_n_diff_key_vals
 Statistics for query optimization. More...
 
uint64_t * stat_n_sample_sizes
 number of pages that were sampled to calculate each of stat_n_diff_key_vals[], e.g. More...
 
uint64_t * stat_n_non_null_key_vals
 
ulint stat_index_size
 approximate index size in database pages More...
 
ulint stat_n_leaf_pages
 approximate number of leaf pages in the index tree More...
 

Detailed Description

Data structure for an index.

Most fields will be initialized to 0, NULL or false in dict_mem_index_create().

Member Function Documentation

◆ add_field()

void dict_index_t::add_field ( const char *  name_arg,
ulint  prefix_len,
bool  is_ascending 
)
inline

Adds a field definition to an index.

NOTE: does not take a copy of the column name if the field is a column. The memory occupied by the column name may be released only after publishing the index.

Parameters
[in]name_argcolumn name
[in]prefix_len0 or the column prefix length in a MySQL index like INDEX (textcol(25))
[in]is_ascendingtrue=ASC, false=DESC

◆ calculate_n_instant_nullable()

size_t dict_index_t::calculate_n_instant_nullable ( size_t  _n_fields) const
inline

◆ create_fields_array()

void dict_index_t::create_fields_array ( )
inline

Create fields array sorted by phy_pos of field in row.

◆ create_nullables()

void dict_index_t::create_nullables ( uint32_t  current_row_version)

Create nullables array.

Parameters
[in]current_row_versioncurrent row version of table

◆ destroy_fields_array()

void dict_index_t::destroy_fields_array ( )
inline

◆ fill_srid_value()

void dict_index_t::fill_srid_value ( uint32_t  srid_value,
bool  srid_is_valid_value 
)
inline

Sets srid and srid_is_valid values.

Parameters
[in]srid_valuevalue of SRID, may be garbage if srid_is_valid_value = false
[in]srid_is_valid_valuevalue of srid_is_valid

◆ get_col()

const dict_col_t * dict_index_t::get_col ( ulint  pos) const
inline

Gets pointer to the nth column in an index.

Parameters
[in]posposition of the field
Returns
column

◆ get_col_no()

ulint dict_index_t::get_col_no ( ulint  pos) const

Gets the column number the nth field in an index.

Parameters
[in]posposition of the field
Returns
column number

◆ get_col_pos()

ulint dict_index_t::get_col_pos ( ulint  n,
bool  inc_prefix = false,
bool  is_virtual = false 
) const

Looks for column n in an index.

Parameters
[in]ncolumn number
[in]inc_prefixtrue=consider column prefixes too
[in]is_virtualtrue==virtual column
Returns
position in internal representation of the index; ULINT_UNDEFINED if not contained

◆ get_field()

dict_field_t * dict_index_t::get_field ( ulint  pos) const
inline

Gets the nth field of an index.

Parameters
[in]posposition of field
Returns
pointer to field object

◆ get_field_off_pos()

uint16_t dict_index_t::get_field_off_pos ( ulint  pos) const
inline

Get the physical position of a field on a row.

For table having INSTANT column, it might differ from field index (pos).

Parameters
[in]posfield index
Returns
physical position on row

◆ get_field_phy_pos()

uint16_t dict_index_t::get_field_phy_pos ( ulint  pos,
uint8_t  version 
) const
inline

◆ get_instant_fields()

uint32_t dict_index_t::get_instant_fields ( ) const
inline

Returns the number of fields before first instant ADD COLUMN.

This is needed only for V1 INSTANT ADD.

It includes dropped fields also (if any)

◆ get_instant_nullable()

uint16_t dict_index_t::get_instant_nullable ( ) const
inline

Get instant nullable.

Returns
number of nullable fields before first INSTANT ADD

◆ get_logical_pos()

uint16_t dict_index_t::get_logical_pos ( uint16_t  phy_pos) const
inline

Given the physical position, find the logical position of field.

Parameters
[in]phy_posphysical position of field
Returns
logical position of field

◆ get_min_size()

ulint dict_index_t::get_min_size ( ) const
inline

Returns the minimum data size of an index record.

Returns
minimum data size in bytes

◆ get_n_nullable_before()

uint32_t dict_index_t::get_n_nullable_before ( uint32_t  nth) const
inline

Returns the number of nullable fields before specified nth field.

Parameters
[in]nthnth field to check

◆ get_n_total_fields()

uint32_t dict_index_t::get_n_total_fields ( ) const
inline

Returns total fields including INSTANT DROP fields.

◆ get_nth_default()

const byte * dict_index_t::get_nth_default ( ulint  nth,
ulint length 
) const
inline

Get the default value of nth field and its length if exists.

If not exists, both the return value is nullptr and length is 0.

Parameters
[in]nthnth field to get
[in,out]lengthlength of the default value
Returns
the default value data of nth field

◆ get_nullable_before_instant_add_drop()

uint16_t dict_index_t::get_nullable_before_instant_add_drop ( ) const
inline

Get the nullable fields before any INSTANT ADD/DROP.

Returns
number of nullable fields

◆ get_nullable_in_version()

uint32_t dict_index_t::get_nullable_in_version ( uint8_t  version) const
inline

Return nullable in a specific row version.

◆ get_page_size()

page_size_t dict_index_t::get_page_size ( ) const

Get the page size of the tablespace to which this index belongs.

Returns
the page size.

◆ get_physical_field()

dict_field_t * dict_index_t::get_physical_field ( size_t  pos) const
inline

Gets the nth physical pos field.

Parameters
[in]posphysical position of the field
Returns
pointer to the field object.

◆ get_sys_col_pos()

ulint dict_index_t::get_sys_col_pos ( ulint  type) const

Returns the position of a system column in an index.

Parameters
[in]typeDATA_ROW_ID, ...
Returns
position, ULINT_UNDEFINED if not contained

◆ has_instant_cols()

bool dict_index_t::has_instant_cols ( ) const
inline

Check whether index has any instantly added columns.

Possible only if table has INSTANT ADD columns and is upgraded.

Returns
true if this is instant affected, otherwise false

◆ has_instant_cols_or_row_versions()

bool dict_index_t::has_instant_cols_or_row_versions ( ) const
inline

check if either instant or versioned.

Returns
true if table has row versions or instant cols, otherwise false

◆ has_multi_value_col()

uint32_t dict_index_t::has_multi_value_col ( const dict_v_col_t mv_col) const
inline

Check if a multi-value index is built on specified multi-value virtual column.

Please note that there could be only one multi-value virtual column on the multi-value index, but not necessary the first field of the index.

Parameters
[in]mv_colmulti-value virtual column
Returns
non-zero means the column is on the index and this is the nth position of the column, zero means it's not on the index

◆ has_row_versions()

bool dict_index_t::has_row_versions ( ) const
inline

Check whether index belongs to a table having row versions.

Returns
true if table has row versions, otherwise false

◆ is_clustered()

bool dict_index_t::is_clustered ( ) const
inline

◆ is_committed()

bool dict_index_t::is_committed ( ) const
inline

Determine if the index has been committed to the data dictionary.

Returns
whether the index definition has been committed

◆ is_compressed()

bool dict_index_t::is_compressed ( ) const
inline

Check if the underlying table is compressed.

Returns
true if compressed, false otherwise.

◆ is_corrupted()

bool dict_index_t::is_corrupted ( ) const
inline

Check whether the index is corrupted.

Returns
true if index is corrupted, otherwise false

◆ is_multi_value()

bool dict_index_t::is_multi_value ( ) const
inline

Check whether the index is the multi-value index.

Returns
nonzero for multi-value index, zero for other indexes

◆ is_tuple_instant_format()

bool dict_index_t::is_tuple_instant_format ( const uint16_t  n_fields_in_tuple) const

Check if tuple is having instant format.

Parameters
[in]n_fields_in_tuplenumber of fields in tuple
Returns
true if yes, false otherwise.

◆ is_usable()

bool dict_index_t::is_usable ( const trx_t trx) const

Check whether index can be used by transaction.

Parameters
[in]trxtransaction

◆ next() [1/2]

dict_index_t * dict_index_t::next ( void  )
inline

Get the next index.

Returns
next index
Return values
NULLif this was the last index

◆ next() [2/2]

const dict_index_t * dict_index_t::next ( void  ) const
inline

Get the next index.

Returns
next index
Return values
NULLif this was the last index

◆ set_committed()

void dict_index_t::set_committed ( bool  committed)
inline

Flag an index committed or uncommitted.

Parameters
[in]committedwhether the index is committed

◆ set_instant_nullable()

void dict_index_t::set_instant_nullable ( uint16_t  n)
inline

Set instant nullable.

Parameters
[in]nnullable fields before first INSTANT ADD

◆ space_id()

space_id_t dict_index_t::space_id ( ) const
inline

Get the space id of the tablespace to which this index belongs.

Returns
the space id.

◆ UT_LIST_NODE_T()

dict_index_t::UT_LIST_NODE_T ( dict_index_t  )

list of indexes of the table

Member Data Documentation

◆ allow_duplicates

unsigned dict_index_t::allow_duplicates

if true, allow duplicate values even if index is created with unique constraint

◆ cached

unsigned dict_index_t::cached

true if the index object is in the dictionary cache

◆ disable_ahi

unsigned dict_index_t::disable_ahi

if true, then disable AHI.

Currently limited to intrinsic temporary table and SDI table as index id is not unique for such table which is one of the validation criterion for ahi.

◆ fields

dict_field_t* dict_index_t::fields

array of field descriptions

◆ fields_array

std::vector<uint16_t> dict_index_t::fields_array

Array of field pos sorted as per their physical pos in record.

Only needed for clustered index having INSTANT ADD/DROP columns.

◆ fill_dd

bool dict_index_t::fill_dd

Flag whether need to fill dd tables when it's a fulltext index.

◆ has_new_v_col

bool dict_index_t::has_new_v_col

whether it has a newly added virtual column in ALTER

◆ heap

mem_heap_t* dict_index_t::heap

memory heap

◆ hidden

bool dict_index_t::hidden

if the index is an hidden index

◆ id

space_index_t dict_index_t::id

id of the index

◆ instant_cols

unsigned dict_index_t::instant_cols

true if the index is clustered index and it has some instant columns

◆ is_ngram

bool dict_index_t::is_ngram

true if it's ngram parser

◆ last_ins_cur

last_ops_cur_t* dict_index_t::last_ins_cur

cache the last insert position.

Currently limited to auto-generated clustered index on intrinsic table only.

◆ last_sel_cur

last_ops_cur_t* dict_index_t::last_sel_cur

cache the last selected position.

Currently limited to intrinsic table only.

◆ lock

rw_lock_t dict_index_t::lock

read-write lock protecting the upper levels of the index tree

◆ magic_n

uint32_t dict_index_t::magic_n

magic number

◆ merge_threshold

unsigned dict_index_t::merge_threshold

In the pessimistic delete, if the page data size drops below this limit in percent, merging it to a neighbor is tried.

◆ n_def

unsigned dict_index_t::n_def

number of fields defined so far

◆ n_fields

unsigned dict_index_t::n_fields

number of fields in the index

◆ n_instant_nullable

unsigned dict_index_t::n_instant_nullable

number of nullable fields before first instant ADD COLUMN applied to this table.

This is valid only when has_instant_cols() is true

◆ n_nullable

unsigned dict_index_t::n_nullable

number of nullable fields

◆ n_total_fields

unsigned dict_index_t::n_total_fields

number of total fields in the index (including INSTANT dropped fields)

◆ n_uniq

unsigned dict_index_t::n_uniq

number of fields from the beginning which are enough to determine an index entry uniquely

◆ n_user_defined_cols

unsigned dict_index_t::n_user_defined_cols

number of columns the user defined to be in the index: in the internal representation we add more columns

◆ name

id_name_t dict_index_t::name

index name

◆ nullables

uint32_t dict_index_t::nullables[MAX_ROW_VERSION+1] = {0}

Number of nullable columns in each version.

Only needed for clustered index having INSTANT ADD/DROP columns.

◆ nulls_equal

unsigned dict_index_t::nulls_equal

if true, SQL NULL == SQL NULL

◆ online_log

row_log_t* dict_index_t::online_log

the log of modifications during online index creation; valid when online_status is ONLINE_INDEX_CREATION

◆ online_status

unsigned dict_index_t::online_status

enum online_index_status.

Transitions from ONLINE_INDEX_COMPLETE (to ONLINE_INDEX_CREATION) are protected by dict_operation_lock and dict_sys->mutex. Other changes are protected by index->lock.

◆ page

unsigned dict_index_t::page

index tree root page number

◆ parser

st_mysql_ftparser* dict_index_t::parser

fulltext parser plugin

◆ rec_cache

rec_cache_t dict_index_t::rec_cache

cache the field that needs to be re-computed on each insert.

Limited to intrinsic table as this is common share and can't be used without protection if table is accessible to multiple-threads.

◆ row_versions

unsigned dict_index_t::row_versions

true if the index is clustered index and table has row versions

◆ rtr_srs

std::unique_ptr<dd::Spatial_reference_system> dict_index_t::rtr_srs

Cached spatial reference system dictionary entry used by R-tree indexes.

◆ rtr_ssn

rtr_ssn_t dict_index_t::rtr_ssn

Node sequence number for RTree.

◆ rtr_track

rtr_info_track_t* dict_index_t::rtr_track

tracking all R-Tree search cursors

◆ search_info

btr_search_t* dict_index_t::search_info

info used in optimistic searches

◆ space

unsigned dict_index_t::space

space where the index tree is placed

◆ srid

uint32_t dict_index_t::srid

spatial reference id

◆ srid_is_valid

bool dict_index_t::srid_is_valid

says whether SRID is valid - it cane be undefined

◆ stat_index_size

ulint dict_index_t::stat_index_size

approximate index size in database pages

◆ stat_n_diff_key_vals

uint64_t* dict_index_t::stat_n_diff_key_vals

Statistics for query optimization.

approximate number of different key values for this index, for each n-column prefix where 1 <= n <= dict_get_n_unique(index) (the array is indexed from 0 to n_uniq-1); we periodically calculate new estimates

◆ stat_n_leaf_pages

ulint dict_index_t::stat_n_leaf_pages

approximate number of leaf pages in the index tree

◆ stat_n_non_null_key_vals

uint64_t* dict_index_t::stat_n_non_null_key_vals

◆ stat_n_sample_sizes

uint64_t* dict_index_t::stat_n_sample_sizes

number of pages that were sampled to calculate each of stat_n_diff_key_vals[], e.g.

stat_n_sample_sizes[3] pages were sampled to get the number stat_n_diff_key_vals[3].

◆ table

dict_table_t* dict_index_t::table

back pointer to table

◆ table_name

const char* dict_index_t::table_name

table name

◆ to_be_dropped

unsigned dict_index_t::to_be_dropped

true if the index is to be dropped; protected by dict_operation_lock

◆ trx_id

trx_id_t dict_index_t::trx_id

id of the transaction that created this index, or 0 if the index existed when InnoDB was started up

◆ trx_id_offset

unsigned dict_index_t::trx_id_offset

position of the trx id column in a clustered index record, if the fields before it are known to be of a fixed size, 0 otherwise

◆ type

unsigned dict_index_t::type

index type (DICT_CLUSTERED, DICT_UNIQUE, DICT_IBUF, DICT_CORRUPT)

◆ uncommitted

unsigned dict_index_t::uncommitted

a flag that is set for secondary indexes that have not been committed to the data dictionary yet

◆ zip_pad

zip_pad_info_t dict_index_t::zip_pad

Information about state of compression failures and successes.


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