MySQL 8.0.40
Source Code Documentation
sql_insert.h File Reference
#include <assert.h>
#include <sys/types.h>
#include "mem_root_deque.h"
#include "my_inttypes.h"
#include "my_sqlcommand.h"
#include "sql/query_result.h"
#include "sql/sql_cmd_dml.h"
#include "sql/sql_data_change.h"
#include "sql/table.h"
#include "sql/thr_malloc.h"

Go to the source code of this file.

Classes

class  Query_result_insert
 
class  Query_result_create
 
class  Sql_cmd_insert_base
 Base class for all INSERT and REPLACE statements. More...
 
class  Sql_cmd_insert_values
 Class that implements INSERT ... VALUES and REPLACE ... VALUES statements. More...
 
class  Sql_cmd_insert_select
 Class that implements INSERT ... SELECT and REPLACE ... SELECT statements. More...
 

Typedefs

using List_item = mem_root_deque< Item * >
 

Functions

bool check_that_all_fields_are_given_values (THD *thd, TABLE *entry, Table_ref *table_list)
 Check that all fields with aren't null_fields are used. More...
 
void prepare_triggers_for_insert_stmt (THD *thd, TABLE *table)
 Prepare triggers for INSERT-like statement. More...
 
bool write_record (THD *thd, TABLE *table, COPY_INFO *info, COPY_INFO *update)
 Write a record to table with optional deletion of conflicting records, invoke proper triggers if needed. More...
 
bool validate_default_values_of_unset_fields (THD *thd, TABLE *table)
 Validates default value of fields which are not specified in the column list of INSERT statement. More...
 

Typedef Documentation

◆ List_item

Function Documentation

◆ check_that_all_fields_are_given_values()

bool check_that_all_fields_are_given_values ( THD thd,
TABLE entry,
Table_ref table_list 
)

Check that all fields with aren't null_fields are used.

Parameters
thdthread handler
entrytable that's checked
table_listtop-level table or view, used for generating error or warning message
Return values
trueif all fields are given values

◆ prepare_triggers_for_insert_stmt()

void prepare_triggers_for_insert_stmt ( THD thd,
TABLE table 
)

Prepare triggers for INSERT-like statement.

Parameters
thdThread handler
tableTable to which insert will happen
Note
Prepare triggers for INSERT-like statement by marking fields used by triggers and inform handlers that batching of UPDATE/DELETE cannot be done if there are BEFORE UPDATE/DELETE triggers.

◆ validate_default_values_of_unset_fields()

bool validate_default_values_of_unset_fields ( THD thd,
TABLE table 
)

Validates default value of fields which are not specified in the column list of INSERT statement.

Note
table->record[0] should be be populated with default values before calling this function.
Parameters
thdthread context
tabletable to which values are inserted.
Returns
false if success, true if error

◆ write_record()

bool write_record ( THD thd,
TABLE table,
COPY_INFO info,
COPY_INFO update 
)

Write a record to table with optional deletion of conflicting records, invoke proper triggers if needed.

Parameters
thdthread context
tabletable to which record should be written
infoCOPY_INFO structure describing handling of duplicates and which is used for counting number of records inserted and deleted.
updateCOPY_INFO structure describing the UPDATE part (only used for INSERT ON DUPLICATE KEY UPDATE)

Once this record is written to the table buffer, any AFTER INSERT trigger will be invoked. If instead of inserting a new record we end up updating an old one, both ON UPDATE triggers will fire instead. Similarly both ON DELETE triggers will be invoked if are to delete conflicting records.

Call thd->transaction.stmt.mark_modified_non_trans_table() if table is a non-transactional table.

Note
In ON DUPLICATE KEY UPDATE case this call may set TABLE::autoinc_field_has_explicit_non_null_value flag to true (even in case of failure) so its caller should make sure that it is reset appropriately (
See also
fill_record()).
Returns
false if success, true if error

< Flag for fatal errors