![]() |
MySQL 8.0.41
Source Code Documentation
|
Insert into a table. More...
#include "data0data.h"
#include "dict0types.h"
#include "que0types.h"
#include "row0types.h"
#include "trx0types.h"
#include "univ.i"
Go to the source code of this file.
Classes | |
struct | ins_node_t |
Functions | |
dberr_t | row_ins_check_foreign_constraint (bool check_ref, dict_foreign_t *foreign, dict_table_t *table, dtuple_t *entry, que_thr_t *thr) |
Checks if foreign key constraint fails for an index entry. More... | |
ins_node_t * | ins_node_create (ulint ins_type, dict_table_t *table, mem_heap_t *heap) |
Creates an insert node struct. More... | |
void | ins_node_set_new_row (ins_node_t *node, dtuple_t *row) |
Sets a new row to insert for an INS_DIRECT node. More... | |
dberr_t | row_ins_clust_index_entry_low (uint32_t flags, ulint mode, dict_index_t *index, ulint n_uniq, dtuple_t *entry, que_thr_t *thr, bool dup_chk_only) |
Tries to insert an entry into a clustered index, ignoring foreign key constraints. More... | |
dberr_t | row_ins_sec_index_entry_low (uint32_t flags, ulint mode, dict_index_t *index, mem_heap_t *offsets_heap, mem_heap_t *heap, dtuple_t *entry, trx_id_t trx_id, que_thr_t *thr, bool dup_chk_only) |
Tries to insert an entry into a secondary index. More... | |
dberr_t | row_ins_index_entry_set_vals (const dict_index_t *index, dtuple_t *entry, const dtuple_t *row) |
Sets the values of the dtuple fields in entry from the values of appropriate columns in row. More... | |
dberr_t | row_ins_clust_index_entry (dict_index_t *index, dtuple_t *entry, que_thr_t *thr, bool dup_chk_only) |
Inserts an entry into a clustered index. More... | |
dberr_t | row_ins_sec_index_entry (dict_index_t *index, dtuple_t *entry, que_thr_t *thr, bool dup_chk_only) |
Inserts an entry into a secondary index. More... | |
que_thr_t * | row_ins_step (que_thr_t *thr) |
Inserts a row to a table. More... | |
Variables | |
constexpr uint32_t | INS_NODE_MAGIC_N = 15849075 |
constexpr uint32_t | INS_SEARCHED = 0 |
INSERT INTO ... SELECT ... More... | |
constexpr uint32_t | INS_VALUES = 1 |
INSERT INTO ... VALUES ... More... | |
constexpr uint32_t | INS_DIRECT = 2 |
this is for internal use in dict0crea: insert the row directly More... | |
constexpr uint32_t | INS_NODE_SET_IX_LOCK = 1 |
we should set an IX lock on table More... | |
constexpr uint32_t | INS_NODE_ALLOC_ROW_ID = 2 |
row id should be allocated More... | |
constexpr uint32_t | INS_NODE_INSERT_ENTRIES = 3 |
index entries should be built and inserted More... | |
Insert into a table.
Created 4/20/1996 Heikki Tuuri
ins_node_t * ins_node_create | ( | ulint | ins_type, |
dict_table_t * | table, | ||
mem_heap_t * | heap | ||
) |
Creates an insert node struct.
ins_type | in: INS_VALUES, ... |
table | in: table where to insert |
heap | in: mem heap where created |
void ins_node_set_new_row | ( | ins_node_t * | node, |
dtuple_t * | row | ||
) |
Sets a new row to insert for an INS_DIRECT node.
This function is only used if we have constructed the row separately, which is a rare case; this function is quite slow. in: new row (or first row) for the node
This function is only used if we have constructed the row separately, which is a rare case; this function is quite slow.
node | in: insert node |
row | in: new row (or first row) for the node |
dberr_t row_ins_check_foreign_constraint | ( | bool | check_ref, |
dict_foreign_t * | foreign, | ||
dict_table_t * | table, | ||
dtuple_t * | entry, | ||
que_thr_t * | thr | ||
) |
Checks if foreign key constraint fails for an index entry.
Sets shared locks which lock either the success or the failure of the constraint. NOTE that the caller must have a shared latch on dict_foreign_key_check_lock.
Sets shared locks which lock either the success or the failure of the constraint. NOTE that the caller must have a shared latch on dict_operation_lock.
check_ref | in: true if we want to check that the referenced table is ok, false if we want to check the foreign key table |
foreign | in: foreign constraint; NOTE that the tables mentioned in it must be in the dictionary cache if they exist at all |
table | in: if check_ref is true, then the foreign table, else the referenced table |
entry | in: index entry for index |
thr | in: query thread |
dberr_t row_ins_clust_index_entry | ( | dict_index_t * | index, |
dtuple_t * | entry, | ||
que_thr_t * | thr, | ||
bool | dup_chk_only | ||
) |
Inserts an entry into a clustered index.
Tries first optimistic, then pessimistic descent down the tree. If the entry matches enough to a delete marked record, performs the insert by updating or delete unmarking the delete marked record.
Tries first optimistic, then pessimistic descent down the tree. If the entry matches enough to a delete marked record, performs the insert by updating or delete unmarking the delete marked record.
index | in: clustered index |
entry | in/out: index entry to insert |
thr | in: query thread |
dup_chk_only | in: if true, just do duplicate check and return. don't execute actual insert. |
dberr_t row_ins_clust_index_entry_low | ( | uint32_t | flags, |
ulint | mode, | ||
dict_index_t * | index, | ||
ulint | n_uniq, | ||
dtuple_t * | entry, | ||
que_thr_t * | thr, | ||
bool | dup_chk_only | ||
) |
Tries to insert an entry into a clustered index, ignoring foreign key constraints.
If a record with the same unique key is found, the other record is necessarily marked deleted by a committed transaction, or a unique key violation error occurs. The delete marked record is then updated to an existing record, and we must write an undo log record on the delete marked record.
[in] | flags | Undo logging and locking flags. |
[in] | mode | BTR_MODIFY_LEAF or BTR_MODIFY_TREE, depending on whether we wish optimistic or pessimistic descent down the index tree. |
[in] | index | Clustered index. |
[in] | n_uniq | 0 or index->n_uniq. |
[in] | entry | Index entry to insert. |
[in] | thr | Query thread, or nullptr if flags & (BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG) and a duplicate can't occur. |
[in] | dup_chk_only | If true, just do duplicate check and return. don't execute actual insert. |
DB_SUCCESS | on success |
DB_LOCK_WAIT | on lock wait when !(flags & BTR_NO_LOCKING_FLAG) |
DB_FAIL | if retry with BTR_MODIFY_TREE is needed |
dberr_t row_ins_index_entry_set_vals | ( | const dict_index_t * | index, |
dtuple_t * | entry, | ||
const dtuple_t * | row | ||
) |
Sets the values of the dtuple fields in entry from the values of appropriate columns in row.
[in] | index | index handler |
[out] | entry | index entry to make |
[in] | row | row |
dberr_t row_ins_sec_index_entry | ( | dict_index_t * | index, |
dtuple_t * | entry, | ||
que_thr_t * | thr, | ||
bool | dup_chk_only | ||
) |
Inserts an entry into a secondary index.
Tries first optimistic, then pessimistic descent down the tree. If the entry matches enough to a delete marked record, performs the insert by updating or delete unmarking the delete marked record.
Tries first optimistic, then pessimistic descent down the tree. If the entry matches enough to a delete marked record, performs the insert by updating or delete unmarking the delete marked record.
index | in: secondary index |
entry | in/out: index entry to insert |
thr | in: query thread |
dup_chk_only | in: if true, just do duplicate check and return. don't execute actual insert. |
dberr_t row_ins_sec_index_entry_low | ( | uint32_t | flags, |
ulint | mode, | ||
dict_index_t * | index, | ||
mem_heap_t * | offsets_heap, | ||
mem_heap_t * | heap, | ||
dtuple_t * | entry, | ||
trx_id_t | trx_id, | ||
que_thr_t * | thr, | ||
bool | dup_chk_only | ||
) |
Tries to insert an entry into a secondary index.
If a record with exactly the same fields is found, the other record is necessarily marked deleted. It is then unmarked. Otherwise, the entry is just inserted to the index.
[in] | flags | undo logging and locking flags |
[in] | mode | BTR_MODIFY_LEAF or BTR_MODIFY_TREE, depending on whether we wish optimistic or pessimistic descent down the index tree |
[in] | index | secondary index |
[in,out] | offsets_heap | memory heap that can be emptied |
[in,out] | heap | memory heap |
[in,out] | entry | index entry to insert |
[in] | trx_id | PAGE_MAX_TRX_ID during row_log_table_apply(), or trx_id when undo log is disabled during alter copy operation or 0 |
[in] | thr | query thread |
[in] | dup_chk_only | true, just do duplicate check and return. don't execute actual insert |
DB_SUCCESS | on success |
DB_LOCK_WAIT | on lock wait when !(flags & BTR_NO_LOCKING_FLAG) |
DB_FAIL | if retry with BTR_MODIFY_TREE is needed |
Inserts a row to a table.
This is a high-level function used in SQL execution graphs.
This is a high-level function used in SQL execution graphs.
thr | in: query thread |
|
constexpr |
this is for internal use in dict0crea: insert the row directly
|
constexpr |
row id should be allocated
|
constexpr |
index entries should be built and inserted
|
constexpr |
|
constexpr |
we should set an IX lock on table
|
constexpr |
INSERT INTO ... SELECT ...
|
constexpr |
INSERT INTO ... VALUES ...