~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to storage/falcon/Context.cpp

auto-merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2006 MySQL AB
 
1
/* Copyright � 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc.
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
28
28
#include "View.h"
29
29
#include "SQLError.h"
30
30
#include "Connection.h"
 
31
#include "CycleLock.h"
31
32
 
32
33
#ifdef _DEBUG
33
34
#undef THIS_FILE
100
101
        if (eof)
101
102
                throw SQLEXCEPTION (RUNTIME_ERROR, "record stream is not open");
102
103
 
 
104
        CycleLock cycleLock(table->database);
 
105
        
103
106
        for (;;)
104
107
                {
105
108
                if (record)
106
109
                        close();
107
 
                        
 
110
 
108
111
                Record *candidate = table->fetchNext(recordNumber);
109
 
                
 
112
                RECORD_HISTORY(candidate);
 
113
 
110
114
                if (!candidate)
111
115
                        {
112
116
                        eof = true;
113
117
                        
114
118
                        return false;
115
119
                        }
116
 
                        
 
120
 
117
121
                ++statement->stats.exhaustiveFetches;
118
122
                recordNumber = candidate->recordNumber + 1;
119
123
                record = candidate->fetchVersion (statement->transaction);
120
 
                
 
124
 
121
125
                if (record)
122
126
                        {
123
127
                        checkRecordLimits (statement);
124
128
                        
125
129
                        if (record != candidate)
126
130
                                {
127
 
                                record->addRef();
128
 
                                candidate->release();
 
131
                                record->addRef(REC_HISTORY);
 
132
                                candidate->release(REC_HISTORY);
129
133
                                }
130
134
 
131
135
                        return true;
132
136
                        }
133
137
                        
134
 
                candidate->release();
 
138
                candidate->release(REC_HISTORY);
135
139
                }
136
140
}
137
141
 
152
156
        if (!bitmap)
153
157
                return false;
154
158
 
 
159
        CycleLock cycleLock(table->database);
 
160
 
155
161
        for (;;)
156
162
                {
157
163
                if (record)
167
173
                        
168
174
                ++statement->stats.indexHits;
169
175
                Record *candidate = table->fetch(recordNumber);
 
176
                RECORD_HISTORY(candidate);
170
177
                ++recordNumber;
171
178
                
172
179
                if (candidate)
180
187
                                
181
188
                                if (record != candidate)
182
189
                                        {
183
 
                                        record->addRef();
184
 
                                        candidate->release();
 
190
                                        record->addRef(REC_HISTORY);
 
191
                                        candidate->release(REC_HISTORY);
185
192
                                        }
186
193
                                        
187
194
                                return true;
188
195
                                }
189
196
                                
190
 
                        candidate->release();
 
197
                        candidate->release(REC_HISTORY);
191
198
                        }
192
199
                }
193
200
}
231
238
                close();
232
239
 
233
240
        if ( (record = rec) )
234
 
                record->addRef();
 
241
                record->addRef(REC_HISTORY);
235
242
}
236
243
 
237
244
void Context::checkRecordLimits(Statement *statement)