Debian Codegraph @

examples/c/ex_apprec/ex_apprec_template

raw
1 #include "db.h"
2
3 /*
4 * ex_apprec_mkdir_recover --
5 * Recovery function for mkdir.
6 *
7 * PUBLIC: int ex_apprec_mkdir_recover
8 * PUBLIC: __P((dbenv *, DBT *, DB_LSN *, db_recops));
9 */
10 int
11 ex_apprec_mkdir_recover(dbenv, dbtp, lsnp, op)
12 dbenv *dbenv;
13 DBT *dbtp;
14 DB_LSN *lsnp;
15 db_recops op;
16 {
17 ex_apprec_mkdir_args *argp;
18 int cmp_n, cmp_p, modified, ret;
19
20 #ifdef DEBUG_RECOVER
21 (void)ex_apprec_mkdir_print(dbenv, dbtp, lsnp, op);
22 #endif
23 argp = NULL;
24 if ((ret = ex_apprec_mkdir_read(dbenv, dbtp->data, &argp)) != 0)
25 goto out;
26
27 modified = 0;
28 cmp_n = 0;
29 cmp_p = 0;
30
31 /*
32 * The function now needs to calculate cmp_n and cmp_p based
33 * on whatever is in argp (usually an LSN representing the state
34 * of an object BEFORE the operation described in this record was
35 * applied) and whatever other information the function needs,
36 * e.g., the LSN of the object as it exists now.
37 *
38 * cmp_p should be set to 0 if the current state of the object
39 * is believed to be same as the state of the object BEFORE the
40 * described operation was applied. For example, if you had an
41 * LSN in the log record (argp->prevlsn) and a current LSN of the
42 * object (curlsn), you might want to do:
43 *
44 * cmp_p = log_compare(curlsn, argp->prevlsn);
45 *
46 * Similarly, cmp_n should be set to 0 if the current state
47 * of the object reflects the object AFTER this operation has
48 * been applied. Thus, if you can figure out an object's current
49 * LSN, yo might set cmp_n as:
50 *
51 * cmp_n = log_compare(lsnp, curlsn);
52 */
53 if (cmp_p == 0 && DB_REDO(op)) {
54 /* Need to redo update described. */
55 modified = 1;
56 } else if (cmp_n == 0 && !DB_REDO(op)) {
57 /* Need to undo update described. */
58 modified = 1;
59 }
60
61 /* Allow for following LSN pointers through a transaction. */
62 *lsnp = argp->prev_lsn;
63 ret = 0;
64
65 out: if (argp != NULL)
66 free(argp);
67
68 return (ret);
69 }
70