InnoDB Plugin  1.0
Data Structures | Macros | Functions | Variables
row0ins.h File Reference
#include "univ.i"
#include "data0data.h"
#include "que0types.h"
#include "dict0types.h"
#include "trx0types.h"
#include "row0types.h"
#include "row0ins.ic"
Include dependency graph for row0ins.h:

Go to the source code of this file.

Data Structures

struct  ins_node_t

Macros

#define row_ins_index_entry_big_rec(e, big, ofs, heap, index, thd, file, line)   row_ins_index_entry_big_rec_func(e,big,ofs,heap,index,file,thd,line)
#define INS_NODE_MAGIC_N   15849075
#define INS_SEARCHED   0 /* INSERT INTO ... SELECT ... */
#define INS_VALUES   1 /* INSERT INTO ... VALUES ... */
#define INS_DIRECT
#define INS_NODE_SET_IX_LOCK   1 /* we should set an IX lock on table */
#define INS_NODE_ALLOC_ROW_ID   2 /* row id should be allocated */
#define INS_NODE_INSERT_ENTRIES

Functions

UNIV_INTERN dberr_t row_ins_check_foreign_constraint (ibool check_ref, dict_foreign_t *foreign, dict_table_t *table, dtuple_t *entry, que_thr_t *thr))
UNIV_INTERN ins_node_tins_node_create (ulint ins_type, dict_table_t *table, mem_heap_t *heap)
UNIV_INTERN void ins_node_set_new_row (ins_node_t *node, dtuple_t *row)
UNIV_INTERN dberr_t row_ins_clust_index_entry_low (ulint flags, ulint mode, dict_index_t *index, ulint n_uniq, dtuple_t *entry, ulint n_ext, que_thr_t *thr))
UNIV_INTERN dberr_t row_ins_sec_index_entry_low (ulint 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))
UNIV_INTERN dberr_t row_ins_index_entry_big_rec_func (const dtuple_t *entry, const big_rec_t *big_rec, ulint *offsets, mem_heap_t **heap, dict_index_t *index, const char *file, const void *thd, ulint line)
UNIV_INTERN dberr_t row_ins_clust_index_entry (dict_index_t *index, dtuple_t *entry, que_thr_t *thr, ulint n_ext))
UNIV_INTERN dberr_t row_ins_sec_index_entry (dict_index_t *index, dtuple_t *entry, que_thr_t *thr))
UNIV_INTERN que_thr_trow_ins_step (que_thr_t *thr)

Variables

UNIV_INTERN dberr_t warn_unused_result

Detailed Description

Insert into a table

Created 4/20/1996 Heikki Tuuri

Macro Definition Documentation

#define INS_DIRECT
Value:
2 /* this is for internal use in dict0crea:
insert the row directly */
#define INS_NODE_INSERT_ENTRIES
Value:
3 /* index entries should be built and
inserted */

Function Documentation

UNIV_INTERN ins_node_t* ins_node_create ( ulint  ins_type,
dict_table_t table,
mem_heap_t heap 
)

Creates an insert node struct.

Returns
own: insert node struct in: mem heap where created
Parameters
ins_typein: INS_VALUES, ...
tablein: table where to insert
UNIV_INTERN 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

Parameters
nodein: insert node
UNIV_INTERN dberr_t row_ins_check_foreign_constraint ( ibool  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.

Returns
DB_SUCCESS, DB_LOCK_WAIT, DB_NO_REFERENCED_ROW, or DB_ROW_IS_REFERENCED
Parameters
check_refin: TRUE If we want to check that the referenced table is ok, FALSE if we want to check the foreign key table
foreignin: foreign constraint; NOTE that the tables mentioned in it must be in the dictionary cache if they exist at all
tablein: if check_ref is TRUE, then the foreign table, else the referenced table
entryin: index entry for index
thrin: query thread
UNIV_INTERN dberr_t row_ins_clust_index_entry ( dict_index_t index,
dtuple_t entry,
que_thr_t thr,
ulint  n_ext 
)

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.

Returns
DB_SUCCESS, DB_LOCK_WAIT, DB_DUPLICATE_KEY, or some other error code
Parameters
indexin: clustered index
entryin/out: index entry to insert
thrin: query thread
n_extin: number of externally stored columns
UNIV_INTERN dberr_t row_ins_clust_index_entry_low ( ulint  flags,
ulint  mode,
dict_index_t index,
ulint  n_uniq,
dtuple_t entry,
ulint  n_ext,
que_thr_t thr 
)

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.

Return values
DB_SUCCESSon success
DB_LOCK_WAITon lock wait when !(flags & BTR_NO_LOCKING_FLAG)
DB_FAILif retry with BTR_MODIFY_TREE is needed
Returns
error code
Parameters
flagsin: undo logging and locking flags
modein: BTR_MODIFY_LEAF or BTR_MODIFY_TREE, depending on whether we wish optimistic or pessimistic descent down the index tree
indexin: clustered index
n_uniqin: 0 or index->n_uniq
entryin/out: index entry to insert
n_extin: number of externally stored columns
thrin: query thread or NULL
UNIV_INTERN dberr_t row_ins_index_entry_big_rec_func ( const dtuple_t entry,
const big_rec_t big_rec,
ulint *  offsets,
mem_heap_t **  heap,
dict_index_t index,
const char *  file,
const void *  thd,
ulint  line 
)

Tries to insert the externally stored fields (off-page columns) of a clustered index entry.

Returns
DB_SUCCESS or DB_OUT_OF_FILE_SPACE
Parameters
entryin/out: index entry to insert
big_recin: externally stored fields
offsetsin/out: rec offsets
heapin/out: memory heap
indexin: index
filein: file name of caller
thdin: connection, or NULL
linein: line number of caller
UNIV_INTERN dberr_t row_ins_sec_index_entry ( dict_index_t index,
dtuple_t entry,
que_thr_t thr 
)

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.

Returns
DB_SUCCESS, DB_LOCK_WAIT, DB_DUPLICATE_KEY, or some other error code
Parameters
indexin: secondary index
entryin/out: index entry to insert
thrin: query thread
UNIV_INTERN dberr_t row_ins_sec_index_entry_low ( ulint  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 
)

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.

Return values
DB_SUCCESSon success
DB_LOCK_WAITon lock wait when !(flags & BTR_NO_LOCKING_FLAG)
DB_FAILif retry with BTR_MODIFY_TREE is needed
Returns
error code
Parameters
flagsin: undo logging and locking flags
modein: BTR_MODIFY_LEAF or BTR_MODIFY_TREE, depending on whether we wish optimistic or pessimistic descent down the index tree
indexin: secondary index
offsets_heapin/out: memory heap that can be emptied
heapin/out: memory heap
entryin/out: index entry to insert
trx_idin: PAGE_MAX_TRX_ID during row_log_table_apply(), or 0
thrin: query thread
UNIV_INTERN que_thr_t* row_ins_step ( que_thr_t thr)

Inserts a row to a table. This is a high-level function used in SQL execution graphs.

Returns
query thread to run next or NULL in: query thread