1 /* Do not edit: automatically built by dist/db_gen.sh. */
4 #ifndef NO_SYSTEM_INCLUDES
15 #include "db_dispatch.h"
19 * PUBLIC: int __txn_regop_log
20 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
21 * PUBLIC: u_int32_t));
23 int __txn_regop_log(logp
, txnid
, ret_lsnp
, flags
,
32 DB_LSN
*lsnp
, null_lsn
;
33 u_int32_t rectype
, txn_num
;
37 rectype
= DB_txn_regop
;
38 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
44 lsnp
= &txnid
->last_lsn
;
45 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
47 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
51 memcpy(bp
, &rectype
, sizeof(rectype
));
52 bp
+= sizeof(rectype
);
53 memcpy(bp
, &txn_num
, sizeof(txn_num
));
54 bp
+= sizeof(txn_num
);
55 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
57 memcpy(bp
, &opcode
, sizeof(opcode
));
60 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
61 fprintf(stderr
, "Error in log record length");
63 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
65 txnid
->last_lsn
= *ret_lsnp
;
66 __db_free(logrec
.data
);
71 * PUBLIC: int __txn_regop_print
72 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
75 __txn_regop_print(notused1
, dbtp
, lsnp
, notused2
, notused3
)
82 __txn_regop_args
*argp
;
93 if ((ret
= __txn_regop_read(dbtp
->data
, &argp
)) != 0)
95 printf("[%lu][%lu]txn_regop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
99 (u_long
)argp
->txnid
->txnid
,
100 (u_long
)argp
->prev_lsn
.file
,
101 (u_long
)argp
->prev_lsn
.offset
);
102 printf("\topcode: %lu\n", (u_long
)argp
->opcode
);
109 * PUBLIC: int __txn_regop_read __P((void *, __txn_regop_args **));
112 __txn_regop_read(recbuf
, argpp
)
114 __txn_regop_args
**argpp
;
116 __txn_regop_args
*argp
;
119 argp
= (__txn_regop_args
*)__db_malloc(sizeof(__txn_regop_args
) +
123 argp
->txnid
= (DB_TXN
*)&argp
[1];
125 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
126 bp
+= sizeof(argp
->type
);
127 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
128 bp
+= sizeof(argp
->txnid
->txnid
);
129 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
130 bp
+= sizeof(DB_LSN
);
131 memcpy(&argp
->opcode
, bp
, sizeof(argp
->opcode
));
132 bp
+= sizeof(argp
->opcode
);
138 * PUBLIC: int __txn_ckp_log
139 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
140 * PUBLIC: DB_LSN *, DB_LSN *));
142 int __txn_ckp_log(logp
, txnid
, ret_lsnp
, flags
,
152 DB_LSN
*lsnp
, null_lsn
;
153 u_int32_t rectype
, txn_num
;
157 rectype
= DB_txn_ckp
;
158 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
164 lsnp
= &txnid
->last_lsn
;
165 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
168 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
172 memcpy(bp
, &rectype
, sizeof(rectype
));
173 bp
+= sizeof(rectype
);
174 memcpy(bp
, &txn_num
, sizeof(txn_num
));
175 bp
+= sizeof(txn_num
);
176 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
177 bp
+= sizeof(DB_LSN
);
179 memcpy(bp
, ckp_lsn
, sizeof(*ckp_lsn
));
181 memset(bp
, 0, sizeof(*ckp_lsn
));
182 bp
+= sizeof(*ckp_lsn
);
183 if (last_ckp
!= NULL
)
184 memcpy(bp
, last_ckp
, sizeof(*last_ckp
));
186 memset(bp
, 0, sizeof(*last_ckp
));
187 bp
+= sizeof(*last_ckp
);
189 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
190 fprintf(stderr
, "Error in log record length");
192 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
194 txnid
->last_lsn
= *ret_lsnp
;
195 __db_free(logrec
.data
);
200 * PUBLIC: int __txn_ckp_print
201 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
204 __txn_ckp_print(notused1
, dbtp
, lsnp
, notused2
, notused3
)
211 __txn_ckp_args
*argp
;
222 if ((ret
= __txn_ckp_read(dbtp
->data
, &argp
)) != 0)
224 printf("[%lu][%lu]txn_ckp: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
226 (u_long
)lsnp
->offset
,
228 (u_long
)argp
->txnid
->txnid
,
229 (u_long
)argp
->prev_lsn
.file
,
230 (u_long
)argp
->prev_lsn
.offset
);
231 printf("\tckp_lsn: [%lu][%lu]\n",
232 (u_long
)argp
->ckp_lsn
.file
, (u_long
)argp
->ckp_lsn
.offset
);
233 printf("\tlast_ckp: [%lu][%lu]\n",
234 (u_long
)argp
->last_ckp
.file
, (u_long
)argp
->last_ckp
.offset
);
241 * PUBLIC: int __txn_ckp_read __P((void *, __txn_ckp_args **));
244 __txn_ckp_read(recbuf
, argpp
)
246 __txn_ckp_args
**argpp
;
248 __txn_ckp_args
*argp
;
251 argp
= (__txn_ckp_args
*)__db_malloc(sizeof(__txn_ckp_args
) +
255 argp
->txnid
= (DB_TXN
*)&argp
[1];
257 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
258 bp
+= sizeof(argp
->type
);
259 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
260 bp
+= sizeof(argp
->txnid
->txnid
);
261 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
262 bp
+= sizeof(DB_LSN
);
263 memcpy(&argp
->ckp_lsn
, bp
, sizeof(argp
->ckp_lsn
));
264 bp
+= sizeof(argp
->ckp_lsn
);
265 memcpy(&argp
->last_ckp
, bp
, sizeof(argp
->last_ckp
));
266 bp
+= sizeof(argp
->last_ckp
);
272 * PUBLIC: int __txn_init_print __P((DB_ENV *));
275 __txn_init_print(dbenv
)
280 if ((ret
= __db_add_recovery(dbenv
,
281 __txn_regop_print
, DB_txn_regop
)) != 0)
283 if ((ret
= __db_add_recovery(dbenv
,
284 __txn_ckp_print
, DB_txn_ckp
)) != 0)
290 * PUBLIC: int __txn_init_recover __P((DB_ENV *));
293 __txn_init_recover(dbenv
)
298 if ((ret
= __db_add_recovery(dbenv
,
299 __txn_regop_recover
, DB_txn_regop
)) != 0)
301 if ((ret
= __db_add_recovery(dbenv
,
302 __txn_ckp_recover
, DB_txn_ckp
)) != 0)