MySQL 8.3.0
Source Code Documentation
dict0mem.cc File Reference

Data dictionary memory object creation. More...

#include <atomic>
#include <mysql_com.h>
#include "ha_prototypes.h"
#include "data0type.h"
#include "dict0dd.h"
#include "dict0dict.h"
#include "dict0mem.h"
#include "fts0priv.h"
#include "mach0data.h"
#include "my_dbug.h"
#include "rem0rec.h"
#include "ut0crc32.h"
#include <iostream>
#include "sync0sync.h"

Functions

std::ostream & operator<< (std::ostream &s, const id_name_t &id_name)
 Display an identifier. More...
 
std::ostream & operator<< (std::ostream &s, const table_name_t &table_name)
 Display a table name. More...
 
dict_v_col_tdict_mem_table_add_v_col (dict_table_t *table, mem_heap_t *heap, const char *name, ulint mtype, ulint prtype, ulint len, ulint pos, ulint num_base, bool is_visible)
 Adds a virtual column definition to a table. More...
 
void dict_mem_table_add_s_col (dict_table_t *table, ulint num_base)
 Adds a stored column definition to a table. More...
 
static void dict_mem_table_col_rename_low (dict_table_t *table, unsigned i, const char *to, const char *s, bool is_virtual)
 Renames a column of a table in the data dictionary cache. More...
 
void dict_mem_table_col_rename (dict_table_t *table, ulint nth_col, const char *from, const char *to, bool is_virtual)
 Renames a column of a table in the data dictionary cache. More...
 
dict_foreign_tdict_mem_foreign_create (void)
 Creates and initializes a foreign constraint memory object. More...
 
void dict_mem_foreign_table_name_lookup_set (dict_foreign_t *foreign, bool do_alloc)
 Sets the foreign_table_name_lookup pointer based on the value of lower_case_table_names. More...
 
void dict_mem_referenced_table_name_lookup_set (dict_foreign_t *foreign, bool do_alloc)
 Sets the referenced_table_name_lookup pointer based on the value of lower_case_table_names. More...
 
static void dict_mem_fill_vcol_has_index (const dict_index_t *index, dict_vcol_set **v_cols)
 Fill the virtual column set with virtual column information present in the given virtual index. More...
 
static void dict_mem_fill_vcol_from_v_indexes (const char *col_name, const dict_table_t *table, dict_vcol_set **v_cols)
 Fill the virtual column set with virtual column of the index if the index contains the given column name. More...
 
static void dict_mem_fill_vcol_set_for_base_col (const char *col_name, const dict_table_t *table, dict_vcol_set **v_cols)
 Fill the virtual column set with virtual columns which have base columns as the given col_name. More...
 
void dict_mem_foreign_fill_vcol_set (dict_foreign_t *foreign)
 Fills the dependent virtual columns in a set. More...
 
void dict_mem_table_fill_foreign_vcol_set (dict_table_t *table)
 Fill virtual columns set in each fk constraint present in the table. More...
 
void dict_mem_table_free_foreign_vcol_set (dict_table_t *table)
 Free the vcol_set from all foreign key constraint on the table. More...
 
void dict_mem_index_free (dict_index_t *index)
 Frees an index memory object. More...
 
char * dict_mem_create_temporary_tablename (mem_heap_t *heap, const char *dbtab, table_id_t id)
 Create a temporary tablename like "#sql-ibtid-inc" where tid = the Table ID inc = a randomly initialized number that is incremented for each file The table ID is a 64 bit integer, can use up to 20 digits, and is initialized at bootstrap. More...
 
void dict_mem_init (void)
 Initialize dict memory variables. More...
 
bool dict_foreign_set_validate (const dict_foreign_set &fk_set)
 Validate the search order in the foreign key set. More...
 
bool dict_foreign_set_validate (const dict_table_t &table)
 Validate the search order in the foreign key sets of the table (foreign_set and referenced_set). More...
 
std::ostream & operator<< (std::ostream &out, const dict_foreign_t &foreign)
 
