@@ -392,42 +392,35 @@ when loading a table definition.
392
392
@return error code
393
393
@retval DB_SUCCESS if no error occurred
394
394
@retval DB_CORRUPTION if any corruption was noticed */
395
- static
396
- dberr_t
397
- btr_cur_instant_init_low (dict_index_t * index, mtr_t * mtr)
395
+ static dberr_t btr_cur_instant_init_low (dict_index_t * index, mtr_t * mtr)
398
396
{
399
397
ut_ad (index->is_primary ());
400
398
ut_ad (index->n_core_null_bytes == dict_index_t ::NO_CORE_NULL_BYTES);
401
399
ut_ad (index->table ->supports_instant ());
402
400
ut_ad (index->table ->is_readable ());
403
401
404
- page_t * root = btr_root_get ( index, mtr) ;
405
-
406
- if (!root || btr_cur_instant_root_init (index, root)) {
402
+ const fil_space_t * space = index-> table -> space ;
403
+ if (!space) {
404
+ unreadable:
407
405
ib::error () << " Table " << index->table ->name
408
406
<< " has an unreadable root page" ;
409
407
index->table ->corrupted = true ;
410
408
return DB_CORRUPTION;
411
409
}
412
410
411
+ page_t * root = btr_root_get (index, mtr);
412
+
413
+ if (!root || btr_cur_instant_root_init (index, root)) {
414
+ goto unreadable;
415
+ }
416
+
413
417
ut_ad (index->n_core_null_bytes != dict_index_t ::NO_CORE_NULL_BYTES);
414
418
415
419
if (fil_page_get_type (root) == FIL_PAGE_INDEX) {
416
420
ut_ad (!index->is_instant ());
417
421
return DB_SUCCESS;
418
422
}
419
423
420
- /* In a later format, these fields in a FIL_PAGE_TYPE_INSTANT
421
- root page could be repurposed for something else. */
422
- if (memcmp (page_get_infimum_rec (root), " infimum" , 8 )
423
- || memcmp (page_get_supremum_rec (root), " supremum" , 8 )) {
424
- incompatible:
425
- ib::error () << " Table " << index->table ->name
426
- << " contains unrecognizable instant ALTER metadata" ;
427
- index->table ->corrupted = true ;
428
- return DB_CORRUPTION;
429
- }
430
-
431
424
btr_cur_t cur;
432
425
dberr_t err = btr_cur_open_at_index_side (true , index, BTR_SEARCH_LEAF,
433
426
&cur, 0 , mtr);
@@ -466,7 +459,11 @@ btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr)
466
459
467
460
if (info_bits != REC_INFO_MIN_REC_FLAG
468
461
|| (comp && rec_get_status (rec) != REC_STATUS_COLUMNS_ADDED)) {
469
- goto incompatible;
462
+ incompatible:
463
+ ib::error () << " Table " << index->table ->name
464
+ << " contains unrecognizable instant ALTER metadata" ;
465
+ index->table ->corrupted = true ;
466
+ return DB_CORRUPTION;
470
467
}
471
468
472
469
/* Read the metadata. We can get here on server restart
@@ -558,8 +555,7 @@ index root page.
558
555
@param[in] index clustered index that is on its first access
559
556
@param[in] page clustered index root page
560
557
@return whether the page is corrupted */
561
- bool
562
- btr_cur_instant_root_init (dict_index_t * index, const page_t * page)
558
+ bool btr_cur_instant_root_init (dict_index_t * index, const page_t * page)
563
559
{
564
560
ut_ad (page_is_root (page));
565
561
ut_ad (!page_is_comp (page) == !dict_table_is_comp (index->table ));
@@ -590,7 +586,8 @@ btr_cur_instant_root_init(dict_index_t* index, const page_t* page)
590
586
break ;
591
587
}
592
588
593
- uint16_t n = page_get_instant (page);
589
+ const uint16_t n = page_get_instant (page);
590
+
594
591
if (n < index->n_uniq + DATA_ROLL_PTR || n > index->n_fields ) {
595
592
/* The PRIMARY KEY (or hidden DB_ROW_ID) and
596
593
DB_TRX_ID,DB_ROLL_PTR columns must always be present
@@ -599,6 +596,14 @@ btr_cur_instant_root_init(dict_index_t* index, const page_t* page)
599
596
dictionary. */
600
597
return true ;
601
598
}
599
+
600
+ if (memcmp (page_get_infimum_rec (page), " infimum" , 8 )
601
+ || memcmp (page_get_supremum_rec (page), " supremum" , 8 )) {
602
+ /* In a later format, these fields in a FIL_PAGE_TYPE_INSTANT
603
+ root page could be repurposed for something else. */
604
+ return true ;
605
+ }
606
+
602
607
index->n_core_fields = n;
603
608
ut_ad (!index->is_dummy );
604
609
ut_d (index->is_dummy = true );
0 commit comments