1 /*
2 Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #include "API.hpp"
26 #include <AttributeHeader.hpp>
27 #include <signaldata/TcIndx.hpp>
28 #include <signaldata/TcKeyReq.hpp>
29 #include <signaldata/IndxKeyInfo.hpp>
30 #include <signaldata/IndxAttrInfo.hpp>
31
NdbIndexOperation(Ndb * aNdb)32 NdbIndexOperation::NdbIndexOperation(Ndb* aNdb) :
33 NdbOperation(aNdb, NdbOperation::UniqueIndexAccess),
34 m_theIndex(NULL)
35 {
36 m_tcReqGSN = GSN_TCINDXREQ;
37 m_attrInfoGSN = GSN_INDXATTRINFO;
38 m_keyInfoGSN = GSN_INDXKEYINFO;
39
40 /**
41 * Change receiver type
42 */
43 theReceiver.init(NdbReceiver::NDB_INDEX_OPERATION, false, this);
44 }
45
~NdbIndexOperation()46 NdbIndexOperation::~NdbIndexOperation()
47 {
48 }
49
50 /*****************************************************************************
51 * int indxInit();
52 *
53 * Return Value: Return 0 : init was successful.
54 * Return -1: In all other case.
55 * Remark: Initiates operation record after allocation.
56 *****************************************************************************/
57 int
indxInit(const NdbIndexImpl * anIndex,const NdbTableImpl * aTable,NdbTransaction * myConnection,bool useRec)58 NdbIndexOperation::indxInit(const NdbIndexImpl * anIndex,
59 const NdbTableImpl * aTable,
60 NdbTransaction* myConnection,
61 bool useRec)
62 {
63 NdbOperation::init(aTable, myConnection, useRec);
64
65 switch (anIndex->m_type) {
66 case(NdbDictionary::Index::UniqueHashIndex):
67 break;
68 case(NdbDictionary::Index::Undefined):
69 case(NdbDictionary::Index::OrderedIndex):
70 setErrorCodeAbort(4003);
71 return -1;
72 default:
73 DBUG_ASSERT(0);
74 break;
75 }
76 m_theIndex = anIndex;
77 m_accessTable = anIndex->m_table;
78 theNoOfTupKeyLeft = m_accessTable->getNoOfPrimaryKeys();
79 return 0;
80 }
81
readTuple(NdbOperation::LockMode lm)82 int NdbIndexOperation::readTuple(NdbOperation::LockMode lm)
83 {
84 switch(lm) {
85 case LM_Read:
86 return readTuple();
87 break;
88 case LM_Exclusive:
89 return readTupleExclusive();
90 break;
91 case LM_CommittedRead:
92 return readTuple();
93 break;
94 case LM_SimpleRead:
95 return readTuple();
96 break;
97 default:
98 return -1;
99 };
100 }
101
insertTuple()102 int NdbIndexOperation::insertTuple()
103 {
104 setErrorCode(4200);
105 return -1;
106 }
107
readTuple()108 int NdbIndexOperation::readTuple()
109 {
110 // First check that index is unique
111
112 return NdbOperation::readTuple();
113 }
114
readTupleExclusive()115 int NdbIndexOperation::readTupleExclusive()
116 {
117 // First check that index is unique
118
119 return NdbOperation::readTupleExclusive();
120 }
121
simpleRead()122 int NdbIndexOperation::simpleRead()
123 {
124 // First check that index is unique
125
126 return NdbOperation::readTuple();
127 }
128
dirtyRead()129 int NdbIndexOperation::dirtyRead()
130 {
131 // First check that index is unique
132
133 return NdbOperation::readTuple();
134 }
135
committedRead()136 int NdbIndexOperation::committedRead()
137 {
138 // First check that index is unique
139
140 return NdbOperation::readTuple();
141 }
142
updateTuple()143 int NdbIndexOperation::updateTuple()
144 {
145 // First check that index is unique
146
147 return NdbOperation::updateTuple();
148 }
149
deleteTuple()150 int NdbIndexOperation::deleteTuple()
151 {
152 // First check that index is unique
153
154 return NdbOperation::deleteTuple();
155 }
156
dirtyUpdate()157 int NdbIndexOperation::dirtyUpdate()
158 {
159 // First check that index is unique
160
161 return NdbOperation::dirtyUpdate();
162 }
163
interpretedUpdateTuple()164 int NdbIndexOperation::interpretedUpdateTuple()
165 {
166 // First check that index is unique
167
168 return NdbOperation::interpretedUpdateTuple();
169 }
170
interpretedDeleteTuple()171 int NdbIndexOperation::interpretedDeleteTuple()
172 {
173 // First check that index is unique
174
175 return NdbOperation::interpretedDeleteTuple();
176 }
177
178 const NdbDictionary::Index*
getIndex() const179 NdbIndexOperation::getIndex() const
180 {
181 return m_theIndex;
182 }
183
184 /***************************************************************************
185 int receiveTCINDXREF( NdbApiSignal* aSignal)
186
187 Return Value: Return 0 : send was succesful.
188 Return -1: In all other case.
189 Parameters: aSignal: the signal object that contains the TCINDXREF signal from TC.
190 Remark: Handles the reception of the TCKEYREF signal.
191 ***************************************************************************/
192 int
receiveTCINDXREF(const NdbApiSignal * aSignal)193 NdbIndexOperation::receiveTCINDXREF(const NdbApiSignal* aSignal)
194 {
195 return receiveTCKEYREF(aSignal);
196 }//NdbIndexOperation::receiveTCINDXREF()
197