~ubuntu-branches/ubuntu/raring/mysql-5.5/raring-proposed

« back to all changes in this revision

Viewing changes to storage/innobase/btr/btr0sea.c

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include "ha0ha.h"
45
45
 
46
46
/** Flag: has the search system been enabled?
47
 
Protected by btr_search_latch and btr_search_enabled_mutex. */
 
47
Protected by btr_search_latch. */
48
48
UNIV_INTERN char                btr_search_enabled      = TRUE;
49
 
UNIV_INTERN ibool               btr_search_fully_disabled = FALSE;
50
 
 
51
 
/** Mutex protecting btr_search_enabled */
52
 
static mutex_t                  btr_search_enabled_mutex;
53
49
 
54
50
#ifdef UNIV_PFS_MUTEX
55
51
/* Key to register btr_search_enabled_mutex with performance schema */
180
176
 
181
177
        rw_lock_create(btr_search_latch_key, &btr_search_latch,
182
178
                       SYNC_SEARCH_SYS);
183
 
        mutex_create(btr_search_enabled_mutex_key,
184
 
                     &btr_search_enabled_mutex, SYNC_SEARCH_SYS_CONF);
185
179
 
186
180
        btr_search_sys = mem_alloc(sizeof(btr_search_sys_t));
187
181
 
211
205
btr_search_disable(void)
212
206
/*====================*/
213
207
{
214
 
        mutex_enter(&btr_search_enabled_mutex);
 
208
        dict_table_t*   table;
 
209
 
 
210
        mutex_enter(&dict_sys->mutex);
215
211
        rw_lock_x_lock(&btr_search_latch);
216
212
 
217
 
        /* Disable access to hash index, also tell ha_insert_for_fold()
218
 
        stop adding new nodes to hash index, but still allow updating
219
 
        existing nodes */
220
213
        btr_search_enabled = FALSE;
221
214
 
222
 
        /* Clear all block->is_hashed flags and remove all entries
223
 
        from btr_search_sys->hash_index. */
224
 
        buf_pool_drop_hash_index();
225
 
 
226
 
        /* hash index has been cleaned up, disallow any operation to
227
 
        the hash index */
228
 
        btr_search_fully_disabled = TRUE;
229
 
 
230
 
        /* btr_search_enabled_mutex should guarantee this. */
231
 
        ut_ad(!btr_search_enabled);
 
215
        /* Clear the index->search_info->ref_count of every index in
 
216
        the data dictionary cache. */
 
217
        for (table = UT_LIST_GET_FIRST(dict_sys->table_LRU); table;
 
218
             table = UT_LIST_GET_NEXT(table_LRU, table)) {
 
219
 
 
220
                dict_index_t*   index;
 
221
 
 
222
                for (index = dict_table_get_first_index(table); index;
 
223
                     index = dict_table_get_next_index(index)) {
 
224
 
 
225
                        index->search_info->ref_count = 0;
 
226
                }
 
227
        }
 
228
 
 
229
        mutex_exit(&dict_sys->mutex);
 
230
 
 
231
        /* Set all block->index = NULL. */
 
232
        buf_pool_clear_hash_index();
 
233
 
 
234
        /* Clear the adaptive hash index. */
 
235
        hash_table_clear(btr_search_sys->hash_index);
 
236
        mem_heap_empty(btr_search_sys->hash_index->heap);
232
237
 
233
238
        rw_lock_x_unlock(&btr_search_latch);
234
 
        mutex_exit(&btr_search_enabled_mutex);
235
239
}
236
240
 
237
241
/********************************************************************//**
241
245
btr_search_enable(void)
242
246
/*====================*/
243
247
{
244
 
        mutex_enter(&btr_search_enabled_mutex);
245
248
        rw_lock_x_lock(&btr_search_latch);
246
249
 
247
250
        btr_search_enabled = TRUE;
248
 
        btr_search_fully_disabled = FALSE;
249
251
 
250
252
        rw_lock_x_unlock(&btr_search_latch);
251
 
        mutex_exit(&btr_search_enabled_mutex);
252
253
}
253
254
 
