~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/page/page0zip.c

  • Committer: lbieber at stabletransit
  • Date: 2010-10-15 00:46:40 UTC
  • mfrom: (1849.1.4 build)
  • Revision ID: lbieber@drizzle-build-n02.wc1.dfw1.stabletransit.com-20101015004640-59supgzfwelkthos
Merge Travis - changing struct to C++ classes 
Merge Andrew - fix bug 655186: disabling innobase_stats_on_metadata disables ANALYZE

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 2005, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 2005, 2009, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
571
571
        /* Traverse the list of stored records in the collation order,
572
572
        starting from the first user record. */
573
573
 
574
 
        rec = page + PAGE_NEW_INFIMUM;
 
574
        rec = page + PAGE_NEW_INFIMUM, TRUE;
575
575
 
576
576
        i = 0;
577
577
 
651
651
 
652
652
/**********************************************************************//**
653
653
Allocate memory for zlib. */
654
 
extern "C" void* page_zip_malloc(void* opaque, uInt items, uInt size);
655
 
 
656
 
extern "C" void* page_zip_malloc
657
 
(
 
654
static
 
655
void*
 
656
page_zip_malloc(
658
657
/*============*/
659
658
        void*   opaque, /*!< in/out: memory heap */
660
659
        uInt    items,  /*!< in: number of items to allocate */
661
660
        uInt    size)   /*!< in: size of an item in bytes */
662
661
{
663
 
        return(mem_heap_alloc(static_cast<mem_block_info_t *>(opaque), items * size));
 
662
        return(mem_heap_alloc(opaque, items * size));
664
663
}
665
664
 
666
665
/**********************************************************************//**
667
666
Deallocate memory for zlib. */
668
 
extern "C" void page_zip_free(void *opaque, void *address);
669
 
 
670
 
extern "C" void page_zip_free(void *, void *)
671
 
{ }
 
667
static
 
668
void
 
669
page_zip_free(
 
670
/*==========*/
 
671
        void*   opaque __attribute__((unused)), /*!< in: memory heap */
 
672
        void*   address __attribute__((unused)))/*!< in: object to free */
 
673
{
 
674
}
672
675
 
673
676
/**********************************************************************//**
674
677
Configure the zlib allocator to use the given memory heap. */
679
682
        void*           stream,         /*!< in/out: zlib stream */
680
683
        mem_heap_t*     heap)           /*!< in: memory heap to use */
681
684
{
682
 
        z_stream*       strm = static_cast<z_stream *>(stream);
 
685
        z_stream*       strm = stream;
683
686
 
684
687
        strm->zalloc = page_zip_malloc;
685
688
        strm->zfree = page_zip_free;
1226
1229
                               + UNIV_PAGE_SIZE * 4
1227
1230
                               + (512 << MAX_MEM_LEVEL));
1228
1231
 
1229
 
        recs = static_cast<const unsigned char **>(mem_heap_zalloc(heap, n_dense * sizeof *recs));
1230
 
 
1231
 
        fields = static_cast<byte *>(mem_heap_alloc(heap, (n_fields + 1) * 2));
1232
 
 
1233
 
        buf = static_cast<byte *>(mem_heap_alloc(heap, page_zip_get_size(page_zip) - PAGE_DATA));
 
1232
        recs = mem_heap_zalloc(heap, n_dense * sizeof *recs);
 
1233
 
 
1234
        fields = mem_heap_alloc(heap, (n_fields + 1) * 2);
 
1235
 
 
1236
        buf = mem_heap_alloc(heap, page_zip_get_size(page_zip) - PAGE_DATA);
1234
1237
        buf_end = buf + page_zip_get_size(page_zip) - PAGE_DATA;
1235
1238
 
1236
1239
        /* Compress the data payload. */
1461
1464
                dict_table_t*   table = index->table;
1462
1465
                mem_heap_free(index->heap);
1463
1466
                mutex_free(&(table->autoinc_mutex));
1464
 
                ut_free(table->name);
1465
1467
                mem_heap_free(table->heap);
1466
1468
        }
1467
1469
}
2851
2853
        }
2852
2854
 
2853
2855
        heap = mem_heap_create(n_dense * (3 * sizeof *recs) + UNIV_PAGE_SIZE);
