8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 00:43:02 +01:00
This commit is contained in:
robocop 2014-03-22 20:51:24 +00:00
parent 8623583aab
commit 66af445e2e
17 changed files with 112 additions and 71 deletions

View File

@ -86,7 +86,8 @@ public:
// Set bit
void set(T value)
{
if (singular) {
if (singular)
{
// If we are trying to set the same bit as already set - do nothing
if (singular_value == value)
return;
@ -101,8 +102,10 @@ public:
bucket.bits = BUNCH_ONE << (singular_value - bucket.start_value);
tree.add(bucket);
}
else {
if (tree.isEmpty()) {
else
{
if (tree.isEmpty())
{
singular = true;
singular_value = value;
return;
@ -124,10 +127,12 @@ public:
bool clear(T value)
{
if (singular) {
if (singular)
{
fb_assert(tree.isEmpty());
if (value == singular_value) {
if (value == singular_value)
{
singular = false;
return true;
}
@ -135,10 +140,12 @@ public:
}
const T val_aligned = value & ~(T)(BUNCH_BITS - 1);
if (tree.isPositioned(val_aligned) || tree.locate(val_aligned)) {
if (tree.isPositioned(val_aligned) || tree.locate(val_aligned))
{
const BUNCH_T bit_mask = BUNCH_ONE << (value - val_aligned);
Bucket *current_bucket = &tree.current();
if (current_bucket->bits & bit_mask) {
if (current_bucket->bits & bit_mask)
{
current_bucket->bits &= ~bit_mask;
if (!current_bucket->bits)
tree.fastRemove();
@ -150,13 +157,15 @@ public:
bool test(T value)
{
if (singular) {
if (singular)
{
fb_assert(tree.isEmpty());
return (value == singular_value);
}
const T val_aligned = value & ~(T) (BUNCH_BITS - 1);
if (tree.isPositioned(val_aligned) || tree.locate(val_aligned)) {
if (tree.isPositioned(val_aligned) || tree.locate(val_aligned))
{
const BUNCH_T bit_mask = BUNCH_ONE << (value - val_aligned);
return tree.current().bits & bit_mask;
}
@ -255,7 +264,8 @@ public:
// If need arises to use it in performance-critical places separation
// of handling for different LocType cases may make sense.
if (bitmap->singular) {
if (bitmap->singular)
{
// Trivial handling for singular bitmap
current_value = bitmap->singular_value;
@ -294,7 +304,8 @@ public:
// Look up a bucket for our key
T key_aligned = key & ~(T) (BUNCH_BITS - 1);
if (!treeAccessor.locate(lt, key_aligned)) {
if (!treeAccessor.locate(lt, key_aligned)) m
{
// If we didn't find the desired bucket no way we can find desired value
return false;
}
@ -347,11 +358,13 @@ public:
case locLessEqual:
{
// Initialize bit_mask
if (treeAccessor.current().start_value == key_aligned) {
if (treeAccessor.current().start_value == key_aligned)
{
current_value = key;
bit_mask = BUNCH_ONE << (key - key_aligned);
}
else {
else
{
current_value = treeAccessor.current().start_value;
bit_mask = BUNCH_ONE << (BUNCH_BITS - 1);
}
@ -396,7 +409,8 @@ public:
if (!bitmap)
return false;
if (bitmap->singular) {
if (bitmap->singular)
{
current_value = bitmap->singular_value;
return true;
}
@ -427,7 +441,8 @@ public:
if (!bitmap)
return false;
if (bitmap->singular) {
if (bitmap->singular)
{
current_value = bitmap->singular_value;
return true;
}
@ -466,8 +481,10 @@ public:
// Scan bucket forwards looking for a match
BUNCH_T tree_bits = treeAccessor.current().bits;
while (try_mask) {
if (tree_bits & try_mask) {
while (try_mask)
{
if (tree_bits & try_mask)
{
bit_mask = try_mask;
current_value = try_value;
return true;
@ -516,8 +533,10 @@ public:
// Scan bucket backwards looking for a match
BUNCH_T tree_bits = treeAccessor.current().bits;
while (try_mask) {
if (tree_bits & try_mask) {
while (try_mask)
{
if (tree_bits & try_mask)
{
bit_mask = try_mask;
current_value = try_value;
return true;
@ -535,7 +554,8 @@ public:
try_mask = BUNCH_ONE << (BUNCH_BITS - 1);
try_value = treeAccessor.current().start_value + BUNCH_BITS - 1;
do {
if (tree_bits & try_mask) {
if (tree_bits & try_mask)
{
bit_mask = try_mask;
current_value = try_value;
return true;
@ -582,13 +602,15 @@ SparseBitmap<T, InternalTypes>::bit_or(SparseBitmap<T, InternalTypes>** bitmap1,
fb_assert(map1 != map2);
// First bitmap is singular. Set appropriate bit in second and return it
if (map1->singular) {
if (map1->singular)
{
map2->set(map1->singular_value);
return bitmap2;
}
// Second bitmap is singular. Set appropriate bit in first and return it
if (map2->singular) {
if (map2->singular)
{
map1->set(map2->singular_value);
return bitmap1;
}
@ -596,12 +618,14 @@ SparseBitmap<T, InternalTypes>::bit_or(SparseBitmap<T, InternalTypes>** bitmap1,
SparseBitmap *source, *dest, **result;
// If second bitmap seems larger then use it as a target
if (map2->tree.seemsBiggerThan(map1->tree)) {
if (map2->tree.seemsBiggerThan(map1->tree))
{
dest = map2;
source = map1;
result = bitmap2;
}
else {
else
{
dest = map1;
source = map2;
result = bitmap1;
@ -628,14 +652,16 @@ SparseBitmap<T, InternalTypes>::bit_or(SparseBitmap<T, InternalTypes>** bitmap1,
if (destFound)
{
// See if we need to skip value in destination tree
if (destValue < sourceValue) {
if (destValue < sourceValue)
{
if ((destFound = dest->tree.getNext()))
destValue = dest->tree.current().start_value;
continue;
}
// Positions of our trees match
if (destValue == sourceValue) {
if (destValue == sourceValue)
{
dest->tree.current().bits |= source->tree.current().bits;
if ((destFound = dest->tree.getNext()))
@ -648,7 +674,8 @@ SparseBitmap<T, InternalTypes>::bit_or(SparseBitmap<T, InternalTypes>** bitmap1,
// Need to add some buckets to destination tree.
// Try to add them in a row to avoid accessor resync after addition
while (true) {
while (true)
{
dest->tree.add(source->tree.current());
if (!(sourceFound = source->tree.getNext()))
@ -657,7 +684,8 @@ SparseBitmap<T, InternalTypes>::bit_or(SparseBitmap<T, InternalTypes>** bitmap1,
sourceValue = source->tree.current().start_value;
// Resync accessor position if necessary
if (destValue <= sourceValue) {
if (destValue <= sourceValue)
{
dest->tree.locate(destValue);
break;
}
@ -694,7 +722,8 @@ SparseBitmap<T, InternalTypes>::bit_and(SparseBitmap<T, InternalTypes>** bitmap1
fb_assert(map1 != map2);
// First bitmap is singular. Test appropriate bit in second and return first
if (map1->singular) {
if (map1->singular)
{
if (map2->test(map1->singular_value))
return bitmap1;
@ -702,7 +731,8 @@ SparseBitmap<T, InternalTypes>::bit_and(SparseBitmap<T, InternalTypes>** bitmap1
}
// Second bitmap is singular. Test appropriate bit in first and return second
if (map2->singular) {
if (map2->singular)
{
if (map1->test(map2->singular_value))
return bitmap2;
@ -712,12 +742,14 @@ SparseBitmap<T, InternalTypes>::bit_and(SparseBitmap<T, InternalTypes>** bitmap1
SparseBitmap *source, *dest, **result;
// If second bitmap seems smaller then use it as a target
if (map1->tree.seemsBiggerThan(map2->tree)) {
if (map1->tree.seemsBiggerThan(map2->tree))
{
dest = map2;
source = map1;
result = bitmap2;
}
else {
else
{
dest = map1;
source = map2;
result = bitmap1;
@ -743,14 +775,16 @@ SparseBitmap<T, InternalTypes>::bit_and(SparseBitmap<T, InternalTypes>** bitmap1
if (sourceFound)
{
// See if we need to skip value in destination tree
if (sourceValue < destValue) {
if (sourceValue < destValue)
{
if ((sourceFound = source->tree.getNext()))
sourceValue = source->tree.current().start_value;
continue;
}
// Positions of our trees match
if (sourceValue == destValue) {
if (sourceValue == destValue)
{
const BUNCH_T bits = dest->tree.current().bits &= source->tree.current().bits;
// Move to the next item of destination tree

View File

@ -387,7 +387,7 @@ int Parser::yylexAux()
// The Introducer (_) is skipped, all other idents are copied
// to become the name of the character set.
char* p = string;
for (; lex.ptr < lex.end && classes(*lex.ptr) & CHR_IDENT; lex.ptr++)
for (; lex.ptr < lex.end && (classes(*lex.ptr) & CHR_IDENT); lex.ptr++)
{
if (lex.ptr >= lex.end)
return -1;
@ -1019,7 +1019,7 @@ int Parser::yylexAux()
{
char* p = string;
check_copy_incr(p, UPPER (c), string);
for (; lex.ptr < lex.end && classes(*lex.ptr) & CHR_IDENT; lex.ptr++)
for (; lex.ptr < lex.end && (classes(*lex.ptr) & CHR_IDENT); lex.ptr++)
{
if (lex.ptr >= lex.end)
return -1;

View File

@ -905,10 +905,10 @@ void OptimizerRetrieval::getInversionCandidates(InversionCandidateList* inversio
// than one row. The same is true for an equivalence scan for
// any primary index.
const bool single_match =
((segment->scanType == segmentScanEqual &&
scratch.idx->idx_flags & idx_unique) ||
(segment->scanType == segmentScanEqual &&
(scratch.idx->idx_flags & idx_unique)) ||
(segment->scanType == segmentScanEquivalent &&
scratch.idx->idx_flags & idx_primary));
(scratch.idx->idx_flags & idx_primary));
// dimitr: IS NULL scan against primary key is guaranteed
// to return zero rows. Do we need yet another

View File

@ -1047,13 +1047,13 @@ static TokenType getToken(const char** begin, const char* end)
default:
if (classes(c) & CHR_DIGIT)
{
while (p < end && classes(*p) & CHR_DIGIT)
while (p < end && (classes(*p) & CHR_DIGIT))
p++;
ret = ttOther;
}
else if (classes(c) & CHR_IDENT)
{
while (p < end && classes(*p) & CHR_IDENT)
while (p < end && (classes(*p) & CHR_IDENT))
p++;
ret = ttIdent;
}

View File

@ -6688,7 +6688,7 @@ static void purge_attachment(thread_db* tdbb, JAttachment* jAtt, unsigned flags)
Jrd::Attachment* attachment = NULL;
while ((attachment = jAtt->getHandle()) && attachment->att_flags & ATT_purge_started)
while ((attachment = jAtt->getHandle()) && (attachment->att_flags & ATT_purge_started))
{
attachment->att_use_count--;

View File

@ -3626,7 +3626,7 @@ void MET_scan_relation(thread_db* tdbb, jrd_rel* relation)
try {
if (relation->rel_flags & REL_scanned || relation->rel_flags & REL_deleted)
if (relation->rel_flags & (REL_scanned | REL_deleted))
return;
relation->rel_flags |= REL_being_scanned;

View File

@ -172,11 +172,12 @@ SLONG LOCK_enq(PTR prior_request,
if ((status & 1) &&
(((status = lksb.lksb_status) & 1) || status == SS$_VALNOTVALID))
{
if (data) {
if (data)
{
if (lock_type == LCK$K_EXMODE)
write_data(lksb.lksb_lock_id, data);
write_data(lksb.lksb_lock_id, data);
else
LOCK_write_data(lksb.lksb_lock_id, data);
LOCK_write_data(lksb.lksb_lock_id, data);
}
return lksb.lksb_lock_id;
}
@ -246,8 +247,9 @@ SLONG LOCK_read_data(PTR lock_id)
LCK$K_NLMODE, &lksb,
LCK$M_CONVERT | LCK$M_VALBLK, &desc, NULL, /* Lock parent (not used) */
gds__completion_ast, /* AST routine when granted */
NULL, NULL, NULL, NULL); if (status & 1)
ISC_wait(&lksb, EVENT_FLAG);
NULL, NULL, NULL, NULL);
if (status & 1)
ISC_wait(&lksb, EVENT_FLAG);
if (!status && !(lksb.lksb_status & 1))
return 0;
return lksb.lksb_value[0];
@ -292,8 +294,9 @@ SLONG LOCK_write_data(PTR lock_id, SLONG data)
status =
sys$enq(EVENT_FLAG, LCK$K_EXMODE, &lksb, LCK$M_CONVERT, &desc, NULL, /* Lock parent (not used) */
gds__completion_ast, /* AST routine when granted */
NULL, NULL, NULL, NULL); if (status & 1)
ISC_wait(&lksb, EVENT_FLAG);
NULL, NULL, NULL, NULL);
if (status & 1)
ISC_wait(&lksb, EVENT_FLAG);
if (!(status & 1) || !((status = lksb.lksb_status) & 1))
return 0;
return write_data(lock_id, data);
@ -314,7 +317,8 @@ static bool lock_error(ISC_STATUS * status_vector,
*
**************************************/
if (code == SS$_DEADLOCK) {
if (code == SS$_DEADLOCK)
{
*status_vector++ = isc_arg_gds;
*status_vector++ = isc_deadlock;
}
@ -358,6 +362,8 @@ static SLONG write_data(SLONG lock_id, SLONG data)
NULL,
NULL);
if (!(status & 1) || !((status = lksb.lksb_status) & 1))
return 0;
return 0;
return 1; // maybe 1 ???
}

View File

@ -1628,7 +1628,7 @@ void PAG_set_db_SQL_dialect(thread_db* tdbb, SSHORT flag)
{
case SQL_DIALECT_V5:
if (dbb->dbb_flags & DBB_DB_SQL_dialect_3 || header->hdr_flags & hdr_SQL_dialect_3)
if ((dbb->dbb_flags & DBB_DB_SQL_dialect_3) || (header->hdr_flags & hdr_SQL_dialect_3))
{
// Check the returned value here!
ERR_post_warning(Arg::Warning(isc_dialect_reset_warning));

View File

@ -70,7 +70,7 @@ void FullTableScan::open(thread_db* tdbb) const
BufferControl* const bcb = dbb->dbb_bcb;
if (attachment->att_flags & ATT_gbak_attachment ||
if ((attachment->att_flags & ATT_gbak_attachment) ||
DPM_data_pages(tdbb, rpb->rpb_relation) > bcb->bcb_count)
{
rpb->getWindow(tdbb).win_flags = WIN_large_scan;

View File

@ -1081,7 +1081,7 @@ void SDW_start(thread_db* tdbb, const TEXT* file_name,
delete shadow_file;
}
delete[] spare_buffer;
if (file_flags & FILE_manual && !delete_files) {
if ((file_flags & FILE_manual) && !delete_files) {
ERR_post(Arg::Gds(isc_shadow_missing) << Arg::Num(shadow_number));
}
else

View File

@ -258,7 +258,7 @@ void SHUT_database(thread_db* tdbb, SSHORT flag, SSHORT delay, Sync* guard)
}
if (!exclusive && !successful &&
(timeout > 0 || flag & (isc_dpb_shut_attachment | isc_dpb_shut_transaction)))
(timeout > 0 || (flag & (isc_dpb_shut_attachment | isc_dpb_shut_transaction))))
{
notify_shutdown(tdbb, 0, -1, guard); // Tell everyone we're giving up
attachment->att_flags &= ~ATT_shutdown_manager;

View File

@ -2478,7 +2478,7 @@ void Service::finish(USHORT flag)
{
svc_flags |= SVC_finished;
}
if (svc_flags & SVC_finished && svc_flags & SVC_detached)
if ((svc_flags & SVC_finished) && (svc_flags & SVC_detached))
{
delete this;
return;

View File

@ -346,14 +346,14 @@ void TRA_commit(thread_db* tdbb, jrd_tra* transaction, const bool retaining_flag
// and no events have been posted (via stored procedures etc)
// no-op the operation.
if (retaining_flag && !(transaction->tra_flags & TRA_write || transaction->tra_deferred_job))
if (retaining_flag && !((transaction->tra_flags & TRA_write) || transaction->tra_deferred_job))
{
if (sysTran->tra_flags & TRA_write)
transaction_flush(tdbb, FLUSH_SYSTEM, 0);
transaction->tra_flags &= ~TRA_prepared;
// Get rid of all user savepoints
while (transaction->tra_save_point && transaction->tra_save_point->sav_flags & SAV_user)
while (transaction->tra_save_point && (transaction->tra_save_point->sav_flags & SAV_user))
{
Savepoint* const next = transaction->tra_save_point->sav_next;
transaction->tra_save_point->sav_next = NULL;
@ -721,7 +721,7 @@ void TRA_invalidate(thread_db* tdbb, ULONG mask)
transaction = transaction->tra_next)
{
const ULONG transaction_mask = 1L << (transaction->tra_number & (BITS_PER_LONG - 1));
if (transaction_mask & mask && transaction->tra_flags & TRA_write)
if ((transaction_mask & mask) && (transaction->tra_flags & TRA_write))
transaction->tra_flags |= TRA_invalidated;
}
@ -1285,7 +1285,7 @@ void TRA_rollback(thread_db* tdbb, jrd_tra* transaction, const bool retaining_fl
// Free all savepoint data
// We can do it in reverse order because nothing except simple deallocation
// of memory is really done in VIO_verb_cleanup when we pass NULL as sav_next
while (transaction->tra_save_point && transaction->tra_save_point->sav_flags & SAV_user)
while (transaction->tra_save_point && (transaction->tra_save_point->sav_flags & SAV_user))
{
Savepoint* const next = transaction->tra_save_point->sav_next;
transaction->tra_save_point->sav_next = NULL;
@ -1382,7 +1382,8 @@ void TRA_set_state(thread_db* tdbb, jrd_tra* transaction, TraNumber number, int
// If we're terminating ourselves and we've been precommitted then just return.
if (transaction && transaction->tra_number == number && transaction->tra_flags & TRA_precommitted)
if (transaction && transaction->tra_number == number &&
(transaction->tra_flags & TRA_precommitted))
{
return;
}
@ -2402,7 +2403,7 @@ static void retain_context(thread_db* tdbb, jrd_tra* transaction, bool commit, i
// Get rid of all user savepoints
// Why we can do this in reverse order described in commit method
while (transaction->tra_save_point && transaction->tra_save_point->sav_flags & SAV_user)
while (transaction->tra_save_point && (transaction->tra_save_point->sav_flags & SAV_user))
{
Savepoint* const next = transaction->tra_save_point->sav_next;
transaction->tra_save_point->sav_next = NULL;
@ -3277,7 +3278,7 @@ static void transaction_start(thread_db* tdbb, jrd_tra* trans)
// forever without impacting garbage collection or causing
// transaction bitmap growth.
if (trans->tra_flags & TRA_readonly && trans->tra_flags & TRA_read_committed)
if ((trans->tra_flags & TRA_readonly) && (trans->tra_flags & TRA_read_committed))
{
TRA_set_state(tdbb, trans, trans->tra_number, tra_committed);
LCK_release(tdbb, lock);

View File

@ -1990,7 +1990,7 @@ RTN Vdr::walk_record(thread_db* tdbb,
// If the record is a fragment, not large, or we're not interested in
// chasing records, skip the record
if (header->rhd_flags & (rhd_fragment | rhd_deleted) ||
if ((header->rhd_flags & (rhd_fragment | rhd_deleted)) ||
!((header->rhd_flags & rhd_large) || (validate && (vdr_flags & vdr_records))))
{
return rtn_ok;

View File

@ -1991,8 +1991,8 @@ lrq* LockManager::deadlock_walk(lrq* request, bool* maybe_deadlock)
own* const owner = (own*) SRQ_ABS_PTR(block->lrq_owner);
if (owner->own_flags & (OWN_signaled | OWN_wakeup) || !SRQ_EMPTY((owner->own_blocks)) ||
block->lrq_flags & LRQ_just_granted)
if ((owner->own_flags & (OWN_signaled | OWN_wakeup)) || !SRQ_EMPTY((owner->own_blocks)) ||
(block->lrq_flags & LRQ_just_granted))
{
*maybe_deadlock = true;
continue;

View File

@ -2116,7 +2116,7 @@ static qli_nod* expand_store( qli_syntax* input, qli_lls* right, qli_lls* left)
if (field->fld_flags & FLD_computed)
continue;
if ((field->fld_system_flag && field->fld_system_flag != relation->rel_system_flag) ||
field->fld_flags & FLD_array)
(field->fld_flags & FLD_array))
{
continue;
}
@ -2287,7 +2287,7 @@ static int generate_fields( qli_ctx* context, qli_lls* values, qli_syntax* rse)
for (qli_fld* field = relation->rel_fields; field; field = field->fld_next)
{
if ((field->fld_system_flag && field->fld_system_flag != relation->rel_system_flag) ||
field->fld_flags & FLD_array)
(field->fld_flags & FLD_array))
{
continue;
}
@ -2339,7 +2339,7 @@ static int generate_items(const qli_syntax* symbol, qli_lls* right, qli_lls* ite
for (qli_fld* field = relation->rel_fields; field; field = field->fld_next)
{
if ((field->fld_system_flag && field->fld_system_flag != relation->rel_system_flag) ||
field->fld_flags & FLD_array)
(field->fld_flags & FLD_array))
{
continue;
}

View File

@ -1090,7 +1090,7 @@ static void edit_numeric(const dsc* desc, pics* picture, TEXT** output)
*out++ = c;
break;
}
if (picture->pic_flags & PIC_suppress_blanks && out[-1] == ' ')
if ((picture->pic_flags & PIC_suppress_blanks) && out[-1] == ' ')
--out;
}