MySQL  8.0.27
Source Code Documentation
default_values.h File Reference
#include <stddef.h>
#include "my_inttypes.h"

Go to the source code of this file.

Namespaces

 dd
 The version of the current data dictionary table definitions.
 

Functions

size_t max_pack_length (const List< Create_field > &create_fields)
 Find the largest field among a list of create fields. More...
 
bool prepare_default_value (THD *thd, uchar *buf, TABLE *table, const Create_field &field, dd::Column *col_obj)
 Prepare the default value of a single column. More...
 
bool prepare_default_value_buffer_and_table_share (THD *thd, const dd::Table &table, TABLE_SHARE *share)
 Prepare the default value buffer for an empty record. More...
 

Function Documentation

◆ max_pack_length()

size_t max_pack_length ( const List< Create_field > &  create_fields)

Find the largest field among a list of create fields.

Iterates over the list of create fields and find the largest one, i.e. the field with largest pack length.

Parameters
create_fieldsList of create fields.
Returns
Size of the largest field, as number of bytes.

◆ prepare_default_value()

bool prepare_default_value ( THD thd,
uchar buf,
TABLE table,
const Create_field field,
dd::Column col_obj 
)

Prepare the default value of a single column.

This function creates a fake field using the submitted fake table object, which also has assigned a fake table share. The field is create in order to use existing code to store the default value. The value is stored into the submitted buffer, which has been allocated in advance (and will be deleted afterwards). The fake table and share are required by the field infrastructure.

After storing the default value into the buffer, the value is read back and copied into the column object's default value field. For bit fields with leftover bits in the preamble, these bits are copied and appended onto the default value as the last byte.

Parameters
thdThread context.
bufBuffer to store the default value into. The buffer size must be at least two bytes.
tableFake table to use when storing the default value.
fieldCreate_field corresponding to the column object.
[in,out]col_objColumn for which to prepare the default value.
Return values
trueFailure.
falseSuccess.

◆ prepare_default_value_buffer_and_table_share()

bool prepare_default_value_buffer_and_table_share ( THD thd,
const dd::Table table,
TABLE_SHARE share 
)

Prepare the default value buffer for an empty record.

This function prepares the buffer based on the objects retrieved from the data dictionary. The function will scan the columns of the submitted table objects and calculate the length of the record, the number of null bits, etc. The empty buffer is allocated, and all bits are set to 0, including used null bits, the actual field values, etc. Afterwards, the unused bits in the preamble, up to the next full byte border, are set to 1. Finally, the buffer is assigned to the 'TABLE_SHARE::default_values' field.

Note
This function does not fill in the actual default values, it just allocates and prepares the buffer.
Parameters
thdThread context.
tableTable for which the default value buffer should be prepared.
[in,out]shareTable share for the table. The default value buffer is assigned to the appropriate table share field.
Return values
trueFailure.
falseSuccess.