mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / include / ndbapi / NdbReceiver.hpp
blob42dc85990fe37c7d2edeb7b9647d17f94bf28689
1 /* Copyright (c) 2003-2007 MySQL AB
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef NdbReceiver_H
17 #define NdbReceiver_H
18 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL // Not part of public interface
20 #include <ndb_types.h>
22 class Ndb;
23 class NdbTransaction;
25 class NdbReceiver
27 friend class Ndb;
28 friend class NdbOperation;
29 friend class NdbScanOperation;
30 friend class NdbIndexOperation;
31 friend class NdbIndexScanOperation;
32 friend class NdbTransaction;
33 public:
34 enum ReceiverType { NDB_UNINITIALIZED,
35 NDB_OPERATION = 1,
36 NDB_SCANRECEIVER = 2,
37 NDB_INDEX_OPERATION = 3
40 NdbReceiver(Ndb *aNdb);
41 int init(ReceiverType type, void* owner);
42 void release();
43 ~NdbReceiver();
45 Uint32 getId(){
46 return m_id;
49 ReceiverType getType(){
50 return m_type;
53 inline NdbTransaction * getTransaction();
54 void* getOwner(){
55 return m_owner;
58 bool checkMagicNumber() const;
60 inline void next(NdbReceiver* next_arg) { m_next = next_arg;}
61 inline NdbReceiver* next() { return m_next; }
63 void setErrorCode(int);
64 private:
65 Uint32 theMagicNumber;
66 Ndb* m_ndb;
67 Uint32 m_id;
68 Uint32 m_tcPtrI;
69 Uint32 m_hidden_count;
70 ReceiverType m_type;
71 void* m_owner;
72 NdbReceiver* m_next;
74 /**
75 * At setup
77 class NdbRecAttr * getValue(const class NdbColumnImpl*, char * user_dst_ptr);
78 int do_get_value(NdbReceiver*, Uint32 rows, Uint32 key_size, Uint32 range);
79 void prepareSend();
80 void calculate_batch_size(Uint32, Uint32, Uint32&, Uint32&, Uint32&);
82 int execKEYINFO20(Uint32 info, const Uint32* ptr, Uint32 len);
83 int execTRANSID_AI(const Uint32* ptr, Uint32 len);
84 int execTCOPCONF(Uint32 len);
85 int execSCANOPCONF(Uint32 tcPtrI, Uint32 len, Uint32 rows);
86 class NdbRecAttr* theFirstRecAttr;
87 class NdbRecAttr* theCurrentRecAttr;
88 class NdbRecAttr** m_rows;
90 Uint32 m_list_index; // When using multiple
91 Uint32 m_current_row;
92 Uint32 m_result_rows;
93 Uint32 m_defined_rows;
95 Uint32 m_expected_result_length;
96 Uint32 m_received_result_length;
98 bool nextResult() const { return m_current_row < m_result_rows; }
99 NdbRecAttr* copyout(NdbReceiver&);
102 #ifdef NDB_NO_DROPPED_SIGNAL
103 #include <stdlib.h>
104 #endif
106 inline
107 bool
108 NdbReceiver::checkMagicNumber() const {
109 bool retVal = (theMagicNumber == 0x11223344);
110 #ifdef NDB_NO_DROPPED_SIGNAL
111 if(!retVal){
112 abort();
114 #endif
115 return retVal;
118 inline
119 void
120 NdbReceiver::prepareSend(){
121 m_current_row = 0;
122 m_received_result_length = 0;
123 m_expected_result_length = 0;
124 theCurrentRecAttr = theFirstRecAttr;
127 inline
129 NdbReceiver::execTCOPCONF(Uint32 len){
130 Uint32 tmp = m_received_result_length;
131 m_expected_result_length = len;
132 #ifdef assert
133 assert(!(tmp && !len));
134 #endif
135 return ((bool)len ^ (bool)tmp ? 0 : 1);
138 inline
140 NdbReceiver::execSCANOPCONF(Uint32 tcPtrI, Uint32 len, Uint32 rows){
141 m_tcPtrI = tcPtrI;
142 m_result_rows = rows;
143 Uint32 tmp = m_received_result_length;
144 m_expected_result_length = len;
145 return (tmp == len ? 1 : 0);
148 #endif // DOXYGEN_SHOULD_SKIP_INTERNAL
149 #endif