Drizzled Public API Documentation

row0ins.h File Reference
#include "univ.i"
#include "data0data.h"
#include "que0types.h"
#include "dict0types.h"
#include "trx0types.h"
#include "row0types.h"

Go to the source code of this file.

Classes

struct  ins_node_struct
 

Macros

#define row0ins_h
 
#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 ulint 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 ulint row_ins_index_entry (dict_index_t *index, dtuple_t *entry, ulint n_ext, ibool foreign, que_thr_t *thr)
 
UNIV_INTERN que_thr_trow_ins_step (que_thr_t *thr)
 
UNIV_INTERN void ins_node_create_entry_list (ins_node_t *node)
 

Detailed Description

Insert into a table

Created 4/20/1996 Heikki Tuuri

Definition in file row0ins.h.

Macro Definition Documentation

#define INS_DIRECT
Value:
2 /* this is for internal use in dict0crea:
insert the row directly */

Definition at line 145 of file row0ins.h.

#define INS_NODE_INSERT_ENTRIES
Value:
3 /* index entries should be built and
inserted */

Definition at line 151 of file row0ins.h.

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

Creates an insert node struct.

Returns
own: insert node struct
Parameters
ins_typein: INS_VALUES, ...
tablein: table where to insert
heapin: mem heap where created

Definition at line 69 of file row0ins.cc.

References ins_node_struct::common, ins_node_struct::entry, ins_node_struct::index, ins_node_create(), mem_heap_alloc(), mem_heap_create, ins_node_struct::select, ins_node_struct::state, ins_node_struct::table, ins_node_struct::trx_id, and que_common_struct::type.

Referenced by ind_create_graph_create(), ins_node_create(), pars_insert_statement(), and tab_create_graph_create().

UNIV_INTERN void ins_node_create_entry_list ( ins_node_t node)

Creates an entry template for each index of a table. in: row insert node

Creates an entry template for each index of a table.

Parameters
nodein: row insert node

Definition at line 103 of file row0ins.cc.

References ins_node_create_entry_list(), ins_node_struct::row, row_build_index_entry(), ins_node_struct::table, ut_ad, UT_LIST_ADD_LAST, and UT_LIST_INIT.

Referenced by ins_node_create_entry_list(), and ins_node_set_new_row().

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

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.

Parameters
nodein: insert node
rowin: new row (or first row) for the node

Definition at line 186 of file row0ins.cc.

References ins_node_struct::entry, ins_node_struct::index, ins_node_create_entry_list(), ins_node_set_new_row(), mem_heap_empty(), ins_node_struct::row, ins_node_struct::state, and ins_node_struct::trx_id.

Referenced by ins_node_set_new_row(), and pars_insert_statement().

UNIV_INTERN ulint 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 in: query thread

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_operation_lock.

Returns
DB_SUCCESS, 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

Definition at line 1187 of file row0ins.cc.

References btr_pcur_close(), btr_pcur_move_to_next(), BTR_SEARCH_LEAF, cmp_dtuple_rec(), DB_SUCCESS_LOCKED_REC, dfield_get_len(), dtuple_get_n_fields_cmp(), dtuple_set_n_fields_cmp(), trx_struct::error_state, dict_foreign_struct::foreign_index, dict_foreign_struct::foreign_table, dict_foreign_struct::foreign_table_name, dict_table_struct::ibd_file_missing, LOCK_GAP, LOCK_ORDINARY, LOCK_REC_NOT_GAP, lock_table(), mem_heap_free, mtr_commit(), mtr_start(), dict_foreign_struct::n_fields, dict_index_struct::name, page_rec_is_infimum(), page_rec_is_supremum(), que_node_get_type(), que_thr_stop_for_mysql(), rec_get_deleted_flag(), rec_offs_comp(), dict_foreign_struct::referenced_index, dict_foreign_struct::referenced_table, dict_foreign_struct::referenced_table_name, row_ins_check_foreign_constraint(), que_thr_struct::run_node, srv_suspend_mysql_thread(), thr_get_trx(), trx_print(), dict_foreign_struct::type, ut_a, ut_ad, ut_print_name(), and ut_print_timestamp().

Referenced by row_ins_check_foreign_constraint().

UNIV_INTERN ulint row_ins_index_entry ( dict_index_t index,
dtuple_t entry,
ulint  n_ext,
ibool  foreign,
que_thr_t thr 
)

Inserts an index entry to 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 in: query thread

Inserts an index entry to 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: index
entryin/out: index entry to insert
n_extin: number of externally stored columns
foreignin: TRUE=check foreign key constraints (foreign=FALSE only during CREATE INDEX)
thrin: query thread

Definition at line 2151 of file row0ins.cc.

References BTR_MODIFY_LEAF, BTR_MODIFY_TREE, dict_table_struct::foreign_list, row_ins_index_entry(), dict_index_struct::table, and UT_LIST_GET_FIRST.

Referenced by row_ins_index_entry().

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

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
Parameters
thrin: query thread

Definition at line 2414 of file row0ins.cc.

References trx_struct::error_state, trx_struct::id, lock_table(), que_thr_struct::prev_node, que_node_get_parent(), que_node_get_type(), row_ins_step(), que_thr_struct::run_node, SEL_NODE_FETCH, SEL_NODE_NO_MORE_ROWS, SEL_NODE_OPEN, ins_node_struct::select, ins_node_struct::state, sel_node_struct::state, ins_node_struct::table, thr_get_trx(), ins_node_struct::trx_id, trx_start_if_not_started(), trx_write_trx_id(), and ut_ad.

Referenced by row_ins_step(), and row_insert_for_mysql().