#At file:///home/gluh/MySQL/mysql-trunk/ based on revid:sergey.glukhov@stripped
3347 Sergey Glukhov 2011-03-30 [merge]
automerge
removed:
storage/innobase/include/thr0loc.h
storage/innobase/include/thr0loc.ic
storage/innobase/thr/
storage/innobase/thr/thr0loc.c
modified:
mysql-test/suite/innodb/include/innodb_stats.inc
mysql-test/suite/innodb/r/innodb_stats.result
storage/innobase/CMakeLists.txt
storage/innobase/btr/btr0cur.c
storage/innobase/buf/buf0buddy.c
storage/innobase/buf/buf0buf.c
storage/innobase/buf/buf0flu.c
storage/innobase/buf/buf0rea.c
storage/innobase/data/data0data.c
storage/innobase/dict/dict0boot.c
storage/innobase/dict/dict0crea.c
storage/innobase/dict/dict0dict.c
storage/innobase/dict/dict0load.c
storage/innobase/dict/dict0mem.c
storage/innobase/dict/dict0stats.c
storage/innobase/fil/fil0fil.c
storage/innobase/fsp/fsp0fsp.c
storage/innobase/handler/ha_innodb.cc
storage/innobase/handler/i_s.cc
storage/innobase/ibuf/ibuf0ibuf.c
storage/innobase/include/btr0pcur.h
storage/innobase/include/btr0pcur.ic
storage/innobase/include/buf0buf.h
storage/innobase/include/buf0buf.ic
storage/innobase/include/buf0flu.ic
storage/innobase/include/buf0rea.h
storage/innobase/include/dict0dict.ic
storage/innobase/include/dict0mem.h
storage/innobase/include/ibuf0ibuf.h
storage/innobase/include/ibuf0ibuf.ic
storage/innobase/include/mtr0mtr.h
storage/innobase/include/mtr0mtr.ic
storage/innobase/include/page0page.h
storage/innobase/include/page0types.h
storage/innobase/include/page0zip.ic
storage/innobase/include/rem0rec.h
storage/innobase/include/rem0rec.ic
storage/innobase/include/srv0srv.h
storage/innobase/include/sync0sync.h
storage/innobase/include/univ.i
storage/innobase/lock/lock0lock.c
storage/innobase/mtr/mtr0log.c
storage/innobase/mtr/mtr0mtr.c
storage/innobase/page/page0page.c
storage/innobase/page/page0zip.c
storage/innobase/pars/pars0pars.c
storage/innobase/row/row0ext.c
storage/innobase/row/row0merge.c
storage/innobase/row/row0mysql.c
storage/innobase/row/row0row.c
storage/innobase/row/row0umod.c
storage/innobase/row/row0undo.c
storage/innobase/row/row0upd.c
storage/innobase/srv/srv0srv.c
storage/innobase/srv/srv0start.c
storage/innobase/trx/trx0i_s.c
storage/innobase/trx/trx0rec.c
storage/innobase/trx/trx0sys.c
storage/innobase/trx/trx0trx.c
=== modified file 'mysql-test/suite/innodb/include/innodb_stats.inc'
--- a/mysql-test/suite/innodb/include/innodb_stats.inc 2010-04-21 15:24:51 +0000
+++ b/mysql-test/suite/innodb/include/innodb_stats.inc 2011-03-18 12:49:38 +0000
@@ -16,3 +16,11 @@ table_name = 'test_innodb_stats' AND
index_name = 'a_key' AND
stat_name IN ('n_diff_pfx01', 'n_diff_pfx02', 'n_leaf_pages', 'size')
ORDER BY stat_name;
+
+# provoke reading from persistent storage from
+# row_update_statistics_if_needed()
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+
+# see what has been read
+query_vertical SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
=== modified file 'mysql-test/suite/innodb/r/innodb_stats.result'
--- a/mysql-test/suite/innodb/r/innodb_stats.result 2010-04-21 15:24:51 +0000
+++ b/mysql-test/suite/innodb/r/innodb_stats.result 2011-03-18 12:49:38 +0000
@@ -33,6 +33,25 @@ stat_name size
stat_value 1
sample_size NULL
stat_description Number of pages in the index
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME test_innodb_stats
+NON_UNIQUE 1
+INDEX_SCHEMA test
+INDEX_NAME a_key
+SEQ_IN_INDEX 1
+COLUMN_NAME a
+COLLATION A
+CARDINALITY 0
+SUB_PART NULL
+PACKED NULL
+NULLABLE YES
+INDEX_TYPE BTREE
+COMMENT
+INDEX_COMMENT
DELETE FROM test_innodb_stats;
INSERT INTO test_innodb_stats (a) VALUES (1);
ANALYZE TABLE test_innodb_stats;
@@ -66,6 +85,25 @@ stat_name size
stat_value 1
sample_size NULL
stat_description Number of pages in the index
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME test_innodb_stats
+NON_UNIQUE 1
+INDEX_SCHEMA test
+INDEX_NAME a_key
+SEQ_IN_INDEX 1
+COLUMN_NAME a
+COLLATION A
+CARDINALITY 1
+SUB_PART NULL
+PACKED NULL
+NULLABLE YES
+INDEX_TYPE BTREE
+COMMENT
+INDEX_COMMENT
DELETE FROM test_innodb_stats;
INSERT INTO test_innodb_stats (a) VALUES (1), (1);
ANALYZE TABLE test_innodb_stats;
@@ -99,6 +137,25 @@ stat_name size
stat_value 1
sample_size NULL
stat_description Number of pages in the index
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME test_innodb_stats
+NON_UNIQUE 1
+INDEX_SCHEMA test
+INDEX_NAME a_key
+SEQ_IN_INDEX 1
+COLUMN_NAME a
+COLLATION A
+CARDINALITY 2
+SUB_PART NULL
+PACKED NULL
+NULLABLE YES
+INDEX_TYPE BTREE
+COMMENT
+INDEX_COMMENT
DELETE FROM test_innodb_stats;
INSERT INTO test_innodb_stats (a) VALUES (1), (1), (1);
ANALYZE TABLE test_innodb_stats;
@@ -132,6 +189,25 @@ stat_name size
stat_value 1
sample_size NULL
stat_description Number of pages in the index
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME test_innodb_stats
+NON_UNIQUE 1
+INDEX_SCHEMA test
+INDEX_NAME a_key
+SEQ_IN_INDEX 1
+COLUMN_NAME a
+COLLATION A
+CARDINALITY 3
+SUB_PART NULL
+PACKED NULL
+NULLABLE YES
+INDEX_TYPE BTREE
+COMMENT
+INDEX_COMMENT
DELETE FROM test_innodb_stats;
INSERT INTO test_innodb_stats (a) VALUES (1), (1), (1), (1), (1), (1), (1), (1), (1), (1);
ANALYZE TABLE test_innodb_stats;
@@ -165,6 +241,25 @@ stat_name size
stat_value 1
sample_size NULL
stat_description Number of pages in the index
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME test_innodb_stats
+NON_UNIQUE 1
+INDEX_SCHEMA test
+INDEX_NAME a_key
+SEQ_IN_INDEX 1
+COLUMN_NAME a
+COLLATION A
+CARDINALITY 2
+SUB_PART NULL
+PACKED NULL
+NULLABLE YES
+INDEX_TYPE BTREE
+COMMENT
+INDEX_COMMENT
DELETE FROM test_innodb_stats;
INSERT INTO test_innodb_stats (a) VALUES (1), (2);
ANALYZE TABLE test_innodb_stats;
@@ -198,6 +293,25 @@ stat_name size
stat_value 1
sample_size NULL
stat_description Number of pages in the index
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME test_innodb_stats
+NON_UNIQUE 1
+INDEX_SCHEMA test
+INDEX_NAME a_key
+SEQ_IN_INDEX 1
+COLUMN_NAME a
+COLLATION A
+CARDINALITY 2
+SUB_PART NULL
+PACKED NULL
+NULLABLE YES
+INDEX_TYPE BTREE
+COMMENT
+INDEX_COMMENT
DELETE FROM test_innodb_stats;
INSERT INTO test_innodb_stats (a) VALUES (1), (1), (2);
ANALYZE TABLE test_innodb_stats;
@@ -231,6 +345,25 @@ stat_name size
stat_value 1
sample_size NULL
stat_description Number of pages in the index
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME test_innodb_stats
+NON_UNIQUE 1
+INDEX_SCHEMA test
+INDEX_NAME a_key
+SEQ_IN_INDEX 1
+COLUMN_NAME a
+COLLATION A
+CARDINALITY 3
+SUB_PART NULL
+PACKED NULL
+NULLABLE YES
+INDEX_TYPE BTREE
+COMMENT
+INDEX_COMMENT
DELETE FROM test_innodb_stats;
INSERT INTO test_innodb_stats (a) VALUES (1), (2), (3);
ANALYZE TABLE test_innodb_stats;
@@ -264,6 +397,25 @@ stat_name size
stat_value 1
sample_size NULL
stat_description Number of pages in the index
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME test_innodb_stats
+NON_UNIQUE 1
+INDEX_SCHEMA test
+INDEX_NAME a_key
+SEQ_IN_INDEX 1
+COLUMN_NAME a
+COLLATION A
+CARDINALITY 3
+SUB_PART NULL
+PACKED NULL
+NULLABLE YES
+INDEX_TYPE BTREE
+COMMENT
+INDEX_COMMENT
DELETE FROM test_innodb_stats;
INSERT INTO test_innodb_stats (a) VALUES (1), (1), (2), (3), (3);
ANALYZE TABLE test_innodb_stats;
@@ -297,6 +449,25 @@ stat_name size
stat_value 1
sample_size NULL
stat_description Number of pages in the index
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME test_innodb_stats
+NON_UNIQUE 1
+INDEX_SCHEMA test
+INDEX_NAME a_key
+SEQ_IN_INDEX 1
+COLUMN_NAME a
+COLLATION A
+CARDINALITY 5
+SUB_PART NULL
+PACKED NULL
+NULLABLE YES
+INDEX_TYPE BTREE
+COMMENT
+INDEX_COMMENT
DELETE FROM test_innodb_stats;
INSERT INTO test_innodb_stats (a) VALUES (1), (2), (3), (4), (5), (1), (2), (3), (4), (5);
ANALYZE TABLE test_innodb_stats;
@@ -330,3 +501,22 @@ stat_name size
stat_value 1
sample_size NULL
stat_description Number of pages in the index
+INSERT INTO test_innodb_stats SELECT * FROM test_innodb_stats;
+SELECT * FROM information_schema.statistics
+WHERE table_name = 'test_innodb_stats';
+TABLE_CATALOG def
+TABLE_SCHEMA test
+TABLE_NAME test_innodb_stats
+NON_UNIQUE 1
+INDEX_SCHEMA test
+INDEX_NAME a_key
+SEQ_IN_INDEX 1
+COLUMN_NAME a
+COLLATION A
+CARDINALITY 10
+SUB_PART NULL
+PACKED NULL
+NULLABLE YES
+INDEX_TYPE BTREE
+COMMENT
+INDEX_COMMENT
=== modified file 'storage/innobase/CMakeLists.txt'
--- a/storage/innobase/CMakeLists.txt 2011-03-15 16:17:31 +0000
+++ b/storage/innobase/CMakeLists.txt 2011-03-24 12:24:08 +0000
@@ -247,7 +247,6 @@ SET(INNOBASE_SOURCES btr/btr0btr.c btr/b
row/row0sel.c row/row0uins.c row/row0umod.c row/row0undo.c row/row0upd.c row/row0vers.c
srv/srv0mon.c srv/srv0srv.c srv/srv0start.c
sync/sync0arr.c sync/sync0rw.c sync/sync0sync.c
- thr/thr0loc.c
trx/trx0i_s.c trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c
trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c
usr/usr0sess.c
=== modified file 'storage/innobase/btr/btr0cur.c'
--- a/storage/innobase/btr/btr0cur.c 2011-03-15 10:57:47 +0000
+++ b/storage/innobase/btr/btr0cur.c 2011-03-24 12:24:08 +0000
@@ -402,7 +402,7 @@ btr_cur_search_to_nth_level(
ut_ad(level == 0 || mode == PAGE_CUR_LE);
ut_ad(dict_index_check_search_tuple(index, tuple));
- ut_ad(!dict_index_is_ibuf(index) || ibuf_inside());
+ ut_ad(!dict_index_is_ibuf(index) || ibuf_inside(mtr));
ut_ad(dtuple_check_typed(tuple));
#ifdef UNIV_DEBUG
@@ -4534,8 +4534,8 @@ btr_check_blob_fil_page_type(
ulint flags = fil_space_get_flags(space_id);
#ifndef UNIV_DEBUG /* Improve debug test coverage */
- if (UNIV_LIKELY
- ((flags & DICT_TF_FORMAT_MASK) == DICT_TF_FORMAT_51)) {
+ if (UNIV_LIKELY((flags & DICT_TF_FORMAT_MASK)
+ == (UNIV_FORMAT_A << DICT_TF_FORMAT_SHIFT))) {
/* Old versions of InnoDB did not initialize
FIL_PAGE_TYPE on BLOB pages. Do not print
anything about the type mismatch when reading
@@ -4935,8 +4935,8 @@ btr_copy_zblob_prefix(
page_zip_set_alloc(&d_stream, heap);
ut_ad(ut_is_2pow(zip_size));
- ut_ad(zip_size >= PAGE_ZIP_MIN_SIZE);
- ut_ad(zip_size <= UNIV_PAGE_SIZE);
+ ut_ad(zip_size >= UNIV_ZIP_SIZE_MIN);
+ ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
ut_ad(space_id);
err = inflateInit(&d_stream);
=== modified file 'storage/innobase/buf/buf0buddy.c'
--- a/storage/innobase/buf/buf0buddy.c 2011-02-03 22:18:48 +0000
+++ b/storage/innobase/buf/buf0buddy.c 2011-03-23 13:43:14 +0000
@@ -434,13 +434,13 @@ buf_buddy_relocate(
/* We look inside the allocated objects returned by
buf_buddy_alloc() and assume that anything of
- PAGE_ZIP_MIN_SIZE or larger is a compressed page that contains
+ UNIV_ZIP_SIZE_MIN or larger is a compressed page that contains
a valid space_id and page_no in the page header. Should the
fields be invalid, we will be unable to relocate the block.
We also assume that anything that fits sizeof(buf_page_t)
actually is a properly initialized buf_page_t object. */
- if (size >= PAGE_ZIP_MIN_SIZE) {
+ if (size >= UNIV_ZIP_SIZE_MIN) {
/* This is a compressed page. */
mutex_t* mutex;
@@ -659,7 +659,7 @@ buddy_nonfree:
/* Free the block to the buddy list. */
bpage = buf;
#ifdef UNIV_DEBUG
- if (i < buf_buddy_get_slot(PAGE_ZIP_MIN_SIZE)) {
+ if (i < buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN)) {
/* This area has most likely been allocated for at
least one compressed-only block descriptor. Check
that there are no live objects in the area. This is
=== modified file 'storage/innobase/buf/buf0buf.c'
--- a/storage/innobase/buf/buf0buf.c 2011-03-15 13:26:34 +0000
+++ b/storage/innobase/buf/buf0buf.c 2011-03-24 12:24:08 +0000
@@ -2461,9 +2461,6 @@ buf_page_get_zip(
unsigned access_time;
buf_pool_t* buf_pool = buf_pool_get(space, offset);
-#ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside());
-#endif
buf_pool->stat.n_page_gets++;
for (;;) {
@@ -2908,8 +2905,9 @@ buf_page_get_gen(
ut_ad(zip_size == fil_space_get_zip_size(space));
ut_ad(ut_is_2pow(zip_size));
#ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside() || ibuf_page_low(space, zip_size, offset,
- FALSE, file, line, NULL));
+ ut_ad(!ibuf_inside(mtr)
+ || ibuf_page_low(space, zip_size, offset,
+ FALSE, file, line, NULL));
#endif
buf_pool->stat.n_page_gets++;
fold = buf_page_address_fold(space, offset);
@@ -3347,7 +3345,8 @@ wait_until_unfixed:
/* In the case of a first access, try to apply linear
read-ahead */
- buf_read_ahead_linear(space, zip_size, offset);
+ buf_read_ahead_linear(space, zip_size, offset,
+ ibuf_inside(mtr));
}
#ifdef UNIV_IBUF_COUNT_DEBUG
@@ -3408,7 +3407,7 @@ buf_page_optimistic_get(
access_time = buf_page_is_accessed(&block->page);
buf_page_set_accessed_make_young(&block->page, access_time);
- ut_ad(!ibuf_inside()
+ ut_ad(!ibuf_inside(mtr)
|| ibuf_page(buf_block_get_space(block),
buf_block_get_zip_size(block),
buf_block_get_page_no(block), NULL));
@@ -3464,7 +3463,8 @@ buf_page_optimistic_get(
buf_read_ahead_linear(buf_block_get_space(block),
buf_block_get_zip_size(block),
- buf_block_get_page_no(block));
+ buf_block_get_page_no(block),
+ ibuf_inside(mtr));
}
#ifdef UNIV_IBUF_COUNT_DEBUG
@@ -3540,7 +3540,7 @@ buf_page_get_known_nowait(
buf_pool_mutex_exit(buf_pool);
}
- ut_ad(!ibuf_inside() || (mode == BUF_KEEP_OLD));
+ ut_ad(!ibuf_inside(mtr) || mode == BUF_KEEP_OLD);
if (rw_latch == RW_S_LATCH) {
success = rw_lock_s_lock_nowait(&(block->lock),
@@ -3815,14 +3815,13 @@ buf_page_init_for_read(
/* It is a read-ahead within an ibuf routine */
ut_ad(!ibuf_bitmap_page(zip_size, offset));
- ut_ad(ibuf_inside());
- mtr_start(&mtr);
+ ibuf_mtr_start(&mtr);
if (!recv_no_ibuf_operations
&& !ibuf_page(space, zip_size, offset, &mtr)) {
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
return(NULL);
}
@@ -4019,7 +4018,7 @@ func_exit:
if (mode == BUF_READ_IBUF_PAGES_ONLY) {
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
}
@@ -5619,7 +5618,7 @@ buf_page_init_for_backup_restore(
/* We assume that block->page.data has been allocated
with zip_size == UNIV_PAGE_SIZE. */
- ut_ad(zip_size <= UNIV_PAGE_SIZE);
+ ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
ut_ad(ut_is_2pow(zip_size));
page_zip_set_size(&block->page.zip, zip_size);
if (zip_size) {
=== modified file 'storage/innobase/buf/buf0flu.c'
--- a/storage/innobase/buf/buf0flu.c 2011-03-14 15:03:04 +0000
+++ b/storage/innobase/buf/buf0flu.c 2011-03-23 13:43:14 +0000
@@ -1021,7 +1021,7 @@ buf_flush_init_for_writing(
ulint zip_size = page_zip_get_size(page_zip);
ut_ad(zip_size);
ut_ad(ut_is_2pow(zip_size));
- ut_ad(zip_size <= UNIV_PAGE_SIZE);
+ ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
switch (UNIV_EXPECT(fil_page_get_type(page), FIL_PAGE_INDEX)) {
case FIL_PAGE_TYPE_ALLOCATED:
=== modified file 'storage/innobase/buf/buf0rea.c'
--- a/storage/innobase/buf/buf0rea.c 2011-02-10 12:17:21 +0000
+++ b/storage/innobase/buf/buf0rea.c 2011-03-24 12:24:08 +0000
@@ -236,10 +236,10 @@ UNIV_INTERN
ulint
buf_read_ahead_linear(
/*==================*/
- ulint space, /*!< in: space id */
- ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
- ulint offset) /*!< in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
+ ulint space, /*!< in: space id */
+ ulint zip_size, /*!< in: compressed page size in bytes, or 0 */
+ ulint offset, /*!< in: page number; see NOTE 3 above */
+ ibool inside_ibuf) /*!< in: TRUE if we are inside ibuf routine */
{
buf_pool_t* buf_pool = buf_pool_get(space, offset);
ib_int64_t tablespace_version;
@@ -434,11 +434,9 @@ buf_read_ahead_linear(
/* If we got this far, read-ahead can be sensible: do it */
- if (ibuf_inside()) {
- ibuf_mode = BUF_READ_IBUF_PAGES_ONLY;
- } else {
- ibuf_mode = BUF_READ_ANY_PAGE;
- }
+ ibuf_mode = inside_ibuf
+ ? BUF_READ_IBUF_PAGES_ONLY | OS_AIO_SIMULATED_WAKE_LATER
+ : BUF_READ_ANY_PAGE | OS_AIO_SIMULATED_WAKE_LATER;
count = 0;
@@ -455,7 +453,7 @@ buf_read_ahead_linear(
if (!ibuf_bitmap_page(zip_size, i)) {
count += buf_read_page_low(
&err, FALSE,
- ibuf_mode | OS_AIO_SIMULATED_WAKE_LATER,
+ ibuf_mode,
space, zip_size, FALSE, tablespace_version, i);
if (err == DB_TABLESPACE_DELETED) {
ut_print_timestamp(stderr);
@@ -525,7 +523,6 @@ buf_read_ibuf_merge_pages(
{
ulint i;
- ut_ad(!ibuf_inside());
#ifdef UNIV_IBUF_DEBUG
ut_a(n_stored < UNIV_PAGE_SIZE);
#endif
=== modified file 'storage/innobase/data/data0data.c'
--- a/storage/innobase/data/data0data.c 2010-07-29 10:44:35 +0000
+++ b/storage/innobase/data/data0data.c 2011-03-23 13:43:14 +0000
@@ -583,7 +583,7 @@ dtuple_convert_big_rec(
return(NULL);
}
- if (dict_table_get_format(index->table) < DICT_TF_FORMAT_ZIP) {
+ if (dict_table_get_format(index->table) < UNIV_FORMAT_B) {
/* up to MySQL 5.1: store a 768-byte prefix locally */
local_len = BTR_EXTERN_FIELD_REF_SIZE + DICT_MAX_INDEX_COL_LEN;
} else {
=== modified file 'storage/innobase/dict/dict0boot.c'
--- a/storage/innobase/dict/dict0boot.c 2010-10-20 08:54:44 +0000
+++ b/storage/innobase/dict/dict0boot.c 2011-03-18 15:48:14 +0000
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -283,7 +283,7 @@ dict_boot(void)
/* Insert into the dictionary cache the descriptions of the basic
system tables */
/*-------------------------*/
- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0);
+ table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0, 0);
dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
@@ -335,7 +335,7 @@ dict_boot(void)
ut_a(error == DB_SUCCESS);
/*-------------------------*/
- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0);
+ table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0, 0);
dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
@@ -367,7 +367,7 @@ dict_boot(void)
ut_a(error == DB_SUCCESS);
/*-------------------------*/
- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0);
+ table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0, 0);
dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
@@ -413,7 +413,7 @@ dict_boot(void)
ut_a(error == DB_SUCCESS);
/*-------------------------*/
- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0);
+ table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0, 0);
dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
=== modified file 'storage/innobase/dict/dict0crea.c'
--- a/storage/innobase/dict/dict0crea.c 2010-11-03 09:30:27 +0000
+++ b/storage/innobase/dict/dict0crea.c 2011-03-23 13:43:14 +0000
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -97,13 +97,13 @@ dict_create_sys_tables_tuple(
dfield = dtuple_get_nth_field(entry, 3/*TYPE*/);
ptr = mem_heap_alloc(heap, 4);
- if (table->flags & (~DICT_TF_COMPACT & ~(~0 << DICT_TF_BITS))) {
+ if (table->flags & ~DICT_TF_COMPACT) {
ut_a(table->flags & DICT_TF_COMPACT);
- ut_a(dict_table_get_format(table) >= DICT_TF_FORMAT_ZIP);
+ ut_a(dict_table_get_format(table) >= UNIV_FORMAT_B);
ut_a((table->flags & DICT_TF_ZSSIZE_MASK)
<= (DICT_TF_ZSSIZE_MAX << DICT_TF_ZSSIZE_SHIFT));
- ut_a(!(table->flags & (~0 << DICT_TF2_BITS)));
- mach_write_to_4(ptr, table->flags & ~(~0 << DICT_TF_BITS));
+ ut_a(!(table->flags & ~DICT_TF_BIT_MASK));
+ mach_write_to_4(ptr, table->flags & DICT_TF_BIT_MASK);
} else {
mach_write_to_4(ptr, DICT_TABLE_ORDINARY);
}
@@ -120,7 +120,9 @@ dict_create_sys_tables_tuple(
dfield = dtuple_get_nth_field(entry, 5/*MIX_LEN*/);
ptr = mem_heap_alloc(heap, 4);
- mach_write_to_4(ptr, table->flags >> DICT_TF2_SHIFT);
+ /* Be sure all non-used bits are zero. */
+ ut_a(!(table->flags2 & ~DICT_TF2_BIT_MASK));
+ mach_write_to_4(ptr, table->flags2);
dfield_set_data(dfield, ptr, 4);
/* 8: CLUSTER_NAME ---------------------*/
@@ -287,11 +289,12 @@ dict_build_table_def_step(
is_path = FALSE;
}
- ut_ad(dict_table_get_format(table) <= DICT_TF_FORMAT_MAX);
+ ut_ad(dict_table_get_format(table) <= UNIV_FORMAT_MAX);
ut_ad(!dict_table_zip_size(table)
- || dict_table_get_format(table) >= DICT_TF_FORMAT_ZIP);
+ || dict_table_get_format(table) >= UNIV_FORMAT_B);
- flags = table->flags & ~(~0 << DICT_TF_BITS);
+ flags = table->flags;
+ ut_a(!(flags & ~DICT_TF_BIT_MASK));
error = fil_create_new_single_table_tablespace(
space, path_or_name, is_path,
flags == DICT_TF_COMPACT ? 0 : flags,
@@ -309,8 +312,10 @@ dict_build_table_def_step(
mtr_commit(&mtr);
} else {
- /* Create in the system tablespace: disallow new features */
- table->flags &= (~0 << DICT_TF_BITS) | DICT_TF_COMPACT;
+ /* Create in the system tablespace: disallow Barracuda
+ features by keeping only the first bit which says whether
+ the row format is redundant or compact */
+ table->flags &= DICT_TF_COMPACT;
}
row = dict_create_sys_tables_tuple(table, node->heap);
@@ -1123,7 +1128,7 @@ dict_create_index_step(
node->table, node->index, FIL_NULL,
trx_is_strict(trx)
|| dict_table_get_format(node->table)
- >= DICT_TF_FORMAT_ZIP);
+ >= UNIV_FORMAT_B);
node->index = dict_index_get_if_in_cache_low(index_id);
ut_a(!node->index == (err != DB_SUCCESS));
=== modified file 'storage/innobase/dict/dict0dict.c'
--- a/storage/innobase/dict/dict0dict.c 2011-02-18 13:00:57 +0000
+++ b/storage/innobase/dict/dict0dict.c 2011-03-23 13:43:14 +0000
@@ -1988,14 +1988,14 @@ too_big:
}
switch (dict_table_get_format(table)) {
- case DICT_TF_FORMAT_51:
+ case UNIV_FORMAT_A:
/* ROW_FORMAT=REDUNDANT and ROW_FORMAT=COMPACT store
prefixes of externally stored columns locally within
the record. There are no special considerations for
the undo log record size. */
goto undo_size_ok;
- case DICT_TF_FORMAT_ZIP:
+ case UNIV_FORMAT_B:
/* In ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPRESSED,
column prefix indexes require that prefixes of
externally stored columns are written to the undo log.
@@ -2005,8 +2005,8 @@ too_big:
checked for below. */
break;
-#if DICT_TF_FORMAT_ZIP != DICT_TF_FORMAT_MAX
-# error "DICT_TF_FORMAT_ZIP != DICT_TF_FORMAT_MAX"
+#if UNIV_FORMAT_B != UNIV_FORMAT_MAX
+# error "UNIV_FORMAT_B != UNIV_FORMAT_MAX"
#endif
}
@@ -5085,7 +5085,7 @@ dict_ind_init(void)
dict_table_t* table;
/* create dummy table and index for REDUNDANT infimum and supremum */
- table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0);
+ table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0, 0);
dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR,
DATA_ENGLISH | DATA_NOT_NULL, 8);
@@ -5097,7 +5097,8 @@ dict_ind_init(void)
/* create dummy table and index for COMPACT infimum and supremum */
table = dict_mem_table_create("SYS_DUMMY2",
- DICT_HDR_SPACE, 1, DICT_TF_COMPACT);
+ DICT_HDR_SPACE, 1,
+ DICT_TF_COMPACT, 0);
dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR,
DATA_ENGLISH | DATA_NOT_NULL, 8);
dict_ind_compact = dict_mem_index_create("SYS_DUMMY2", "SYS_DUMMY2",
=== modified file 'storage/innobase/dict/dict0load.c'
--- a/storage/innobase/dict/dict0load.c 2011-03-07 16:11:09 +0000
+++ b/storage/innobase/dict/dict0load.c 2011-03-23 13:43:14 +0000
@@ -605,22 +605,22 @@ dict_sys_tables_get_flags(
field = rec_get_nth_field_old(rec, 4/*N_COLS*/, &len);
n_cols = mach_read_from_4(field);
- if (UNIV_UNLIKELY(!(n_cols & 0x80000000UL))) {
+ if (UNIV_UNLIKELY(!(n_cols & DICT_N_COLS_COMPACT))) {
/* New file formats require ROW_FORMAT=COMPACT. */
return(ULINT_UNDEFINED);
}
switch (flags & (DICT_TF_FORMAT_MASK | DICT_TF_COMPACT)) {
default:
- case DICT_TF_FORMAT_51 << DICT_TF_FORMAT_SHIFT:
- case DICT_TF_FORMAT_51 << DICT_TF_FORMAT_SHIFT | DICT_TF_COMPACT:
+ case UNIV_FORMAT_A << DICT_TF_FORMAT_SHIFT:
+ case UNIV_FORMAT_A << DICT_TF_FORMAT_SHIFT | DICT_TF_COMPACT:
/* flags should be DICT_TABLE_ORDINARY,
or DICT_TF_FORMAT_MASK should be nonzero. */
return(ULINT_UNDEFINED);
- case DICT_TF_FORMAT_ZIP << DICT_TF_FORMAT_SHIFT | DICT_TF_COMPACT:
-#if DICT_TF_FORMAT_MAX > DICT_TF_FORMAT_ZIP
-# error "missing case labels for DICT_TF_FORMAT_ZIP .. DICT_TF_FORMAT_MAX"
+ case UNIV_FORMAT_B << DICT_TF_FORMAT_SHIFT | DICT_TF_COMPACT:
+#if UNIV_FORMAT_MAX > UNIV_FORMAT_B
+# error "missing case labels for UNIV_FORMAT_B .. UNIV_FORMAT_MAX"
#endif
/* We support this format. */
break;
@@ -632,7 +632,7 @@ dict_sys_tables_get_flags(
return(ULINT_UNDEFINED);
}
- if (UNIV_UNLIKELY(flags & (~0 << DICT_TF_BITS))) {
+ if (UNIV_UNLIKELY(flags & ~DICT_TF_BIT_MASK)) {
/* Some unused bits are set. */
return(ULINT_UNDEFINED);
}
@@ -746,7 +746,7 @@ loop:
ibool is_temp;
field = rec_get_nth_field_old(rec, 4, &len);
- if (0x80000000UL & mach_read_from_4(field)) {
+ if (mach_read_from_4(field) & DICT_N_COLS_COMPACT) {
/* ROW_FORMAT=COMPACT: read the is_temp
flag from SYS_TABLES.MIX_LEN. */
field = rec_get_nth_field_old(rec, 7, &len);
@@ -1485,7 +1485,8 @@ dict_load_table_low(
ulint len;
ulint space;
ulint n_cols;
- ulint flags;
+ ulint flags = 0;
+ ulint flags2 = 0;
if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {
return("delete-marked record in SYS_TABLES");
@@ -1567,27 +1568,22 @@ err_len:
(ulong) flags);
return("incorrect flags in SYS_TABLES");
}
- } else {
- flags = 0;
}
/* The high-order bit of N_COLS is the "compact format" flag.
For tables in that format, MIX_LEN may hold additional flags. */
- if (n_cols & 0x80000000UL) {
- ulint flags2;
-
+ if (n_cols & DICT_N_COLS_COMPACT) {
flags |= DICT_TF_COMPACT;
- field = rec_get_nth_field_old(rec, 7, &len);
+ field = rec_get_nth_field_old(rec, 7/*MIX_LEN*/, &len);
if (UNIV_UNLIKELY(len != 4)) {
-
goto err_len;
}
flags2 = mach_read_from_4(field);
- if (flags2 & (~0 << (DICT_TF2_BITS - DICT_TF2_SHIFT))) {
+ if (flags2 & ~DICT_TF2_BIT_MASK) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Warning: table ", stderr);
ut_print_filename(stderr, name);
@@ -1596,15 +1592,13 @@ err_len:
" has unknown flags %lx.\n",
(ulong) flags2);
- flags2 &= ~(~0 << (DICT_TF2_BITS - DICT_TF2_SHIFT));
+ flags2 &= DICT_TF2_BIT_MASK;
}
-
- flags |= flags2 << DICT_TF2_SHIFT;
}
/* See if the tablespace is available. */
- *table = dict_mem_table_create(name, space, n_cols & ~0x80000000UL,
- flags);
+ *table = dict_mem_table_create(
+ name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2);
field = rec_get_nth_field_old(rec, 3/*ID*/, &len);
ut_ad(len == 8); /* this was checked earlier */
@@ -1707,11 +1701,10 @@ err_exit:
/* The system tablespace is always available. */
} else if (!fil_space_for_table_exists_in_mem(
table->space, name,
- (table->flags >> DICT_TF2_SHIFT)
- & DICT_TF2_TEMPORARY,
+ table->flags2 & DICT_TF2_TEMPORARY,
FALSE, FALSE)) {
- if (table->flags & (DICT_TF2_TEMPORARY << DICT_TF2_SHIFT)) {
+ if (table->flags2 & DICT_TF2_TEMPORARY) {
/* Do not bother to retry opening temporary tables. */
table->ibd_file_missing = TRUE;
} else {
@@ -1727,7 +1720,7 @@ err_exit:
if (!fil_open_single_table_tablespace(
TRUE, table->space,
table->flags == DICT_TF_COMPACT ? 0 :
- table->flags & ~(~0 << DICT_TF_BITS), name)) {
+ table->flags, name)) {
/* We failed to find a sensible
tablespace file */
=== modified file 'storage/innobase/dict/dict0mem.c'
--- a/storage/innobase/dict/dict0mem.c 2011-02-08 12:16:14 +0000
+++ b/storage/innobase/dict/dict0mem.c 2011-03-18 15:48:14 +0000
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -63,13 +63,15 @@ dict_mem_table_create(
ignored if the table is made a member of
a cluster */
ulint n_cols, /*!< in: number of columns */
- ulint flags) /*!< in: table flags */
+ ulint flags, /*!< in: table flags */
+ ulint flags2) /*!< in: table flags2 */
{
dict_table_t* table;
mem_heap_t* heap;
ut_ad(name);
- ut_a(!(flags & (~0 << DICT_TF2_BITS)));
+ ut_a(!(flags & ~DICT_TF_BIT_MASK));
+ ut_a(!(flags2 & ~DICT_TF2_BIT_MASK));
heap = mem_heap_create(DICT_HEAP_SIZE);
@@ -78,6 +80,7 @@ dict_mem_table_create(
table->heap = heap;
table->flags = (unsigned int) flags;
+ table->flags2 = (unsigned int) flags2;
table->name = ut_malloc(strlen(name) + 1);
memcpy(table->name, name, strlen(name) + 1);
table->space = (unsigned int) space;
=== modified file 'storage/innobase/dict/dict0stats.c'
--- a/storage/innobase/dict/dict0stats.c 2011-03-15 14:33:31 +0000
+++ b/storage/innobase/dict/dict0stats.c 2011-03-18 12:49:38 +0000
@@ -1798,7 +1798,7 @@ dict_stats_fetch_index_stats_step(
switch (i) {
case 0: /* innodb.index_stats.index_name */
- ut_a(dtype_get_mtype(type) == DATA_VARCHAR);
+ ut_a(dtype_get_mtype(type) == DATA_VARMYSQL);
/* search for index in table's indexes whose name
matches data; the fetched index name is in data,
@@ -1829,7 +1829,7 @@ dict_stats_fetch_index_stats_step(
case 1: /* innodb.index_stats.stat_name */
- ut_a(dtype_get_mtype(type) == DATA_VARCHAR);
+ ut_a(dtype_get_mtype(type) == DATA_VARMYSQL);
ut_a(index != NULL);
=== modified file 'storage/innobase/fil/fil0fil.c'
--- a/storage/innobase/fil/fil0fil.c 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/fil/fil0fil.c 2011-03-24 12:24:08 +0000
@@ -1153,13 +1153,11 @@ fil_space_create(
fil_space_t* space;
/* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
- ROW_FORMAT=COMPACT
- ((table->flags & ~(~0 << DICT_TF_BITS)) == DICT_TF_COMPACT) and
+ ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
ROW_FORMAT=REDUNDANT (table->flags == 0). For any other
- format, the tablespace flags should equal
- (table->flags & ~(~0 << DICT_TF_BITS)). */
+ format, the tablespace flags should equal table->flags. */
ut_a(flags != DICT_TF_COMPACT);
- ut_a(!(flags & (~0UL << DICT_TF_BITS)));
+ ut_a(!(flags & ~DICT_TF_BIT_MASK));
try_again:
/*printf(
@@ -2697,13 +2695,11 @@ fil_create_new_single_table_tablespace(
ut_a(space_id < SRV_LOG_SPACE_FIRST_ID);
ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE);
/* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
- ROW_FORMAT=COMPACT
- ((table->flags & ~(~0 << DICT_TF_BITS)) == DICT_TF_COMPACT) and
+ ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
ROW_FORMAT=REDUNDANT (table->flags == 0). For any other
- format, the tablespace flags should equal
- (table->flags & ~(~0 << DICT_TF_BITS)). */
+ format, the tablespace flags should equal table->flags. */
ut_a(flags != DICT_TF_COMPACT);
- ut_a(!(flags & (~0UL << DICT_TF_BITS)));
+ ut_a(!(flags & ~DICT_TF_BIT_MASK));
path = fil_make_ibd_name(tablename, is_temp);
@@ -2792,7 +2788,7 @@ error_exit2:
page_zip_des_t page_zip;
ulint zip_size;
- zip_size = ((PAGE_ZIP_MIN_SIZE >> 1)
+ zip_size = ((UNIV_ZIP_SIZE_MIN >> 1)
<< ((flags & DICT_TF_ZSSIZE_MASK)
>> DICT_TF_ZSSIZE_SHIFT));
@@ -2959,7 +2955,7 @@ fil_reset_too_high_lsns(
fputs(".\n", stderr);
ut_a(ut_is_2pow(zip_size));
- ut_a(zip_size <= UNIV_PAGE_SIZE);
+ ut_a(zip_size <= UNIV_ZIP_SIZE_MAX);
/* Loop through all the pages in the tablespace and reset the lsn and
the page checksum if necessary */
@@ -3072,13 +3068,11 @@ fil_open_single_table_tablespace(
filepath = fil_make_ibd_name(name, FALSE);
/* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
- ROW_FORMAT=COMPACT
- ((table->flags & ~(~0 << DICT_TF_BITS)) == DICT_TF_COMPACT) and
+ ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
ROW_FORMAT=REDUNDANT (table->flags == 0). For any other
- format, the tablespace flags should equal
- (table->flags & ~(~0 << DICT_TF_BITS)). */
+ format, the tablespace flags should equal table->flags. */
ut_a(flags != DICT_TF_COMPACT);
- ut_a(!(flags & (~0UL << DICT_TF_BITS)));
+ ut_a(!(flags & ~DICT_TF_BIT_MASK));
file = os_file_create_simple_no_error_handling(
innodb_file_data_key, filepath, OS_FILE_OPEN,
@@ -3131,8 +3125,7 @@ fil_open_single_table_tablespace(
ut_free(buf2);
- if (UNIV_UNLIKELY(space_id != id
- || space_flags != (flags & ~(~0 << DICT_TF_BITS)))) {
+ if (UNIV_UNLIKELY(space_id != id || space_flags != flags)) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Error: tablespace id and flags in file ",
@@ -4346,8 +4339,6 @@ fil_io(
ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)
|| !ibuf_bitmap_page(zip_size, block_offset)
|| sync || is_log);
- ut_ad(!ibuf_inside() || is_log || (type == OS_FILE_WRITE)
- || ibuf_page(space_id, zip_size, block_offset, NULL));
# endif /* UNIV_LOG_DEBUG */
if (sync) {
mode = OS_AIO_SYNC;
=== modified file 'storage/innobase/fsp/fsp0fsp.c'
--- a/storage/innobase/fsp/fsp0fsp.c 2011-02-03 22:18:48 +0000
+++ b/storage/innobase/fsp/fsp0fsp.c 2011-03-23 13:43:14 +0000
@@ -365,8 +365,8 @@ fsp_get_space_header(
fsp_header_t* header;
ut_ad(ut_is_2pow(zip_size));
- ut_ad(zip_size <= UNIV_PAGE_SIZE);
- ut_ad(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
+ ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
+ ut_ad(!zip_size || zip_size >= UNIV_ZIP_SIZE_MIN);
ut_ad(id || !zip_size);
block = buf_page_get(id, zip_size, 0, RW_X_LATCH, mtr);
@@ -656,8 +656,8 @@ xdes_calc_descriptor_page(
+ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
# error
# endif
-# if PAGE_ZIP_MIN_SIZE <= XDES_ARR_OFFSET \
- + (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
+# if UNIV_ZIP_SIZE_MIN <= XDES_ARR_OFFSET \
+ + (UNIV_ZIP_SIZE_MIN / FSP_EXTENT_SIZE) * XDES_SIZE
# error
# endif
#endif /* !DOXYGEN */
@@ -1361,8 +1361,8 @@ fsp_fill_free_list(
zip_size = dict_table_flags_to_zip_size(
mach_read_from_4(FSP_SPACE_FLAGS + header));
ut_a(ut_is_2pow(zip_size));
- ut_a(zip_size <= UNIV_PAGE_SIZE);
- ut_a(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
+ ut_a(zip_size <= UNIV_ZIP_SIZE_MAX);
+ ut_a(!zip_size || zip_size >= UNIV_ZIP_SIZE_MIN);
if (space == 0 && srv_auto_extend_last_data_file
&& size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) {
@@ -1456,8 +1456,8 @@ fsp_fill_free_list(
#if UNIV_PAGE_SIZE % FSP_EXTENT_SIZE
# error "UNIV_PAGE_SIZE % FSP_EXTENT_SIZE != 0"
#endif
-#if PAGE_ZIP_MIN_SIZE % FSP_EXTENT_SIZE
-# error "PAGE_ZIP_MIN_SIZE % FSP_EXTENT_SIZE != 0"
+#if UNIV_ZIP_SIZE_MIN % FSP_EXTENT_SIZE
+# error "UNIV_ZIP_SIZE_MIN % FSP_EXTENT_SIZE != 0"
#endif
if (UNIV_UNLIKELY(init_xdes)) {
@@ -3935,8 +3935,8 @@ fsp_validate(
latch = fil_space_get_latch(space, &flags);
zip_size = dict_table_flags_to_zip_size(flags);
ut_a(ut_is_2pow(zip_size));
- ut_a(zip_size <= UNIV_PAGE_SIZE);
- ut_a(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
+ ut_a(zip_size <= UNIV_ZIP_SIZE_MAX);
+ ut_a(!zip_size || zip_size >= UNIV_ZIP_SIZE_MIN);
/* Start first a mini-transaction mtr2 to lock out all other threads
from the fsp system */
=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc 2011-03-22 11:44:40 +0000
+++ b/storage/innobase/handler/ha_innodb.cc 2011-03-30 07:34:34 +0000
@@ -70,7 +70,6 @@ extern "C" {
#include "fil0fil.h"
#include "trx0xa.h"
#include "row0merge.h"
-#include "thr0loc.h"
#include "dict0boot.h"
#include "dict0stats.h"
#include "ha_prototypes.h"
@@ -284,7 +283,6 @@ static PSI_mutex_info all_innodb_mutexes
{&sync_thread_mutex_key, "sync_thread_mutex", 0},
# endif /* UNIV_SYNC_DEBUG */
{&trx_doublewrite_mutex_key, "trx_doublewrite_mutex", 0},
- {&thr_local_mutex_key, "thr_local_mutex", 0},
{&trx_undo_mutex_key, "trx_undo_mutex", 0},
{&srv_sys_mutex_key, "srv_sys_mutex", 0},
{&lock_sys_mutex_key, "lock_mutex", 0},
@@ -2524,7 +2522,7 @@ mem_free_and_error:
format_id = innobase_file_format_name_lookup(
innobase_file_format_name);
- if (format_id > DICT_TF_FORMAT_MAX) {
+ if (format_id > UNIV_FORMAT_MAX) {
sql_print_error("InnoDB: wrong innodb_file_format.");
@@ -2550,12 +2548,12 @@ mem_free_and_error:
if (!innobase_file_format_check) {
/* Set the value to disable checking. */
- srv_max_file_format_at_startup = DICT_TF_FORMAT_MAX + 1;
+ srv_max_file_format_at_startup = UNIV_FORMAT_MAX + 1;
} else {
/* Set the value to the lowest supported format. */
- srv_max_file_format_at_startup = DICT_TF_FORMAT_MIN;
+ srv_max_file_format_at_startup = UNIV_FORMAT_MIN;
}
/* Did the user specify a format name that we support?
@@ -2569,7 +2567,7 @@ mem_free_and_error:
"should be any value up to %s or its "
"equivalent numeric id",
trx_sys_file_format_id_to_name(
- DICT_TF_FORMAT_MAX));
+ UNIV_FORMAT_MAX));
goto mem_free_and_error;
}
@@ -3264,7 +3262,6 @@ innobase_close_connection(
innobase_rollback_trx(trx);
- thr_local_free(trx->mysql_thread_id);
trx_free_for_mysql(trx);
DBUG_RETURN(0);
@@ -3294,16 +3291,16 @@ ha_innobase::get_row_type() const
ut_ad(flags & DICT_TF_COMPACT);
switch (flags & DICT_TF_FORMAT_MASK) {
- case DICT_TF_FORMAT_51 << DICT_TF_FORMAT_SHIFT:
+ case UNIV_FORMAT_A << DICT_TF_FORMAT_SHIFT:
return(ROW_TYPE_COMPACT);
- case DICT_TF_FORMAT_ZIP << DICT_TF_FORMAT_SHIFT:
+ case UNIV_FORMAT_B << DICT_TF_FORMAT_SHIFT:
if (flags & DICT_TF_ZSSIZE_MASK) {
return(ROW_TYPE_COMPRESSED);
} else {
return(ROW_TYPE_DYNAMIC);
}
-#if DICT_TF_FORMAT_ZIP != DICT_TF_FORMAT_MAX
-# error "DICT_TF_FORMAT_ZIP != DICT_TF_FORMAT_MAX"
+#if UNIV_FORMAT_B != UNIV_FORMAT_MAX
+# error "UNIV_FORMAT_B != UNIV_FORMAT_MAX"
#endif
}
}
@@ -6664,7 +6661,8 @@ create_table_def(
an .ibd file for it (no .ibd extension
in the path, though); otherwise this
is NULL */
- ulint flags) /*!< in: table flags */
+ ulint flags, /*!< in: table flags */
+ ulint flags2) /*!< in: table flags2 */
{
Field* field;
dict_table_t* table;
@@ -6704,7 +6702,7 @@ create_table_def(
/* We pass 0 as the space id, and determine at a lower level the space
id where to store the table */
- table = dict_mem_table_create(table_name, 0, n_cols, flags);
+ table = dict_mem_table_create(table_name, 0, n_cols, flags, flags2);
if (path_of_temp_table) {
table->dir_path_of_temp_table =
@@ -7023,7 +7021,7 @@ get_row_format_name(
/** If file-format is Antelope, issue warning and set ret false */
#define CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE \
- if (srv_file_format < DICT_TF_FORMAT_ZIP) { \
+ if (srv_file_format < UNIV_FORMAT_B) { \
push_warning_printf( \
thd, MYSQL_ERROR::WARN_LEVEL_WARN, \
ER_ILLEGAL_HA_CREATE_OPTION, \
@@ -7081,7 +7079,7 @@ create_options_are_valid(
" innodb_file_per_table.");
ret = FALSE;
}
- if (srv_file_format < DICT_TF_FORMAT_ZIP) {
+ if (srv_file_format < UNIV_FORMAT_B) {
push_warning(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
@@ -7179,7 +7177,8 @@ ha_innobase::create(
char norm_name[FN_REFLEN];
THD* thd = ha_thd();
ib_int64_t auto_inc_value;
- ulint flags;
+ ulint flags = 0;
+ ulint flags2 = 0;
/* Cache the value of innodb_file_format, in case it is
modified by another thread while the table is being created. */
const ulint file_format = srv_file_format;
@@ -7249,8 +7248,6 @@ ha_innobase::create(
/* Create the table definition in InnoDB */
- flags = 0;
-
/* Validate create options if innodb_strict_mode is set. */
if (!create_options_are_valid(thd, form, create_info)) {
error = ER_ILLEGAL_HA_CREATE_OPTION;
@@ -7271,7 +7268,7 @@ ha_innobase::create(
if (key_block_size == ksize) {
flags = ssize << DICT_TF_ZSSIZE_SHIFT
| DICT_TF_COMPACT
- | DICT_TF_FORMAT_ZIP
+ | UNIV_FORMAT_B
<< DICT_TF_FORMAT_SHIFT;
break;
}
@@ -7286,7 +7283,7 @@ ha_innobase::create(
flags = 0;
}
- if (file_format < DICT_TF_FORMAT_ZIP) {
+ if (file_format < UNIV_FORMAT_B) {
push_warning(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
@@ -7335,7 +7332,7 @@ ha_innobase::create(
flags = (DICT_TF_ZSSIZE_MAX - 1)
<< DICT_TF_ZSSIZE_SHIFT
| DICT_TF_COMPACT
- | DICT_TF_FORMAT_ZIP
+ | UNIV_FORMAT_B
<< DICT_TF_FORMAT_SHIFT;
#if DICT_TF_ZSSIZE_MAX < 1
# error "DICT_TF_ZSSIZE_MAX < 1"
@@ -7355,7 +7352,7 @@ ha_innobase::create(
"InnoDB: ROW_FORMAT=%s requires"
" innodb_file_per_table.",
get_row_format_name(row_format));
- } else if (file_format < DICT_TF_FORMAT_ZIP) {
+ } else if (file_format < UNIV_FORMAT_B) {
push_warning_printf(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
@@ -7364,7 +7361,7 @@ ha_innobase::create(
get_row_format_name(row_format));
} else {
flags |= DICT_TF_COMPACT
- | (DICT_TF_FORMAT_ZIP
+ | (UNIV_FORMAT_B
<< DICT_TF_FORMAT_SHIFT);
break;
}
@@ -7403,12 +7400,12 @@ ha_innobase::create(
}
if (create_info->options & HA_LEX_CREATE_TMP_TABLE) {
- flags |= DICT_TF2_TEMPORARY << DICT_TF2_SHIFT;
+ flags2 |= DICT_TF2_TEMPORARY;
}
error = create_table_def(trx, form, norm_name,
create_info->options & HA_LEX_CREATE_TMP_TABLE ? name2 : NULL,
- flags);
+ flags, flags2);
if (error) {
goto cleanup;
@@ -11072,13 +11069,13 @@ innobase_file_format_name_lookup(
/* Check for valid parse. */
if (*endp == '\0' && *format_name != '\0') {
- if (format_id <= DICT_TF_FORMAT_MAX) {
+ if (format_id <= UNIV_FORMAT_MAX) {
return(format_id);
}
} else {
- for (format_id = 0; format_id <= DICT_TF_FORMAT_MAX;
+ for (format_id = 0; format_id <= UNIV_FORMAT_MAX;
format_id++) {
const char* name;
@@ -11091,7 +11088,7 @@ innobase_file_format_name_lookup(
}
}
- return(DICT_TF_FORMAT_MAX + 1);
+ return(UNIV_FORMAT_MAX + 1);
}
/************************************************************//**
@@ -11108,7 +11105,7 @@ innobase_file_format_validate_and_set(
format_id = innobase_file_format_name_lookup(format_max);
- if (format_id < DICT_TF_FORMAT_MAX + 1) {
+ if (format_id < UNIV_FORMAT_MAX + 1) {
srv_max_file_format_at_startup = format_id;
return((int) format_id);
@@ -11147,7 +11144,7 @@ innodb_file_format_name_validate(
format_id = innobase_file_format_name_lookup(
file_format_input);
- if (format_id <= DICT_TF_FORMAT_MAX) {
+ if (format_id <= UNIV_FORMAT_MAX) {
/* Save a pointer to the name in the
'file_format_name_map' constant array. */
@@ -11189,7 +11186,7 @@ innodb_file_format_name_update(
format_id = innobase_file_format_name_lookup(format_name);
- if (format_id <= DICT_TF_FORMAT_MAX) {
+ if (format_id <= UNIV_FORMAT_MAX) {
srv_file_format = format_id;
}
}
@@ -11244,8 +11241,8 @@ innodb_file_format_max_validate(
"InnoDB: invalid innodb_file_format_max "
"value; can be any format up to %s "
"or equivalent id of %d",
- trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX),
- DICT_TF_FORMAT_MAX);
+ trx_sys_file_format_id_to_name(UNIV_FORMAT_MAX),
+ UNIV_FORMAT_MAX);
}
}
@@ -11284,7 +11281,7 @@ innodb_file_format_max_update(
format_id = innobase_file_format_name_lookup(format_name_in);
- if (format_id > DICT_TF_FORMAT_MAX) {
+ if (format_id > UNIV_FORMAT_MAX) {
/* DEFAULT is "on", which is invalid at runtime. */
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WRONG_ARGUMENTS,
=== modified file 'storage/innobase/handler/i_s.cc'
--- a/storage/innobase/handler/i_s.cc 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/handler/i_s.cc 2011-03-23 13:43:14 +0000
@@ -39,7 +39,7 @@ extern "C" {
#include "btr0pcur.h" /* for file sys_tables related info. */
#include "btr0types.h"
#include "buf0buddy.h" /* for i_s_cmpmem */
-#include "buf0buf.h" /* for buf_pool and PAGE_ZIP_MIN_SIZE */
+#include "buf0buf.h" /* for buf_pool */
#include "dict0load.h" /* for file sys_tables related info. */
#include "dict0mem.h"
#include "dict0types.h"
@@ -1371,7 +1371,7 @@ i_s_cmp_fill_low(
for (uint i = 0; i < PAGE_ZIP_NUM_SSIZE - 1; i++) {
page_zip_stat_t* zip_stat = &page_zip_stat[i];
- table->field[0]->store(PAGE_ZIP_MIN_SIZE << i);
+ table->field[0]->store(UNIV_ZIP_SIZE_MIN << i);
/* The cumulated counts are not protected by any
mutex. Thus, some operation in page0zip.c could
@@ -3190,8 +3190,9 @@ i_s_innodb_buffer_page_fill(
page_info->data_size));
OK(fields[IDX_BUFFER_PAGE_ZIP_SIZE]->store(
- page_info->zip_ssize ?
- 512 << page_info->zip_ssize : 0));
+ page_info->zip_ssize
+ ? (UNIV_ZIP_SIZE_MIN >> 1) << page_info->zip_ssize
+ : 0));
#if BUF_PAGE_STATE_BITS > 3
# error "BUF_PAGE_STATE_BITS > 3, please ensure that all 1<<BUF_PAGE_STATE_BITS values are checked for"
=== modified file 'storage/innobase/ibuf/ibuf0ibuf.c'
--- a/storage/innobase/ibuf/ibuf0ibuf.c 2011-02-10 15:01:01 +0000
+++ b/storage/innobase/ibuf/ibuf0ibuf.c 2011-03-24 12:24:08 +0000
@@ -44,7 +44,6 @@ Created 7/19/1997 Heikki Tuuri
#include "fsp0fsp.h"
#include "trx0sys.h"
#include "fil0fil.h"
-#include "thr0loc.h"
#include "rem0rec.h"
#include "btr0cur.h"
#include "btr0pcur.h"
@@ -321,52 +320,43 @@ still physically like the index page eve
dropped! So, there seems to be no problem. */
/******************************************************************//**
-Sets the flag in the current OS thread local storage denoting that it is
+Sets the flag in the current mini-transaction record indicating we're
inside an insert buffer routine. */
UNIV_INLINE
void
-ibuf_enter(void)
-/*============*/
+ibuf_enter(
+/*=======*/
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
- ibool* ptr;
-
- ptr = thr_local_get_in_ibuf_field();
-
- ut_ad(*ptr == FALSE);
-
- *ptr = TRUE;
+ ut_ad(!mtr->inside_ibuf);
+ mtr->inside_ibuf = TRUE;
}
/******************************************************************//**
-Sets the flag in the current OS thread local storage denoting that it is
+Sets the flag in the current mini-transaction record indicating we're
exiting an insert buffer routine. */
UNIV_INLINE
void
-ibuf_exit(void)
-/*===========*/
+ibuf_exit(
+/*======*/
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
- ibool* ptr;
-
- ptr = thr_local_get_in_ibuf_field();
-
- ut_ad(*ptr == TRUE);
-
- *ptr = FALSE;
+ ut_ad(mtr->inside_ibuf);
+ mtr->inside_ibuf = FALSE;
}
-/******************************************************************//**
-Returns TRUE if the current OS thread is performing an insert buffer
-routine.
-
-For instance, a read-ahead of non-ibuf pages is forbidden by threads
-that are executing an insert buffer routine.
-@return TRUE if inside an insert buffer routine */
-UNIV_INTERN
-ibool
-ibuf_inside(void)
-/*=============*/
+/**************************************************************//**
+Commits an insert buffer mini-transaction and sets the persistent
+cursor latch mode to BTR_NO_LATCHES, that is, detaches the cursor. */
+UNIV_INLINE
+void
+ibuf_btr_pcur_commit_specify_mtr(
+/*=============================*/
+ btr_pcur_t* pcur, /*!< in/out: persistent cursor */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
- return(*thr_local_get_in_ibuf_field());
+ ut_d(ibuf_exit(mtr));
+ btr_pcur_commit_specify_mtr(pcur, mtr);
}
/******************************************************************//**
@@ -376,11 +366,11 @@ static
page_t*
ibuf_header_page_get(
/*=================*/
- mtr_t* mtr) /*!< in: mtr */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
{
buf_block_t* block;
- ut_ad(!ibuf_inside());
+ ut_ad(!ibuf_inside(mtr));
block = buf_page_get(
IBUF_SPACE_ID, 0, FSP_IBUF_HEADER_PAGE_NO, RW_X_LATCH, mtr);
@@ -401,7 +391,7 @@ ibuf_tree_root_get(
buf_block_t* block;
page_t* root;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
ut_ad(mutex_own(&ibuf_mutex));
mtr_x_lock(dict_index_get_lock(ibuf->index), mtr);
@@ -545,7 +535,7 @@ ibuf_init_at_db_start(void)
fseg_n_reserved_pages(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
&n_used, &mtr);
- ibuf_enter();
+ ibuf_enter(&mtr);
ut_ad(n_used >= 2);
@@ -566,14 +556,12 @@ ibuf_init_at_db_start(void)
mutex_exit(&ibuf_mutex);
ibuf->empty = (page_get_n_recs(root) == 0);
- mtr_commit(&mtr);
-
- ibuf_exit();
+ ibuf_mtr_commit(&mtr);
heap = mem_heap_create(450);
/* Use old-style record format for the insert buffer. */
- table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0);
+ table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0, 0);
dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0);
@@ -608,11 +596,9 @@ ibuf_max_size_update(
{
ulint new_size = ((buf_pool_get_curr_size() / UNIV_PAGE_SIZE)
* new_val) / 100;
- ibuf_enter();
mutex_enter(&ibuf_mutex);
ibuf->max_size = new_size;
mutex_exit(&ibuf_mutex);
- ibuf_exit();
}
@@ -1248,19 +1234,30 @@ ibuf_page_low(
return(ret);
}
+#ifdef UNIV_DEBUG
+# define ibuf_rec_get_page_no(mtr,rec) ibuf_rec_get_page_no_func(mtr,rec)
+#else /* UNIV_DEBUG */
+# define ibuf_rec_get_page_no(mtr,rec) ibuf_rec_get_page_no_func(rec)
+#endif /* UNIV_DEBUG */
+
/********************************************************************//**
Returns the page number field of an ibuf record.
@return page number */
static
ulint
-ibuf_rec_get_page_no(
-/*=================*/
+ibuf_rec_get_page_no_func(
+/*======================*/
+#ifdef UNIV_DEBUG
+ mtr_t* mtr, /*!< in: mini-transaction owning rec */
+#endif /* UNIV_DEBUG */
const rec_t* rec) /*!< in: ibuf record */
{
const byte* field;
ulint len;
- ut_ad(ibuf_inside());
+ ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX)
+ || mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_S_FIX));
+ ut_ad(ibuf_inside(mtr));
ut_ad(rec_get_n_fields_old(rec) > 2);
field = rec_get_nth_field_old(rec, 1, &len);
@@ -1282,20 +1279,31 @@ ibuf_rec_get_page_no(
return(mach_read_from_4(field));
}
+#ifdef UNIV_DEBUG
+# define ibuf_rec_get_space(mtr,rec) ibuf_rec_get_space_func(mtr,rec)
+#else /* UNIV_DEBUG */
+# define ibuf_rec_get_space(mtr,rec) ibuf_rec_get_space_func(rec)
+#endif /* UNIV_DEBUG */
+
/********************************************************************//**
Returns the space id field of an ibuf record. For < 4.1.x format records
returns 0.
@return space id */
static
ulint
-ibuf_rec_get_space(
-/*===============*/
+ibuf_rec_get_space_func(
+/*====================*/
+#ifdef UNIV_DEBUG
+ mtr_t* mtr, /*!< in: mini-transaction owning rec */
+#endif /* UNIV_DEBUG */
const rec_t* rec) /*!< in: ibuf record */
{
const byte* field;
ulint len;
- ut_ad(ibuf_inside());
+ ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX)
+ || mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_S_FIX));
+ ut_ad(ibuf_inside(mtr));
ut_ad(rec_get_n_fields_old(rec) > 2);
field = rec_get_nth_field_old(rec, 1, &len);
@@ -1316,12 +1324,22 @@ ibuf_rec_get_space(
return(0);
}
+#ifdef UNIV_DEBUG
+# define ibuf_rec_get_info(mtr,rec,op,comp,info_len,counter) \
+ ibuf_rec_get_info_func(mtr,rec,op,comp,info_len,counter)
+#else /* UNIV_DEBUG */
+# define ibuf_rec_get_info(mtr,rec,op,comp,info_len,counter) \
+ ibuf_rec_get_info_func(rec,op,comp,info_len,counter)
+#endif
/****************************************************************//**
Get various information about an ibuf record in >= 4.1.x format. */
static
void
-ibuf_rec_get_info(
-/*==============*/
+ibuf_rec_get_info_func(
+/*===================*/
+#ifdef UNIV_DEBUG
+ mtr_t* mtr, /*!< in: mini-transaction owning rec */
+#endif /* UNIV_DEBUG */
const rec_t* rec, /*!< in: ibuf record */
ibuf_op_t* op, /*!< out: operation type, or NULL */
ibool* comp, /*!< out: compact flag, or NULL */
@@ -1340,7 +1358,9 @@ ibuf_rec_get_info(
ulint info_len_local;
ulint counter_local;
- ut_ad(ibuf_inside());
+ ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX)
+ || mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_S_FIX));
+ ut_ad(ibuf_inside(mtr));
fields = rec_get_n_fields_old(rec);
ut_a(fields > 4);
@@ -1389,18 +1409,29 @@ ibuf_rec_get_info(
}
}
+#ifdef UNIV_DEBUG
+# define ibuf_rec_get_op_type(mtr,rec) ibuf_rec_get_op_type_func(mtr,rec)
+#else /* UNIV_DEBUG */
+# define ibuf_rec_get_op_type(mtr,rec) ibuf_rec_get_op_type_func(rec)
+#endif
+
/****************************************************************//**
Returns the operation type field of an ibuf record.
@return operation type */
static
ibuf_op_t
-ibuf_rec_get_op_type(
-/*=================*/
+ibuf_rec_get_op_type_func(
+/*======================*/
+#ifdef UNIV_DEBUG
+ mtr_t* mtr, /*!< in: mini-transaction owning rec */
+#endif /* UNIV_DEBUG */
const rec_t* rec) /*!< in: ibuf record */
{
ulint len;
- ut_ad(ibuf_inside());
+ ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX)
+ || mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_S_FIX));
+ ut_ad(ibuf_inside(mtr));
ut_ad(rec_get_n_fields_old(rec) > 2);
(void) rec_get_nth_field_old(rec, 1, &len);
@@ -1412,7 +1443,7 @@ ibuf_rec_get_op_type(
} else {
ibuf_op_t op;
- ibuf_rec_get_info(rec, &op, NULL, NULL, NULL);
+ ibuf_rec_get_info(mtr, rec, &op, NULL, NULL, NULL);
return(op);
}
@@ -1515,7 +1546,7 @@ ibuf_dummy_index_create(
table = dict_mem_table_create("IBUF_DUMMY",
DICT_HDR_SPACE, n,
- comp ? DICT_TF_COMPACT : 0);
+ comp ? DICT_TF_COMPACT : 0, 0);
index = dict_mem_index_create("IBUF_DUMMY", "IBUF_DUMMY",
DICT_HDR_SPACE, 0, n);
@@ -1611,6 +1642,14 @@ ibuf_build_entry_pre_4_1_x(
return(tuple);
}
+#ifdef UNIV_DEBUG
+# define ibuf_build_entry_from_ibuf_rec(mtr,ibuf_rec,heap,pindex) \
+ ibuf_build_entry_from_ibuf_rec_func(mtr,ibuf_rec,heap,pindex)
+#else /* UNIV_DEBUG */
+# define ibuf_build_entry_from_ibuf_rec(mtr,ibuf_rec,heap,pindex) \
+ ibuf_build_entry_from_ibuf_rec_func(ibuf_rec,heap,pindex)
+#endif
+
/*********************************************************************//**
Builds the entry used to
@@ -1629,8 +1668,11 @@ hold a latch to the ibuf_rec page as lon
@return own: entry to insert to a non-clustered index */
static
dtuple_t*
-ibuf_build_entry_from_ibuf_rec(
-/*===========================*/
+ibuf_build_entry_from_ibuf_rec_func(
+/*================================*/
+#ifdef UNIV_DEBUG
+ mtr_t* mtr, /*!< in: mini-transaction owning rec */
+#endif /* UNIV_DEBUG */
const rec_t* ibuf_rec, /*!< in: record in an insert buffer */
mem_heap_t* heap, /*!< in: heap where built */
dict_index_t** pindex) /*!< out, own: dummy index that
@@ -1647,6 +1689,10 @@ ibuf_build_entry_from_ibuf_rec(
ulint comp;
dict_index_t* index;
+ ut_ad(mtr_memo_contains_page(mtr, ibuf_rec, MTR_MEMO_PAGE_X_FIX)
+ || mtr_memo_contains_page(mtr, ibuf_rec, MTR_MEMO_PAGE_S_FIX));
+ ut_ad(ibuf_inside(mtr));
+
data = rec_get_nth_field_old(ibuf_rec, 1, &len);
if (len > 1) {
@@ -1667,7 +1713,7 @@ ibuf_build_entry_from_ibuf_rec(
types = rec_get_nth_field_old(ibuf_rec, 3, &len);
- ibuf_rec_get_info(ibuf_rec, NULL, &comp, &info_len, NULL);
+ ibuf_rec_get_info(mtr, ibuf_rec, NULL, &comp, &info_len, NULL);
index = ibuf_dummy_index_create(n_fields, comp);
@@ -1754,6 +1800,12 @@ ibuf_rec_get_size(
return(size);
}
+#ifdef UNIV_DEBUG
+# define ibuf_rec_get_volume(mtr,rec) ibuf_rec_get_volume_func(mtr,rec)
+#else /* UNIV_DEBUG */
+# define ibuf_rec_get_volume(mtr,rec) ibuf_rec_get_volume_func(rec)
+#endif
+
/********************************************************************//**
Returns the space taken by a stored non-clustered index entry if converted to
an index record.
@@ -1761,8 +1813,11 @@ an index record.
taken in the page directory */
static
ulint
-ibuf_rec_get_volume(
-/*================*/
+ibuf_rec_get_volume_func(
+/*=====================*/
+#ifdef UNIV_DEBUG
+ mtr_t* mtr, /*!< in: mini-transaction owning rec */
+#endif /* UNIV_DEBUG */
const rec_t* ibuf_rec)/*!< in: ibuf record */
{
ulint len;
@@ -1773,7 +1828,9 @@ ibuf_rec_get_volume(
ibool pre_4_1;
ulint comp;
- ut_ad(ibuf_inside());
+ ut_ad(mtr_memo_contains_page(mtr, ibuf_rec, MTR_MEMO_PAGE_X_FIX)
+ || mtr_memo_contains_page(mtr, ibuf_rec, MTR_MEMO_PAGE_S_FIX));
+ ut_ad(ibuf_inside(mtr));
ut_ad(rec_get_n_fields_old(ibuf_rec) > 2);
data = rec_get_nth_field_old(ibuf_rec, 1, &len);
@@ -1801,7 +1858,7 @@ ibuf_rec_get_volume(
types = rec_get_nth_field_old(ibuf_rec, 3, &len);
- ibuf_rec_get_info(ibuf_rec, &op, &comp, &info_len, NULL);
+ ibuf_rec_get_info(mtr, ibuf_rec, &op, &comp, &info_len, NULL);
if (op == IBUF_OP_DELETE_MARK || op == IBUF_OP_DELETE) {
/* Delete-marking a record doesn't take any
@@ -1818,7 +1875,7 @@ ibuf_rec_get_volume(
mem_heap_t* heap = mem_heap_create(500);
entry = ibuf_build_entry_from_ibuf_rec(
- ibuf_rec, heap, &dummy_index);
+ mtr, ibuf_rec, heap, &dummy_index);
volume = rec_get_converted_size(dummy_index, entry, 0);
@@ -2176,21 +2233,15 @@ ibuf_add_free_page(void)
mtr_commit(&mtr);
return(FALSE);
- }
-
- {
- buf_block_t* block;
-
- block = buf_page_get(
+ } else {
+ buf_block_t* block = buf_page_get(
IBUF_SPACE_ID, 0, page_no, RW_X_LATCH, &mtr);
-
buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW);
-
page = buf_block_get_frame(block);
}
- ibuf_enter();
+ ibuf_enter(&mtr);
mutex_enter(&ibuf_mutex);
@@ -2218,9 +2269,7 @@ ibuf_add_free_page(void)
ibuf_bitmap_page_set_bits(
bitmap_page, page_no, zip_size, IBUF_BITMAP_IBUF, TRUE, &mtr);
- mtr_commit(&mtr);
-
- ibuf_exit();
+ ibuf_mtr_commit(&mtr);
return(TRUE);
}
@@ -2252,7 +2301,7 @@ ibuf_remove_free_page(void)
header_page = ibuf_header_page_get(&mtr);
/* Prevent pessimistic inserts to insert buffer trees for a while */
- ibuf_enter();
+ ibuf_enter(&mtr);
mutex_enter(&ibuf_pessimistic_insert_mutex);
mutex_enter(&ibuf_mutex);
@@ -2261,14 +2310,12 @@ ibuf_remove_free_page(void)
mutex_exit(&ibuf_mutex);
mutex_exit(&ibuf_pessimistic_insert_mutex);
- ibuf_exit();
-
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
return;
}
- mtr_start(&mtr2);
+ ibuf_mtr_start(&mtr2);
root = ibuf_tree_root_get(&mtr2);
@@ -2281,9 +2328,8 @@ ibuf_remove_free_page(void)
because in fseg_free_page we access level 1 pages, and the root
is a level 2 page. */
- mtr_commit(&mtr2);
-
- ibuf_exit();
+ ibuf_mtr_commit(&mtr2);
+ ibuf_exit(&mtr);
/* Since pessimistic inserts were prevented, we know that the
page is still in the free list. NOTE that also deletes may take
@@ -2298,7 +2344,7 @@ ibuf_remove_free_page(void)
buf_page_reset_file_page_was_freed(IBUF_SPACE_ID, page_no);
#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
- ibuf_enter();
+ ibuf_enter(&mtr);
mutex_enter(&ibuf_mutex);
@@ -2343,9 +2389,7 @@ ibuf_remove_free_page(void)
#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
buf_page_set_file_page_was_freed(IBUF_SPACE_ID, page_no);
#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
- mtr_commit(&mtr);
-
- ibuf_exit();
+ ibuf_mtr_commit(&mtr);
}
/***********************************************************************//**
@@ -2367,8 +2411,6 @@ ibuf_free_excess_pages(void)
ut_ad(rw_lock_get_x_lock_count(
fil_space_get_latch(IBUF_SPACE_ID, NULL)) == 1);
- ut_ad(!ibuf_inside());
-
/* NOTE: We require that the thread did not own the latch before,
because then we know that we can obey the correct latching order
for ibuf latches */
@@ -2399,20 +2441,30 @@ ibuf_free_excess_pages(void)
}
}
+#ifdef UNIV_DEBUG
+# define ibuf_get_merge_page_nos(contract,rec,mtr,ids,vers,pages,n_stored) \
+ ibuf_get_merge_page_nos_func(contract,rec,mtr,ids,vers,pages,n_stored)
+#else /* UNIV_DEBUG */
+# define ibuf_get_merge_page_nos(contract,rec,mtr,ids,vers,pages,n_stored) \
+ ibuf_get_merge_page_nos_func(contract,rec,ids,vers,pages,n_stored)
+#endif /* UNIV_DEBUG */
+
/*********************************************************************//**
Reads page numbers from a leaf in an ibuf tree.
@return a lower limit for the combined volume of records which will be
merged */
static
ulint
-ibuf_get_merge_page_nos(
-/*====================*/
+ibuf_get_merge_page_nos_func(
+/*=========================*/
ibool contract,/*!< in: TRUE if this function is called to
contract the tree, FALSE if this is called
when a single page becomes full and we look
if it pays to read also nearby pages */
- rec_t* rec, /*!< in: record from which we read up and down
- in the chain of records */
+ const rec_t* rec, /*!< in: insert buffer record */
+#ifdef UNIV_DEBUG
+ mtr_t* mtr, /*!< in: mini-transaction holding rec */
+#endif /* UNIV_DEBUG */
ulint* space_ids,/*!< in/out: space id's of the pages */
ib_int64_t* space_versions,/*!< in/out: tablespace version
timestamps; used to prevent reading in old
@@ -2435,18 +2487,22 @@ ibuf_get_merge_page_nos(
ulint limit;
ulint n_pages;
+ ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX)
+ || mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_S_FIX));
+ ut_ad(ibuf_inside(mtr));
+
*n_stored = 0;
limit = ut_min(IBUF_MAX_N_PAGES_MERGED, buf_pool_get_curr_size() / 4);
if (page_rec_is_supremum(rec)) {
- rec = page_rec_get_prev(rec);
+ rec = page_rec_get_prev_const(rec);
}
if (page_rec_is_infimum(rec)) {
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
}
if (page_rec_is_supremum(rec)) {
@@ -2454,8 +2510,8 @@ ibuf_get_merge_page_nos(
return(0);
}
- first_page_no = ibuf_rec_get_page_no(rec);
- first_space_id = ibuf_rec_get_space(rec);
+ first_page_no = ibuf_rec_get_page_no(mtr, rec);
+ first_space_id = ibuf_rec_get_space(mtr, rec);
n_pages = 0;
prev_page_no = 0;
prev_space_id = 0;
@@ -2466,8 +2522,8 @@ ibuf_get_merge_page_nos(
while (!page_rec_is_infimum(rec) && UNIV_LIKELY(n_pages < limit)) {
- rec_page_no = ibuf_rec_get_page_no(rec);
- rec_space_id = ibuf_rec_get_space(rec);
+ rec_page_no = ibuf_rec_get_page_no(mtr, rec);
+ rec_space_id = ibuf_rec_get_space(mtr, rec);
if (rec_space_id != first_space_id
|| (rec_page_no / IBUF_MERGE_AREA)
@@ -2484,10 +2540,10 @@ ibuf_get_merge_page_nos(
prev_page_no = rec_page_no;
prev_space_id = rec_space_id;
- rec = page_rec_get_prev(rec);
+ rec = page_rec_get_prev_const(rec);
}
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
/* At the loop start there is no prev page; we mark this with a pair
of space id, page no (0, 0) for which there can never be entries in
@@ -2505,8 +2561,8 @@ ibuf_get_merge_page_nos(
rec_page_no = 1;
rec_space_id = 0;
} else {
- rec_page_no = ibuf_rec_get_page_no(rec);
- rec_space_id = ibuf_rec_get_space(rec);
+ rec_page_no = ibuf_rec_get_page_no(mtr, rec);
+ rec_space_id = ibuf_rec_get_space(mtr, rec);
ut_ad(rec_page_no > IBUF_TREE_ROOT_PAGE_NO);
}
@@ -2517,9 +2573,9 @@ ibuf_get_merge_page_nos(
|| rec_page_no != prev_page_no)
&& (prev_space_id != 0 || prev_page_no != 0)) {
- if ((prev_page_no == first_page_no
- && prev_space_id == first_space_id)
- || contract
+ if (contract
+ || (prev_page_no == first_page_no
+ && prev_space_id == first_space_id)
|| (volume_for_page
> ((IBUF_MERGE_THRESHOLD - 1)
* 4 * UNIV_PAGE_SIZE
@@ -2552,14 +2608,14 @@ ibuf_get_merge_page_nos(
break;
}
- rec_volume = ibuf_rec_get_volume(rec);
+ rec_volume = ibuf_rec_get_volume(mtr, rec);
volume_for_page += rec_volume;
prev_page_no = rec_page_no;
prev_space_id = rec_space_id;
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
}
#ifdef UNIV_IBUF_DEBUG
@@ -2594,7 +2650,6 @@ ibuf_contract_ext(
mtr_t mtr;
*n_pages = 0;
- ut_ad(!ibuf_inside());
/* We perform a dirty read of ibuf->empty, without latching
the insert buffer root page. We trust this dirty read except
@@ -2606,9 +2661,7 @@ ibuf_contract_ext(
return(0);
}
- mtr_start(&mtr);
-
- ibuf_enter();
+ ibuf_mtr_start(&mtr);
/* Open a cursor to a randomly chosen leaf of the tree, at a random
position within the leaf */
@@ -2627,24 +2680,21 @@ ibuf_contract_ext(
ut_ad(page_get_page_no(btr_pcur_get_page(&pcur))
== FSP_IBUF_TREE_ROOT_PAGE_NO);
- ibuf_exit();
-
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
btr_pcur_close(&pcur);
return(0);
}
- sum_sizes = ibuf_get_merge_page_nos(TRUE, btr_pcur_get_rec(&pcur),
+ sum_sizes = ibuf_get_merge_page_nos(TRUE,
+ btr_pcur_get_rec(&pcur), &mtr,
space_ids, space_versions,
page_nos, n_pages);
#if 0 /* defined UNIV_IBUF_DEBUG */
fprintf(stderr, "Ibuf contract sync %lu pages %lu volume %lu\n",
sync, *n_pages, sum_sizes);
#endif
- ibuf_exit();
-
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
btr_pcur_close(&pcur);
buf_read_ibuf_merge_pages(sync, space_ids, space_versions, page_nos,
@@ -2695,13 +2745,11 @@ ibuf_contract_in_background(
/* Caller has requested a full batch */
n_pages = PCT_IO(100);
} else {
-
- ibuf_enter();
- mutex_enter(&ibuf_mutex);
-
/* By default we do a batch of 5% of the io_capacity */
n_pages = PCT_IO(5);
+ mutex_enter(&ibuf_mutex);
+
/* If the ibuf->size is more than half the max_size
then we make more agreesive contraction.
+1 is to avoid division by zero. */
@@ -2712,7 +2760,6 @@ ibuf_contract_in_background(
}
mutex_exit(&ibuf_mutex);
- ibuf_exit();
}
while (sum_pages < n_pages) {
@@ -2807,6 +2854,13 @@ ibuf_get_volume_buffered_hash(
return(TRUE);
}
+#ifdef UNIV_DEBUG
+# define ibuf_get_volume_buffered_count(mtr,rec,hash,size,n_recs) \
+ ibuf_get_volume_buffered_count_func(mtr,rec,hash,size,n_recs)
+#else /* UNIV_DEBUG */
+# define ibuf_get_volume_buffered_count(mtr,rec,hash,size,n_recs) \
+ ibuf_get_volume_buffered_count_func(rec,hash,size,n_recs)
+#endif
/*********************************************************************//**
Update the estimate of the number of records on a page, and
get the space taken by merging the buffered record to the index page.
@@ -2814,8 +2868,11 @@ get the space taken by merging the buffe
taken in the page directory */
static
ulint
-ibuf_get_volume_buffered_count(
-/*===========================*/
+ibuf_get_volume_buffered_count_func(
+/*================================*/
+#ifdef UNIV_DEBUG
+ mtr_t* mtr, /*!< in: mini-transaction owning rec */
+#endif /* UNIV_DEBUG */
const rec_t* rec, /*!< in: insert buffer record */
ulint* hash, /*!< in/out: hash array */
ulint size, /*!< in: number of elements in hash array */
@@ -2825,9 +2882,13 @@ ibuf_get_volume_buffered_count(
ulint len;
ibuf_op_t ibuf_op;
const byte* types;
- ulint n_fields = rec_get_n_fields_old(rec);
+ ulint n_fields;
+
+ ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX)
+ || mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_S_FIX));
+ ut_ad(ibuf_inside(mtr));
- ut_ad(ibuf_inside());
+ n_fields = rec_get_n_fields_old(rec);
ut_ad(n_fields > 4);
n_fields -= 4;
@@ -2912,7 +2973,7 @@ get_volume_comp:
mem_heap_t* heap = mem_heap_create(500);
entry = ibuf_build_entry_from_ibuf_rec(
- rec, heap, &dummy_index);
+ mtr, rec, heap, &dummy_index);
volume = rec_get_converted_size(dummy_index, entry, 0);
@@ -2933,7 +2994,7 @@ static
ulint
ibuf_get_volume_buffered(
/*=====================*/
- btr_pcur_t* pcur, /*!< in: pcur positioned at a place in an
+ const btr_pcur_t*pcur, /*!< in: pcur positioned at a place in an
insert buffer tree where we would insert an
entry for the index page whose number is
page_no, latch mode has to be BTR_MODIFY_PREV
@@ -2943,16 +3004,17 @@ ibuf_get_volume_buffered(
lint* n_recs, /*!< in/out: minimum number of records on the
page after the buffered changes have been
applied, or NULL to disable the counting */
- mtr_t* mtr) /*!< in: mtr */
+ mtr_t* mtr) /*!< in: mini-transaction of pcur */
{
- ulint volume;
- rec_t* rec;
- page_t* page;
- ulint prev_page_no;
- page_t* prev_page;
- ulint next_page_no;
- page_t* next_page;
- ulint hash_bitmap[128 / sizeof(ulint)]; /* bitmap of buffered recs */
+ ulint volume;
+ const rec_t* rec;
+ const page_t* page;
+ ulint prev_page_no;
+ const page_t* prev_page;
+ ulint next_page_no;
+ const page_t* next_page;
+ /* bitmap of buffered recs */
+ ulint hash_bitmap[128 / sizeof(ulint)];
ut_a(trx_sys_multiple_tablespace_format);
@@ -2973,26 +3035,22 @@ ibuf_get_volume_buffered(
ut_ad(page_validate(page, ibuf->index));
if (page_rec_is_supremum(rec)) {
- rec = page_rec_get_prev(rec);
+ rec = page_rec_get_prev_const(rec);
}
- for (;;) {
- if (page_rec_is_infimum(rec)) {
-
- break;
- }
+ for (; !page_rec_is_infimum(rec);
+ rec = page_rec_get_prev_const(rec)) {
+ ut_ad(page_align(rec) == page);
- if (page_no != ibuf_rec_get_page_no(rec)
- || space != ibuf_rec_get_space(rec)) {
+ if (page_no != ibuf_rec_get_page_no(mtr, rec)
+ || space != ibuf_rec_get_space(mtr, rec)) {
goto count_later;
}
volume += ibuf_get_volume_buffered_count(
- rec, hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs);
-
- rec = page_rec_get_prev(rec);
- ut_ad(page_align(rec) == page);
+ mtr, rec,
+ hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs);
}
/* Look at the previous page */
@@ -3008,7 +3066,8 @@ ibuf_get_volume_buffered(
buf_block_t* block;
block = buf_page_get(
- IBUF_SPACE_ID, 0, prev_page_no, RW_X_LATCH, mtr);
+ IBUF_SPACE_ID, 0, prev_page_no, RW_X_LATCH,
+ mtr);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
@@ -3018,14 +3077,15 @@ ibuf_get_volume_buffered(
}
#ifdef UNIV_BTR_DEBUG
- ut_a(btr_page_get_next(prev_page, mtr)
- == page_get_page_no(page));
+ ut_a(btr_page_get_next(prev_page, mtr) == page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
rec = page_get_supremum_rec(prev_page);
- rec = page_rec_get_prev(rec);
+ rec = page_rec_get_prev_const(rec);
+
+ for (;; rec = page_rec_get_prev_const(rec)) {
+ ut_ad(page_align(rec) == prev_page);
- for (;;) {
if (page_rec_is_infimum(rec)) {
/* We cannot go to yet a previous page, because we
@@ -3035,42 +3095,35 @@ ibuf_get_volume_buffered(
return(UNIV_PAGE_SIZE);
}
- if (page_no != ibuf_rec_get_page_no(rec)
- || space != ibuf_rec_get_space(rec)) {
+ if (page_no != ibuf_rec_get_page_no(mtr, rec)
+ || space != ibuf_rec_get_space(mtr, rec)) {
goto count_later;
}
volume += ibuf_get_volume_buffered_count(
- rec, hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs);
-
- rec = page_rec_get_prev(rec);
- ut_ad(page_align(rec) == prev_page);
+ mtr, rec,
+ hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs);
}
count_later:
rec = btr_pcur_get_rec(pcur);
if (!page_rec_is_supremum(rec)) {
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
}
- for (;;) {
- if (page_rec_is_supremum(rec)) {
-
- break;
- }
-
- if (page_no != ibuf_rec_get_page_no(rec)
- || space != ibuf_rec_get_space(rec)) {
+ for (; !page_rec_is_supremum(rec);
+ rec = page_rec_get_next_const(rec)) {
+ if (page_no != ibuf_rec_get_page_no(mtr, rec)
+ || space != ibuf_rec_get_space(mtr, rec)) {
return(volume);
}
volume += ibuf_get_volume_buffered_count(
- rec, hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs);
-
- rec = page_rec_get_next(rec);
+ mtr, rec,
+ hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs);
}
/* Look at the next page */
@@ -3086,7 +3139,8 @@ count_later:
buf_block_t* block;
block = buf_page_get(
- IBUF_SPACE_ID, 0, next_page_no, RW_X_LATCH, mtr);
+ IBUF_SPACE_ID, 0, next_page_no, RW_X_LATCH,
+ mtr);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
@@ -3100,9 +3154,11 @@ count_later:
#endif /* UNIV_BTR_DEBUG */
rec = page_get_infimum_rec(next_page);
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
+
+ for (;; rec = page_rec_get_next_const(rec)) {
+ ut_ad(page_align(rec) == next_page);
- for (;;) {
if (page_rec_is_supremum(rec)) {
/* We give up */
@@ -3110,17 +3166,15 @@ count_later:
return(UNIV_PAGE_SIZE);
}
- if (page_no != ibuf_rec_get_page_no(rec)
- || space != ibuf_rec_get_space(rec)) {
+ if (page_no != ibuf_rec_get_page_no(mtr, rec)
+ || space != ibuf_rec_get_space(mtr, rec)) {
return(volume);
}
volume += ibuf_get_volume_buffered_count(
- rec, hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs);
-
- rec = page_rec_get_next(rec);
- ut_ad(page_align(rec) == next_page);
+ mtr, rec,
+ hash_bitmap, UT_ARR_SIZE(hash_bitmap), n_recs);
}
}
@@ -3141,9 +3195,7 @@ ibuf_update_max_tablespace_id(void)
ut_a(!dict_table_is_comp(ibuf->index->table));
- ibuf_enter();
-
- mtr_start(&mtr);
+ ibuf_mtr_start(&mtr);
btr_pcur_open_at_index_side(
FALSE, ibuf->index, BTR_SEARCH_LEAF, &pcur, TRUE, &mtr);
@@ -3166,14 +3218,20 @@ ibuf_update_max_tablespace_id(void)
max_space_id = mach_read_from_4(field);
}
- mtr_commit(&mtr);
- ibuf_exit();
+ ibuf_mtr_commit(&mtr);
/* printf("Maximum space id in insert buffer %lu\n", max_space_id); */
fil_set_max_space_id_if_bigger(max_space_id);
}
+#ifdef UNIV_DEBUG
+# define ibuf_get_entry_counter_low(mtr,rec,space,page_no) \
+ ibuf_get_entry_counter_low_func(mtr,rec,space,page_no)
+#else /* UNIV_DEBUG */
+# define ibuf_get_entry_counter_low(mtr,rec,space,page_no) \
+ ibuf_get_entry_counter_low_func(rec,space,page_no)
+#endif
/****************************************************************//**
Helper function for ibuf_set_entry_counter. Checks if rec is for (space,
page_no), and if so, reads counter value from it and returns that + 1.
@@ -3181,8 +3239,11 @@ Otherwise, returns 0.
@return new counter value, or 0 */
static
ulint
-ibuf_get_entry_counter_low(
-/*=======================*/
+ibuf_get_entry_counter_low_func(
+/*============================*/
+#ifdef UNIV_DEBUG
+ mtr_t* mtr, /*!< in: mini-transaction of rec */
+#endif /* UNIV_DEBUG */
const rec_t* rec, /*!< in: insert buffer record */
ulint space, /*!< in: space id */
ulint page_no) /*!< in: page number */
@@ -3191,7 +3252,9 @@ ibuf_get_entry_counter_low(
const byte* field;
ulint len;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
+ ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX)
+ || mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_S_FIX));
ut_ad(rec_get_n_fields_old(rec) > 2);
field = rec_get_nth_field_old(rec, 1, &len);
@@ -3263,12 +3326,15 @@ ibuf_set_entry_counter(
ulint counter = 0;
/* pcur points to either a user rec or to a page's infimum record. */
+ ut_ad(ibuf_inside(mtr));
+ ut_ad(mtr_memo_contains(mtr, btr_pcur_get_block(pcur),
+ MTR_MEMO_PAGE_X_FIX));
ut_ad(page_validate(btr_pcur_get_page(pcur), ibuf->index));
if (btr_pcur_is_on_user_rec(pcur)) {
counter = ibuf_get_entry_counter_low(
- btr_pcur_get_rec(pcur), space, page_no);
+ mtr, btr_pcur_get_rec(pcur), space, page_no);
if (UNIV_UNLIKELY(counter == ULINT_UNDEFINED)) {
/* The record lacks a counter field.
@@ -3324,7 +3390,7 @@ ibuf_set_entry_counter(
ut_ad(page_rec_is_user_rec(rec));
counter = ibuf_get_entry_counter_low(
- rec, space, page_no);
+ mtr, rec, space, page_no);
if (UNIV_UNLIKELY(counter == ULINT_UNDEFINED)) {
/* The record lacks a counter field.
@@ -3478,7 +3544,6 @@ ibuf_insert_low(
if (mode == BTR_MODIFY_TREE) {
for (;;) {
- ibuf_enter();
mutex_enter(&ibuf_pessimistic_insert_mutex);
mutex_enter(&ibuf_mutex);
@@ -3489,7 +3554,6 @@ ibuf_insert_low(
mutex_exit(&ibuf_mutex);
mutex_exit(&ibuf_pessimistic_insert_mutex);
- ibuf_exit();
if (UNIV_UNLIKELY(!ibuf_add_free_page())) {
@@ -3497,11 +3561,9 @@ ibuf_insert_low(
return(DB_STRONG_FAIL);
}
}
- } else {
- ibuf_enter();
}
- mtr_start(&mtr);
+ ibuf_mtr_start(&mtr);
btr_pcur_open(ibuf->index, ibuf_entry, PAGE_CUR_LE, mode, &pcur, &mtr);
ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf->index));
@@ -3556,7 +3618,7 @@ fail_exit:
#ifdef UNIV_IBUF_COUNT_DEBUG
ut_a((buffered == 0) || ibuf_count_get(space, page_no));
#endif
- mtr_start(&bitmap_mtr);
+ ibuf_mtr_start(&bitmap_mtr);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
zip_size, &bitmap_mtr);
@@ -3577,15 +3639,15 @@ fail_exit:
if (buffered + entry_size + page_dir_calc_reserved_space(1)
> ibuf_index_page_calc_free_from_bits(zip_size, bits)) {
/* Release the bitmap page latch early. */
- mtr_commit(&bitmap_mtr);
+ ibuf_mtr_commit(&bitmap_mtr);
/* It may not fit */
do_merge = TRUE;
- ibuf_get_merge_page_nos(
- FALSE, btr_pcur_get_rec(&pcur),
- space_ids, space_versions,
- page_nos, &n_stored);
+ ibuf_get_merge_page_nos(FALSE,
+ btr_pcur_get_rec(&pcur), &mtr,
+ space_ids, space_versions,
+ page_nos, &n_stored);
goto fail_exit;
}
@@ -3598,7 +3660,7 @@ fail_exit:
&& !ibuf_set_entry_counter(ibuf_entry, space, page_no, &pcur,
mode == BTR_MODIFY_PREV, &mtr)) {
bitmap_fail:
- mtr_commit(&bitmap_mtr);
+ ibuf_mtr_commit(&bitmap_mtr);
goto fail_exit;
}
@@ -3616,7 +3678,7 @@ bitmap_fail:
&bitmap_mtr);
}
- mtr_commit(&bitmap_mtr);
+ ibuf_mtr_commit(&bitmap_mtr);
cursor = btr_pcur_get_btr_cur(&pcur);
@@ -3681,9 +3743,8 @@ func_exit:
}
#endif
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
btr_pcur_close(&pcur);
- ibuf_exit();
mem_heap_free(heap);
@@ -3937,7 +3998,7 @@ ibuf_insert_to_index_page(
page_t* page = buf_block_get_frame(block);
rec_t* rec;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
ut_ad(dtuple_check_typed(entry));
ut_ad(!buf_block_align(page)->is_hashed);
@@ -4084,7 +4145,7 @@ ibuf_set_del_mark(
page_cur_t page_cur;
ulint low_match;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
ut_ad(dtuple_check_typed(entry));
low_match = page_cur_search(
@@ -4141,7 +4202,7 @@ ibuf_delete(
page_cur_t page_cur;
ulint low_match;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
ut_ad(dtuple_check_typed(entry));
low_match = page_cur_search(
@@ -4229,7 +4290,7 @@ ibuf_restore_pos(
/* The tablespace has been dropped. It is possible
that another thread has deleted the insert buffer
entry. Do not complain. */
- btr_pcur_commit_specify_mtr(pcur, mtr);
+ ibuf_btr_pcur_commit_specify_mtr(pcur, mtr);
} else {
fprintf(stderr,
"InnoDB: ERROR: Submit the output to"
@@ -4247,7 +4308,7 @@ ibuf_restore_pos(
page_rec_get_next(btr_pcur_get_rec(pcur)));
fflush(stderr);
- btr_pcur_commit_specify_mtr(pcur, mtr);
+ ibuf_btr_pcur_commit_specify_mtr(pcur, mtr);
fputs("InnoDB: Validating insert buffer tree:\n", stderr);
if (!btr_validate_index(ibuf->index, NULL)) {
@@ -4271,8 +4332,8 @@ ibool
ibuf_delete_rec(
/*============*/
ulint space, /*!< in: space id */
- ulint page_no,/*!< in: index page number where the record
- should belong */
+ ulint page_no,/*!< in: index page number that the record
+ should belong to */
btr_pcur_t* pcur, /*!< in: pcur positioned on the record to
delete, having latch mode BTR_MODIFY_LEAF */
const dtuple_t* search_tuple,
@@ -4283,10 +4344,10 @@ ibuf_delete_rec(
page_t* root;
ulint err;
- ut_ad(ibuf_inside());
+ ut_ad(ibuf_inside(mtr));
ut_ad(page_rec_is_user_rec(btr_pcur_get_rec(pcur)));
- ut_ad(ibuf_rec_get_page_no(btr_pcur_get_rec(pcur)) == page_no);
- ut_ad(ibuf_rec_get_space(btr_pcur_get_rec(pcur)) == space);
+ ut_ad(ibuf_rec_get_page_no(mtr, btr_pcur_get_rec(pcur)) == page_no);
+ ut_ad(ibuf_rec_get_space(mtr, btr_pcur_get_rec(pcur)) == space);
success = btr_cur_optimistic_delete(btr_pcur_get_btr_cur(pcur), mtr);
@@ -4319,22 +4380,22 @@ ibuf_delete_rec(
}
ut_ad(page_rec_is_user_rec(btr_pcur_get_rec(pcur)));
- ut_ad(ibuf_rec_get_page_no(btr_pcur_get_rec(pcur)) == page_no);
- ut_ad(ibuf_rec_get_space(btr_pcur_get_rec(pcur)) == space);
+ ut_ad(ibuf_rec_get_page_no(mtr, btr_pcur_get_rec(pcur)) == page_no);
+ ut_ad(ibuf_rec_get_space(mtr, btr_pcur_get_rec(pcur)) == space);
/* We have to resort to a pessimistic delete from ibuf */
btr_pcur_store_position(pcur, mtr);
+ ibuf_btr_pcur_commit_specify_mtr(pcur, mtr);
- btr_pcur_commit_specify_mtr(pcur, mtr);
-
+ ibuf_mtr_start(mtr);
mutex_enter(&ibuf_mutex);
- mtr_start(mtr);
-
if (!ibuf_restore_pos(space, page_no, search_tuple,
BTR_MODIFY_TREE, pcur, mtr)) {
mutex_exit(&ibuf_mutex);
+ ut_ad(!ibuf_inside(mtr));
+ ut_ad(mtr->state == MTR_COMMITTED);
goto func_exit;
}
@@ -4351,9 +4412,11 @@ ibuf_delete_rec(
mutex_exit(&ibuf_mutex);
ibuf->empty = (page_get_n_recs(root) == 0);
- btr_pcur_commit_specify_mtr(pcur, mtr);
+ ibuf_btr_pcur_commit_specify_mtr(pcur, mtr);
func_exit:
+ ut_ad(!ibuf_inside(mtr));
+ ut_ad(mtr->state == MTR_COMMITTED);
btr_pcur_close(pcur);
return(TRUE);
@@ -4445,18 +4508,20 @@ ibuf_merge_or_delete_for_page(
update_ibuf_bitmap = FALSE;
} else {
page_t* bitmap_page;
+ ulint bitmap_bits;
- mtr_start(&mtr);
+ ibuf_mtr_start(&mtr);
bitmap_page = ibuf_bitmap_get_map_page(
space, page_no, zip_size, &mtr);
+ bitmap_bits = ibuf_bitmap_page_get_bits(
+ bitmap_page, page_no, zip_size,
+ IBUF_BITMAP_BUFFERED, &mtr);
+
+ ibuf_mtr_commit(&mtr);
- if (!ibuf_bitmap_page_get_bits(bitmap_page, page_no,
- zip_size,
- IBUF_BITMAP_BUFFERED,
- &mtr)) {
+ if (!bitmap_bits) {
/* No inserts buffered for this page */
- mtr_commit(&mtr);
if (!tablespace_being_deleted) {
fil_decr_pending_ibuf_merges(space);
@@ -4464,7 +4529,6 @@ ibuf_merge_or_delete_for_page(
return;
}
- mtr_commit(&mtr);
}
} else if (block
&& (ibuf_fixed_addr_page(space, zip_size, page_no)
@@ -4473,11 +4537,9 @@ ibuf_merge_or_delete_for_page(
return;
}
- ibuf_enter();
-
heap = mem_heap_create(512);
- if (!trx_sys_multiple_tablespace_format) {
+ if (UNIV_UNLIKELY(!trx_sys_multiple_tablespace_format)) {
ut_a(trx_doublewrite_must_reset_space_ids);
search_tuple = ibuf_search_tuple_build(space, page_no, heap);
} else {
@@ -4504,7 +4566,7 @@ ibuf_merge_or_delete_for_page(
ut_print_timestamp(stderr);
- mtr_start(&mtr);
+ ibuf_mtr_start(&mtr);
fputs(" InnoDB: Dump of the ibuf bitmap page:\n",
stderr);
@@ -4512,8 +4574,7 @@ ibuf_merge_or_delete_for_page(
bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
zip_size, &mtr);
buf_page_print(bitmap_page, 0);
-
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
fputs("\nInnoDB: Dump of the page:\n", stderr);
@@ -4544,7 +4605,7 @@ ibuf_merge_or_delete_for_page(
memset(dops, 0, sizeof(dops));
loop:
- mtr_start(&mtr);
+ ibuf_mtr_start(&mtr);
if (block) {
ibool success;
@@ -4578,8 +4639,8 @@ loop:
rec = btr_pcur_get_rec(&pcur);
/* Check if the entry is for this index page */
- if (ibuf_rec_get_page_no(rec) != page_no
- || ibuf_rec_get_space(rec) != space) {
+ if (ibuf_rec_get_page_no(&mtr, rec) != page_no
+ || ibuf_rec_get_space(&mtr, rec) != space) {
if (block) {
page_header_reset_last_insert(
@@ -4602,7 +4663,7 @@ loop:
dtuple_t* entry;
trx_id_t max_trx_id;
dict_index_t* dummy_index;
- ibuf_op_t op = ibuf_rec_get_op_type(rec);
+ ibuf_op_t op = ibuf_rec_get_op_type(&mtr, rec);
max_trx_id = page_get_max_trx_id(page_align(rec));
page_update_max_trx_id(block, page_zip, max_trx_id,
@@ -4611,7 +4672,7 @@ loop:
ut_ad(page_validate(page_align(rec), ibuf->index));
entry = ibuf_build_entry_from_ibuf_rec(
- rec, heap, &dummy_index);
+ &mtr, rec, heap, &dummy_index);
ut_ad(page_validate(block->frame, dummy_index));
@@ -4644,13 +4705,14 @@ loop:
Store and restore the cursor position. */
ut_ad(rec == btr_pcur_get_rec(&pcur));
ut_ad(page_rec_is_user_rec(rec));
- ut_ad(ibuf_rec_get_page_no(rec) == page_no);
- ut_ad(ibuf_rec_get_space(rec) == space);
+ ut_ad(ibuf_rec_get_page_no(&mtr, rec)
+ == page_no);
+ ut_ad(ibuf_rec_get_space(&mtr, rec) == space);
btr_pcur_store_position(&pcur, &mtr);
- btr_pcur_commit_specify_mtr(&pcur, &mtr);
+ ibuf_btr_pcur_commit_specify_mtr(&pcur, &mtr);
- mtr_start(&mtr);
+ ibuf_mtr_start(&mtr);
success = buf_page_get_known_nowait(
RW_X_LATCH, block,
@@ -4665,7 +4727,8 @@ loop:
BTR_MODIFY_LEAF,
&pcur, &mtr)) {
- mtr_commit(&mtr);
+ ut_ad(!ibuf_inside(&mtr));
+ ut_ad(mtr.state == MTR_COMMITTED);
mops[op]++;
ibuf_dummy_index_free(dummy_index);
goto loop;
@@ -4680,7 +4743,7 @@ loop:
ibuf_dummy_index_free(dummy_index);
} else {
- dops[ibuf_rec_get_op_type(rec)]++;
+ dops[ibuf_rec_get_op_type(&mtr, rec)]++;
}
/* Delete the record from ibuf */
@@ -4691,7 +4754,7 @@ loop:
goto loop;
} else if (btr_pcur_is_after_last_on_page(&pcur)) {
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
btr_pcur_close(&pcur);
goto loop;
@@ -4725,7 +4788,7 @@ reset_bit:
}
}
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
btr_pcur_close(&pcur);
mem_heap_free(heap);
@@ -4749,8 +4812,6 @@ reset_bit:
fil_decr_pending_ibuf_merges(space);
}
- ibuf_exit();
-
#ifdef UNIV_IBUF_COUNT_DEBUG
ut_a(ibuf_count_get(space, page_no) == 0);
#endif
@@ -4770,9 +4831,8 @@ ibuf_delete_for_discarded_space(
mem_heap_t* heap;
btr_pcur_t pcur;
dtuple_t* search_tuple;
- rec_t* ibuf_rec;
+ const rec_t* ibuf_rec;
ulint page_no;
- ibool closed;
mtr_t mtr;
/* Counts for discarded operations. */
@@ -4787,9 +4847,7 @@ ibuf_delete_for_discarded_space(
memset(dops, 0, sizeof(dops));
loop:
- ibuf_enter();
-
- mtr_start(&mtr);
+ ibuf_mtr_start(&mtr);
/* Position pcur in the insert buffer at the first entry for the
space */
@@ -4809,39 +4867,34 @@ loop:
ibuf_rec = btr_pcur_get_rec(&pcur);
/* Check if the entry is for this space */
- if (ibuf_rec_get_space(ibuf_rec) != space) {
+ if (ibuf_rec_get_space(&mtr, ibuf_rec) != space) {
goto leave_loop;
}
- page_no = ibuf_rec_get_page_no(ibuf_rec);
+ page_no = ibuf_rec_get_page_no(&mtr, ibuf_rec);
- dops[ibuf_rec_get_op_type(ibuf_rec)]++;
+ dops[ibuf_rec_get_op_type(&mtr, ibuf_rec)]++;
/* Delete the record from ibuf */
- closed = ibuf_delete_rec(space, page_no, &pcur, search_tuple,
- &mtr);
- if (closed) {
+ if (ibuf_delete_rec(space, page_no, &pcur, search_tuple,
+ &mtr)) {
/* Deletion was pessimistic and mtr was committed:
we start from the beginning again */
- ibuf_exit();
-
goto loop;
}
if (btr_pcur_is_after_last_on_page(&pcur)) {
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
btr_pcur_close(&pcur);
- ibuf_exit();
-
goto loop;
}
}
leave_loop:
- mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
btr_pcur_close(&pcur);
#ifdef HAVE_ATOMIC_BUILTINS
@@ -4853,8 +4906,6 @@ leave_loop:
mutex_exit(&ibuf_mutex);
#endif /* HAVE_ATOMIC_BUILTINS */
- ibuf_exit();
-
mem_heap_free(heap);
}
@@ -4870,18 +4921,15 @@ ibuf_is_empty(void)
const page_t* root;
mtr_t mtr;
- ibuf_enter();
- mtr_start(&mtr);
+ ibuf_mtr_start(&mtr);
mutex_enter(&ibuf_mutex);
root = ibuf_tree_root_get(&mtr);
mutex_exit(&ibuf_mutex);
is_empty = (page_get_n_recs(root) == 0);
- mtr_commit(&mtr);
- ibuf_exit();
-
ut_a(is_empty == ibuf->empty);
+ ibuf_mtr_commit(&mtr);
return(is_empty);
}
=== modified file 'storage/innobase/include/btr0pcur.h'
--- a/storage/innobase/include/btr0pcur.h 2010-09-09 09:07:48 +0000
+++ b/storage/innobase/include/btr0pcur.h 2011-03-22 12:34:16 +0000
@@ -151,7 +151,7 @@ UNIV_INLINE
ulint
btr_pcur_get_up_match(
/*==================*/
- btr_pcur_t* cursor); /*!< in: memory buffer for persistent cursor */
+ const btr_pcur_t* cursor); /*!< in: persistent cursor */
/**************************************************************//**
Gets the low_match value for a pcur after a search.
@return number of matched fields at the cursor or to the right if
@@ -160,7 +160,7 @@ UNIV_INLINE
ulint
btr_pcur_get_low_match(
/*===================*/
- btr_pcur_t* cursor); /*!< in: memory buffer for persistent cursor */
+ const btr_pcur_t* cursor); /*!< in: persistent cursor */
/**************************************************************//**
If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first
user record satisfying the search condition, in the case PAGE_CUR_L or
@@ -265,22 +265,6 @@ ulint
btr_pcur_get_rel_pos(
/*=================*/
const btr_pcur_t* cursor);/*!< in: persistent cursor */
-/*********************************************************//**
-Sets the mtr field for a pcur. */
-UNIV_INLINE
-void
-btr_pcur_set_mtr(
-/*=============*/
- btr_pcur_t* cursor, /*!< in: persistent cursor */
- mtr_t* mtr); /*!< in, own: mtr */
-/*********************************************************//**
-Gets the mtr field for a pcur.
-@return mtr */
-UNIV_INLINE
-mtr_t*
-btr_pcur_get_mtr(
-/*=============*/
- btr_pcur_t* cursor); /*!< in: persistent cursor */
/**************************************************************//**
Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES,
that is, the cursor becomes detached. If there have been modifications
@@ -388,10 +372,6 @@ page_cur_t*
btr_pcur_get_page_cur(
/*==================*/
const btr_pcur_t* cursor); /*!< in: persistent cursor */
-#else /* UNIV_DEBUG */
-# define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur)
-# define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur)
-#endif /* UNIV_DEBUG */
/*********************************************************//**
Returns the page of a persistent cursor.
@return pointer to the page */
@@ -399,7 +379,7 @@ UNIV_INLINE
page_t*
btr_pcur_get_page(
/*==============*/
- btr_pcur_t* cursor);/*!< in: persistent cursor */
+ const btr_pcur_t* cursor);/*!< in: persistent cursor */
/*********************************************************//**
Returns the buffer block of a persistent cursor.
@return pointer to the block */
@@ -407,7 +387,7 @@ UNIV_INLINE
buf_block_t*
btr_pcur_get_block(
/*===============*/
- btr_pcur_t* cursor);/*!< in: persistent cursor */
+ const btr_pcur_t* cursor);/*!< in: persistent cursor */
/*********************************************************//**
Returns the record of a persistent cursor.
@return pointer to the record */
@@ -415,7 +395,14 @@ UNIV_INLINE
rec_t*
btr_pcur_get_rec(
/*=============*/
- btr_pcur_t* cursor);/*!< in: persistent cursor */
+ const btr_pcur_t* cursor);/*!< in: persistent cursor */
+#else /* UNIV_DEBUG */
+# define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur)
+# define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur)
+# define btr_pcur_get_page(cursor) ((cursor)->btr_cur.page_cur.block->frame)
+# define btr_pcur_get_block(cursor) ((cursor)->btr_cur.page_cur.block)
+# define btr_pcur_get_rec(cursor) ((cursor)->btr_cur.page_cur.rec)
+#endif /* UNIV_DEBUG */
/*********************************************************//**
Checks if the persistent cursor is on a user record. */
UNIV_INLINE
@@ -518,9 +505,6 @@ struct btr_pcur_struct{
/* NOTE that the following fields may possess dynamically allocated
memory which should be freed if not needed anymore! */
- mtr_t* mtr; /*!< NULL, or this field may contain
- a mini-transaction which holds the
- latch on the cursor page */
byte* old_rec_buf; /*!< NULL, or a dynamically allocated
buffer for old_rec */
ulint buf_size; /*!< old_rec_buf size if old_rec_buf
=== modified file 'storage/innobase/include/btr0pcur.ic'
--- a/storage/innobase/include/btr0pcur.ic 2010-09-09 09:07:48 +0000
+++ b/storage/innobase/include/btr0pcur.ic 2011-03-22 12:34:16 +0000
@@ -42,34 +42,6 @@ btr_pcur_get_rel_pos(
return(cursor->rel_pos);
}
-/*********************************************************//**
-Sets the mtr field for a pcur. */
-UNIV_INLINE
-void
-btr_pcur_set_mtr(
-/*=============*/
- btr_pcur_t* cursor, /*!< in: persistent cursor */
- mtr_t* mtr) /*!< in, own: mtr */
-{
- ut_ad(cursor);
-
- cursor->mtr = mtr;
-}
-
-/*********************************************************//**
-Gets the mtr field for a pcur.
-@return mtr */
-UNIV_INLINE
-mtr_t*
-btr_pcur_get_mtr(
-/*=============*/
- btr_pcur_t* cursor) /*!< in: persistent cursor */
-{
- ut_ad(cursor);
-
- return(cursor->mtr);
-}
-
#ifdef UNIV_DEBUG
/*********************************************************//**
Returns the btr cursor component of a persistent cursor.
@@ -95,7 +67,7 @@ btr_pcur_get_page_cur(
{
return(btr_cur_get_page_cur(btr_pcur_get_btr_cur(cursor)));
}
-#endif /* UNIV_DEBUG */
+
/*********************************************************//**
Returns the page of a persistent cursor.
@return pointer to the page */
@@ -103,7 +75,7 @@ UNIV_INLINE
page_t*
btr_pcur_get_page(
/*==============*/
- btr_pcur_t* cursor) /*!< in: persistent cursor */
+ const btr_pcur_t* cursor) /*!< in: persistent cursor */
{
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
@@ -117,7 +89,7 @@ UNIV_INLINE
buf_block_t*
btr_pcur_get_block(
/*===============*/
- btr_pcur_t* cursor) /*!< in: persistent cursor */
+ const btr_pcur_t* cursor) /*!< in: persistent cursor */
{
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
@@ -131,13 +103,14 @@ UNIV_INLINE
rec_t*
btr_pcur_get_rec(
/*=============*/
- btr_pcur_t* cursor) /*!< in: persistent cursor */
+ const btr_pcur_t* cursor) /*!< in: persistent cursor */
{
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
return(btr_cur_get_rec(btr_pcur_get_btr_cur(cursor)));
}
+#endif /* UNIV_DEBUG */
/**************************************************************//**
Gets the up_match value for a pcur after a search.
@@ -147,9 +120,9 @@ UNIV_INLINE
ulint
btr_pcur_get_up_match(
/*==================*/
- btr_pcur_t* cursor) /*!< in: memory buffer for persistent cursor */
+ const btr_pcur_t* cursor) /*!< in: persistent cursor */
{
- btr_cur_t* btr_cursor;
+ const btr_cur_t* btr_cursor;
ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED)
|| (cursor->pos_state == BTR_PCUR_IS_POSITIONED));
@@ -169,9 +142,9 @@ UNIV_INLINE
ulint
btr_pcur_get_low_match(
/*===================*/
- btr_pcur_t* cursor) /*!< in: memory buffer for persistent cursor */
+ const btr_pcur_t* cursor) /*!< in: persistent cursor */
{
- btr_cur_t* btr_cursor;
+ const btr_cur_t* btr_cursor;
ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED)
|| (cursor->pos_state == BTR_PCUR_IS_POSITIONED));
=== modified file 'storage/innobase/include/buf0buf.h'
--- a/storage/innobase/include/buf0buf.h 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/include/buf0buf.h 2011-03-23 13:43:14 +0000
@@ -1838,8 +1838,8 @@ struct buf_pool_struct{
#if BUF_BUDDY_HIGH != UNIV_PAGE_SIZE
# error "BUF_BUDDY_HIGH != UNIV_PAGE_SIZE"
#endif
-#if BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE
-# error "BUF_BUDDY_LOW > PAGE_ZIP_MIN_SIZE"
+#if BUF_BUDDY_LOW > UNIV_ZIP_SIZE_MIN
+# error "BUF_BUDDY_LOW > UNIV_ZIP_SIZE_MIN"
#endif
/* @} */
};
=== modified file 'storage/innobase/include/buf0buf.ic'
--- a/storage/innobase/include/buf0buf.ic 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/include/buf0buf.ic 2011-03-23 13:43:14 +0000
@@ -690,7 +690,8 @@ buf_page_get_zip_size(
/*==================*/
const buf_page_t* bpage) /*!< in: pointer to the control block */
{
- return(bpage->zip.ssize ? 512 << bpage->zip.ssize : 0);
+ return(bpage->zip.ssize
+ ? (UNIV_ZIP_SIZE_MIN >> 1) << bpage->zip.ssize : 0);
}
/*********************************************************************//**
@@ -702,7 +703,8 @@ buf_block_get_zip_size(
/*===================*/
const buf_block_t* block) /*!< in: pointer to the control block */
{
- return(block->page.zip.ssize ? 512 << block->page.zip.ssize : 0);
+ return(block->page.zip.ssize
+ ? (UNIV_ZIP_SIZE_MIN >> 1) << block->page.zip.ssize : 0);
}
#ifndef UNIV_HOTBACKUP
=== modified file 'storage/innobase/include/buf0flu.ic'
--- a/storage/innobase/include/buf0flu.ic 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/include/buf0flu.ic 2011-03-28 13:09:20 +0000
@@ -70,7 +70,7 @@ buf_flush_note_modification(
ut_ad(!buf_pool_mutex_own(buf_pool));
ut_ad(!buf_flush_list_mutex_own(buf_pool));
- ut_ad(log_flush_order_mutex_own());
+ ut_ad(!mtr->made_dirty || log_flush_order_mutex_own());
ut_ad(mtr->start_lsn != 0);
ut_ad(mtr->modifications);
@@ -81,6 +81,8 @@ buf_flush_note_modification(
block->page.newest_modification = mtr->end_lsn;
if (!block->page.oldest_modification) {
+ ut_a(mtr->made_dirty);
+ ut_ad(log_flush_order_mutex_own());
buf_flush_insert_into_flush_list(
buf_pool, block, mtr->start_lsn);
} else {
=== modified file 'storage/innobase/include/buf0rea.h'
--- a/storage/innobase/include/buf0rea.h 2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/buf0rea.h 2011-03-24 12:24:08 +0000
@@ -70,10 +70,10 @@ UNIV_INTERN
ulint
buf_read_ahead_linear(
/*==================*/
- ulint space, /*!< in: space id */
- ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
- ulint offset);/*!< in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
+ ulint space, /*!< in: space id */
+ ulint zip_size, /*!< in: compressed page size in bytes, or 0 */
+ ulint offset, /*!< in: page number; see NOTE 3 above */
+ ibool inside_ibuf); /*!< in: TRUE if we are inside ibuf routine */
/********************************************************************//**
Issues read requests for pages which the ibuf module wants to read in, in
order to contract the insert buffer tree. Technically, this function is like
=== modified file 'storage/innobase/include/dict0dict.ic'
--- a/storage/innobase/include/dict0dict.ic 2011-02-09 09:27:12 +0000
+++ b/storage/innobase/include/dict0dict.ic 2011-03-23 13:43:14 +0000
@@ -467,10 +467,10 @@ dict_table_flags_to_zip_size(
ulint zip_size = flags & DICT_TF_ZSSIZE_MASK;
if (UNIV_UNLIKELY(zip_size)) {
- zip_size = ((PAGE_ZIP_MIN_SIZE >> 1)
+ zip_size = ((UNIV_ZIP_SIZE_MIN >> 1)
<< (zip_size >> DICT_TF_ZSSIZE_SHIFT));
- ut_ad(zip_size <= UNIV_PAGE_SIZE);
+ ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
}
return(zip_size);
=== modified file 'storage/innobase/include/dict0mem.h'
--- a/storage/innobase/include/dict0mem.h 2011-02-09 09:27:12 +0000
+++ b/storage/innobase/include/dict0mem.h 2011-03-23 13:43:14 +0000
@@ -64,17 +64,17 @@ combination of types */
/** Table flags. All unused bits must be 0. */
/* @{ */
-#define DICT_TF_COMPACT 1 /* Compact page format.
- This must be set for
- new file formats
- (later than
- DICT_TF_FORMAT_51). */
+/** Compact page format.
+This flag is set for all row formats later than Redundant. It identifies
+the Compact row format. It is also used for the later formats, Compressed
+and Dynamic, because they add features to the Compact structure. */
+#define DICT_TF_COMPACT 1
/** Compressed page size (0=uncompressed, up to 15 compressed sizes) */
/* @{ */
#define DICT_TF_ZSSIZE_SHIFT 1
#define DICT_TF_ZSSIZE_MASK (15 << DICT_TF_ZSSIZE_SHIFT)
-#define DICT_TF_ZSSIZE_MAX (UNIV_PAGE_SIZE_SHIFT - PAGE_ZIP_MIN_SIZE_SHIFT + 1)
+#define DICT_TF_ZSSIZE_MAX (UNIV_PAGE_SIZE_SHIFT - UNIV_ZIP_SIZE_SHIFT_MIN + 1)
/* @} */
/** File format */
@@ -82,38 +82,29 @@ combination of types */
#define DICT_TF_FORMAT_SHIFT 5 /* file format */
#define DICT_TF_FORMAT_MASK \
((~(~0 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT))) << DICT_TF_FORMAT_SHIFT)
-#define DICT_TF_FORMAT_51 0 /*!< InnoDB/MySQL up to 5.1 */
-#define DICT_TF_FORMAT_ZIP 1 /*!< InnoDB plugin for 5.1:
- compressed tables,
- new BLOB treatment */
-/** Maximum supported file format */
-#define DICT_TF_FORMAT_MAX DICT_TF_FORMAT_ZIP
-
-/** Minimum supported file format */
-#define DICT_TF_FORMAT_MIN DICT_TF_FORMAT_51
+#define DICT_N_COLS_COMPACT 0x80000000UL /*!< Set if ROW_FORMAT!=REDUNDANT */
/* @} */
#define DICT_TF_BITS 6 /*!< number of flag bits */
-#if (1 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT)) <= DICT_TF_FORMAT_MAX
-# error "DICT_TF_BITS is insufficient for DICT_TF_FORMAT_MAX"
+#if (1 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT)) <= UNIV_FORMAT_MAX
+# error "DICT_TF_BITS is insufficient for UNIV_FORMAT_MAX"
#endif
+/** Valid table flag bits */
+#define DICT_TF_BIT_MASK (~(~0 << DICT_TF_BITS))
/* @} */
-/** @brief Additional table flags.
+/** @brief Table Flags set number 2.
These flags will be stored in SYS_TABLES.MIX_LEN. All unused flags
will be written as 0. The column may contain garbage for tables
created with old versions of InnoDB that only implemented
ROW_FORMAT=REDUNDANT. */
/* @{ */
-#define DICT_TF2_SHIFT DICT_TF_BITS
- /*!< Shift value for
- table->flags. */
-#define DICT_TF2_TEMPORARY 1 /*!< TRUE for tables from
- CREATE TEMPORARY TABLE. */
-#define DICT_TF2_BITS (DICT_TF2_SHIFT + 1)
- /*!< Total number of bits
- in table->flags. */
+/** Total number of bits in table->flags2. */
+#define DICT_TF2_BITS 1
+#define DICT_TF2_BIT_MASK ~(~0 << DICT_TF2_BITS)
+
+#define DICT_TF2_TEMPORARY (1<<0) /*!< 1 if CREATE TEMPORARY TABLE */
/* @} */
/** Tables could be chained together with Foreign key constraint. When
@@ -145,7 +136,8 @@ dict_mem_table_create(
is ignored if the table is made
a member of a cluster */
ulint n_cols, /*!< in: number of columns */
- ulint flags); /*!< in: table flags */
+ ulint flags, /*!< in: table flags */
+ ulint flags2); /*!< in: table flags2 */
/****************************************************************//**
Free a table memory object. */
UNIV_INTERN
@@ -486,7 +478,8 @@ struct dict_table_struct{
unsigned space:32;
/*!< space where the clustered index of the
table is placed */
- unsigned flags:DICT_TF2_BITS;/*!< DICT_TF_COMPACT, ... */
+ unsigned flags:DICT_TF_BITS; /*!< DICT_TF_... */
+ unsigned flags2:DICT_TF2_BITS; /*!< DICT_TF2_... */
unsigned ibd_file_missing:1;
/*!< TRUE if this is in a single-table
tablespace and the .ibd file is missing; then
=== modified file 'storage/innobase/include/ibuf0ibuf.h'
--- a/storage/innobase/include/ibuf0ibuf.h 2011-02-10 15:01:01 +0000
+++ b/storage/innobase/include/ibuf0ibuf.h 2011-03-24 12:24:08 +0000
@@ -116,6 +116,22 @@ UNIV_INTERN
void
ibuf_update_max_tablespace_id(void);
/*===============================*/
+/***************************************************************//**
+Starts an insert buffer mini-transaction. */
+UNIV_INLINE
+void
+ibuf_mtr_start(
+/*===========*/
+ mtr_t* mtr) /*!< out: mini-transaction */
+ __attribute__((nonnull));
+/***************************************************************//**
+Commits an insert buffer mini-transaction. */
+UNIV_INLINE
+void
+ibuf_mtr_commit(
+/*============*/
+ mtr_t* mtr) /*!< in/out: mini-transaction */
+ __attribute__((nonnull));
/*********************************************************************//**
Initializes an ibuf bitmap page. */
UNIV_INTERN
@@ -236,10 +252,12 @@ routine.
For instance, a read-ahead of non-ibuf pages is forbidden by threads
that are executing an insert buffer routine.
@return TRUE if inside an insert buffer routine */
-UNIV_INTERN
+UNIV_INLINE
ibool
-ibuf_inside(void);
-/*=============*/
+ibuf_inside(
+/*========*/
+ const mtr_t* mtr) /*!< in: mini-transaction */
+ __attribute__((nonnull, pure));
/***********************************************************************//**
Checks if a page address is an ibuf bitmap page (level 3 page) address.
@return TRUE if a bitmap page */
=== modified file 'storage/innobase/include/ibuf0ibuf.ic'
--- a/storage/innobase/include/ibuf0ibuf.ic 2011-02-10 15:01:01 +0000
+++ b/storage/innobase/include/ibuf0ibuf.ic 2011-03-24 12:24:08 +0000
@@ -37,6 +37,30 @@ buffer inserts to this page. If there i
corresponding bits are set in the ibuf bitmap. */
#define IBUF_PAGE_SIZE_PER_FREE_SPACE 32
+/***************************************************************//**
+Starts an insert buffer mini-transaction. */
+UNIV_INLINE
+void
+ibuf_mtr_start(
+/*===========*/
+ mtr_t* mtr) /*!< out: mini-transaction */
+{
+ mtr_start(mtr);
+ mtr->inside_ibuf = TRUE;
+}
+/***************************************************************//**
+Commits an insert buffer mini-transaction. */
+UNIV_INLINE
+void
+ibuf_mtr_commit(
+/*============*/
+ mtr_t* mtr) /*!< in/out: mini-transaction */
+{
+ ut_ad(mtr->inside_ibuf);
+ ut_d(mtr->inside_ibuf = FALSE);
+ mtr_commit(mtr);
+}
+
/** Insert buffer struct */
struct ibuf_struct{
ulint size; /*!< current size of the ibuf index
@@ -121,6 +145,22 @@ ibuf_should_try(
return(FALSE);
}
+/******************************************************************//**
+Returns TRUE if the current OS thread is performing an insert buffer
+routine.
+
+For instance, a read-ahead of non-ibuf pages is forbidden by threads
+that are executing an insert buffer routine.
+@return TRUE if inside an insert buffer routine */
+UNIV_INLINE
+ibool
+ibuf_inside(
+/*========*/
+ const mtr_t* mtr) /*!< in: mini-transaction */
+{
+ return(mtr->inside_ibuf);
+}
+
/***********************************************************************//**
Checks if a page address is an ibuf bitmap page address.
@return TRUE if a bitmap page */
@@ -158,7 +198,7 @@ ibuf_index_page_calc_free_bits(
ulint n;
ut_ad(ut_is_2pow(zip_size));
ut_ad(!zip_size || zip_size > IBUF_PAGE_SIZE_PER_FREE_SPACE);
- ut_ad(zip_size <= UNIV_PAGE_SIZE);
+ ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
if (zip_size) {
n = max_ins_size
@@ -193,7 +233,7 @@ ibuf_index_page_calc_free_from_bits(
ut_ad(bits < 4);
ut_ad(ut_is_2pow(zip_size));
ut_ad(!zip_size || zip_size > IBUF_PAGE_SIZE_PER_FREE_SPACE);
- ut_ad(zip_size <= UNIV_PAGE_SIZE);
+ ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
if (zip_size) {
if (bits == 3) {
=== modified file 'storage/innobase/include/mtr0mtr.h'
--- a/storage/innobase/include/mtr0mtr.h 2011-03-14 11:45:13 +0000
+++ b/storage/innobase/include/mtr0mtr.h 2011-03-28 13:09:20 +0000
@@ -193,21 +193,21 @@ functions). The page number parameter w
#include "log0log.h"
/***************************************************************//**
-Starts a mini-transaction and creates a mini-transaction handle
-and buffer in the memory buffer given by the caller.
-@return mtr buffer which also acts as the mtr handle */
+Starts a mini-transaction. */
UNIV_INLINE
-mtr_t*
+void
mtr_start(
/*======*/
- mtr_t* mtr); /*!< in: memory buffer for the mtr buffer */
+ mtr_t* mtr) /*!< out: mini-transaction */
+ __attribute__((nonnull));
/***************************************************************//**
Commits a mini-transaction. */
UNIV_INTERN
void
mtr_commit(
/*=======*/
- mtr_t* mtr); /*!< in: mini-transaction */
+ mtr_t* mtr) /*!< in/out: mini-transaction */
+ __attribute__((nonnull));
/**********************************************************//**
Sets and returns a savepoint in mtr.
@return savepoint */
@@ -366,7 +366,6 @@ mtr_memo_push(
void* object, /*!< in: object */
ulint type); /*!< in: object type: MTR_MEMO_S_LOCK, ... */
-
/* Type definition of a mini-transaction memo stack slot. */
typedef struct mtr_memo_slot_struct mtr_memo_slot_t;
struct mtr_memo_slot_struct{
@@ -381,9 +380,13 @@ struct mtr_struct{
#endif
dyn_array_t memo; /*!< memo stack for locks etc. */
dyn_array_t log; /*!< mini-transaction log */
+ ibool inside_ibuf;
+ /*!< TRUE if inside ibuf changes */
ibool modifications;
/* TRUE if the mtr made modifications to
buffer pool pages */
+ ibool made_dirty;/*!< TRUE if mtr has made at least
+ one buffer pool page dirty */
ulint n_log_recs;
/* count of how many page initial log records
have been written to the mtr log */
=== modified file 'storage/innobase/include/mtr0mtr.ic'
--- a/storage/innobase/include/mtr0mtr.ic 2010-12-01 08:52:55 +0000
+++ b/storage/innobase/include/mtr0mtr.ic 2011-03-28 13:09:20 +0000
@@ -29,27 +29,35 @@ Created 11/26/1995 Heikki Tuuri
#endif /* !UNIV_HOTBACKUP */
#include "mach0data.h"
+/***************************************************//**
+Checks if a mini-transaction is dirtying a clean page.
+@return TRUE if the mtr is dirtying a clean page. */
+UNIV_INTERN
+ibool
+mtr_block_dirtied(
+/*==============*/
+ const buf_block_t* block) /*!< in: block being x-fixed */
+ __attribute__((nonnull,warn_unused_result));
+
/***************************************************************//**
-Starts a mini-transaction and creates a mini-transaction handle
-and a buffer in the memory buffer given by the caller.
-@return mtr buffer which also acts as the mtr handle */
+Starts a mini-transaction. */
UNIV_INLINE
-mtr_t*
+void
mtr_start(
/*======*/
- mtr_t* mtr) /*!< in: memory buffer for the mtr buffer */
+ mtr_t* mtr) /*!< out: mini-transaction */
{
dyn_array_create(&(mtr->memo));
dyn_array_create(&(mtr->log));
mtr->log_mode = MTR_LOG_ALL;
mtr->modifications = FALSE;
+ mtr->inside_ibuf = FALSE;
mtr->n_log_recs = 0;
+ mtr->made_dirty = FALSE;
ut_d(mtr->state = MTR_ACTIVE);
ut_d(mtr->magic_n = MTR_MAGIC_N);
-
- return(mtr);
}
/***************************************************//**
@@ -72,6 +80,15 @@ mtr_memo_push(
ut_ad(mtr->magic_n == MTR_MAGIC_N);
ut_ad(mtr->state == MTR_ACTIVE);
+ /* If this mtr has x-fixed a clean page then we set
+ the made_dirty flag. This tells us if we need to
+ grab log_flush_order_mutex at mtr_commit so that we
+ can insert the dirtied page to the flush list. */
+ if (type == MTR_MEMO_PAGE_X_FIX && !mtr->made_dirty) {
+ mtr->made_dirty =
+ mtr_block_dirtied((const buf_block_t *)object);
+ }
+
memo = &(mtr->memo);
slot = (mtr_memo_slot_t*) dyn_array_push(memo, sizeof *slot);
=== modified file 'storage/innobase/include/page0page.h'
--- a/storage/innobase/include/page0page.h 2010-07-29 10:44:35 +0000
+++ b/storage/innobase/include/page0page.h 2011-03-22 12:34:16 +0000
@@ -952,7 +952,7 @@ UNIV_INTERN
ibool
page_rec_validate(
/*==============*/
- rec_t* rec, /*!< in: physical record */
+ const rec_t* rec, /*!< in: physical record */
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
/***************************************************************//**
Checks that the first directory slot points to the infimum record and
@@ -972,7 +972,7 @@ UNIV_INTERN
ibool
page_simple_validate_old(
/*=====================*/
- page_t* page); /*!< in: old-style index page */
+ const page_t* page); /*!< in: index page in ROW_FORMAT=REDUNDANT */
/***************************************************************//**
This function checks the consistency of an index page when we do not
know the index. This is also resilient so that this should never crash
@@ -982,7 +982,7 @@ UNIV_INTERN
ibool
page_simple_validate_new(
/*=====================*/
- page_t* block); /*!< in: new-style index page */
+ const page_t* page); /*!< in: index page in ROW_FORMAT!=REDUNDANT */
/***************************************************************//**
This function checks the consistency of an index page.
@return TRUE if ok */
@@ -990,7 +990,7 @@ UNIV_INTERN
ibool
page_validate(
/*==========*/
- page_t* page, /*!< in: index page */
+ const page_t* page, /*!< in: index page */
dict_index_t* index); /*!< in: data dictionary index containing
the page record type definition */
/***************************************************************//**
=== modified file 'storage/innobase/include/page0types.h'
--- a/storage/innobase/include/page0types.h 2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/page0types.h 2011-03-23 13:43:14 +0000
@@ -49,13 +49,9 @@ page0*.h includes rem0rec.h and may incl
/** Number of bits needed for representing different compressed page sizes */
#define PAGE_ZIP_SSIZE_BITS 3
-/** log2 of smallest compressed page size */
-#define PAGE_ZIP_MIN_SIZE_SHIFT 10
-/** Smallest compressed page size */
-#define PAGE_ZIP_MIN_SIZE (1 << PAGE_ZIP_MIN_SIZE_SHIFT)
-
/** Number of supported compressed page sizes */
-#define PAGE_ZIP_NUM_SSIZE (UNIV_PAGE_SIZE_SHIFT - PAGE_ZIP_MIN_SIZE_SHIFT + 2)
+#define PAGE_ZIP_NUM_SSIZE \
+ (UNIV_ZIP_SIZE_SHIFT_MAX - UNIV_ZIP_SIZE_SHIFT_MIN + 2)
#if PAGE_ZIP_NUM_SSIZE > (1 << PAGE_ZIP_SSIZE_BITS)
# error "PAGE_ZIP_NUM_SSIZE > (1 << PAGE_ZIP_SSIZE_BITS)"
#endif
@@ -77,7 +73,7 @@ struct page_zip_des_struct
unsigned ssize:PAGE_ZIP_SSIZE_BITS;
/*!< 0 or compressed page size;
the size in bytes is
- PAGE_ZIP_MIN_SIZE << (ssize - 1). */
+ UNIV_ZIP_SIZE_MIN << (ssize - 1). */
};
/** Compression statistics for a given page size */
=== modified file 'storage/innobase/include/page0zip.ic'
--- a/storage/innobase/include/page0zip.ic 2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/page0zip.ic 2011-03-23 13:43:14 +0000
@@ -124,9 +124,9 @@ page_zip_get_size(
return(0);
}
- size = (PAGE_ZIP_MIN_SIZE >> 1) << page_zip->ssize;
+ size = (UNIV_ZIP_SIZE_MIN >> 1) << page_zip->ssize;
- ut_ad(size >= PAGE_ZIP_MIN_SIZE);
+ ut_ad(size >= UNIV_ZIP_SIZE_MIN);
ut_ad(size <= UNIV_PAGE_SIZE);
return(size);
=== modified file 'storage/innobase/include/rem0rec.h'
--- a/storage/innobase/include/rem0rec.h 2010-10-21 22:25:09 +0000
+++ b/storage/innobase/include/rem0rec.h 2011-03-22 12:34:16 +0000
@@ -600,6 +600,7 @@ ulint
rec_offs_size(
/*==========*/
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
+#ifdef UNIV_DEBUG
/**********************************************************//**
Returns a pointer to the start of the record.
@return pointer to start */
@@ -607,7 +608,7 @@ UNIV_INLINE
byte*
rec_get_start(
/*==========*/
- rec_t* rec, /*!< in: pointer to record */
+ const rec_t* rec, /*!< in: pointer to record */
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
/**********************************************************//**
Returns a pointer to the end of the record.
@@ -616,8 +617,12 @@ UNIV_INLINE
byte*
rec_get_end(
/*========*/
- rec_t* rec, /*!< in: pointer to record */
+ const rec_t* rec, /*!< in: pointer to record */
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
+#else /* UNIV_DEBUG */
+# define rec_get_start(rec, offsets) ((rec) - rec_offs_extra_size(offsets))
+# define rec_get_end(rec, offsets) ((rec) + rec_offs_data_size(offsets))
+#endif /* UNIV_DEBUG */
/***************************************************************//**
Copies a physical record to a buffer.
@return pointer to the origin of the copy */
=== modified file 'storage/innobase/include/rem0rec.ic'
--- a/storage/innobase/include/rem0rec.ic 2010-07-29 10:44:35 +0000
+++ b/storage/innobase/include/rem0rec.ic 2011-03-22 12:34:16 +0000
@@ -1462,6 +1462,7 @@ rec_offs_size(
return(rec_offs_data_size(offsets) + rec_offs_extra_size(offsets));
}
+#ifdef UNIV_DEBUG
/**********************************************************//**
Returns a pointer to the end of the record.
@return pointer to end */
@@ -1469,11 +1470,11 @@ UNIV_INLINE
byte*
rec_get_end(
/*========*/
- rec_t* rec, /*!< in: pointer to record */
+ const rec_t* rec, /*!< in: pointer to record */
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
{
ut_ad(rec_offs_validate(rec, NULL, offsets));
- return(rec + rec_offs_data_size(offsets));
+ return((rec_t*) rec + rec_offs_data_size(offsets));
}
/**********************************************************//**
@@ -1483,12 +1484,13 @@ UNIV_INLINE
byte*
rec_get_start(
/*==========*/
- rec_t* rec, /*!< in: pointer to record */
+ const rec_t* rec, /*!< in: pointer to record */
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
{
ut_ad(rec_offs_validate(rec, NULL, offsets));
- return(rec - rec_offs_extra_size(offsets));
+ return((rec_t*) rec - rec_offs_extra_size(offsets));
}
+#endif /* UNIV_DEBUG */
/***************************************************************//**
Copies a physical record to a buffer.
=== modified file 'storage/innobase/include/srv0srv.h'
--- a/storage/innobase/include/srv0srv.h 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/include/srv0srv.h 2011-03-23 13:46:37 +0000
@@ -109,7 +109,7 @@ extern ibool srv_file_per_table;
/** The file format to use on new *.ibd files. */
extern ulint srv_file_format;
/** Whether to check file format during startup. A value of
-DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE. The default is to
+UNIV_FORMAT_MAX + 1 means no checking ie. FALSE. The default is to
set it to the highest format we support. */
extern ulint srv_max_file_format_at_startup;
/** Place locks to records only i.e. do not use next-key locking except
@@ -575,27 +575,6 @@ srv_conc_exit_innodb(
/*=================*/
trx_t* trx); /*!< in: transaction object associated with the
thread */
-/***************************************************************//**
-Puts a MySQL OS thread to wait for a lock to be released. If an error
-occurs during the wait trx->error_state associated with thr is
-!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK
-are possible errors. DB_DEADLOCK is returned if selective deadlock
-resolution chose this transaction as a victim. */
-UNIV_INTERN
-void
-srv_suspend_mysql_thread(
-/*=====================*/
- que_thr_t* thr); /*!< in: query thread associated with the MySQL
- OS thread */
-/********************************************************************//**
-Releases a MySQL OS thread waiting for a lock to be released, if the
-thread is already suspended. */
-UNIV_INTERN
-void
-srv_release_mysql_thread_if_suspended(
-/*==================================*/
- que_thr_t* thr); /*!< in: query thread associated with the
- MySQL OS thread */
/*********************************************************************//**
A thread which prints the info output by various InnoDB monitors.
@return a dummy parameter */
=== modified file 'storage/innobase/include/sync0sync.h'
--- a/storage/innobase/include/sync0sync.h 2011-02-22 05:11:15 +0000
+++ b/storage/innobase/include/sync0sync.h 2011-03-24 12:24:08 +0000
@@ -108,7 +108,6 @@ extern mysql_pfs_key_t syn_arr_mutex_key
extern mysql_pfs_key_t sync_thread_mutex_key;
# endif /* UNIV_SYNC_DEBUG */
extern mysql_pfs_key_t trx_doublewrite_mutex_key;
-extern mysql_pfs_key_t thr_local_mutex_key;
extern mysql_pfs_key_t trx_undo_mutex_key;
extern mysql_pfs_key_t trx_mutex_key;
extern mysql_pfs_key_t lock_sys_mutex_key;
=== removed file 'storage/innobase/include/thr0loc.h'
--- a/storage/innobase/include/thr0loc.h 2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/thr0loc.h 1970-01-01 00:00:00 +0000
@@ -1,90 +0,0 @@
-/*****************************************************************************
-
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation; version 2 of the License.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
-
-*****************************************************************************/
-
-/**************************************************//**
-@file include/thr0loc.h
-The thread local storage
-
-Created 10/5/1995 Heikki Tuuri
-*******************************************************/
-
-/* This module implements storage private to each thread,
-a capability useful in some situations like storing the
-OS handle to the current thread, or its priority. */
-
-#ifndef thr0loc_h
-#define thr0loc_h
-
-#include "univ.i"
-#include "os0thread.h"
-
-/****************************************************************//**
-Initializes the thread local storage module. */
-UNIV_INTERN
-void
-thr_local_init(void);
-/*================*/
- /****************************************************************//**
-Close the thread local storage module. */
-UNIV_INTERN
-void
-thr_local_close(void);
-/*=================*/
-/*******************************************************************//**
-Creates a local storage struct for the calling new thread. */
-UNIV_INTERN
-void
-thr_local_create(void);
-/*==================*/
-/*******************************************************************//**
-Frees the local storage struct for the specified thread. */
-UNIV_INTERN
-void
-thr_local_free(
-/*===========*/
- os_thread_id_t id); /*!< in: thread id */
-/*******************************************************************//**
-Gets the slot number in the thread table of a thread.
-@return slot number */
-UNIV_INTERN
-ulint
-thr_local_get_slot_no(
-/*==================*/
- os_thread_id_t id); /*!< in: thread id of the thread */
-/*******************************************************************//**
-Sets in the local storage the slot number in the thread table of a thread. */
-UNIV_INTERN
-void
-thr_local_set_slot_no(
-/*==================*/
- os_thread_id_t id, /*!< in: thread id of the thread */
- ulint slot_no);/*!< in: slot number */
-/*******************************************************************//**
-Returns pointer to the 'in_ibuf' field within the current thread local
-storage.
-@return pointer to the in_ibuf field */
-UNIV_INTERN
-ibool*
-thr_local_get_in_ibuf_field(void);
-/*=============================*/
-
-#ifndef UNIV_NONINL
-#include "thr0loc.ic"
-#endif
-
-#endif
=== removed file 'storage/innobase/include/thr0loc.ic'
--- a/storage/innobase/include/thr0loc.ic 2010-07-16 21:00:50 +0000
+++ b/storage/innobase/include/thr0loc.ic 1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
-/*****************************************************************************
-
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation; version 2 of the License.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
-
-*****************************************************************************/
-
-/**************************************************//**
-@file include/thr0loc.ic
-Thread local storage
-
-Created 10/4/1995 Heikki Tuuri
-*******************************************************/
=== modified file 'storage/innobase/include/univ.i'
--- a/storage/innobase/include/univ.i 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/include/univ.i 2011-03-23 13:43:14 +0000
@@ -308,25 +308,58 @@ management to ensure correct alignment f
========================
*/
-/* The 2-logarithm of UNIV_PAGE_SIZE: */
+/** Antelope File Format: InnoDB/MySQL up to 5.1.
+This format includes REDUNDANT and COMPACT row formats */
+#define UNIV_FORMAT_A 0
+
+/** Barracuda File Format: Introduced in InnoDB plugin for 5.1:
+This format includes COMPRESSED and DYNAMIC row formats,
+including new BLOB treatment */
+#define UNIV_FORMAT_B 1
+
+/** Minimum supported file format */
+#define UNIV_FORMAT_MIN UNIV_FORMAT_A
+
+/** Maximum supported file format */
+#define UNIV_FORMAT_MAX UNIV_FORMAT_B
+
+/** The 2-logarithm of UNIV_PAGE_SIZE: */
#define UNIV_PAGE_SIZE_SHIFT 14
-/* The universal page size of the database */
+
+/** The universal page size of the database */
#define UNIV_PAGE_SIZE (1 << UNIV_PAGE_SIZE_SHIFT)
-/* Maximum number of parallel threads in a parallelized operation */
+/** log2 of smallest compressed page size (1<<10 == 1024 bytes) */
+#define UNIV_ZIP_SIZE_SHIFT_MIN 10
+
+/** log2 of largest compressed page size (1<<14 == 16384 bytes).
+A compressed page directory entry reserves 14 bits for the start offset
+and 2 bits for flags. This limits the uncompressed page size to 16k.
+So even though a 16k uncompressed page can theoretically be compressed
+into a larger compressed page, it is not a useful feature so we will
+limit both with this same constant. */
+#define UNIV_ZIP_SIZE_SHIFT_MAX 14
+
+/** Smallest compressed page size */
+#define UNIV_ZIP_SIZE_MIN (1 << UNIV_ZIP_SIZE_SHIFT_MIN)
+
+/** Largest compressed page size */
+#define UNIV_ZIP_SIZE_MAX (1 << UNIV_ZIP_SIZE_SHIFT_MAX)
+
+/** Maximum number of parallel threads in a parallelized operation */
#define UNIV_MAX_PARALLELISM 32
-/* The maximum length of a table name. This is the MySQL limit and is
+/** The maximum length of a table name. This is the MySQL limit and is
defined in mysql_com.h like NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN, the
number does not include a terminating '\0'. InnoDB probably can handle
longer names internally */
#define MAX_TABLE_NAME_LEN 192
-/* The maximum length of a database name. Like MAX_TABLE_NAME_LEN this is
+/** The maximum length of a database name. Like MAX_TABLE_NAME_LEN this is
the MySQL's NAME_LEN, see check_and_convert_db_name(). */
#define MAX_DATABASE_NAME_LEN MAX_TABLE_NAME_LEN
-/* MAX_FULL_NAME_LEN defines the full name path including the
+/** MAX_FULL_NAME_LEN defines the full name path including the
database name and table name. In addition, 14 bytes is added for:
2 for surrounding quotes around table name
1 for the separating dot (.)
@@ -371,7 +404,7 @@ typedef long int lint;
typedef __int64 ib_int64_t;
typedef unsigned __int64 ib_uint64_t;
#elif !defined(UNIV_HOTBACKUP)
-/* Note: longlong and ulonglong come from MySQL headers. */
+/** Note: longlong and ulonglong come from MySQL headers. */
typedef longlong ib_int64_t;
typedef ulonglong ib_uint64_t;
#endif
@@ -386,31 +419,31 @@ typedef unsigned long long int ullint;
#endif
#endif
-/* The 'undefined' value for a ulint */
+/** The 'undefined' value for a ulint */
#define ULINT_UNDEFINED ((ulint)(-1))
-/* The 'undefined' value for a ib_uint64_t */
+/** The 'undefined' value for a ib_uint64_t */
#define UINT64_UNDEFINED ((ib_uint64_t)(-1))
/** The bitmask of 32-bit unsigned integer */
#define ULINT32_MASK 0xFFFFFFFF
-/* The undefined 32-bit unsigned integer */
+/** The undefined 32-bit unsigned integer */
#define ULINT32_UNDEFINED ULINT32_MASK
-/* Maximum value for a ulint */
+/** Maximum value for a ulint */
#define ULINT_MAX ((ulint)(-2))
-/* Maximum value for ib_uint64_t */
+/** Maximum value for ib_uint64_t */
#define IB_ULONGLONG_MAX ((ib_uint64_t) (~0ULL))
#define IB_UINT64_MAX IB_ULONGLONG_MAX
/** The generic InnoDB system object identifier data type */
typedef ib_uint64_t ib_id_t;
-/* The 'undefined' value for a ullint */
+/** The 'undefined' value for a ullint */
#define ULLINT_UNDEFINED ((ullint)(-1))
-/* This 'ibool' type is used within Innobase. Remember that different included
+/** This 'ibool' type is used within Innobase. Remember that different included
headers may define 'bool' differently. Do not assume that 'bool' is a ulint! */
#define ibool ulint
@@ -421,7 +454,7 @@ headers may define 'bool' differently. D
#endif
-/* The following number as the length of a logical field means that the field
+/** The following number as the length of a logical field means that the field
has the SQL NULL as its value. NOTE that because we assume that the length
of a field is a 32-bit integer when we store it, for example, to an undo log
on disk, we must have also this number fit in 32 bits, also in 64-bit
@@ -429,7 +462,7 @@ computers! */
#define UNIV_SQL_NULL ULINT32_UNDEFINED
-/* Lengths which are not UNIV_SQL_NULL, but bigger than the following
+/** Lengths which are not UNIV_SQL_NULL, but bigger than the following
number indicate that a field contains a reference to an externally
stored part of the field in the tablespace. The length field then
contains the sum of the following flag and the locally stored len. */
=== modified file 'storage/innobase/lock/lock0lock.c'
--- a/storage/innobase/lock/lock0lock.c 2011-03-04 01:47:48 +0000
+++ b/storage/innobase/lock/lock0lock.c 2011-03-18 13:58:55 +0000
@@ -2071,13 +2071,7 @@ lock_rec_lock_fast(
status = LOCK_REC_FAIL;
} else if (!impl) {
- /* If the nth bit of the record lock is already
- set then we do not set a new lock bit, otherwise
- we do set */
-
- if (!lock_rec_get_nth_bit(lock, heap_no)) {
- lock_rec_set_nth_bit(lock, heap_no);
- }
+ lock_rec_set_nth_bit(lock, heap_no);
status = LOCK_REC_SUCCESS_CREATED;
}
@@ -4246,10 +4240,11 @@ lock_rec_unlock(
const rec_t* rec, /*!< in: record */
enum lock_mode lock_mode)/*!< in: LOCK_S or LOCK_X */
{
- lock_t* first_lock;
- lock_t* lock;
- ulint heap_no;
- size_t stmt_len;
+ lock_t* first_lock;
+ lock_t* lock;
+ ulint heap_no;
+ const char* stmt;
+ size_t stmt_len;
ut_ad(trx);
ut_ad(rec);
@@ -4277,15 +4272,15 @@ lock_rec_unlock(
lock_mutex_exit();
trx_mutex_exit(trx);
- /* Ignore stmt_len, because it should not hurt to see more
- context (the tail of a multi-statement) in the error message. */
+ stmt = innobase_get_stmt(trx->mysql_thd, &stmt_len);
ut_print_timestamp(stderr);
fprintf(stderr,
- " InnoDB: Error: unlock row could not"
- " find a %lu mode lock on the record\n"
- "InnoDB: current statement: %s\n",
- (ulong) lock_mode,
- innobase_get_stmt(trx->mysql_thd, &stmt_len));
+ " InnoDB: Error: unlock row could not"
+ " find a %lu mode lock on the record\n",
+ (ulong) lock_mode);
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB: current statement: %.*s\n",
+ (int) stmt_len, stmt);
return;
=== modified file 'storage/innobase/mtr/mtr0log.c'
--- a/storage/innobase/mtr/mtr0log.c 2011-01-25 10:51:35 +0000
+++ b/storage/innobase/mtr/mtr0log.c 2011-03-18 15:48:14 +0000
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -563,7 +563,7 @@ mlog_parse_index(
n = n_uniq = 1;
}
table = dict_mem_table_create("LOG_DUMMY", DICT_HDR_SPACE, n,
- comp ? DICT_TF_COMPACT : 0);
+ comp ? DICT_TF_COMPACT : 0, 0);
ind = dict_mem_index_create("LOG_DUMMY", "LOG_DUMMY",
DICT_HDR_SPACE, 0, n);
ind->table = table;
=== modified file 'storage/innobase/mtr/mtr0mtr.c'
--- a/storage/innobase/mtr/mtr0mtr.c 2011-03-15 16:01:03 +0000
+++ b/storage/innobase/mtr/mtr0mtr.c 2011-03-28 13:09:20 +0000
@@ -37,6 +37,25 @@ Created 11/26/1995 Heikki Tuuri
#ifndef UNIV_HOTBACKUP
# include "log0recv.h"
+
+/***************************************************//**
+Checks if a mini-transaction is dirtying a clean page.
+@return TRUE if the mtr is dirtying a clean page. */
+UNIV_INTERN
+ibool
+mtr_block_dirtied(
+/*==============*/
+ const buf_block_t* block) /*!< in: block being x-fixed */
+{
+ ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
+ ut_ad(block->page.buf_fix_count > 0);
+
+ /* It is OK to read oldest_modification because no
+ other thread can be performing a write of it and it
+ is only during write that the value is reset to 0. */
+ return(block->page.oldest_modification == 0);
+}
+
/*****************************************************************//**
Releases the item in the slot given. */
static
@@ -128,7 +147,7 @@ mtr_memo_slot_note_modification(
if (slot->object != NULL && slot->type == MTR_MEMO_PAGE_X_FIX) {
buf_block_t* block = (buf_block_t*) slot->object;
- ut_ad(log_flush_order_mutex_own());
+ ut_ad(!mtr->made_dirty || log_flush_order_mutex_own());
buf_flush_note_modification(block, mtr);
}
}
@@ -227,7 +246,15 @@ mtr_log_reserve_and_write(
mtr->end_lsn = log_close();
func_exit:
- log_flush_order_mutex_enter();
+
+ /* No need to acquire log_flush_order_mutex if this mtr has
+ not dirtied a clean page. log_flush_order_mutex is used to
+ ensure ordered insertions in the flush_list. We need to
+ insert in the flush_list iff the page in question was clean
+ before modifications. */
+ if (mtr->made_dirty) {
+ log_flush_order_mutex_enter();
+ }
/* It is now safe to release the log mutex because the
flush_order mutex will ensure that we are the first one
@@ -238,7 +265,9 @@ func_exit:
mtr_memo_note_modifications(mtr);
}
- log_flush_order_mutex_exit();
+ if (mtr->made_dirty) {
+ log_flush_order_mutex_exit();
+ }
}
#endif /* !UNIV_HOTBACKUP */
@@ -253,6 +282,7 @@ mtr_commit(
ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
ut_ad(mtr->state == MTR_ACTIVE);
+ ut_ad(!mtr->inside_ibuf);
ut_d(mtr->state = MTR_COMMITTING);
#ifndef UNIV_HOTBACKUP
=== modified file 'storage/innobase/page/page0page.c'
--- a/storage/innobase/page/page0page.c 2011-02-08 12:16:14 +0000
+++ b/storage/innobase/page/page0page.c 2011-03-22 12:34:16 +0000
@@ -166,11 +166,11 @@ static
ibool
page_dir_slot_check(
/*================*/
- page_dir_slot_t* slot) /*!< in: slot */
+ const page_dir_slot_t* slot) /*!< in: slot */
{
- page_t* page;
- ulint n_slots;
- ulint n_owned;
+ const page_t* page;
+ ulint n_slots;
+ ulint n_owned;
ut_a(slot);
@@ -1803,12 +1803,12 @@ UNIV_INTERN
ibool
page_rec_validate(
/*==============*/
- rec_t* rec, /*!< in: physical record */
+ const rec_t* rec, /*!< in: physical record */
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
{
- ulint n_owned;
- ulint heap_no;
- page_t* page;
+ ulint n_owned;
+ ulint heap_no;
+ const page_t* page;
page = page_align(rec);
ut_a(!page_is_comp(page) == !rec_offs_comp(offsets));
@@ -1889,16 +1889,16 @@ UNIV_INTERN
ibool
page_simple_validate_old(
/*=====================*/
- page_t* page) /*!< in: old-style index page */
+ const page_t* page) /*!< in: index page in ROW_FORMAT=REDUNDANT */
{
- page_dir_slot_t* slot;
- ulint slot_no;
- ulint n_slots;
- rec_t* rec;
- byte* rec_heap_top;
- ulint count;
- ulint own_count;
- ibool ret = FALSE;
+ const page_dir_slot_t* slot;
+ ulint slot_no;
+ ulint n_slots;
+ const rec_t* rec;
+ const byte* rec_heap_top;
+ ulint count;
+ ulint own_count;
+ ibool ret = FALSE;
ut_a(!page_is_comp(page));
@@ -2011,7 +2011,7 @@ page_simple_validate_old(
goto func_exit;
}
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
own_count++;
}
@@ -2072,7 +2072,7 @@ page_simple_validate_old(
goto func_exit;
}
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
}
if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) {
@@ -2099,16 +2099,16 @@ UNIV_INTERN
ibool
page_simple_validate_new(
/*=====================*/
- page_t* page) /*!< in: new-style index page */
+ const page_t* page) /*!< in: index page in ROW_FORMAT!=REDUNDANT */
{
- page_dir_slot_t* slot;
- ulint slot_no;
- ulint n_slots;
- rec_t* rec;
- byte* rec_heap_top;
- ulint count;
- ulint own_count;
- ibool ret = FALSE;
+ const page_dir_slot_t* slot;
+ ulint slot_no;
+ ulint n_slots;
+ const rec_t* rec;
+ const byte* rec_heap_top;
+ ulint count;
+ ulint own_count;
+ ibool ret = FALSE;
ut_a(page_is_comp(page));
@@ -2221,7 +2221,7 @@ page_simple_validate_new(
goto func_exit;
}
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
own_count++;
}
@@ -2283,7 +2283,7 @@ page_simple_validate_new(
goto func_exit;
}
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
}
if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) {
@@ -2308,26 +2308,26 @@ UNIV_INTERN
ibool
page_validate(
/*==========*/
- page_t* page, /*!< in: index page */
+ const page_t* page, /*!< in: index page */
dict_index_t* index) /*!< in: data dictionary index containing
the page record type definition */
{
- page_dir_slot_t*slot;
- mem_heap_t* heap;
- byte* buf;
- ulint count;
- ulint own_count;
- ulint rec_own_count;
- ulint slot_no;
- ulint data_size;
- rec_t* rec;
- rec_t* old_rec = NULL;
- ulint offs;
- ulint n_slots;
- ibool ret = FALSE;
- ulint i;
- ulint* offsets = NULL;
- ulint* old_offsets = NULL;
+ const page_dir_slot_t* slot;
+ mem_heap_t* heap;
+ byte* buf;
+ ulint count;
+ ulint own_count;
+ ulint rec_own_count;
+ ulint slot_no;
+ ulint data_size;
+ const rec_t* rec;
+ const rec_t* old_rec = NULL;
+ ulint offs;
+ ulint n_slots;
+ ibool ret = FALSE;
+ ulint i;
+ ulint* offsets = NULL;
+ ulint* old_offsets = NULL;
if (UNIV_UNLIKELY((ibool) !!page_is_comp(page)
!= dict_table_is_comp(index->table))) {
@@ -2482,7 +2482,7 @@ page_validate(
count++;
own_count++;
old_rec = rec;
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
/* set old_offsets to offsets; recycle offsets */
{
@@ -2556,7 +2556,7 @@ n_owned_zero:
buf[offs + i] = 1;
}
- rec = page_rec_get_next(rec);
+ rec = page_rec_get_next_const(rec);
}
if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) {
=== modified file 'storage/innobase/page/page0zip.c'
--- a/storage/innobase/page/page0zip.c 2011-03-15 10:57:47 +0000
+++ b/storage/innobase/page/page0zip.c 2011-03-18 15:48:14 +0000
@@ -1516,7 +1516,7 @@ page_zip_fields_decode(
}
table = dict_mem_table_create("ZIP_DUMMY", DICT_HDR_SPACE, n,
- DICT_TF_COMPACT);
+ DICT_TF_COMPACT, 0);
index = dict_mem_index_create("ZIP_DUMMY", "ZIP_DUMMY",
DICT_HDR_SPACE, 0, n);
index->table = table;
=== modified file 'storage/innobase/pars/pars0pars.c'
--- a/storage/innobase/pars/pars0pars.c 2010-10-21 03:54:20 +0000
+++ b/storage/innobase/pars/pars0pars.c 2011-03-18 15:48:14 +0000
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -1629,7 +1629,7 @@ pars_create_table(
/* As the InnoDB SQL parser is for internal use only,
for creating some system tables, this function will only
create tables in the old (not compact) record format. */
- table = dict_mem_table_create(table_sym->name, 0, n_cols, 0);
+ table = dict_mem_table_create(table_sym->name, 0, n_cols, 0, 0);
#ifdef UNIV_DEBUG
if (not_fit_in_memory != NULL) {
=== modified file 'storage/innobase/row/row0ext.c'
--- a/storage/innobase/row/row0ext.c 2010-07-16 21:00:50 +0000
+++ b/storage/innobase/row/row0ext.c 2011-03-23 13:43:14 +0000
@@ -93,7 +93,7 @@ row_ext_create(
+ (n_ext - 1) * sizeof ret->len);
ut_ad(ut_is_2pow(zip_size));
- ut_ad(zip_size <= UNIV_PAGE_SIZE);
+ ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
ret->n_ext = n_ext;
ret->ext = ext;
=== modified file 'storage/innobase/row/row0merge.c'
--- a/storage/innobase/row/row0merge.c 2011-02-17 12:02:22 +0000
+++ b/storage/innobase/row/row0merge.c 2011-03-18 15:48:14 +0000
@@ -2295,7 +2295,8 @@ row_merge_create_temporary_table(
ut_ad(table);
ut_ad(mutex_own(&dict_sys->mutex));
- new_table = dict_mem_table_create(table_name, 0, n_cols, table->flags);
+ new_table = dict_mem_table_create(
+ table_name, 0, n_cols, table->flags, table->flags2);
for (i = 0; i < n_cols; i++) {
const dict_col_t* col;
=== modified file 'storage/innobase/row/row0mysql.c'
--- a/storage/innobase/row/row0mysql.c 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/row/row0mysql.c 2011-03-18 15:48:14 +0000
@@ -1610,14 +1610,12 @@ row_unlock_for_mysql(
/* We did not update the record: unlock it */
rec = btr_pcur_get_rec(pcur);
- index = btr_pcur_get_btr_cur(pcur)->index;
lock_rec_unlock(trx, btr_pcur_get_block(pcur),
rec, prebuilt->select_lock_type);
if (prebuilt->new_rec_locks >= 2) {
rec = btr_pcur_get_rec(clust_pcur);
- index = btr_pcur_get_btr_cur(clust_pcur)->index;
lock_rec_unlock(trx,
btr_pcur_get_block(clust_pcur),
@@ -3418,8 +3416,7 @@ check_next_foreign:
is_temp = TRUE;
} else {
name_or_path = name;
- is_temp = (table->flags >> DICT_TF2_SHIFT)
- & DICT_TF2_TEMPORARY;
+ is_temp = table->flags2 & DICT_TF2_TEMPORARY;
}
dict_table_remove_from_cache(table);
@@ -3554,15 +3551,19 @@ row_mysql_drop_temp_tables(void)
break;
}
+ /* The high order bit of N_COLS is set unless
+ ROW_FORMAT=REDUNDANT. */
rec = btr_pcur_get_rec(&pcur);
field = rec_get_nth_field_old(rec, 4/*N_COLS*/, &len);
- if (len != 4 || !(mach_read_from_4(field) & 0x80000000UL)) {
+ if (len != 4
+ || !(mach_read_from_4(field) & DICT_N_COLS_COMPACT)) {
continue;
}
- /* Because this is not a ROW_FORMAT=REDUNDANT table,
- the is_temp flag is valid. Examine it. */
-
+ /* Older versions of InnoDB, which only supported tables
+ in ROW_FORMAT=REDUNDANT could write garbage to
+ SYS_TABLES.MIX_LEN, where we now store the is_temp flag.
+ Above, we assumed is_temp=0 if ROW_FORMAT=REDUNDANT. */
field = rec_get_nth_field_old(rec, 7/*MIX_LEN*/, &len);
if (len != 4
|| !(mach_read_from_4(field) & DICT_TF2_TEMPORARY)) {
=== modified file 'storage/innobase/row/row0row.c'
--- a/storage/innobase/row/row0row.c 2010-07-29 12:33:56 +0000
+++ b/storage/innobase/row/row0row.c 2011-03-23 13:43:14 +0000
@@ -298,8 +298,7 @@ row_build(
/* REDUNDANT and COMPACT formats store a local
768-byte prefix of each externally stored
column. No cache is needed. */
- ut_ad(dict_table_get_format(index->table)
- < DICT_TF_FORMAT_ZIP);
+ ut_ad(dict_table_get_format(index->table) < UNIV_FORMAT_B);
} else if (j) {
*ext = row_ext_create(j, ext_cols, row,
dict_table_zip_size(index->table),
=== modified file 'storage/innobase/row/row0umod.c'
--- a/storage/innobase/row/row0umod.c 2011-02-02 14:08:30 +0000
+++ b/storage/innobase/row/row0umod.c 2011-03-23 13:43:14 +0000
@@ -698,7 +698,7 @@ row_undo_mod_upd_exist_sec(
store a local 768-byte prefix of each
externally stored column. */
ut_a(dict_table_get_format(index->table)
- >= DICT_TF_FORMAT_ZIP);
+ >= UNIV_FORMAT_B);
/* This is only legitimate when
rolling back an incomplete transaction
=== modified file 'storage/innobase/row/row0undo.c'
--- a/storage/innobase/row/row0undo.c 2010-08-24 02:07:08 +0000
+++ b/storage/innobase/row/row0undo.c 2011-03-23 13:43:14 +0000
@@ -200,7 +200,7 @@ row_undo_search_clust_to_pcur(
} else {
row_ext_t** ext;
- if (dict_table_get_format(node->table) >= DICT_TF_FORMAT_ZIP) {
+ if (dict_table_get_format(node->table) >= UNIV_FORMAT_B) {
/* In DYNAMIC or COMPRESSED format, there is
no prefix of externally stored columns in the
clustered index record. Build a cache of
=== modified file 'storage/innobase/row/row0upd.c'
--- a/storage/innobase/row/row0upd.c 2011-02-08 12:16:14 +0000
+++ b/storage/innobase/row/row0upd.c 2011-03-23 13:43:14 +0000
@@ -1507,7 +1507,7 @@ row_upd_store_row(
offsets = rec_get_offsets(rec, clust_index, offsets_,
ULINT_UNDEFINED, &heap);
- if (dict_table_get_format(node->table) >= DICT_TF_FORMAT_ZIP) {
+ if (dict_table_get_format(node->table) >= UNIV_FORMAT_B) {
/* In DYNAMIC or COMPRESSED format, there is no prefix
of externally stored columns in the clustered index
record. Build a cache of column prefixes. */
=== modified file 'storage/innobase/srv/srv0srv.c'
--- a/storage/innobase/srv/srv0srv.c 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/srv/srv0srv.c 2011-03-24 12:24:08 +0000
@@ -47,7 +47,6 @@ Created 10/8/1995 Heikki Tuuri
#include "mem0mem.h"
#include "mem0pool.h"
#include "sync0sync.h"
-#include "thr0loc.h"
#include "que0que.h"
#include "log0recv.h"
#include "pars0pars.h"
@@ -106,12 +105,12 @@ UNIV_INTERN my_bool srv_file_per_table;
/** The file format to use on new *.ibd files. */
UNIV_INTERN ulint srv_file_format = 0;
/** Whether to check file format during startup. A value of
-DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE. The default is to
+UNIV_FORMAT_MAX + 1 means no checking ie. FALSE. The default is to
set it to the highest format we support. */
-UNIV_INTERN ulint srv_max_file_format_at_startup = DICT_TF_FORMAT_MAX;
+UNIV_INTERN ulint srv_max_file_format_at_startup = UNIV_FORMAT_MAX;
-#if DICT_TF_FORMAT_51
-# error "DICT_TF_FORMAT_51 must be 0!"
+#if UNIV_FORMAT_A
+# error "UNIV_FORMAT_A must be 0!"
#endif
/** Place locks to records only i.e. do not use next-key locking except
on duplicate key checking and foreign key checking */
@@ -693,6 +692,7 @@ srv_table_get_nth_slot(
/*===================*/
ulint index) /*!< in: index of the slot */
{
+ ut_ad(srv_sys_mutex_own());
ut_a(index < OS_THREAD_MAX_N);
return(srv_sys->sys_threads + index);
@@ -721,28 +721,61 @@ srv_get_n_threads(void)
return(n_threads);
}
+#ifdef UNIV_DEBUG
/*********************************************************************//**
-Reserves a slot in the thread table for the current thread. Also creates the
-thread local storage struct for the current thread. NOTE! The server mutex
-has to be reserved by the caller!
-@return reserved slot index */
+Validates the type of a thread table slot.
+@return TRUE if ok */
static
-ulint
+ibool
+srv_thread_type_validate(
+/*=====================*/
+ enum srv_thread_type type) /*!< in: thread type */
+{
+ switch (type) {
+ case SRV_NONE:
+ break;
+ case SRV_WORKER:
+ case SRV_PURGE:
+ case SRV_MASTER:
+ return(TRUE);
+ }
+ ut_error;
+ return(FALSE);
+}
+#endif /* UNIV_DEBUG */
+
+/*********************************************************************//**
+Gets the type of a thread table slot.
+@return thread type */
+static
+enum srv_thread_type
+srv_slot_get_type(
+/*==============*/
+ const srv_slot_t* slot) /*!< in: thread slot */
+{
+ enum srv_thread_type type = (enum srv_thread_type) slot->type;
+ ut_ad(srv_thread_type_validate(type));
+ return(type);
+}
+
+/*********************************************************************//**
+Reserves a slot in the thread table for the current thread.
+NOTE! The server mutex has to be reserved by the caller!
+@return reserved slot */
+static
+srv_slot_t*
srv_table_reserve_slot(
/*===================*/
enum srv_thread_type type) /*!< in: type of the thread */
{
- ulint i;
srv_slot_t* slot;
ut_ad(srv_sys_mutex_own());
- ut_a(type > 0);
- ut_a(type <= SRV_MASTER);
+ ut_ad(srv_thread_type_validate(type));
if (type != SRV_MASTER) {
-
- i = 1;
+ ulint i = 1;
/* Find an empty slot. */
for (slot = srv_table_get_nth_slot(i);
@@ -753,60 +786,45 @@ srv_table_reserve_slot(
}
} else {
- ut_a(type != SRV_NONE);
- i = 0;
slot = srv_table_get_nth_slot(0);
}
- ut_a(slot->in_use == FALSE);
-
slot->in_use = TRUE;
slot->suspended = FALSE;
slot->type = type;
+ ut_ad(srv_slot_get_type(slot) == type);
slot->id = os_thread_get_curr_id();
slot->handle = os_thread_get_curr();
- thr_local_create();
-
- thr_local_set_slot_no(os_thread_get_curr_id(), i);
-
- return(i);
+ return(slot);
}
/*********************************************************************//**
-Suspends the calling thread to wait for the event in its thread slot.
-@return event for the calling thread to wait */
+Suspends the calling thread to wait for the event in its thread slot. */
static
-os_event_t
-srv_suspend_thread(void)
-/*====================*/
+void
+srv_suspend_thread(
+/*===============*/
+ srv_slot_t* slot) /*!< in/out: thread slot */
{
- srv_slot_t* slot;
- os_event_t event;
- ulint slot_no;
enum srv_thread_type type;
srv_sys_mutex_enter();
-
- slot_no = thr_local_get_slot_no(os_thread_get_curr_id());
+ ut_ad(slot->in_use);
+ ut_ad(!slot->suspended);
+ ut_ad(slot->id == os_thread_get_curr_id());
if (srv_print_thread_releases) {
fprintf(stderr,
"Suspending thread %lu to slot %lu\n",
- (ulong) os_thread_get_curr_id(), (ulong) slot_no);
+ (ulong) os_thread_get_curr_id(),
+ (ulong) (slot - srv_sys->sys_threads));
}
- slot = srv_table_get_nth_slot(slot_no);
-
- type = slot->type;
-
- ut_ad(type >= SRV_WORKER);
- ut_ad(type <= SRV_MASTER);
-
- /* The master thread always uses slot number 0. */
- ut_a(type != SRV_MASTER || slot_no == 0);
+ type = srv_slot_get_type(slot);
- event = slot->event;
+ /* The master thread always uses the first slot. */
+ ut_a(type != SRV_MASTER || slot == srv_sys->sys_threads);
slot->suspended = TRUE;
@@ -814,11 +832,9 @@ srv_suspend_thread(void)
srv_sys->n_threads_active[type]--;
- os_event_reset(event);
+ os_event_reset(slot->event);
srv_sys_mutex_exit();
-
- return(event);
}
/*********************************************************************//**
@@ -836,8 +852,7 @@ srv_release_threads(
ulint i;
ulint count = 0;
- ut_ad(type >= SRV_WORKER);
- ut_ad(type <= SRV_MASTER);
+ ut_ad(srv_thread_type_validate(type));
ut_ad(n > 0);
srv_sys_mutex_enter();
@@ -847,7 +862,8 @@ srv_release_threads(
slot = srv_table_get_nth_slot(i);
- if (slot->in_use && slot->type == type && slot->suspended) {
+ if (slot->in_use && slot->suspended
+ && srv_slot_get_type(slot) == type) {
slot->suspended = FALSE;
@@ -894,6 +910,7 @@ srv_thread_has_reserved_slot(
ulint i;
ulint slot_no = ULINT_UNDEFINED;
+ ut_ad(srv_thread_type_validate(type));
srv_sys_mutex_enter();
for (i = 0; i < OS_THREAD_MAX_N; i++) {
@@ -901,7 +918,7 @@ srv_thread_has_reserved_slot(
slot = srv_table_get_nth_slot(i);
- if (slot->in_use && slot->type == type) {
+ if (slot->in_use && srv_slot_get_type(slot) == type) {
slot_no = i;
break;
}
@@ -943,7 +960,7 @@ srv_init(void)
for (i = 0; i < OS_THREAD_MAX_N; i++) {
srv_slot_t* slot;
- slot = srv_table_get_nth_slot(i);
+ slot = srv_sys->sys_threads + i;
slot->event = os_event_create(NULL);
@@ -1012,7 +1029,6 @@ srv_general_init(void)
os_sync_init();
sync_init();
mem_init(srv_mem_pool_size);
- thr_local_init();
que_init();
row_mysql_init();
}
@@ -2032,7 +2048,7 @@ srv_active_wake_master_thread(void)
/* Only if the master thread has been started. */
if (slot->in_use) {
- ut_a(slot->type == SRV_MASTER);
+ ut_a(srv_slot_get_type(slot) == SRV_MASTER);
if (slot->suspended) {
@@ -2552,9 +2568,8 @@ srv_master_thread(
/*!< in: a dummy parameter required by
os_thread_create */
{
- ulint slot;
+ srv_slot_t* slot;
ulint old_activity_count = srv_get_activity_count();
- os_event_t event;
ib_time_t last_print_time;
#ifdef UNIV_DEBUG_THREAD_CREATION
@@ -2572,7 +2587,7 @@ srv_master_thread(
srv_sys_mutex_enter();
slot = srv_table_reserve_slot(SRV_MASTER);
- ut_a(slot == 0);
+ ut_a(slot == srv_sys->sys_threads);
srv_sys->n_threads_active[SRV_MASTER]++;
@@ -2607,7 +2622,7 @@ loop:
suspend_thread:
srv_main_thread_op_info = "suspending";
- event = srv_suspend_thread();
+ srv_suspend_thread(slot);
/* DO NOT CHANGE THIS STRING. innobase_start_or_create_for_mysql()
waits for database activity to die down when converting < 4.1.x
@@ -2615,7 +2630,7 @@ suspend_thread:
manual also mentions this string in several places. */
srv_main_thread_op_info = "waiting for server activity";
- os_event_wait(event);
+ os_event_wait(slot->event);
if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
/* This is only extra safety, the thread should exit
@@ -2626,8 +2641,6 @@ suspend_thread:
}
goto loop;
-
- OS_THREAD_DUMMY_RETURN; /* Not reached, avoid compiler warning */
}
/*********************************************************************//**
@@ -2681,7 +2694,6 @@ srv_worker_thread(
required by os_thread_create */
{
srv_slot_t* slot;
- ulint slot_no = ULINT_UNDEFINED;
#ifdef UNIV_DEBUG_THREAD_CREATION
fprintf(stderr, "Worker thread starts, id %lu\n",
@@ -2690,7 +2702,7 @@ srv_worker_thread(
srv_sys_mutex_enter();
- slot_no = srv_table_reserve_slot(SRV_WORKER);
+ slot = srv_table_reserve_slot(SRV_WORKER);
++srv_sys->n_threads_active[SRV_WORKER];
@@ -2701,11 +2713,9 @@ srv_worker_thread(
while (srv_shutdown_state == SRV_SHUTDOWN_NONE && !srv_fast_shutdown) {
- os_event_t event;
-
- event = srv_suspend_thread();
+ srv_suspend_thread(slot);
- os_event_wait(event);
+ os_event_wait(slot->event);
srv_task_execute();
@@ -2715,15 +2725,12 @@ srv_worker_thread(
srv_wake_purge_thread_if_not_active();
}
- srv_suspend_thread();
-
- /* Free the thread local memory. */
- thr_local_free(os_thread_get_curr_id());
+ srv_suspend_thread(slot);
srv_sys_mutex_enter();
/* Free the slot for reuse. */
- slot = srv_table_get_nth_slot(slot_no);
+ ut_ad(slot->in_use);
slot->in_use = FALSE;
srv_sys_mutex_exit();
@@ -2751,7 +2758,6 @@ srv_purge_coordinator_thread(
required by os_thread_create */
{
srv_slot_t* slot;
- ulint slot_no = ULINT_UNDEFINED;
ut_a(srv_n_purge_threads >= 1);
@@ -2769,7 +2775,7 @@ srv_purge_coordinator_thread(
srv_sys_mutex_enter();
- slot_no = srv_table_reserve_slot(SRV_PURGE);
+ slot = srv_table_reserve_slot(SRV_PURGE);
++srv_sys->n_threads_active[SRV_PURGE];
@@ -2900,19 +2906,16 @@ srv_purge_coordinator_thread(
}
/* Decrement the active count. */
- srv_suspend_thread();
+ srv_suspend_thread(slot);
srv_sys_mutex_enter();
/* Free the slot for reuse. */
- slot = srv_table_get_nth_slot(slot_no);
+ ut_ad(slot->in_use);
slot->in_use = FALSE;
srv_sys_mutex_exit();
- /* Free the thread local memory. */
- thr_local_free(os_thread_get_curr_id());
-
#ifdef UNIV_DEBUG_THREAD_CREATION
fprintf(stderr, "Purge coordinator exiting, id %lu\n",
os_thread_pf(os_thread_get_curr_id()));
=== modified file 'storage/innobase/srv/srv0start.c'
--- a/storage/innobase/srv/srv0start.c 2011-03-14 13:00:56 +0000
+++ b/storage/innobase/srv/srv0start.c 2011-03-24 12:24:08 +0000
@@ -85,7 +85,6 @@ Created 2/16/1996 Heikki Tuuri
# include "row0row.h"
# include "row0mysql.h"
# include "btr0pcur.h"
-# include "thr0loc.h"
# include "os0sync.h" /* for INNODB_RW_LOCKS_USE_ATOMICS */
# include "zlib.h" /* for ZLIB_VERSION */
@@ -2260,7 +2259,6 @@ innobase_shutdown_for_mysql(void)
ibuf_close();
log_shutdown();
lock_sys_close();
- thr_local_close();
trx_sys_file_format_close();
trx_sys_close();
=== removed directory 'storage/innobase/thr'
=== removed file 'storage/innobase/thr/thr0loc.c'
--- a/storage/innobase/thr/thr0loc.c 2010-11-11 13:16:04 +0000
+++ b/storage/innobase/thr/thr0loc.c 1970-01-01 00:00:00 +0000
@@ -1,307 +0,0 @@
-/*****************************************************************************
-
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation; version 2 of the License.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
-
-*****************************************************************************/
-
-/**************************************************//**
-@file thr/thr0loc.c
-The thread local storage
-
-Created 10/5/1995 Heikki Tuuri
-*******************************************************/
-
-#include "thr0loc.h"
-#ifdef UNIV_NONINL
-#include "thr0loc.ic"
-#endif
-
-#include "sync0sync.h"
-#include "hash0hash.h"
-#include "mem0mem.h"
-#include "srv0srv.h"
-
-/*
- IMPLEMENTATION OF THREAD LOCAL STORAGE
- ======================================
-
-The threads sometimes need private data which depends on the thread id.
-This is implemented as a hash table, where the hash value is calculated
-from the thread id, to prepare for a large number of threads. The hash table
-is protected by a mutex. If you need modify the program and put new data to
-the thread local storage, just add it to struct thr_local_struct in the
-header file. */
-
-/** Mutex protecting thr_local_hash */
-static mutex_t thr_local_mutex;
-
-/** The hash table. The module is not yet initialized when it is NULL. */
-static hash_table_t* thr_local_hash = NULL;
-
-/** Thread local data */
-typedef struct thr_local_struct thr_local_t;
-
-#ifdef UNIV_PFS_MUTEX
-/* Key to register the mutex with performance schema */
-UNIV_INTERN mysql_pfs_key_t thr_local_mutex_key;
-#endif /* UNIV_PFS_MUTEX */
-
-/** @brief Thread local data.
-The private data for each thread should be put to
-the structure below and the accessor functions written
-for the field. */
-struct thr_local_struct{
- os_thread_id_t id; /*!< id of the thread which owns this struct */
- os_thread_t handle; /*!< operating system handle to the thread */
- ulint slot_no;/*!< the index of the slot in the thread table
- for this thread */
- ibool in_ibuf;/*!< TRUE if the thread is doing an ibuf
- operation */
- hash_node_t hash; /*!< hash chain node */
- ulint magic_n;/*!< magic number (THR_LOCAL_MAGIC_N) */
-};
-
-/** The value of thr_local_struct::magic_n */
-#define THR_LOCAL_MAGIC_N 1231234
-
-#ifdef UNIV_DEBUG
-/*******************************************************************//**
-Validates thread local data.
-@return TRUE if valid */
-static
-ibool
-thr_local_validate(
-/*===============*/
- const thr_local_t* local) /*!< in: data to validate */
-{
- ut_ad(local->magic_n == THR_LOCAL_MAGIC_N);
- ut_ad(local->slot_no == ULINT_UNDEFINED
- || local->slot_no < OS_THREAD_MAX_N);
- ut_ad(local->in_ibuf == FALSE || local->in_ibuf == TRUE);
- return(TRUE);
-}
-#endif /* UNIV_DEBUG */
-
-/*******************************************************************//**
-Returns the local storage struct for a thread.
-@return local storage */
-static
-thr_local_t*
-thr_local_get(
-/*==========*/
- os_thread_id_t id) /*!< in: thread id of the thread */
-{
- thr_local_t* local;
-
-try_again:
- ut_ad(thr_local_hash);
- ut_ad(mutex_own(&thr_local_mutex));
-
- /* Look for the local struct in the hash table */
-
- local = NULL;
-
- HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
- thr_local_t*, local, ut_ad(thr_local_validate(local)),
- os_thread_eq(local->id, id));
- if (local == NULL) {
- mutex_exit(&thr_local_mutex);
-
- thr_local_create();
-
- mutex_enter(&thr_local_mutex);
-
- goto try_again;
- }
-
- ut_ad(thr_local_validate(local));
-
- return(local);
-}
-
-/*******************************************************************//**
-Gets the slot number in the thread table of a thread.
-@return slot number */
-UNIV_INTERN
-ulint
-thr_local_get_slot_no(
-/*==================*/
- os_thread_id_t id) /*!< in: thread id of the thread */
-{
- ulint slot_no;
- thr_local_t* local;
-
- mutex_enter(&thr_local_mutex);
-
- local = thr_local_get(id);
-
- slot_no = local->slot_no;
-
- mutex_exit(&thr_local_mutex);
-
- return(slot_no);
-}
-
-/*******************************************************************//**
-Sets the slot number in the thread table of a thread. */
-UNIV_INTERN
-void
-thr_local_set_slot_no(
-/*==================*/
- os_thread_id_t id, /*!< in: thread id of the thread */
- ulint slot_no)/*!< in: slot number */
-{
- thr_local_t* local;
-
- mutex_enter(&thr_local_mutex);
-
- local = thr_local_get(id);
-
- local->slot_no = slot_no;
-
- mutex_exit(&thr_local_mutex);
-}
-
-/*******************************************************************//**
-Returns pointer to the 'in_ibuf' field within the current thread local
-storage.
-@return pointer to the in_ibuf field */
-UNIV_INTERN
-ibool*
-thr_local_get_in_ibuf_field(void)
-/*=============================*/
-{
- thr_local_t* local;
-
- mutex_enter(&thr_local_mutex);
-
- local = thr_local_get(os_thread_get_curr_id());
-
- mutex_exit(&thr_local_mutex);
-
- return(&(local->in_ibuf));
-}
-
-/*******************************************************************//**
-Creates a local storage struct for the calling new thread. */
-UNIV_INTERN
-void
-thr_local_create(void)
-/*==================*/
-{
- thr_local_t* local;
-
- if (thr_local_hash == NULL) {
- thr_local_init();
- }
-
- local = mem_alloc(sizeof(thr_local_t));
-
- local->id = os_thread_get_curr_id();
- local->handle = os_thread_get_curr();
- local->magic_n = THR_LOCAL_MAGIC_N;
- local->slot_no = ULINT_UNDEFINED;
- local->in_ibuf = FALSE;
-
- mutex_enter(&thr_local_mutex);
-
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-
- mutex_exit(&thr_local_mutex);
-}
-
-/*******************************************************************//**
-Frees the local storage struct for the specified thread. */
-UNIV_INTERN
-void
-thr_local_free(
-/*===========*/
- os_thread_id_t id) /*!< in: thread id */
-{
- thr_local_t* local;
-
- mutex_enter(&thr_local_mutex);
-
- /* Look for the local struct in the hash table */
-
- HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
- thr_local_t*, local, ut_ad(thr_local_validate(local)),
- os_thread_eq(local->id, id));
- if (local == NULL) {
- mutex_exit(&thr_local_mutex);
-
- return;
- }
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-
- mutex_exit(&thr_local_mutex);
-
- ut_a(local->magic_n == THR_LOCAL_MAGIC_N);
- ut_ad(thr_local_validate(local));
-
- mem_free(local);
-}
-
-/****************************************************************//**
-Initializes the thread local storage module. */
-UNIV_INTERN
-void
-thr_local_init(void)
-/*================*/
-{
-
- ut_a(thr_local_hash == NULL);
-
- thr_local_hash = hash_create(OS_THREAD_MAX_N + 100);
-
- mutex_create(thr_local_mutex_key,
- &thr_local_mutex, SYNC_THR_LOCAL);
-}
-
-/********************************************************************
-Close the thread local storage module. */
-UNIV_INTERN
-void
-thr_local_close(void)
-/*=================*/
-{
- ulint i;
-
- ut_a(thr_local_hash != NULL);
-
- /* Free the hash elements. We don't remove them from the table
- because we are going to destroy the table anyway. */
- for (i = 0; i < hash_get_n_cells(thr_local_hash); i++) {
- thr_local_t* local;
-
- local = HASH_GET_FIRST(thr_local_hash, i);
-
- while (local) {
- thr_local_t* prev_local = local;
-
- local = HASH_GET_NEXT(hash, prev_local);
- ut_a(prev_local->magic_n == THR_LOCAL_MAGIC_N);
- ut_ad(thr_local_validate(prev_local));
- mem_free(prev_local);
- }
- }
-
- hash_table_free(thr_local_hash);
- thr_local_hash = NULL;
-}
=== modified file 'storage/innobase/trx/trx0i_s.c'
--- a/storage/innobase/trx/trx0i_s.c 2011-01-19 08:45:58 +0000
+++ b/storage/innobase/trx/trx0i_s.c 2011-03-28 09:15:58 +0000
@@ -519,7 +519,7 @@ fill_trx_row(
query[stmt_len] = '\0';
row->trx_query = ha_storage_put_memlim(
- cache->storage, stmt, stmt_len + 1,
+ cache->storage, query, stmt_len + 1,
MAX_ALLOWED_FOR_STORAGE(cache));
row->trx_query_cs = innobase_get_charset(trx->mysql_thd);
=== modified file 'storage/innobase/trx/trx0rec.c'
--- a/storage/innobase/trx/trx0rec.c 2010-08-07 06:52:02 +0000
+++ b/storage/innobase/trx/trx0rec.c 2011-03-23 13:43:14 +0000
@@ -353,7 +353,7 @@ trx_undo_rec_get_col_val(
/* @see dtuple_convert_big_rec() */
ut_ad(*len >= BTR_EXTERN_FIELD_REF_SIZE * 2);
/* we do not have access to index->table here
- ut_ad(dict_table_get_format(index->table) >= DICT_TF_FORMAT_ZIP
+ ut_ad(dict_table_get_format(index->table) >= UNIV_FORMAT_B
|| *len >= REC_MAX_INDEX_COL_LEN
+ BTR_EXTERN_FIELD_REF_SIZE);
*/
@@ -1084,7 +1084,7 @@ trx_undo_rec_get_partial_row(
ut_a(dfield_get_len(dfield)
>= 2 * BTR_EXTERN_FIELD_REF_SIZE);
ut_a(dict_table_get_format(index->table)
- >= DICT_TF_FORMAT_ZIP
+ >= UNIV_FORMAT_B
|| dfield_get_len(dfield)
>= REC_MAX_INDEX_COL_LEN
+ BTR_EXTERN_FIELD_REF_SIZE);
=== modified file 'storage/innobase/trx/trx0sys.c'
--- a/storage/innobase/trx/trx0sys.c 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/trx/trx0sys.c 2011-03-23 13:43:14 +0000
@@ -1189,7 +1189,7 @@ trx_sys_file_format_id_to_name(
/*****************************************************************//**
Check for the max file format tag stored on disk. Note: If max_format_id
-is == DICT_TF_FORMAT_MAX + 1 then we only print a warning.
+is == UNIV_FORMAT_MAX + 1 then we only print a warning.
@return DB_SUCCESS or error code */
UNIV_INTERN
ulint
@@ -1206,15 +1206,15 @@ trx_sys_file_format_max_check(
if (format_id == ULINT_UNDEFINED) {
/* Format ID was not set. Set it to minimum possible
value. */
- format_id = DICT_TF_FORMAT_MIN;
+ format_id = UNIV_FORMAT_MIN;
}
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: highest supported file format is %s.\n",
- trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX));
+ trx_sys_file_format_id_to_name(UNIV_FORMAT_MAX));
- if (format_id > DICT_TF_FORMAT_MAX) {
+ if (format_id > UNIV_FORMAT_MAX) {
ut_a(format_id < FILE_FORMAT_NAME_N);
@@ -1222,11 +1222,11 @@ trx_sys_file_format_max_check(
fprintf(stderr,
" InnoDB: %s: the system tablespace is in a file "
"format that this version doesn't support - %s\n",
- ((max_format_id <= DICT_TF_FORMAT_MAX)
+ ((max_format_id <= UNIV_FORMAT_MAX)
? "Error" : "Warning"),
trx_sys_file_format_id_to_name(format_id));
- if (max_format_id <= DICT_TF_FORMAT_MAX) {
+ if (max_format_id <= UNIV_FORMAT_MAX) {
return(DB_ERROR);
}
}
@@ -1255,7 +1255,7 @@ trx_sys_file_format_max_set(
{
ibool ret = FALSE;
- ut_a(format_id <= DICT_TF_FORMAT_MAX);
+ ut_a(format_id <= UNIV_FORMAT_MAX);
mutex_enter(&file_format_max.mutex);
@@ -1286,7 +1286,7 @@ trx_sys_file_format_tag_init(void)
/* If format_id is not set then set it to the minimum. */
if (format_id == ULINT_UNDEFINED) {
- trx_sys_file_format_max_set(DICT_TF_FORMAT_MIN, NULL);
+ trx_sys_file_format_max_set(UNIV_FORMAT_MIN, NULL);
}
}
@@ -1305,7 +1305,7 @@ trx_sys_file_format_max_upgrade(
ut_a(name);
ut_a(file_format_max.name != NULL);
- ut_a(format_id <= DICT_TF_FORMAT_MAX);
+ ut_a(format_id <= UNIV_FORMAT_MAX);
mutex_enter(&file_format_max.mutex);
@@ -1342,7 +1342,7 @@ trx_sys_file_format_init(void)
/* We don't need a mutex here, as this function should only
be called once at start up. */
- file_format_max.id = DICT_TF_FORMAT_MIN;
+ file_format_max.id = UNIV_FORMAT_MIN;
file_format_max.name = trx_sys_file_format_id_to_name(
file_format_max.id);
=== modified file 'storage/innobase/trx/trx0trx.c'
--- a/storage/innobase/trx/trx0trx.c 2011-03-09 07:32:36 +0000
+++ b/storage/innobase/trx/trx0trx.c 2011-03-24 12:24:08 +0000
@@ -39,7 +39,6 @@ Created 3/26/1996 Heikki Tuuri
#include "read0read.h"
#include "srv0srv.h"
#include "srv0start.h"
-#include "thr0loc.h"
#include "btr0sea.h"
#include "os0proc.h"
#include "trx0xa.h"
No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
| Thread |
|---|
| • bzr commit into mysql-trunk branch (sergey.glukhov:3347) | Sergey Glukhov | 30 Mar |