2854
 
        recs = static_cast<byte **>(mem_heap_alloc(heap, n_dense * (2 * sizeof *recs)));
 
2856
        recs = mem_heap_alloc(heap, n_dense * (2 * sizeof *recs));
2855
2857
 
2856
2858
        if (all) {
2857
2859
                /* Copy the page header. */
2954
2956
                /* Pre-allocate the offsets for rec_get_offsets_reverse(). */
2955
2957
                ulint   n = 1 + 1/* node ptr */ + REC_OFFS_HEADER_SIZE
2956
2958
                        + dict_index_get_n_fields(index);
2957
 
                offsets = static_cast<unsigned long *>(mem_heap_alloc(heap, n * sizeof(ulint)));
 
2959
                offsets = mem_heap_alloc(heap, n * sizeof(ulint));
2958
2960
                *offsets = n;
2959
2961
        }
2960
2962
 
3115
3117
        temp_page_zip in a debugger when running valgrind --db-attach. */
3116
3118
        VALGRIND_GET_VBITS(page, temp_page, UNIV_PAGE_SIZE);
3117
3119
        UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE);
3118
 
# if UNIV_WORD_SIZE == 4
3119
3120
        VALGRIND_GET_VBITS(page_zip, &temp_page_zip, sizeof temp_page_zip);
3120
 
        /* On 32-bit systems, there is no padding in page_zip_des_t.
3121
 
        On other systems, Valgrind could complain about uninitialized
3122
 
        pad bytes. */
3123
3121
        UNIV_MEM_ASSERT_RW(page_zip, sizeof *page_zip);
3124
 
# endif
3125
3122
        VALGRIND_GET_VBITS(page_zip->data, temp_page,
3126
3123
                           page_zip_get_size(page_zip));
3127
3124
        UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
4419
4416
        dict_index_t*   index,  /*!< in: index of the B-tree node */
4420
4417
        mtr_t*          mtr)    /*!< in: mini-transaction */
4421
4418
{
4422
 
        buf_pool_t*     buf_pool        = buf_pool_from_block(block);
4423
4419
        page_zip_des_t* page_zip        = buf_block_get_page_zip(block);
4424
4420
        page_t*         page            = buf_block_get_frame(block);
4425
4421
        buf_block_t*    temp_block;
4437
4433
        log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
4438
4434
 
4439
4435
#ifndef UNIV_HOTBACKUP
4440
 
        temp_block = buf_block_alloc(buf_pool, 0);
 
4436
        temp_block = buf_block_alloc(0);
4441
4437
        btr_search_drop_page_hash_index(block);
4442
4438
        block->check_index_page_at_flush = TRUE;
4443
4439
#else /* !UNIV_HOTBACKUP */
4465
4461
                /* Copy max trx id to recreated page */
4466
4462
                trx_id_t        max_trx_id = page_get_max_trx_id(temp_page);
4467
4463
                page_set_max_trx_id(block, NULL, max_trx_id, NULL);
4468
 
                ut_ad(max_trx_id != 0);
 
4464
                ut_ad(!ut_dulint_is_zero(max_trx_id));
4469
4465
        }
4470
4466
 
4471
4467
        /* Restore logging. */
4525
4521
        /* The PAGE_MAX_TRX_ID must be set on leaf pages of secondary
4526
4522
        indexes.  It does not matter on other pages. */
4527
4523
        ut_a(dict_index_is_clust(index) || !page_is_leaf(src)
4528
 
             || page_get_max_trx_id(src));
 
4524
             || !ut_dulint_is_zero(page_get_max_trx_id(src)));
4529
4525
 
4530
4526
        UNIV_MEM_ASSERT_W(page, UNIV_PAGE_SIZE);
4531
4527
        UNIV_MEM_ASSERT_W(page_zip->data, page_zip_get_size(page_zip));
4656
4652
        /* Exclude FIL_PAGE_SPACE_OR_CHKSUM, FIL_PAGE_LSN,
4657
4653
        and FIL_PAGE_FILE_FLUSH_LSN from the checksum. */
4658
4654
 
4659
 
        const Bytef*    s       = static_cast<const Bytef *>(data);
 
4655
        const Bytef*    s       = data;
4660
4656
        uLong           adler;
4661
4657
 
4662
4658
        ut_ad(size > FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);