Debian Codegraph @

storage/innobase/include/trx0rec.ic

raw
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/trx0rec.ic
29 Transaction undo log record
30
31 Created 3/26/1996 Heikki Tuuri
32 *******************************************************/
33
34 #ifndef UNIV_HOTBACKUP
35 /** Reads from an undo log record the record type.
36 @return record type */
37 static inline ulint trx_undo_rec_get_type(
38 const trx_undo_rec_t *undo_rec) /*!< in: undo log record */
39 {
40 return (mach_read_from_1(undo_rec + 2) & (TRX_UNDO_CMPL_INFO_MULT - 1));
41 }
42
43 /** Reads from an undo log record the record compiler info.
44 @return compiler info */
45 static inline ulint trx_undo_rec_get_cmpl_info(
46 const trx_undo_rec_t *undo_rec) /*!< in: undo log record */
47 {
48 return (mach_read_from_1(undo_rec + 2) / TRX_UNDO_CMPL_INFO_MULT);
49 }
50
51 /** Returns true if an undo log record contains an extern storage field.
52 @return true if extern */
53 static inline bool trx_undo_rec_get_extern_storage(
54 const trx_undo_rec_t *undo_rec) /*!< in: undo log record */
55 {
56 if (mach_read_from_1(undo_rec + 2) & TRX_UNDO_UPD_EXTERN) {
57 return true;
58 }
59
60 return false;
61 }
62
63 /** Reads the undo log record number.
64 @return undo no */
65 static inline undo_no_t trx_undo_rec_get_undo_no(
66 const trx_undo_rec_t *undo_rec) /*!< in: undo log record */
67 {
68 const byte *ptr = undo_rec + 2;
69 uint8_t type_cmpl = mach_read_from_1(ptr);
70
71 const bool blob_undo = type_cmpl & TRX_UNDO_MODIFY_BLOB;
72
73 if (blob_undo) {
74 /* The next record offset takes 2 bytes + 1 byte for
75 type_cmpl flag + 1 byte for the new flag. Total 4 bytes.*/
76 ptr = undo_rec + 4;
77 } else {
78 ptr = undo_rec + 3;
79 }
80 return (mach_u64_read_much_compressed(ptr));
81 }
82
83 static inline trx_undo_rec_t *trx_undo_rec_copy(const page_t *undo_page,
84 uint32_t undo_offset,
85 mem_heap_t *heap) {
86 ut_ad(undo_offset < UNIV_PAGE_SIZE);
87 trx_undo_rec_t *undo_rec = (trx_undo_rec_t *)(undo_page + undo_offset);
88
89 /* Read the offset of next undo record from the current undo record
90 and subtract it from current undo log record offset to get the length
91 of undo record */
92 uint32_t next_undo_offset = mach_read_from_2(undo_rec);
93 ut_a(next_undo_offset > undo_offset);
94
95 uint32_t len = next_undo_offset - undo_offset;
96 ut_ad(len < UNIV_PAGE_SIZE);
97 return ((trx_undo_rec_t *)mem_heap_dup(heap, undo_rec, len));
98 }
99 #endif /* !UNIV_HOTBACKUP */