~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
4
4
Copyright (c) 2008, Google Inc.
5
5
 
6
6
Portions of this file contain modifications contributed and copyrighted by
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
49
 
50
 
/** Mutex protecting btr_search_enabled */
51
 
static mutex_t                  btr_search_enabled_mutex;
52
 
 
53
50
/** A dummy variable to fool the compiler */
54
51
UNIV_INTERN ulint               btr_search_this_is_zero = 0;
55
52
 
140
137
        be enough free space in the hash table. */
141
138
 
142
139
        if (heap->free_block == NULL) {
143
 
                buf_block_t*    block = buf_block_alloc(0);
 
140
                buf_block_t*    block = buf_block_alloc();
144
141
 
145
142
                rw_lock_x_lock(&btr_search_latch);
146
143
 
168
165
        btr_search_latch_temp = mem_alloc(sizeof(rw_lock_t));
169
166
 
170
167
        rw_lock_create(&btr_search_latch, SYNC_SEARCH_SYS);
171
 
        mutex_create(&btr_search_enabled_mutex, SYNC_SEARCH_SYS_CONF);
172
168
 
173
169
        btr_search_sys = mem_alloc(sizeof(btr_search_sys_t));
174
170
 
198
194
btr_search_disable(void)
199
195
/*====================*/
200
196
{
201
 
        mutex_enter(&btr_search_enabled_mutex);
 
197
        dict_table_t*   table;
 
198
 
 
199
        mutex_enter(&dict_sys->mutex);
202
200
        rw_lock_x_lock(&btr_search_latch);
203
201
 
204
202
        btr_search_enabled = FALSE;
205
203
 
206
 
        /* Clear all block->is_hashed flags and remove all entries
207
 
        from btr_search_sys->hash_index. */
208
 
        buf_pool_drop_hash_index();
209
 
 
210
 
        /* btr_search_enabled_mutex should guarantee this. */
211
 
        ut_ad(!btr_search_enabled);
 
204
        /* Clear the index->search_info->ref_count of every index in
 
205
        the data dictionary cache. */
 
206
        for (table = UT_LIST_GET_FIRST(dict_sys->table_LRU); table;
 
207
             table = UT_LIST_GET_NEXT(table_LRU, table)) {
 
208
 
 
209
                dict_index_t*   index;
 
210
 
 
211
                for (index = dict_table_get_first_index(table); index;
 
212
                     index = dict_table_get_next_index(index)) {
 
213
 
 
214
                        index->search_info->ref_count = 0;
 
215
                }
 
216
        }
 
217
 
 
218
        mutex_exit(&dict_sys->mutex);
 
219
 
 
220
        /* Set all block->index = NULL. */
 
221
        buf_pool_clear_hash_index();
 
222
 
 
223
        /* Clear the adaptive hash index. */
 
224
        hash_table_clear(btr_search_sys->hash_index);
 
225
        mem_heap_empty(btr_search_sys->hash_index->heap);
212
226
 
213
227
        rw_lock_x_unlock(&btr_search_latch);
214
 
        mutex_exit(&btr_search_enabled_mutex);
215
228
}
216
229
 
217
230
/********************************************************************//**
221
234
btr_search_enable(void)
222
235
/*====================*/
223
236
{
224
 
        mutex_enter(&btr_search_enabled_mutex);
225
237
        rw_lock_x_lock(&btr_search_latch);
226
238
 
227
239
        btr_search_enabled = TRUE;
228
240
 
229
241
        rw_lock_x_unlock(&btr_search_latch);
230
 
        mutex_exit(&btr_search_enabled_mutex);
231
242
}
232
243
 
233
244
/*****************************************************************//**
450
461
            && (block->n_bytes == info->n_bytes)
451
462
            && (block->left_side == info->left_side)) {
452
463
 
453
 
                if ((block->is_hashed)
 
464
                if ((block->index)
454
465
                    && (block->curr_n_fields == info->n_fields)
455
466
                    && (block->curr_n_bytes == info->n_bytes)
456
467
                    && (block->curr_left_side == info->left_side)) {
479
490
             / BTR_SEARCH_PAGE_BUILD_LIMIT)
480
491
            && (info->n_hash_potential >= BTR_SEARCH_BUILD_LIMIT)) {
481
492
 
482
 
                if ((!block->is_hashed)
 
493
                if ((!block->index)
483
494
                    || (block->n_hash_helps
484
495
                        > 2 * page_get_n_recs(block->frame))
485
496
                    || (block->n_fields != block->curr_n_fields)
511
522
        buf_block_t*    block,  /*!< in: buffer block where cursor positioned */
512
523
        btr_cur_t*      cursor) /*!< in: cursor */
