@@ -167,17 +167,14 @@ array in the trx system object.
167
167
@param[in] space space where the segment is placed
168
168
@param[in] page_no page number of the segment header
169
169
@param[in] page_size page size
170
- @param[out] rseg_array add rseg reference to this central array
171
- @param[in,out] mtr mini-transaction
172
- @return own: rollback segment object */
170
+ @param[in,out] mtr mini-transaction */
173
171
static
174
- trx_rseg_t *
172
+ void
175
173
trx_rseg_mem_create (
176
174
ulint id,
177
175
ulint space,
178
176
ulint page_no,
179
177
const page_size_t & page_size,
180
- trx_rseg_t ** rseg_array,
181
178
mtr_t * mtr)
182
179
{
183
180
ulint len;
@@ -207,7 +204,7 @@ trx_rseg_mem_create(
207
204
UT_LIST_INIT (rseg->insert_undo_list , &trx_undo_t ::undo_list);
208
205
UT_LIST_INIT (rseg->insert_undo_cached , &trx_undo_t ::undo_list);
209
206
210
- *(( trx_rseg_t **) rseg_array + rseg-> id ) = rseg;
207
+ trx_sys-> rseg_array [id] = rseg;
211
208
212
209
rseg_header = trx_rsegf_get_new (space, page_no, page_size, mtr);
213
210
@@ -256,28 +253,25 @@ trx_rseg_mem_create(
256
253
} else {
257
254
rseg->last_page_no = FIL_NULL;
258
255
}
259
-
260
- return (rseg);
261
256
}
262
257
263
258
/* * Initialize the rollback segments in memory at database startup. */
264
259
void
265
260
trx_rseg_array_init ()
266
261
{
262
+ mtr_t mtr;
263
+
267
264
for (ulint i = 0 ; i < TRX_SYS_N_RSEGS; i++) {
265
+ ut_a (!trx_rseg_get_on_id (i));
268
266
ulint page_no;
269
267
270
- mtr_t mtr;
271
268
mtr.start ();
272
269
trx_sysf_t * sys_header = trx_sysf_get (&mtr);
273
270
274
271
page_no = trx_sysf_rseg_get_page_no (sys_header, i, &mtr);
275
272
276
273
if (page_no != FIL_NULL) {
277
274
ulint space;
278
- trx_rseg_t * rseg = NULL ;
279
-
280
- ut_a (!trx_rseg_get_on_id (i));
281
275
282
276
space = trx_sysf_rseg_get_space (sys_header, i, &mtr);
283
277
@@ -289,17 +283,10 @@ trx_rseg_array_init()
289
283
290
284
ut_ad (found);
291
285
292
- trx_rseg_t ** rseg_array =
293
- static_cast <trx_rseg_t **>(trx_sys->rseg_array );
294
-
295
- rseg = trx_rseg_mem_create (
296
- i, space, page_no, page_size,
297
- rseg_array, &mtr);
298
-
299
- ut_a (rseg->id == i);
300
- } else {
301
- ut_a (trx_sys->rseg_array [i] == NULL );
286
+ trx_rseg_mem_create (
287
+ i, space, page_no, page_size, &mtr);
302
288
}
289
+
303
290
mtr.commit ();
304
291
}
305
292
}
@@ -315,10 +302,8 @@ trx_rseg_create(
315
302
0 means next free slots. */
316
303
{
317
304
mtr_t mtr;
318
- ulint slot_no;
319
- trx_rseg_t * rseg = NULL ;
320
305
321
- mtr_start (& mtr);
306
+ mtr. start ( );
322
307
323
308
/* To obey the latching order, acquire the file space
324
309
x-latch before the trx_sys->mutex. */
@@ -329,46 +314,34 @@ trx_rseg_create(
329
314
case FIL_TYPE_IMPORT:
330
315
ut_ad (0 );
331
316
case FIL_TYPE_TEMPORARY:
332
- mtr_set_log_mode (& mtr, MTR_LOG_NO_REDO);
317
+ mtr. set_log_mode ( MTR_LOG_NO_REDO);
333
318
break ;
334
319
case FIL_TYPE_TABLESPACE:
335
320
break ;
336
321
}
337
322
338
- slot_no = trx_sysf_rseg_find_free (
323
+ page_size_t page_size (space->flags );
324
+ ulint slot_no = trx_sysf_rseg_find_free (
339
325
&mtr, space->purpose == FIL_TYPE_TEMPORARY, nth_free_slot);
340
-
341
- if (slot_no != ULINT_UNDEFINED) {
342
- ulint id;
343
- ulint page_no;
344
- trx_sysf_t * sys_header;
345
- page_size_t page_size (space->flags );
346
-
347
- page_no = trx_rseg_header_create (
326
+ ulint page_no = slot_no == ULINT_UNDEFINED
327
+ ? FIL_NULL
328
+ : trx_rseg_header_create (
348
329
space_id, page_size, ULINT_MAX, slot_no, &mtr);
349
330
350
- if (page_no = = FIL_NULL) {
351
- mtr_commit (&mtr);
331
+ if (page_no ! = FIL_NULL) {
332
+ trx_sysf_t * sys_header = trx_sysf_get (&mtr);
352
333
353
- return (rseg);
354
- }
355
-
356
- sys_header = trx_sysf_get (&mtr);
357
-
358
- id = trx_sysf_rseg_get_space (sys_header, slot_no, &mtr);
334
+ ulint id = trx_sysf_rseg_get_space (
335
+ sys_header, slot_no, &mtr);
359
336
ut_a (id == space_id || trx_sys_is_noredo_rseg_slot (slot_no));
360
337
361
- trx_rseg_t ** rseg_array =
362
- ((trx_rseg_t **) trx_sys->rseg_array );
363
-
364
- rseg = trx_rseg_mem_create (
365
- slot_no, space_id, page_no, page_size,
366
- rseg_array, &mtr);
338
+ trx_rseg_mem_create (
339
+ slot_no, space_id, page_no, page_size, &mtr);
367
340
}
368
341
369
- mtr_commit (& mtr);
342
+ mtr. commit ( );
370
343
371
- return (rseg );
344
+ return (page_no == FIL_NULL ? NULL : trx_sys-> rseg_array [slot_no] );
372
345
}
373
346
374
347
/* *******************************************************************
0 commit comments