MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / insert_key

Function insert_key

src/jrd/idx.cpp:2086–2141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2084
2085
2086static idx_e insert_key(thread_db* tdbb,
2087 jrd_rel* relation,
2088 Record* record,
2089 jrd_tra* transaction,
2090 WIN * window_ptr,
2091 index_insertion* insertion,
2092 IndexErrorContext& context)
2093{
2094/**************************************
2095 *
2096 * i n s e r t _ k e y
2097 *
2098 **************************************
2099 *
2100 * Functional description
2101 * Insert a key in the index.
2102 * If this is a unique index, check for active duplicates.
2103 * If this is a foreign key, check for duplicates in the
2104 * primary key index.
2105 *
2106 **************************************/
2107 SET_TDBB(tdbb);
2108
2109 idx_e result = idx_e_ok;
2110 index_desc* idx = insertion->iib_descriptor;
2111
2112 // Insert the key into the index. If the index is unique, btr will keep track of duplicates.
2113
2114 insertion->iib_duplicates = NULL;
2115 BTR_insert(tdbb, window_ptr, insertion);
2116
2117 if (insertion->iib_duplicates)
2118 {
2119 result = check_duplicates(tdbb, record, idx, insertion, NULL);
2120 delete insertion->iib_duplicates;
2121 insertion->iib_duplicates = 0;
2122 }
2123
2124 if (result != idx_e_ok)
2125 return result;
2126
2127 // if we are dealing with a foreign key index,
2128 // check for an insert into the corresponding primary key index
2129 if (idx->idx_flags & idx_foreign)
2130 {
2131 // Find out if there is a null segment. If there is one,
2132 // don't bother to check the primary key.
2133 if (result == idx_e_ok && insertion->iib_key->key_nulls == 0)
2134 {
2135 result = check_foreign_key(tdbb, record, insertion->iib_relation,
2136 transaction, idx, context);
2137 }
2138 }
2139
2140 return result;
2141}
2142
2143

Callers 2

IDX_modifyFunction · 0.85
IDX_storeFunction · 0.85

Calls 4

SET_TDBBFunction · 0.85
BTR_insertFunction · 0.85
check_duplicatesFunction · 0.85
check_foreign_keyFunction · 0.85

Tested by

no test coverage detected