8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 14:03:07 +01:00
This commit is contained in:
asfernandes 2014-05-23 02:12:56 +00:00
parent 45e46da20d
commit bb735cb5a2
8 changed files with 36 additions and 48 deletions

View File

@ -116,7 +116,7 @@ public:
length = 0;
}
Item& accessItem(unsigned n)
Item& getItem(unsigned n)
{
fb_assert(n < items.getCount());
return items[n];

View File

@ -4044,23 +4044,7 @@ ValueExprNode* DerivedExprNode::pass2(thread_db* tdbb, CompilerScratch* csb)
dsc* DerivedExprNode::execute(thread_db* tdbb, jrd_req* request) const
{
if (cursorNumber.specified)
{
const Cursor* const cursor = request->req_cursors[cursorNumber.value];
const Cursor::Impure* const cursorImpure = request->getImpure<Cursor::Impure>(cursor->m_impure);
if (!cursorImpure->irsb_active)
{
// error: invalid cursor state
status_exception::raise(Arg::Gds(isc_cursor_not_open));
}
if (cursorImpure->irsb_state != Cursor::POSITIONED)
{
status_exception::raise(
Arg::Gds(isc_cursor_not_positioned) <<
Arg::Str(cursor->name));
}
}
request->req_cursors[cursorNumber.value]->checkState(request);
dsc* value = NULL;
@ -5569,23 +5553,7 @@ dsc* FieldNode::execute(thread_db* tdbb, jrd_req* request) const
impure_value* const impure = request->getImpure<impure_value>(impureOffset);
if (cursorNumber.specified)
{
const Cursor* const cursor = request->req_cursors[cursorNumber.value];
const Cursor::Impure* const cursorImpure = request->getImpure<Cursor::Impure>(cursor->m_impure);
if (!cursorImpure->irsb_active)
{
// error: invalid cursor state
status_exception::raise(Arg::Gds(isc_cursor_not_open));
}
if (cursorImpure->irsb_state != Cursor::POSITIONED)
{
status_exception::raise(
Arg::Gds(isc_cursor_not_positioned) <<
Arg::Str(cursor->name));
}
}
request->req_cursors[cursorNumber.value]->checkState(request);
record_param& rpb = request->req_rpb[fieldStream];
Record* record = rpb.rpb_record;

View File

@ -403,7 +403,7 @@ void PreparedStatement::parseDsqlMessage(const dsql_msg* dsqlMsg, Array<dsc>& va
msgMetadata->setItemsCount(paramCount);
for (size_t i = 0; i < paramCount; ++i)
dscToMetaItem(&params[i]->par_desc, msgMetadata->accessItem(i));
dscToMetaItem(&params[i]->par_desc, msgMetadata->getItem(i));
msgMetadata->makeOffsets();
msg.resize(msgMetadata->getMessageLength());
@ -414,12 +414,12 @@ void PreparedStatement::parseDsqlMessage(const dsql_msg* dsqlMsg, Array<dsc>& va
{
// value
*value = params[i]->par_desc;
value->dsc_address = msg.begin() + msgMetadata->accessItem(i).offset;
value->dsc_address = msg.begin() + msgMetadata->getItem(i).offset;
++value;
// NULL indicator
value->makeShort(0);
value->dsc_address = msg.begin() + msgMetadata->accessItem(i).nullInd;
value->dsc_address = msg.begin() + msgMetadata->getItem(i).nullInd;
// set NULL indicator value
*((SSHORT*) value->dsc_address) = -1;
++value;

View File

@ -3020,7 +3020,7 @@ static rhd* locate_space(thread_db* tdbb,
{
// hvlad: to avoid deadlocks in DPM_fetch_fragment enforce ascending
// order of pages for record fragments
if (rpb->rpb_flags & rpb_fragment && type == DPM_other &&
if ((rpb->rpb_flags & rpb_fragment) && type == DPM_other &&
rpb->rpb_page > dp_number)
{
continue;

View File

@ -482,9 +482,8 @@ void BackupManager::endBackup(thread_db* tdbb, bool recover)
if (all.getFirst())
{
do {
if (--tdbb->tdbb_quantum < 0) {
if (--tdbb->tdbb_quantum < 0)
JRD_reschedule(tdbb, QUANTUM, true);
}
WIN window2(DB_PAGE_SPACE, all.current().db_page);
NBAK_TRACE(("Merge page %d, diff=%d", all.current().db_page, all.current().diff_page));
@ -672,7 +671,7 @@ ULONG BackupManager::allocateDifferencePage(thread_db* tdbb, ULONG db_page)
{
LocalAllocWriteGuard localAllocGuard(this);
// This page may be allocated while we wait for a local lock above
// This page may be allocated while we wait for a local lock above
if (ULONG diff_page = findPageIndex(tdbb, db_page)) {
return diff_page;
}

View File

@ -254,8 +254,8 @@ private:
class LocalAllocGuard
{
public:
LocalAllocGuard(BackupManager* bm) :
m_bm(bm)
LocalAllocGuard(BackupManager* bm)
: m_bm(bm)
{
//Database::Checkout cout(m_bm->database);
@ -293,8 +293,8 @@ private:
class GlobalAllocGuard
{
public:
GlobalAllocGuard(thread_db* _tdbb, BackupManager* _backupManager)
: tdbb(_tdbb), backupManager(_backupManager)
GlobalAllocGuard(thread_db* aTdbb, BackupManager* aBackupManager)
: tdbb(aTdbb), backupManager(aBackupManager)
{
if (Exclusive)
backupManager->lockAllocWrite(tdbb);
@ -408,6 +408,7 @@ public:
bool actualizeState(thread_db* tdbb);
bool actualizeAlloc(thread_db* tdbb, bool haveGlobalLock);
void initializeAlloc(thread_db* tdbb);
void invalidateAlloc(thread_db* tdbb)
{
allocIsValid = false;

View File

@ -299,3 +299,22 @@ bool Cursor::fetchRelative(thread_db* tdbb, SINT64 offset) const
return true;
}
// Check if the cursor is in a good state for access a field.
void Cursor::checkState(jrd_req* request) const
{
const Impure* const impure = request->getImpure<Impure>(m_impure);
if (!impure->irsb_active)
{
// error: invalid cursor state
status_exception::raise(Arg::Gds(isc_cursor_not_open));
}
if (impure->irsb_state != Cursor::POSITIONED)
{
status_exception::raise(
Arg::Gds(isc_cursor_not_positioned) <<
Arg::Str(name));
}
}

View File

@ -35,7 +35,6 @@ namespace Jrd
class Cursor
{
public:
enum State { BOS, POSITIONED, EOS };
struct Impure
@ -60,6 +59,8 @@ namespace Jrd
bool fetchAbsolute(thread_db* tdbb, SINT64 offset) const;
bool fetchRelative(thread_db* tdbb, SINT64 offset) const;
void checkState(jrd_req* request) const;
const RecordSource* getAccessPath() const
{
return m_top;
@ -80,10 +81,10 @@ namespace Jrd
}
public:
ULONG m_impure;
Firebird::MetaName name; // optional name for explicit PSQL cursors
private:
ULONG m_impure;
const RecordSource* const m_top;
const VarInvariantArray* const m_invariants;
const bool m_scrollable;