8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 14:03:02 +01:00
This commit is contained in:
robocop 2008-02-24 03:23:40 +00:00
parent 3a9567e868
commit f8007f4071
9 changed files with 99 additions and 86 deletions

View File

@ -95,7 +95,7 @@ private:
{ {
if ((offset < this->size) && (offset + _size <= this->size)) if ((offset < this->size) && (offset + _size <= this->size))
return ptr + offset; return ptr + offset;
else
return NULL; return NULL;
} }

View File

@ -341,7 +341,7 @@ ULONG TextType::str_to_upper(ULONG srcLen,
{ {
if (tt->texttype_fn_str_to_upper) if (tt->texttype_fn_str_to_upper)
return (*tt->texttype_fn_str_to_upper)(tt, srcLen, src, dstLen, dst); return (*tt->texttype_fn_str_to_upper)(tt, srcLen, src, dstLen, dst);
else
return Firebird::IntlUtil::toUpper(getCharSet(), srcLen, src, dstLen, dst, NULL); return Firebird::IntlUtil::toUpper(getCharSet(), srcLen, src, dstLen, dst, NULL);
} }
@ -353,7 +353,7 @@ ULONG TextType::str_to_lower(ULONG srcLen,
{ {
if (tt->texttype_fn_str_to_lower) if (tt->texttype_fn_str_to_lower)
return (*tt->texttype_fn_str_to_lower)(tt, srcLen, src, dstLen, dst); return (*tt->texttype_fn_str_to_lower)(tt, srcLen, src, dstLen, dst);
else
return Firebird::IntlUtil::toLower(getCharSet(), srcLen, src, dstLen, dst, NULL); return Firebird::IntlUtil::toLower(getCharSet(), srcLen, src, dstLen, dst, NULL);
} }

View File

@ -540,14 +540,14 @@ namespace {
class HugeStaticBuffer class HugeStaticBuffer
{ {
public: public:
HugeStaticBuffer(MemoryPool& p) explicit HugeStaticBuffer(MemoryPool& p)
: zeroArray(p), : zeroArray(p),
zeroBuff(zeroArray.getBuffer(ZERO_BUF_SIZE)) zeroBuff(zeroArray.getBuffer(ZERO_BUF_SIZE))
{ {
memset(zeroBuff, 0, ZERO_BUF_SIZE); memset(zeroBuff, 0, ZERO_BUF_SIZE);
} }
const char* get() { return zeroBuff; } const char* get() const { return zeroBuff; }
private: private:
Firebird::Array<char> zeroArray; Firebird::Array<char> zeroArray;

View File

@ -1106,10 +1106,9 @@ static SSHORT par_context(CompilerScratch* csb, SSHORT* context_ptr)
if (csb->csb_g_flags & csb_reuse_context) { if (csb->csb_g_flags & csb_reuse_context) {
return tail->csb_stream; return tail->csb_stream;
} }
else {
error(csb, isc_ctxinuse, 0); error(csb, isc_ctxinuse, 0);
} }
}
const SSHORT stream = csb->nextStream(false); const SSHORT stream = csb->nextStream(false);
if (stream >= MAX_STREAMS) if (stream >= MAX_STREAMS)
@ -1476,11 +1475,10 @@ static jrd_nod* par_function(thread_db* tdbb, CompilerScratch* csb)
anode->nod_arg[e_fun_args] = par_args(tdbb, csb, VALUE); anode->nod_arg[e_fun_args] = par_args(tdbb, csb, VALUE);
return anode; return anode;
} }
else {
csb->csb_running -= count; csb->csb_running -= count;
error(csb, isc_funnotdef, isc_arg_string, ERR_cstring(name), 0); error(csb, isc_funnotdef, isc_arg_string, ERR_cstring(name), 0);
} }
}
UserFunction* homonyms; UserFunction* homonyms;
for (homonyms = function; homonyms; homonyms = homonyms->fun_homonym) { for (homonyms = function; homonyms; homonyms = homonyms->fun_homonym) {

View File

@ -246,7 +246,8 @@ void API_ROUTINE perf_get_info(FB_API_HANDLE* handle, PERF* perf)
const char* p = buffer; const char* p = buffer;
while (true) while (true)
switch (*p++) { switch (*p++)
{
case isc_info_reads: case isc_info_reads:
perf->perf_reads = get_parameter(&p); perf->perf_reads = get_parameter(&p);
break; break;
@ -283,12 +284,18 @@ void API_ROUTINE perf_get_info(FB_API_HANDLE* handle, PERF* perf)
return; return;
case isc_info_error: case isc_info_error:
if (p[2] == isc_info_marks) switch (p[2])
{
case isc_info_marks:
perf->perf_marks = 0; perf->perf_marks = 0;
else if (p[2] == isc_info_current_memory) break;
case isc_info_current_memory:
perf->perf_current_memory = 0; perf->perf_current_memory = 0;
else if (p[2] == isc_info_max_memory) break;
case isc_info_max_memory:
perf->perf_max_memory = 0; perf->perf_max_memory = 0;
break;
}
{ {
const SLONG temp = isc_vax_integer(p, 2); const SLONG temp = isc_vax_integer(p, 2);
fb_assert(temp <= MAX_SSHORT); fb_assert(temp <= MAX_SSHORT);

View File

@ -2241,48 +2241,52 @@ static bool get_record(thread_db* tdbb,
break; break;
case rsb_skip: case rsb_skip:
switch (mode) { {
irsb_skip_n* skip = (irsb_skip_n*) impure;
switch (mode)
{
#ifdef SCROLLABLE_CURSORS #ifdef SCROLLABLE_CURSORS
case RSE_get_backward: case RSE_get_backward:
if (((irsb_skip_n*) impure)->irsb_count > 0) if (skip->irsb_count > 0)
{ {
invalidate_child_rpbs(tdbb, rsb); invalidate_child_rpbs(tdbb, rsb);
return false; return false;
} }
if (((irsb_skip_n*) impure)->irsb_count == 0) if (skip->irsb_count == 0)
{ {
((irsb_skip_n*) impure)->irsb_count++; skip->irsb_count++;
if (get_record(tdbb, rsb->rsb_next, NULL, mode)) if (get_record(tdbb, rsb->rsb_next, NULL, mode))
invalidate_child_rpbs(tdbb, rsb); invalidate_child_rpbs(tdbb, rsb);
return false; return false;
} }
((irsb_skip_n*) impure)->irsb_count++; skip->irsb_count++;
if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
return false; return false;
break; break;
case RSE_get_current: case RSE_get_current:
if (((irsb_skip_n*) impure)->irsb_count >= 1) if (skip->irsb_count >= 1)
{ {
invalidate_child_rpbs(tdbb, rsb); invalidate_child_rpbs(tdbb, rsb);
return false; return false;
} }
else if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
return false; return false;
break; break;
#endif #endif
case RSE_get_forward: case RSE_get_forward:
while (((irsb_skip_n*) impure)->irsb_count > 1) { while (skip->irsb_count > 1) {
((irsb_skip_n*) impure)->irsb_count--; skip->irsb_count--;
if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
return false; return false;
} }
((irsb_skip_n*) impure)->irsb_count--; skip->irsb_count--;
if (!get_record(tdbb, rsb->rsb_next, NULL, mode)) if (!get_record(tdbb, rsb->rsb_next, NULL, mode))
return false; return false;
break; break;
} }
}
break; break;
case rsb_merge: case rsb_merge:

View File

@ -144,26 +144,26 @@ void SCL_check_access(const SecurityClass* s_class,
0); 0);
} }
const Attachment* const attachment = tdbb->getAttachment(); const Attachment& attachment = *tdbb->getAttachment();
// Allow the database owner to back up a database even if he does not have // Allow the database owner to back up a database even if he does not have
// read access to all the tables in the database // read access to all the tables in the database
if ((attachment->att_flags & ATT_gbak_attachment) && (mask & SCL_read)) if ((attachment.att_flags & ATT_gbak_attachment) && (mask & SCL_read))
{ {
return; return;
} }
// Allow the locksmith any access to database // Allow the locksmith any access to database
if (attachment->locksmith()) if (attachment.locksmith())
{ {
return; return;
} }
bool denied_db = false; bool denied_db = false;
const SecurityClass* const att_class = attachment->att_security_class; const SecurityClass* const att_class = attachment.att_security_class;
if (att_class && !(att_class->scl_flags & mask)) if (att_class && !(att_class->scl_flags & mask))
{ {
denied_db = true; denied_db = true;
@ -974,6 +974,7 @@ static bool check_user_group(const UCHAR* acl,
else // processing group name else // processing group name
{ {
Firebird::UCharBuffer buffer; Firebird::UCharBuffer buffer;
fb_assert(l < length); // Not sure how we can guarantee this.
UCHAR* user_group_name = buffer.getBuffer(length); UCHAR* user_group_name = buffer.getBuffer(length);
do { do {
const TEXT one_char = *acl++; const TEXT one_char = *acl++;

View File

@ -646,8 +646,10 @@ int TRA_get_state(thread_db* tdbb, SLONG number)
return TPC_snapshot_state(tdbb, number); return TPC_snapshot_state(tdbb, number);
if (number && dbb->dbb_pc_transactions) if (number && dbb->dbb_pc_transactions)
{
if (TRA_precommited(tdbb, number, number)) if (TRA_precommited(tdbb, number, number))
return tra_precommitted; return tra_precommitted;
}
return TRA_fetch_state(tdbb, number); return TRA_fetch_state(tdbb, number);
} }
@ -1069,7 +1071,7 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction)
} }
} }
{ { // scope
vec<jrd_rel*>& rels = *dbb->dbb_relations; vec<jrd_rel*>& rels = *dbb->dbb_relations;
for (size_t i = 0; i < rels.count(); i++) for (size_t i = 0; i < rels.count(); i++)
{ {
@ -1080,7 +1082,7 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction)
} }
} }
} } // end scope
// Release the locks associated with the transaction // Release the locks associated with the transaction
@ -1275,10 +1277,8 @@ void TRA_rollback(thread_db* tdbb, jrd_tra* transaction, const bool retaining_fl
retain_context(tdbb, transaction, false, state); retain_context(tdbb, transaction, false, state);
return; return;
} }
else {
TRA_set_state(tdbb, transaction, transaction->tra_number, state);
}
TRA_set_state(tdbb, transaction, transaction->tra_number, state);
TRA_release_transaction(tdbb, transaction); TRA_release_transaction(tdbb, transaction);
} }
@ -1352,7 +1352,7 @@ void TRA_set_state(thread_db* tdbb, jrd_tra* transaction, SLONG number, SSHORT s
if (transaction && !(transaction->tra_flags & TRA_write)) if (transaction && !(transaction->tra_flags & TRA_write))
return; return;
else {
{ //scope { //scope
Database::Checkout dcoHolder(dbb); Database::Checkout dcoHolder(dbb);
THREAD_YIELD(); THREAD_YIELD();
@ -1361,7 +1361,6 @@ void TRA_set_state(thread_db* tdbb, jrd_tra* transaction, SLONG number, SSHORT s
if (generation == tip->pag_generation) if (generation == tip->pag_generation)
CCH_MARK_MUST_WRITE(tdbb, &window); CCH_MARK_MUST_WRITE(tdbb, &window);
CCH_RELEASE(tdbb, &window); CCH_RELEASE(tdbb, &window);
}
#endif #endif
} }
@ -1450,7 +1449,7 @@ int TRA_snapshot_state(thread_db* tdbb, const jrd_tra* trans, SLONG number)
int state = TPC_snapshot_state(tdbb, number); int state = TPC_snapshot_state(tdbb, number);
if (state == tra_active) if (state == tra_active)
return tra_committed; return tra_committed;
else
return state; return state;
} }

View File

@ -5352,8 +5352,10 @@ static Transaction* find_transaction(Attachment* dbb,
**************************************/ **************************************/
for (; transaction; transaction = transaction->next) for (; transaction; transaction = transaction->next)
{
if (transaction->parent == dbb) if (transaction->parent == dbb)
return transaction; return transaction;
}
return NULL; return NULL;
} }
@ -5741,6 +5743,7 @@ static ISC_STATUS prepare(ISC_STATUS* user_status,
length = p - description; length = p - description;
for (sub = transaction->next; sub; sub = sub->next) for (sub = transaction->next; sub; sub = sub->next)
{
if (CALL(PROC_PREPARE, sub->implementation) (status, if (CALL(PROC_PREPARE, sub->implementation) (status,
&sub->handle, &sub->handle,
length, description)) length, description))
@ -5750,6 +5753,7 @@ static ISC_STATUS prepare(ISC_STATUS* user_status,
} }
return status[1]; return status[1];
} }
}
if (description != tdr_buffer) if (description != tdr_buffer)
free_block(description); free_block(description);