8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-31 16:43:03 +01:00
firebird-mirror/src/jrd/recsrc/VirtualTableScan.cpp
dimitr 11495a55fb Refactored the whole RSB stuff into classes. They're inside the /recsrc sub-directory now.
Fixed the layering for WITH LOCK and (partially) ANY/ALL predicates.
Cleaned up the outdated code that never worked (mapping DISTINCT to an index, some VMS remainings).
Wiped out a lot of the pre-ODS11 optimizer logic. Some minor adjustments there.
Re-implemented the full outer join from scratch. This resolves CORE-2678 (full outer join cannot use available indices).
Resolved CORE-2796: DB_KEY is always zero for external tables.
Implemented the core part of the scrollable PSQL cursors. Implementation is still incomplete, but ready for testing.
Some other changes I don't recall at the moment ;-)

WARNING! The engine may be unstable. Please email me about any issues found.
2009-12-09 18:45:44 +00:00

140 lines
3.5 KiB
C++

/*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
*
* Software distributed under the License is distributed AS IS,
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
* See the License for the specific language governing rights
* and limitations under the License.
*
* The Original Code was created by Dmitry Yemanov
* for the Firebird Open Source RDBMS project.
*
* Copyright (c) 2009 Dmitry Yemanov <dimitr@firebirdsql.org>
* and all contributors signed below.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#include "firebird.h"
#include "../jrd/jrd.h"
#include "../jrd/req.h"
#include "../jrd/rse.h"
#include "../jrd/cmp_proto.h"
#include "../jrd/met_proto.h"
#include "../jrd/vio_proto.h"
#include "RecordSource.h"
using namespace Firebird;
using namespace Jrd;
// -------------------------------
// Data access: virtual table scan
// -------------------------------
VirtualTableScan::VirtualTableScan(CompilerScratch* csb, const string& name, UCHAR stream)
: RecordStream(csb, stream), m_name(csb->csb_pool, name)
{
m_impure = CMP_impure(csb, sizeof(Impure));
}
void VirtualTableScan::open(thread_db* tdbb)
{
jrd_req* const request = tdbb->getRequest();
Impure* const impure = (Impure*) ((UCHAR*) request + m_impure);
impure->irsb_flags = irsb_open;
record_param* const rpb = &request->req_rpb[m_stream];
rpb->getWindow(tdbb).win_flags = 0;
jrd_rel* const relation = rpb->rpb_relation;
const Record* const record = rpb->rpb_record;
const Format* format = NULL;
if (!record || !record->rec_format)
{
format = MET_current(tdbb, relation);
VIO_record(tdbb, rpb, format, request->req_pool);
}
else
{
format = record->rec_format;
}
rpb->rpb_number.setValue(BOF_NUMBER);
DatabaseSnapshot* const snapshot = DatabaseSnapshot::create(tdbb);
impure->irsb_record_buffer = snapshot->getData(relation);
}
void VirtualTableScan::close(thread_db* tdbb)
{
jrd_req* const request = tdbb->getRequest();
invalidateRecords(request);
Impure* const impure = (Impure*) ((UCHAR*) request + m_impure);
if (impure->irsb_flags & irsb_open)
{
impure->irsb_flags &= ~irsb_open;
impure->irsb_record_buffer = NULL;
}
}
bool VirtualTableScan::getRecord(thread_db* tdbb)
{
jrd_req* const request = tdbb->getRequest();
record_param* const rpb = &request->req_rpb[m_stream];
Impure* const impure = (Impure*) ((UCHAR*) request + m_impure);
if (!(impure->irsb_flags & irsb_open))
{
rpb->rpb_number.setValid(false);
return false;
}
rpb->rpb_number.increment();
fb_assert(impure->irsb_record_buffer);
if (impure->irsb_record_buffer->fetch(rpb->rpb_number.getValue(), rpb->rpb_record))
{
rpb->rpb_number.setValid(true);
return true;
}
rpb->rpb_number.setValid(false);
return false;
}
bool VirtualTableScan::refetchRecord(thread_db* tdbb)
{
return true;
}
bool VirtualTableScan::lockRecord(thread_db* tdbb)
{
status_exception::raise(Arg::Gds(isc_record_lock_not_supp));
return false; // compiler silencer
}
void VirtualTableScan::dump(thread_db* tdbb, UCharBuffer& buffer)
{
buffer.add(isc_info_rsb_begin);
buffer.add(isc_info_rsb_relation);
dumpName(tdbb, m_name, buffer);
buffer.add(isc_info_rsb_type);
buffer.add(isc_info_rsb_virt_sequential);
buffer.add(isc_info_rsb_end);
}