| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 2016, 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 | #ifndef _fil0fil_h_ |
| 28 | #define _fil0fil_h_ |
| 29 | |
| 30 | #include "fil0types.h" |
| 31 | #include "lot0types.h" |
| 32 | #include "mach0data.h" |
| 33 | |
| 34 | /** File space address */ |
| 35 | struct fil_addr_t { |
| 36 | fil_addr_t() : page(FIL_NULL), boffset(0) {} |
| 37 | fil_addr_t(page_no_t p, ulint off) : page(p), boffset(off) {} |
| 38 | |
| 39 | page_no_t page; /*!< page number within a space */ |
| 40 | ulint boffset; /*!< byte offset within the page */ |
| 41 | |
| 42 | bool is_equal(const fil_addr_t &that) const { |
| 43 | return ((page == that.page) && (boffset == that.boffset)); |
| 44 | } |
| 45 | |
| 46 | std::ostream &print(std::ostream &out) const { |
| 47 | out << "[fil_addr_t: page=" << page << ", boffset=" << boffset << "]"; |
| 48 | return (out); |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | inline std::ostream &operator<<(std::ostream &out, const fil_addr_t &obj) { |
| 53 | return (obj.print(out)); |
| 54 | } |
| 55 | |
| 56 | typedef byte fil_faddr_t; |
| 57 | |
| 58 | #define FIL_ADDR_PAGE 0 /* first in address is the page offset */ |
| 59 | #define FIL_ADDR_BYTE 4 /* then comes 2-byte byte offset within page*/ |
| 60 | #define FIL_ADDR_SIZE 6 /* address size is 6 bytes */ |
| 61 | |
| 62 | extern fil_addr_t fil_addr_null; |
| 63 | typedef uint16_t page_type_t; |
| 64 | |
| 65 | inline bool fil_addr_is_null(fil_addr_t addr) { |
| 66 | return (addr.page == FIL_NULL); |
| 67 | } |
| 68 | |
| 69 | /** Get the file page type. |
| 70 | @param[in] page file page |
| 71 | @return page type */ |
| 72 | inline page_type_t fil_page_get_type(const byte *page) { |
| 73 | return (static_cast<page_type_t>(mach_read_from_2(page + FIL_PAGE_TYPE))); |
| 74 | } |
| 75 | |
| 76 | #define FIL_PAGE_TYPE_LOB_INDEX 21 |
| 77 | #define FIL_PAGE_TYPE_LOB_DATA 22 |
| 78 | #define FIL_PAGE_TYPE_LOB_FIRST 23 |
| 79 | #define FIL_PAGE_TYPE_ZLOB_FIRST 24 |
| 80 | #define FIL_PAGE_TYPE_ZLOB_DATA 25 |
| 81 | |
| 82 | /** This page contains an array of z_index_entry_t objects. */ |
| 83 | #define FIL_PAGE_TYPE_ZLOB_INDEX 26 |
| 84 | #define FIL_PAGE_TYPE_ZLOB_FRAG 27 |
| 85 | #define FIL_PAGE_TYPE_ZLOB_FRAG_ENTRY 28 |
| 86 | |
| 87 | #endif // _fil0fil_h_ |