~ken-vandine/+junk/mysql-3.23.58

« back to all changes in this revision

Viewing changes to bdb/dist/template/rec_log

  • Committer: Ken VanDine
  • Date: 2018-01-27 03:45:15 UTC
  • Revision ID: ken.vandine@canonical.com-20180127034515-wpgsf0e7g0dq3qhv
init

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "db_config.h"
 
2
 
 
3
#ifndef NO_SYSTEM_INCLUDES
 
4
#include <sys/types.h>
 
5
 
 
6
#include <string.h>
 
7
#endif
 
8
 
 
9
#include "db_int.h"
 
10
#include "db_page.h"
 
11
#include "log.h"
 
12
#include "log.h"
 
13
 
 
14
/*
 
15
 * __log_register1_recover --
 
16
 *      Recovery function for register1.
 
17
 *
 
18
 * PUBLIC: int __log_register1_recover
 
19
 * PUBLIC:   __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
 
20
 */
 
21
int
 
22
__log_register1_recover(dbenv, dbtp, lsnp, op, info)
 
23
        DB_ENV *dbenv;
 
24
        DBT *dbtp;
 
25
        DB_LSN *lsnp;
 
26
        db_recops op;
 
27
        void *info;
 
28
{
 
29
        __log_register1_args *argp;
 
30
        DB *file_dbp;
 
31
        DBC *dbc;
 
32
        DB_MPOOLFILE *mpf;
 
33
        PAGE *pagep;
 
34
        int cmp_n, cmp_p, modified, ret;
 
35
 
 
36
        REC_PRINT(__log_register1_print);
 
37
        REC_INTRO(__log_register1_read);
 
38
 
 
39
        if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0)
 
40
                if (DB_REDO(op)) {
 
41
                        if ((ret = memp_fget(mpf,
 
42
                            &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
 
43
                                goto out;
 
44
                } else {
 
45
                        *lsnp = argp->prev_lsn;
 
46
                        ret = 0;
 
47
                        goto out;
 
48
                }
 
49
 
 
50
        modified = 0;
 
51
        cmp_n = log_compare(lsnp, &LSN(pagep));
 
52
 
 
53
        /*
 
54
         * Use this when there is something like "pagelsn" in the argp
 
55
         * structure.  Sometimes, you might need to compare meta-data
 
56
         * lsn's instead.
 
57
         *
 
58
         * cmp_p = log_compare(&LSN(pagep), argp->pagelsn);
 
59
         */
 
60
        if (cmp_p == 0 && DB_REDO(op)) {
 
61
                /* Need to redo update described. */
 
62
                modified = 1;
 
63
        } else if (cmp_n == 0 && !DB_REDO(op)) {
 
64
                /* Need to undo update described. */
 
65
                modified = 1;
 
66
        }
 
67
        if (ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
 
68
                goto out;
 
69
 
 
70
        *lsnp = argp->prev_lsn;
 
71
        ret = 0;
 
72
 
 
73
out:    REC_CLOSE;
 
74
}
 
75
 
 
76
/*
 
77
 * __log_register_recover --
 
78
 *      Recovery function for register.
 
79
 *
 
80
 * PUBLIC: int __log_register_recover
 
81
 * PUBLIC:   __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
 
82
 */
 
83
int
 
84
__log_register_recover(dbenv, dbtp, lsnp, op, info)
 
85
        DB_ENV *dbenv;
 
86
        DBT *dbtp;
 
87
        DB_LSN *lsnp;
 
88
        db_recops op;
 
89
        void *info;
 
90
{
 
91
        __log_register_args *argp;
 
92
        DB *file_dbp;
 
93
        DBC *dbc;
 
94
        DB_MPOOLFILE *mpf;
 
95
        PAGE *pagep;
 
96
        int cmp_n, cmp_p, modified, ret;
 
97
 
 
98
        REC_PRINT(__log_register_print);
 
99
        REC_INTRO(__log_register_read);
 
100
 
 
101
        if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0)
 
102
                if (DB_REDO(op)) {
 
103
                        if ((ret = memp_fget(mpf,
 
104
                            &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
 
105
                                goto out;
 
106
                } else {
 
107
                        *lsnp = argp->prev_lsn;
 
108
                        ret = 0;
 
109
                        goto out;
 
110
                }
 
111
 
 
112
        modified = 0;
 
113
        cmp_n = log_compare(lsnp, &LSN(pagep));
 
114
 
 
115
        /*
 
116
         * Use this when there is something like "pagelsn" in the argp
 
117
         * structure.  Sometimes, you might need to compare meta-data
 
118
         * lsn's instead.
 
119
         *
 
120
         * cmp_p = log_compare(&LSN(pagep), argp->pagelsn);
 
121
         */
 
122
        if (cmp_p == 0 && DB_REDO(op)) {
 
123
                /* Need to redo update described. */
 
124
                modified = 1;
 
125
        } else if (cmp_n == 0 && !DB_REDO(op)) {
 
126
                /* Need to undo update described. */
 
127
                modified = 1;
 
128
        }
 
129
        if (ret = memp_fput(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
 
130
                goto out;
 
131
 
 
132
        *lsnp = argp->prev_lsn;
 
133
        ret = 0;
 
134
 
 
135
out:    REC_CLOSE;
 
136
}
 
137