| 317 | |
| 318 | |
| 319 | bool LCK_convert(thread_db* tdbb, Lock* lock, USHORT level, SSHORT wait) |
| 320 | { |
| 321 | /************************************** |
| 322 | * |
| 323 | * L C K _ c o n v e r t |
| 324 | * |
| 325 | ************************************** |
| 326 | * |
| 327 | * Functional description |
| 328 | * Convert an existing lock to a new level. |
| 329 | * |
| 330 | **************************************/ |
| 331 | SET_TDBB(tdbb); |
| 332 | fb_assert(LCK_CHECK_LOCK(lock)); |
| 333 | |
| 334 | #ifdef DEBUG_LCK |
| 335 | LckSync sync(lock, "LCK_convert"); |
| 336 | #endif |
| 337 | |
| 338 | Database* dbb = lock->lck_dbb; |
| 339 | |
| 340 | Jrd::Attachment* const old_attachment = lock->getLockAttachment(); |
| 341 | lock->setLockAttachment(tdbb->getAttachment()); |
| 342 | |
| 343 | WaitCancelGuard guard(tdbb, lock, wait); |
| 344 | FbLocalStatus statusVector; |
| 345 | |
| 346 | const bool result = CONVERT(tdbb, &statusVector, lock, level, wait); |
| 347 | |
| 348 | if (!result) |
| 349 | { |
| 350 | lock->setLockAttachment(old_attachment); |
| 351 | |
| 352 | switch (statusVector[1]) |
| 353 | { |
| 354 | case isc_deadlock: |
| 355 | case isc_lock_conflict: |
| 356 | case isc_lock_timeout: |
| 357 | statusVector.copyTo(tdbb->tdbb_status_vector); |
| 358 | tdbb->checkCancelState(); |
| 359 | return false; |
| 360 | case isc_lockmanerr: |
| 361 | dbb->dbb_flags |= DBB_bugcheck; |
| 362 | break; |
| 363 | } |
| 364 | |
| 365 | statusVector.raise(); |
| 366 | } |
| 367 | |
| 368 | if (!lock->lck_compatible) |
| 369 | lock->lck_physical = lock->lck_logical = level; |
| 370 | |
| 371 | fb_assert(LCK_CHECK_LOCK(lock)); |
| 372 | return true; |
| 373 | } |
| 374 | |
| 375 | |
| 376 | bool LCK_convert_opt(thread_db* tdbb, Lock* lock, USHORT level) |
no test coverage detected