2009-02-17 08:12:02 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1996, 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
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**************************************************//**
|
|
|
|
@file dict/dict0boot.c
|
2005-10-27 07:29:40 +00:00
|
|
|
Data dictionary creation and booting
|
|
|
|
|
|
|
|
Created 4/18/1996 Heikki Tuuri
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
#include "dict0boot.h"
|
|
|
|
|
|
|
|
#ifdef UNIV_NONINL
|
|
|
|
#include "dict0boot.ic"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "dict0crea.h"
|
|
|
|
#include "btr0btr.h"
|
|
|
|
#include "dict0load.h"
|
|
|
|
#include "dict0load.h"
|
|
|
|
#include "trx0trx.h"
|
|
|
|
#include "srv0srv.h"
|
|
|
|
#include "ibuf0ibuf.h"
|
|
|
|
#include "buf0flu.h"
|
|
|
|
#include "log0recv.h"
|
|
|
|
#include "os0file.h"
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets a pointer to the dictionary header and x-latches its page.
|
|
|
|
@return pointer to the dictionary header, page x-latched */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_hdr_t*
|
|
|
|
dict_hdr_get(
|
|
|
|
/*=========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_hdr_t* header;
|
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
block = buf_page_get(DICT_HDR_SPACE, 0, DICT_HDR_PAGE_NO,
|
2006-10-12 11:05:22 +00:00
|
|
|
RW_X_LATCH, mtr);
|
|
|
|
header = DICT_HDR + buf_block_get_frame(block);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_DICT_HEADER);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(header);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Returns a new table, index, or tree id.
|
|
|
|
@return the new id */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
dulint
|
|
|
|
dict_hdr_get_new_id(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint type) /*!< in: DICT_HDR_ROW_ID, ... */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
dict_hdr_t* dict_hdr;
|
|
|
|
dulint id;
|
|
|
|
mtr_t mtr;
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
ut_ad((type == DICT_HDR_TABLE_ID) || (type == DICT_HDR_INDEX_ID));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
|
|
|
dict_hdr = dict_hdr_get(&mtr);
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
id = mtr_read_dulint(dict_hdr + type, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
id = ut_dulint_add(id, 1);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
|
|
|
mlog_write_dulint(dict_hdr + type, id, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
return(id);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Writes the current value of the row id counter to the dictionary header file
|
|
|
|
page. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
dict_hdr_flush_row_id(void)
|
|
|
|
/*=======================*/
|
|
|
|
{
|
|
|
|
dict_hdr_t* dict_hdr;
|
|
|
|
dulint id;
|
|
|
|
mtr_t mtr;
|
|
|
|
|
|
|
|
ut_ad(mutex_own(&(dict_sys->mutex)));
|
|
|
|
|
|
|
|
id = dict_sys->row_id;
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
|
|
|
dict_hdr = dict_hdr_get(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
|
|
|
mlog_write_dulint(dict_hdr + DICT_HDR_ROW_ID, id, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*****************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Creates the file page for the dictionary header. This function is
|
2009-05-25 05:30:14 +00:00
|
|
|
called only at the database creation.
|
|
|
|
@return TRUE if succeed */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
ibool
|
|
|
|
dict_hdr_create(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr) /*!< in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_hdr_t* dict_header;
|
|
|
|
ulint root_page_no;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(mtr);
|
|
|
|
|
|
|
|
/* Create the dictionary header file block in a new, allocated file
|
|
|
|
segment in the system tablespace */
|
2006-10-12 11:05:22 +00:00
|
|
|
block = fseg_create(DICT_HDR_SPACE, 0,
|
|
|
|
DICT_HDR + DICT_HDR_FSEG_HEADER, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
ut_a(DICT_HDR_PAGE_NO == buf_block_get_page_no(block));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
dict_header = dict_hdr_get(mtr);
|
|
|
|
|
|
|
|
/* Start counting row, table, index, and tree ids from
|
|
|
|
DICT_HDR_FIRST_ID */
|
|
|
|
mlog_write_dulint(dict_header + DICT_HDR_ROW_ID,
|
2006-08-29 09:30:31 +00:00
|
|
|
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mlog_write_dulint(dict_header + DICT_HDR_TABLE_ID,
|
2006-08-29 09:30:31 +00:00
|
|
|
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID,
|
2006-08-29 09:30:31 +00:00
|
|
|
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
/* Obsolete, but we must initialize it to 0 anyway. */
|
2005-10-27 07:29:40 +00:00
|
|
|
mlog_write_dulint(dict_header + DICT_HDR_MIX_ID,
|
2006-08-29 09:30:31 +00:00
|
|
|
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Create the B-tree roots for the clustered indexes of the basic
|
|
|
|
system tables */
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
/*--------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
|
2007-01-18 09:59:00 +00:00
|
|
|
DICT_HDR_SPACE, 0, DICT_TABLES_ID,
|
2009-03-20 10:33:33 +00:00
|
|
|
dict_ind_redundant, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (root_page_no == FIL_NULL) {
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
mlog_write_ulint(dict_header + DICT_HDR_TABLES, root_page_no,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
/*--------------------------*/
|
2007-01-18 09:59:00 +00:00
|
|
|
root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE, 0,
|
2006-08-29 09:30:31 +00:00
|
|
|
DICT_TABLE_IDS_ID,
|
2009-03-20 10:33:33 +00:00
|
|
|
dict_ind_redundant, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (root_page_no == FIL_NULL) {
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
mlog_write_ulint(dict_header + DICT_HDR_TABLE_IDS, root_page_no,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
/*--------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
|
2007-01-18 09:59:00 +00:00
|
|
|
DICT_HDR_SPACE, 0, DICT_COLUMNS_ID,
|
2009-03-20 10:33:33 +00:00
|
|
|
dict_ind_redundant, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (root_page_no == FIL_NULL) {
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
mlog_write_ulint(dict_header + DICT_HDR_COLUMNS, root_page_no,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
/*--------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
|
2007-01-18 09:59:00 +00:00
|
|
|
DICT_HDR_SPACE, 0, DICT_INDEXES_ID,
|
2009-03-20 10:33:33 +00:00
|
|
|
dict_ind_redundant, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (root_page_no == FIL_NULL) {
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
mlog_write_ulint(dict_header + DICT_HDR_INDEXES, root_page_no,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
/*--------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
|
2007-01-18 09:59:00 +00:00
|
|
|
DICT_HDR_SPACE, 0, DICT_FIELDS_ID,
|
2009-03-20 10:33:33 +00:00
|
|
|
dict_ind_redundant, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (root_page_no == FIL_NULL) {
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
mlog_write_ulint(dict_header + DICT_HDR_FIELDS, root_page_no,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_4BYTES, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
/*--------------------------*/
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*****************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Initializes the data dictionary memory structures when the database is
|
|
|
|
started. This function is also called when the data dictionary is created. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
dict_boot(void)
|
|
|
|
/*===========*/
|
|
|
|
{
|
|
|
|
dict_table_t* table;
|
|
|
|
dict_index_t* index;
|
|
|
|
dict_hdr_t* dict_hdr;
|
2007-01-30 09:24:18 +00:00
|
|
|
mem_heap_t* heap;
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_t mtr;
|
2007-12-19 14:03:39 +00:00
|
|
|
ulint error;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_start(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Create the hash tables etc. */
|
|
|
|
dict_init();
|
|
|
|
|
2007-01-30 09:24:18 +00:00
|
|
|
heap = mem_heap_create(450);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mutex_enter(&(dict_sys->mutex));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Get the dictionary header */
|
|
|
|
dict_hdr = dict_hdr_get(&mtr);
|
|
|
|
|
|
|
|
/* Because we only write new row ids to disk-based data structure
|
|
|
|
(dictionary header) when it is divisible by
|
|
|
|
DICT_HDR_ROW_ID_WRITE_MARGIN, in recovery we will not recover
|
|
|
|
the latest value of the row id counter. Therefore we advance
|
|
|
|
the counter at the database startup to avoid overlapping values.
|
|
|
|
Note that when a user after database startup first time asks for
|
|
|
|
a new row id, then because the counter is now divisible by
|
|
|
|
..._MARGIN, it will immediately be updated to the disk-based
|
|
|
|
header. */
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
dict_sys->row_id = ut_dulint_add(
|
|
|
|
ut_dulint_align_up(mtr_read_dulint(dict_hdr + DICT_HDR_ROW_ID,
|
|
|
|
&mtr),
|
|
|
|
DICT_HDR_ROW_ID_WRITE_MARGIN),
|
|
|
|
DICT_HDR_ROW_ID_WRITE_MARGIN);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Insert into the dictionary cache the descriptions of the basic
|
|
|
|
system tables */
|
|
|
|
/*-------------------------*/
|
2006-02-27 09:33:26 +00:00
|
|
|
table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-30 09:24:18 +00:00
|
|
|
dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
|
|
|
|
dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
|
branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
2008-03-10 11:05:32 +00:00
|
|
|
/* ROW_FORMAT = (N_COLS >> 31) ? COMPACT : REDUNDANT */
|
2007-01-30 09:24:18 +00:00
|
|
|
dict_mem_table_add_col(table, heap, "N_COLS", DATA_INT, 0, 4);
|
branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
2008-03-10 11:05:32 +00:00
|
|
|
/* TYPE is either DICT_TABLE_ORDINARY, or (TYPE & DICT_TF_COMPACT)
|
|
|
|
and (TYPE & DICT_TF_FORMAT_MASK) are nonzero and TYPE = table->flags */
|
2007-01-30 09:24:18 +00:00
|
|
|
dict_mem_table_add_col(table, heap, "TYPE", DATA_INT, 0, 4);
|
|
|
|
dict_mem_table_add_col(table, heap, "MIX_ID", DATA_BINARY, 0, 0);
|
|
|
|
dict_mem_table_add_col(table, heap, "MIX_LEN", DATA_INT, 0, 4);
|
|
|
|
dict_mem_table_add_col(table, heap, "CLUSTER_NAME", DATA_BINARY, 0, 0);
|
|
|
|
dict_mem_table_add_col(table, heap, "SPACE", DATA_INT, 0, 4);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
table->id = DICT_TABLES_ID;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-30 09:24:18 +00:00
|
|
|
dict_table_add_to_cache(table, heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_sys->sys_tables = table;
|
2007-01-30 09:24:18 +00:00
|
|
|
mem_heap_empty(heap);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
index = dict_mem_index_create("SYS_TABLES", "CLUST_IND",
|
2006-08-29 09:30:31 +00:00
|
|
|
DICT_HDR_SPACE,
|
|
|
|
DICT_UNIQUE | DICT_CLUSTERED, 1);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
dict_mem_index_add_field(index, "NAME", 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
index->id = DICT_TABLES_ID;
|
|
|
|
|
2007-12-19 14:03:39 +00:00
|
|
|
error = dict_index_add_to_cache(table, index,
|
|
|
|
mtr_read_ulint(dict_hdr
|
|
|
|
+ DICT_HDR_TABLES,
|
2008-09-18 12:31:17 +00:00
|
|
|
MLOG_4BYTES, &mtr),
|
|
|
|
FALSE);
|
2007-12-19 14:03:39 +00:00
|
|
|
ut_a(error == DB_SUCCESS);
|
2006-09-19 10:14:07 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*-------------------------*/
|
|
|
|
index = dict_mem_index_create("SYS_TABLES", "ID_IND",
|
2006-08-29 09:30:31 +00:00
|
|
|
DICT_HDR_SPACE, DICT_UNIQUE, 1);
|
2006-02-23 19:25:29 +00:00
|
|
|
dict_mem_index_add_field(index, "ID", 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
index->id = DICT_TABLE_IDS_ID;
|
2007-12-19 14:03:39 +00:00
|
|
|
error = dict_index_add_to_cache(table, index,
|
|
|
|
mtr_read_ulint(dict_hdr
|
|
|
|
+ DICT_HDR_TABLE_IDS,
|
2008-09-18 12:31:17 +00:00
|
|
|
MLOG_4BYTES, &mtr),
|
|
|
|
FALSE);
|
2007-12-19 14:03:39 +00:00
|
|
|
ut_a(error == DB_SUCCESS);
|
2006-09-19 10:14:07 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*-------------------------*/
|
2006-02-27 09:33:26 +00:00
|
|
|
table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-30 09:24:18 +00:00
|
|
|
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);
|
|
|
|
dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
|
|
|
|
dict_mem_table_add_col(table, heap, "MTYPE", DATA_INT, 0, 4);
|
|
|
|
dict_mem_table_add_col(table, heap, "PRTYPE", DATA_INT, 0, 4);
|
|
|
|
dict_mem_table_add_col(table, heap, "LEN", DATA_INT, 0, 4);
|
|
|
|
dict_mem_table_add_col(table, heap, "PREC", DATA_INT, 0, 4);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
table->id = DICT_COLUMNS_ID;
|
|
|
|
|
2007-01-30 09:24:18 +00:00
|
|
|
dict_table_add_to_cache(table, heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_sys->sys_columns = table;
|
2007-01-30 09:24:18 +00:00
|
|
|
mem_heap_empty(heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
index = dict_mem_index_create("SYS_COLUMNS", "CLUST_IND",
|
2006-08-29 09:30:31 +00:00
|
|
|
DICT_HDR_SPACE,
|
|
|
|
DICT_UNIQUE | DICT_CLUSTERED, 2);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
dict_mem_index_add_field(index, "TABLE_ID", 0);
|
|
|
|
dict_mem_index_add_field(index, "POS", 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
index->id = DICT_COLUMNS_ID;
|
2007-12-19 14:03:39 +00:00
|
|
|
error = dict_index_add_to_cache(table, index,
|
|
|
|
mtr_read_ulint(dict_hdr
|
|
|
|
+ DICT_HDR_COLUMNS,
|
2008-09-18 12:31:17 +00:00
|
|
|
MLOG_4BYTES, &mtr),
|
|
|
|
FALSE);
|
2007-12-19 14:03:39 +00:00
|
|
|
ut_a(error == DB_SUCCESS);
|
2006-09-19 10:14:07 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*-------------------------*/
|
2006-02-27 09:33:26 +00:00
|
|
|
table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-30 09:24:18 +00:00
|
|
|
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);
|
|
|
|
dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
|
|
|
|
dict_mem_table_add_col(table, heap, "N_FIELDS", DATA_INT, 0, 4);
|
|
|
|
dict_mem_table_add_col(table, heap, "TYPE", DATA_INT, 0, 4);
|
|
|
|
dict_mem_table_add_col(table, heap, "SPACE", DATA_INT, 0, 4);
|
|
|
|
dict_mem_table_add_col(table, heap, "PAGE_NO", DATA_INT, 0, 4);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* The '+ 2' below comes from the 2 system fields */
|
|
|
|
#if DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2
|
|
|
|
#error "DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2"
|
|
|
|
#endif
|
|
|
|
#if DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2
|
|
|
|
#error "DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2"
|
|
|
|
#endif
|
|
|
|
#if DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2
|
|
|
|
#error "DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
table->id = DICT_INDEXES_ID;
|
2007-01-30 09:24:18 +00:00
|
|
|
dict_table_add_to_cache(table, heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_sys->sys_indexes = table;
|
2007-01-30 09:24:18 +00:00
|
|
|
mem_heap_empty(heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
index = dict_mem_index_create("SYS_INDEXES", "CLUST_IND",
|
2006-08-29 09:30:31 +00:00
|
|
|
DICT_HDR_SPACE,
|
|
|
|
DICT_UNIQUE | DICT_CLUSTERED, 2);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
dict_mem_index_add_field(index, "TABLE_ID", 0);
|
|
|
|
dict_mem_index_add_field(index, "ID", 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
index->id = DICT_INDEXES_ID;
|
2007-12-19 14:03:39 +00:00
|
|
|
error = dict_index_add_to_cache(table, index,
|
|
|
|
mtr_read_ulint(dict_hdr
|
|
|
|
+ DICT_HDR_INDEXES,
|
2008-09-18 12:31:17 +00:00
|
|
|
MLOG_4BYTES, &mtr),
|
|
|
|
FALSE);
|
2007-12-19 14:03:39 +00:00
|
|
|
ut_a(error == DB_SUCCESS);
|
2006-09-19 10:14:07 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*-------------------------*/
|
2006-02-27 09:33:26 +00:00
|
|
|
table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-30 09:24:18 +00:00
|
|
|
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);
|
|
|
|
dict_mem_table_add_col(table, heap, "COL_NAME", DATA_BINARY, 0, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
table->id = DICT_FIELDS_ID;
|
2007-01-30 09:24:18 +00:00
|
|
|
dict_table_add_to_cache(table, heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_sys->sys_fields = table;
|
2007-01-30 09:24:18 +00:00
|
|
|
mem_heap_free(heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
index = dict_mem_index_create("SYS_FIELDS", "CLUST_IND",
|
2006-08-29 09:30:31 +00:00
|
|
|
DICT_HDR_SPACE,
|
|
|
|
DICT_UNIQUE | DICT_CLUSTERED, 2);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
dict_mem_index_add_field(index, "INDEX_ID", 0);
|
|
|
|
dict_mem_index_add_field(index, "POS", 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
index->id = DICT_FIELDS_ID;
|
2007-12-19 14:03:39 +00:00
|
|
|
error = dict_index_add_to_cache(table, index,
|
|
|
|
mtr_read_ulint(dict_hdr
|
|
|
|
+ DICT_HDR_FIELDS,
|
2008-09-18 12:31:17 +00:00
|
|
|
MLOG_4BYTES, &mtr),
|
|
|
|
FALSE);
|
2007-12-19 14:03:39 +00:00
|
|
|
ut_a(error == DB_SUCCESS);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
/*-------------------------*/
|
|
|
|
|
|
|
|
/* Initialize the insert buffer table and index for each tablespace */
|
|
|
|
|
|
|
|
ibuf_init_at_db_start();
|
|
|
|
|
|
|
|
/* Load definitions of other indexes on system tables */
|
|
|
|
|
|
|
|
dict_load_sys_table(dict_sys->sys_tables);
|
|
|
|
dict_load_sys_table(dict_sys->sys_columns);
|
|
|
|
dict_load_sys_table(dict_sys->sys_indexes);
|
|
|
|
dict_load_sys_table(dict_sys->sys_fields);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mutex_exit(&(dict_sys->mutex));
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*****************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Inserts the basic system table data into themselves in the database
|
|
|
|
creation. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
dict_insert_initial_data(void)
|
|
|
|
/*==========================*/
|
|
|
|
{
|
|
|
|
/* Does nothing yet */
|
|
|
|
}
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/*****************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Creates and initializes the data dictionary at the database creation. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
dict_create(void)
|
|
|
|
/*=============*/
|
|
|
|
{
|
|
|
|
mtr_t mtr;
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
|
|
|
dict_hdr_create(&mtr);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_boot();
|
|
|
|
|
|
|
|
dict_insert_initial_data();
|
|
|
|
}
|