From 3e9f47d6b01e7943a79a9c6f76e1f271489d84e2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Jun 2004 13:49:22 +0200 Subject: [PATCH] Fix handler w.r.t scan ndb/include/ndbapi/NdbApi.hpp: Removed SchemaOp, SchemaCon ndb/src/ndbapi/NdbRecAttr.cpp: merge error ndb/tools/select_count.cpp: clean up sql/ha_ndbcluster.cc: Fixed handler w.r.t scan sql/ha_ndbcluster.h: Fixed handler w.r.t scan --- ndb/include/ndbapi/NdbApi.hpp | 2 -- ndb/src/ndbapi/NdbRecAttr.cpp | 1 - ndb/tools/select_count.cpp | 27 +++++++++++++-------------- sql/ha_ndbcluster.cc | 30 +++++++++++++++--------------- sql/ha_ndbcluster.h | 4 +++- 5 files changed, 31 insertions(+), 33 deletions(-) diff --git a/ndb/include/ndbapi/NdbApi.hpp b/ndb/include/ndbapi/NdbApi.hpp index 5f55c8951ba..4f721940332 100644 --- a/ndb/include/ndbapi/NdbApi.hpp +++ b/ndb/include/ndbapi/NdbApi.hpp @@ -25,8 +25,6 @@ #include "NdbIndexOperation.hpp" #include "NdbIndexScanOperation.hpp" #include "NdbScanFilter.hpp" -#include "NdbSchemaCon.hpp" -#include "NdbSchemaOp.hpp" #include "NdbRecAttr.hpp" #include "NdbResultSet.hpp" #include "NdbDictionary.hpp" diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index ec10fc1d769..16ac98218ee 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -220,5 +220,4 @@ NdbOut& operator<<(NdbOut& ndbout, const NdbRecAttr &r) } return ndbout; ->>>>>>> } diff --git a/ndb/tools/select_count.cpp b/ndb/tools/select_count.cpp index cae91feb378..2c43af20e64 100644 --- a/ndb/tools/select_count.cpp +++ b/ndb/tools/select_count.cpp @@ -30,8 +30,7 @@ static int select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism, int* count_rows, - UtilTransactions::ScanLock lock, - NdbConnection* pBuddyTrans=0); + UtilTransactions::ScanLock lock); int main(int argc, const char** argv){ const char* _dbname = "TEST_DB"; @@ -95,14 +94,13 @@ int select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism, int* count_rows, - UtilTransactions::ScanLock lock, - NdbConnection* pBuddyTrans){ + UtilTransactions::ScanLock lock){ int retryAttempt = 0; const int retryMax = 100; int check; NdbConnection *pTrans; - NdbOperation *pOp; + NdbScanOperation *pOp; while (true){ @@ -112,7 +110,7 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, return NDBT_FAILED; } - pTrans = pNdb->hupp(pBuddyTrans); + pTrans = pNdb->startTransaction(); if (pTrans == NULL) { const NdbError err = pNdb->getNdbError(); @@ -124,26 +122,27 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, ERR(err); return NDBT_FAILED; } - pOp = pTrans->getNdbOperation(pTab->getName()); + pOp = pTrans->getNdbScanOperation(pTab->getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return NDBT_FAILED; } + NdbResultSet * rs; switch(lock){ case UtilTransactions::SL_ReadHold: - check = pOp->openScanReadHoldLock(parallelism); + rs = pOp->readTuples(NdbScanOperation::LM_Read, 0, parallelism); break; case UtilTransactions::SL_Exclusive: - check = pOp->openScanExclusive(parallelism); + rs = pOp->readTuples(NdbScanOperation::LM_Exclusive, 0, parallelism); break; case UtilTransactions::SL_Read: default: - check = pOp->openScanRead(parallelism); + rs = pOp->readTuples(NdbScanOperation::LM_Dirty, 0, parallelism); } - if( check == -1 ) { + if( rs == 0 ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return NDBT_FAILED; @@ -156,7 +155,7 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, return NDBT_FAILED; } - check = pTrans->executeScan(); + check = pTrans->execute(NoCommit); if( check == -1 ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); @@ -165,11 +164,11 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, int eof; int rows = 0; - eof = pTrans->nextScanResult(); + eof = rs->nextResult(); while(eof == 0){ rows++; - eof = pTrans->nextScanResult(); + eof = rs->nextResult(); } if (eof == -1) { const NdbError err = pTrans->getNdbError(); diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index c76534943b8..e3a63eacd22 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -462,10 +462,10 @@ void ha_ndbcluster::release_metadata() DBUG_VOID_RETURN; } -NdbCursorOperation::LockMode get_ndb_lock_type(enum thr_lock_type type) +NdbScanOperation::LockMode get_ndb_lock_type(enum thr_lock_type type) { return (type == TL_WRITE_ALLOW_WRITE) ? - NdbCursorOperation::LM_Exclusive : NdbCursorOperation::LM_Read; + NdbScanOperation::LM_Exclusive : NdbScanOperation::LM_Read; } static const ulong index_type_flags[]= @@ -795,7 +795,7 @@ inline int ha_ndbcluster::next_result(byte *buf) Set bounds for a ordered index scan, use key_range */ -int ha_ndbcluster::set_bounds(NdbOperation *op, +int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, const key_range *key, int bound) { @@ -843,7 +843,7 @@ int ha_ndbcluster::set_bounds(NdbOperation *op, so if this bound was not EQ, bail out and make a best effort attempt */ - if (bound != NdbOperation::BoundEQ) + if (bound != NdbIndexScanOperation::BoundEQ) break; } @@ -861,7 +861,7 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key, { NdbConnection *trans= m_active_trans; NdbResultSet *cursor; - NdbScanOperation *op; + NdbIndexScanOperation *op; const char *index_name; DBUG_ENTER("ordered_index_scan"); @@ -869,19 +869,19 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key, DBUG_PRINT("enter", ("Starting new ordered scan on %s", m_tabname)); index_name= get_index_name(active_index); - if (!(op= trans->getNdbScanOperation(index_name, m_tabname))) + if (!(op= trans->getNdbIndexScanOperation(index_name, m_tabname))) ERR_RETURN(trans->getNdbError()); - if (!(cursor= op->readTuples(parallelism, get_ndb_lock_type(m_lock.type)))) + if (!(cursor= op->readTuples(get_ndb_lock_type(m_lock.type), 0,parallelism))) ERR_RETURN(trans->getNdbError()); m_active_cursor= cursor; if (start_key && set_bounds(op, start_key, (start_key->flag == HA_READ_KEY_EXACT) ? - NdbOperation::BoundEQ : + NdbIndexScanOperation::BoundEQ : (start_key->flag == HA_READ_AFTER_KEY) ? - NdbOperation::BoundLT : - NdbOperation::BoundLE)) + NdbIndexScanOperation::BoundLT : + NdbIndexScanOperation::BoundLE)) DBUG_RETURN(1); if (end_key) @@ -892,8 +892,8 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key, } else if (set_bounds(op, end_key, (end_key->flag == HA_READ_AFTER_KEY) ? - NdbOperation::BoundGE : - NdbOperation::BoundGT)) + NdbIndexScanOperation::BoundGE : + NdbIndexScanOperation::BoundGT)) DBUG_RETURN(1); } DBUG_RETURN(define_read_attrs(buf, op)); @@ -931,10 +931,10 @@ int ha_ndbcluster::filtered_scan(const byte *key, uint key_len, if (!(op= trans->getNdbScanOperation(m_tabname))) ERR_RETURN(trans->getNdbError()); - if (!(cursor= op->readTuples(parallelism, get_ndb_lock_type(m_lock.type)))) + if (!(cursor= op->readTuples(get_ndb_lock_type(m_lock.type), 0,parallelism))) ERR_RETURN(trans->getNdbError()); m_active_cursor= cursor; - + { // Start scan filter NdbScanFilter sf(op); @@ -1000,7 +1000,7 @@ int ha_ndbcluster::full_table_scan(byte *buf) if (!(op=trans->getNdbScanOperation(m_tabname))) ERR_RETURN(trans->getNdbError()); - if (!(cursor= op->readTuples(parallelism, get_ndb_lock_type(m_lock.type)))) + if (!(cursor= op->readTuples(get_ndb_lock_type(m_lock.type), 0,parallelism))) ERR_RETURN(trans->getNdbError()); m_active_cursor= cursor; DBUG_RETURN(define_read_attrs(buf, op)); diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index df296648272..9c01f839b1f 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -33,6 +33,8 @@ class NdbOperation; // Forward declaration class NdbConnection; // Forward declaration class NdbRecAttr; // Forward declaration class NdbResultSet; // Forward declaration +class NdbScanOperation; +class NdbIndexScanOperation; typedef enum ndb_index_type { UNDEFINED_INDEX = 0, @@ -182,7 +184,7 @@ class ha_ndbcluster: public handler int set_primary_key(NdbOperation *op, const byte *key); int set_primary_key(NdbOperation *op); int set_primary_key_from_old_data(NdbOperation *op, const byte *old_data); - int set_bounds(NdbOperation *ndb_op, const key_range *key, + int set_bounds(NdbIndexScanOperation *ndb_op, const key_range *key, int bound); int key_cmp(uint keynr, const byte * old_row, const byte * new_row); void print_results();