MySQL 8.3.0
Source Code Documentation
sql_gipk.h File Reference
#include "my_inttypes.h"

Go to the source code of this file.

Functions

bool is_generate_invisible_primary_key_mode_active (THD *thd)
 Check if generate invisible primary key mode is active. More...
 
bool is_generated_invisible_primary_key_column_name (const char *column_name)
 Check if column_name matches generated invisible primary key column name. 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...
 
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...
 
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...
 
bool table_has_generated_invisible_primary_key (const TABLE *table)
 Check if table has a generated invisible primary key. More...
 

Function Documentation

◆ adjust_generated_invisible_primary_key_column_position()

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.

Parameters
[in]thdThread handle.
[in]se_handlertonHandlerton instance of table's storage engine
[in]old_tableOld definition of a table being altered.
[in,out]prepared_create_listCreate_field list prepared for ALTER in prepare_fields_and_keys().
Return values
falseOn success.
trueOn failure.

◆ check_primary_key_alter_restrictions()

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.

Parameters
[in]thdThread handle.
[in]se_handlertonHandlerton instance of table's storage engine
[in]alter_infoAlter_info instance describing new table definition of a table being altered.
[in]old_tableOld definition of a table being altered.
Return values
falseOn success.
trueOn failure.

◆ is_candidate_table_for_invisible_primary_key_generation()

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.

Parameters
[in]create_infoHA_CREATE_INFO instance describing table being created.
[in]alter_infoAlter_info instance describing table being created.
Return values
trueif table is suitable for primary key generation.
falseOtherwise.

◆ is_generate_invisible_primary_key_mode_active()

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.

Parameters
[in]thdThread handle.
Returns
true if @sql_generate_invisible_primary_key is ON for thread other than bootstrap and initialize system threads.

◆ is_generated_invisible_primary_key_column_name()

bool is_generated_invisible_primary_key_column_name ( const char *  column_name)

Check if column_name matches generated invisible primary key column name.

Parameters
[in]column_nameName of a column.
Return values
truecolumn_name matches generated invisible primary key column name.
falseOtherwise.

◆ table_def_has_generated_invisible_primary_key()

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.

Parameters
[in]thdThread handle.
[in]se_handlertonHandlerton instance of table's storage engine
[in]create_fieldsList of Create_field instance for the table columns.
[in]keysNumber of KEY structs in the 'keyinfo'.
[in]keyinfoAn array of KEY structs for the indexes.
Returns
true if table definition has a generated invisible primary key otherwise returns false.

◆ table_has_generated_invisible_primary_key()

bool table_has_generated_invisible_primary_key ( const TABLE table)

Check if table has a generated invisible primary key.

Parameters
[in]tableTABLE instance of a table.
Return values
trueIf table has a generated invisible primary key.
falseOtherwise.

◆ validate_and_generate_invisible_primary_key()

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.

Parameters
[in]thdThread handle.
[in,out]alter_infoAlter_info instance describing table being created or altered.
Return values
falseOn success.
trueOn failure.