1/*****************************************************************************
2
3Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc.,
1551 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16
17*****************************************************************************/
18
19/**************************************************//**
20@file include/dict0boot.ic
21Data dictionary creation and booting
22
23Created 4/18/1996 Heikki Tuuri
24*******************************************************/
25
26/**********************************************************************//**
27Returns a new row id.
28@return the new id */
29UNIV_INLINE
30row_id_t
31dict_sys_get_new_row_id(void)
32/*=========================*/
33{
34 row_id_t id;
35
36 mutex_enter(&dict_sys->mutex);
37
38 id = dict_sys->row_id;
39
40 if (0 == (id % DICT_HDR_ROW_ID_WRITE_MARGIN)) {
41
42 dict_hdr_flush_row_id();
43 }
44
45 dict_sys->row_id++;
46
47 mutex_exit(&dict_sys->mutex);
48
49 return(id);
50}
51
52/**********************************************************************//**
53Reads a row id from a record or other 6-byte stored form.
54@return row id */
55UNIV_INLINE
56row_id_t
57dict_sys_read_row_id(
58/*=================*/
59 const byte* field) /*!< in: record field */
60{
61 compile_time_assert(DATA_ROW_ID_LEN == 6);
62 return(mach_read_from_6(field));
63}
64
65/**********************************************************************//**
66Writes a row id to a record or other 6-byte stored form. */
67UNIV_INLINE
68void
69dict_sys_write_row_id(
70/*==================*/
71 byte* field, /*!< in: record field */
72 row_id_t row_id) /*!< in: row id */
73{
74 compile_time_assert(DATA_ROW_ID_LEN == 6);
75 mach_write_to_6(field, row_id);
76}
77
78/*********************************************************************//**
79Check if a table id belongs to system table.
80@return true if the table id belongs to a system table. */
81UNIV_INLINE
82bool
83dict_is_sys_table(
84/*==============*/
85 table_id_t id) /*!< in: table id to check */
86{
87 return(id < DICT_HDR_FIRST_ID);
88}
89
90
91