~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

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
#include <ndb_global.h>
 
17
#include <NdbIndexOperation.hpp>
 
18
#include <Ndb.hpp>
 
19
#include <NdbTransaction.hpp>
 
20
#include "NdbApiSignal.hpp"
 
21
#include <AttributeHeader.hpp>
 
22
#include <signaldata/TcIndx.hpp>
 
23
#include <signaldata/TcKeyReq.hpp>
 
24
#include <signaldata/IndxKeyInfo.hpp>
 
25
#include <signaldata/IndxAttrInfo.hpp>
 
26
 
 
27
NdbIndexOperation::NdbIndexOperation(Ndb* aNdb) :
 
28
  NdbOperation(aNdb, NdbOperation::UniqueIndexAccess),
 
29
  m_theIndex(NULL)
 
30
{
 
31
  m_tcReqGSN = GSN_TCINDXREQ;
 
32
  m_attrInfoGSN = GSN_INDXATTRINFO;
 
33
  m_keyInfoGSN = GSN_INDXKEYINFO;
 
34
 
 
35
  /**
 
36
   * Change receiver type
 
37
   */
 
38
  theReceiver.init(NdbReceiver::NDB_INDEX_OPERATION, this);
 
39
}
 
40
 
 
41
NdbIndexOperation::~NdbIndexOperation()
 
42
{
 
43
}
 
44
 
 
45
/*****************************************************************************
 
46
 * int indxInit();
 
47
 *
 
48
 * Return Value:  Return 0 : init was successful.
 
49
 *                Return -1: In all other case.  
 
50
 * Remark:        Initiates operation record after allocation.
 
51
 *****************************************************************************/
 
52
int
 
53
NdbIndexOperation::indxInit(const NdbIndexImpl * anIndex,
 
54
                            const NdbTableImpl * aTable, 
 
55
                            NdbTransaction* myConnection)
 
56
{
 
57
  NdbOperation::init(aTable, myConnection);
 
58
 
 
59
  switch (anIndex->m_type) {
 
60
  case(NdbDictionary::Index::UniqueHashIndex):
 
61
    break;
 
62
  case(NdbDictionary::Index::Undefined):
 
63
  case(NdbDictionary::Index::OrderedIndex):
 
64
    setErrorCodeAbort(4003);
 
65
    return -1;
 
66
  default:
 
67
    DBUG_ASSERT(0);
 
68
    break;
 
69
  }
 
70
  m_theIndex = anIndex;
 
71
  m_accessTable = anIndex->m_table;
 
72
  theNoOfTupKeyLeft = m_accessTable->getNoOfPrimaryKeys();
 
73
  return 0;
 
74
}
 
75
 
 
76
int NdbIndexOperation::readTuple(NdbOperation::LockMode lm)
 
77
 
78
  switch(lm) {
 
79
  case LM_Read:
 
80
    return readTuple();
 
81
    break;
 
82
  case LM_Exclusive:
 
83
    return readTupleExclusive();
 
84
    break;
 
85
  case LM_CommittedRead:
 
86
    return readTuple();
 
87
    break;
 
88
  case LM_SimpleRead:
 
89
    return readTuple();
 
90
    break;
 
91
  default:
 
92
    return -1;
 
93
  };
 
94
}
 
95
 
 
96
int NdbIndexOperation::insertTuple()
 
97
{
 
98
  setErrorCode(4200);
 
99
  return -1;
 
100
}
 
101
 
 
102
int NdbIndexOperation::readTuple()
 
103
{
 
104
  // First check that index is unique
 
105
 
 
106
  return NdbOperation::readTuple();
 
107
}
 
108
 
 
109
int NdbIndexOperation::readTupleExclusive()
 
110
{
 
111
  // First check that index is unique
 
112
 
 
113
  return NdbOperation::readTupleExclusive();
 
114
}
 
115
 
 
116
int NdbIndexOperation::simpleRead()
 
117
{
 
118
  // First check that index is unique
 
119
 
 
120
  return NdbOperation::readTuple();
 
121
}
 
122
 
 
123
int NdbIndexOperation::dirtyRead()
 
124
{
 
125
  // First check that index is unique
 
126
 
 
127
  return NdbOperation::readTuple();
 
128
}
 
129
 
 
130
int NdbIndexOperation::committedRead()
 
131
{
 
132
  // First check that index is unique
 
133
 
 
134
  return NdbOperation::readTuple();
 
135
}
 
136
 
 
137
int NdbIndexOperation::updateTuple()
 
138
{
 
139
  // First check that index is unique
 
140
 
 
141
  return NdbOperation::updateTuple();
 
142
}
 
143
 
 
144
int NdbIndexOperation::deleteTuple()
 
145
{
 
146
  // First check that index is unique
 
147
 
 
148
  return NdbOperation::deleteTuple();
 
149
}
 
150
 
 
151
int NdbIndexOperation::dirtyUpdate()
 
152
{
 
153
  // First check that index is unique
 
154
 
 
155
  return NdbOperation::dirtyUpdate();
 
156
}
 
157
 
 
158
int NdbIndexOperation::interpretedUpdateTuple()
 
159
{
 
160
  // First check that index is unique
 
161
 
 
162
  return NdbOperation::interpretedUpdateTuple();
 
163
}
 
164
 
 
165
int NdbIndexOperation::interpretedDeleteTuple()
 
166
{
 
167
  // First check that index is unique
 
168
 
 
169
  return NdbOperation::interpretedDeleteTuple();
 
170
}
 
171
 
 
172
const NdbDictionary::Index*
 
173
NdbIndexOperation::getIndex() const
 
174
{
 
175
  return m_theIndex;
 
176
}
 
177
 
 
178
/***************************************************************************
 
179
int receiveTCINDXREF( NdbApiSignal* aSignal)
 
180
 
 
181
Return Value:   Return 0 : send was succesful.
 
182
                Return -1: In all other case.   
 
183
Parameters:     aSignal: the signal object that contains the TCINDXREF signal from TC.
 
184
Remark:         Handles the reception of the TCKEYREF signal.
 
185
***************************************************************************/
 
186
int
 
187
NdbIndexOperation::receiveTCINDXREF( NdbApiSignal* aSignal)
 
188
{
 
189
  return receiveTCKEYREF(aSignal);
 
190
}//NdbIndexOperation::receiveTCINDXREF()