MySQL 8.0.39
Source Code Documentation
dict0crea.cc File Reference

Database object creation. More...

#include "dict0crea.h"
#include "btr0btr.h"
#include "btr0pcur.h"
#include "dict0boot.h"
#include "dict0dd.h"
#include "dict0dict.h"
#include "dict0priv.h"
#include "dict0stats.h"
#include "fsp0space.h"
#include "fsp0sysspace.h"
#include "fts0priv.h"
#include "ha_prototypes.h"
#include "log0write.h"
#include "mach0data.h"
#include "my_dbug.h"
#include "dict0upgrade.h"
#include "page0page.h"
#include "pars0pars.h"
#include "que0que.h"
#include "row0ins.h"
#include "row0mysql.h"
#include "srv0start.h"
#include "trx0roll.h"
#include "usr0sess.h"
#include "ut0vec.h"

Functions

dberr_t dict_build_table_def (dict_table_t *table, const HA_CREATE_INFO *create_info, trx_t *trx)
 Build a table definition without updating SYSTEM TABLES. More...
 
dberr_t dict_build_tablespace (trx_t *trx, Tablespace *tablespace)
 Builds a tablespace to store various objects. More...
 
dberr_t dict_build_tablespace_for_table (dict_table_t *table, const HA_CREATE_INFO *create_info, trx_t *trx)
 Builds a tablespace to contain a table, using file-per-table=1. More...
 
void dict_build_index_def (const dict_table_t *table, dict_index_t *index, trx_t *trx)
 Builds an index definition. More...
 
dberr_t dict_create_index_tree_in_mem (dict_index_t *index, trx_t *trx)
 Creates an index tree for the index if it is not a member of a cluster. More...
 
void dict_drop_temporary_table_index (const dict_index_t *index, page_no_t root_page_no)
 Drop an index tree belonging to a temporary table. More...
 
static bool dict_index_has_col_by_name (const char *col_name, const dict_index_t *index)
 Check whether a column is in an index by the column name. More...
 
bool dict_foreign_has_col_in_v_index (const char *fk_col_name, const dict_table_t *table)
 Check whether the foreign constraint could be on a column that is part of a virtual index (index contains virtual column) in the table. More...
 
bool dict_foreign_has_col_as_base_col (const char *col_name, const dict_table_t *table)
 Check whether the foreign constraint could be on a column that is a base column of some indexed virtual columns. More...
 
static bool dict_foreign_base_for_stored (const char *col_name, const dict_table_t *table)
 Check if a foreign constraint is on the given column name. More...
 
bool dict_foreigns_has_s_base_col (const dict_foreign_set &local_fk_set, const dict_table_t *table)
 Check if a foreign constraint is on columns served as base columns of any stored column. More...
 
bool dict_foreigns_has_this_col (const dict_table_t *table, const char *col_name)
 Check if a column is in foreign constraint with CASCADE properties or SET NULL. More...
 
void dict_table_assign_new_id (dict_table_t *table)
 Assign a new table ID and put it into the table cache and the transaction. More...
 
dict_index_tdict_sdi_create_idx_in_mem (space_id_t space, bool space_discarded, uint32_t in_flags, bool is_create)
 Create in-memory tablespace dictionary index & table. More...
 

Detailed Description

Database object creation.

Created 1/8/1996 Heikki Tuuri

Function Documentation

◆ dict_build_index_def()

void dict_build_index_def ( const dict_table_t table,
dict_index_t index,
trx_t trx 
)

Builds an index definition.

Builds an index definition but doesn't update sys_table.

Parameters
tablein: table
indexin/out: index
trxin/out: InnoDB transaction handle

◆ dict_build_table_def()

dberr_t dict_build_table_def ( dict_table_t table,
const HA_CREATE_INFO create_info,
trx_t trx 
)

Build a table definition without updating SYSTEM TABLES.

Parameters
[in,out]tabledict table object
[in]create_infoHA_CREATE_INFO object
[in,out]trxtransaction instance
Returns
DB_SUCCESS or error code

In-memory counter used for assigning table_id of data dictionary table. This counter is only used during bootstrap or upgrade

◆ dict_build_tablespace()

dberr_t dict_build_tablespace ( trx_t trx,
Tablespace tablespace 
)

Builds a tablespace to store various objects.

