1
/* Copyright (C) 2008 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18
#include "WalkIndex.h"
20
#include "Transaction.h"
23
#include "WalkIndex.h"
24
#include "WalkIndex.h"
25
#include "IndexRootPage.h"
29
static const char THIS_FILE[]=__FILE__;
32
//////////////////////////////////////////////////////////////////////
33
// Construction/Destruction
34
//////////////////////////////////////////////////////////////////////
36
WalkIndex::WalkIndex(Index *index, Transaction *transaction, int flags, IndexKey *lower, IndexKey *upper) : IndexWalker(index, transaction, flags)
39
lowerBound.setKey(lower);
42
upperBound.setKey(upper);
44
nodes = new UCHAR[transaction->database->dbb->pageSize];
48
WalkIndex::~WalkIndex(void)
53
void WalkIndex::setNodes(int32 nextIndexPage, int length, Btn* stuff)
55
memcpy(nodes, stuff, length);
56
endNodes = (Btn*) (nodes + length);
57
node.parseNode((Btn*) nodes, endNodes);
58
nextPage = nextIndexPage;
61
Record* WalkIndex::getNext(bool lockForUpdate)
65
int32 recordNumber = getNextNode();
74
keyLength = indexKey.keyLength;
76
if ( (currentRecord = getValidatedRecord(recordNumber, lockForUpdate)) )
81
int32 WalkIndex::getNextNode(void)
88
recordNumber = node.getNumber();
90
if (recordNumber >= 0)
92
else if (recordNumber == END_LEVEL)
96
node.getNext(endNodes);
98
if (node.node < endNodes)
100
recordNumber = node.getNumber();
101
node.expandKey(&indexKey);
103
if (recordNumber >= 0)
110
IndexRootPage::repositionIndex(index->dbb, index->indexId, this);