~vadim-tk/percona-server/percona-galera-5.1.57

« back to all changes in this revision

Viewing changes to storage/ndb/src/ndbapi/NdbTransactionScan.cpp

  • Committer: root
  • Date: 2011-07-10 16:09:24 UTC
  • Revision ID: root@r815.office.percona.com-20110710160924-fyffqsbaclgu6vui
Initial port

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
 
 
17
#include <ndb_global.h>
 
18
 
 
19
#include <Ndb.hpp>
 
20
#include <NdbTransaction.hpp>
 
21
#include <NdbOperation.hpp>
 
22
#include <NdbScanOperation.hpp>
 
23
#include "NdbApiSignal.hpp"
 
24
#include "TransporterFacade.hpp"
 
25
#include "NdbUtil.hpp"
 
26
#include "API.hpp"
 
27
#include "NdbImpl.hpp"
 
28
 
 
29
#include <signaldata/ScanTab.hpp>
 
30
 
 
31
#include <NdbOut.hpp>
 
32
 
 
33
 
 
34
/***************************************************************************
 
35
 * int  receiveSCAN_TABREF(NdbApiSignal* aSignal)
 
36
 *
 
37
 *  This means the scan could not be started, set status(s) to indicate 
 
38
 *  the failure
 
39
 *
 
40
 ****************************************************************************/
 
41
int                     
 
42
NdbTransaction::receiveSCAN_TABREF(NdbApiSignal* aSignal){
 
43
  const ScanTabRef * ref = CAST_CONSTPTR(ScanTabRef, aSignal->getDataPtr());
 
44
  
 
45
  if(checkState_TransId(&ref->transId1)){
 
46
    theScanningOp->setErrorCode(ref->errorCode);
 
47
    theScanningOp->execCLOSE_SCAN_REP();
 
48
    if(!ref->closeNeeded){
 
49
      return 0;
 
50
    }
 
51
 
 
52
    /**
 
53
     * Setup so that close_impl will actually perform a close
 
54
     *   and not "close scan"-optimze it away
 
55
     */
 
56
    theScanningOp->m_conf_receivers_count++;
 
57
    theScanningOp->m_conf_receivers[0] = theScanningOp->m_receivers[0];
 
58
    theScanningOp->m_conf_receivers[0]->m_tcPtrI = ~0;
 
59
    return 0;
 
60
  } else {
 
61
#ifdef NDB_NO_DROPPED_SIGNAL
 
62
    abort();
 
63
#endif
 
64
  }
 
65
 
 
66
  return -1;
 
67
}
 
68
 
 
69
/*****************************************************************************
 
70
 * int  receiveSCAN_TABCONF(NdbApiSignal* aSignal)
 
71
 *
 
72
 * Receive SCAN_TABCONF
 
73
 * If scanStatus == 0 there is more records to read. Since signals may be 
 
74
 * received in any order we have to go through the lists with saved signals 
 
75
 * and check if all expected signals are there so that we can start to 
 
76
 * execute them.
 
77
 *
 
78
 * If scanStatus > 0 this indicates that the scan is finished and there are 
 
79
 * no more data to be read.
 
80
 * 
 
81
 *****************************************************************************/
 
82
int                     
 
83
NdbTransaction::receiveSCAN_TABCONF(NdbApiSignal* aSignal, 
 
84
                                   const Uint32 * ops, Uint32 len)
 
85
{
 
86
  const ScanTabConf * conf = CAST_CONSTPTR(ScanTabConf, aSignal->getDataPtr());
 
87
  if(checkState_TransId(&conf->transId1)){
 
88
    
 
89
    if (conf->requestInfo == ScanTabConf::EndOfData) {
 
90
      theScanningOp->execCLOSE_SCAN_REP();
 
91
      return 0;
 
92
    }
 
93
 
 
94
    for(Uint32 i = 0; i<len; i += 3){
 
95
      Uint32 opCount, totalLen;
 
96
      Uint32 ptrI = * ops++;
 
97
      Uint32 tcPtrI = * ops++;
 
98
      Uint32 info = * ops++;
 
99
      opCount  = ScanTabConf::getRows(info);
 
100
      totalLen = ScanTabConf::getLength(info);
 
101
      
 
102
      void * tPtr = theNdb->int2void(ptrI);
 
103
      assert(tPtr); // For now
 
104
      NdbReceiver* tOp = theNdb->void2rec(tPtr);
 
105
      if (tOp && tOp->checkMagicNumber())
 
106
      {
 
107
        if (tcPtrI == RNIL && opCount == 0)
 
108
          theScanningOp->receiver_completed(tOp);
 
109
        else if (tOp->execSCANOPCONF(tcPtrI, totalLen, opCount))
 
110
          theScanningOp->receiver_delivered(tOp);
 
111
      }
 
112
    }
 
113
    return 0;
 
114
  } else {
 
115
#ifdef NDB_NO_DROPPED_SIGNAL
 
116
    abort();
 
117
#endif
 
118
  }
 
119
  
 
120
  return -1;
 
121
}