MySQL 26.10.0
Source Code Documentation
sql_load.cc File Reference
#include "sql/sql_load.h"
#include "my_sqlcommand.h"
#include "sql/mysqld_cs.h"
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <algorithm>
#include <atomic>
#include <limits>
#include <memory>
#include <sstream>
#include <string>
#include "my_base.h"
#include "my_bitmap.h"
#include "my_dbug.h"
#include "my_dir.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_macros.h"
#include "my_sys.h"
#include "my_thread_local.h"
#include "mysql/binlog/event/load_data_events.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/my_loglevel.h"
#include "mysql/psi/mysql_file.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql/strings/m_ctype.h"
#include "mysql/thread_type.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "nulls.h"
#include "scope_guard.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/binlog.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/dd/dd_table.h"
#include "sql/dd/types/abstract_table.h"
#include "sql/dd/types/schema.h"
#include "sql/debug_sync.h"
#include "sql/derror.h"
#include "sql/error_handler.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/item.h"
#include "sql/item_func.h"
#include "sql/item_timefunc.h"
#include "sql/log.h"
#include "sql/log_event.h"
#include "sql/mysqld.h"
#include "sql/protocol.h"
#include "sql/protocol_classic.h"
#include "sql/psi_memory_key.h"
#include "sql/query_result.h"
#include "sql/rpl_replica.h"
#include "sql/rpl_rli.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_data_change.h"
#include "sql/sql_error.h"
#include "sql/sql_exchange.h"
#include "sql/sql_foreign_key_constraint.h"
#include "sql/sql_insert.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_show.h"
#include "sql/sql_table.h"
#include "sql/sql_view.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/table_trigger_dispatcher.h"
#include "sql/thd_raii.h"
#include "sql/thr_malloc.h"
#include "sql/transaction.h"
#include "sql/transaction_info.h"
#include "sql/trigger_def.h"
#include "sql_string.h"
#include "string_with_len.h"
#include "strxnmov.h"
#include "thr_lock.h"
#include <mysql/components/services/bulk_load_service.h>

Classes

class  Load_data_tmp_null_guard
 
class  XML_TAG
 
class  READ_INFO
 

Namespaces

namespace  anonymous_namespace{sql_load.cc}
 

Macros

#define GET   (stack_pos != stack ? *--stack_pos : my_b_get(&cache))
 
#define PUSH(A)   *(stack_pos++) = (A)
 
#define GET_MBCHARLEN(cs, chr, len)
 The logic here is similar with my_mbcharlen, except for GET and PUSH. More...
 

Functions

static bool lock_and_check_bulk_load_backup_name (THD *thd, const std::string &schema_name, const std::string &table_name, const std::string &backup_name)
 Lock a generated backup table name and verify that it is not already in use. More...
 
static bool rename_table_for_bulk_load (THD *thd, handlerton *hton, const dd::Schema &schema, const std::string &schema_name, const std::string &table_name, const std::string &from_name, const std::string &from_fk_name, const std::string &to_name)
 Rename a table as part of an atomic copy-style bulk load replacement. More...
 
static bool replace_table_for_bulk_load (THD *thd, handlerton *hton, Table_ref *table_ref, const std::string &schema_name, const std::string &original_name, const std::string &loaded_table_name, const std::string &backup_name)
 
bool anonymous_namespace{sql_load.cc}::is_hidden_generated_column (TABLE *table, Item *item)
 Checks if an item is a hidden generated column. More...
 
static int my_xml_entity_to_char (const char *name, size_t length)
 
static int my_tospace (int chr)
 Convert newline, linefeed, tab to space. More...
 
static bool is_whitespace (const std::string &s)
 Check if the given string is made up of whitespace characters only. More...
 

Macro Definition Documentation

◆ GET

#define GET   (stack_pos != stack ? *--stack_pos : my_b_get(&cache))

◆ GET_MBCHARLEN

