mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 04:03:04 +01:00
Allowed conditional bitmap scans for the index navigation.
This commit is contained in:
parent
b2df821da7
commit
98c9f00c2c
@ -2379,8 +2379,7 @@ static RecordSource* gen_retrieval(thread_db* tdbb,
|
||||
if (sort_ptr)
|
||||
*sort_ptr = NULL;
|
||||
|
||||
if (inversion && !condition)
|
||||
nav_rsb->setInversion(inversion);
|
||||
nav_rsb->setInversion(inversion, condition);
|
||||
|
||||
rsb = nav_rsb;
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ using namespace Jrd;
|
||||
|
||||
IndexTableScan::IndexTableScan(CompilerScratch* csb, const string& name, StreamType stream,
|
||||
InversionNode* index, USHORT length)
|
||||
: RecordStream(csb, stream), m_name(csb->csb_pool, name), m_index(index), m_inversion(NULL),
|
||||
m_length(length), m_offset(0)
|
||||
: RecordStream(csb, stream), m_name(csb->csb_pool, name), m_index(index),
|
||||
m_inversion(NULL), m_condition(NULL), m_length(length), m_offset(0)
|
||||
{
|
||||
fb_assert(m_index);
|
||||
|
||||
@ -191,7 +191,7 @@ bool IndexTableScan::getRecord(thread_db* tdbb) const
|
||||
// is not in the bitmap for the inversion, or
|
||||
// 2) the record has already been visited
|
||||
|
||||
if ((m_inversion &&
|
||||
if ((!(impure->irsb_flags & irsb_mustread) &&
|
||||
(!impure->irsb_nav_bitmap ||
|
||||
!RecordBitmap::test(*impure->irsb_nav_bitmap, number.getValue()))) ||
|
||||
RecordBitmap::test(impure->irsb_nav_records_visited, number.getValue()))
|
||||
@ -593,6 +593,7 @@ bool IndexTableScan::setupBitmaps(thread_db* tdbb, Impure* impure) const
|
||||
// than one leaf node reference to the same record number; the
|
||||
// bitmap allows us to filter out the multiple references.
|
||||
RecordBitmap::reset(impure->irsb_nav_records_visited);
|
||||
impure->irsb_flags |= irsb_mustread;
|
||||
|
||||
// the first time we open the stream, compute a bitmap
|
||||
// for the inversion tree -- this may cause problems for
|
||||
@ -600,11 +601,15 @@ bool IndexTableScan::setupBitmaps(thread_db* tdbb, Impure* impure) const
|
||||
// view of the database when the stream is opened
|
||||
if (m_inversion)
|
||||
{
|
||||
if (!m_condition || !m_condition->execute(tdbb, tdbb->getRequest()))
|
||||
{
|
||||
impure->irsb_flags &= ~irsb_mustread;
|
||||
// There is no need to reset or release the bitmap, it is
|
||||
// done in EVL_bitmap()
|
||||
impure->irsb_nav_bitmap = EVL_bitmap(tdbb, m_inversion, NULL);
|
||||
return (*impure->irsb_nav_bitmap != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -205,10 +205,11 @@ namespace Jrd
|
||||
void print(thread_db* tdbb, Firebird::string& plan,
|
||||
bool detailed, unsigned level) const;
|
||||
|
||||
void setInversion(InversionNode* inversion)
|
||||
void setInversion(InversionNode* inversion, BoolExprNode* condition)
|
||||
{
|
||||
fb_assert(!m_inversion);
|
||||
fb_assert(!m_inversion && !m_condition);
|
||||
m_inversion = inversion;
|
||||
m_condition = condition;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -224,6 +225,7 @@ namespace Jrd
|
||||
const Firebird::string m_name;
|
||||
NestConst<InversionNode> const m_index;
|
||||
NestConst<InversionNode> m_inversion;
|
||||
NestConst<BoolExprNode> m_condition;
|
||||
const size_t m_length;
|
||||
size_t m_offset;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user