ma_key_recover.h 5.03 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/* Copyright (C) 2007 Michael Widenius

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

/*
  When we have finished the write/update/delete of a row, we have cleanups to
  do. For now it is signalling to Checkpoint that all dirtied pages have
  their rec_lsn set and page LSN set (_ma_unpin_all_pages() has been called),
  and that bitmap pages are correct (_ma_bitmap_release_unused() has been
  called).
*/

24 25 26 27 28 29 30 31 32 33 34 35 36 37
/* Struct for clr_end */

struct st_msg_to_write_hook_for_clr_end
{
  LSN previous_undo_lsn;
  enum translog_record_type undone_record_type;
  ha_checksum checksum_delta;
  void *extra_msg;
};

struct st_msg_to_write_hook_for_undo_key
{
  my_off_t *root;
  my_off_t value;
38
  uint keynr;
39
  ulonglong auto_increment;
40 41 42
};


43 44 45 46 47
/* Function definitions for some redo functions */

my_bool _ma_write_clr(MARIA_HA *info, LSN undo_lsn,
                      enum translog_record_type undo_type,
                      my_bool store_checksum, ha_checksum checksum,
48
                      LSN *res_lsn, void *extra_msg);
49
int _ma_write_undo_key_insert(MARIA_HA *info, const MARIA_KEY *key,
unknown's avatar
unknown committed
50 51
                              my_off_t *root, my_off_t new_root,
                              LSN *res_lsn);
52 53
my_bool _ma_write_undo_key_delete(MARIA_HA *info, const MARIA_KEY *key,
                                  my_off_t new_root, LSN *res_lsn);
54 55 56 57 58 59
my_bool write_hook_for_clr_end(enum translog_record_type type,
                               TRN *trn, MARIA_HA *tbl_info, LSN *lsn,
                               void *hook_arg);
extern my_bool write_hook_for_undo_key(enum translog_record_type type,
                                       TRN *trn, MARIA_HA *tbl_info,
                                       LSN *lsn, void *hook_arg);
60
extern my_bool write_hook_for_undo_key_insert(enum translog_record_type type,
61 62 63
                                              TRN *trn, MARIA_HA *tbl_info,
                                              LSN *lsn, void *hook_arg);
extern my_bool write_hook_for_undo_key_delete(enum translog_record_type type,
64 65
                                              TRN *trn, MARIA_HA *tbl_info,
                                              LSN *lsn, void *hook_arg);
66

67 68
my_bool _ma_log_prefix(MARIA_PAGE *page, uint changed_length, int move_length,
                       enum en_key_debug debug_marker);
69
my_bool _ma_log_suffix(MARIA_PAGE *page, uint org_length,
70
                       uint new_length);
71
my_bool _ma_log_add(MARIA_PAGE *page, uint buff_length, uchar *key_pos,
72 73
                    uint changed_length, int move_length,
                    my_bool handle_overflow);
74
my_bool _ma_log_delete(MARIA_PAGE *page, const uchar *key_pos,
75 76
                       uint changed_length, uint move_length,
                       uint append_length, enum en_key_debug debug_marker);
77 78
my_bool _ma_log_change(MARIA_PAGE *page, const uchar *key_pos, uint length,
                       enum en_key_debug debug_marker);
79
my_bool _ma_log_new(MARIA_PAGE *page, my_bool root_page);
80 81 82 83 84 85 86
#ifdef EXTRA_DEBUG_KEY_CHANGES
void _ma_log_key_changes(MARIA_PAGE *ma_page, LEX_CUSTRING *log_array,
                         uchar *log_pos, uint *changed_length,
                         uint *translog_parts);
#else
void _ma_log_key_changes(A,B,C,D,E)
#endif
87

88 89 90 91 92 93 94 95 96 97
uint _ma_apply_redo_index_new_page(MARIA_HA *info, LSN lsn,
                                   const uchar *header, uint length);
uint _ma_apply_redo_index_free_page(MARIA_HA *info, LSN lsn,
                                    const uchar *header);
uint _ma_apply_redo_index(MARIA_HA *info,
                          LSN lsn, const uchar *header, uint length);

my_bool _ma_apply_undo_key_insert(MARIA_HA *info, LSN undo_lsn,
                                  const uchar *header, uint length);
my_bool _ma_apply_undo_key_delete(MARIA_HA *info, LSN undo_lsn,
unknown's avatar
unknown committed
98 99
                                  const uchar *header, uint length,
                                  my_bool with_root);
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118

static inline void _ma_finalize_row(MARIA_HA *info)
{
  info->trn->rec_lsn= LSN_IMPOSSIBLE;
}

/* unpinning is often the last operation before finalizing */

static inline void _ma_unpin_all_pages_and_finalize_row(MARIA_HA *info,
                                                        LSN undo_lsn)
{
  _ma_unpin_all_pages(info, undo_lsn);
  _ma_finalize_row(info);
}

extern my_bool _ma_lock_key_del(MARIA_HA *info, my_bool insert_at_end);
extern void _ma_unlock_key_del(MARIA_HA *info);
static inline void _ma_fast_unlock_key_del(MARIA_HA *info)
{
119
  if (info->key_del_used)
120 121
    _ma_unlock_key_del(info);
}