mariadb/ndb/include/ndbapi/NdbScanOperation.hpp

171 lines
4.9 KiB
C++
Raw Normal View History

/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*****************************************************************************
* Name: NdbScanOperation.hpp
* Include:
* Link:
* Author: Martin Sk<EFBFBD>ld
* Date: 2002-04-01
* Version: 0.1
* Description: Table scan support
* Documentation:
* Adjust: 2002-04-01 Martin Sk<EFBFBD>ld First version.
****************************************************************************/
#ifndef NdbScanOperation_H
#define NdbScanOperation_H
#include <NdbOperation.hpp>
2004-06-10 12:04:30 +02:00
class NdbBlob;
class NdbResultSet;
2004-06-10 12:04:30 +02:00
/**
* @class NdbScanOperation
* @brief Class of scan operations for use in transactions.
*/
2004-05-26 13:24:14 +02:00
class NdbScanOperation : public NdbOperation {
friend class Ndb;
friend class NdbConnection;
friend class NdbResultSet;
friend class NdbOperation;
2004-06-17 23:42:17 +02:00
friend class NdbBlob;
public:
2004-05-26 13:24:14 +02:00
/**
* Type of cursor
*/
enum CursorType {
NoCursor = 0,
ScanCursor = 1,
IndexCursor = 2
};
/**
* Type of cursor
*/
CursorType get_cursor_type() const;
/**
* readTuples returns a NdbResultSet where tuples are stored.
* Tuples are not stored in NdbResultSet until execute(NoCommit)
* has been executed and nextResult has been called.
*
* @param parallel Scan parallelism
2004-05-26 13:24:14 +02:00
* @param batch No of rows to fetch from each fragment at a time
* @param LockMode Scan lock handling
* @returns NdbResultSet.
2004-05-26 13:24:14 +02:00
* @note specifying 0 for batch and parallall means max performance
*/
2004-05-26 13:24:14 +02:00
NdbResultSet* readTuples(LockMode = LM_Read,
Uint32 batch = 0, Uint32 parallel = 0);
2004-05-26 13:24:14 +02:00
inline NdbResultSet* readTuples(int parallell){
return readTuples(LM_Read, 0, parallell);
}
inline NdbResultSet* readTuplesExclusive(int parallell = 0){
return readTuples(LM_Exclusive, 0, parallell);
}
2004-06-10 12:04:30 +02:00
NdbBlob* getBlobHandle(const char* anAttrName);
NdbBlob* getBlobHandle(Uint32 anAttrId);
2004-06-17 23:42:17 +02:00
protected:
CursorType m_cursor_type;
NdbScanOperation(Ndb* aNdb);
virtual ~NdbScanOperation();
int nextResult(bool fetchAllowed = true, bool forceSend = false);
virtual void release();
void closeScan(bool forceSend = false);
int close_impl(class TransporterFacade*, bool forceSend = false);
// Overloaded methods from NdbCursorOperation
int executeCursor(int ProcessorId);
// Overloaded private methods from NdbOperation
int init(const NdbTableImpl* tab, NdbConnection* myConnection);
int prepareSend(Uint32 TC_ConnectPtr, Uint64 TransactionId);
int doSend(int ProcessorId);
void checkForceSend(bool forceSend);
virtual void setErrorCode(int aErrorCode);
virtual void setErrorCodeAbort(int aErrorCode);
2004-05-26 13:24:14 +02:00
NdbResultSet * m_resultSet;
NdbResultSet* getResultSet();
NdbConnection *m_transConnection;
2004-05-26 13:24:14 +02:00
// Scan related variables
Uint32 theParallelism;
Uint32 m_keyInfo;
2004-05-26 13:24:14 +02:00
int getFirstATTRINFOScan();
int doSendScan(int ProcessorId);
int prepareSendScan(Uint32 TC_ConnectPtr, Uint64 TransactionId);
int fix_receivers(Uint32 parallel);
NdbIndexScanOperation::reset_bounds() - Send BOUNDS as KEYINFO - At restart, only reset KEYINFO -- Fix resource shortage at KEYINFO in Dbtc and Dblqh w.r.t scan -- ndb/include/kernel/signaldata/AttrInfo.hpp: Let NdbScanOperation access AttrInfo ndb/include/kernel/signaldata/KeyInfo.hpp: Let NdbScanOperation access AttrInfo ndb/include/kernel/signaldata/ScanFrag.hpp: Send KeyLen in ScanFragReq (for range scans) ndb/include/kernel/signaldata/ScanTab.hpp: Send KeyLen in ScanTabReq (for range scans) ndb/include/ndbapi/NdbConnection.hpp: Function for adding op to list ndb/include/ndbapi/NdbIndexScanOperation.hpp: new method for saving BOUNDS ndb/include/ndbapi/NdbOperation.hpp: Remove bounds stuff from NdbOperation and put it into NdbScanOperation ndb/include/ndbapi/NdbScanOperation.hpp: reset bounds ndb/src/common/debugger/signaldata/Makefile.am: New signal data printer for ScanFrag ndb/src/common/debugger/signaldata/ScanTab.cpp: Fix printout ndb/src/common/debugger/signaldata/SignalDataPrint.cpp: New signal data printer for ScanFrag ndb/src/kernel/blocks/backup/Backup.cpp: Updated ScanFragReq ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Use same sendKeyInfo for both acckeyreq and tux_bounds ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Let range scan use KEYinfo for bounds instead of attrinfo ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Let range scan use KEYinfo for bounds instead of attrinfo ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Handle keyinfo in range scan ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp: Skip useless 5 words in beginning of TuxBounds ndb/src/kernel/blocks/suma/Suma.cpp: Fix SCAN_FRAGREQ ndb/src/ndbapi/NdbConnection.cpp: reset bounds ndb/src/ndbapi/NdbOperation.cpp: Remove bounds ndb/src/ndbapi/NdbOperationDefine.cpp: Remove bounds stuff ndb/src/ndbapi/NdbOperationInt.cpp: Remove bounds stuff ndb/src/ndbapi/NdbScanOperation.cpp: Send BOUNDS in KEYINFO instead of ATTRINFO
2004-10-04 12:59:04 +02:00
void reset_receivers(Uint32 parallel, Uint32 ordered);
Uint32* m_array; // containing all arrays below
2004-05-26 13:24:14 +02:00
Uint32 m_allocated_receivers;
NdbReceiver** m_receivers; // All receivers
2004-05-26 13:24:14 +02:00
Uint32* m_prepared_receivers; // These are to be sent
/**
* owned by API/user thread
*/
2004-05-26 13:24:14 +02:00
Uint32 m_current_api_receiver;
Uint32 m_api_receivers_count;
NdbReceiver** m_api_receivers; // These are currently used by api
/**
* owned by receiver thread
*/
2004-05-26 13:24:14 +02:00
Uint32 m_conf_receivers_count; // NOTE needs mutex to access
NdbReceiver** m_conf_receivers; // receive thread puts them here
/**
* owned by receiver thread
*/
2004-05-26 13:24:14 +02:00
Uint32 m_sent_receivers_count; // NOTE needs mutex to access
NdbReceiver** m_sent_receivers; // receive thread puts them here
int send_next_scan(Uint32 cnt, bool close, bool forceSend = false);
2004-05-26 13:24:14 +02:00
void receiver_delivered(NdbReceiver*);
void receiver_completed(NdbReceiver*);
void execCLOSE_SCAN_REP();
2004-06-17 23:42:17 +02:00
int getKeyFromKEYINFO20(Uint32* data, unsigned size);
2004-05-26 13:24:14 +02:00
NdbOperation* takeOverScanOp(OperationType opType, NdbConnection*);
2004-06-17 23:42:17 +02:00
2004-05-26 13:24:14 +02:00
Uint32 m_ordered;
Uint32 m_read_range_no;
int restart(bool forceSend = false);
};
inline
2004-05-26 13:24:14 +02:00
NdbScanOperation::CursorType
NdbScanOperation::get_cursor_type() const {
return m_cursor_type;
}
#endif