MySQL 9.1.0
Source Code Documentation
Bulk_data_convert Namespace Reference

Classes

class  Row_header
 

Functions

static void log_conversion_error (const Column_text &text_col, std::string mesg)
 Log details of error during data conversion. More...
 
template<typename S , typename U >
static int format_int_column (const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, bool write_in_buffer, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create an integer column converting data from CSV text. More...
 
static int format_blob_column (Field *field, const CHARSET_INFO *from_cs, const Column_text &text_col, Column_mysql &sql_col, size_t &length_size, Bulk_load_error_location_details &error_details)
 Create a blob column. More...
 
static int format_char_column (const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, bool write_length, const Column_meta &col_meta, bool single_byte, Column_mysql &sql_col, size_t &length_size, Bulk_load_error_location_details &error_details)
 Create a char/varchar column converting data to MySQL storage format. More...
 
static int format_float_column (const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a FLOAT column converting data to MySQL storage format. More...
 
static int format_double_column (const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a DOUBLE column converting data to MySQL storage format. More...
 
static int format_decimal_column (const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a DECIMAL column converting data to MySQL storage format. More...
 
int format_datetime_column (THD *thd, const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a DATETIME column converting data to MySQL storage format. More...
 
int format_date_column (THD *thd, const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a DATE column converting data to MySQL storage format. More...
 
static int format_time_column (THD *thd, const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a TIME column converting data to MySQL storage format. More...
 
static int format_timestamp_column (THD *thd, const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a TIMESTAMP column converting data to MySQL storage format. More...
 
static int format_year_column (const Column_text &text_col, const CHARSET_INFO *charset, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a YEAR column converting data to MySQL storage format. More...
 
static int format_bit_column (const Column_text &text_col, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a BIT column converting data to MySQL storage format. More...
 
static int format_enum_column (const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a ENUM column converting data to MySQL storage format. More...
 
static int format_set_column (const Column_text &text_col, const CHARSET_INFO *charset, const Field *field, Column_mysql &sql_col, Bulk_load_error_location_details &error_details)
 Create a SET column converting data to MySQL storage format. More...
 
static int format_row (THD *thd, const TABLE_SHARE *table_share, const Rows_text &text_rows, size_t text_row_index, char *&buffer, size_t &buffer_length, const CHARSET_INFO *charset, const Row_meta &metadata, Rows_mysql &sql_rows, size_t sql_row_index, bool single_byte_char, bool &completed, Bulk_load_error_location_details &error_details)
 Create a row in converting column data to MySQL storage format. More...
 
static int fill_column_data (char *buffer, size_t buffer_length, const Column_meta &col_meta, const Row_header &header, bool marked_fixed, size_t &col_length, Column_mysql &sql_col)
 Fill data in column from raw format. More...
 
static int fill_row_data (char *buffer, size_t buffer_length, bool fill_keys, const Row_meta &metadata, Row_header &header, Rows_mysql &sql_rows, size_t row_num, size_t &row_length)
 Fill data in row from raw format. More...
 
int mysql_format_using_key (const Row_meta &metadata, const Rows_mysql &sql_keys, size_t key_offset, Rows_mysql &sql_rows, size_t sql_index) noexcept
 
int mysql_format_from_raw (char *buffer, size_t buffer_length, const Row_meta &metadata, size_t start_index, size_t &consumed_length, Rows_mysql &sql_rows) noexcept
 
int mysql_format (THD *thd, const TABLE *table, const Rows_text &text_rows, size_t &next_index, char *buffer, size_t &buffer_length, const CHARSET_INFO *charset, const Row_meta &metadata, Rows_mysql &sql_rows, Bulk_load_error_location_details &error_details) noexcept
 
bool is_killed (THD *thd) noexcept
 
int compare_keys (const Column_mysql &key1, const Column_mysql &key2, const Column_meta &col_meta) noexcept
 
static void set_data_type (const Field *field, Column_meta &col_meta)
 Fill column metadata type related information from mysql field structure. More...
 
static void fill_column_metadata (const Field *field, Column_meta &col_meta)
 Fill column metadata from mysql field structure. More...
 
bool get_row_metadata (THD *, const TABLE *table, bool have_key, Row_meta &metadata) noexcept
 

Function Documentation

◆ compare_keys()

int Bulk_data_convert::compare_keys ( const Column_mysql key1,
const Column_mysql key2,
const Column_meta col_meta 
)
noexcept

◆ fill_column_data()

static int Bulk_data_convert::fill_column_data ( char *  buffer,
size_t  buffer_length,
const Column_meta col_meta,
const Row_header header,
bool  marked_fixed,
size_t &  col_length,
Column_mysql sql_col 
)
static

Fill data in column from raw format.

Parameters
[in,out]bufferinput raw data buffer
[in]buffer_lengthbuffer length
[in]col_metacolumn metadata
[in]headerrow header
[in]marked_fixedif the row is marked as fixed length
[out]col_lengthcolumn length
[out]sql_colcolumn data
Returns
error code.

◆ fill_column_metadata()

static void Bulk_data_convert::fill_column_metadata ( const Field field,
Column_meta col_meta 
)
static

Fill column metadata from mysql field structure.

Parameters
[in]fieldMySQL field from TABLE
[out]col_metacolumn metadata object to fill

◆ fill_row_data()

static int Bulk_data_convert::fill_row_data ( char *  buffer,
size_t  buffer_length,
bool  fill_keys,
const Row_meta metadata,
Row_header header,
Rows_mysql sql_rows,
size_t  row_num,
size_t &  row_length 
)
static

Fill data in row from raw format.

Parameters
[in,out]bufferinput raw data buffer
[in]buffer_lengthbuffer length
[in]fill_keystrue if keys to be filled otherwise the entire row
[in]metadatarow metadata
[in,out]headerrow header
[in,out]sql_rowsrow bunch to fill data
[in]row_numindex of the row within row bunch
[out]row_lengthrow length
Returns
error code.

◆ format_bit_column()

static int Bulk_data_convert::format_bit_column ( const Column_text text_col,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)
static

Create a BIT column converting data to MySQL storage format.

Parameters
[in]text_colinput column in text read from CSV
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ format_blob_column()

static int Bulk_data_convert::format_blob_column ( Field field,
const CHARSET_INFO from_cs,
const Column_text text_col,
Column_mysql sql_col,
size_t &  length_size,
Bulk_load_error_location_details error_details 
)
static

Create a blob column.

Parameters
[in]fieldtable column metadata
[in]from_cscharset of the input string from CSV.
[in]text_colinput column in text read from CSV.
[out]sql_colconverted column in MySQL storage format
[out]length_sizenumber of bytes used to write the length
[out]error_detailserror location details
Returns
0 on success, error code on failure.

◆ format_char_column()

static int Bulk_data_convert::format_char_column ( const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
bool  write_length,
const Column_meta col_meta,
bool  single_byte,
Column_mysql sql_col,
size_t &  length_size,
Bulk_load_error_location_details error_details 
)
static

Create a char/varchar column converting data to MySQL storage format.

Parameters
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[in]write_lengthwrite length of column data if variable length
[in]col_metacolumn metadata
[in]single_byteif true, allocation is done assuming single byte return ER_TOO_BIG_FIELDLENGTH if not enough
[out]sql_colconverted column in MySQL storage format
[out]length_sizenumber of bytes used to write the length
[out]error_detailserror location details
Returns
error code.

◆ format_date_column()

int Bulk_data_convert::format_date_column ( THD thd,
const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)

Create a DATE column converting data to MySQL storage format.

Parameters
[in]thdsession THD
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[out]sql_colconverted column in MySQL storage format
[out]error_detailserror location details
Returns
error code.

◆ format_datetime_column()

int Bulk_data_convert::format_datetime_column ( THD thd,
const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)

Create a DATETIME column converting data to MySQL storage format.

Parameters
[in]thdsession THD
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ format_decimal_column()

static int Bulk_data_convert::format_decimal_column ( const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)
static

Create a DECIMAL column converting data to MySQL storage format.

Parameters
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ format_double_column()

static int Bulk_data_convert::format_double_column ( const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)
static

Create a DOUBLE column converting data to MySQL storage format.

Parameters
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ format_enum_column()

static int Bulk_data_convert::format_enum_column ( const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)
static

Create a ENUM column converting data to MySQL storage format.

Parameters
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ format_float_column()

static int Bulk_data_convert::format_float_column ( const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)
static

Create a FLOAT column converting data to MySQL storage format.

Parameters
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ format_int_column()

template<typename S , typename U >
static int Bulk_data_convert::format_int_column ( const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
bool  write_in_buffer,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)
static

Create an integer column converting data from CSV text.

Parameters
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[in]write_in_bufferwrite integer data in column buffer
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ format_row()

static int Bulk_data_convert::format_row ( THD thd,
const TABLE_SHARE table_share,
const Rows_text text_rows,
size_t  text_row_index,
char *&  buffer,
size_t &  buffer_length,
const CHARSET_INFO charset,
const Row_meta metadata,
Rows_mysql sql_rows,
size_t  sql_row_index,
bool  single_byte_char,
bool &  completed,
Bulk_load_error_location_details error_details 
)
static

Create a row in converting column data to MySQL storage format.

Parameters
[in]thdsession THD
[in]table_shareshared table object
[in]text_rowsinput rows with columns in text read from CSV
[in]text_row_indexcurrent text row index
[in]bufferbuffer to write to
[in]buffer_lengthbuffer length
[in]charsetcharacter set for the input row data
[in]metadatarow metadata
[out]sql_rowsconverted row in MySQL storage format
[in]sql_row_indexcurrent sql row index
[in]single_byte_charassume single byte char length is enough
[out]completedif all rows are processed
[out]error_detailsthe error details
Returns
error code.

◆ format_set_column()

static int Bulk_data_convert::format_set_column ( const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)
static

Create a SET column converting data to MySQL storage format.

Parameters
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ format_time_column()

static int Bulk_data_convert::format_time_column ( THD thd,
const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)
static

Create a TIME column converting data to MySQL storage format.

Parameters
[in]thdsession THD
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ format_timestamp_column()

static int Bulk_data_convert::format_timestamp_column ( THD thd,
const Column_text text_col,
const CHARSET_INFO charset,
const Field field,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)
static

Create a TIMESTAMP column converting data to MySQL storage format.

Parameters
[in]thdsession THD
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[in]fieldtable column metadata
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ format_year_column()

static int Bulk_data_convert::format_year_column ( const Column_text text_col,
const CHARSET_INFO charset,
Column_mysql sql_col,
Bulk_load_error_location_details error_details 
)
static

Create a YEAR column converting data to MySQL storage format.

Parameters
[in]text_colinput column in text read from CSV
[in]charsetcharacter set for the input column data
[out]sql_colconverted column in MySQL storage format
[out]error_detailsthe error details
Returns
error code.

◆ get_row_metadata()

bool Bulk_data_convert::get_row_metadata ( THD ,
const TABLE table,
bool  have_key,
Row_meta metadata 
)
noexcept

◆ is_killed()

bool Bulk_data_convert::is_killed ( THD thd)
noexcept

◆ log_conversion_error()

static void Bulk_data_convert::log_conversion_error ( const Column_text text_col,
std::string  mesg 
)
static

Log details of error during data conversion.

Parameters
[in]text_colinput column from CSV file
[in]mesgerror message to append to

◆ mysql_format()

int Bulk_data_convert::mysql_format ( THD thd,
const TABLE table,
const Rows_text text_rows,
size_t &  next_index,
char *  buffer,
size_t &  buffer_length,
const CHARSET_INFO charset,
const Row_meta metadata,
Rows_mysql sql_rows,
Bulk_load_error_location_details error_details 
)
noexcept

◆ mysql_format_from_raw()

int Bulk_data_convert::mysql_format_from_raw ( char *  buffer,
size_t  buffer_length,
const Row_meta metadata,
size_t  start_index,
size_t &  consumed_length,
Rows_mysql sql_rows 
)
noexcept

◆ mysql_format_using_key()

int Bulk_data_convert::mysql_format_using_key ( const Row_meta metadata,
const Rows_mysql sql_keys,
size_t  key_offset,
Rows_mysql sql_rows,
size_t  sql_index 
)
noexcept

◆ set_data_type()

static void Bulk_data_convert::set_data_type ( const Field field,
Column_meta col_meta 
)
static

Fill column metadata type related information from mysql field structure.

Parameters
[in]fieldMySQL field from TABLE
[out]col_metacolumn metadata object to fill