513
524
{
514
 
        ulint   fold;
515
 
        rec_t*  rec;
516
 
        dulint  index_id;
 
525
        dict_index_t*   index;
 
526
        ulint           fold;
 
527
        const rec_t*    rec;
517
528
 
518
529
        ut_ad(cursor->flag == BTR_CUR_HASH_FAIL);
519
530
#ifdef UNIV_SYNC_DEBUG
524
535
        ut_ad(page_align(btr_cur_get_rec(cursor))
525
536
              == buf_block_get_frame(block));
526
537
 
527
 
        if (!block->is_hashed) {
 
538
        index = block->index;
 
539
 
 
540
        if (!index) {
528
541
 
529
542
                return;
530
543
        }
531
544
 
532
 
        ut_a(block->index == cursor->index);
533
 
        ut_a(!dict_index_is_ibuf(cursor->index));
 
545
        ut_a(index == cursor->index);
 
546
        ut_a(!dict_index_is_ibuf(index));
534
547
 
535
548
        if ((info->n_hash_potential > 0)
536
549
            && (block->curr_n_fields == info->n_fields)
547
560
                        return;
548
561
                }
549
562
 
550
 
                index_id = cursor->index->id;
551
563
                fold = rec_fold(rec,
552
 
                                rec_get_offsets(rec, cursor->index, offsets_,
 
564
                                rec_get_offsets(rec, index, offsets_,
553
565
                                                ULINT_UNDEFINED, &heap),
554
566
                                block->curr_n_fields,
555
 
                                block->curr_n_bytes, index_id);
 
567
                                block->curr_n_bytes, index->id);
556
568
                if (UNIV_LIKELY_NULL(heap)) {
557
569
                        mem_heap_free(heap);
558
570
                }
815
827
        mtr_t*          mtr)            /*!< in: mtr */
816
828
{
817
829
        buf_block_t*    block;
818
 
        rec_t*          rec;
 
830
        const rec_t*    rec;
819
831
        ulint           fold;
820
832
        dulint          index_id;
821
833
#ifdef notdefined
823
835
        btr_pcur_t      pcur;
824
836
#endif
825
837
        ut_ad(index && info && tuple && cursor && mtr);
 
838
        ut_ad(!dict_index_is_ibuf(index));
826
839
        ut_ad((latch_mode == BTR_SEARCH_LEAF)
827
840
              || (latch_mode == BTR_MODIFY_LEAF));
828
841
 
900
913
 
901
914
        ut_ad(page_rec_is_user_rec(rec));
902
915
 
903
 
        btr_cur_position(index, rec, block, cursor);
 
916
        btr_cur_position(index, (rec_t*) rec, block, cursor);
904
917
 
905
918
        /* Check the validity of the guess within the page */
906
919
 
1031
1044
 
1032
1045
retry:
1033
1046
        rw_lock_s_lock(&btr_search_latch);
1034
 
        page = block->frame;
 
1047
        index = block->index;
1035
1048
 
1036
 
        if (UNIV_LIKELY(!block->is_hashed)) {
 
1049
        if (UNIV_LIKELY(!index)) {
1037
1050
 
1038
1051
                rw_lock_s_unlock(&btr_search_latch);
1039
1052
 
1040
1053
                return;
1041
1054
        }
1042
1055
 
 
1056
        ut_a(!dict_index_is_ibuf(index));
1043
1057
        table = btr_search_sys->hash_index;
1044
1058
 
1045
1059
#ifdef UNIV_SYNC_DEBUG
1050
1064
 
1051
1065
        n_fields = block->curr_n_fields;
1052
1066
        n_bytes = block->curr_n_bytes;
1053
 
        index = block->index;
1054
 
        ut_a(!dict_index_is_ibuf(index));
1055
1067
 
1056
1068
        /* NOTE: The fields of block must not be accessed after
1057
1069
        releasing btr_search_latch, as the index page might only
1061
1073
 
1062
1074
        ut_a(n_fields + n_bytes > 0);
1063
1075
 
 
1076
        page = block->frame;
1064
1077
        n_recs = page_get_n_recs(page);
1065
1078
 
1066
1079
        /* Calculate and cache fold values into an array for fast deletion
1109
1122
 
1110
1123
        rw_lock_x_lock(&btr_search_latch);
1111
1124
 
1112
 
        if (UNIV_UNLIKELY(!block->is_hashed)) {
 
1125
        if (UNIV_UNLIKELY(!block->index)) {
1113
1126
                /* Someone else has meanwhile dropped the hash index */
1114
1127
 
1115
1128
                goto cleanup;
1137
1150
        ut_a(index->search_info->ref_count > 0);
1138
1151
        index->search_info->ref_count--;
1139
1152
 
1140
 
        block->is_hashed = FALSE;
1141
1153
        block->index = NULL;
1142
 
        
 
1154
 
1143
1155
cleanup:
1144
1156
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
1145
1157
        if (UNIV_UNLIKELY(block->n_pointers)) {
1165
1177
}
1166
1178
 
1167
1179
/********************************************************************//**
1168
 
Drops a page hash index when a page is freed from a fseg to the file system.
1169
 
Drops possible hash index if the page happens to be in the buffer pool. */
 
1180
Drops a possible page hash index when a page is evicted from the buffer pool
 
1181
or freed in a file segment. */
1170
1182
UNIV_INTERN
1171
1183
void
1172
1184
btr_search_drop_page_hash_when_freed(
1179
1191
        buf_block_t*    block;
1180
1192
        mtr_t           mtr;
1181
1193
 
1182
 
        if (!buf_page_peek_if_search_hashed(space, page_no)) {
1183
 
 
1184
 
                return;
1185
 
        }
1186
 
 
1187
1194
        mtr_start(&mtr);
1188
1195
 
1189
 
        /* We assume that if the caller has a latch on the page, then the
1190
 
        caller has already dropped the hash index for the page, and we never
1191
 
        get here. Therefore we can acquire the s-latch to the page without
1192
 
        having to fear a deadlock. */
1193
 
 
1194
 
        block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, NULL,
1195
 
                                BUF_GET_IF_IN_POOL, __FILE__, __LINE__,
1196
 
                                &mtr);
1197
 
        /* Because the buffer pool mutex was released by
1198
 
        buf_page_peek_if_search_hashed(), it is possible that the
1199
 
        block was removed from the buffer pool by another thread
1200
 
        before buf_page_get_gen() got a chance to acquire the buffer
1201
 
        pool mutex again.  Thus, we must check for a NULL return. */
1202
 
 
1203
 
        if (UNIV_LIKELY(block != NULL)) {
 
1196
        /* If the caller has a latch on the page, then the caller must
 
1197
        have a x-latch on the page and it must have already dropped
 
1198
        the hash index for the page. Because of the x-latch that we
 
1199
        are possibly holding, we cannot s-latch the page, but must
 
1200
        (recursively) x-latch it, even though we are only reading. */
 
1201
 
 
1202
        block = buf_page_get_gen(space, zip_size, page_no, RW_X_LATCH, NULL,
 
1203
                                 BUF_PEEK_IF_IN_POOL, __FILE__, __LINE__,
 
1204
                                 &mtr);
 
1205
 
 
1206
        if (block && block->index) {
1204
1207
 
1205
1208
                buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
1206
1209
 
1232
1235
        rec_t*          next_rec;
1233
1236
        ulint           fold;
1234
1237
        ulint           next_fold;
1235
 
        dulint          index_id;
1236
1238
        ulint           n_cached;
1237
1239
        ulint           n_recs;
1238
1240
        ulint*          folds;
1246
1248
        ut_ad(index);
1247
1249
        ut_a(!dict_index_is_ibuf(index));
1248
1250
 
 
1251
#ifdef UNIV_SYNC_DEBUG
 
1252
        ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
 
1253
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
 
1254
              || rw_lock_own(&(block->lock), RW_LOCK_EX));
 
1255
#endif /* UNIV_SYNC_DEBUG */
 
1256
 
 
1257
        rw_lock_s_lock(&btr_search_latch);
 
1258
 
 
1259
        if (!btr_search_enabled) {
 
1260
                rw_lock_s_unlock(&btr_search_latch);
 
1261
                return;
 
1262
        }
 
1263
 
1249
1264
        table = btr_search_sys->hash_index;
1250
1265
        page = buf_block_get_frame(block);
1251
1266
 
1252
 
#ifdef UNIV_SYNC_DEBUG
1253
 
        ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
1254
 
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
1255
 
              || rw_lock_own(&(block->lock), RW_LOCK_EX));
1256
 
#endif /* UNIV_SYNC_DEBUG */
1257
 
 
1258
 
        rw_lock_s_lock(&btr_search_latch);
1259
 
 
1260
 
        if (block->is_hashed && ((block->curr_n_fields != n_fields)
1261
 
                                 || (block->curr_n_bytes != n_bytes)
1262
 
                                 || (block->curr_left_side != left_side))) {
 
1267
        if (block->index && ((block->curr_n_fields != n_fields)
 
1268
                             || (block->curr_n_bytes != n_bytes)
 
1269
                             || (block->curr_left_side != left_side))) {
1263
1270
 
1264
1271
                rw_lock_s_unlock(&btr_search_latch);
1265
1272
 
1296
1303
 
1297
1304
        n_cached = 0;
1298
1305
 
1299
 
        index_id = btr_page_get_index_id(page);
 
1306
        ut_a(UT_DULINT_EQ(index->id, btr_page_get_index_id(page)));
1300
1307
 
1301
1308
        rec = page_rec_get_next(page_get_infimum_rec(page));
1302
1309
 
1311
1318
                }
1312
1319
        }
1313
1320
 
1314
 
        fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
 
1321
        fold = rec_fold(rec, offsets, n_fields, n_bytes, index->id);
1315
1322
 
1316
1323
        if (left_side) {
1317
1324
 
1338
1345
                offsets = rec_get_offsets(next_rec, index, offsets,
1339
1346
                                          n_fields + (n_bytes > 0), &heap);
1340
1347
                next_fold = rec_fold(next_rec, offsets, n_fields,
1341
 
                                     n_bytes, index_id);
 
1348
                                     n_bytes, index->id);
1342
1349
 
1343
1350
                if (fold != next_fold) {
1344
1351
                        /* Insert an entry into the hash index */
1367
1374
                goto exit_func;
1368
1375
        }
1369
1376
 
1370
 
        if (block->is_hashed && ((block->curr_n_fields != n_fields)
1371
 
                                 || (block->curr_n_bytes != n_bytes)
1372
 
                                 || (block->curr_left_side != left_side))) {
 
1377
        if (block->index && ((block->curr_n_fields != n_fields)
 
1378
                             || (block->curr_n_bytes != n_bytes)
 
1379
                             || (block->curr_left_side != left_side))) {
1373
1380
                goto exit_func;
1374
1381
        }
1375
1382
 
1378
1385
        rebuild hash index for a page that is already hashed, we
1379
1386
        have to take care not to increment the counter in that
1380
1387
        case. */
1381
 
        if (!block->is_hashed) {
 
1388
        if (!block->index) {
1382
1389
                index->search_info->ref_count++;
1383
1390
        }
1384
1391
 
1385
 
        block->is_hashed = TRUE;
1386
1392
        block->n_hash_helps = 0;
1387
1393
 
1388
1394
        block->curr_n_fields = n_fields;
1430
1436
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
1431
1437
        ut_ad(rw_lock_own(&(new_block->lock), RW_LOCK_EX));
1432
1438
#endif /* UNIV_SYNC_DEBUG */
1433
 
        ut_a(!new_block->is_hashed || new_block->index == index);
1434
 
        ut_a(!block->is_hashed || block->index == index);
1435
 
        ut_a(!(new_block->is_hashed || block->is_hashed)
 
1439
 
 
1440
        rw_lock_s_lock(&btr_search_latch);
 
1441
 
 
1442
        ut_a(!new_block->index || new_block->index == index);
 
1443
        ut_a(!block->index || block->index == index);
 
1444
        ut_a(!(new_block->index || block->index)
1436
1445
             || !dict_index_is_ibuf(index));
1437
1446
 
1438
 
        rw_lock_s_lock(&btr_search_latch);
1439
 
 
1440
 
        if (new_block->is_hashed) {
 
1447
        if (new_block->index) {
1441
1448
 
1442
1449
                rw_lock_s_unlock(&btr_search_latch);
1443
1450
 
1446
1453
                return;
1447
1454
        }
1448
1455
 
1449
 
        if (block->is_hashed) {
 
1456
        if (block->index) {
1450
1457
 
1451
1458
                n_fields = block->curr_n_fields;
1452
1459
                n_bytes = block->curr_n_bytes;
1483
1490
{
1484
1491
        hash_table_t*   table;
1485
1492
        buf_block_t*    block;
1486
 
        rec_t*          rec;
 
1493
        const rec_t*    rec;
1487
1494
        ulint           fold;
1488
 
        dulint          index_id;
1489
 
        ibool           found;
 
1495
        dict_index_t*   index;
1490
1496
        ulint           offsets_[REC_OFFS_NORMAL_SIZE];
1491
1497
        mem_heap_t*     heap            = NULL;
1492
1498
        rec_offs_init(offsets_);
1493
1499
 
1494
 
        rec = btr_cur_get_rec(cursor);
1495
 
 
1496
1500
        block = btr_cur_get_block(cursor);
1497
1501
 
1498
1502
#ifdef UNIV_SYNC_DEBUG
1499
1503
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
1500
1504
#endif /* UNIV_SYNC_DEBUG */
1501
1505
 
1502
 
        if (!block->is_hashed) {
 
1506
        index = block->index;
 
1507
 
 
1508
        if (!index) {
1503
1509
 
1504
1510
                return;
1505
1511
        }
1506
1512
 
1507
 
        ut_a(block->index == cursor->index);
 
1513
        ut_a(index == cursor->index);
1508
1514
        ut_a(block->curr_n_fields + block->curr_n_bytes > 0);
1509
 
        ut_a(!dict_index_is_ibuf(cursor->index));
 
1515
        ut_a(!dict_index_is_ibuf(index));
1510
1516
 
1511
1517
        table = btr_search_sys->hash_index;
1512
1518
 
1513
 
        index_id = cursor->index->id;
1514
 
        fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_,
 
1519
        rec = btr_cur_get_rec(cursor);
 
1520
 
 
1521
        fold = rec_fold(rec, rec_get_offsets(rec, index, offsets_,
1515
1522
                                             ULINT_UNDEFINED, &heap),
1516
 
                        block->curr_n_fields, block->curr_n_bytes, index_id);
 
1523
                        block->curr_n_fields, block->curr_n_bytes, index->id);
1517
1524
        if (UNIV_LIKELY_NULL(heap)) {
1518
1525
                mem_heap_free(heap);
1519
1526
        }
 
1527
 
1520
1528
        rw_lock_x_lock(&btr_search_latch);
1521
1529
 
1522
 
        found = ha_search_and_delete_if_found(table, fold, rec);
 
1530
        if (block->index) {
 
1531
                ut_a(block->index == index);
 
1532
 
 
1533
                ha_search_and_delete_if_found(table, fold, rec);
 
1534
        }
1523
1535
 
1524
1536
        rw_lock_x_unlock(&btr_search_latch);
1525
1537
}
1537
1549
{
1538
1550
        hash_table_t*   table;
1539
1551
        buf_block_t*    block;
 
1552
        dict_index_t*   index;
1540
1553
        rec_t*          rec;
1541
1554
 
1542
1555
        rec = btr_cur_get_rec(cursor);
1547
1560
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
1548
1561
#endif /* UNIV_SYNC_DEBUG */
1549
1562
 
1550
 
        if (!block->is_hashed) {
 
1563
        index = block->index;
 
1564
 
 
1565
        if (!index) {
1551
1566
 
1552
1567
                return;
1553
1568
        }
1554
1569
 
1555
 
        ut_a(block->index == cursor->index);
1556
 
        ut_a(!dict_index_is_ibuf(cursor->index));
 
1570
        ut_a(cursor->index == index);
 
1571
        ut_a(!dict_index_is_ibuf(index));
1557
1572
 
1558
1573
        rw_lock_x_lock(&btr_search_latch);
1559
1574
 
 
1575
        if (!block->index) {
 
1576
 
 
1577
                goto func_exit;
 
1578
        }
 
1579
 
 
1580
        ut_a(block->index == index);
 
1581
 
1560
1582
        if ((cursor->flag == BTR_CUR_HASH)
1561
1583
            && (cursor->n_fields == block->curr_n_fields)
1562
1584
            && (cursor->n_bytes == block->curr_n_bytes)
1567
1589
                ha_search_and_update_if_found(table, cursor->fold, rec,
1568
1590
                                              block, page_rec_get_next(rec));
1569
1591
 
 
1592
func_exit:
1570
1593
                rw_lock_x_unlock(&btr_search_latch);
1571
1594
        } else {
1572
1595
                rw_lock_x_unlock(&btr_search_latch);
1588
1611
{
1589
1612
        hash_table_t*   table;
1590
1613
        buf_block_t*    block;
 
1614
        dict_index_t*   index;
1591
1615
        rec_t*          rec;
1592
1616
        rec_t*          ins_rec;
1593
1617
        rec_t*          next_rec;
1594
 
        dulint          index_id;
1595
1618
        ulint           fold;
1596
1619
        ulint           ins_fold;
1597
1620
        ulint           next_fold = 0; /* remove warning (??? bug ???) */
1616
1639
        ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
1617
1640
#endif /* UNIV_SYNC_DEBUG */
1618
1641
 
1619
 
        if (!block->is_hashed) {
 
1642
        index = block->index;
 
1643
 
 
1644
        if (!index) {
1620
1645
 
1621
1646
                return;
1622
1647
        }
1623
1648
 
1624
 
        ut_a(block->index == cursor->index);
1625
 
        ut_a(!dict_index_is_ibuf(cursor->index));
1626
 
 
1627
 
        index_id = cursor->index->id;
 
1649
        ut_a(index == cursor->index);
 
1650
        ut_a(!dict_index_is_ibuf(index));
1628
1651
 
1629
1652
        n_fields = block->curr_n_fields;
1630
1653
        n_bytes = block->curr_n_bytes;
1633
1656
        ins_rec = page_rec_get_next(rec);
1634
1657
        next_rec = page_rec_get_next(ins_rec);
1635
1658
 
1636
 
        offsets = rec_get_offsets(ins_rec, cursor->index, offsets,
 
1659
        offsets = rec_get_offsets(ins_rec, index, offsets,
1637
1660
                                  ULINT_UNDEFINED, &heap);
1638
 
        ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, index_id);
 
1661
        ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, index->id);
1639
1662
 
1640
1663
        if (!page_rec_is_supremum(next_rec)) {
1641
 
                offsets = rec_get_offsets(next_rec, cursor->index, offsets,
 
1664
                offsets = rec_get_offsets(next_rec, index, offsets,
1642
1665
                                          n_fields + (n_bytes > 0), &heap);
1643
1666
                next_fold = rec_fold(next_rec, offsets, n_fields,
1644
 
                                     n_bytes, index_id);
 
1667
                                     n_bytes, index->id);
1645
1668
        }
1646
1669
 
1647
1670
        if (!page_rec_is_infimum(rec)) {
1648
 
                offsets = rec_get_offsets(rec, cursor->index, offsets,
 
1671
                offsets = rec_get_offsets(rec, index, offsets,
1649
1672
                                          n_fields + (n_bytes > 0), &heap);
1650
 
                fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
 
1673
                fold = rec_fold(rec, offsets, n_fields, n_bytes, index->id);
1651
1674
        } else {
1652
1675
                if (left_side) {
1653
1676
 
1655
1678
 
1656
1679
                        locked = TRUE;
1657
1680
 
 
1681
                        if (!btr_search_enabled) {
 
1682
                                goto function_exit;
 
1683
                        }
 
1684
 
1658
1685
                        ha_insert_for_fold(table, ins_fold, block, ins_rec);
1659
1686
                }
1660
1687
 
1668
1695
                        rw_lock_x_lock(&btr_search_latch);
1669
1696
 
1670
1697
                        locked = TRUE;
 
1698
 
 
1699
                        if (!btr_search_enabled) {
 
1700
                                goto function_exit;
 
1701
                        }
1671
1702
                }
1672
1703
 
1673
1704
                if (!left_side) {
1686
1717
                                rw_lock_x_lock(&btr_search_latch);
1687
1718
 
1688
1719
                                locked = TRUE;
 
1720
 
 
1721
                                if (!btr_search_enabled) {
 
1722
                                        goto function_exit;
 
1723
                                }
1689
1724
                        }
1690
1725
 
1691
1726
                        ha_insert_for_fold(table, ins_fold, block, ins_rec);
1701
1736
                        rw_lock_x_lock(&btr_search_latch);
1702
1737
 
1703
1738
                        locked = TRUE;
 
1739
 
 
1740
                        if (!btr_search_enabled) {
 
1741
                                goto function_exit;
 
1742
                        }
1704
1743
                }
1705
1744
 
1706
1745
                if (!left_side) {
1708
1747
                        ha_insert_for_fold(table, ins_fold, block, ins_rec);
1709
1748
                        /*
1710
1749
                        fputs("Hash insert for ", stderr);
1711
 
                        dict_index_name_print(stderr, cursor->index);
 
1750
                        dict_index_name_print(stderr, index);
1712
1751
                        fprintf(stderr, " fold %lu\n", ins_fold);
1713
1752
                        */
1714
1753
                } else {
1725
1764
        }
1726
1765
}
1727
1766
 
 
1767
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
1728
1768
/********************************************************************//**
1729
1769
Validates the search system.
1730
1770
@return TRUE if ok */
1811
1851
                                                  + (block->curr_n_bytes > 0),
1812
1852
                                                  &heap);
1813
1853
 
1814
 
                        if (!block->is_hashed || node->fold
 
1854
                        if (!block->index || node->fold
1815
1855
                            != rec_fold((rec_t*)(node->data),
1816
1856
                                        offsets,
1817
1857
                                        block->curr_n_fields,
1846
1886
                                rec_print_new(stderr, (rec_t*)node->data,
1847
1887
                                              offsets);
1848
1888
                                fprintf(stderr, "\nInnoDB: on that page."
1849
 
                                        " Page mem address %p, is hashed %lu,"
 
1889
                                        " Page mem address %p, is hashed %p,"
1850
1890
                                        " n fields %lu, n bytes %lu\n"
1851
1891
                                        "InnoDB: side %lu\n",
1852
 
                                        (void*) page, (ulong) block->is_hashed,
 
1892
                                        (void*) page, (void*) block->index,
1853
1893
                                        (ulong) block->curr_n_fields,
1854
1894
                                        (ulong) block->curr_n_bytes,
1855
1895
                                        (ulong) block->curr_left_side);
1888
1928
 
1889
1929
        return(ok);
1890
1930
}
 
1931
#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */