MySQL 8.0.39
Source Code Documentation
|
Create_field is a description a field/column that may or may not exists in a table. More...
#include <create_field.h>
Public Member Functions | |
size_t | max_display_width_in_codepoints () const |
size_t | max_display_width_in_bytes () const |
size_t | pack_length (bool dont_override=false) const |
size_t | key_length () const |
bool | explicit_display_width () const |
void | set_max_display_width_from_create_field (const Create_field &create_field) |
Set the maximum display width based on another Create_field. More... | |
Create_field () | |
Create_field (Field *field, Field *orig_field) | |
Constructs a column definition from an object representing an actual column. More... | |
Create_field * | clone (MEM_ROOT *mem_root) const |
bool | is_gcol () const |
bool | is_virtual_gcol () const |
void | init_for_tmp_table (enum_field_types sql_type_arg, uint32 max_length, uint32 decimals, bool is_nullable, bool is_unsigned, uint pack_length_override, const char *field_name="") |
Init for a tmp table field. More... | |
bool | init (THD *thd, const char *field_name, enum_field_types type, const char *length, const char *decimals, uint type_modifier, Item *default_value, Item *on_update_value, const LEX_CSTRING *comment, const char *change, List< String > *interval_list, const CHARSET_INFO *cs, bool has_explicit_collation, uint uint_geom_type, Value_generator *gcol_info, Value_generator *default_val_expr, std::optional< gis::srid_t > srid, dd::Column::enum_hidden_type hidden, bool is_array=false) |
Initialize a column definition object. More... | |
ha_storage_media | field_storage_type () const |
column_format_type | column_format () const |
Public Attributes | |
dd::Column::enum_hidden_type | hidden |
const char * | field_name |
const char * | change |
Name of column modified by ALTER TABLE's CHANGE/MODIFY COLUMN clauses, NULL for columns added. More... | |
const char * | after {nullptr} |
LEX_CSTRING | comment |
Item * | constant_default |
The declared default value, if any, otherwise NULL. More... | |
enum_field_types | sql_type |
uint | decimals |
uint | flags {0} |
uchar | auto_flags {Field::NONE} |
Bitmap of flags indicating if field value should be auto-generated by default and/or on update, and in which way. More... | |
TYPELIB * | interval |
List< String > | interval_list |
const CHARSET_INFO * | charset |
bool | is_explicit_collation |
Field::geometry_type | geom_type |
Field * | field |
uint | offset |
bool | is_nullable |
Indicate whether column is nullable, zerofill or unsigned. More... | |
bool | is_zerofill |
bool | is_unsigned |
bool | treat_bit_as_char |
Indicates that storage engine doesn't support optimized BIT field storage. More... | |
uint | pack_length_override {0} |
Row based replication code sometimes needs to create ENUM and SET fields with pack length which doesn't correspond to number of elements in interval TYPELIB. More... | |
Value_generator * | gcol_info {nullptr} |
bool | stored_in_db |
Value_generator * | m_default_val_expr {nullptr} |
Holds the expression to be used to generate default values. More... | |
std::optional< gis::srid_t > | m_srid |
bool | is_array {false} |
LEX_CSTRING | m_engine_attribute = EMPTY_CSTR |
LEX_CSTRING | m_secondary_engine_attribute = EMPTY_CSTR |
Private Attributes | |
size_t | m_max_display_width_in_codepoints {0} |
The maximum display width of this column. More... | |
bool | m_explicit_display_width {false} |
Whether or not the display width was given explicitly by the user. More... | |
Create_field is a description a field/column that may or may not exists in a table.
The main usage of Create_field is to contain the description of a column given by the user (usually given with CREATE TABLE). It is also used to describe changes to be carried out on a column (usually given with ALTER TABLE ... CHANGE COLUMN).
|
inline |
Constructs a column definition from an object representing an actual column.
This is a reverse-engineering procedure that creates a column definition object as produced by the parser (Create_field) from a resolved column object (Field).
old_field | The column object from which the column definition is constructed. |
orig_field | Used for copying default values. This parameter may be NULL, but if present it is used for copying default values. |
Default values are copied into an Item_string unless:
|
inline |
|
inline |
|
inline |
true | if the maximum column length was given explicitly by the user. |
false | if the user didn't specify any maximum length. |
|
inline |
bool Create_field::init | ( | THD * | thd, |
const char * | fld_name, | ||
enum_field_types | fld_type, | ||
const char * | display_width_in_codepoints, | ||
const char * | fld_decimals, | ||
uint | fld_type_modifier, | ||
Item * | fld_default_value, | ||
Item * | fld_on_update_value, | ||
const LEX_CSTRING * | fld_comment, | ||
const char * | fld_change, | ||
List< String > * | fld_interval_list, | ||
const CHARSET_INFO * | fld_charset, | ||
bool | has_explicit_collation, | ||
uint | fld_geom_type, | ||
Value_generator * | fld_gcol_info, | ||
Value_generator * | fld_default_val_expr, | ||
std::optional< gis::srid_t > | srid, | ||
dd::Column::enum_hidden_type | hidden, | ||
bool | is_array_arg = false |
||
) |
Initialize a column definition object.
Column definition objects can be used to construct Field objects.
thd | Session/Thread handle. |
fld_name | Column name. |
fld_type | Column type. |
display_width_in_codepoints | The column display width, counted in number of code points. |
fld_decimals | Number of digits to the right of the decimal point (if any.) |
fld_type_modifier | Additional type information. |
fld_default_value | Column default constant or datetime expression (if any.) |
fld_on_update_value | The expression in the ON UPDATE clause. |
fld_comment | Column comment. |
fld_change | Column change. |
fld_interval_list | Interval list (if any.) |
fld_charset | Column charset. |
has_explicit_collation | Column has an explicit COLLATE attribute. |
fld_geom_type | Column geometry type (if any.) |
fld_gcol_info | Generated column data |
fld_default_val_expr | The expression for generating default values |
srid | The SRID specification. This might be null (has_value() may return false). |
hidden | Whether this column should be hidden or not. |
is_array_arg | Whether the field is a typed array |
false | on success. |
true | on error. |
void Create_field::init_for_tmp_table | ( | enum_field_types | sql_type_arg, |
uint32 | length_arg, | ||
uint32 | decimals_arg, | ||
bool | is_nullable_arg, | ||
bool | is_unsigned_arg, | ||
uint | pack_length_override_arg, | ||
const char * | fld_name = "" |
||
) |
Init for a tmp table field.
To be extended if need be.
|
inline |
|
inline |
size_t Create_field::key_length | ( | ) | const |
size_t Create_field::max_display_width_in_bytes | ( | ) | const |
size_t Create_field::max_display_width_in_codepoints | ( | ) | const |
size_t Create_field::pack_length | ( | bool | dont_override = false | ) | const |
dont_override | Don't use pack_length_override even if non-zero Used by multi-valued index, where pack_length and key_length aren't the same. |
|
inline |
Set the maximum display width based on another Create_field.
const char* Create_field::after {nullptr} |
uchar Create_field::auto_flags {Field::NONE} |
Bitmap of flags indicating if field value should be auto-generated by default and/or on update, and in which way.
const char* Create_field::change |
Name of column modified by ALTER TABLE's CHANGE/MODIFY COLUMN clauses, NULL for columns added.
const CHARSET_INFO* Create_field::charset |
LEX_CSTRING Create_field::comment |
Item* Create_field::constant_default |
The declared default value, if any, otherwise NULL.
Note that this member is NULL if the default is a function. If the column definition has a function declared as the default, the information is found in Create_field::auto_flags.
uint Create_field::decimals |
Field* Create_field::field |
const char* Create_field::field_name |
uint Create_field::flags {0} |
Value_generator* Create_field::gcol_info {nullptr} |
Field::geometry_type Create_field::geom_type |
dd::Column::enum_hidden_type Create_field::hidden |
TYPELIB* Create_field::interval |
bool Create_field::is_array {false} |
bool Create_field::is_explicit_collation |
bool Create_field::is_nullable |
Indicate whether column is nullable, zerofill or unsigned.
Initialized based on flags and other members at prepare_create_field()/ init_for_tmp_table() stage.
bool Create_field::is_unsigned |
bool Create_field::is_zerofill |
Value_generator* Create_field::m_default_val_expr {nullptr} |
Holds the expression to be used to generate default values.
LEX_CSTRING Create_field::m_engine_attribute = EMPTY_CSTR |
|
private |
Whether or not the display width was given explicitly by the user.
|
private |
The maximum display width of this column.
The "display width" is the number of code points that is needed to print out the string representation of a value. It can be given by the user both explicitly and implicitly. If a user creates a table with the columns "a VARCHAR(3), b INT(3)", both columns are given an explicit display width of 3 code points. But if a user creates a table with the columns "a INT, b TINYINT UNSIGNED", the first column has an implicit display width of 11 (-2147483648 is the longest value for a signed int) and the second column has an implicit display width of 3 (255 is the longest value for an unsigned tinyint). This is related to storage size for some types (VARCHAR, BLOB etc), but not for all types (an INT is four bytes regardless of the display width).
A "code point" is basically a numeric value. For instance, ASCII compromises of 128 code points (0x00 to 0x7F), while unicode contains way more. In most cases a code point represents a single graphical unit (aka grapheme), but not always. For instance, É may consists of two code points where one is the letter E and the other one is the quotation mark above the letter.
LEX_CSTRING Create_field::m_secondary_engine_attribute = EMPTY_CSTR |
std::optional<gis::srid_t> Create_field::m_srid |
uint Create_field::offset |
uint Create_field::pack_length_override {0} |
Row based replication code sometimes needs to create ENUM and SET fields with pack length which doesn't correspond to number of elements in interval TYPELIB.
When this member is non-zero ENUM/SET field to be created will use its value as pack length instead of one calculated from number elements in its interval.
Initialized at prepare_create_field()/init_for_tmp_table() stage.
enum_field_types Create_field::sql_type |
bool Create_field::stored_in_db |
bool Create_field::treat_bit_as_char |
Indicates that storage engine doesn't support optimized BIT field storage.
Initialized at mysql_prepare_create_table()/sp_prepare_create_field()/ init_for_tmp_table() stage.