@@ -113,8 +113,135 @@ purge_state_t
113
113
trx_purge_state (void );
114
114
/* =================*/
115
115
116
- // Forward declaration
117
- struct TrxUndoRsegsIterator ;
116
+ /* * Rollback segements from a given transaction with trx-no
117
+ scheduled for purge. */
118
+ class TrxUndoRsegs {
119
+ private:
120
+ typedef std::vector<trx_rseg_t *, ut_allocator<trx_rseg_t *> >
121
+ trx_rsegs_t ;
122
+ public:
123
+ typedef trx_rsegs_t ::iterator iterator;
124
+
125
+ /* * Default constructor */
126
+ TrxUndoRsegs () : m_trx_no() { }
127
+
128
+ explicit TrxUndoRsegs (trx_id_t trx_no)
129
+ :
130
+ m_trx_no(trx_no)
131
+ {
132
+ // Do nothing
133
+ }
134
+
135
+ /* * Get transaction number
136
+ @return trx_id_t - get transaction number. */
137
+ trx_id_t get_trx_no () const
138
+ {
139
+ return (m_trx_no);
140
+ }
141
+
142
+ /* * Add rollback segment.
143
+ @param rseg rollback segment to add. */
144
+ void push_back (trx_rseg_t * rseg)
145
+ {
146
+ m_rsegs.push_back (rseg);
147
+ }
148
+
149
+ /* * Erase the element pointed by given iterator.
150
+ @param[in] iterator iterator */
151
+ void erase (iterator& it)
152
+ {
153
+ m_rsegs.erase (it);
154
+ }
155
+
156
+ /* * Number of registered rsegs.
157
+ @return size of rseg list. */
158
+ ulint size () const
159
+ {
160
+ return (m_rsegs.size ());
161
+ }
162
+
163
+ /* *
164
+ @return an iterator to the first element */
165
+ iterator begin ()
166
+ {
167
+ return (m_rsegs.begin ());
168
+ }
169
+
170
+ /* *
171
+ @return an iterator to the end */
172
+ iterator end ()
173
+ {
174
+ return (m_rsegs.end ());
175
+ }
176
+
177
+ /* * Append rollback segments from referred instance to current
178
+ instance. */
179
+ void append (const TrxUndoRsegs& append_from)
180
+ {
181
+ ut_ad (get_trx_no () == append_from.get_trx_no ());
182
+
183
+ m_rsegs.insert (m_rsegs.end (),
184
+ append_from.m_rsegs .begin (),
185
+ append_from.m_rsegs .end ());
186
+ }
187
+
188
+ /* * Compare two TrxUndoRsegs based on trx_no.
189
+ @param elem1 first element to compare
190
+ @param elem2 second element to compare
191
+ @return true if elem1 > elem2 else false.*/
192
+ bool operator ()(const TrxUndoRsegs& lhs, const TrxUndoRsegs& rhs)
193
+ {
194
+ return (lhs.m_trx_no > rhs.m_trx_no );
195
+ }
196
+
197
+ /* * Compiler defined copy-constructor/assignment operator
198
+ should be fine given that there is no reference to a memory
199
+ object outside scope of class object.*/
200
+
201
+ private:
202
+ /* * The rollback segments transaction number. */
203
+ trx_id_t m_trx_no;
204
+
205
+ /* * Rollback segments of a transaction, scheduled for purge. */
206
+ trx_rsegs_t m_rsegs;
207
+ };
208
+
209
+ typedef std::priority_queue<
210
+ TrxUndoRsegs,
211
+ std::vector<TrxUndoRsegs, ut_allocator<TrxUndoRsegs> >,
212
+ TrxUndoRsegs> purge_pq_t ;
213
+
214
+ /* *
215
+ Chooses the rollback segment with the smallest trx_no. */
216
+ struct TrxUndoRsegsIterator {
217
+
218
+ /* * Constructor */
219
+ TrxUndoRsegsIterator (trx_purge_t * purge_sys);
220
+
221
+ /* * Sets the next rseg to purge in m_purge_sys.
222
+ @return page size of the table for which the log is.
223
+ NOTE: if rseg is NULL when this function returns this means that
224
+ there are no rollback segments to purge and then the returned page
225
+ size object should not be used. */
226
+ const page_size_t set_next ();
227
+
228
+ private:
229
+ // Disable copying
230
+ TrxUndoRsegsIterator (const TrxUndoRsegsIterator&);
231
+ TrxUndoRsegsIterator& operator =(const TrxUndoRsegsIterator&);
232
+
233
+ /* * The purge system pointer */
234
+ trx_purge_t * m_purge_sys;
235
+
236
+ /* * The current element to process */
237
+ TrxUndoRsegs m_trx_undo_rsegs;
238
+
239
+ /* * Track the current element in m_trx_undo_rseg */
240
+ TrxUndoRsegs::iterator m_iter;
241
+
242
+ /* * Sentinel value */
243
+ static const TrxUndoRsegs NullElement;
244
+ };
118
245
119
246
/* * This is the purge pointer/iterator. We need both the undo no and the
120
247
transaction no up to which purge has parsed and applied the records. */
@@ -467,38 +594,6 @@ struct trx_purge_rec_t {
467
594
roll_ptr_t roll_ptr; /* !< File pointr to UNDO record */
468
595
};
469
596
470
- /* *
471
- Chooses the rollback segment with the smallest trx_no. */
472
- struct TrxUndoRsegsIterator {
473
-
474
- /* * Constructor */
475
- TrxUndoRsegsIterator (trx_purge_t * purge_sys);
476
-
477
- /* * Sets the next rseg to purge in m_purge_sys.
478
- @return page size of the table for which the log is.
479
- NOTE: if rseg is NULL when this function returns this means that
480
- there are no rollback segments to purge and then the returned page
481
- size object should not be used. */
482
- const page_size_t set_next ();
483
-
484
- private:
485
- // Disable copying
486
- TrxUndoRsegsIterator (const TrxUndoRsegsIterator&);
487
- TrxUndoRsegsIterator& operator =(const TrxUndoRsegsIterator&);
488
-
489
- /* * The purge system pointer */
490
- trx_purge_t * m_purge_sys;
491
-
492
- /* * The current element to process */
493
- TrxUndoRsegs m_trx_undo_rsegs;
494
-
495
- /* * Track the current element in m_trx_undo_rseg */
496
- TrxUndoRsegs::iterator m_iter;
497
-
498
- /* * Sentinel value */
499
- static const TrxUndoRsegs NullElement;
500
- };
501
-
502
597
#ifndef UNIV_NONINL
503
598
#include " trx0purge.ic"
504
599
#endif /* UNIV_NOINL */
0 commit comments