MySQL 9.0.0
Source Code Documentation
dict0crea.h File Reference

Database object creation. More...

#include "dict0dict.h"
#include "dict0types.h"
#include "fsp0space.h"
#include "mtr0mtr.h"
#include "que0types.h"
#include "row0types.h"
#include "sql/handler.h"
#include "univ.i"
#include "dict0crea.ic"

Go to the source code of this file.

Classes

struct  tab_node_t
 
struct  ind_node_t
 

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_table_assign_new_id (dict_table_t *table)
 Assign a new table ID and put it into the table cache and the transaction. More...
 
void dict_build_index_def (const dict_table_t *table, dict_index_t *index, trx_t *trx)
 Builds an index definition but doesn't update sys_table. 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 dberr_t dict_create_add_foreign_id (ulint *id_nr, const char *name, dict_foreign_t *foreign)
 Generate a foreign key constraint name when it was not named by the user. 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...
 
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...
 
static ulint dict_create_v_col_pos (ulint v_pos, ulint col_pos)
 Compose a column number for a virtual column, stored in the "POS" field of Sys_columns. More...
 
static ulint dict_get_v_col_mysql_pos (ulint pos)
 Get the column number for a virtual column (the column position in original table), stored in the "POS" field of Sys_columns. More...
 
static ulint dict_get_v_col_pos (ulint pos)
 Get a virtual column sequence (the "nth" virtual column) for a virtual column, stord in the "POS" field of Sys_columns. 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 but doesn't update sys_table.

in/out: InnoDB transaction handle

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_add_foreign_id()

static dberr_t dict_create_add_foreign_id ( ulint id_nr,
const char *  name,
dict_foreign_t foreign 
)
inlinestatic

Generate a foreign key constraint name when it was not named by the user.

A generated constraint has a name of the format dbname/tablename_ibfk_NUMBER, where the numbers start from 1, and are given locally for this table, that is, the number is not global, as it used to be before MySQL 4.0.18.

Parameters
[in,out]id_nrnumber to use in id generation; incremented if used
[in]nametable name
[in,out]foreignforeign key

◆ 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_create_v_col_pos()

static ulint dict_create_v_col_pos ( ulint  v_pos,
ulint  col_pos 
)
inlinestatic

Compose a column number for a virtual column, stored in the "POS" field of Sys_columns.

The column number includes both its virtual column sequence (the "nth" virtual column) and its actual column position in original table

Parameters
[in]v_posvirtual column sequence
[in]col_poscolumn position in original table definition
Returns
composed column position number

◆ 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_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_get_v_col_mysql_pos()

static ulint dict_get_v_col_mysql_pos ( ulint  pos)
inlinestatic

Get the column number for a virtual column (the column position in original table), stored in the "POS" field of Sys_columns.

Parameters
[in]posvirtual column position
Returns
column position in original table

◆ dict_get_v_col_pos()

static ulint dict_get_v_col_pos ( ulint  pos)
inlinestatic

Get a virtual column sequence (the "nth" virtual column) for a virtual column, stord in the "POS" field of Sys_columns.

Parameters
[in]posvirtual column position
Returns
virtual column sequence

◆ 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