1
/*****************************************************************************
3
Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
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.
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.
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., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/**************************************************//**
1
/******************************************************
21
2
Transaction undo log
23
6
Created 3/26/1996 Heikki Tuuri
24
7
*******************************************************/
93
75
of the list and release undo log segments. In stepping through the list,
94
76
s-latches on the undo log pages are enough, but in a truncate, x-latches must
95
77
be obtained on the rollback segment and individual pages. */
96
#endif /* !UNIV_HOTBACKUP */
98
/********************************************************************//**
79
/************************************************************************
99
80
Initializes the fields in an undo log segment page. */
102
83
trx_undo_page_init(
103
84
/*===============*/
104
page_t* undo_page, /*!< in: undo log segment page */
105
ulint type, /*!< in: undo log segment type */
106
mtr_t* mtr); /*!< in: mtr */
108
#ifndef UNIV_HOTBACKUP
109
/********************************************************************//**
110
Creates and initializes an undo log memory object.
111
@return own: the undo log memory object */
85
page_t* undo_page, /* in: undo log segment page */
86
ulint type, /* in: undo log segment type */
87
mtr_t* mtr); /* in: mtr */
88
/************************************************************************
89
Creates and initializes an undo log memory object. */
114
92
trx_undo_mem_create(
115
93
/*================*/
116
trx_rseg_t* rseg, /*!< in: rollback segment memory object */
117
ulint id, /*!< in: slot index within rseg */
118
ulint type, /*!< in: type of the log: TRX_UNDO_INSERT or
94
/* out, own: the undo log memory object */
95
trx_rseg_t* rseg, /* in: rollback segment memory object */
96
ulint id, /* in: slot index within rseg */
97
ulint type, /* in: type of the log: TRX_UNDO_INSERT or
119
98
TRX_UNDO_UPDATE */
120
trx_id_t trx_id, /*!< in: id of the trx for which the undo log
99
dulint trx_id, /* in: id of the trx for which the undo log
122
const XID* xid, /*!< in: X/Open XA transaction identification*/
123
ulint page_no,/*!< in: undo log header page number */
124
ulint offset);/*!< in: undo log header byte offset on page */
125
#endif /* !UNIV_HOTBACKUP */
126
/***************************************************************//**
101
const XID* xid, /* in: X/Open XA transaction identification*/
102
ulint page_no,/* in: undo log header page number */
103
ulint offset);/* in: undo log header byte offset on page */
104
/*******************************************************************
127
105
Initializes a cached insert undo log header page for new use. NOTE that this
128
106
function has its own log record type MLOG_UNDO_HDR_REUSE. You must NOT change
129
the operation of this function!
130
@return undo log header byte offset on page */
107
the operation of this function! */
133
110
trx_undo_insert_header_reuse(
134
111
/*=========================*/
135
page_t* undo_page, /*!< in/out: insert undo log segment
136
header page, x-latched */
137
trx_id_t trx_id, /*!< in: transaction id */
138
mtr_t* mtr); /*!< in: mtr */
139
/**********************************************************************//**
112
/* out: undo log header byte offset on page */
113
page_t* undo_page, /* in: insert undo log segment header page,
115
dulint trx_id, /* in: transaction id */
116
mtr_t* mtr); /* in: mtr */
117
/**************************************************************************
140
118
If an update undo log can be discarded immediately, this function frees the
141
119
space, resetting the page to the proper state for caching. */
144
122
trx_undo_discard_latest_update_undo(
145
123
/*================================*/
146
page_t* undo_page, /*!< in: header page of an undo log of size 1 */
147
mtr_t* mtr); /*!< in: mtr */
149
#ifndef UNIV_HOTBACKUP
150
/***********************************************************************//**
151
Gets the previous record in an undo log from the previous page.
152
@return undo log record, the page s-latched, NULL if none */
124
page_t* undo_page, /* in: header page of an undo log of size 1 */
125
mtr_t* mtr); /* in: mtr */
128
/***************************************************************************
129
Gets the previous record in an undo log from the previous page. */
155
132
trx_undo_get_prev_rec_from_prev_page(
156
133
/*=================================*/
157
trx_undo_rec_t* rec, /*!< in: undo record */
158
ulint page_no,/*!< in: undo log header page number */
159
ulint offset, /*!< in: undo log header offset on page */
160
mtr_t* mtr) /*!< in: mtr */
134
/* out: undo log record, the page s-latched,
136
trx_undo_rec_t* rec, /* in: undo record */
137
ulint page_no,/* in: undo log header page number */
138
ulint offset, /* in: undo log header offset on page */
139
mtr_t* mtr) /* in: mtr */
185
164
return(trx_undo_page_get_last_rec(prev_page, page_no, offset));
188
/***********************************************************************//**
189
Gets the previous record in an undo log.
190
@return undo log record, the page s-latched, NULL if none */
167
/***************************************************************************
168
Gets the previous record in an undo log. */
193
171
trx_undo_get_prev_rec(
194
172
/*==================*/
195
trx_undo_rec_t* rec, /*!< in: undo record */
196
ulint page_no,/*!< in: undo log header page number */
197
ulint offset, /*!< in: undo log header offset on page */
198
mtr_t* mtr) /*!< in: mtr */
173
/* out: undo log record, the page s-latched,
175
trx_undo_rec_t* rec, /* in: undo record */
176
ulint page_no,/* in: undo log header page number */
177
ulint offset, /* in: undo log header offset on page */
178
mtr_t* mtr) /* in: mtr */
200
180
trx_undo_rec_t* prev_rec;
216
/***********************************************************************//**
217
Gets the next record in an undo log from the next page.
218
@return undo log record, the page latched, NULL if none */
196
/***************************************************************************
197
Gets the next record in an undo log from the next page. */
221
200
trx_undo_get_next_rec_from_next_page(
222
201
/*=================================*/
223
ulint space, /*!< in: undo log header space */
224
ulint zip_size,/*!< in: compressed page size in bytes
202
/* out: undo log record, the page latched, NULL if
204
ulint space, /* in: undo log header space */
205
ulint zip_size,/* in: compressed page size in bytes
225
206
or 0 for uncompressed pages */
226
page_t* undo_page, /*!< in: undo log page */
227
ulint page_no,/*!< in: undo log header page number */
228
ulint offset, /*!< in: undo log header offset on page */
229
ulint mode, /*!< in: latch mode: RW_S_LATCH or RW_X_LATCH */
230
mtr_t* mtr) /*!< in: mtr */
207
page_t* undo_page, /* in: undo log page */
208
ulint page_no,/* in: undo log header page number */
209
ulint offset, /* in: undo log header offset on page */
210
ulint mode, /* in: latch mode: RW_S_LATCH or RW_X_LATCH */
211
mtr_t* mtr) /* in: mtr */
232
213
trx_ulogf_t* log_hdr;
233
214
ulint next_page_no;
265
246
return(trx_undo_page_get_first_rec(next_page, page_no, offset));
268
/***********************************************************************//**
269
Gets the next record in an undo log.
270
@return undo log record, the page s-latched, NULL if none */
249
/***************************************************************************
250
Gets the next record in an undo log. */
273
253
trx_undo_get_next_rec(
274
254
/*==================*/
275
trx_undo_rec_t* rec, /*!< in: undo record */
276
ulint page_no,/*!< in: undo log header page number */
277
ulint offset, /*!< in: undo log header offset on page */
278
mtr_t* mtr) /*!< in: mtr */
255
/* out: undo log record, the page s-latched,
257
trx_undo_rec_t* rec, /* in: undo record */
258
ulint page_no,/* in: undo log header page number */
259
ulint offset, /* in: undo log header offset on page */
260
mtr_t* mtr) /* in: mtr */
296
278
RW_S_LATCH, mtr));
299
/***********************************************************************//**
300
Gets the first record in an undo log.
301
@return undo log record, the page latched, NULL if none */
281
/***************************************************************************
282
Gets the first record in an undo log. */
304
285
trx_undo_get_first_rec(
305
286
/*===================*/
306
ulint space, /*!< in: undo log header space */
307
ulint zip_size,/*!< in: compressed page size in bytes
287
/* out: undo log record, the page latched, NULL if
289
ulint space, /* in: undo log header space */
290
ulint zip_size,/* in: compressed page size in bytes
308
291
or 0 for uncompressed pages */
309
ulint page_no,/*!< in: undo log header page number */
310
ulint offset, /*!< in: undo log header offset on page */
311
ulint mode, /*!< in: latching mode: RW_S_LATCH or RW_X_LATCH */
312
mtr_t* mtr) /*!< in: mtr */
292
ulint page_no,/* in: undo log header page number */
293
ulint offset, /* in: undo log header offset on page */
294
ulint mode, /* in: latching mode: RW_S_LATCH or RW_X_LATCH */
295
mtr_t* mtr) /* in: mtr */
314
297
page_t* undo_page;
315
298
trx_undo_rec_t* rec;
335
318
/*============== UNDO LOG FILE COPY CREATION AND FREEING ==================*/
337
/**********************************************************************//**
320
/**************************************************************************
338
321
Writes the mtr log entry of an undo log page initialization. */
341
324
trx_undo_page_init_log(
342
325
/*===================*/
343
page_t* undo_page, /*!< in: undo log page */
344
ulint type, /*!< in: undo log type */
345
mtr_t* mtr) /*!< in: mtr */
326
page_t* undo_page, /* in: undo log page */
327
ulint type, /* in: undo log type */
328
mtr_t* mtr) /* in: mtr */
347
330
mlog_write_initial_log_record(undo_page, MLOG_UNDO_INIT, mtr);
349
332
mlog_catenate_ulint_compressed(mtr, type);
351
#else /* !UNIV_HOTBACKUP */
352
# define trx_undo_page_init_log(undo_page,type,mtr) ((void) 0)
353
#endif /* !UNIV_HOTBACKUP */
355
/***********************************************************//**
356
Parses the redo log entry of an undo log page initialization.
357
@return end of log record or NULL */
335
/***************************************************************
336
Parses the redo log entry of an undo log page initialization. */
360
339
trx_undo_parse_page_init(
361
340
/*=====================*/
362
byte* ptr, /*!< in: buffer */
363
byte* end_ptr,/*!< in: buffer end */
364
page_t* page, /*!< in: page or NULL */
365
mtr_t* mtr) /*!< in: mtr or NULL */
341
/* out: end of log record or NULL */
342
byte* ptr, /* in: buffer */
343
byte* end_ptr,/* in: buffer end */
344
page_t* page, /* in: page or NULL */
345
mtr_t* mtr) /* in: mtr or NULL */
406
386
trx_undo_page_init_log(undo_page, type, mtr);
409
#ifndef UNIV_HOTBACKUP
410
/***************************************************************//**
411
Creates a new undo log segment in file.
412
@return DB_SUCCESS if page creation OK possible error codes are:
413
DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE */
389
/*******************************************************************
390
Creates a new undo log segment in file. */
416
393
trx_undo_seg_create(
417
394
/*================*/
418
trx_rseg_t* /*rseg*/,/*!< in: rollback segment */
419
trx_rsegf_t* rseg_hdr,/*!< in: rollback segment header, page
395
/* out: DB_SUCCESS if page creation OK
396
possible error codes are:
397
DB_TOO_MANY_CONCURRENT_TRXS
398
DB_OUT_OF_FILE_SPACE */
399
trx_rseg_t* rseg __attribute__((unused)),/* in: rollback segment */
400
trx_rsegf_t* rseg_hdr,/* in: rollback segment header, page
421
ulint type, /*!< in: type of the segment: TRX_UNDO_INSERT or
402
ulint type, /* in: type of the segment: TRX_UNDO_INSERT or
422
403
TRX_UNDO_UPDATE */
423
ulint* id, /*!< out: slot index within rseg header */
404
ulint* id, /* out: slot index within rseg header */
424
405
page_t** undo_page,
425
/*!< out: segment header page x-latched, NULL
406
/* out: segment header page x-latched, NULL
426
407
if there was an error */
427
mtr_t* mtr) /*!< in: mtr */
408
mtr_t* mtr) /* in: mtr */
506
/**********************************************************************//**
487
/**************************************************************************
507
488
Writes the mtr log entry of an undo log header initialization. */
510
491
trx_undo_header_create_log(
511
492
/*=======================*/
512
const page_t* undo_page, /*!< in: undo log header page */
513
trx_id_t trx_id, /*!< in: transaction id */
514
mtr_t* mtr) /*!< in: mtr */
493
page_t* undo_page, /* in: undo log header page */
494
dulint trx_id, /* in: transaction id */
495
mtr_t* mtr) /* in: mtr */
516
497
mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_CREATE, mtr);
518
mlog_catenate_ull_compressed(mtr, trx_id);
499
mlog_catenate_dulint_compressed(mtr, trx_id);
520
#else /* !UNIV_HOTBACKUP */
521
# define trx_undo_header_create_log(undo_page,trx_id,mtr) ((void) 0)
522
#endif /* !UNIV_HOTBACKUP */
524
/***************************************************************//**
502
/*******************************************************************
525
503
Creates a new undo log header in file. NOTE that this function has its own
526
504
log record type MLOG_UNDO_HDR_CREATE. You must NOT change the operation of
528
@return header byte offset on page */
531
508
trx_undo_header_create(
532
509
/*===================*/
533
page_t* undo_page, /*!< in/out: undo log segment
534
header page, x-latched; it is
535
assumed that there is
536
TRX_UNDO_LOG_XA_HDR_SIZE bytes
538
trx_id_t trx_id, /*!< in: transaction id */
539
mtr_t* mtr) /*!< in: mtr */
510
/* out: header byte offset on page */
511
page_t* undo_page, /* in: undo log segment header page,
512
x-latched; it is assumed that there are
513
TRX_UNDO_LOG_XA_HDR_SIZE bytes free space
515
dulint trx_id, /* in: transaction id */
516
mtr_t* mtr) /* in: mtr */
541
518
trx_upagef_t* page_hdr;
542
519
trx_usegf_t* seg_hdr;
675
651
MLOG_2BYTES, mtr);
678
/**********************************************************************//**
654
/**************************************************************************
679
655
Writes the mtr log entry of an undo log header reuse. */
682
658
trx_undo_insert_header_reuse_log(
683
659
/*=============================*/
684
const page_t* undo_page, /*!< in: undo log header page */
685
trx_id_t trx_id, /*!< in: transaction id */
686
mtr_t* mtr) /*!< in: mtr */
660
page_t* undo_page, /* in: undo log header page */
661
dulint trx_id, /* in: transaction id */
662
mtr_t* mtr) /* in: mtr */
688
664
mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_REUSE, mtr);
690
mlog_catenate_ull_compressed(mtr, trx_id);
666
mlog_catenate_dulint_compressed(mtr, trx_id);
692
#else /* !UNIV_HOTBACKUP */
693
# define trx_undo_insert_header_reuse_log(undo_page,trx_id,mtr) ((void) 0)
694
#endif /* !UNIV_HOTBACKUP */
696
/***********************************************************//**
697
Parses the redo log entry of an undo log page header create or reuse.
698
@return end of log record or NULL */
669
/***************************************************************
670
Parses the redo log entry of an undo log page header create or reuse. */
701
673
trx_undo_parse_page_header(
702
674
/*=======================*/
703
ulint type, /*!< in: MLOG_UNDO_HDR_CREATE or MLOG_UNDO_HDR_REUSE */
704
byte* ptr, /*!< in: buffer */
705
byte* end_ptr,/*!< in: buffer end */
706
page_t* page, /*!< in: page or NULL */
707
mtr_t* mtr) /*!< in: mtr or NULL */
675
/* out: end of log record or NULL */
676
ulint type, /* in: MLOG_UNDO_HDR_CREATE or MLOG_UNDO_HDR_REUSE */
677
byte* ptr, /* in: buffer */
678
byte* end_ptr,/* in: buffer end */
679
page_t* page, /* in: page or NULL */
680
mtr_t* mtr) /* in: mtr or NULL */
710
/* Silence a GCC warning about possibly uninitialized variable
711
when mach_ull_parse_compressed() is not inlined. */
713
/* Declare the variable uninitialized in Valgrind, so that the
714
above initialization will not mask any bugs. */
715
UNIV_MEM_INVALID(&trx_id, sizeof trx_id);
717
ptr = mach_ull_parse_compressed(ptr, end_ptr, &trx_id);
684
ptr = mach_dulint_parse_compressed(ptr, end_ptr, &trx_id);
719
686
if (ptr == NULL) {
736
/***************************************************************//**
703
/*******************************************************************
737
704
Initializes a cached insert undo log header page for new use. NOTE that this
738
705
function has its own log record type MLOG_UNDO_HDR_REUSE. You must NOT change
739
the operation of this function!
740
@return undo log header byte offset on page */
706
the operation of this function! */
743
709
trx_undo_insert_header_reuse(
744
710
/*=========================*/
745
page_t* undo_page, /*!< in/out: insert undo log segment
746
header page, x-latched */
747
trx_id_t trx_id, /*!< in: transaction id */
748
mtr_t* mtr) /*!< in: mtr */
711
/* out: undo log header byte offset on page */
712
page_t* undo_page, /* in: insert undo log segment header page,
714
dulint trx_id, /* in: transaction id */
715
mtr_t* mtr) /* in: mtr */
750
717
trx_upagef_t* page_hdr;
751
718
trx_usegf_t* seg_hdr;
796
#ifndef UNIV_HOTBACKUP
797
/**********************************************************************//**
763
/**************************************************************************
798
764
Writes the redo log entry of an update undo log header discard. */
801
767
trx_undo_discard_latest_log(
802
768
/*========================*/
803
page_t* undo_page, /*!< in: undo log header page */
804
mtr_t* mtr) /*!< in: mtr */
769
page_t* undo_page, /* in: undo log header page */
770
mtr_t* mtr) /* in: mtr */
806
772
mlog_write_initial_log_record(undo_page, MLOG_UNDO_HDR_DISCARD, mtr);
808
#else /* !UNIV_HOTBACKUP */
809
# define trx_undo_discard_latest_log(undo_page, mtr) ((void) 0)
810
#endif /* !UNIV_HOTBACKUP */
812
/***********************************************************//**
813
Parses the redo log entry of an undo log page header discard.
814
@return end of log record or NULL */
775
/***************************************************************
776
Parses the redo log entry of an undo log page header discard. */
817
779
trx_undo_parse_discard_latest(
818
780
/*==========================*/
819
byte* ptr, /*!< in: buffer */
820
byte* /*end_ptr*/, /*!< in: buffer end */
821
page_t* page, /*!< in: page or NULL */
822
mtr_t* mtr) /*!< in: mtr or NULL */
781
/* out: end of log record or NULL */
782
byte* ptr, /* in: buffer */
783
byte* end_ptr __attribute__((unused)), /* in: buffer end */
784
page_t* page, /* in: page or NULL */
785
mtr_t* mtr) /* in: mtr or NULL */
872
835
trx_undo_discard_latest_log(undo_page, mtr);
875
#ifndef UNIV_HOTBACKUP
876
/********************************************************************//**
877
Tries to add a page to the undo log segment where the undo log is placed.
878
@return page number if success, else FIL_NULL */
838
/************************************************************************
839
Tries to add a page to the undo log segment where the undo log is placed. */
881
842
trx_undo_add_page(
882
843
/*==============*/
883
trx_t* trx, /*!< in: transaction */
884
trx_undo_t* undo, /*!< in: undo log memory object */
885
mtr_t* mtr) /*!< in: mtr which does not have a latch to any
844
/* out: page number if success, else
846
trx_t* trx, /* in: transaction */
847
trx_undo_t* undo, /* in: undo log memory object */
848
mtr_t* mtr) /* in: mtr which does not have a latch to any
886
849
undo log page; the caller must have reserved
887
850
the rollback segment mutex */
946
/********************************************************************//**
947
Frees an undo log page that is not the header page.
948
@return last page number in remaining log */
909
/************************************************************************
910
Frees an undo log page that is not the header page. */
951
913
trx_undo_free_page(
952
914
/*===============*/
953
trx_rseg_t* rseg, /*!< in: rollback segment */
954
ibool in_history, /*!< in: TRUE if the undo log is in the history
915
/* out: last page number in remaining log */
916
trx_rseg_t* rseg, /* in: rollback segment */
917
ibool in_history, /* in: TRUE if the undo log is in the history
956
ulint space, /*!< in: space */
957
ulint hdr_page_no, /*!< in: header page number */
958
ulint page_no, /*!< in: page number to free: must not be the
919
ulint space, /* in: space */
920
ulint hdr_page_no, /* in: header page number */
921
ulint page_no, /* in: page number to free: must not be the
960
mtr_t* mtr) /*!< in: mtr which does not have a latch to any
923
mtr_t* mtr) /* in: mtr which does not have a latch to any
961
924
undo log page; the caller must have reserved
962
925
the rollback segment mutex */
1002
965
return(last_addr.page);
1005
/********************************************************************//**
968
/************************************************************************
1006
969
Frees an undo log page when there is also the memory object for the undo
1010
973
trx_undo_free_page_in_rollback(
1011
974
/*===========================*/
1012
trx_t* /*trx*/, /*!< in: transaction */
1013
trx_undo_t* undo, /*!< in: undo log memory copy */
1014
ulint page_no,/*!< in: page number to free: must not be the
975
trx_t* trx __attribute__((unused)), /* in: transaction */
976
trx_undo_t* undo, /* in: undo log memory copy */
977
ulint page_no,/* in: page number to free: must not be the
1016
mtr_t* mtr) /*!< in: mtr which does not have a latch to any
979
mtr_t* mtr) /* in: mtr which does not have a latch to any
1017
980
undo log page; the caller must have reserved
1018
981
the rollback segment mutex */
1032
/********************************************************************//**
995
/************************************************************************
1033
996
Empties an undo log header page of undo records for that undo log. Other
1034
997
undo logs may still have records on that page, if it is an update undo log. */
1037
1000
trx_undo_empty_header_page(
1038
1001
/*=======================*/
1039
ulint space, /*!< in: space */
1040
ulint zip_size, /*!< in: compressed page size in bytes
1002
ulint space, /* in: space */
1003
ulint zip_size, /* in: compressed page size in bytes
1041
1004
or 0 for uncompressed pages */
1042
ulint hdr_page_no, /*!< in: header page number */
1043
ulint hdr_offset, /*!< in: header offset */
1044
mtr_t* mtr) /*!< in: mtr */
1005
ulint hdr_page_no, /* in: header page number */
1006
ulint hdr_offset, /* in: header offset */
1007
mtr_t* mtr) /* in: mtr */
1046
1009
page_t* header_page;
1047
1010
trx_ulogf_t* log_hdr;
1056
1019
mlog_write_ulint(log_hdr + TRX_UNDO_LOG_START, end, MLOG_2BYTES, mtr);
1059
/***********************************************************************//**
1022
/***************************************************************************
1060
1023
Truncates an undo log from the end. This function is used during a rollback
1061
1024
to free space from an undo log. */
1064
1027
trx_undo_truncate_end(
1065
1028
/*==================*/
1066
trx_t* trx, /*!< in: transaction whose undo log it is */
1067
trx_undo_t* undo, /*!< in: undo log */
1068
undo_no_t limit) /*!< in: all undo records with undo number
1029
trx_t* trx, /* in: transaction whose undo log it is */
1030
trx_undo_t* undo, /* in: undo log */
1031
dulint limit) /* in: all undo records with undo number
1069
1032
>= this value should be truncated */
1071
1034
page_t* undo_page;
1072
1035
ulint last_page_no;
1073
1036
trx_undo_rec_t* rec;
1074
1037
trx_undo_rec_t* trunc_here;
1077
1041
ut_ad(mutex_own(&(trx->undo_mutex)));
1078
1042
ut_ad(mutex_own(&(trx->rseg->mutex)));
1081
1047
mtr_start(&mtr);
1127
1094
mtr_commit(&mtr);
1130
/***********************************************************************//**
1097
/***************************************************************************
1131
1098
Truncates an undo log from the start. This function is used during a purge
1135
1102
trx_undo_truncate_start(
1136
1103
/*====================*/
1137
trx_rseg_t* rseg, /*!< in: rollback segment */
1138
ulint space, /*!< in: space id of the log */
1139
ulint hdr_page_no, /*!< in: header page number */
1140
ulint hdr_offset, /*!< in: header offset on the page */
1141
undo_no_t limit) /*!< in: all undo pages with
1142
undo numbers < this value
1143
should be truncated; NOTE that
1144
the function only frees whole
1145
pages; the header page is not
1146
freed, but emptied, if all the
1147
records there are < limit */
1104
trx_rseg_t* rseg, /* in: rollback segment */
1105
ulint space, /* in: space id of the log */
1106
ulint hdr_page_no, /* in: header page number */
1107
ulint hdr_offset, /* in: header offset on the page */
1108
dulint limit) /* in: all undo pages with undo numbers <
1109
this value should be truncated; NOTE that
1110
the function only frees whole pages; the
1111
header page is not freed, but emptied, if
1112
all the records there are < limit */
1149
1114
page_t* undo_page;
1150
1115
trx_undo_rec_t* rec;
1249
1214
/*========== UNDO LOG MEMORY COPY INITIALIZATION =====================*/
1251
/********************************************************************//**
1216
/************************************************************************
1252
1217
Creates and initializes an undo log memory object according to the values
1253
1218
in the header in file, when the database is started. The memory object is
1254
inserted in the appropriate list of rseg.
1255
@return own: the undo log memory object */
1219
inserted in the appropriate list of rseg. */
1258
1222
trx_undo_mem_create_at_db_start(
1259
1223
/*============================*/
1260
trx_rseg_t* rseg, /*!< in: rollback segment memory object */
1261
ulint id, /*!< in: slot index within rseg */
1262
ulint page_no,/*!< in: undo log segment page number */
1263
mtr_t* mtr) /*!< in: mtr */
1224
/* out, own: the undo log memory object */
1225
trx_rseg_t* rseg, /* in: rollback segment memory object */
1226
ulint id, /* in: slot index within rseg */
1227
ulint page_no,/* in: undo log segment page number */
1228
mtr_t* mtr) /* in: mtr */
1265
1230
page_t* undo_page;
1266
1231
trx_upagef_t* page_header;
1433
/********************************************************************//**
1434
Creates and initializes an undo log memory object.
1435
@return own: the undo log memory object */
1399
/************************************************************************
1400
Creates and initializes an undo log memory object. */
1438
1403
trx_undo_mem_create(
1439
1404
/*================*/
1440
trx_rseg_t* rseg, /*!< in: rollback segment memory object */
1441
ulint id, /*!< in: slot index within rseg */
1442
ulint type, /*!< in: type of the log: TRX_UNDO_INSERT or
1405
/* out, own: the undo log memory object */
1406
trx_rseg_t* rseg, /* in: rollback segment memory object */
1407
ulint id, /* in: slot index within rseg */
1408
ulint type, /* in: type of the log: TRX_UNDO_INSERT or
1443
1409
TRX_UNDO_UPDATE */
1444
trx_id_t trx_id, /*!< in: id of the trx for which the undo log
1410
dulint trx_id, /* in: id of the trx for which the undo log
1446
const XID* xid, /*!< in: X/Open transaction identification */
1447
ulint page_no,/*!< in: undo log header page number */
1448
ulint offset) /*!< in: undo log header byte offset on page */
1412
const XID* xid, /* in: X/Open transaction identification */
1413
ulint page_no,/* in: undo log header page number */
1414
ulint offset) /* in: undo log header byte offset on page */
1450
1416
trx_undo_t* undo;
1492
/********************************************************************//**
1458
/************************************************************************
1493
1459
Initializes a cached undo log object for new use. */
1496
1462
trx_undo_mem_init_for_reuse(
1497
1463
/*========================*/
1498
trx_undo_t* undo, /*!< in: undo log to init */
1499
trx_id_t trx_id, /*!< in: id of the trx for which the undo log
1464
trx_undo_t* undo, /* in: undo log to init */
1465
dulint trx_id, /* in: id of the trx for which the undo log
1501
const XID* xid, /*!< in: X/Open XA transaction identification*/
1502
ulint offset) /*!< in: undo log header byte offset on page */
1467
const XID* xid, /* in: X/Open XA transaction identification*/
1468
ulint offset) /* in: undo log header byte offset on page */
1504
1470
ut_ad(mutex_own(&((undo->rseg)->mutex)));
1539
1505
mem_free(undo);
1542
/**********************************************************************//**
1543
Creates a new undo log.
1544
@return DB_SUCCESS if successful in creating the new undo lob object,
1545
possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS
1546
DB_OUT_OF_FILE_SPACE DB_OUT_OF_MEMORY */
1508
/**************************************************************************
1509
Creates a new undo log. */
1549
1512
trx_undo_create(
1550
1513
/*============*/
1551
trx_t* trx, /*!< in: transaction */
1552
trx_rseg_t* rseg, /*!< in: rollback segment memory copy */
1553
ulint type, /*!< in: type of the log: TRX_UNDO_INSERT or
1514
/* out: DB_SUCCESS if successful in creating
1515
the new undo lob object, possible error
1517
DB_TOO_MANY_CONCURRENT_TRXS
1518
DB_OUT_OF_FILE_SPACE
1520
trx_t* trx, /* in: transaction */
1521
trx_rseg_t* rseg, /* in: rollback segment memory copy */
1522
ulint type, /* in: type of the log: TRX_UNDO_INSERT or
1554
1523
TRX_UNDO_UPDATE */
1555
trx_id_t trx_id, /*!< in: id of the trx for which the undo log
1524
dulint trx_id, /* in: id of the trx for which the undo log
1557
const XID* xid, /*!< in: X/Open transaction identification*/
1558
trx_undo_t** undo, /*!< out: the new undo log object, undefined
1526
const XID* xid, /* in: X/Open transaction identification*/
1527
trx_undo_t** undo, /* out: the new undo log object, undefined
1559
1528
* if did not succeed */
1560
mtr_t* mtr) /*!< in: mtr */
1529
mtr_t* mtr) /* in: mtr */
1562
1531
trx_rsegf_t* rseg_header;
1611
1580
/*================ UNDO LOG ASSIGNMENT AND CLEANUP =====================*/
1613
/********************************************************************//**
1614
Reuses a cached undo log.
1615
@return the undo log memory object, NULL if none cached */
1582
/************************************************************************
1583
Reuses a cached undo log. */
1618
1586
trx_undo_reuse_cached(
1619
1587
/*==================*/
1620
trx_t* trx, /*!< in: transaction */
1621
trx_rseg_t* rseg, /*!< in: rollback segment memory object */
1622
ulint type, /*!< in: type of the log: TRX_UNDO_INSERT or
1588
/* out: the undo log memory object, NULL if
1590
trx_t* trx, /* in: transaction */
1591
trx_rseg_t* rseg, /* in: rollback segment memory object */
1592
ulint type, /* in: type of the log: TRX_UNDO_INSERT or
1623
1593
TRX_UNDO_UPDATE */
1624
trx_id_t trx_id, /*!< in: id of the trx for which the undo log
1594
dulint trx_id, /* in: id of the trx for which the undo log
1626
const XID* xid, /*!< in: X/Open XA transaction identification */
1627
mtr_t* mtr) /*!< in: mtr */
1596
const XID* xid, /* in: X/Open XA transaction identification */
1597
mtr_t* mtr) /* in: mtr */
1629
1599
trx_undo_t* undo;
1630
1600
page_t* undo_page;
1722
1692
+ TRX_UNDO_DICT_TRANS,
1723
1693
TRUE, MLOG_1BYTE, mtr);
1725
mlog_write_ull(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID,
1726
undo->table_id, mtr);
1695
mlog_write_dulint(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID,
1696
undo->table_id, mtr);
1728
1698
undo->dict_operation = TRUE;
1731
/**********************************************************************//**
1701
/**************************************************************************
1732
1702
Assigns an undo log for a transaction. A new undo log is created or a cached
1734
@return DB_SUCCESS if undo log assign successful, possible error codes
1735
are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE
1739
1706
trx_undo_assign_undo(
1740
1707
/*=================*/
1741
trx_t* trx, /*!< in: transaction */
1742
ulint type) /*!< in: TRX_UNDO_INSERT or TRX_UNDO_UPDATE */
1708
/* out: DB_SUCCESS if undo log assign
1709
successful, possible error codes are:
1710
DB_TOO_MANY_CONCURRENT_TRXS
1711
DB_OUT_OF_FILE_SPACE DB_OUT_OF_MEMORY*/
1712
trx_t* trx, /* in: transaction */
1713
ulint type) /* in: TRX_UNDO_INSERT or TRX_UNDO_UPDATE */
1744
1715
trx_rseg_t* rseg;
1745
1716
trx_undo_t* undo;
1794
/******************************************************************//**
1795
Sets the state of the undo log segment at a transaction finish.
1796
@return undo log segment header page, x-latched */
1765
/**********************************************************************
1766
Sets the state of the undo log segment at a transaction finish. */
1799
1769
trx_undo_set_state_at_finish(
1800
1770
/*=========================*/
1801
trx_undo_t* undo, /*!< in: undo log memory copy */
1802
mtr_t* mtr) /*!< in: mtr */
1771
/* out: undo log segment header page,
1773
trx_rseg_t* rseg, /* in: rollback segment memory object */
1774
trx_t* trx __attribute__((unused)), /* in: transaction */
1775
trx_undo_t* undo, /* in: undo log memory copy */
1776
mtr_t* mtr) /* in: mtr */
1804
1778
trx_usegf_t* seg_hdr;
1805
1779
trx_upagef_t* page_hdr;
1806
1780
page_t* undo_page;
1786
ut_ad(mutex_own(&rseg->mutex));
1812
1788
if (undo->id >= TRX_RSEG_N_SLOTS) {
1813
1789
fprintf(stderr, "InnoDB: Error: undo->id is %lu\n",
1842
1830
return(undo_page);
1845
/******************************************************************//**
1846
Sets the state of the undo log segment at a transaction prepare.
1847
@return undo log segment header page, x-latched */
1833
/**********************************************************************
1834
Sets the state of the undo log segment at a transaction prepare. */
1850
1837
trx_undo_set_state_at_prepare(
1851
1838
/*==========================*/
1852
trx_t* trx, /*!< in: transaction */
1853
trx_undo_t* undo, /*!< in: undo log memory copy */
1854
mtr_t* mtr) /*!< in: mtr */
1839
/* out: undo log segment header page,
1841
trx_t* trx, /* in: transaction */
1842
trx_undo_t* undo, /* in: undo log memory copy */
1843
mtr_t* mtr) /* in: mtr */
1856
1845
trx_usegf_t* seg_hdr;
1846
trx_upagef_t* page_hdr;
1857
1847
trx_ulogf_t* undo_header;
1858
1848
page_t* undo_page;