std::ostream & operator<< (std::ostream &out, const dict_foreign_set &fk_set)
 

Variables

static std::atomic< uint32_t > dict_temp_file_num
 An integer randomly initialized at startup used to make a temporary table name as unuique as possible. More...
 

Detailed Description

Data dictionary memory object creation.

Created 1/8/1996 Heikki Tuuri

Function Documentation

◆ dict_foreign_set_validate() [1/2]

bool dict_foreign_set_validate ( const dict_foreign_set fk_set)

Validate the search order in the foreign key set.

Parameters
[in]fk_setthe foreign key set to be validated
Returns
true if search order is fine in the set, false otherwise.

◆ dict_foreign_set_validate() [2/2]

bool dict_foreign_set_validate ( const dict_table_t table)

Validate the search order in the foreign key sets of the table (foreign_set and referenced_set).

Parameters
[in]tabletable whose foreign key sets are to be validated
Returns
true if foreign key sets are fine, false otherwise.

◆ dict_mem_create_temporary_tablename()

char * dict_mem_create_temporary_tablename ( mem_heap_t heap,
const char *  dbtab,
table_id_t  id 
)

Create a temporary tablename like "#sql-ibtid-inc" where tid = the Table ID inc = a randomly initialized number that is incremented for each file The table ID is a 64 bit integer, can use up to 20 digits, and is initialized at bootstrap.

The second number is 32 bits, can use up to 10 digits, and is initialized at startup to a randomly distributed number. It is hoped that the combination of these two numbers will provide a reasonably unique temporary file name.

Parameters
[in]heapA memory heap
[in]dbtabTable name in the form database/table name
[in]idTable id
Returns
A unique temporary tablename suitable for InnoDB use

◆ dict_mem_fill_vcol_from_v_indexes()

static void dict_mem_fill_vcol_from_v_indexes ( const char *  col_name,
const dict_table_t table,
dict_vcol_set **  v_cols 
)
static

Fill the virtual column set with virtual column of the index if the index contains the given column name.

Parameters
[in]col_namecolumn name
[in]tableinnodb table object
[out]v_colsset of virtual column information.

◆ dict_mem_fill_vcol_has_index()

static void dict_mem_fill_vcol_has_index ( const dict_index_t index,
dict_vcol_set **  v_cols 
)
static

Fill the virtual column set with virtual column information present in the given virtual index.

Parameters
[in]indexvirtual index
[out]v_colsvirtual column set.

◆ dict_mem_fill_vcol_set_for_base_col()

static void dict_mem_fill_vcol_set_for_base_col ( const char *  col_name,
const dict_table_t table,
dict_vcol_set **  v_cols 
)
static

Fill the virtual column set with virtual columns which have base columns as the given col_name.

Parameters
[in]col_namecolumn name
[in]tabletable object
[out]v_colsset of virtual columns.

◆ dict_mem_foreign_create()

dict_foreign_t * dict_mem_foreign_create ( void  )

Creates and initializes a foreign constraint memory object.

Returns
own: foreign constraint struct

◆ dict_mem_foreign_fill_vcol_set()

void dict_mem_foreign_fill_vcol_set ( dict_foreign_t foreign)

Fills the dependent virtual columns in a set.

Reason for being dependent are 1) FK can be present on base column of virtual columns 2) FK can be present on column which is a part of virtual index

Parameters
[in,out]foreignforeign key information.

FK can be present on base columns of virtual columns.

FK can be present on the columns which can be a part of virtual index.

◆ dict_mem_foreign_table_name_lookup_set()

void dict_mem_foreign_table_name_lookup_set ( dict_foreign_t foreign,
bool  do_alloc 
)

Sets the foreign_table_name_lookup pointer based on the value of lower_case_table_names.

If that is 0 or 1, foreign_table_name_lookup will point to foreign_table_name. If 2, then another string is allocated from foreign->heap and set to lower case.

Parameters
foreignin/out: foreign struct
do_allocin: is an alloc needed

◆ dict_mem_index_free()

