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