mirror of
https://github.com/MariaDB/server.git
synced 2025-10-27 05:56:07 +03:00
------------------------------------------------------------ revno: 3414 revision-id: marko.makela@oracle.com-20100422093342-jf9ojlzdqsdebohn parent: marko.makela@oracle.com-20100421185359-8qaxoa2yyrpzwdd7 committer: Marko M?kel? <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Thu 2010-04-22 12:33:42 +0300 message: Correct the definition of DICT_SYS_INDEXES_NAME_FIELD. When row_merge_drop_temp_indexes() was reworked to drop the indexes via the data dictionary cache, the code was broken because it would read the index name from the wrong field. modified: storage/innodb_plugin/ChangeLog 2425@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog storage/innodb_plugin/dict/dict0boot.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fdict%2Fdict0boot.c storage/innodb_plugin/include/dict0boot.h 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fdict0boot.h ------------------------------------------------------------ revno: 3413 revision-id: marko.makela@oracle.com-20100421185359-8qaxoa2yyrpzwdd7 parent: marko.makela@oracle.com-20100421102723-0i80uezbyu0ekj5d committer: Marko M?kel? <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Wed 2010-04-21 21:53:59 +0300 message: btr_page_split_and_insert(): Avoid an infinite loop. (Bug #52964) btr_page_tuple_smaller(): New function, refactored from btr_page_split_and_insert(). btr_page_get_split_rec(): Renamed from btr_page_get_sure_split_rec(). Note that a NULL return may mean that the tuple is to be inserted into either the lower or upper page, to be determined by btr_page_tuple_smaller(). btr_page_split_and_insert(): When btr_page_get_split_rec() returns NULL, invoke btr_page_tuple_smaller() to determine which half-page the tuple belongs to. Reviewed by Sunny Bains modified: storage/innodb_plugin/ChangeLog 2425@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog storage/innodb_plugin/btr/btr0btr.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0btr.c ------------------------------------------------------------ revno: 3412 revision-id: marko.makela@oracle.com-20100421102723-0i80uezbyu0ekj5d parent: marko.makela@oracle.com-20100421100029-mji6lmdgvuqh96qq committer: Marko M?kel? <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Wed 2010-04-21 13:27:23 +0300 message: dict_create_index_step(): Be strict about DYNAMIC and COMPRESSED tables. Bug #50495 is about REDUNDANT and COMPACT tables, after all. modified: mysql-test/suite/innodb_plugin/r/innodb-zip.result 2252@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb-zip.result mysql-test/suite/innodb_plugin/t/innodb-zip.test 2252@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb-zip.test storage/innodb_plugin/ChangeLog 2425@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog storage/innodb_plugin/dict/dict0crea.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fdict%2Fdict0crea.c ------------------------------------------------------------ revno: 3411 revision-id: marko.makela@oracle.com-20100421100029-mji6lmdgvuqh96qq parent: marko.makela@oracle.com-20100421095033-0acvzxb8um8cms0a committer: Marko M?kel? <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Wed 2010-04-21 13:00:29 +0300 message: ha_innobase::add_index(): Only check for duplicate indexes when the data dictionary is locked. This fixes a UNIV_DEBUG assertion failure in innodb-index.test. modified: storage/innodb_plugin/handler/handler0alter.cc 1845@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fhandler%2Fhandler0alter.cc ------------------------------------------------------------ revno: 3410 revision-id: marko.makela@oracle.com-20100421095033-0acvzxb8um8cms0a parent: marko.makela@oracle.com-20100421094032-ir4glqk46qvg2ywn committer: Marko M?kel? <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Wed 2010-04-21 12:50:33 +0300 message: dtuple_convert_big_rec(): Store locally any fields whose maximum length is less than 256 bytes. (Bug #52745) Add related comments and debug assertions to the "offsets" functions in rem0rec.c. Approved by Sunny Bains modified: storage/innodb_plugin/ChangeLog 2425@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog storage/innodb_plugin/data/data0data.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fdata%2Fdata0data.c storage/innodb_plugin/rem/rem0rec.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Frem%2Frem0rec.c ------------------------------------------------------------ revno: 3409 revision-id: marko.makela@oracle.com-20100421094032-ir4glqk46qvg2ywn parent: marko.makela@oracle.com-20100421091611-uu46iygmv5sizjru committer: Marko M?kel? <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Wed 2010-04-21 12:40:32 +0300 message: Adjust tests for the Bug #50495 fix. modified: mysql-test/suite/innodb_plugin/r/innodb-zip.result 2252@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb-zip.result mysql-test/suite/innodb_plugin/t/innodb-zip.test 2252@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb-zip.test mysql-test/suite/innodb_plugin/t/innodb_bug36169.test 2418@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb_bug36169.test ------------------------------------------------------------ revno: 3408 revision-id: marko.makela@oracle.com-20100421091611-uu46iygmv5sizjru parent: marko.makela@oracle.com-20100421063916-h3gwjea7jzjilyww committer: Marko M?kel? <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Wed 2010-04-21 12:16:11 +0300 message: rec_convert_dtuple_to_rec(): Correct the debug check. The "extern" accessor functions return zero or nonzero, not 0 or 1. modified: storage/innodb_plugin/rem/rem0rec.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Frem%2Frem0rec.c ------------------------------------------------------------ revno: 3407 revision-id: marko.makela@oracle.com-20100421063916-h3gwjea7jzjilyww parent: marko.makela@oracle.com-20100420201550-cax1xywvlcdshgfg committer: Marko M?kel? <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Wed 2010-04-21 09:39:16 +0300 message: rec_convert_dtuple_to_rec(): Add a debug check. modified: storage/innodb_plugin/rem/rem0rec.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Frem%2Frem0rec.c ------------------------------------------------------------ revno: 3406 revision-id: marko.makela@oracle.com-20100420201550-cax1xywvlcdshgfg parent: marko.makela@oracle.com-20100420114222-diq7h2hiom9ww6me committer: Marko Makela <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Tue 2010-04-20 23:15:50 +0300 message: btr_cur_optimistic_insert(): Remove unused variable "heap". modified: storage/innodb_plugin/btr/btr0cur.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0cur.c ------------------------------------------------------------ revno: 3405 revision-id: marko.makela@oracle.com-20100420114222-diq7h2hiom9ww6me parent: marko.makela@oracle.com-20100420082908-tpako8jd4imkh1xb committer: Marko Makela <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Tue 2010-04-20 14:42:22 +0300 message: dict_create_index_step(): Invoke dict_index_add_to_cache() in strict mode only if innodb_strict_mode is set. (Bug #50495) trx_is_strict(): New function, for checking innodb_strict_mode. modified: storage/innodb_plugin/ChangeLog 2425@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog storage/innodb_plugin/dict/dict0crea.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fdict%2Fdict0crea.c storage/innodb_plugin/handler/ha_innodb.cc 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fhandler%2Fha_innodb.cc storage/innodb_plugin/include/trx0trx.h 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0trx.h ------------------------------------------------------------ revno: 3404 revision-id: marko.makela@oracle.com-20100420082908-tpako8jd4imkh1xb parent: marko.makela@oracle.com-20100419103603-u5pz4qc6hfhx4nua committer: Marko M?kel? <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Tue 2010-04-20 11:29:08 +0300 message: Implement UNIV_BTR_AVOID_COPY, an optimization of page splits. modified: storage/innodb_plugin/ChangeLog 2425@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog storage/innodb_plugin/btr/btr0btr.c 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0btr.c storage/innodb_plugin/include/univ.i 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Funiv.i ------------------------------------------------------------ revno: 3403 revision-id: marko.makela@oracle.com-20100419103603-u5pz4qc6hfhx4nua parent: marko.makela@oracle.com-20100419094405-fd3xwadullishv07 committer: Marko =?ISO-8859-1?Q?M=E4kel=E4?= <marko.makela@oracle.com> branch nick: 5.1-innodb timestamp: Mon 2010-04-19 13:36:03 +0300 message: Enable UNIV_DEBUG_VALGRIND when HAVE_purify is set. modified: storage/innobase/include/univ.i 2@cee13dc7-1704-0410-992b-c9b4543f1246:trunk%2Finclude%2Funiv.i storage/innodb_plugin/include/univ.i 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Funiv.i
469 lines
13 KiB
C
469 lines
13 KiB
C
/*****************************************************************************
|
|
|
|
Copyright (c) 1996, 2010, 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 dict/dict0boot.c
|
|
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"
|
|
|
|
/**********************************************************************//**
|
|
Gets a pointer to the dictionary header and x-latches its page.
|
|
@return pointer to the dictionary header, page x-latched */
|
|
UNIV_INTERN
|
|
dict_hdr_t*
|
|
dict_hdr_get(
|
|
/*=========*/
|
|
mtr_t* mtr) /*!< in: mtr */
|
|
{
|
|
buf_block_t* block;
|
|
dict_hdr_t* header;
|
|
|
|
block = buf_page_get(DICT_HDR_SPACE, 0, DICT_HDR_PAGE_NO,
|
|
RW_X_LATCH, mtr);
|
|
header = DICT_HDR + buf_block_get_frame(block);
|
|
|
|
buf_block_dbg_add_level(block, SYNC_DICT_HEADER);
|
|
|
|
return(header);
|
|
}
|
|
|
|
/**********************************************************************//**
|
|
Returns a new table, index, or tree id.
|
|
@return the new id */
|
|
UNIV_INTERN
|
|
dulint
|
|
dict_hdr_get_new_id(
|
|
/*================*/
|
|
ulint type) /*!< in: DICT_HDR_ROW_ID, ... */
|
|
{
|
|
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);
|
|
|
|
mlog_write_dulint(dict_hdr + type, id, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
return(id);
|
|
}
|
|
|
|
/**********************************************************************//**
|
|
Writes the current value of the row id counter to the dictionary header file
|
|
page. */
|
|
UNIV_INTERN
|
|
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);
|
|
|
|
mlog_write_dulint(dict_hdr + DICT_HDR_ROW_ID, id, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
}
|
|
|
|
/*****************************************************************//**
|
|
Creates the file page for the dictionary header. This function is
|
|
called only at the database creation.
|
|
@return TRUE if succeed */
|
|
static
|
|
ibool
|
|
dict_hdr_create(
|
|
/*============*/
|
|
mtr_t* mtr) /*!< in: mtr */
|
|
{
|
|
buf_block_t* block;
|
|
dict_hdr_t* dict_header;
|
|
ulint root_page_no;
|
|
|
|
ut_ad(mtr);
|
|
|
|
/* Create the dictionary header file block in a new, allocated file
|
|
segment in the system tablespace */
|
|
block = fseg_create(DICT_HDR_SPACE, 0,
|
|
DICT_HDR + DICT_HDR_FSEG_HEADER, mtr);
|
|
|
|
ut_a(DICT_HDR_PAGE_NO == buf_block_get_page_no(block));
|
|
|
|
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,
|
|
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
|
|
|
|
mlog_write_dulint(dict_header + DICT_HDR_TABLE_ID,
|
|
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
|
|
|
|
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);
|
|
|
|
/* Create the B-tree roots for the clustered indexes of the basic
|
|
system tables */
|
|
|
|
/*--------------------------*/
|
|
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
|
|
DICT_HDR_SPACE, 0, DICT_TABLES_ID,
|
|
dict_ind_redundant, mtr);
|
|
if (root_page_no == FIL_NULL) {
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
mlog_write_ulint(dict_header + DICT_HDR_TABLES, root_page_no,
|
|
MLOG_4BYTES, mtr);
|
|
/*--------------------------*/
|
|
root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE, 0,
|
|
DICT_TABLE_IDS_ID,
|
|
dict_ind_redundant, mtr);
|
|
if (root_page_no == FIL_NULL) {
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
mlog_write_ulint(dict_header + DICT_HDR_TABLE_IDS, root_page_no,
|
|
MLOG_4BYTES, mtr);
|
|
/*--------------------------*/
|
|
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
|
|
DICT_HDR_SPACE, 0, DICT_COLUMNS_ID,
|
|
dict_ind_redundant, mtr);
|
|
if (root_page_no == FIL_NULL) {
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
mlog_write_ulint(dict_header + DICT_HDR_COLUMNS, root_page_no,
|
|
MLOG_4BYTES, mtr);
|
|
/*--------------------------*/
|
|
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
|
|
DICT_HDR_SPACE, 0, DICT_INDEXES_ID,
|
|
dict_ind_redundant, mtr);
|
|
if (root_page_no == FIL_NULL) {
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
mlog_write_ulint(dict_header + DICT_HDR_INDEXES, root_page_no,
|
|
MLOG_4BYTES, mtr);
|
|
/*--------------------------*/
|
|
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
|
|
DICT_HDR_SPACE, 0, DICT_FIELDS_ID,
|
|
dict_ind_redundant, mtr);
|
|
if (root_page_no == FIL_NULL) {
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
mlog_write_ulint(dict_header + DICT_HDR_FIELDS, root_page_no,
|
|
MLOG_4BYTES, mtr);
|
|
/*--------------------------*/
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
/*****************************************************************//**
|
|
Initializes the data dictionary memory structures when the database is
|
|
started. This function is also called when the data dictionary is created. */
|
|
UNIV_INTERN
|
|
void
|
|
dict_boot(void)
|
|
/*===========*/
|
|
{
|
|
dict_table_t* table;
|
|
dict_index_t* index;
|
|
dict_hdr_t* dict_hdr;
|
|
mem_heap_t* heap;
|
|
mtr_t mtr;
|
|
ulint error;
|
|
|
|
mtr_start(&mtr);
|
|
|
|
/* Create the hash tables etc. */
|
|
dict_init();
|
|
|
|
heap = mem_heap_create(450);
|
|
|
|
mutex_enter(&(dict_sys->mutex));
|
|
|
|
/* 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. */
|
|
|
|
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);
|
|
|
|
/* Insert into the dictionary cache the descriptions of the basic
|
|
system tables */
|
|
/*-------------------------*/
|
|
table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 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);
|
|
/* ROW_FORMAT = (N_COLS >> 31) ? COMPACT : REDUNDANT */
|
|
dict_mem_table_add_col(table, heap, "N_COLS", DATA_INT, 0, 4);
|
|
/* TYPE is either DICT_TABLE_ORDINARY, or (TYPE & DICT_TF_COMPACT)
|
|
and (TYPE & DICT_TF_FORMAT_MASK) are nonzero and TYPE = table->flags */
|
|
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);
|
|
/* MIX_LEN may contain additional table flags when
|
|
ROW_FORMAT!=REDUNDANT. Currently, these flags include
|
|
DICT_TF2_TEMPORARY. */
|
|
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);
|
|
|
|
table->id = DICT_TABLES_ID;
|
|
|
|
dict_table_add_to_cache(table, heap);
|
|
dict_sys->sys_tables = table;
|
|
mem_heap_empty(heap);
|
|
|
|
index = dict_mem_index_create("SYS_TABLES", "CLUST_IND",
|
|
DICT_HDR_SPACE,
|
|
DICT_UNIQUE | DICT_CLUSTERED, 1);
|
|
|
|
dict_mem_index_add_field(index, "NAME", 0);
|
|
|
|
index->id = DICT_TABLES_ID;
|
|
|
|
error = dict_index_add_to_cache(table, index,
|
|
mtr_read_ulint(dict_hdr
|
|
+ DICT_HDR_TABLES,
|
|
MLOG_4BYTES, &mtr),
|
|
FALSE);
|
|
ut_a(error == DB_SUCCESS);
|
|
|
|
/*-------------------------*/
|
|
index = dict_mem_index_create("SYS_TABLES", "ID_IND",
|
|
DICT_HDR_SPACE, DICT_UNIQUE, 1);
|
|
dict_mem_index_add_field(index, "ID", 0);
|
|
|
|
index->id = DICT_TABLE_IDS_ID;
|
|
error = dict_index_add_to_cache(table, index,
|
|
mtr_read_ulint(dict_hdr
|
|
+ DICT_HDR_TABLE_IDS,
|
|
MLOG_4BYTES, &mtr),
|
|
FALSE);
|
|
ut_a(error == DB_SUCCESS);
|
|
|
|
/*-------------------------*/
|
|
table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 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);
|
|
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);
|
|
|
|
table->id = DICT_COLUMNS_ID;
|
|
|
|
dict_table_add_to_cache(table, heap);
|
|
dict_sys->sys_columns = table;
|
|
mem_heap_empty(heap);
|
|
|
|
index = dict_mem_index_create("SYS_COLUMNS", "CLUST_IND",
|
|
DICT_HDR_SPACE,
|
|
DICT_UNIQUE | DICT_CLUSTERED, 2);
|
|
|
|
dict_mem_index_add_field(index, "TABLE_ID", 0);
|
|
dict_mem_index_add_field(index, "POS", 0);
|
|
|
|
index->id = DICT_COLUMNS_ID;
|
|
error = dict_index_add_to_cache(table, index,
|
|
mtr_read_ulint(dict_hdr
|
|
+ DICT_HDR_COLUMNS,
|
|
MLOG_4BYTES, &mtr),
|
|
FALSE);
|
|
ut_a(error == DB_SUCCESS);
|
|
|
|
/*-------------------------*/
|
|
table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 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);
|
|
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);
|
|
|
|
/* The '+ 2' below comes from the fields DB_TRX_ID, DB_ROLL_PTR */
|
|
#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
|
|
#if DICT_SYS_INDEXES_NAME_FIELD != 2 + 2
|
|
#error "DICT_SYS_INDEXES_NAME_FIELD != 2 + 2"
|
|
#endif
|
|
|
|
table->id = DICT_INDEXES_ID;
|
|
dict_table_add_to_cache(table, heap);
|
|
dict_sys->sys_indexes = table;
|
|
mem_heap_empty(heap);
|
|
|
|
index = dict_mem_index_create("SYS_INDEXES", "CLUST_IND",
|
|
DICT_HDR_SPACE,
|
|
DICT_UNIQUE | DICT_CLUSTERED, 2);
|
|
|
|
dict_mem_index_add_field(index, "TABLE_ID", 0);
|
|
dict_mem_index_add_field(index, "ID", 0);
|
|
|
|
index->id = DICT_INDEXES_ID;
|
|
error = dict_index_add_to_cache(table, index,
|
|
mtr_read_ulint(dict_hdr
|
|
+ DICT_HDR_INDEXES,
|
|
MLOG_4BYTES, &mtr),
|
|
FALSE);
|
|
ut_a(error == DB_SUCCESS);
|
|
|
|
/*-------------------------*/
|
|
table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 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);
|
|
dict_mem_table_add_col(table, heap, "COL_NAME", DATA_BINARY, 0, 0);
|
|
|
|
table->id = DICT_FIELDS_ID;
|
|
dict_table_add_to_cache(table, heap);
|
|
dict_sys->sys_fields = table;
|
|
mem_heap_free(heap);
|
|
|
|
index = dict_mem_index_create("SYS_FIELDS", "CLUST_IND",
|
|
DICT_HDR_SPACE,
|
|
DICT_UNIQUE | DICT_CLUSTERED, 2);
|
|
|
|
dict_mem_index_add_field(index, "INDEX_ID", 0);
|
|
dict_mem_index_add_field(index, "POS", 0);
|
|
|
|
index->id = DICT_FIELDS_ID;
|
|
error = dict_index_add_to_cache(table, index,
|
|
mtr_read_ulint(dict_hdr
|
|
+ DICT_HDR_FIELDS,
|
|
MLOG_4BYTES, &mtr),
|
|
FALSE);
|
|
ut_a(error == DB_SUCCESS);
|
|
|
|
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);
|
|
|
|
mutex_exit(&(dict_sys->mutex));
|
|
}
|
|
|
|
/*****************************************************************//**
|
|
Inserts the basic system table data into themselves in the database
|
|
creation. */
|
|
static
|
|
void
|
|
dict_insert_initial_data(void)
|
|
/*==========================*/
|
|
{
|
|
/* Does nothing yet */
|
|
}
|
|
|
|
/*****************************************************************//**
|
|
Creates and initializes the data dictionary at the database creation. */
|
|
UNIV_INTERN
|
|
void
|
|
dict_create(void)
|
|
/*=============*/
|
|
{
|
|
mtr_t mtr;
|
|
|
|
mtr_start(&mtr);
|
|
|
|
dict_hdr_create(&mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
dict_boot();
|
|
|
|
dict_insert_initial_data();
|
|
}
|