1 /* Do not edit: automatically built by dist/db_gen.sh. */
4 #ifndef NO_SYSTEM_INCLUDES
15 #include "db_dispatch.h"
17 #include "common_ext.h"
20 * PUBLIC: int __db_addrem_log
21 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
22 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, u_int32_t,
23 * PUBLIC: size_t, const DBT *, const DBT *, DB_LSN *));
25 int __db_addrem_log(logp
, txnid
, ret_lsnp
, flags
,
26 opcode
, fileid
, pgno
, indx
, nbytes
, hdr
,
42 DB_LSN
*lsnp
, null_lsn
;
44 u_int32_t rectype
, txn_num
;
48 rectype
= DB_db_addrem
;
49 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
55 lsnp
= &txnid
->last_lsn
;
56 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
62 + sizeof(u_int32_t
) + (hdr
== NULL
? 0 : hdr
->size
)
63 + sizeof(u_int32_t
) + (dbt
== NULL
? 0 : dbt
->size
)
65 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
69 memcpy(bp
, &rectype
, sizeof(rectype
));
70 bp
+= sizeof(rectype
);
71 memcpy(bp
, &txn_num
, sizeof(txn_num
));
72 bp
+= sizeof(txn_num
);
73 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
75 memcpy(bp
, &opcode
, sizeof(opcode
));
77 memcpy(bp
, &fileid
, sizeof(fileid
));
79 memcpy(bp
, &pgno
, sizeof(pgno
));
81 memcpy(bp
, &indx
, sizeof(indx
));
83 memcpy(bp
, &nbytes
, sizeof(nbytes
));
87 memcpy(bp
, &zero
, sizeof(u_int32_t
));
88 bp
+= sizeof(u_int32_t
);
90 memcpy(bp
, &hdr
->size
, sizeof(hdr
->size
));
91 bp
+= sizeof(hdr
->size
);
92 memcpy(bp
, hdr
->data
, hdr
->size
);
97 memcpy(bp
, &zero
, sizeof(u_int32_t
));
98 bp
+= sizeof(u_int32_t
);
100 memcpy(bp
, &dbt
->size
, sizeof(dbt
->size
));
101 bp
+= sizeof(dbt
->size
);
102 memcpy(bp
, dbt
->data
, dbt
->size
);
106 memcpy(bp
, pagelsn
, sizeof(*pagelsn
));
108 memset(bp
, 0, sizeof(*pagelsn
));
109 bp
+= sizeof(*pagelsn
);
111 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
112 fprintf(stderr
, "Error in log record length");
114 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
116 txnid
->last_lsn
= *ret_lsnp
;
117 __db_free(logrec
.data
);
122 * PUBLIC: int __db_addrem_print
123 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
126 __db_addrem_print(notused1
, dbtp
, lsnp
, notused3
, notused4
)
133 __db_addrem_args
*argp
;
143 if ((ret
= __db_addrem_read(dbtp
->data
, &argp
)) != 0)
145 printf("[%lu][%lu]db_addrem: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
147 (u_long
)lsnp
->offset
,
149 (u_long
)argp
->txnid
->txnid
,
150 (u_long
)argp
->prev_lsn
.file
,
151 (u_long
)argp
->prev_lsn
.offset
);
152 printf("\topcode: %lu\n", (u_long
)argp
->opcode
);
153 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
154 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
155 printf("\tindx: %lu\n", (u_long
)argp
->indx
);
156 printf("\tnbytes: %lu\n", (u_long
)argp
->nbytes
);
158 for (i
= 0; i
< argp
->hdr
.size
; i
++) {
159 c
= ((char *)argp
->hdr
.data
)[i
];
160 if (isprint(c
) || c
== 0xa)
167 for (i
= 0; i
< argp
->dbt
.size
; i
++) {
168 c
= ((char *)argp
->dbt
.data
)[i
];
169 if (isprint(c
) || c
== 0xa)
175 printf("\tpagelsn: [%lu][%lu]\n",
176 (u_long
)argp
->pagelsn
.file
, (u_long
)argp
->pagelsn
.offset
);
183 * PUBLIC: int __db_addrem_read __P((void *, __db_addrem_args **));
186 __db_addrem_read(recbuf
, argpp
)
188 __db_addrem_args
**argpp
;
190 __db_addrem_args
*argp
;
193 argp
= (__db_addrem_args
*)__db_malloc(sizeof(__db_addrem_args
) +
197 argp
->txnid
= (DB_TXN
*)&argp
[1];
199 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
200 bp
+= sizeof(argp
->type
);
201 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
202 bp
+= sizeof(argp
->txnid
->txnid
);
203 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
204 bp
+= sizeof(DB_LSN
);
205 memcpy(&argp
->opcode
, bp
, sizeof(argp
->opcode
));
206 bp
+= sizeof(argp
->opcode
);
207 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
208 bp
+= sizeof(argp
->fileid
);
209 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
210 bp
+= sizeof(argp
->pgno
);
211 memcpy(&argp
->indx
, bp
, sizeof(argp
->indx
));
212 bp
+= sizeof(argp
->indx
);
213 memcpy(&argp
->nbytes
, bp
, sizeof(argp
->nbytes
));
214 bp
+= sizeof(argp
->nbytes
);
215 memcpy(&argp
->hdr
.size
, bp
, sizeof(u_int32_t
));
216 bp
+= sizeof(u_int32_t
);
218 bp
+= argp
->hdr
.size
;
219 memcpy(&argp
->dbt
.size
, bp
, sizeof(u_int32_t
));
220 bp
+= sizeof(u_int32_t
);
222 bp
+= argp
->dbt
.size
;
223 memcpy(&argp
->pagelsn
, bp
, sizeof(argp
->pagelsn
));
224 bp
+= sizeof(argp
->pagelsn
);
230 * PUBLIC: int __db_split_log
231 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
232 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, const DBT *,
233 * PUBLIC: DB_LSN *));
235 int __db_split_log(logp
, txnid
, ret_lsnp
, flags
,
236 opcode
, fileid
, pgno
, pageimage
, pagelsn
)
244 const DBT
*pageimage
;
248 DB_LSN
*lsnp
, null_lsn
;
250 u_int32_t rectype
, txn_num
;
254 rectype
= DB_db_split
;
255 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
261 lsnp
= &txnid
->last_lsn
;
262 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
266 + sizeof(u_int32_t
) + (pageimage
== NULL
? 0 : pageimage
->size
)
268 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
272 memcpy(bp
, &rectype
, sizeof(rectype
));
273 bp
+= sizeof(rectype
);
274 memcpy(bp
, &txn_num
, sizeof(txn_num
));
275 bp
+= sizeof(txn_num
);
276 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
277 bp
+= sizeof(DB_LSN
);
278 memcpy(bp
, &opcode
, sizeof(opcode
));
279 bp
+= sizeof(opcode
);
280 memcpy(bp
, &fileid
, sizeof(fileid
));
281 bp
+= sizeof(fileid
);
282 memcpy(bp
, &pgno
, sizeof(pgno
));
284 if (pageimage
== NULL
) {
286 memcpy(bp
, &zero
, sizeof(u_int32_t
));
287 bp
+= sizeof(u_int32_t
);
289 memcpy(bp
, &pageimage
->size
, sizeof(pageimage
->size
));
290 bp
+= sizeof(pageimage
->size
);
291 memcpy(bp
, pageimage
->data
, pageimage
->size
);
292 bp
+= pageimage
->size
;
295 memcpy(bp
, pagelsn
, sizeof(*pagelsn
));
297 memset(bp
, 0, sizeof(*pagelsn
));
298 bp
+= sizeof(*pagelsn
);
300 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
301 fprintf(stderr
, "Error in log record length");
303 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
305 txnid
->last_lsn
= *ret_lsnp
;
306 __db_free(logrec
.data
);
311 * PUBLIC: int __db_split_print
312 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
315 __db_split_print(notused1
, dbtp
, lsnp
, notused3
, notused4
)
322 __db_split_args
*argp
;
332 if ((ret
= __db_split_read(dbtp
->data
, &argp
)) != 0)
334 printf("[%lu][%lu]db_split: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
336 (u_long
)lsnp
->offset
,
338 (u_long
)argp
->txnid
->txnid
,
339 (u_long
)argp
->prev_lsn
.file
,
340 (u_long
)argp
->prev_lsn
.offset
);
341 printf("\topcode: %lu\n", (u_long
)argp
->opcode
);
342 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
343 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
344 printf("\tpageimage: ");
345 for (i
= 0; i
< argp
->pageimage
.size
; i
++) {
346 c
= ((char *)argp
->pageimage
.data
)[i
];
347 if (isprint(c
) || c
== 0xa)
353 printf("\tpagelsn: [%lu][%lu]\n",
354 (u_long
)argp
->pagelsn
.file
, (u_long
)argp
->pagelsn
.offset
);
361 * PUBLIC: int __db_split_read __P((void *, __db_split_args **));
364 __db_split_read(recbuf
, argpp
)
366 __db_split_args
**argpp
;
368 __db_split_args
*argp
;
371 argp
= (__db_split_args
*)__db_malloc(sizeof(__db_split_args
) +
375 argp
->txnid
= (DB_TXN
*)&argp
[1];
377 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
378 bp
+= sizeof(argp
->type
);
379 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
380 bp
+= sizeof(argp
->txnid
->txnid
);
381 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
382 bp
+= sizeof(DB_LSN
);
383 memcpy(&argp
->opcode
, bp
, sizeof(argp
->opcode
));
384 bp
+= sizeof(argp
->opcode
);
385 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
386 bp
+= sizeof(argp
->fileid
);
387 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
388 bp
+= sizeof(argp
->pgno
);
389 memcpy(&argp
->pageimage
.size
, bp
, sizeof(u_int32_t
));
390 bp
+= sizeof(u_int32_t
);
391 argp
->pageimage
.data
= bp
;
392 bp
+= argp
->pageimage
.size
;
393 memcpy(&argp
->pagelsn
, bp
, sizeof(argp
->pagelsn
));
394 bp
+= sizeof(argp
->pagelsn
);
400 * PUBLIC: int __db_big_log
401 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
402 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, db_pgno_t,
403 * PUBLIC: db_pgno_t, const DBT *, DB_LSN *, DB_LSN *,
404 * PUBLIC: DB_LSN *));
406 int __db_big_log(logp
, txnid
, ret_lsnp
, flags
,
407 opcode
, fileid
, pgno
, prev_pgno
, next_pgno
, dbt
,
408 pagelsn
, prevlsn
, nextlsn
)
424 DB_LSN
*lsnp
, null_lsn
;
426 u_int32_t rectype
, txn_num
;
431 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
437 lsnp
= &txnid
->last_lsn
;
438 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
444 + sizeof(u_int32_t
) + (dbt
== NULL
? 0 : dbt
->size
)
448 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
452 memcpy(bp
, &rectype
, sizeof(rectype
));
453 bp
+= sizeof(rectype
);
454 memcpy(bp
, &txn_num
, sizeof(txn_num
));
455 bp
+= sizeof(txn_num
);
456 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
457 bp
+= sizeof(DB_LSN
);
458 memcpy(bp
, &opcode
, sizeof(opcode
));
459 bp
+= sizeof(opcode
);
460 memcpy(bp
, &fileid
, sizeof(fileid
));
461 bp
+= sizeof(fileid
);
462 memcpy(bp
, &pgno
, sizeof(pgno
));
464 memcpy(bp
, &prev_pgno
, sizeof(prev_pgno
));
465 bp
+= sizeof(prev_pgno
);
466 memcpy(bp
, &next_pgno
, sizeof(next_pgno
));
467 bp
+= sizeof(next_pgno
);
470 memcpy(bp
, &zero
, sizeof(u_int32_t
));
471 bp
+= sizeof(u_int32_t
);
473 memcpy(bp
, &dbt
->size
, sizeof(dbt
->size
));
474 bp
+= sizeof(dbt
->size
);
475 memcpy(bp
, dbt
->data
, dbt
->size
);
479 memcpy(bp
, pagelsn
, sizeof(*pagelsn
));
481 memset(bp
, 0, sizeof(*pagelsn
));
482 bp
+= sizeof(*pagelsn
);
484 memcpy(bp
, prevlsn
, sizeof(*prevlsn
));
486 memset(bp
, 0, sizeof(*prevlsn
));
487 bp
+= sizeof(*prevlsn
);
489 memcpy(bp
, nextlsn
, sizeof(*nextlsn
));
491 memset(bp
, 0, sizeof(*nextlsn
));
492 bp
+= sizeof(*nextlsn
);
494 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
495 fprintf(stderr
, "Error in log record length");
497 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
499 txnid
->last_lsn
= *ret_lsnp
;
500 __db_free(logrec
.data
);
505 * PUBLIC: int __db_big_print
506 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
509 __db_big_print(notused1
, dbtp
, lsnp
, notused3
, notused4
)
526 if ((ret
= __db_big_read(dbtp
->data
, &argp
)) != 0)
528 printf("[%lu][%lu]db_big: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
530 (u_long
)lsnp
->offset
,
532 (u_long
)argp
->txnid
->txnid
,
533 (u_long
)argp
->prev_lsn
.file
,
534 (u_long
)argp
->prev_lsn
.offset
);
535 printf("\topcode: %lu\n", (u_long
)argp
->opcode
);
536 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
537 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
538 printf("\tprev_pgno: %lu\n", (u_long
)argp
->prev_pgno
);
539 printf("\tnext_pgno: %lu\n", (u_long
)argp
->next_pgno
);
541 for (i
= 0; i
< argp
->dbt
.size
; i
++) {
542 c
= ((char *)argp
->dbt
.data
)[i
];
543 if (isprint(c
) || c
== 0xa)
549 printf("\tpagelsn: [%lu][%lu]\n",
550 (u_long
)argp
->pagelsn
.file
, (u_long
)argp
->pagelsn
.offset
);
551 printf("\tprevlsn: [%lu][%lu]\n",
552 (u_long
)argp
->prevlsn
.file
, (u_long
)argp
->prevlsn
.offset
);
553 printf("\tnextlsn: [%lu][%lu]\n",
554 (u_long
)argp
->nextlsn
.file
, (u_long
)argp
->nextlsn
.offset
);
561 * PUBLIC: int __db_big_read __P((void *, __db_big_args **));
564 __db_big_read(recbuf
, argpp
)
566 __db_big_args
**argpp
;
571 argp
= (__db_big_args
*)__db_malloc(sizeof(__db_big_args
) +
575 argp
->txnid
= (DB_TXN
*)&argp
[1];
577 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
578 bp
+= sizeof(argp
->type
);
579 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
580 bp
+= sizeof(argp
->txnid
->txnid
);
581 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
582 bp
+= sizeof(DB_LSN
);
583 memcpy(&argp
->opcode
, bp
, sizeof(argp
->opcode
));
584 bp
+= sizeof(argp
->opcode
);
585 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
586 bp
+= sizeof(argp
->fileid
);
587 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
588 bp
+= sizeof(argp
->pgno
);
589 memcpy(&argp
->prev_pgno
, bp
, sizeof(argp
->prev_pgno
));
590 bp
+= sizeof(argp
->prev_pgno
);
591 memcpy(&argp
->next_pgno
, bp
, sizeof(argp
->next_pgno
));
592 bp
+= sizeof(argp
->next_pgno
);
593 memcpy(&argp
->dbt
.size
, bp
, sizeof(u_int32_t
));
594 bp
+= sizeof(u_int32_t
);
596 bp
+= argp
->dbt
.size
;
597 memcpy(&argp
->pagelsn
, bp
, sizeof(argp
->pagelsn
));
598 bp
+= sizeof(argp
->pagelsn
);
599 memcpy(&argp
->prevlsn
, bp
, sizeof(argp
->prevlsn
));
600 bp
+= sizeof(argp
->prevlsn
);
601 memcpy(&argp
->nextlsn
, bp
, sizeof(argp
->nextlsn
));
602 bp
+= sizeof(argp
->nextlsn
);
608 * PUBLIC: int __db_ovref_log
609 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
610 * PUBLIC: u_int32_t, db_pgno_t, int32_t, DB_LSN *));
612 int __db_ovref_log(logp
, txnid
, ret_lsnp
, flags
,
613 fileid
, pgno
, adjust
, lsn
)
624 DB_LSN
*lsnp
, null_lsn
;
625 u_int32_t rectype
, txn_num
;
629 rectype
= DB_db_ovref
;
630 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
636 lsnp
= &txnid
->last_lsn
;
637 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
642 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
646 memcpy(bp
, &rectype
, sizeof(rectype
));
647 bp
+= sizeof(rectype
);
648 memcpy(bp
, &txn_num
, sizeof(txn_num
));
649 bp
+= sizeof(txn_num
);
650 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
651 bp
+= sizeof(DB_LSN
);
652 memcpy(bp
, &fileid
, sizeof(fileid
));
653 bp
+= sizeof(fileid
);
654 memcpy(bp
, &pgno
, sizeof(pgno
));
656 memcpy(bp
, &adjust
, sizeof(adjust
));
657 bp
+= sizeof(adjust
);
659 memcpy(bp
, lsn
, sizeof(*lsn
));
661 memset(bp
, 0, sizeof(*lsn
));
664 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
665 fprintf(stderr
, "Error in log record length");
667 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
669 txnid
->last_lsn
= *ret_lsnp
;
670 __db_free(logrec
.data
);
675 * PUBLIC: int __db_ovref_print
676 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
679 __db_ovref_print(notused1
, dbtp
, lsnp
, notused3
, notused4
)
686 __db_ovref_args
*argp
;
696 if ((ret
= __db_ovref_read(dbtp
->data
, &argp
)) != 0)
698 printf("[%lu][%lu]db_ovref: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
700 (u_long
)lsnp
->offset
,
702 (u_long
)argp
->txnid
->txnid
,
703 (u_long
)argp
->prev_lsn
.file
,
704 (u_long
)argp
->prev_lsn
.offset
);
705 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
706 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
707 printf("\tadjust: %ld\n", (long)argp
->adjust
);
708 printf("\tlsn: [%lu][%lu]\n",
709 (u_long
)argp
->lsn
.file
, (u_long
)argp
->lsn
.offset
);
716 * PUBLIC: int __db_ovref_read __P((void *, __db_ovref_args **));
719 __db_ovref_read(recbuf
, argpp
)
721 __db_ovref_args
**argpp
;
723 __db_ovref_args
*argp
;
726 argp
= (__db_ovref_args
*)__db_malloc(sizeof(__db_ovref_args
) +
730 argp
->txnid
= (DB_TXN
*)&argp
[1];
732 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
733 bp
+= sizeof(argp
->type
);
734 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
735 bp
+= sizeof(argp
->txnid
->txnid
);
736 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
737 bp
+= sizeof(DB_LSN
);
738 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
739 bp
+= sizeof(argp
->fileid
);
740 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
741 bp
+= sizeof(argp
->pgno
);
742 memcpy(&argp
->adjust
, bp
, sizeof(argp
->adjust
));
743 bp
+= sizeof(argp
->adjust
);
744 memcpy(&argp
->lsn
, bp
, sizeof(argp
->lsn
));
745 bp
+= sizeof(argp
->lsn
);
751 * PUBLIC: int __db_relink_log
752 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
753 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t,
754 * PUBLIC: DB_LSN *, db_pgno_t, DB_LSN *));
756 int __db_relink_log(logp
, txnid
, ret_lsnp
, flags
,
757 fileid
, pgno
, lsn
, prev
, lsn_prev
, next
,
772 DB_LSN
*lsnp
, null_lsn
;
773 u_int32_t rectype
, txn_num
;
777 rectype
= DB_db_relink
;
778 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
784 lsnp
= &txnid
->last_lsn
;
785 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
793 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
797 memcpy(bp
, &rectype
, sizeof(rectype
));
798 bp
+= sizeof(rectype
);
799 memcpy(bp
, &txn_num
, sizeof(txn_num
));
800 bp
+= sizeof(txn_num
);
801 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
802 bp
+= sizeof(DB_LSN
);
803 memcpy(bp
, &fileid
, sizeof(fileid
));
804 bp
+= sizeof(fileid
);
805 memcpy(bp
, &pgno
, sizeof(pgno
));
808 memcpy(bp
, lsn
, sizeof(*lsn
));
810 memset(bp
, 0, sizeof(*lsn
));
812 memcpy(bp
, &prev
, sizeof(prev
));
814 if (lsn_prev
!= NULL
)
815 memcpy(bp
, lsn_prev
, sizeof(*lsn_prev
));
817 memset(bp
, 0, sizeof(*lsn_prev
));
818 bp
+= sizeof(*lsn_prev
);
819 memcpy(bp
, &next
, sizeof(next
));
821 if (lsn_next
!= NULL
)
822 memcpy(bp
, lsn_next
, sizeof(*lsn_next
));
824 memset(bp
, 0, sizeof(*lsn_next
));
825 bp
+= sizeof(*lsn_next
);
827 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
828 fprintf(stderr
, "Error in log record length");
830 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
832 txnid
->last_lsn
= *ret_lsnp
;
833 __db_free(logrec
.data
);
838 * PUBLIC: int __db_relink_print
839 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
842 __db_relink_print(notused1
, dbtp
, lsnp
, notused3
, notused4
)
849 __db_relink_args
*argp
;
859 if ((ret
= __db_relink_read(dbtp
->data
, &argp
)) != 0)
861 printf("[%lu][%lu]db_relink: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
863 (u_long
)lsnp
->offset
,
865 (u_long
)argp
->txnid
->txnid
,
866 (u_long
)argp
->prev_lsn
.file
,
867 (u_long
)argp
->prev_lsn
.offset
);
868 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
869 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
870 printf("\tlsn: [%lu][%lu]\n",
871 (u_long
)argp
->lsn
.file
, (u_long
)argp
->lsn
.offset
);
872 printf("\tprev: %lu\n", (u_long
)argp
->prev
);
873 printf("\tlsn_prev: [%lu][%lu]\n",
874 (u_long
)argp
->lsn_prev
.file
, (u_long
)argp
->lsn_prev
.offset
);
875 printf("\tnext: %lu\n", (u_long
)argp
->next
);
876 printf("\tlsn_next: [%lu][%lu]\n",
877 (u_long
)argp
->lsn_next
.file
, (u_long
)argp
->lsn_next
.offset
);
884 * PUBLIC: int __db_relink_read __P((void *, __db_relink_args **));
887 __db_relink_read(recbuf
, argpp
)
889 __db_relink_args
**argpp
;
891 __db_relink_args
*argp
;
894 argp
= (__db_relink_args
*)__db_malloc(sizeof(__db_relink_args
) +
898 argp
->txnid
= (DB_TXN
*)&argp
[1];
900 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
901 bp
+= sizeof(argp
->type
);
902 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
903 bp
+= sizeof(argp
->txnid
->txnid
);
904 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
905 bp
+= sizeof(DB_LSN
);
906 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
907 bp
+= sizeof(argp
->fileid
);
908 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
909 bp
+= sizeof(argp
->pgno
);
910 memcpy(&argp
->lsn
, bp
, sizeof(argp
->lsn
));
911 bp
+= sizeof(argp
->lsn
);
912 memcpy(&argp
->prev
, bp
, sizeof(argp
->prev
));
913 bp
+= sizeof(argp
->prev
);
914 memcpy(&argp
->lsn_prev
, bp
, sizeof(argp
->lsn_prev
));
915 bp
+= sizeof(argp
->lsn_prev
);
916 memcpy(&argp
->next
, bp
, sizeof(argp
->next
));
917 bp
+= sizeof(argp
->next
);
918 memcpy(&argp
->lsn_next
, bp
, sizeof(argp
->lsn_next
));
919 bp
+= sizeof(argp
->lsn_next
);
925 * PUBLIC: int __db_addpage_log
926 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
927 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t,
928 * PUBLIC: DB_LSN *));
930 int __db_addpage_log(logp
, txnid
, ret_lsnp
, flags
,
931 fileid
, pgno
, lsn
, nextpgno
, nextlsn
)
943 DB_LSN
*lsnp
, null_lsn
;
944 u_int32_t rectype
, txn_num
;
948 rectype
= DB_db_addpage
;
949 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
955 lsnp
= &txnid
->last_lsn
;
956 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
962 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
966 memcpy(bp
, &rectype
, sizeof(rectype
));
967 bp
+= sizeof(rectype
);
968 memcpy(bp
, &txn_num
, sizeof(txn_num
));
969 bp
+= sizeof(txn_num
);
970 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
971 bp
+= sizeof(DB_LSN
);
972 memcpy(bp
, &fileid
, sizeof(fileid
));
973 bp
+= sizeof(fileid
);
974 memcpy(bp
, &pgno
, sizeof(pgno
));
977 memcpy(bp
, lsn
, sizeof(*lsn
));
979 memset(bp
, 0, sizeof(*lsn
));
981 memcpy(bp
, &nextpgno
, sizeof(nextpgno
));
982 bp
+= sizeof(nextpgno
);
984 memcpy(bp
, nextlsn
, sizeof(*nextlsn
));
986 memset(bp
, 0, sizeof(*nextlsn
));
987 bp
+= sizeof(*nextlsn
);
989 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
990 fprintf(stderr
, "Error in log record length");
992 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
994 txnid
->last_lsn
= *ret_lsnp
;
995 __db_free(logrec
.data
);
1000 * PUBLIC: int __db_addpage_print
1001 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1004 __db_addpage_print(notused1
, dbtp
, lsnp
, notused3
, notused4
)
1011 __db_addpage_args
*argp
;
1021 if ((ret
= __db_addpage_read(dbtp
->data
, &argp
)) != 0)
1023 printf("[%lu][%lu]db_addpage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1025 (u_long
)lsnp
->offset
,
1027 (u_long
)argp
->txnid
->txnid
,
1028 (u_long
)argp
->prev_lsn
.file
,
1029 (u_long
)argp
->prev_lsn
.offset
);
1030 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
1031 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
1032 printf("\tlsn: [%lu][%lu]\n",
1033 (u_long
)argp
->lsn
.file
, (u_long
)argp
->lsn
.offset
);
1034 printf("\tnextpgno: %lu\n", (u_long
)argp
->nextpgno
);
1035 printf("\tnextlsn: [%lu][%lu]\n",
1036 (u_long
)argp
->nextlsn
.file
, (u_long
)argp
->nextlsn
.offset
);
1043 * PUBLIC: int __db_addpage_read __P((void *, __db_addpage_args **));
1046 __db_addpage_read(recbuf
, argpp
)
1048 __db_addpage_args
**argpp
;
1050 __db_addpage_args
*argp
;
1053 argp
= (__db_addpage_args
*)__db_malloc(sizeof(__db_addpage_args
) +
1057 argp
->txnid
= (DB_TXN
*)&argp
[1];
1059 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
1060 bp
+= sizeof(argp
->type
);
1061 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
1062 bp
+= sizeof(argp
->txnid
->txnid
);
1063 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
1064 bp
+= sizeof(DB_LSN
);
1065 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
1066 bp
+= sizeof(argp
->fileid
);
1067 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
1068 bp
+= sizeof(argp
->pgno
);
1069 memcpy(&argp
->lsn
, bp
, sizeof(argp
->lsn
));
1070 bp
+= sizeof(argp
->lsn
);
1071 memcpy(&argp
->nextpgno
, bp
, sizeof(argp
->nextpgno
));
1072 bp
+= sizeof(argp
->nextpgno
);
1073 memcpy(&argp
->nextlsn
, bp
, sizeof(argp
->nextlsn
));
1074 bp
+= sizeof(argp
->nextlsn
);
1080 * PUBLIC: int __db_debug_log
1081 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
1082 * PUBLIC: const DBT *, u_int32_t, const DBT *, const DBT *,
1083 * PUBLIC: u_int32_t));
1085 int __db_debug_log(logp
, txnid
, ret_lsnp
, flags
,
1086 op
, fileid
, key
, data
, arg_flags
)
1095 u_int32_t arg_flags
;
1098 DB_LSN
*lsnp
, null_lsn
;
1100 u_int32_t rectype
, txn_num
;
1104 rectype
= DB_db_debug
;
1105 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
1106 if (txnid
== NULL
) {
1108 null_lsn
.offset
= 0;
1111 lsnp
= &txnid
->last_lsn
;
1112 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
1113 + sizeof(u_int32_t
) + (op
== NULL
? 0 : op
->size
)
1115 + sizeof(u_int32_t
) + (key
== NULL
? 0 : key
->size
)
1116 + sizeof(u_int32_t
) + (data
== NULL
? 0 : data
->size
)
1117 + sizeof(arg_flags
);
1118 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
1122 memcpy(bp
, &rectype
, sizeof(rectype
));
1123 bp
+= sizeof(rectype
);
1124 memcpy(bp
, &txn_num
, sizeof(txn_num
));
1125 bp
+= sizeof(txn_num
);
1126 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
1127 bp
+= sizeof(DB_LSN
);
1130 memcpy(bp
, &zero
, sizeof(u_int32_t
));
1131 bp
+= sizeof(u_int32_t
);
1133 memcpy(bp
, &op
->size
, sizeof(op
->size
));
1134 bp
+= sizeof(op
->size
);
1135 memcpy(bp
, op
->data
, op
->size
);
1138 memcpy(bp
, &fileid
, sizeof(fileid
));
1139 bp
+= sizeof(fileid
);
1142 memcpy(bp
, &zero
, sizeof(u_int32_t
));
1143 bp
+= sizeof(u_int32_t
);
1145 memcpy(bp
, &key
->size
, sizeof(key
->size
));
1146 bp
+= sizeof(key
->size
);
1147 memcpy(bp
, key
->data
, key
->size
);
1152 memcpy(bp
, &zero
, sizeof(u_int32_t
));
1153 bp
+= sizeof(u_int32_t
);
1155 memcpy(bp
, &data
->size
, sizeof(data
->size
));
1156 bp
+= sizeof(data
->size
);
1157 memcpy(bp
, data
->data
, data
->size
);
1160 memcpy(bp
, &arg_flags
, sizeof(arg_flags
));
1161 bp
+= sizeof(arg_flags
);
1163 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
1164 fprintf(stderr
, "Error in log record length");
1166 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
1168 txnid
->last_lsn
= *ret_lsnp
;
1169 __db_free(logrec
.data
);
1174 * PUBLIC: int __db_debug_print
1175 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1178 __db_debug_print(notused1
, dbtp
, lsnp
, notused3
, notused4
)
1185 __db_debug_args
*argp
;
1195 if ((ret
= __db_debug_read(dbtp
->data
, &argp
)) != 0)
1197 printf("[%lu][%lu]db_debug: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1199 (u_long
)lsnp
->offset
,
1201 (u_long
)argp
->txnid
->txnid
,
1202 (u_long
)argp
->prev_lsn
.file
,
1203 (u_long
)argp
->prev_lsn
.offset
);
1205 for (i
= 0; i
< argp
->op
.size
; i
++) {
1206 c
= ((char *)argp
->op
.data
)[i
];
1207 if (isprint(c
) || c
== 0xa)
1213 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
1215 for (i
= 0; i
< argp
->key
.size
; i
++) {
1216 c
= ((char *)argp
->key
.data
)[i
];
1217 if (isprint(c
) || c
== 0xa)
1224 for (i
= 0; i
< argp
->data
.size
; i
++) {
1225 c
= ((char *)argp
->data
.data
)[i
];
1226 if (isprint(c
) || c
== 0xa)
1232 printf("\targ_flags: %lu\n", (u_long
)argp
->arg_flags
);
1239 * PUBLIC: int __db_debug_read __P((void *, __db_debug_args **));
1242 __db_debug_read(recbuf
, argpp
)
1244 __db_debug_args
**argpp
;
1246 __db_debug_args
*argp
;
1249 argp
= (__db_debug_args
*)__db_malloc(sizeof(__db_debug_args
) +
1253 argp
->txnid
= (DB_TXN
*)&argp
[1];
1255 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
1256 bp
+= sizeof(argp
->type
);
1257 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
1258 bp
+= sizeof(argp
->txnid
->txnid
);
1259 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
1260 bp
+= sizeof(DB_LSN
);
1261 memcpy(&argp
->op
.size
, bp
, sizeof(u_int32_t
));
1262 bp
+= sizeof(u_int32_t
);
1264 bp
+= argp
->op
.size
;
1265 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
1266 bp
+= sizeof(argp
->fileid
);
1267 memcpy(&argp
->key
.size
, bp
, sizeof(u_int32_t
));
1268 bp
+= sizeof(u_int32_t
);
1269 argp
->key
.data
= bp
;
1270 bp
+= argp
->key
.size
;
1271 memcpy(&argp
->data
.size
, bp
, sizeof(u_int32_t
));
1272 bp
+= sizeof(u_int32_t
);
1273 argp
->data
.data
= bp
;
1274 bp
+= argp
->data
.size
;
1275 memcpy(&argp
->arg_flags
, bp
, sizeof(argp
->arg_flags
));
1276 bp
+= sizeof(argp
->arg_flags
);
1282 * PUBLIC: int __db_noop_log
1283 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t));
1285 int __db_noop_log(logp
, txnid
, ret_lsnp
, flags
)
1292 DB_LSN
*lsnp
, null_lsn
;
1293 u_int32_t rectype
, txn_num
;
1297 rectype
= DB_db_noop
;
1298 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
1299 if (txnid
== NULL
) {
1301 null_lsn
.offset
= 0;
1304 lsnp
= &txnid
->last_lsn
;
1305 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
);
1306 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
1310 memcpy(bp
, &rectype
, sizeof(rectype
));
1311 bp
+= sizeof(rectype
);
1312 memcpy(bp
, &txn_num
, sizeof(txn_num
));
1313 bp
+= sizeof(txn_num
);
1314 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
1315 bp
+= sizeof(DB_LSN
);
1317 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
1318 fprintf(stderr
, "Error in log record length");
1320 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
1322 txnid
->last_lsn
= *ret_lsnp
;
1323 __db_free(logrec
.data
);
1328 * PUBLIC: int __db_noop_print
1329 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1332 __db_noop_print(notused1
, dbtp
, lsnp
, notused3
, notused4
)
1339 __db_noop_args
*argp
;
1349 if ((ret
= __db_noop_read(dbtp
->data
, &argp
)) != 0)
1351 printf("[%lu][%lu]db_noop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1353 (u_long
)lsnp
->offset
,
1355 (u_long
)argp
->txnid
->txnid
,
1356 (u_long
)argp
->prev_lsn
.file
,
1357 (u_long
)argp
->prev_lsn
.offset
);
1364 * PUBLIC: int __db_noop_read __P((void *, __db_noop_args **));
1367 __db_noop_read(recbuf
, argpp
)
1369 __db_noop_args
**argpp
;
1371 __db_noop_args
*argp
;
1374 argp
= (__db_noop_args
*)__db_malloc(sizeof(__db_noop_args
) +
1378 argp
->txnid
= (DB_TXN
*)&argp
[1];
1380 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
1381 bp
+= sizeof(argp
->type
);
1382 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
1383 bp
+= sizeof(argp
->txnid
->txnid
);
1384 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
1385 bp
+= sizeof(DB_LSN
);
1391 * PUBLIC: int __db_init_print __P((DB_ENV *));
1394 __db_init_print(dbenv
)
1399 if ((ret
= __db_add_recovery(dbenv
,
1400 __db_addrem_print
, DB_db_addrem
)) != 0)
1402 if ((ret
= __db_add_recovery(dbenv
,
1403 __db_split_print
, DB_db_split
)) != 0)
1405 if ((ret
= __db_add_recovery(dbenv
,
1406 __db_big_print
, DB_db_big
)) != 0)
1408 if ((ret
= __db_add_recovery(dbenv
,
1409 __db_ovref_print
, DB_db_ovref
)) != 0)
1411 if ((ret
= __db_add_recovery(dbenv
,
1412 __db_relink_print
, DB_db_relink
)) != 0)
1414 if ((ret
= __db_add_recovery(dbenv
,
1415 __db_addpage_print
, DB_db_addpage
)) != 0)
1417 if ((ret
= __db_add_recovery(dbenv
,
1418 __db_debug_print
, DB_db_debug
)) != 0)
1420 if ((ret
= __db_add_recovery(dbenv
,
1421 __db_noop_print
, DB_db_noop
)) != 0)
1427 * PUBLIC: int __db_init_recover __P((DB_ENV *));
1430 __db_init_recover(dbenv
)
1435 if ((ret
= __db_add_recovery(dbenv
,
1436 __db_addrem_recover
, DB_db_addrem
)) != 0)
1438 if ((ret
= __db_add_recovery(dbenv
,
1439 __db_split_recover
, DB_db_split
)) != 0)
1441 if ((ret
= __db_add_recovery(dbenv
,
1442 __db_big_recover
, DB_db_big
)) != 0)
1444 if ((ret
= __db_add_recovery(dbenv
,
1445 __db_ovref_recover
, DB_db_ovref
)) != 0)
1447 if ((ret
= __db_add_recovery(dbenv
,
1448 __db_relink_recover
, DB_db_relink
)) != 0)
1450 if ((ret
= __db_add_recovery(dbenv
,
1451 __db_addpage_recover
, DB_db_addpage
)) != 0)
1453 if ((ret
= __db_add_recovery(dbenv
,
1454 __db_debug_recover
, DB_db_debug
)) != 0)
1456 if ((ret
= __db_add_recovery(dbenv
,
1457 __db_noop_recover
, DB_db_noop
)) != 0)