| 277 | |
| 278 | |
| 279 | IndexLock* CMP_get_index_lock(thread_db* tdbb, jrd_rel* relation, USHORT id) |
| 280 | { |
| 281 | /************************************** |
| 282 | * |
| 283 | * C M P _ g e t _ i n d e x _ l o c k |
| 284 | * |
| 285 | ************************************** |
| 286 | * |
| 287 | * Functional description |
| 288 | * Get index lock block for index. If one doesn't exist, |
| 289 | * make one. |
| 290 | * |
| 291 | **************************************/ |
| 292 | SET_TDBB(tdbb); |
| 293 | Database* dbb = tdbb->getDatabase(); |
| 294 | |
| 295 | DEV_BLKCHK(relation, type_rel); |
| 296 | |
| 297 | if (relation->rel_id < (USHORT) rel_MAX) { |
| 298 | return NULL; |
| 299 | } |
| 300 | |
| 301 | // for to find an existing block |
| 302 | |
| 303 | for (IndexLock* index = relation->rel_index_locks; index; index = index->idl_next) |
| 304 | { |
| 305 | if (index->idl_id == id) { |
| 306 | return index; |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | IndexLock* index = FB_NEW_POOL(*relation->rel_pool) IndexLock(); |
| 311 | index->idl_next = relation->rel_index_locks; |
| 312 | relation->rel_index_locks = index; |
| 313 | index->idl_relation = relation; |
| 314 | index->idl_id = id; |
| 315 | index->idl_count = 0; |
| 316 | |
| 317 | Lock* lock = FB_NEW_RPT(*relation->rel_pool, 0) Lock(tdbb, sizeof(SLONG), LCK_idx_exist); |
| 318 | index->idl_lock = lock; |
| 319 | lock->setKey((relation->rel_id << 16) | id); |
| 320 | |
| 321 | return index; |
| 322 | } |
| 323 | |
| 324 | |
| 325 | void CMP_post_access(thread_db* tdbb, |
no test coverage detected