8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-30 22:03:03 +01:00
firebird-mirror/src/jrd/recsrc/Cursor.h

96 lines
2.3 KiB
C
Raw Normal View History

/*
* 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): ______________________________________.
*/
#ifndef JRD_CURSOR_H
#define JRD_CURSOR_H
#include "../common/classes/array.h"
namespace Jrd
{
class thread_db;
class CompilerScratch;
class RecordSource;
// Cursor class (wrapper around the whole access tree)
class Cursor
{
enum State { BOS, POSITIONED, EOS };
struct Impure
{
bool irsb_active;
State irsb_state;
FB_UINT64 irsb_position;
RecordBuffer* irsb_buffer;
};
public:
Cursor(CompilerScratch* csb, const RecordSource* rsb, const VarInvariantArray* invariants,
2009-12-10 02:32:47 +01:00
bool scrollable);
void open(thread_db* tdbb) const;
void close(thread_db* tdbb) const;
bool fetchNext(thread_db* tdbb) const;
bool fetchPrior(thread_db* tdbb) const;
bool fetchFirst(thread_db* tdbb) const;
bool fetchLast(thread_db* tdbb) const;
bool fetchAbsolute(thread_db* tdbb, SINT64 offset) const;
bool fetchRelative(thread_db* tdbb, SINT64 offset) const;
2014-05-23 04:12:56 +02:00
void checkState(jrd_req* request) const;
const RecordSource* getAccessPath() const
{
return m_top;
}
private:
bool validate(thread_db* tdbb) const
{
const jrd_req* const request = tdbb->getRequest();
if (request->req_flags & req_abort)
return false;
if (!request->req_transaction)
return false;
2012-12-19 01:56:57 +01:00
return true;
}
public:
Firebird::MetaName name; // optional name for explicit PSQL cursors
private:
2014-05-23 04:12:56 +02:00
ULONG m_impure;
const RecordSource* const m_top;
const VarInvariantArray* const m_invariants;
const bool m_scrollable;
};
} // namespace
#endif // JRD_CURSOR_H