Skip to content

Commit

Permalink
Backport fix for bug CORE-4565 : GDSCODE can have value = 0 in WHEN-s…
Browse files Browse the repository at this point in the history
…ection under some concurrent env., only in SC or CS (not in SS)
  • Loading branch information
hvlad committed Feb 9, 2018
1 parent 8c728e2 commit 312a1e4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/jrd/cch.cpp
Expand Up @@ -5518,6 +5518,9 @@ static SSHORT lock_buffer(thread_db* tdbb, BufferDesc* bdb, const SSHORT wait, c
TEXT errmsg[MAX_ERRMSG_LEN + 1];
ISC_STATUS* const status = tdbb->tdbb_status_vector;

ISC_STATUS_ARRAY temp_status = {0};
AutoSetRestore<ISC_STATUS*> autoStatus(&tdbb->tdbb_status_vector, temp_status);

This comment has been minimized.

Copy link
@dyemanov

dyemanov Feb 9, 2018

Member

We already have ThreadStatusGuard class for this purpose, shouldn't it be used instead?

This comment has been minimized.

Copy link
@hvlad

hvlad Feb 9, 2018

Author Member

I thought it was introduced in v3 and didn't check its presence in v.2.5, sorry.
Anyway, is it have sence to change already tested patch to save one line of code ?

This comment has been minimized.

Copy link
@dyemanov

dyemanov Feb 9, 2018

Member

Not critical, let's keep what is committed.


if (lock->lck_logical == LCK_none)
{
// Prevent header and TIP pages from generating blocking AST
Expand Down Expand Up @@ -5560,9 +5563,8 @@ static SSHORT lock_buffer(thread_db* tdbb, BufferDesc* bdb, const SSHORT wait, c

// Case: a timeout was specified, or the caller didn't want to wait, return the error.

if ((wait == LCK_NO_WAIT) || ((wait < 0) && (status[1] == isc_lock_timeout)))
if ((wait == LCK_NO_WAIT) || ((wait < 0) && (temp_status[1] == isc_lock_timeout)))
{
fb_utils::init_status(status);
release_bdb(tdbb, bdb, false, false, false);
return -1;
}
Expand All @@ -5579,6 +5581,7 @@ static SSHORT lock_buffer(thread_db* tdbb, BufferDesc* bdb, const SSHORT wait, c
// CCH_unwind releases all the BufferDesc's and calls ERR_punt()
// ERR_punt will longjump.

tdbb->tdbb_status_vector = status;
CCH_unwind(tdbb, true);
}

Expand All @@ -5588,9 +5591,6 @@ static SSHORT lock_buffer(thread_db* tdbb, BufferDesc* bdb, const SSHORT wait, c

const SSHORT must_read = (lock->lck_logical < LCK_read) ? 1 : 0;

ISC_STATUS_ARRAY alt_status;
memcpy(alt_status, tdbb->tdbb_status_vector, sizeof(alt_status));

if (LCK_convert_opt(tdbb, lock, lock_type)) {
return must_read;
}
Expand All @@ -5601,17 +5601,14 @@ static SSHORT lock_buffer(thread_db* tdbb, BufferDesc* bdb, const SSHORT wait, c
return -1;
}

memcpy(tdbb->tdbb_status_vector, alt_status, sizeof(alt_status));

if (LCK_lock(tdbb, lock, lock_type, wait)) {
return 1;
}

// Case: a timeout was specified, or the caller didn't want to wait, return the error.

if ((wait < 0) && (status[1] == isc_lock_timeout))
if ((wait < 0) && (temp_status[1] == isc_lock_timeout))
{
fb_utils::init_status(status);
release_bdb(tdbb, bdb, false, false, false);
return -1;
}
Expand All @@ -5625,6 +5622,7 @@ static SSHORT lock_buffer(thread_db* tdbb, BufferDesc* bdb, const SSHORT wait, c
ERR_append_status(status, Arg::Gds(isc_random) << Arg::Str(errmsg));
ERR_log(JRD_BUGCHK, 215, errmsg); // msg 215 page %ld, page type %ld lock conversion denied

tdbb->tdbb_status_vector = status;
CCH_unwind(tdbb, true);
return 0; // Added to get rid of Compiler Warning
#endif
Expand Down

0 comments on commit 312a1e4

Please sign in to comment.