void dict_mem_index_free ( dict_index_t index)

Frees an index memory object.

in: index

Parameters
indexin: index

◆ dict_mem_init()

void dict_mem_init ( void  )

Initialize dict memory variables.

◆ dict_mem_referenced_table_name_lookup_set()

void dict_mem_referenced_table_name_lookup_set ( dict_foreign_t foreign,
bool  do_alloc 
)

Sets the referenced_table_name_lookup pointer based on the value of lower_case_table_names.

If that is 0 or 1, referenced_table_name_lookup will point to referenced_table_name. If 2, then another string is allocated from foreign->heap and set to lower case.

Parameters
foreignin/out: foreign struct
do_allocin: is an alloc needed

◆ dict_mem_table_add_s_col()

void dict_mem_table_add_s_col ( dict_table_t table,
ulint  num_base 
)

Adds a stored column definition to a table.

Parameters
[in,out]tabletable
[in]num_basenumber of base columns.

◆ dict_mem_table_add_v_col()

dict_v_col_t * dict_mem_table_add_v_col ( dict_table_t table,
mem_heap_t heap,
const char *  name,
ulint  mtype,
ulint  prtype,
ulint  len,
ulint  pos,
ulint  num_base,
bool  is_visible 
)

Adds a virtual column definition to a table.

Parameters
[in,out]tabletable
[in]heaptemporary memory heap, or NULL. It is used to store name when we have not finished adding all columns. When all columns are added, the whole name will copy to memory from table->heap
[in]namecolumn name
[in]mtypemain datatype
[in]prtypeprecise type
[in]lenlength
[in]posposition in a table
[in]num_basenumber of base columns
[in]is_visibleTrue if virtual column is visible to user
Returns
the virtual column definition

◆ dict_mem_table_col_rename()

void dict_mem_table_col_rename ( dict_table_t table,
ulint  nth_col,
const char *  from,
const char *  to,
bool  is_virtual 
)

Renames a column of a table in the data dictionary cache.

Parameters
[in,out]tableTable
[in]nth_colColumn index
[in]fromOld column name
[in]toNew column name
[in]is_virtualIf this is a virtual column

◆ dict_mem_table_col_rename_low()

static void dict_mem_table_col_rename_low ( dict_table_t table,
unsigned  i,
const char *  to,
const char *  s,
bool  is_virtual 
)
static

Renames a column of a table in the data dictionary cache.

Parameters
tablein/out: table
iin: column offset corresponding to s
toin: new column name
sin: pointer to table->col_names
is_virtualin: if this is a virtual column

◆ dict_mem_table_fill_foreign_vcol_set()

void dict_mem_table_fill_foreign_vcol_set ( dict_table_t table)

Fill virtual columns set in each fk constraint present in the table.

Parameters
[in,out]tableinnodb table object.

◆ dict_mem_table_free_foreign_vcol_set()

void dict_mem_table_free_foreign_vcol_set ( dict_table_t table)

Free the vcol_set from all foreign key constraint on the table.

Parameters
[in,out]tableinnodb table object.

◆ operator<<() [1/4]

std::ostream & operator<< ( std::ostream &  out,
const dict_foreign_set fk_set 
)

◆ operator<<() [2/4]

std::ostream & operator<< ( std::ostream &  out,
const dict_foreign_t foreign 
)

◆ operator<<() [3/4]

std::ostream & operator<< ( std::ostream &  s,
const id_name_t id_name 
)

Display an identifier.

Parameters
[in,out]soutput stream
[in]id_nameSQL identifier (other than table name)
Returns
the output stream

◆ operator<<() [4/4]

std::ostream & operator<< ( std::ostream &  s,
const table_name_t table_name 
)

Display a table name.

Parameters
[in,out]soutput stream
[in]table_nametable name
Returns
the output stream

Variable Documentation

◆ dict_temp_file_num

std::atomic<uint32_t> dict_temp_file_num
static

An integer randomly initialized at startup used to make a temporary table name as unuique as possible.