Parameters
[in,out]trxDD transaction
[in,out]tablespaceTablespace object describing what to build.
Returns
DB_SUCCESS or error code.

◆ dict_build_tablespace_for_table()

dberr_t dict_build_tablespace_for_table ( dict_table_t table,
const HA_CREATE_INFO create_info,
trx_t trx 
)

Builds a tablespace to contain a table, using file-per-table=1.

Parameters
[in,out]tableTable to build in its own tablespace.
[in]create_infoHA_CREATE_INFO object
[in,out]trxTransaction
Returns
DB_SUCCESS or error code

◆ dict_create_index_tree_in_mem()

dberr_t dict_create_index_tree_in_mem ( dict_index_t index,
trx_t trx 
)

Creates an index tree for the index if it is not a member of a cluster.

Parameters
[in,out]indexInnoDB index object
[in,out]trxtransaction
Returns
DB_SUCCESS or DB_OUT_OF_FILE_SPACE

◆ dict_drop_temporary_table_index()

void dict_drop_temporary_table_index ( const dict_index_t index,
page_no_t  root_page_no 
)

Drop an index tree belonging to a temporary table.

Parameters
[in]indexindex in a temporary table
[in]root_page_noindex root page number

◆ dict_foreign_base_for_stored()

static bool dict_foreign_base_for_stored ( const char *  col_name,
const dict_table_t table 
)
static

Check if a foreign constraint is on the given column name.

Parameters
[in]col_namecolumn name to be searched for fk constraint
[in]tabletable to which foreign key constraint belongs
Returns
true if fk constraint is present on the table, false otherwise.

If the stored column can refer to virtual column or stored column then it can points to NULL.

◆ dict_foreign_has_col_as_base_col()

bool dict_foreign_has_col_as_base_col ( const char *  col_name,
const dict_table_t table 
)

Check whether the foreign constraint could be on a column that is a base column of some indexed virtual columns.

Parameters
[in]col_namecolumn name for the column to be checked
[in]tablethe table
Returns
true if this column is a base column, otherwise, false

◆ dict_foreign_has_col_in_v_index()

bool dict_foreign_has_col_in_v_index ( const char *  fk_col_name,
const dict_table_t table 
)

Check whether the foreign constraint could be on a column that is part of a virtual index (index contains virtual column) in the table.

Parameters
[in]fk_col_nameFK column name to be checked
[in]tablethe table
Returns
true if this column is indexed with other virtual columns

◆ dict_foreigns_has_s_base_col()

bool dict_foreigns_has_s_base_col ( const dict_foreign_set local_fk_set,
const dict_table_t table 
)

Check if a foreign constraint is on columns served as base columns of any stored column.

This is to prevent creating SET NULL or CASCADE constraint on such columns

Parameters
[in]local_fk_setset of foreign key objects, to be added to the dictionary tables
[in]tabletable to which the foreign key objects in local_fk_set belong to
Returns
true if yes, otherwise, false

◆ dict_foreigns_has_this_col()

bool dict_foreigns_has_this_col ( const dict_table_t table,
const char *  col_name 
)

Check if a column is in foreign constraint with CASCADE properties or SET NULL.

Parameters
[in]tabletable
[in]col_namename for the column to be checked
Returns
true if the column is in foreign constraint, otherwise, false

◆ dict_index_has_col_by_name()

static bool dict_index_has_col_by_name ( const char *  col_name,
const dict_index_t index 
)
static

Check whether a column is in an index by the column name.

Parameters
[in]col_namecolumn name for the column to be checked
[in]indexthe index to be searched
Returns
true if this column is in the index, otherwise, false

◆ dict_sdi_create_idx_in_mem()

dict_index_t * dict_sdi_create_idx_in_mem ( space_id_t  space,
bool  space_discarded,
uint32_t  in_flags,
bool  is_create 
)

Create in-memory tablespace dictionary index & table.

Parameters
[in]spacetablespace id
[in]space_discardedtrue if space is discarded
[in]in_flagsspace flags to use when space_discarded is true
[in]is_createtrue when creating SDI index
Returns
in-memory index structure for tablespace dictionary or NULL

◆ dict_table_assign_new_id()

void dict_table_assign_new_id ( dict_table_t table)

Assign a new table ID and put it into the table cache and the transaction.

Parameters
[in,out]tableTable that needs an ID