#define GET_MBCHARLEN (   cs,
  chr,
  len 
)
Value:
do { \
len = my_mbcharlen((cs), (chr)); \
if (len == 0 && my_mbmaxlenlen((cs)) == 2) { \
const int chr1 = GET; \
if (chr1 != my_b_EOF) { \
len = my_mbcharlen_2((cs), (chr), chr1); \
/* Character is gb18030 or invalid (len = 0) */ \
assert(len == 0 || len == 2 || len == 4); \
} \
if (len != 0) PUSH(chr1); \
} \
} while (0)
constexpr int my_b_EOF
Definition: my_sys.h:525
unsigned my_mbcharlen_2(const CHARSET_INFO *cs, uint8_t first_byte, uint8_t second_byte)
Get the length of gb18030 code by the given two leading bytes.
Definition: m_ctype.h:696
unsigned my_mbcharlen(const CHARSET_INFO *cs, unsigned first_byte)
Definition: m_ctype.h:682
unsigned my_mbmaxlenlen(const CHARSET_INFO *cs)
Get the maximum length of leading bytes needed to determine the length of a multi-byte gb18030 code.
Definition: m_ctype.h:710
Definition: applier_version.h:27
#define GET
Definition: sql_load.cc:362
#define PUSH(A)
Definition: sql_load.cc:363

The logic here is similar with my_mbcharlen, except for GET and PUSH.

Parameters
[in]cscharset info
[in]chrthe first char of sequence
[out]lenthe length of multi-byte char

◆ PUSH

#define PUSH (   A)    *(stack_pos++) = (A)

Function Documentation

◆ is_whitespace()

static bool is_whitespace ( const std::string &  s)
inlinestatic

Check if the given string is made up of whitespace characters only.

Parameters
[in]sthe input string to be checked
Returns
true iff s is made up of whitespace characters

◆ lock_and_check_bulk_load_backup_name()

static bool lock_and_check_bulk_load_backup_name ( THD *  thd,
const std::string &  schema_name,
const std::string &  table_name,
const std::string &  backup_name 
)
static

Lock a generated backup table name and verify that it is not already in use.

Parameters
thdThread context.
schema_nameSchema containing the table.
table_nameOriginal table name, used for error reporting.
backup_nameGenerated name for the backup table.
Return values
falseSuccess.
trueError.

◆ my_tospace()

static int my_tospace ( int  chr)
static

Convert newline, linefeed, tab to space.

Parameters
chrcharacter

According to the "XML 1.0" standard, only space (#x20) characters, carriage returns, line feeds or tabs are considered as spaces. Convert all of them to space (#x20) for parsing simplicity.

◆ my_xml_entity_to_char()

static int my_xml_entity_to_char ( const char *  name,
size_t  length 
)
static

◆ rename_table_for_bulk_load()

static bool rename_table_for_bulk_load ( THD *  thd,
handlerton *  hton,
const dd::Schema &  schema,
const std::string &  schema_name,
const std::string &  table_name,
const std::string &  from_name,
const std::string &  from_fk_name,
const std::string &  to_name 
)
static

Rename a table as part of an atomic copy-style bulk load replacement.

The rename does not commit data dictionary changes or rename generated foreign key names.

Parameters
thdThread context.
htonTable storage engine handlerton.
schemaData dictionary object for the table schema.
schema_nameSchema containing the table.
table_nameOriginal table name, used for error reporting.
from_nameCurrent name of the table being renamed.
from_fk_nameName used to identify self-referencing foreign keys.
to_nameNew name for the table.
Return values
falseSuccess.
trueError.

◆ replace_table_for_bulk_load()

static bool replace_table_for_bulk_load ( THD *  thd,
handlerton *  hton,
Table_ref *  table_ref,
const std::string &  schema_name,
const std::string &  original_name,
const std::string &  loaded_table_name,
const std::string &  backup_name 
)
static