254
255
/*****************************************************************//**
471
472
            && (block->n_bytes == info->n_bytes)
472
473
            && (block->left_side == info->left_side)) {
473
474
 
474
 
                if ((block->is_hashed)
 
475
                if ((block->index)
475
476
                    && (block->curr_n_fields == info->n_fields)
476
477
                    && (block->curr_n_bytes == info->n_bytes)
477
478
                    && (block->curr_left_side == info->left_side)) {
500
501
             / BTR_SEARCH_PAGE_BUILD_LIMIT)
501
502
            && (info->n_hash_potential >= BTR_SEARCH_BUILD_LIMIT)) {
502
503
 
503
 
                if ((!block->is_hashed)
 
504
                if ((!block->index)
504
505
                    || (block->n_hash_helps
505
506
                        > 2 * page_get_n_recs(block->frame))
506
507
                    || (block->n_fields != block->curr_n_fields)
532
533
        buf_block_t*    block,  /*!< in: buffer block where cursor positioned */
533
534
        btr_cur_t*      cursor) /*!< in: cursor */
534
535
{
 
536
        dict_index_t*   index;
535
537
        ulint           fold;
536
 
        rec_t*          rec;
537
 
        index_id_t      index_id;
 
538
        const rec_t*    rec;
538
539
 
539
540
        ut_ad(cursor->flag == BTR_CUR_HASH_FAIL);
540
541
#ifdef UNIV_SYNC_DEBUG
545
546
        ut_ad(page_align(btr_cur_get_rec(cursor))
546
547
              == buf_block_get_frame(block));
547
548
 
548
 
        if (!block->is_hashed) {
 
549
        index = block->index;
 
550
 
 
551
        if (!index) {
549
552
 
550
553
                return;
551
554
        }
552
555
 
553
 
        ut_a(block->index == cursor->index);
554
 
        ut_a(!dict_index_is_ibuf(cursor->index));
 
556
        ut_a(index == cursor->index);
 
557
        ut_a(!dict_index_is_ibuf(index));
555
558
 
556
559
        if ((info->n_hash_potential > 0)
557
560
            && (block->curr_n_fields == info->n_fields)
568
571
                        return;
569
572
                }
570
573
 
571
 
                index_id = cursor->index->id;
572
574
                fold = rec_fold(rec,
573
 
                                rec_get_offsets(rec, cursor->index, offsets_,
 
575
                                rec_get_offsets(rec, index, offsets_,
574
576
                                                ULINT_UNDEFINED, &heap),
575
577
                                block->curr_n_fields,
576
 
                                block->curr_n_bytes, index_id);
 
578
                                block->curr_n_bytes, index->id);
577
579
                if (UNIV_LIKELY_NULL(heap)) {
578
580
                        mem_heap_free(heap);
579
581
                }
837
839
{
838
840
        buf_pool_t*     buf_pool;
839
841
        buf_block_t*    block;
840
 
        rec_t*          rec;
 
842
        const rec_t*    rec;
841
843
        ulint           fold;
842
844
        index_id_t      index_id;
843
845
#ifdef notdefined
923
925
 
924
926
        ut_ad(page_rec_is_user_rec(rec));
925
927
 
926
 
        btr_cur_position(index, rec, block, cursor);
 
928
        btr_cur_position(index, (rec_t*) rec, block, cursor);
927
929
 
928
930
        /* Check the validity of the guess within the page */
929
931
 
1053
1055
 
1054
1056
retry:
1055
1057
        rw_lock_s_lock(&btr_search_latch);
1056
 
        page = block->frame;
 
1058
        index = block->index;
1057
1059
 
1058
 
        if (UNIV_LIKELY(!block->is_hashed)) {
 
1060
        if (UNIV_LIKELY(!index)) {
1059
1061
 
1060
1062
                rw_lock_s_unlock(&btr_search_latch);
1061
1063
 
1062
1064
                return;
1063
1065
        }
1064
1066
 
 
1067
        ut_a(!dict_index_is_ibuf(index));
1065
1068
        table = btr_search_sys->hash_index;
1066
1069
 
1067
1070
#ifdef UNIV_SYNC_DEBUG
1072
1075
 
1073
1076
        n_fields = block->curr_n_fields;
1074
1077
        n_bytes = block->curr_n_bytes;
1075
 
        index = block->index;
1076
 
        ut_a(!dict_index_is_ibuf(index));
1077
1078
 
1078
1079
        /* NOTE: The fields of block must not be accessed after
1079
1080
        releasing btr_search_latch, as the index page might only
1083
1084
 
1084
1085
        ut_a(n_fields + n_bytes > 0);
1085
1086
 
 
1087
        page = block->frame;
1086
1088
        n_recs = page_get_n_recs(page);
1087
1089
 
1088
1090
        /* Calculate and cache fold values into an array for fast deletion
1131
1133
 
1132
1134
        rw_lock_x_lock(&btr_search_latch);
1133
1135
 
1134
 
        if (UNIV_UNLIKELY(!block->is_hashed)) {
 
1136
        if (UNIV_UNLIKELY(!block->index)) {
1135
1137
                /* Someone else has meanwhile dropped the hash index */
1136
1138
 
1137
1139
                goto cleanup;
1159
1161
        ut_a(index->search_info->ref_count > 0);
1160
1162
        index->search_info->ref_count--;
1161
1163
 
1162
 
        block->is_hashed = FALSE;
1163
1164
        block->index = NULL;
1164
 
        
 
1165
 
1165
1166
cleanup:
1166
1167
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
1167
1168
        if (UNIV_UNLIKELY(block->n_pointers)) {
1187
1188
}
1188
1189
 
1189
1190
/********************************************************************//**
1190
 
Drops a page hash index when a page is freed from a fseg to the file system.
1191
 
Drops possible hash index if the page happens to be in the buffer pool. */
 
1191
Drops a possible page hash index when a page is evicted from the buffer pool
 
1192
or freed in a file segment. */
1192
1193
UNIV_INTERN
1193
1194
void
1194
1195
btr_search_drop_page_hash_when_freed(
1201
1202
        buf_block_t*    block;
1202
1203
        mtr_t           mtr;
1203
1204
 
1204
 
        if (!buf_page_peek_if_search_hashed(space, page_no)) {
1205
 
 
1206
 
                return;
1207
 
        }
1208
 
 
1209
1205
        mtr_start(&mtr);
1210
1206
 
1211
 
        /* We assume that if the caller has a latch on the page, then the
1212
 
        caller has already dropped the hash index for the page, and we never
1213
 
        get here. Therefore we can acquire the s-latch to the page without
1214
 
        having to fear a deadlock. */
 
1207
        /* If the caller has a latch on the page, then the caller must
 
1208
        have a x-latch on the page and it must have already dropped
 
1209
        the hash index for the page. Because of the x-latch that we
 
1210
        are possibly holding, we cannot s-latch the page, but must
 
1211
        (recursively) x-latch it, even though we are only reading. */
1215
1212
 
1216
 
        block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, NULL,
 
1213
        block = buf_page_get_gen(space, zip_size, page_no, RW_X_LATCH, NULL,
1217
1214
                                 BUF_PEEK_IF_IN_POOL, __FILE__, __LINE__,
1218
1215
                                 &mtr);
1219
 
        /* Because the buffer pool mutex was released by
1220
 
        buf_page_peek_if_search_hashed(), it is possible that the
1221
 
        block was removed from the buffer pool by another thread
1222
 
        before buf_page_get_gen() got a chance to acquire the buffer
1223
 
        pool mutex again.  Thus, we must check for a NULL return. */
1224
1216
 
1225
 
        if (UNIV_LIKELY(block != NULL)) {
 
1217
        if (block && block->index) {
1226
1218
 
1227
1219
                buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
1228
1220
 
1254
1246
        rec_t*          next_rec;
1255
1247
        ulint           fold;
1256
1248
        ulint           next_fold;
1257
 
        index_id_t      index_id;
1258
1249
        ulint           n_cached;
1259
1250
        ulint           n_recs;
1260
1251
        ulint*          folds;
1268
1259
        ut_ad(index);
1269
1260
        ut_a(!dict_index_is_ibuf(index));
1270
1261
 
 
1262
#ifdef UNIV_SYNC_DEBUG
 
1263
        ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
 
1264
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
 
1265
              || rw_lock_own(&(block->lock), RW_LOCK_EX));
 
1266
#endif /* UNIV_SYNC_DEBUG */
 
1267
 
 
1268
        rw_lock_s_lock(&btr_search_latch);
 
1269
 
 
1270
        if (!btr_search_enabled) {
 
1271
                rw_lock_s_unlock(&btr_search_latch);
 
1272
                return;
 
1273
        }
 
1274
 
1271
1275
        table = btr_search_sys->hash_index;
1272
1276
        page = buf_block_get_frame(block);
1273
1277
 
1274
 
#ifdef UNIV_SYNC_DEBUG
1275
 
        ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
1276
 
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
1277
 
              || rw_lock_own(&(block->lock), RW_LOCK_EX));
1278
 
#endif /* UNIV_SYNC_DEBUG */
1279
 
 
1280
 
        rw_lock_s_lock(&btr_search_latch);
1281
 
 
1282
 
        if (block->is_hashed && ((block->curr_n_fields != n_fields)
1283
 
                                 || (block->curr_n_bytes != n_bytes)
1284
 
                                 || (block->curr_left_side != left_side))) {
 
1278
        if (block->index && ((block->curr_n_fields != n_fields)
 
1279
                             || (block->curr_n_bytes != n_bytes)
 
1280
                             || (block->curr_left_side != left_side))) {
1285
1281
 
1286
1282
                rw_lock_s_unlock(&btr_search_latch);
1287
1283
 
1318
1314
 
1319
1315
        n_cached = 0;
1320
1316
 
1321
 
        index_id = btr_page_get_index_id(page);
 
1317
        ut_a(index->id == btr_page_get_index_id(page));
1322
1318
 
1323
1319
        rec = page_rec_get_next(page_get_infimum_rec(page));
1324
1320
 
1333
1329
                }
1334
1330
        }
1335
1331
 
1336
 
        fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
 
1332
        fold = rec_fold(rec, offsets, n_fields, n_bytes, index->id);
1337
1333
 
1338
1334
        if (left_side) {
1339
1335
 
1360
1356
                offsets = rec_get_offsets(next_rec, index, offsets,
1361
1357
                                          n_fields + (n_bytes > 0), &heap);
1362
1358
                next_fold = rec_fold(next_rec, offsets, n_fields,
1363
 
                                     n_bytes, index_id);
 
1359
                                     n_bytes, index->id);
1364
1360
 
1365
1361
                if (fold != next_fold) {
1366
1362
                        /* Insert an entry into the hash index */
1385
1381
 
1386
1382
        rw_lock_x_lock(&btr_search_latch);
1387
1383
 
1388
 
        if (UNIV_UNLIKELY(btr_search_fully_disabled)) {
 
1384
        if (UNIV_UNLIKELY(!btr_search_enabled)) {
1389
1385
                goto exit_func;
1390
1386
        }
1391
1387
 
1392
 
        if (block->is_hashed && ((block->curr_n_fields != n_fields)
1393
 
                                 || (block->curr_n_bytes != n_bytes)
1394
 
                                 || (block->curr_left_side != left_side))) {
 
1388
        if (block->index && ((block->curr_n_fields != n_fields)
 
1389
                             || (block->curr_n_bytes != n_bytes)
 
1390
                             || (block->curr_left_side != left_side))) {
1395
1391
                goto exit_func;
1396
1392
        }
1397
1393
 
1400
1396
        rebuild hash index for a page that is already hashed, we
1401
1397
        have to take care not to increment the counter in that
1402
1398
        case. */
1403
 
        if (!block->is_hashed) {
 
1399
        if (!block->index) {
1404
1400
                index->search_info->ref_count++;
1405
1401
        }
1406
1402
 
1407
 
        block->is_hashed = TRUE;
1408
1403
        block->n_hash_helps = 0;
1409
1404
 
1410
1405
        block->curr_n_fields = n_fields;
1452
1447
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
1453
1448
        ut_ad(rw_lock_own(&(new_block->lock), RW_LOCK_EX));
1454
1449
#endif /* UNIV_SYNC_DEBUG */
1455
 
        ut_a(!new_block->is_hashed || new_block->index == index);
1456
 
        ut_a(!block->is_hashed || block->index == index);
1457
 
        ut_a(!(new_block->is_hashed || block->is_hashed)
 
1450
 
 
1451
        rw_lock_s_lock(&btr_search_latch);
 
1452
 
 
1453
        ut_a(!new_block->index || new_block->index == index);
 
1454
        ut_a(!block->index || block->index == index);
 
1455
        ut_a(!(new_block->index || block->index)
1458
1456
             || !dict_index_is_ibuf(index));
1459
1457
 
1460
 
        rw_lock_s_lock(&btr_search_latch);
1461
 
 
1462
 
        if (new_block->is_hashed) {
 
1458
        if (new_block->index) {
1463
1459
 
1464
1460
                rw_lock_s_unlock(&btr_search_latch);
1465
1461
 
1468
1464
                return;
1469
1465
        }
1470
1466
 
1471
 
        if (block->is_hashed) {
 
1467
        if (block->index) {
1472
1468
 
1473
1469
                n_fields = block->curr_n_fields;
1474
1470
                n_bytes = block->curr_n_bytes;
1505
1501
{
1506
1502
        hash_table_t*   table;
1507
1503
        buf_block_t*    block;
1508
 
        rec_t*          rec;
 
1504
        const rec_t*    rec;
1509
1505
        ulint           fold;
1510
 
        index_id_t      index_id;
 
1506
        dict_index_t*   index;
1511
1507
        ulint           offsets_[REC_OFFS_NORMAL_SIZE];
1512
1508
        mem_heap_t*     heap            = NULL;
1513
1509
        rec_offs_init(offsets_);
1514
1510
 
1515
 
        rec = btr_cur_get_rec(cursor);
1516
 
 
1517
1511
        block = btr_cur_get_block(cursor);
1518
1512
 
1519
1513
#ifdef UNIV_SYNC_DEBUG
1520
1514
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
1521
1515
#endif /* UNIV_SYNC_DEBUG */
1522
1516
 
1523
 
        if (!block->is_hashed) {
 
1517
        index = block->index;
 
1518
 
 
1519
        if (!index) {
1524
1520
 
1525
1521
                return;
1526
1522
        }
1527
1523
 
1528
 
        ut_a(block->index == cursor->index);
 
1524
        ut_a(index == cursor->index);
1529
1525
        ut_a(block->curr_n_fields + block->curr_n_bytes > 0);
1530
 
        ut_a(!dict_index_is_ibuf(cursor->index));
 
1526
        ut_a(!dict_index_is_ibuf(index));
1531
1527
 
1532
1528
        table = btr_search_sys->hash_index;
1533
1529
 
1534
 
        index_id = cursor->index->id;
1535
 
        fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_,
 
1530
        rec = btr_cur_get_rec(cursor);
 
1531
 
 
1532
        fold = rec_fold(rec, rec_get_offsets(rec, index, offsets_,
1536
1533
                                             ULINT_UNDEFINED, &heap),
1537
 
                        block->curr_n_fields, block->curr_n_bytes, index_id);
 
1534
                        block->curr_n_fields, block->curr_n_bytes, index->id);
1538
1535
        if (UNIV_LIKELY_NULL(heap)) {
1539
1536
                mem_heap_free(heap);
1540
1537
        }
 
1538
 
1541
1539
        rw_lock_x_lock(&btr_search_latch);
1542
1540
 
1543
 
        ha_search_and_delete_if_found(table, fold, rec);
 
1541
        if (block->index) {
 
1542
                ut_a(block->index == index);
 
1543
 
 
1544
                ha_search_and_delete_if_found(table, fold, rec);
 
1545
        }
1544
1546
 
1545
1547
        rw_lock_x_unlock(&btr_search_latch);
1546
1548
}
1558
1560
{
1559
1561
        hash_table_t*   table;
1560
1562
        buf_block_t*    block;
 
1563
        dict_index_t*   index;
1561
1564
        rec_t*          rec;
1562
1565
 
1563
1566
        rec = btr_cur_get_rec(cursor);
1568
1571
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
1569
1572
#endif /* UNIV_SYNC_DEBUG */
1570
1573
 
1571
 
        if (!block->is_hashed) {
 
1574
        index = block->index;
 
1575
 
 
1576
        if (!index) {
1572
1577
 
1573
1578
                return;
1574
1579
        }
1575
1580
 
1576
 
        ut_a(block->index == cursor->index);
1577
 
        ut_a(!dict_index_is_ibuf(cursor->index));
 
1581
        ut_a(cursor->index == index);
 
1582
        ut_a(!dict_index_is_ibuf(index));
1578
1583
 
1579
1584
        rw_lock_x_lock(&btr_search_latch);
1580
1585
 
 
1586
        if (!block->index) {
 
1587
 
 
1588
                goto func_exit;
 
1589
        }
 
1590
 
 
1591
        ut_a(block->index == index);
 
1592
 
1581
1593
        if ((cursor->flag == BTR_CUR_HASH)
1582
1594
            && (cursor->n_fields == block->curr_n_fields)
1583
1595
            && (cursor->n_bytes == block->curr_n_bytes)
1588
1600
                ha_search_and_update_if_found(table, cursor->fold, rec,
1589
1601
                                              block, page_rec_get_next(rec));
1590
1602
 
 
1603
func_exit:
1591
1604
                rw_lock_x_unlock(&btr_search_latch);
1592
1605
        } else {
1593
1606
                rw_lock_x_unlock(&btr_search_latch);
1609
1622
{
1610
1623
        hash_table_t*   table;
1611
1624
        buf_block_t*    block;
 
1625
        dict_index_t*   index;
1612
1626
        rec_t*          rec;
1613
1627
        rec_t*          ins_rec;
1614
1628
        rec_t*          next_rec;
1615
 
        index_id_t      index_id;
1616
1629
        ulint           fold;
1617
1630
        ulint           ins_fold;
1618
1631
        ulint           next_fold = 0; /* remove warning (??? bug ???) */
1637
1650
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
1638
1651
#endif /* UNIV_SYNC_DEBUG */
1639
1652
 
1640
 
        if (!block->is_hashed) {
 
1653
        index = block->index;
 
1654
 
 
1655
        if (!index) {
1641
1656
 
1642
1657
                return;
1643
1658
        }
1644
1659
 
1645
 
        ut_a(block->index == cursor->index);
1646
 
        ut_a(!dict_index_is_ibuf(cursor->index));
1647
 
 
1648
 
        index_id = cursor->index->id;
 
1660
        ut_a(index == cursor->index);
 
1661
        ut_a(!dict_index_is_ibuf(index));
1649
1662
 
1650
1663
        n_fields = block->curr_n_fields;
1651
1664
        n_bytes = block->curr_n_bytes;
1654
1667
        ins_rec = page_rec_get_next(rec);
1655
1668
        next_rec = page_rec_get_next(ins_rec);
1656
1669
 
1657
 
        offsets = rec_get_offsets(ins_rec, cursor->index, offsets,
 
1670
        offsets = rec_get_offsets(ins_rec, index, offsets,
1658
1671
                                  ULINT_UNDEFINED, &heap);
1659
 
        ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, index_id);
 
1672
        ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, index->id);
1660
1673
 
1661
1674
        if (!page_rec_is_supremum(next_rec)) {
1662
 
                offsets = rec_get_offsets(next_rec, cursor->index, offsets,
 
1675
                offsets = rec_get_offsets(next_rec, index, offsets,
1663
1676
                                          n_fields + (n_bytes > 0), &heap);
1664
1677
                next_fold = rec_fold(next_rec, offsets, n_fields,
1665
 
                                     n_bytes, index_id);
 
1678
                                     n_bytes, index->id);
1666
1679
        }
1667
1680
 
1668
1681
        if (!page_rec_is_infimum(rec)) {
1669
 
                offsets = rec_get_offsets(rec, cursor->index, offsets,
 
1682
                offsets = rec_get_offsets(rec, index, offsets,
1670
1683
                                          n_fields + (n_bytes > 0), &heap);
1671
 
                fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
 
1684
                fold = rec_fold(rec, offsets, n_fields, n_bytes, index->id);
1672
1685
        } else {
1673
1686
                if (left_side) {
1674
1687
 
1676
1689
 
1677
1690
                        locked = TRUE;
1678
1691
 
 
1692
                        if (!btr_search_enabled) {
 
1693
                                goto function_exit;
 
1694
                        }
 
1695
 
1679
1696
                        ha_insert_for_fold(table, ins_fold, block, ins_rec);
1680
1697
                }
1681
1698
 
1689
1706
                        rw_lock_x_lock(&btr_search_latch);
1690
1707
 
1691
1708
                        locked = TRUE;
 
1709
 
 
1710
                        if (!btr_search_enabled) {
 
1711
                                goto function_exit;
 
1712
                        }
1692
1713
                }
1693
1714
 
1694
1715
                if (!left_side) {
1707
1728
                                rw_lock_x_lock(&btr_search_latch);
1708
1729
 
1709
1730
                                locked = TRUE;
 
1731
 
 
1732
                                if (!btr_search_enabled) {
 
1733
                                        goto function_exit;
 
1734
                                }
1710
1735
                        }
1711
1736
 
1712
1737
                        ha_insert_for_fold(table, ins_fold, block, ins_rec);
1722
1747
                        rw_lock_x_lock(&btr_search_latch);
1723
1748
 
1724
1749
                        locked = TRUE;
 
1750
 
 
1751
                        if (!btr_search_enabled) {
 
1752
                                goto function_exit;
 
1753
                        }
1725
1754
                }
1726
1755
 
1727
1756
                if (!left_side) {
1729
1758
                        ha_insert_for_fold(table, ins_fold, block, ins_rec);
1730
1759
                        /*
1731
1760
                        fputs("Hash insert for ", stderr);
1732
 
                        dict_index_name_print(stderr, cursor->index);
 
1761
                        dict_index_name_print(stderr, index);
1733
1762
                        fprintf(stderr, " fold %lu\n", ins_fold);
1734
1763
                        */
1735
1764
                } else {
1832
1861
 
1833
1862
                        ut_a(!dict_index_is_ibuf(block->index));
1834
1863
 
1835
 
                        offsets = rec_get_offsets((const rec_t*) node->data,
 
1864
                        page_index_id = btr_page_get_index_id(block->frame);
 
1865
 
 
1866
                        offsets = rec_get_offsets(node->data,
1836
1867
                                                  block->index, offsets,
1837
1868
                                                  block->curr_n_fields
1838
1869
                                                  + (block->curr_n_bytes > 0),
1839
1870
                                                  &heap);
1840
1871
 
1841
 
                        page_index_id = btr_page_get_index_id(block->frame);
1842
 
 
1843
 
                        if (UNIV_UNLIKELY
1844
 
                            (!block->is_hashed || node->fold
1845
 
                             != rec_fold((rec_t*)(node->data),
1846
 
                                         offsets,
1847
 
                                         block->curr_n_fields,
1848
 
                                         block->curr_n_bytes,
1849
 
                                         page_index_id))) {
 
1872
                        if (!block->index || node->fold
 
1873
                            != rec_fold(node->data,
 
1874
                                        offsets,
 
1875
                                        block->curr_n_fields,
 
1876
                                        block->curr_n_bytes,
 
1877
                                        page_index_id)) {
1850
1878
                                const page_t*   page = block->frame;
1851
1879
 
1852
1880
                                ok = FALSE;
1862
1890
                                        node->data,
1863
1891
                                        (ullint) page_index_id,
1864
1892
                                        (ulong) node->fold,
1865
 
                                        (ulong) rec_fold((rec_t*)(node->data),
 
1893
                                        (ulong) rec_fold(node->data,
1866
1894
                                                         offsets,
1867
1895
                                                         block->curr_n_fields,
1868
1896
                                                         block->curr_n_bytes,
1869
1897
                                                         page_index_id));
1870
1898
 
1871
1899
                                fputs("InnoDB: Record ", stderr);
1872
 
                                rec_print_new(stderr, (rec_t*)node->data,
1873
 
                                              offsets);
 
1900
                                rec_print_new(stderr, node->data, offsets);
1874
1901
                                fprintf(stderr, "\nInnoDB: on that page."
1875
 
                                        " Page mem address %p, is hashed %lu,"
 
1902
                                        " Page mem address %p, is hashed %p,"
1876
1903
                                        " n fields %lu, n bytes %lu\n"
1877
1904
                                        "InnoDB: side %lu\n",
1878
 
                                        (void*) page, (ulong) block->is_hashed,
 
1905
                                        (void*) page, (void*) block->index,
1879
1906
                                        (ulong) block->curr_n_fields,
1880
1907
                                        (ulong) block->curr_n_bytes,
1881
1908
                                        (ulong) block->curr_left_side);