MySQL 8.0.40
Source Code Documentation
|
Class describing changes to be done by ALTER TABLE. More...
#include <handler.h>
Public Types | |
typedef ulonglong | HA_ALTER_FLAGS |
Bits to show in detail what operations the storage engine is to execute. More... | |
Public Member Functions | |
Alter_inplace_info (HA_CREATE_INFO *create_info_arg, Alter_info *alter_info_arg, bool error_if_not_empty_arg, KEY *key_info_arg, uint key_count_arg, partition_info *modified_part_info_arg) | |
~Alter_inplace_info () | |
void | report_unsupported_error (const char *not_supported, const char *try_instead) |
Used after check_if_supported_inplace_alter() to report error if the result does not match the LOCK/ALGORITHM requirements set by the user. More... | |
void | add_renamed_key (KEY *old_key, KEY *new_key) |
Add old and new version of key to array of indexes to be renamed. More... | |
void | add_altered_index_visibility (KEY *old_key, KEY *new_key) |
void | add_modified_key (KEY *old_key, KEY *new_key) |
Add old and new version of modified key to arrays of indexes to be dropped and added (correspondingly). More... | |
void | add_dropped_key (KEY *old_key) |
Drop key to array of indexes to be dropped. More... | |
void | add_added_key (KEY *new_key) |
Add key to array of indexes to be added. More... | |
Public Attributes | |
HA_CREATE_INFO * | create_info |
Create options (like MAX_ROWS) for the new version of table. More... | |
Alter_info * | alter_info |
Alter options, fields and keys for the new version of table. More... | |
bool | error_if_not_empty |
Indicates whether operation should fail if table is non-empty. More... | |
KEY * | key_info_buffer |
Array of KEYs for new version of table - including KEYs to be added. More... | |
uint | key_count |
Size of key_info_buffer array. More... | |
uint | index_drop_count |
Size of index_drop_buffer array. More... | |
KEY ** | index_drop_buffer |
Array of pointers to KEYs to be dropped belonging to the TABLE instance for the old version of the table. More... | |
uint | index_add_count |
Size of index_add_buffer array. More... | |
uint * | index_add_buffer |
Array of indexes into key_info_buffer for KEYs to be added, sorted in increasing order. More... | |
uint | index_rename_count |
Size of index_rename_buffer array. More... | |
uint | index_altered_visibility_count |
Size of index_rename_buffer array. More... | |
KEY_PAIR * | index_rename_buffer |
Array of KEY_PAIR objects describing indexes being renamed. More... | |
KEY_PAIR * | index_altered_visibility_buffer |
uint | virtual_column_add_count |
Number of virtual columns to be added. More... | |
uint | virtual_column_drop_count |
number of virtual columns to be dropped. More... | |
inplace_alter_handler_ctx * | handler_ctx |
Context information to allow handlers to keep context between in-place alter API calls. More... | |
inplace_alter_handler_ctx ** | group_commit_ctx |
If the table uses several handlers, like ha_partition uses one handler per partition, this contains a Null terminated array of ctx pointers that should all be committed together. More... | |
HA_ALTER_FLAGS | handler_flags |
Flags describing in detail which operations the storage engine is to execute. More... | |
partition_info * | modified_part_info |
Partition_info taking into account the partition changes to be performed. More... | |
bool | online |
true for online operation (LOCK=NONE) More... | |
uint | handler_trivial_ctx |
Can be set by handler along with handler_ctx. More... | |
const char * | unsupported_reason |
Can be set by handler to describe why a given operation cannot be done in-place (HA_ALTER_INPLACE_NOT_SUPPORTED) or why it cannot be done online (HA_ALTER_INPLACE_NO_LOCK or HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE) If set, it will be used with ER_ALTER_OPERATION_NOT_SUPPORTED_REASON if results from handler::check_if_supported_inplace_alter() doesn't match requirements set by user. More... | |
Static Public Attributes | |
static const HA_ALTER_FLAGS | ADD_INDEX = 1ULL << 0 |
static const HA_ALTER_FLAGS | DROP_INDEX = 1ULL << 1 |
static const HA_ALTER_FLAGS | ADD_UNIQUE_INDEX = 1ULL << 2 |
static const HA_ALTER_FLAGS | DROP_UNIQUE_INDEX = 1ULL << 3 |
static const HA_ALTER_FLAGS | ADD_PK_INDEX = 1ULL << 4 |
static const HA_ALTER_FLAGS | DROP_PK_INDEX = 1ULL << 5 |
static const HA_ALTER_FLAGS | ADD_VIRTUAL_COLUMN = 1ULL << 6 |
static const HA_ALTER_FLAGS | ADD_STORED_BASE_COLUMN = 1ULL << 7 |
static const HA_ALTER_FLAGS | ADD_STORED_GENERATED_COLUMN = 1ULL << 8 |
static const HA_ALTER_FLAGS | ADD_COLUMN |
static const HA_ALTER_FLAGS | DROP_VIRTUAL_COLUMN = 1ULL << 9 |
static const HA_ALTER_FLAGS | DROP_STORED_COLUMN = 1ULL << 10 |
static const HA_ALTER_FLAGS | DROP_COLUMN |
static const HA_ALTER_FLAGS | ALTER_COLUMN_NAME = 1ULL << 11 |
static const HA_ALTER_FLAGS | ALTER_VIRTUAL_COLUMN_TYPE = 1ULL << 12 |
static const HA_ALTER_FLAGS | ALTER_STORED_COLUMN_TYPE = 1ULL << 13 |
static const HA_ALTER_FLAGS | ALTER_COLUMN_EQUAL_PACK_LENGTH = 1ULL << 14 |
Change column datatype in such way that new type has compatible packed representation with old type, so it is theoretically possible to perform change by only updating data dictionary without changing table rows. More... | |
static const HA_ALTER_FLAGS | ALTER_VIRTUAL_COLUMN_ORDER = 1ULL << 15 |
A virtual column has changed its position. More... | |
static const HA_ALTER_FLAGS | ALTER_STORED_COLUMN_ORDER = 1ULL << 16 |
A stored column has changed its position (disregarding virtual columns) More... | |
static const HA_ALTER_FLAGS | ALTER_COLUMN_NULLABLE = 1ULL << 17 |
static const HA_ALTER_FLAGS | ALTER_COLUMN_NOT_NULLABLE = 1ULL << 18 |
static const HA_ALTER_FLAGS | ALTER_COLUMN_DEFAULT = 1ULL << 19 |
static const HA_ALTER_FLAGS | ALTER_VIRTUAL_GCOL_EXPR = 1ULL << 20 |
static const HA_ALTER_FLAGS | ALTER_STORED_GCOL_EXPR = 1ULL << 21 |
static const HA_ALTER_FLAGS | ADD_FOREIGN_KEY = 1ULL << 22 |
static const HA_ALTER_FLAGS | DROP_FOREIGN_KEY = 1ULL << 23 |
static const HA_ALTER_FLAGS | CHANGE_CREATE_OPTION = 1ULL << 24 |
static const HA_ALTER_FLAGS | ALTER_RENAME = 1ULL << 25 |
static const HA_ALTER_FLAGS | ALTER_COLUMN_STORAGE_TYPE = 1ULL << 26 |
static const HA_ALTER_FLAGS | ALTER_COLUMN_COLUMN_FORMAT = 1ULL << 27 |
static const HA_ALTER_FLAGS | ADD_PARTITION = 1ULL << 28 |
static const HA_ALTER_FLAGS | DROP_PARTITION = 1ULL << 29 |
static const HA_ALTER_FLAGS | ALTER_PARTITION = 1ULL << 30 |
static const HA_ALTER_FLAGS | COALESCE_PARTITION = 1ULL << 31 |
static const HA_ALTER_FLAGS | REORGANIZE_PARTITION = 1ULL << 32 |
static const HA_ALTER_FLAGS | ALTER_TABLE_REORG = 1ULL << 33 |
static const HA_ALTER_FLAGS | ALTER_REMOVE_PARTITIONING = 1ULL << 34 |
static const HA_ALTER_FLAGS | ALTER_ALL_PARTITION = 1ULL << 35 |
static const HA_ALTER_FLAGS | RENAME_INDEX = 1ULL << 36 |
Rename index. More... | |
static const HA_ALTER_FLAGS | RECREATE_TABLE = 1ULL << 37 |
Recreate the table for ALTER TABLE FORCE, ALTER TABLE ENGINE and OPTIMIZE TABLE operations. More... | |
static const HA_ALTER_FLAGS | ADD_SPATIAL_INDEX = 1ULL << 38 |
static const HA_ALTER_FLAGS | ALTER_INDEX_COMMENT = 1ULL << 39 |
static const HA_ALTER_FLAGS | VALIDATE_VIRTUAL_COLUMN = 1ULL << 40 |
static const HA_ALTER_FLAGS | CHANGE_INDEX_OPTION = 1LL << 41 |
Change index option in a way which is likely not to require index recreation. More... | |
static const HA_ALTER_FLAGS | ALTER_REBUILD_PARTITION = 1ULL << 42 |
static const HA_ALTER_FLAGS | ALTER_COLUMN_INDEX_LENGTH = 1ULL << 43 |
Change in index length such that it does not require index rebuild. More... | |
static const HA_ALTER_FLAGS | VIRTUAL_GCOL_REEVAL = 1ULL << 44 |
Change to one of columns on which virtual generated column depends, so its values require re-evaluation. More... | |
static const HA_ALTER_FLAGS | STORED_GCOL_REEVAL = 1ULL << 45 |
Change to one of columns on which stored generated column depends, so its values require re-evaluation. More... | |
static const HA_ALTER_FLAGS | ADD_CHECK_CONSTRAINT = 1ULL << 46 |
static const HA_ALTER_FLAGS | DROP_CHECK_CONSTRAINT = 1ULL << 47 |
static const HA_ALTER_FLAGS | SUSPEND_CHECK_CONSTRAINT = 1ULL << 48 |
static const HA_ALTER_FLAGS | ALTER_COLUMN_VISIBILITY = 1ULL << 49 |
Class describing changes to be done by ALTER TABLE.
Instance of this class is passed to storage engine in order to determine if this ALTER TABLE can be done using in-place algorithm. It is also used for executing the ALTER TABLE using in-place algorithm.
Bits to show in detail what operations the storage engine is to execute.
All these operations are supported as in-place operations by the SQL layer. This means that operations that by their nature must be performed by copying the table to a temporary table, will not have their own flags here (e.g. ALTER TABLE FORCE, ALTER TABLE ENGINE).
We generally try to specify handler flags only if there are real changes. But in cases when it is cumbersome to determine if some attribute has really changed we might choose to set flag pessimistically, for example, relying on parser output only.
|
inline |
|
inline |
|
inline |
Add key to array of indexes to be added.
|
inline |
Drop key to array of indexes to be dropped.
Add old and new version of modified key to arrays of indexes to be dropped and added (correspondingly).
Add old and new version of key to array of indexes to be renamed.
void Alter_inplace_info::report_unsupported_error | ( | const char * | not_supported, |
const char * | try_instead | ||
) |
Used after check_if_supported_inplace_alter() to report error if the result does not match the LOCK/ALGORITHM requirements set by the user.
not_supported | Part of statement that was not supported. |
try_instead | Suggestion as to what the user should replace not_supported with. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Change column datatype in such way that new type has compatible packed representation with old type, so it is theoretically possible to perform change by only updating data dictionary without changing table rows.
|
static |
Change in index length such that it does not require index rebuild.
For example, change in index length due to column expansion like varchar(X) changed to varchar(X + N).
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Alter_info* Alter_inplace_info::alter_info |
Alter options, fields and keys for the new version of table.
|
static |
|
static |
|
static |
|
static |
|
static |
A stored column has changed its position (disregarding virtual columns)
|
static |
|
static |
|
static |
|
static |
A virtual column has changed its position.
|
static |
|
static |
|
static |
|
static |
Change index option in a way which is likely not to require index recreation.
For example, change COMMENT or KEY::is_algorithm_explicit flag (without change of index algorithm itself).
|
static |
HA_CREATE_INFO* Alter_inplace_info::create_info |
Create options (like MAX_ROWS) for the new version of table.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
bool Alter_inplace_info::error_if_not_empty |
Indicates whether operation should fail if table is non-empty.
Storage engines should not suggest/allow execution of such operations using INSTANT algorithm since check whether table is empty done from SQL-layer is not "instant". Also SEs might choose different algorithm for ALTER TABLE execution knowing that it will be allowed to proceed only if table is empty.
Unlike for Alter_table_ctx::error_if_not_empty, we use bool for this flag and not bitmap, since SEs are really interested in the fact that ALTER will fail if table is not empty and not in exact reason behind this fact, and because we want to avoid extra dependency between Alter_table_ctx and Alter_inplace_info.
inplace_alter_handler_ctx** Alter_inplace_info::group_commit_ctx |
If the table uses several handlers, like ha_partition uses one handler per partition, this contains a Null terminated array of ctx pointers that should all be committed together.
Or NULL if only handler_ctx should be committed. Set to NULL if the low level handler::commit_inplace_alter_table uses it, to signal to the main handler that everything was committed as atomically.
inplace_alter_handler_ctx* Alter_inplace_info::handler_ctx |
Context information to allow handlers to keep context between in-place alter API calls.
HA_ALTER_FLAGS Alter_inplace_info::handler_flags |
Flags describing in detail which operations the storage engine is to execute.
uint Alter_inplace_info::handler_trivial_ctx |
Can be set by handler along with handler_ctx.
The difference is that this flag can be used to store SE-specific in-place ALTER context in cases when constructing full-blown inplace_alter_handler_ctx descendant is inconvenient.
uint* Alter_inplace_info::index_add_buffer |
Array of indexes into key_info_buffer for KEYs to be added, sorted in increasing order.
uint Alter_inplace_info::index_add_count |
Size of index_add_buffer array.
KEY_PAIR* Alter_inplace_info::index_altered_visibility_buffer |
uint Alter_inplace_info::index_altered_visibility_count |
Size of index_rename_buffer array.
KEY** Alter_inplace_info::index_drop_buffer |
Array of pointers to KEYs to be dropped belonging to the TABLE instance for the old version of the table.
uint Alter_inplace_info::index_drop_count |
Size of index_drop_buffer array.
KEY_PAIR* Alter_inplace_info::index_rename_buffer |
Array of KEY_PAIR objects describing indexes being renamed.
For each index renamed it contains object with KEY_PAIR::old_key pointing to KEY object belonging to the TABLE instance for old version of table representing old version of index and with KEY_PAIR::new_key pointing to KEY object for new version of index in key_info_buffer member.
uint Alter_inplace_info::index_rename_count |
Size of index_rename_buffer array.
uint Alter_inplace_info::key_count |
Size of key_info_buffer array.
KEY* Alter_inplace_info::key_info_buffer |
Array of KEYs for new version of table - including KEYs to be added.
KEYs are sorted - see sort_keys().
partition_info* Alter_inplace_info::modified_part_info |
Partition_info taking into account the partition changes to be performed.
Contains all partitions which are present in the old version of the table with partitions to be dropped or changed marked as such + all partitions to be added in the new version of table marked as such.
bool Alter_inplace_info::online |
true for online operation (LOCK=NONE)
|
static |
Recreate the table for ALTER TABLE FORCE, ALTER TABLE ENGINE and OPTIMIZE TABLE operations.
|
static |
Rename index.
Note that we set this flag only if there are no other changes to the index being renamed. Also for simplicity we don't detect renaming of indexes which is done by dropping index and then re-creating index with identical definition under different name.
|
static |
|
static |
Change to one of columns on which stored generated column depends, so its values require re-evaluation.
|
static |
const char* Alter_inplace_info::unsupported_reason |
Can be set by handler to describe why a given operation cannot be done in-place (HA_ALTER_INPLACE_NOT_SUPPORTED) or why it cannot be done online (HA_ALTER_INPLACE_NO_LOCK or HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE) If set, it will be used with ER_ALTER_OPERATION_NOT_SUPPORTED_REASON if results from handler::check_if_supported_inplace_alter() doesn't match requirements set by user.
If not set, the more generic ER_ALTER_OPERATION_NOT_SUPPORTED will be used.
Please set to a properly localized string, for example using my_get_err_msg(), so that the error message as a whole is localized.
|
static |
uint Alter_inplace_info::virtual_column_add_count |
Number of virtual columns to be added.
uint Alter_inplace_info::virtual_column_drop_count |
number of virtual columns to be dropped.
|
static |
Change to one of columns on which virtual generated column depends, so its values require re-evaluation.