MySQL 9.0.0
Source Code Documentation
|
DDL context/configuration. More...
#include <ddl0ddl.h>
Classes | |
struct | FTS |
Full text search context information and state. More... | |
Public Types | |
using | Scan_buffer_size = std::pair< size_t, size_t > |
Scan sort and IO buffer size. More... | |
Public Member Functions | |
Context (trx_t *trx, dict_table_t *old_table, dict_table_t *new_table, bool online, dict_index_t **indexes, const ulint *key_numbers, size_t n_indexes, TABLE *table, const dtuple_t *add_cols, const ulint *col_map, size_t add_autoinc, ddl::Sequence &sequence, bool skip_pk_sort, Alter_stage *stage, const dict_add_v_col_t *add_v, TABLE *eval_table, size_t max_buffer_size, size_t max_threads) noexcept | |
Build indexes on a table by reading a clustered index, creating a temporary file containing index entries, merge sorting these index entries and inserting sorted index entries to indexes. More... | |
~Context () noexcept | |
Destructor. More... | |
dberr_t | get_error () const noexcept |
void | set_error (dberr_t err) noexcept |
Set the error code, when it's not specific to an index. More... | |
void | set_error (dberr_t err, size_t id) noexcept |
Set the error code and index number where the error occurred. More... | |
dberr_t | build () noexcept |
Build the indexes. More... | |
Flush_observer * | flush_observer () noexcept |
dict_table_t * | old_table () noexcept |
dict_table_t * | new_table () noexcept |
Scan_buffer_size | scan_buffer_size (size_t n_threads) const noexcept |
Calculate the sort and buffer size per thread. More... | |
size_t | merge_io_buffer_size (size_t n_buffers) const noexcept |
Calculate the io buffer size per file for the sort phase. More... | |
size_t | load_io_buffer_size (size_t n_buffers) const noexcept |
Calculate the io buffer size per file for the load phase. More... | |
size_t | allocate (size_t n) const |
Request number of bytes for a buffer. More... | |
THD * | thd () noexcept |
dtuple_t * | create_add_cols () noexcept |
Copy the added columns dtuples so that we don't use the same column data buffer for the added column across multiple threads. More... | |
Private Types | |
using | Key_numbers = std::vector< size_t, ut::allocator< size_t > > |
using | Indexes = std::vector< dict_index_t *, ut::allocator< dict_index_t * > > |
Private Member Functions | |
Cursor * | cursor () noexcept |
const dict_index_t * | index () const noexcept |
dberr_t | read_init (Cursor *cursor) noexcept |
Initialize the context for a cluster index scan. More... | |
dberr_t | fts_create (dict_index_t *index) noexcept |
Initialize the FTS build infrastructure. More... | |
dberr_t | setup_fts_build () noexcept |
Setup the FTS index build data structures. More... | |
doc_id_t | next_doc_id () noexcept |
Get the next Doc ID and increment the current value. More... | |
void | update_fts_doc_id () noexcept |
Update the FTS document ID. More... | |
dberr_t | check_state_of_online_build_log () noexcept |
Check the state of the online build log for the index. More... | |
void | note_max_trx_id (dict_index_t *index) noexcept |
Track the highest TxID that modified this index when the scan was completed. More... | |
dberr_t | setup_pk_sort (Cursor *cursor) noexcept |
Setup the primary key sort. More... | |
void | setup_nonnull () noexcept |
Init the non-null column constraints checks (if required). More... | |
bool | check_null_constraints (const dtuple_t *row) const noexcept |
Check if the nonnull columns satisfy the constraint. More... | |
dberr_t | cleanup (dberr_t err) noexcept |
Clean up the data structures at the end of the DDL. More... | |
dberr_t | handle_autoinc (const dtuple_t *row) noexcept |
Handle auto increment. More... | |
bool | has_virtual_columns () const noexcept |
bool | has_fts_indexes () const noexcept |
bool | is_interrupted () noexcept |
Private Attributes | |
std::atomic< dberr_t > | m_err {DB_SUCCESS} |
Common error code for all index builders running in parallel. More... | |
size_t | m_err_key_number {std::numeric_limits<size_t>::max()} |
Index where the error occurred. More... | |
trx_t * | m_trx {} |
Transaction covering the index build. More... | |
FTS | m_fts |
The FTS builder. More... | |
dict_table_t * | m_old_table {} |
Source table, read rows from this table. More... | |
dict_table_t * | m_new_table {} |
Table where indexes are created; identical to old_table unless creating a PRIMARY KEY. More... | |
bool | m_online {} |
True if creating index online. More... | |
Indexes | m_indexes {} |
Indexes to be created. More... | |
Key_numbers | m_key_numbers {} |
MySQL key numbers. More... | |
TABLE * | m_table {} |
MySQL table for reporting errors/warnings. More... | |
const dtuple_t * | m_add_cols {} |
Default value for added columns or null. More... | |
const ulint * | m_col_map {} |
Mapping of old column numbers to new ones, or nullptr if none were added. More... | |
size_t | m_add_autoinc {ULINT_UNDEFINED} |
Number of added AUTO_INCREMENT columns, or ULINT_UNDEFINED if none added. More... | |
ddl::Sequence & | m_sequence |
Autoinc sequence. More... | |
Alter_stage * | m_stage {} |
Performance schema accounting object, used by ALTER TABLE. More... | |
const dict_add_v_col_t * | m_add_v {} |
New virtual columns added along with indexes. More... | |
TABLE * | m_eval_table {} |
MySQL table used to evaluate virtual column value, see innobase_get_computed_value(). More... | |
bool | m_skip_pk_sort {} |
Skip the sorting phase if true. More... | |
std::vector< size_t, ut::allocator< size_t > > | m_nonnull {} |
Non null columns. More... | |
size_t | m_n_uniq {} |
Number of unique columns in the key. More... | |
bool | m_need_observer {} |
true if need flush observer. More... | |
Cursor * | m_cursor {} |
Cursor for reading the cluster index. More... | |
size_t | m_n_allocated {} |
Number of bytes used. More... | |
const size_t | m_max_buffer_size {} |
Maximum number of bytes to use. More... | |
const size_t | m_max_threads {} |
Maximum number of threads to use. More... | |
ib_mutex_t | m_autoinc_mutex |
For parallel access to the autoincrement generator. More... | |
mem_heap_t * | m_dtuple_heap {} |
Heap for copies of m_add_cols. More... | |
Friends | |
struct | Row |
class | Loader |
struct | Cursor |
struct | Builder |
struct | ddl::FTS |
struct | Load_cursor |
struct | Btree_cursor |
struct | Merge_file_sort |
struct | Parallel_cursor |
DDL context/configuration.
|
private |
|
private |
using ddl::Context::Scan_buffer_size = std::pair<size_t, size_t> |
Scan sort and IO buffer size.
|
noexcept |
Build indexes on a table by reading a clustered index, creating a temporary file containing index entries, merge sorting these index entries and inserting sorted index entries to indexes.
[in] | trx | Transaction. |
[in] | old_table | Table where rows are read from |
[in] | new_table | Table where indexes are created; identical to old_table unless creating a PRIMARY KEY |
[in] | online | True if creating indexes online |
[in] | indexes | Indexes to be created |
[in] | key_numbers | MySQL key numbers |
[in] | n_indexes | Size of indexes[] |
[in,out] | table | MySQL table, for reporting erroneous key value if applicable |
[in] | add_cols | Default values of added columns, or NULL |
[in] | col_map | Mapping of old column numbers to new ones, or nullptr if old_table == new_table |
[in] | add_autoinc | Number of added AUTO_INCREMENT columns, or ULINT_UNDEFINED if none is added |
[in,out] | sequence | Autoinc sequence |
[in] | skip_pk_sort | Whether the new PRIMARY KEY will follow existing order |
[in,out] | stage | Performance schema accounting object, used by ALTER TABLE. stage->begin_phase_read_pk() will be called at the beginning of this function and it will be passed to other functions for further accounting. |
[in] | add_v | New virtual columns added along with indexes |
[in] | eval_table | MySQL table used to evaluate virtual column value, see innobase_get_computed_value(). |
[in] | max_buffer_size | Memory use upper limit. |
[in] | max_threads | true if DDL should use multiple threads. |
|
noexcept |
Destructor.
size_t ddl::Context::allocate | ( | size_t | n | ) | const |
Request number of bytes for a buffer.
[in] | n | Number of bytes requested. |
|
noexcept |
Build the indexes.
|
privatenoexcept |
Check if the nonnull columns satisfy the constraint.
[in] | row | Row to check. |
|
privatenoexcept |
Check the state of the online build log for the index.
Clean up the data structures at the end of the DDL.
[in] | err | Status of the DDL. |
|
noexcept |
Copy the added columns dtuples so that we don't use the same column data buffer for the added column across multiple threads.
|
inlineprivatenoexcept |
|
noexcept |
|
privatenoexcept |
Initialize the FTS build infrastructure.
[in,out] | index | Index prototype to build. |
|
inlinenoexcept |
Handle auto increment.
[in] | row | Row with autoinc column. |
|
privatenoexcept |
|
privatenoexcept |
|
privatenoexcept |
|
privatenoexcept |
|
noexcept |
Calculate the io buffer size per file for the load phase.
[in] | n_buffers | Total number of buffers to use for the loading. |
|
noexcept |
Calculate the io buffer size per file for the sort phase.
[in] | n_buffers | Total number of buffers to use for the merge. |
|
inlinenoexcept |
|
privatenoexcept |
Get the next Doc ID and increment the current value.
|
privatenoexcept |
Track the highest TxID that modified this index when the scan was completed.
We prevent older readers from accessing this index, to ensure read consistency.
[in,out] | index | Index to track. |
|
inlinenoexcept |
Initialize the context for a cluster index scan.
[in,out] | cursor | Cursor used for the cluster index read. |
|
noexcept |
Calculate the sort and buffer size per thread.
[in] | n_threads | Total number of threads used for scanning. |
|
inlinenoexcept |
Set the error code, when it's not specific to an index.
[in] | err | Error code. |
|
inlinenoexcept |
Set the error code and index number where the error occurred.
[in] | err | Error code. |
[in] | id | Index ordinal value where error occurred. |
|
privatenoexcept |
Setup the FTS index build data structures.
|
privatenoexcept |
Init the non-null column constraints checks (if required).
Setup the primary key sort.
[in,out] | cursor | Setup the primary key data structures. |
|
noexcept |
|
privatenoexcept |
Update the FTS document ID.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
Number of added AUTO_INCREMENT columns, or ULINT_UNDEFINED if none added.
|
private |
Default value for added columns or null.
|
private |
New virtual columns added along with indexes.
|
private |
For parallel access to the autoincrement generator.
|
private |
Mapping of old column numbers to new ones, or nullptr if none were added.
|
private |
Cursor for reading the cluster index.
|
private |
Heap for copies of m_add_cols.
|
private |
Common error code for all index builders running in parallel.
|
private |
Index where the error occurred.
|
private |
MySQL table used to evaluate virtual column value, see innobase_get_computed_value().
|
private |
The FTS builder.
There is one FTS per table.
|
private |
Indexes to be created.
|
private |
MySQL key numbers.
|
private |
Maximum number of bytes to use.
|
private |
Maximum number of threads to use.
We don't do a parallel scan of the clustered index when FTS and/or virtual columns are involved. The build phase is parallel though.
|
private |
Number of bytes used.
|
private |
Number of unique columns in the key.
|
private |
true if need flush observer.
|
private |
Table where indexes are created; identical to old_table unless creating a PRIMARY KEY.
|
private |
Non null columns.
|
private |
Source table, read rows from this table.
|
private |
True if creating index online.
Non-online implies that we have an S latch on the table, therefore there can't be concurrent updates to the table while we are executing the DDL. We don't log the changes to the row log.
|
private |
Autoinc sequence.
|
private |
Skip the sorting phase if true.
|
private |
Performance schema accounting object, used by ALTER TABLE.
stage->begin_phase_read_pk() will be called at the beginning of this function and it will be passed to other functions for further accounting.
|
private |
MySQL table for reporting errors/warnings.
|
private |
Transaction covering the index build.