1
by Clint Byrum
Import upstream version 5.5.17 |
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
|
|
1.1.13
by Marc Deslauriers
Import upstream version 5.5.32 |
14 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
1
by Clint Byrum
Import upstream version 5.5.17 |
15 |
|
16 |
#ifndef NdbReceiver_H
|
|
17 |
#define NdbReceiver_H
|
|
18 |
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL // Not part of public interface |
|
19 |
||
20 |
#include <ndb_types.h> |
|
21 |
||
22 |
class Ndb; |
|
23 |
class NdbTransaction; |
|
24 |
||
25 |
class NdbReceiver |
|
26 |
{
|
|
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 |
|
38 |
};
|
|
39 |
||
40 |
NdbReceiver(Ndb *aNdb); |
|
41 |
int init(ReceiverType type, void* owner); |
|
42 |
void release(); |
|
43 |
~NdbReceiver(); |
|
44 |
||
45 |
Uint32 getId(){ |
|
46 |
return m_id; |
|
47 |
}
|
|
48 |
||
49 |
ReceiverType getType(){ |
|
50 |
return m_type; |
|
51 |
}
|
|
52 |
||
53 |
inline NdbTransaction * getTransaction(); |
|
54 |
void* getOwner(){ |
|
55 |
return m_owner; |
|
56 |
}
|
|
57 |
||
58 |
bool checkMagicNumber() const; |
|
59 |
||
60 |
inline void next(NdbReceiver* next_arg) { m_next = next_arg;} |
|
61 |
inline NdbReceiver* next() { return m_next; } |
|
62 |
||
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; |
|
73 |
||
74 |
/**
|
|
75 |
* At setup
|
|
76 |
*/
|
|
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&); |
|
81 |
||
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; |
|
89 |
||
90 |
Uint32 m_list_index; // When using multiple |
|
91 |
Uint32 m_current_row; |
|
92 |
Uint32 m_result_rows; |
|
93 |
Uint32 m_defined_rows; |
|
94 |
||
95 |
Uint32 m_expected_result_length; |
|
96 |
Uint32 m_received_result_length; |
|
97 |
||
98 |
bool nextResult() const { return m_current_row < m_result_rows; } |
|
99 |
NdbRecAttr* copyout(NdbReceiver&); |
|
100 |
};
|
|
101 |
||
102 |
#ifdef NDB_NO_DROPPED_SIGNAL
|
|
103 |
#include <stdlib.h> |
|
104 |
#endif
|
|
105 |
||
106 |
inline
|
|
107 |
bool
|
|
108 |
NdbReceiver::checkMagicNumber() const { |
|
109 |
bool retVal = (theMagicNumber == 0x11223344); |
|
110 |
#ifdef NDB_NO_DROPPED_SIGNAL
|
|
111 |
if(!retVal){ |
|
112 |
abort(); |
|
113 |
}
|
|
114 |
#endif
|
|
115 |
return retVal; |
|
116 |
}
|
|
117 |
||
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; |
|
125 |
}
|
|
126 |
||
127 |
inline
|
|
128 |
int
|
|
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); |
|
136 |
}
|
|
137 |
||
138 |
inline
|
|
139 |
int
|
|
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); |
|
146 |
}
|
|
147 |
||
148 |
#endif // DOXYGEN_SHOULD_SKIP_INTERNAL |
|
149 |
#endif
|