Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CBRD-25510] Removed unnecessary loop in heap_get_insert_location_with_lock() function execution #5654

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
21 changes: 6 additions & 15 deletions src/storage/heap_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -20455,7 +20455,7 @@ static int
heap_get_insert_location_with_lock (THREAD_ENTRY * thread_p, HEAP_OPERATION_CONTEXT * context,
PGBUF_WATCHER * home_hint_p)
{
int slot_count, slot_id, lk_result;
int lk_result, slot_id = 0;
LOCK lock;
int error_code = NO_ERROR;

Expand Down Expand Up @@ -20515,19 +20515,11 @@ heap_get_insert_location_with_lock (THREAD_ENTRY * thread_p, HEAP_OPERATION_CONT
}
}

/* retrieve number of slots in page */
slot_count = spage_number_of_slots (context->home_page_watcher_p->pgptr);

/* find REC_DELETED_WILL_REUSE slot or add new slot */
/* slot_id == slot_count means add new slot */
for (slot_id = 0; slot_id <= slot_count; slot_id++)
{
slot_id = spage_find_free_slot (context->home_page_watcher_p->pgptr, NULL, slot_id);
if (slot_id == SP_ERROR)
{
break; /* this will not happen */
}
YeunjunLee marked this conversation as resolved.
Show resolved Hide resolved
slot_id = spage_find_free_slot (context->home_page_watcher_p->pgptr, NULL, slot_id);

if (slot_id != SP_ERROR)
{
context->res_oid.slotid = slot_id;

if (lock == NULL_LOCK)
Expand All @@ -20543,9 +20535,9 @@ heap_get_insert_location_with_lock (THREAD_ENTRY * thread_p, HEAP_OPERATION_CONT
/* successfully locked! */
return NO_ERROR;
}
#if !defined(NDEBUG)
else if (lk_result != LK_NOTGRANTED_DUE_TIMEOUT)
{
#if !defined(NDEBUG)
if (lk_result == LK_NOTGRANTED_DUE_ABORTED)
{
LOG_TDES *tdes = LOG_FIND_CURRENT_TDES (thread_p);
Expand All @@ -20555,10 +20547,9 @@ heap_get_insert_location_with_lock (THREAD_ENTRY * thread_p, HEAP_OPERATION_CONT
{
assert (false); /* unknown locking error */
}
#endif
break; /* go to error case */
}
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endif 위치가 잘못된 것 같습니다.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정하였습니다.


/* either lock error or no slot was found in page (which should not happen) */
OID_SET_NULL (&context->res_oid);
Expand Down
Loading