| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 1996, 2014, 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/trx0rec.ic |
| 21 | Transaction undo log record |
| 22 | |
| 23 | Created 3/26/1996 Heikki Tuuri |
| 24 | *******************************************************/ |
| 25 | |
| 26 | /**********************************************************************//** |
| 27 | Reads from an undo log record the record type. |
| 28 | @return record type */ |
| 29 | UNIV_INLINE |
| 30 | ulint |
| 31 | trx_undo_rec_get_type( |
| 32 | /*==================*/ |
| 33 | const trx_undo_rec_t* undo_rec) /*!< in: undo log record */ |
| 34 | { |
| 35 | return(mach_read_from_1(undo_rec + 2) & (TRX_UNDO_CMPL_INFO_MULT - 1)); |
| 36 | } |
| 37 | |
| 38 | /**********************************************************************//** |
| 39 | Reads the undo log record number. |
| 40 | @return undo no */ |
| 41 | UNIV_INLINE |
| 42 | undo_no_t |
| 43 | trx_undo_rec_get_undo_no( |
| 44 | /*=====================*/ |
| 45 | const trx_undo_rec_t* undo_rec) /*!< in: undo log record */ |
| 46 | { |
| 47 | const byte* ptr; |
| 48 | |
| 49 | ptr = undo_rec + 3; |
| 50 | |
| 51 | return(mach_u64_read_much_compressed(ptr)); |
| 52 | } |
| 53 | |
| 54 | /***********************************************************************//** |
| 55 | Copies the undo record to the heap. |
| 56 | @return own: copy of undo log record */ |
| 57 | UNIV_INLINE |
| 58 | trx_undo_rec_t* |
| 59 | trx_undo_rec_copy( |
| 60 | /*==============*/ |
| 61 | const trx_undo_rec_t* undo_rec, /*!< in: undo log record */ |
| 62 | mem_heap_t* heap) /*!< in: heap where copied */ |
| 63 | { |
| 64 | ulint len; |
| 65 | |
| 66 | len = mach_read_from_2(undo_rec) |
| 67 | - ut_align_offset(undo_rec, srv_page_size); |
| 68 | ut_ad(len < srv_page_size); |
| 69 | trx_undo_rec_t* rec = static_cast<trx_undo_rec_t*>( |
| 70 | mem_heap_dup(heap, undo_rec, len)); |
| 71 | mach_write_to_2(rec, len); |
| 72 | return rec; |
| 73 | } |
| 74 | |