summaryrefslogtreecommitdiff
path: root/storage/innobase/dict/dict0boot.c
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@oracle.com>2010-05-24 14:45:24 +0300
committerMarko Mäkelä <marko.makela@oracle.com>2010-05-24 14:45:24 +0300
commit42eff81005a02487a661ad46b34316410251df2e (patch)
treeda5ec33bcdf696efacf0c9cdc1028d6cab96426d /storage/innobase/dict/dict0boot.c
parentdde975afb9fc95f2b3d603a3995157c9e744a5df (diff)
downloadmariadb-git-42eff81005a02487a661ad46b34316410251df2e.tar.gz
Merge a change from mysql-5.1-innodb:
------------------------------------------------------------ revno: 3479 revision-id: marko.makela@oracle.com-20100524110439-fazi70rlmt07tzd9 parent: vasil.dimov@oracle.com-20100520133157-42uk5q3pp0vsinac committer: Marko Mäkelä <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Mon 2010-05-24 14:04:39 +0300 message: Bug#53578: assert on invalid page access, in fil_io() Store the max_space_id in the data dictionary header in order to avoid space_id reuse. DICT_HDR_MIX_ID: Renamed to DICT_HDR_MAX_SPACE_ID, DICT_HDR_MIX_ID_LOW. dict_hdr_get_new_id(): Return table_id, index_id, space_id or a subset of them. fil_system_t: Add ibool space_id_reuse_warned. fil_create_new_single_table_tablespace(): Get the space_id from the caller. fil_space_create(): Issue a warning if the fil_system->max_assigned_id is exceeded. fil_assign_new_space_id(): Return TRUE/FALSE and take a pointer to the space_id as a parameter. Make the function public. fil_init(): Initialize all fil_system fields by mem_zalloc(). Remove explicit initializations of certain fields to 0 or NULL.
Diffstat (limited to 'storage/innobase/dict/dict0boot.c')
-rw-r--r--storage/innobase/dict/dict0boot.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/storage/innobase/dict/dict0boot.c b/storage/innobase/dict/dict0boot.c
index 45d57b8c619..e63c1dc94b9 100644
--- a/storage/innobase/dict/dict0boot.c
+++ b/storage/innobase/dict/dict0boot.c
@@ -62,32 +62,47 @@ dict_hdr_get(
}
/**********************************************************************//**
-Returns a new table, index, or tree id.
-@return the new id */
+Returns a new table, index, or space id. */
UNIV_INTERN
-dulint
+void
dict_hdr_get_new_id(
/*================*/
- ulint type) /*!< in: DICT_HDR_ROW_ID, ... */
+ dulint* table_id, /*!< out: table id (not assigned if NULL) */
+ dulint* index_id, /*!< out: index id (not assigned if NULL) */
+ ulint* space_id) /*!< out: space id (not assigned if NULL) */
{
dict_hdr_t* dict_hdr;
dulint id;
mtr_t mtr;
- ut_ad((type == DICT_HDR_TABLE_ID) || (type == DICT_HDR_INDEX_ID));
-
mtr_start(&mtr);
dict_hdr = dict_hdr_get(&mtr);
- id = mtr_read_dulint(dict_hdr + type, &mtr);
- id = ut_dulint_add(id, 1);
+ if (table_id) {
+ id = mtr_read_dulint(dict_hdr + DICT_HDR_TABLE_ID, &mtr);
+ id = ut_dulint_add(id, 1);
+ mlog_write_dulint(dict_hdr + DICT_HDR_TABLE_ID, id, &mtr);
+ *table_id = id;
+ }
- mlog_write_dulint(dict_hdr + type, id, &mtr);
+ if (index_id) {
+ id = mtr_read_dulint(dict_hdr + DICT_HDR_INDEX_ID, &mtr);
+ id = ut_dulint_add(id, 1);
+ mlog_write_dulint(dict_hdr + DICT_HDR_INDEX_ID, id, &mtr);
+ *index_id = id;
+ }
- mtr_commit(&mtr);
+ if (space_id) {
+ *space_id = mtr_read_ulint(dict_hdr + DICT_HDR_MAX_SPACE_ID,
+ MLOG_4BYTES, &mtr);
+ if (fil_assign_new_space_id(space_id)) {
+ mlog_write_ulint(dict_hdr + DICT_HDR_MAX_SPACE_ID,
+ *space_id, MLOG_4BYTES, &mtr);
+ }
+ }
- return(id);
+ mtr_commit(&mtr);
}
/**********************************************************************//**
@@ -151,9 +166,12 @@ dict_hdr_create(
mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID,
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
- /* Obsolete, but we must initialize it to 0 anyway. */
- mlog_write_dulint(dict_header + DICT_HDR_MIX_ID,
- ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
+ mlog_write_ulint(dict_header + DICT_HDR_MAX_SPACE_ID,
+ 0, MLOG_4BYTES, mtr);
+
+ /* Obsolete, but we must initialize it anyway. */
+ mlog_write_ulint(dict_header + DICT_HDR_MIX_ID_LOW,
+ DICT_HDR_FIRST_ID, MLOG_4BYTES, mtr);
/* Create the B-tree roots for the clustered indexes of the basic
system tables */