| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 1996, 2026, Oracle and/or its affiliates. |
| 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, version 2.0, as published by the |
| 7 |
Free Software Foundation. |
| 8 |
|
| 9 |
This program is designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
|
| 26 |
*****************************************************************************/ |
| 27 |
|
| 28 |
/** @file include/dict0boot.ic |
| 29 |
Data dictionary creation and booting |
| 30 |
|
| 31 |
Created 4/18/1996 Heikki Tuuri |
| 32 |
*******************************************************/ |
| 33 |
|
| 34 |
/** Returns a new row id. |
| 35 |
@return the new id */ |
| 36 |
static inline row_id_t dict_sys_get_new_row_id(void) { |
| 37 |
row_id_t id; |
| 38 |
|
| 39 |
dict_sys_mutex_enter(); |
| 40 |
|
| 41 |
id = dict_sys->row_id; |
| 42 |
|
| 43 |
if (0 == (id % DICT_HDR_ROW_ID_WRITE_MARGIN)) { |
| 44 |
dict_hdr_flush_row_id(); |
| 45 |
} |
| 46 |
|
| 47 |
dict_sys->row_id++; |
| 48 |
|
| 49 |
dict_sys_mutex_exit(); |
| 50 |
|
| 51 |
return (id); |
| 52 |
} |
| 53 |
|
| 54 |
/** Reads a row id from a record or other 6-byte stored form. |
| 55 |
@return row id */ |
| 56 |
static inline row_id_t dict_sys_read_row_id( |
| 57 |
const byte *field) /*!< in: record field */ |
| 58 |
{ |
| 59 |
static_assert(DATA_ROW_ID_LEN == 6, "DATA_ROW_ID_LEN != 6"); |
| 60 |
|
| 61 |
return (mach_read_from_6(field)); |
| 62 |
} |
| 63 |
|
| 64 |
/** Writes a row id to a record or other 6-byte stored form. */ |
| 65 |
static inline void dict_sys_write_row_id(byte *field, /*!< in: record field */ |
| 66 |
row_id_t row_id) /*!< in: row id */ |
| 67 |
{ |
| 68 |
static_assert(DATA_ROW_ID_LEN == 6, "DATA_ROW_ID_LEN != 6"); |
| 69 |
|
| 70 |
mach_write_to_6(field, row_id); |
| 71 |
} |
| 72 |
|
| 73 |
/** Check if a table id belongs to old innodb internal system table. |
| 74 |
@param[in] id table id |
| 75 |
@return true if the table id belongs to a system table. */ |
| 76 |
static inline bool dict_is_old_sys_table(table_id_t id) { |
| 77 |
if (srv_is_upgrade_mode) { |
| 78 |
return (id < DICT_HDR_FIRST_ID); |
| 79 |
} |
| 80 |
return (false); |
| 81 |
} |