53struct Merge_file_sort;
56struct Parallel_cursor;
199 if (locker !=
nullptr) {
201 (locker, 0, __FILE__, __LINE__);
209 if (locker !=
nullptr) {
241 const char *
path)
noexcept;
288 ut_ad(rhs.m_next_value > 0);
357 explicit FTS(
size_t n_parser_threads) noexcept
416 TABLE *eval_table,
size_t max_buffer_size,
417 size_t max_threads)
noexcept;
434 m_err.compare_exchange_strong(expected,
err);
448 if (
m_err.compare_exchange_strong(expected,
err)) {
471 size_t n_threads)
const noexcept;
489 [[nodiscard]]
THD *
thd() noexcept;
Class used to report ALTER TABLE progress via performance_schema.
Definition: ut0stage.h:81
We use Flush_observer to track flushing of non-redo logged pages in bulk create index(btr0load....
Definition: buf0flu.h:274
Definition: conf_to_src.cc:75
A row of result or a row of metadata A row is a collection of Column values or Column metadata.
Definition: protocol_local_v2.h:92
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Build indexes on a table by reading a clustered index, creating a temporary file containing index ent...
Definition: ddl0impl-loader.h:44
Captures ownership and manages lifetime of an already opened OS file descriptor.
Definition: ddl0ddl.h:161
Unique_os_file_descriptor(os_fd_t fd)
Main constructor capturing an already opened OS file descriptor.
Definition: ddl0ddl.h:167
os_fd_t get() const
Returns the managed OS file descriptor for use with OS functions that operate on file.
Definition: ddl0ddl.h:175
os_fd_t m_fd
Definition: ddl0ddl.h:216
void swap(Unique_os_file_descriptor &other)
Swaps the underlying managed file descriptors between two instances of Unique_os_file_descriptor.
Definition: ddl0ddl.h:189
Unique_os_file_descriptor(Unique_os_file_descriptor &&other)
Definition: ddl0ddl.h:169
bool is_open() const
Definition: ddl0ddl.h:179
Unique_os_file_descriptor()=default
Default constructor, does not hold any file, does not close any on destruction.
Unique_os_file_descriptor & operator=(Unique_os_file_descriptor &&other)
Definition: ddl0ddl.h:181
void close()
Closes the managed file.
Definition: ddl0ddl.h:193
~Unique_os_file_descriptor()
Definition: ddl0ddl.h:171
A utility class which, if inherited from, prevents the descendant class from being copied,...
Definition: ut0class_life_cycle.h:41
#define PSI_FILE_CALL(M)
Definition: psi_file.h:36
dberr_t
Definition: db0err.h:39
@ DB_SUCCESS
Definition: db0err.h:43
@ DB_END_OF_INDEX
Definition: db0err.h:219
Full text search header file.
uint64_t doc_id_t
Document id type.
Definition: fts0fts.h:79
struct PSI_file_locker PSI_file_locker
Definition: psi_file_bits.h:62
@ PSI_FILE_CLOSE
File close, as in close().
Definition: psi_file_bits.h:75
unsigned char byte
Blob class.
Definition: common.h:151
The transaction lock system global types.
lock_mode
Definition: lock0types.h:54
unsigned long long int ulonglong
Definition: my_inttypes.h:56
static char * path
Definition: mysqldump.cc:149
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
The general architecture is that the work is done in two phases, roughly the read and write phase.
Definition: btr0load.cc:42
ulong fts_parser_threads
Variable specifying the number of FTS parser threads to use.
Definition: ddl0fts.cc:49
void drop_indexes(trx_t *trx, dict_table_t *table, bool locked) noexcept
Drop those indexes which were created before an error occurred.
Definition: ddl0ddl.cc:468
dberr_t lock_table(trx_t *trx, dict_table_t *table, enum lock_mode mode) noexcept
Sets an exclusive lock on a table, for the duration of creating indexes.
Definition: ddl0ddl.cc:300
dberr_t drop_table(trx_t *trx, dict_table_t *table) noexcept
Drop a table.
Definition: ddl0ddl.cc:291
byte mrec_t
Merge record in Aligned_buffer.
Definition: ddl0ddl.h:78
long fill_factor
Innodb B-tree index fill factor for bulk load.
Definition: btr0load.cc:44
constexpr size_t IO_BLOCK_SIZE
Minimum IO buffer size.
Definition: ddl0ddl.h:65
Unique_os_file_descriptor file_create_low(const char *path) noexcept
Create temporary merge files in the given parameter path, and if UNIV_PFS_IO defined,...
Definition: ddl0ddl.cc:129
dict_index_t * create_index(trx_t *trx, dict_table_t *table, const Index_defn *index_def, const dict_add_v_col_t *add_v) noexcept
Create the index and load in to the dictionary.
Definition: ddl0ddl.cc:184
byte[UNIV_PAGE_SIZE_MAX] mrec_buf_t
Secondary buffer for I/O operations of merge records.
Definition: ddl0ddl.h:72
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:908
Definition: gcs_xcom_synode.h:64
mode
Definition: file_handle.h:61
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:48
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
void delete_(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new*() variants.
Definition: ut0new.h:811
The interface to the operating system file io.
static constexpr os_fd_t OS_FD_CLOSED
Definition: os0file.h:117
int os_fd_t
Raw file handle.
Definition: os0file.h:115
static void swap(String &a, String &b) noexcept
Definition: sql_string.h:663
State data storage for get_thread_file_name_locker_v1_t.
Definition: psi_file_bits.h:146
Definition: completion_hash.h:35
For loading indexes.
Definition: ddl0impl-builder.h:48
Document ID sequence.
Definition: ddl0ddl.h:325
virtual doc_id_t generated_count() const noexcept=0
virtual ~Sequence() noexcept
Destructor.
Definition: ddl0ctx.cc:134
virtual void increment() noexcept=0
Advance the document ID.
virtual bool is_generated() const noexcept=0
virtual doc_id_t fetch(const dtuple_t *dtuple=nullptr) noexcept=0
Get the next document ID.
virtual doc_id_t current() noexcept=0
Get the current document ID.
doc_id_t m_doc_id
Current document ID.
Definition: ddl0ddl.h:352
virtual doc_id_t max_doc_id() const noexcept=0
Full text search context information and state.
Definition: ddl0ddl.h:323
~FTS() noexcept
Destructor.
Definition: ddl0ddl.h:361
ddl::FTS * m_ptr
FTS instance.
Definition: ddl0ddl.h:373
FTS(size_t n_parser_threads) noexcept
Constructor.
Definition: ddl0ddl.h:357
const size_t m_n_parser_threads
Maximum number of FTS parser and sort threads to use.
Definition: ddl0ddl.h:367
Sequence * m_doc_id
Document ID sequence generator.
Definition: ddl0ddl.h:370
dict_index_t * m_index
FTS index.
Definition: ddl0ddl.h:364
DDL context/configuration.
Definition: ddl0ddl.h:321
size_t m_err_key_number
Index where the error occurred.
Definition: ddl0ddl.h:573
~Context() noexcept
Destructor.
Definition: ddl0ctx.cc:126
const dict_index_t * index() const noexcept
Definition: ddl0ctx.cc:145
bool m_need_observer
true if need flush observer.
Definition: ddl0ddl.h:640
void set_error(dberr_t err) noexcept
Set the error code, when it's not specific to an index.
Definition: ddl0ddl.h:427
const dtuple_t * m_add_cols
Default value for added columns or null.
Definition: ddl0ddl.h:604
dict_table_t * old_table() noexcept
Definition: ddl0ddl.h:462
bool is_interrupted() noexcept
Definition: ddl0ctx.cc:523
size_t allocate(size_t n) const
Request number of bytes for a buffer.
const ulint * m_col_map
Mapping of old column numbers to new ones, or nullptr if none were added.
Definition: ddl0ddl.h:608
dberr_t cleanup(dberr_t err) noexcept
Clean up the data structures at the end of the DDL.
Definition: ddl0ctx.cc:300
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 ent...
Definition: ddl0ctx.cc:46
mem_heap_t * m_dtuple_heap
Heap for copies of m_add_cols.
Definition: ddl0ddl.h:660
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 ...
Definition: ddl0ctx.cc:525
bool m_skip_pk_sort
Skip the sorting phase if true.
Definition: ddl0ddl.h:631
size_t merge_io_buffer_size(size_t n_buffers) const noexcept
Calculate the io buffer size per file for the sort phase.
Definition: ddl0ctx.cc:201
Scan_buffer_size scan_buffer_size(size_t n_threads) const noexcept
Calculate the sort and buffer size per thread.
Definition: ddl0ctx.cc:149
void note_max_trx_id(dict_index_t *index) noexcept
Track the highest TxID that modified this index when the scan was completed.
Definition: ddl0ctx.cc:474
std::vector< size_t, ut::allocator< size_t > > m_nonnull
Non null columns.
Definition: ddl0ddl.h:634
TABLE * m_table
MySQL table for reporting errors/warnings.
Definition: ddl0ddl.h:601
dict_table_t * m_old_table
Source table, read rows from this table.
Definition: ddl0ddl.h:582
std::vector< size_t, ut::allocator< size_t > > Key_numbers
Definition: ddl0ddl.h:566
dict_table_t * new_table() noexcept
Definition: ddl0ddl.h:465
void setup_nonnull() noexcept
Init the non-null column constraints checks (if required).
Definition: ddl0ctx.cc:387
const dict_add_v_col_t * m_add_v
New virtual columns added along with indexes.
Definition: ddl0ddl.h:624
const size_t m_max_buffer_size
Maximum number of bytes to use.
Definition: ddl0ddl.h:649
dict_table_t * m_new_table
Table where indexes are created; identical to old_table unless creating a PRIMARY KEY.
Definition: ddl0ddl.h:586
void update_fts_doc_id() noexcept
Update the FTS document ID.
trx_t * m_trx
Transaction covering the index build.
Definition: ddl0ddl.h:576
size_t m_n_allocated
Number of bytes used.
Definition: ddl0ddl.h:646
std::atomic< dberr_t > m_err
Common error code for all index builders running in parallel.
Definition: ddl0ddl.h:570
Cursor * cursor() noexcept
Definition: ddl0ddl.h:498
size_t m_n_uniq
Number of unique columns in the key.
Definition: ddl0ddl.h:637
ib_mutex_t m_autoinc_mutex
For parallel access to the autoincrement generator.
Definition: ddl0ddl.h:657
bool has_virtual_columns() const noexcept
Definition: ddl0ctx.cc:224
bool has_fts_indexes() const noexcept
Definition: ddl0ctx.cc:431
dberr_t check_state_of_online_build_log() noexcept
Check the state of the online build log for the index.
Definition: ddl0ctx.cc:461
dberr_t setup_fts_build() noexcept
Setup the FTS index build data structures.
Definition: ddl0ctx.cc:444
FTS m_fts
The FTS builder.
Definition: ddl0ddl.h:579
dberr_t setup_pk_sort(Cursor *cursor) noexcept
Setup the primary key sort.
Definition: ddl0ctx.cc:494
std::pair< size_t, size_t > Scan_buffer_size
Scan sort and IO buffer size.
Definition: ddl0ddl.h:377
Key_numbers m_key_numbers
MySQL key numbers.
Definition: ddl0ddl.h:598
size_t m_add_autoinc
Number of added AUTO_INCREMENT columns, or ULINT_UNDEFINED if none added.
Definition: ddl0ddl.h:612
dberr_t handle_autoinc(const dtuple_t *row) noexcept
Handle auto increment.
Definition: ddl0ctx.cc:239
Flush_observer * flush_observer() noexcept
Definition: ddl0ctx.cc:136
bool m_online
True if creating index online.
Definition: ddl0ddl.h:592
Indexes m_indexes
Indexes to be created.
Definition: ddl0ddl.h:595
size_t load_io_buffer_size(size_t n_buffers) const noexcept
Calculate the io buffer size per file for the load phase.
Definition: ddl0ctx.cc:216
dberr_t get_error() const noexcept
Definition: ddl0ddl.h:423
void set_error(dberr_t err, size_t id) noexcept
Set the error code and index number where the error occurred.
Definition: ddl0ddl.h:440
std::vector< dict_index_t *, ut::allocator< dict_index_t * > > Indexes
Definition: ddl0ddl.h:567
dberr_t read_init(Cursor *cursor) noexcept
Initialize the context for a cluster index scan.
Definition: ddl0ctx.cc:502
ddl::Sequence & m_sequence
Autoinc sequence.
Definition: ddl0ddl.h:615
friend struct Btree_cursor
Definition: ddl0ddl.h:668
Cursor * m_cursor
Cursor for reading the cluster index.
Definition: ddl0ddl.h:643
Alter_stage * m_stage
Performance schema accounting object, used by ALTER TABLE.
Definition: ddl0ddl.h:621
const size_t m_max_threads
Maximum number of threads to use.
Definition: ddl0ddl.h:654
dberr_t build() noexcept
Build the indexes.
Definition: ddl0ctx.cc:511
bool check_null_constraints(const dtuple_t *row) const noexcept
Check if the nonnull columns satisfy the constraint.
Definition: ddl0ctx.cc:417
dberr_t fts_create(dict_index_t *index) noexcept
Initialize the FTS build infrastructure.
Definition: ddl0ctx.cc:286
TABLE * m_eval_table
MySQL table used to evaluate virtual column value, see innobase_get_computed_value().
Definition: ddl0ddl.h:628
THD * thd() noexcept
Definition: ddl0ctx.cc:140
doc_id_t next_doc_id() noexcept
Get the next Doc ID and increment the current value.
Cursor for reading the data.
Definition: ddl0impl-cursor.h:41
Structure for reporting duplicate records.
Definition: ddl0ddl.h:132
dict_index_t * m_index
Index being sorted.
Definition: ddl0ddl.h:146
size_t m_n_dup
Number of duplicates.
Definition: ddl0ddl.h:156
void report(const dfield_t *entry) noexcept
Report a duplicate key.
Definition: ddl0ddl.cc:83
const ulint * m_col_map
Mapping of column numbers in table to the rebuilt table (index->table), or NULL if not rebuilding tab...
Definition: ddl0ddl.h:153
TABLE * m_table
MySQL table object.
Definition: ddl0ddl.h:149
bool empty() const noexcept
Definition: ddl0ddl.h:143
Full text search index builder.
Definition: ddl0fts.h:67
Definition of an index being created.
Definition: ddl0ddl.h:99
const char * m_name
Index name.
Definition: ddl0ddl.h:101
bool m_srid_is_valid
true if we want to check SRID while inserting to index
Definition: ddl0ddl.h:125
bool m_is_ngram
true if it's ngram parser
Definition: ddl0ddl.h:122
size_t m_ind_type
0, DICT_UNIQUE, or DICT_CLUSTERED
Definition: ddl0ddl.h:107
size_t m_key_number
MySQL key number, or ULINT_UNDEFINED if none.
Definition: ddl0ddl.h:110
Index_field * m_fields
Field definitions.
Definition: ddl0ddl.h:116
uint32_t m_srid
SRID obtained from dd column.
Definition: ddl0ddl.h:128
size_t m_n_fields
Number of fields in index.
Definition: ddl0ddl.h:113
st_mysql_ftparser * m_parser
Fulltext parser plugin.
Definition: ddl0ddl.h:119
bool m_rebuild
Whether the table is rebuilt.
Definition: ddl0ddl.h:104
Index field definition.
Definition: ddl0ddl.h:81
bool m_is_ascending
true=ASC, false=DESC
Definition: ddl0ddl.h:95
size_t m_col_no
Column offset.
Definition: ddl0ddl.h:83
size_t m_prefix_len
Column prefix length, or 0 if indexing the whole column.
Definition: ddl0ddl.h:86
bool m_is_v_col
Whether this is a virtual column.
Definition: ddl0ddl.h:89
bool m_is_multi_value
Whether it has multi-value.
Definition: ddl0ddl.h:92
Definition: ddl0impl-builder.h:457
Merge the blocks in the file.
Definition: ddl0impl-merge.h:45
Cursor used for parallel reads.
Definition: ddl0par-scan.cc:45
Physical row context.
Definition: ddl0impl.h:121
Generate the next autoinc based on a snapshot of the session auto_increment_increment and auto_increm...
Definition: ddl0ddl.h:267
ulonglong last() const noexcept
Definition: ddl0ddl.h:298
bool m_eof
true if no more values left in the sequence
Definition: ddl0ddl.h:317
ulong m_increment
Value of auto_increment_increment.
Definition: ddl0ddl.h:308
const ulonglong m_max_value
Maximum column value if adding an AUTOINC column else 0.
Definition: ddl0ddl.h:305
ddl::Sequence & operator=(const ddl::Sequence &rhs) noexcept
Assignment operator to copy the sequence values.
Definition: ddl0ddl.h:287
ulong m_offset
Value of auto_increment_offset.
Definition: ddl0ddl.h:311
ulonglong operator++(int) noexcept
Postfix increment.
Definition: ddl0ctx.cc:560
Sequence(THD *thd, ulonglong start_value, ulonglong max_value) noexcept
Constructor.
Definition: ddl0ctx.cc:538
ulonglong m_next_value
Next value in the sequence.
Definition: ddl0ddl.h:314
~Sequence()=default
Destructor.
bool eof() const noexcept
Check if the autoinc "sequence" is exhausted.
Definition: ddl0ddl.h:283
Structure for an SQL data field.
Definition: data0data.h:617
Data structure for newly added virtual column in a table.
Definition: dict0mem.h:830
Data structure for an index.
Definition: dict0mem.h:1041
Data structure for a database table.
Definition: dict0mem.h:1904
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:696
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:302
Definition: plugin_ftparser.h:216
Definition: trx0trx.h:675
long long sequence(UDF_INIT *initid, UDF_ARGS *args, unsigned char *, unsigned char *)
Definition: udf_example.cc:568
unsigned long int ulint
Definition: univ.i:406
constexpr size_t UNIV_PAGE_SIZE_MAX
Maximum page size InnoDB currently supports.
Definition: univ.i:323
constexpr ulint ULINT_UNDEFINED
The 'undefined' value for a ulint.
Definition: univ.i:420
Utilities related to class lifecycle.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:105
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:93
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:510
int n
Definition: xcom_base.cc:509