MySQL 8.0.39
Source Code Documentation
|
#include "sql_gipk.h"
#include "sql/create_field.h"
#include "sql/dd/properties.h"
#include "sql/dd/types/abstract_table.h"
#include "sql/dd/types/index.h"
#include "sql/sql_alter.h"
#include "sql/sql_class.h"
#include "sql/sql_lex.h"
#include "sql/sql_table.h"
Functions | |
bool | is_generated_invisible_primary_key_column_name (const char *column_name) |
Check if column_name matches generated invisible primary key column name. More... | |
static bool | is_generating_invisible_pk_supported_for_se (handlerton *se_handlerton) |
Check if invisible primary key generation is supported for the table's storage engine. More... | |
bool | is_generate_invisible_primary_key_mode_active (THD *thd) |
Check if generate invisible primary key mode is active. More... | |
bool | is_candidate_table_for_invisible_primary_key_generation (const HA_CREATE_INFO *create_info, Alter_info *alter_info) |
Check if table being created is suitable for invisible primary key generation. More... | |
static bool | validate_invisible_primary_key_generation (THD *thd, Alter_info *alter_info) |
Validate invisible primary key generation for a candidate table (table being created). More... | |
static bool | generate_invisible_primary_key (THD *thd, Alter_info *alter_info) |
Generates invisible primary key for a table. More... | |
bool | validate_and_generate_invisible_primary_key (THD *thd, Alter_info *alter_info) |
Validate and generate invisible primary key for a candidate table (table being created). More... | |
bool | adjust_generated_invisible_primary_key_column_position (THD *thd, handlerton *se_handlerton, TABLE *old_table, List< Create_field > *prepared_create_list) |
Adjust generated invisible primary key column position in prepared fields list for the ALTER TABLE statement. More... | |
static bool | is_candidate_table_for_pk_alter_restrictions_check (handlerton *se_handlerton, TABLE *old_table) |
Check if table being altered is suitable to apply primary key ALTER restriction checks. More... | |
bool | check_primary_key_alter_restrictions (THD *thd, handlerton *se_handlerton, Alter_info *alter_info, TABLE *old_table) |
Check ALTER restrictions on primary key and column. More... | |
bool | table_def_has_generated_invisible_primary_key (THD *thd, handlerton *se_handlerton, const List< Create_field > &create_fields, uint keys, const KEY *keyinfo) |
Check that definition of a table being created or altered has a generated invisible primary key definition. More... | |
static bool | is_generated_invisible_primary_key_column (Field *field) |
Check if column is a generated invisible primary key column. More... | |
static bool | is_generated_invisible_primary_key (const KEY *key) |
Check if KEY is of a generated invisible primary key. More... | |
static const KEY * | find_generated_invisible_primary_key (TABLE *table) |
Find generated invisible primary key in KEYs list of a table. More... | |
bool | table_has_generated_invisible_primary_key (TABLE *table) |
Check if table has a generated invisible primary key. More... | |
Variables | |
const char * | gipk_column_name = "my_row_id" |
bool adjust_generated_invisible_primary_key_column_position | ( | THD * | thd, |
handlerton * | se_handlerton, | ||
TABLE * | old_table, | ||
List< Create_field > * | prepared_create_list | ||
) |
Adjust generated invisible primary key column position in prepared fields list for the ALTER TABLE statement.
Make sure generated invisible column is positioned at the first place.
[in] | thd | Thread handle. |
[in] | se_handlerton | Handlerton instance of table's storage engine |
[in] | old_table | Old definition of a table being altered. |
[in,out] | prepared_create_list | Create_field list prepared for ALTER in prepare_fields_and_keys(). |
false | On success. |
true | On failure. |
bool check_primary_key_alter_restrictions | ( | THD * | thd, |
handlerton * | se_handlerton, | ||
Alter_info * | alter_info, | ||
TABLE * | old_table | ||
) |
Check ALTER restrictions on primary key and column.
Following ALTER restrictions are applicable on primary key and column,
) When sql_generate_invisible_primary_key is enabled then, primary key is allowed to drop only if new table definition has a primary key.
) Generated invisible primary key is allowed to drop only if primary key column is also dropped. This restriction is applicable irrespective of sql_generate_invisible_primary_key's state.
) CHANGE/MODIFY OR ALTER operations on generated invisible primary key columns are not allowed except ALTER operation to change column visibility attribute. This restriction is applicable irrespective of sql_generate_invisible_primary_key's state.
[in] | thd | Thread handle. |
[in] | se_handlerton | Handlerton instance of table's storage engine |
[in] | alter_info | Alter_info instance describing new table definition of a table being altered. |
[in] | old_table | Old definition of a table being altered. |
false | On success. |
true | On failure. |
Find generated invisible primary key in KEYs list of a table.
table | TABLE instance of a table. |
KEY* | KEY instance of a generated primary key. |
nullptr | If table does not have a generated invisible primary key. |
|
static |
Generates invisible primary key for a table.
[in] | thd | Thread handle. |
[in,out] | alter_info | Alter_info instance describing table being created or altered. |
false | On success. |
true | On failure. |
bool is_candidate_table_for_invisible_primary_key_generation | ( | const HA_CREATE_INFO * | create_info, |
Alter_info * | alter_info | ||
) |
Check if table being created is suitable for invisible primary key generation.
Primary key is generated only if a) explicit primary key is not defined for a table b) primary key generation is supported for the storage engine.
[in] | create_info | HA_CREATE_INFO instance describing table being created. |
[in] | alter_info | Alter_info instance describing table being created. |
true | if table is suitable for primary key generation. |
false | Otherwise. |
|
static |
Check if table being altered is suitable to apply primary key ALTER restriction checks.
se_handlerton | Handlerton instance of table's storage engine. |
old_table | Old definition of table being altered. |
true | if table is suitable to apply ALTER restriction checks. |
false | Otherwise. |
bool is_generate_invisible_primary_key_mode_active | ( | THD * | thd | ) |
Check if generate invisible primary key mode is active.
Note: For bootstreap and initialize system threads, generate invisible primary key mode is not applicable. If there are any system table without explicit primary key then primary key is not generated for them while bootstrapping or initializing.
[in] | thd | Thread handle. |
|
static |
Check if KEY is of a generated invisible primary key.
key | KEY instance. |
true | If KEY is of a generated invisible primary key. |
false | Otherwise. |
|
static |
Check if column is a generated invisible primary key column.
field | FIELD instance. |
true | If column is a generated invisible primary key column. |
false | Otherwise. |
bool is_generated_invisible_primary_key_column_name | ( | const char * | column_name | ) |
Check if column_name matches generated invisible primary key column name.
[in] | column_name | Name of a column. |
true | column_name matches generated invisible primary key column name. |
false | Otherwise. |
|
static |
Check if invisible primary key generation is supported for the table's storage engine.
se_handlerton | Handlerton instance of storage engine. |
true | If generating primary key is supported. |
false | Otherwise. |
bool table_def_has_generated_invisible_primary_key | ( | THD * | thd, |
handlerton * | se_handlerton, | ||
const List< Create_field > & | create_fields, | ||
uint | keys, | ||
const KEY * | keyinfo | ||
) |
Check that definition of a table being created or altered has a generated invisible primary key definition.
[in] | thd | Thread handle. |
[in] | se_handlerton | Handlerton instance of table's storage engine |
[in] | create_fields | List of Create_field instance for the table columns. |
[in] | keys | Number of KEY structs in the 'keyinfo'. |
[in] | keyinfo | An array of KEY structs for the indexes. |
bool table_has_generated_invisible_primary_key | ( | TABLE * | table | ) |
Check if table has a generated invisible primary key.
[in] | table | TABLE instance of a table. |
true | If table has a generated invisible primary key. |
false | Otherwise. |
bool validate_and_generate_invisible_primary_key | ( | THD * | thd, |
Alter_info * | alter_info | ||
) |
Validate and generate invisible primary key for a candidate table (table being created).
Primary key is generated if, a) Table is a non-partitioned table. Generating invisible primary key is not supported for partitioned tables for now. b) Table does not have a column with auto_increment attribute. c) Table does not have a column with name "my_row_id". d) Table is not created using CREATE TABLE ... SELECT in binlog_format=STATEMENT mode. Otherwise an error is reported in the validation of phase.
[in] | thd | Thread handle. |
[in,out] | alter_info | Alter_info instance describing table being created or altered. |
false | On success. |
true | On failure. |
|
static |
Validate invisible primary key generation for a candidate table (table being created).
thd | Thread handle. |
alter_info | Alter_info instance describing table being created. |
false | On success. |
true | On failure. |
const char* gipk_column_name = "my_row_id" |