1 | /***************************************************************************** |
2 | |
3 | Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. |
4 | |
5 | This program is free software; you can redistribute it and/or modify it under |
6 | the terms of the GNU General Public License as published by the Free Software |
7 | Foundation; version 2 of the License. |
8 | |
9 | This program is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
11 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
12 | |
13 | You should have received a copy of the GNU General Public License along with |
14 | this program; if not, write to the Free Software Foundation, Inc., |
15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
16 | |
17 | *****************************************************************************/ |
18 | |
19 | /**************************************************//** |
20 | @file include/dict0boot.ic |
21 | Data dictionary creation and booting |
22 | |
23 | Created 4/18/1996 Heikki Tuuri |
24 | *******************************************************/ |
25 | |
26 | /**********************************************************************//** |
27 | Returns a new row id. |
28 | @return the new id */ |
29 | UNIV_INLINE |
30 | row_id_t |
31 | dict_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 | /**********************************************************************//** |
53 | Reads a row id from a record or other 6-byte stored form. |
54 | @return row id */ |
55 | UNIV_INLINE |
56 | row_id_t |
57 | dict_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 | /**********************************************************************//** |
66 | Writes a row id to a record or other 6-byte stored form. */ |
67 | UNIV_INLINE |
68 | void |
69 | dict_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 | /*********************************************************************//** |
79 | Check if a table id belongs to system table. |
80 | @return true if the table id belongs to a system table. */ |
81 | UNIV_INLINE |
82 | bool |
83 | dict_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 | |