1 /* Do not edit: automatically built by dist/db_gen.sh. */
4 #ifndef NO_SYSTEM_INCLUDES
15 #include "db_dispatch.h"
18 * PUBLIC: int __db_addrem_log
19 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
20 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, u_int32_t,
21 * PUBLIC: size_t, const DBT *, const DBT *, DB_LSN *));
23 int __db_addrem_log(logp
, txnid
, ret_lsnp
, flags
,
24 opcode
, fileid
, pgno
, indx
, nbytes
, hdr
,
40 DB_LSN
*lsnp
, null_lsn
;
42 u_int32_t rectype
, txn_num
;
46 rectype
= DB_db_addrem
;
47 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
53 lsnp
= &txnid
->last_lsn
;
54 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
60 + sizeof(u_int32_t
) + (hdr
== NULL
? 0 : hdr
->size
)
61 + sizeof(u_int32_t
) + (dbt
== NULL
? 0 : dbt
->size
)
63 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
67 memcpy(bp
, &rectype
, sizeof(rectype
));
68 bp
+= sizeof(rectype
);
69 memcpy(bp
, &txn_num
, sizeof(txn_num
));
70 bp
+= sizeof(txn_num
);
71 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
73 memcpy(bp
, &opcode
, sizeof(opcode
));
75 memcpy(bp
, &fileid
, sizeof(fileid
));
77 memcpy(bp
, &pgno
, sizeof(pgno
));
79 memcpy(bp
, &indx
, sizeof(indx
));
81 memcpy(bp
, &nbytes
, sizeof(nbytes
));
85 memcpy(bp
, &zero
, sizeof(u_int32_t
));
86 bp
+= sizeof(u_int32_t
);
88 memcpy(bp
, &hdr
->size
, sizeof(hdr
->size
));
89 bp
+= sizeof(hdr
->size
);
90 memcpy(bp
, hdr
->data
, hdr
->size
);
95 memcpy(bp
, &zero
, sizeof(u_int32_t
));
96 bp
+= sizeof(u_int32_t
);
98 memcpy(bp
, &dbt
->size
, sizeof(dbt
->size
));
99 bp
+= sizeof(dbt
->size
);
100 memcpy(bp
, dbt
->data
, dbt
->size
);
104 memcpy(bp
, pagelsn
, sizeof(*pagelsn
));
106 memset(bp
, 0, sizeof(*pagelsn
));
107 bp
+= sizeof(*pagelsn
);
109 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
110 fprintf(stderr
, "Error in log record length");
112 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
114 txnid
->last_lsn
= *ret_lsnp
;
115 __db_free(logrec
.data
);
120 * PUBLIC: int __db_addrem_print
121 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
124 __db_addrem_print(notused1
, dbtp
, lsnp
, notused2
, notused3
)
131 __db_addrem_args
*argp
;
142 if ((ret
= __db_addrem_read(dbtp
->data
, &argp
)) != 0)
144 printf("[%lu][%lu]db_addrem: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
146 (u_long
)lsnp
->offset
,
148 (u_long
)argp
->txnid
->txnid
,
149 (u_long
)argp
->prev_lsn
.file
,
150 (u_long
)argp
->prev_lsn
.offset
);
151 printf("\topcode: %lu\n", (u_long
)argp
->opcode
);
152 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
153 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
154 printf("\tindx: %lu\n", (u_long
)argp
->indx
);
155 printf("\tnbytes: %lu\n", (u_long
)argp
->nbytes
);
157 for (i
= 0; i
< argp
->hdr
.size
; i
++) {
158 ch
= ((u_int8_t
*)argp
->hdr
.data
)[i
];
159 if (isprint(ch
) || ch
== 0xa)
166 for (i
= 0; i
< argp
->dbt
.size
; i
++) {
167 ch
= ((u_int8_t
*)argp
->dbt
.data
)[i
];
168 if (isprint(ch
) || ch
== 0xa)
174 printf("\tpagelsn: [%lu][%lu]\n",
175 (u_long
)argp
->pagelsn
.file
, (u_long
)argp
->pagelsn
.offset
);
182 * PUBLIC: int __db_addrem_read __P((void *, __db_addrem_args **));
185 __db_addrem_read(recbuf
, argpp
)
187 __db_addrem_args
**argpp
;
189 __db_addrem_args
*argp
;
192 argp
= (__db_addrem_args
*)__db_malloc(sizeof(__db_addrem_args
) +
196 argp
->txnid
= (DB_TXN
*)&argp
[1];
198 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
199 bp
+= sizeof(argp
->type
);
200 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
201 bp
+= sizeof(argp
->txnid
->txnid
);
202 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
203 bp
+= sizeof(DB_LSN
);
204 memcpy(&argp
->opcode
, bp
, sizeof(argp
->opcode
));
205 bp
+= sizeof(argp
->opcode
);
206 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
207 bp
+= sizeof(argp
->fileid
);
208 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
209 bp
+= sizeof(argp
->pgno
);
210 memcpy(&argp
->indx
, bp
, sizeof(argp
->indx
));
211 bp
+= sizeof(argp
->indx
);
212 memcpy(&argp
->nbytes
, bp
, sizeof(argp
->nbytes
));
213 bp
+= sizeof(argp
->nbytes
);
214 memcpy(&argp
->hdr
.size
, bp
, sizeof(u_int32_t
));
215 bp
+= sizeof(u_int32_t
);
217 bp
+= argp
->hdr
.size
;
218 memcpy(&argp
->dbt
.size
, bp
, sizeof(u_int32_t
));
219 bp
+= sizeof(u_int32_t
);
221 bp
+= argp
->dbt
.size
;
222 memcpy(&argp
->pagelsn
, bp
, sizeof(argp
->pagelsn
));
223 bp
+= sizeof(argp
->pagelsn
);
229 * PUBLIC: int __db_split_log
230 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
231 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, const DBT *,
232 * PUBLIC: DB_LSN *));
234 int __db_split_log(logp
, txnid
, ret_lsnp
, flags
,
235 opcode
, fileid
, pgno
, pageimage
, pagelsn
)
243 const DBT
*pageimage
;
247 DB_LSN
*lsnp
, null_lsn
;
249 u_int32_t rectype
, txn_num
;
253 rectype
= DB_db_split
;
254 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
260 lsnp
= &txnid
->last_lsn
;
261 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
265 + sizeof(u_int32_t
) + (pageimage
== NULL
? 0 : pageimage
->size
)
267 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
271 memcpy(bp
, &rectype
, sizeof(rectype
));
272 bp
+= sizeof(rectype
);
273 memcpy(bp
, &txn_num
, sizeof(txn_num
));
274 bp
+= sizeof(txn_num
);
275 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
276 bp
+= sizeof(DB_LSN
);
277 memcpy(bp
, &opcode
, sizeof(opcode
));
278 bp
+= sizeof(opcode
);
279 memcpy(bp
, &fileid
, sizeof(fileid
));
280 bp
+= sizeof(fileid
);
281 memcpy(bp
, &pgno
, sizeof(pgno
));
283 if (pageimage
== NULL
) {
285 memcpy(bp
, &zero
, sizeof(u_int32_t
));
286 bp
+= sizeof(u_int32_t
);
288 memcpy(bp
, &pageimage
->size
, sizeof(pageimage
->size
));
289 bp
+= sizeof(pageimage
->size
);
290 memcpy(bp
, pageimage
->data
, pageimage
->size
);
291 bp
+= pageimage
->size
;
294 memcpy(bp
, pagelsn
, sizeof(*pagelsn
));
296 memset(bp
, 0, sizeof(*pagelsn
));
297 bp
+= sizeof(*pagelsn
);
299 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
300 fprintf(stderr
, "Error in log record length");
302 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
304 txnid
->last_lsn
= *ret_lsnp
;
305 __db_free(logrec
.data
);
310 * PUBLIC: int __db_split_print
311 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
314 __db_split_print(notused1
, dbtp
, lsnp
, notused2
, notused3
)
321 __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 ch
= ((u_int8_t
*)argp
->pageimage
.data
)[i
];
347 if (isprint(ch
) || ch
== 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
, notused2
, notused3
)
527 if ((ret
= __db_big_read(dbtp
->data
, &argp
)) != 0)
529 printf("[%lu][%lu]db_big: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
531 (u_long
)lsnp
->offset
,
533 (u_long
)argp
->txnid
->txnid
,
534 (u_long
)argp
->prev_lsn
.file
,
535 (u_long
)argp
->prev_lsn
.offset
);
536 printf("\topcode: %lu\n", (u_long
)argp
->opcode
);
537 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
538 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
539 printf("\tprev_pgno: %lu\n", (u_long
)argp
->prev_pgno
);
540 printf("\tnext_pgno: %lu\n", (u_long
)argp
->next_pgno
);
542 for (i
= 0; i
< argp
->dbt
.size
; i
++) {
543 ch
= ((u_int8_t
*)argp
->dbt
.data
)[i
];
544 if (isprint(ch
) || ch
== 0xa)
550 printf("\tpagelsn: [%lu][%lu]\n",
551 (u_long
)argp
->pagelsn
.file
, (u_long
)argp
->pagelsn
.offset
);
552 printf("\tprevlsn: [%lu][%lu]\n",
553 (u_long
)argp
->prevlsn
.file
, (u_long
)argp
->prevlsn
.offset
);
554 printf("\tnextlsn: [%lu][%lu]\n",
555 (u_long
)argp
->nextlsn
.file
, (u_long
)argp
->nextlsn
.offset
);
562 * PUBLIC: int __db_big_read __P((void *, __db_big_args **));
565 __db_big_read(recbuf
, argpp
)
567 __db_big_args
**argpp
;
572 argp
= (__db_big_args
*)__db_malloc(sizeof(__db_big_args
) +
576 argp
->txnid
= (DB_TXN
*)&argp
[1];
578 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
579 bp
+= sizeof(argp
->type
);
580 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
581 bp
+= sizeof(argp
->txnid
->txnid
);
582 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
583 bp
+= sizeof(DB_LSN
);
584 memcpy(&argp
->opcode
, bp
, sizeof(argp
->opcode
));
585 bp
+= sizeof(argp
->opcode
);
586 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
587 bp
+= sizeof(argp
->fileid
);
588 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
589 bp
+= sizeof(argp
->pgno
);
590 memcpy(&argp
->prev_pgno
, bp
, sizeof(argp
->prev_pgno
));
591 bp
+= sizeof(argp
->prev_pgno
);
592 memcpy(&argp
->next_pgno
, bp
, sizeof(argp
->next_pgno
));
593 bp
+= sizeof(argp
->next_pgno
);
594 memcpy(&argp
->dbt
.size
, bp
, sizeof(u_int32_t
));
595 bp
+= sizeof(u_int32_t
);
597 bp
+= argp
->dbt
.size
;
598 memcpy(&argp
->pagelsn
, bp
, sizeof(argp
->pagelsn
));
599 bp
+= sizeof(argp
->pagelsn
);
600 memcpy(&argp
->prevlsn
, bp
, sizeof(argp
->prevlsn
));
601 bp
+= sizeof(argp
->prevlsn
);
602 memcpy(&argp
->nextlsn
, bp
, sizeof(argp
->nextlsn
));
603 bp
+= sizeof(argp
->nextlsn
);
609 * PUBLIC: int __db_ovref_log
610 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
611 * PUBLIC: u_int32_t, db_pgno_t, int32_t, DB_LSN *));
613 int __db_ovref_log(logp
, txnid
, ret_lsnp
, flags
,
614 fileid
, pgno
, adjust
, lsn
)
625 DB_LSN
*lsnp
, null_lsn
;
626 u_int32_t rectype
, txn_num
;
630 rectype
= DB_db_ovref
;
631 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
637 lsnp
= &txnid
->last_lsn
;
638 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
643 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
647 memcpy(bp
, &rectype
, sizeof(rectype
));
648 bp
+= sizeof(rectype
);
649 memcpy(bp
, &txn_num
, sizeof(txn_num
));
650 bp
+= sizeof(txn_num
);
651 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
652 bp
+= sizeof(DB_LSN
);
653 memcpy(bp
, &fileid
, sizeof(fileid
));
654 bp
+= sizeof(fileid
);
655 memcpy(bp
, &pgno
, sizeof(pgno
));
657 memcpy(bp
, &adjust
, sizeof(adjust
));
658 bp
+= sizeof(adjust
);
660 memcpy(bp
, lsn
, sizeof(*lsn
));
662 memset(bp
, 0, sizeof(*lsn
));
665 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
666 fprintf(stderr
, "Error in log record length");
668 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
670 txnid
->last_lsn
= *ret_lsnp
;
671 __db_free(logrec
.data
);
676 * PUBLIC: int __db_ovref_print
677 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
680 __db_ovref_print(notused1
, dbtp
, lsnp
, notused2
, notused3
)
687 __db_ovref_args
*argp
;
698 if ((ret
= __db_ovref_read(dbtp
->data
, &argp
)) != 0)
700 printf("[%lu][%lu]db_ovref: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
702 (u_long
)lsnp
->offset
,
704 (u_long
)argp
->txnid
->txnid
,
705 (u_long
)argp
->prev_lsn
.file
,
706 (u_long
)argp
->prev_lsn
.offset
);
707 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
708 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
709 printf("\tadjust: %ld\n", (long)argp
->adjust
);
710 printf("\tlsn: [%lu][%lu]\n",
711 (u_long
)argp
->lsn
.file
, (u_long
)argp
->lsn
.offset
);
718 * PUBLIC: int __db_ovref_read __P((void *, __db_ovref_args **));
721 __db_ovref_read(recbuf
, argpp
)
723 __db_ovref_args
**argpp
;
725 __db_ovref_args
*argp
;
728 argp
= (__db_ovref_args
*)__db_malloc(sizeof(__db_ovref_args
) +
732 argp
->txnid
= (DB_TXN
*)&argp
[1];
734 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
735 bp
+= sizeof(argp
->type
);
736 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
737 bp
+= sizeof(argp
->txnid
->txnid
);
738 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
739 bp
+= sizeof(DB_LSN
);
740 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
741 bp
+= sizeof(argp
->fileid
);
742 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
743 bp
+= sizeof(argp
->pgno
);
744 memcpy(&argp
->adjust
, bp
, sizeof(argp
->adjust
));
745 bp
+= sizeof(argp
->adjust
);
746 memcpy(&argp
->lsn
, bp
, sizeof(argp
->lsn
));
747 bp
+= sizeof(argp
->lsn
);
753 * PUBLIC: int __db_relink_log
754 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
755 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t,
756 * PUBLIC: DB_LSN *, db_pgno_t, DB_LSN *));
758 int __db_relink_log(logp
, txnid
, ret_lsnp
, flags
,
759 fileid
, pgno
, lsn
, prev
, lsn_prev
, next
,
774 DB_LSN
*lsnp
, null_lsn
;
775 u_int32_t rectype
, txn_num
;
779 rectype
= DB_db_relink
;
780 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
786 lsnp
= &txnid
->last_lsn
;
787 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
795 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
799 memcpy(bp
, &rectype
, sizeof(rectype
));
800 bp
+= sizeof(rectype
);
801 memcpy(bp
, &txn_num
, sizeof(txn_num
));
802 bp
+= sizeof(txn_num
);
803 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
804 bp
+= sizeof(DB_LSN
);
805 memcpy(bp
, &fileid
, sizeof(fileid
));
806 bp
+= sizeof(fileid
);
807 memcpy(bp
, &pgno
, sizeof(pgno
));
810 memcpy(bp
, lsn
, sizeof(*lsn
));
812 memset(bp
, 0, sizeof(*lsn
));
814 memcpy(bp
, &prev
, sizeof(prev
));
816 if (lsn_prev
!= NULL
)
817 memcpy(bp
, lsn_prev
, sizeof(*lsn_prev
));
819 memset(bp
, 0, sizeof(*lsn_prev
));
820 bp
+= sizeof(*lsn_prev
);
821 memcpy(bp
, &next
, sizeof(next
));
823 if (lsn_next
!= NULL
)
824 memcpy(bp
, lsn_next
, sizeof(*lsn_next
));
826 memset(bp
, 0, sizeof(*lsn_next
));
827 bp
+= sizeof(*lsn_next
);
829 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
830 fprintf(stderr
, "Error in log record length");
832 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
834 txnid
->last_lsn
= *ret_lsnp
;
835 __db_free(logrec
.data
);
840 * PUBLIC: int __db_relink_print
841 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
844 __db_relink_print(notused1
, dbtp
, lsnp
, notused2
, notused3
)
851 __db_relink_args
*argp
;
862 if ((ret
= __db_relink_read(dbtp
->data
, &argp
)) != 0)
864 printf("[%lu][%lu]db_relink: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
866 (u_long
)lsnp
->offset
,
868 (u_long
)argp
->txnid
->txnid
,
869 (u_long
)argp
->prev_lsn
.file
,
870 (u_long
)argp
->prev_lsn
.offset
);
871 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
872 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
873 printf("\tlsn: [%lu][%lu]\n",
874 (u_long
)argp
->lsn
.file
, (u_long
)argp
->lsn
.offset
);
875 printf("\tprev: %lu\n", (u_long
)argp
->prev
);
876 printf("\tlsn_prev: [%lu][%lu]\n",
877 (u_long
)argp
->lsn_prev
.file
, (u_long
)argp
->lsn_prev
.offset
);
878 printf("\tnext: %lu\n", (u_long
)argp
->next
);
879 printf("\tlsn_next: [%lu][%lu]\n",
880 (u_long
)argp
->lsn_next
.file
, (u_long
)argp
->lsn_next
.offset
);
887 * PUBLIC: int __db_relink_read __P((void *, __db_relink_args **));
890 __db_relink_read(recbuf
, argpp
)
892 __db_relink_args
**argpp
;
894 __db_relink_args
*argp
;
897 argp
= (__db_relink_args
*)__db_malloc(sizeof(__db_relink_args
) +
901 argp
->txnid
= (DB_TXN
*)&argp
[1];
903 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
904 bp
+= sizeof(argp
->type
);
905 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
906 bp
+= sizeof(argp
->txnid
->txnid
);
907 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
908 bp
+= sizeof(DB_LSN
);
909 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
910 bp
+= sizeof(argp
->fileid
);
911 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
912 bp
+= sizeof(argp
->pgno
);
913 memcpy(&argp
->lsn
, bp
, sizeof(argp
->lsn
));
914 bp
+= sizeof(argp
->lsn
);
915 memcpy(&argp
->prev
, bp
, sizeof(argp
->prev
));
916 bp
+= sizeof(argp
->prev
);
917 memcpy(&argp
->lsn_prev
, bp
, sizeof(argp
->lsn_prev
));
918 bp
+= sizeof(argp
->lsn_prev
);
919 memcpy(&argp
->next
, bp
, sizeof(argp
->next
));
920 bp
+= sizeof(argp
->next
);
921 memcpy(&argp
->lsn_next
, bp
, sizeof(argp
->lsn_next
));
922 bp
+= sizeof(argp
->lsn_next
);
928 * PUBLIC: int __db_addpage_log
929 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
930 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t,
931 * PUBLIC: DB_LSN *));
933 int __db_addpage_log(logp
, txnid
, ret_lsnp
, flags
,
934 fileid
, pgno
, lsn
, nextpgno
, nextlsn
)
946 DB_LSN
*lsnp
, null_lsn
;
947 u_int32_t rectype
, txn_num
;
951 rectype
= DB_db_addpage
;
952 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
958 lsnp
= &txnid
->last_lsn
;
959 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
965 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
969 memcpy(bp
, &rectype
, sizeof(rectype
));
970 bp
+= sizeof(rectype
);
971 memcpy(bp
, &txn_num
, sizeof(txn_num
));
972 bp
+= sizeof(txn_num
);
973 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
974 bp
+= sizeof(DB_LSN
);
975 memcpy(bp
, &fileid
, sizeof(fileid
));
976 bp
+= sizeof(fileid
);
977 memcpy(bp
, &pgno
, sizeof(pgno
));
980 memcpy(bp
, lsn
, sizeof(*lsn
));
982 memset(bp
, 0, sizeof(*lsn
));
984 memcpy(bp
, &nextpgno
, sizeof(nextpgno
));
985 bp
+= sizeof(nextpgno
);
987 memcpy(bp
, nextlsn
, sizeof(*nextlsn
));
989 memset(bp
, 0, sizeof(*nextlsn
));
990 bp
+= sizeof(*nextlsn
);
992 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
993 fprintf(stderr
, "Error in log record length");
995 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
997 txnid
->last_lsn
= *ret_lsnp
;
998 __db_free(logrec
.data
);
1003 * PUBLIC: int __db_addpage_print
1004 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1007 __db_addpage_print(notused1
, dbtp
, lsnp
, notused2
, notused3
)
1014 __db_addpage_args
*argp
;
1025 if ((ret
= __db_addpage_read(dbtp
->data
, &argp
)) != 0)
1027 printf("[%lu][%lu]db_addpage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1029 (u_long
)lsnp
->offset
,
1031 (u_long
)argp
->txnid
->txnid
,
1032 (u_long
)argp
->prev_lsn
.file
,
1033 (u_long
)argp
->prev_lsn
.offset
);
1034 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
1035 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
1036 printf("\tlsn: [%lu][%lu]\n",
1037 (u_long
)argp
->lsn
.file
, (u_long
)argp
->lsn
.offset
);
1038 printf("\tnextpgno: %lu\n", (u_long
)argp
->nextpgno
);
1039 printf("\tnextlsn: [%lu][%lu]\n",
1040 (u_long
)argp
->nextlsn
.file
, (u_long
)argp
->nextlsn
.offset
);
1047 * PUBLIC: int __db_addpage_read __P((void *, __db_addpage_args **));
1050 __db_addpage_read(recbuf
, argpp
)
1052 __db_addpage_args
**argpp
;
1054 __db_addpage_args
*argp
;
1057 argp
= (__db_addpage_args
*)__db_malloc(sizeof(__db_addpage_args
) +
1061 argp
->txnid
= (DB_TXN
*)&argp
[1];
1063 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
1064 bp
+= sizeof(argp
->type
);
1065 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
1066 bp
+= sizeof(argp
->txnid
->txnid
);
1067 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
1068 bp
+= sizeof(DB_LSN
);
1069 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
1070 bp
+= sizeof(argp
->fileid
);
1071 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
1072 bp
+= sizeof(argp
->pgno
);
1073 memcpy(&argp
->lsn
, bp
, sizeof(argp
->lsn
));
1074 bp
+= sizeof(argp
->lsn
);
1075 memcpy(&argp
->nextpgno
, bp
, sizeof(argp
->nextpgno
));
1076 bp
+= sizeof(argp
->nextpgno
);
1077 memcpy(&argp
->nextlsn
, bp
, sizeof(argp
->nextlsn
));
1078 bp
+= sizeof(argp
->nextlsn
);
1084 * PUBLIC: int __db_debug_log
1085 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
1086 * PUBLIC: const DBT *, u_int32_t, const DBT *, const DBT *,
1087 * PUBLIC: u_int32_t));
1089 int __db_debug_log(logp
, txnid
, ret_lsnp
, flags
,
1090 op
, fileid
, key
, data
, arg_flags
)
1099 u_int32_t arg_flags
;
1102 DB_LSN
*lsnp
, null_lsn
;
1104 u_int32_t rectype
, txn_num
;
1108 rectype
= DB_db_debug
;
1109 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
1110 if (txnid
== NULL
) {
1112 null_lsn
.offset
= 0;
1115 lsnp
= &txnid
->last_lsn
;
1116 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
1117 + sizeof(u_int32_t
) + (op
== NULL
? 0 : op
->size
)
1119 + sizeof(u_int32_t
) + (key
== NULL
? 0 : key
->size
)
1120 + sizeof(u_int32_t
) + (data
== NULL
? 0 : data
->size
)
1121 + sizeof(arg_flags
);
1122 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
1126 memcpy(bp
, &rectype
, sizeof(rectype
));
1127 bp
+= sizeof(rectype
);
1128 memcpy(bp
, &txn_num
, sizeof(txn_num
));
1129 bp
+= sizeof(txn_num
);
1130 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
1131 bp
+= sizeof(DB_LSN
);
1134 memcpy(bp
, &zero
, sizeof(u_int32_t
));
1135 bp
+= sizeof(u_int32_t
);
1137 memcpy(bp
, &op
->size
, sizeof(op
->size
));
1138 bp
+= sizeof(op
->size
);
1139 memcpy(bp
, op
->data
, op
->size
);
1142 memcpy(bp
, &fileid
, sizeof(fileid
));
1143 bp
+= sizeof(fileid
);
1146 memcpy(bp
, &zero
, sizeof(u_int32_t
));
1147 bp
+= sizeof(u_int32_t
);
1149 memcpy(bp
, &key
->size
, sizeof(key
->size
));
1150 bp
+= sizeof(key
->size
);
1151 memcpy(bp
, key
->data
, key
->size
);
1156 memcpy(bp
, &zero
, sizeof(u_int32_t
));
1157 bp
+= sizeof(u_int32_t
);
1159 memcpy(bp
, &data
->size
, sizeof(data
->size
));
1160 bp
+= sizeof(data
->size
);
1161 memcpy(bp
, data
->data
, data
->size
);
1164 memcpy(bp
, &arg_flags
, sizeof(arg_flags
));
1165 bp
+= sizeof(arg_flags
);
1167 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
1168 fprintf(stderr
, "Error in log record length");
1170 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
1172 txnid
->last_lsn
= *ret_lsnp
;
1173 __db_free(logrec
.data
);
1178 * PUBLIC: int __db_debug_print
1179 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1182 __db_debug_print(notused1
, dbtp
, lsnp
, notused2
, notused3
)
1189 __db_debug_args
*argp
;
1200 if ((ret
= __db_debug_read(dbtp
->data
, &argp
)) != 0)
1202 printf("[%lu][%lu]db_debug: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1204 (u_long
)lsnp
->offset
,
1206 (u_long
)argp
->txnid
->txnid
,
1207 (u_long
)argp
->prev_lsn
.file
,
1208 (u_long
)argp
->prev_lsn
.offset
);
1210 for (i
= 0; i
< argp
->op
.size
; i
++) {
1211 ch
= ((u_int8_t
*)argp
->op
.data
)[i
];
1212 if (isprint(ch
) || ch
== 0xa)
1218 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
1220 for (i
= 0; i
< argp
->key
.size
; i
++) {
1221 ch
= ((u_int8_t
*)argp
->key
.data
)[i
];
1222 if (isprint(ch
) || ch
== 0xa)
1229 for (i
= 0; i
< argp
->data
.size
; i
++) {
1230 ch
= ((u_int8_t
*)argp
->data
.data
)[i
];
1231 if (isprint(ch
) || ch
== 0xa)
1237 printf("\targ_flags: %lu\n", (u_long
)argp
->arg_flags
);
1244 * PUBLIC: int __db_debug_read __P((void *, __db_debug_args **));
1247 __db_debug_read(recbuf
, argpp
)
1249 __db_debug_args
**argpp
;
1251 __db_debug_args
*argp
;
1254 argp
= (__db_debug_args
*)__db_malloc(sizeof(__db_debug_args
) +
1258 argp
->txnid
= (DB_TXN
*)&argp
[1];
1260 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
1261 bp
+= sizeof(argp
->type
);
1262 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
1263 bp
+= sizeof(argp
->txnid
->txnid
);
1264 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
1265 bp
+= sizeof(DB_LSN
);
1266 memcpy(&argp
->op
.size
, bp
, sizeof(u_int32_t
));
1267 bp
+= sizeof(u_int32_t
);
1269 bp
+= argp
->op
.size
;
1270 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
1271 bp
+= sizeof(argp
->fileid
);
1272 memcpy(&argp
->key
.size
, bp
, sizeof(u_int32_t
));
1273 bp
+= sizeof(u_int32_t
);
1274 argp
->key
.data
= bp
;
1275 bp
+= argp
->key
.size
;
1276 memcpy(&argp
->data
.size
, bp
, sizeof(u_int32_t
));
1277 bp
+= sizeof(u_int32_t
);
1278 argp
->data
.data
= bp
;
1279 bp
+= argp
->data
.size
;
1280 memcpy(&argp
->arg_flags
, bp
, sizeof(argp
->arg_flags
));
1281 bp
+= sizeof(argp
->arg_flags
);
1287 * PUBLIC: int __db_noop_log
1288 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
1289 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *));
1291 int __db_noop_log(logp
, txnid
, ret_lsnp
, flags
,
1292 fileid
, pgno
, prevlsn
)
1302 DB_LSN
*lsnp
, null_lsn
;
1303 u_int32_t rectype
, txn_num
;
1307 rectype
= DB_db_noop
;
1308 txn_num
= txnid
== NULL
? 0 : txnid
->txnid
;
1309 if (txnid
== NULL
) {
1311 null_lsn
.offset
= 0;
1314 lsnp
= &txnid
->last_lsn
;
1315 logrec
.size
= sizeof(rectype
) + sizeof(txn_num
) + sizeof(DB_LSN
)
1319 if ((logrec
.data
= (void *)__db_malloc(logrec
.size
)) == NULL
)
1323 memcpy(bp
, &rectype
, sizeof(rectype
));
1324 bp
+= sizeof(rectype
);
1325 memcpy(bp
, &txn_num
, sizeof(txn_num
));
1326 bp
+= sizeof(txn_num
);
1327 memcpy(bp
, lsnp
, sizeof(DB_LSN
));
1328 bp
+= sizeof(DB_LSN
);
1329 memcpy(bp
, &fileid
, sizeof(fileid
));
1330 bp
+= sizeof(fileid
);
1331 memcpy(bp
, &pgno
, sizeof(pgno
));
1333 if (prevlsn
!= NULL
)
1334 memcpy(bp
, prevlsn
, sizeof(*prevlsn
));
1336 memset(bp
, 0, sizeof(*prevlsn
));
1337 bp
+= sizeof(*prevlsn
);
1339 if ((u_int32_t
)(bp
- (u_int8_t
*)logrec
.data
) != logrec
.size
)
1340 fprintf(stderr
, "Error in log record length");
1342 ret
= log_put(logp
, ret_lsnp
, (DBT
*)&logrec
, flags
);
1344 txnid
->last_lsn
= *ret_lsnp
;
1345 __db_free(logrec
.data
);
1350 * PUBLIC: int __db_noop_print
1351 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1354 __db_noop_print(notused1
, dbtp
, lsnp
, notused2
, notused3
)
1361 __db_noop_args
*argp
;
1372 if ((ret
= __db_noop_read(dbtp
->data
, &argp
)) != 0)
1374 printf("[%lu][%lu]db_noop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1376 (u_long
)lsnp
->offset
,
1378 (u_long
)argp
->txnid
->txnid
,
1379 (u_long
)argp
->prev_lsn
.file
,
1380 (u_long
)argp
->prev_lsn
.offset
);
1381 printf("\tfileid: %lu\n", (u_long
)argp
->fileid
);
1382 printf("\tpgno: %lu\n", (u_long
)argp
->pgno
);
1383 printf("\tprevlsn: [%lu][%lu]\n",
1384 (u_long
)argp
->prevlsn
.file
, (u_long
)argp
->prevlsn
.offset
);
1391 * PUBLIC: int __db_noop_read __P((void *, __db_noop_args **));
1394 __db_noop_read(recbuf
, argpp
)
1396 __db_noop_args
**argpp
;
1398 __db_noop_args
*argp
;
1401 argp
= (__db_noop_args
*)__db_malloc(sizeof(__db_noop_args
) +
1405 argp
->txnid
= (DB_TXN
*)&argp
[1];
1407 memcpy(&argp
->type
, bp
, sizeof(argp
->type
));
1408 bp
+= sizeof(argp
->type
);
1409 memcpy(&argp
->txnid
->txnid
, bp
, sizeof(argp
->txnid
->txnid
));
1410 bp
+= sizeof(argp
->txnid
->txnid
);
1411 memcpy(&argp
->prev_lsn
, bp
, sizeof(DB_LSN
));
1412 bp
+= sizeof(DB_LSN
);
1413 memcpy(&argp
->fileid
, bp
, sizeof(argp
->fileid
));
1414 bp
+= sizeof(argp
->fileid
);
1415 memcpy(&argp
->pgno
, bp
, sizeof(argp
->pgno
));
1416 bp
+= sizeof(argp
->pgno
);
1417 memcpy(&argp
->prevlsn
, bp
, sizeof(argp
->prevlsn
));
1418 bp
+= sizeof(argp
->prevlsn
);
1424 * PUBLIC: int __db_init_print __P((DB_ENV *));
1427 __db_init_print(dbenv
)
1432 if ((ret
= __db_add_recovery(dbenv
,
1433 __db_addrem_print
, DB_db_addrem
)) != 0)
1435 if ((ret
= __db_add_recovery(dbenv
,
1436 __db_split_print
, DB_db_split
)) != 0)
1438 if ((ret
= __db_add_recovery(dbenv
,
1439 __db_big_print
, DB_db_big
)) != 0)
1441 if ((ret
= __db_add_recovery(dbenv
,
1442 __db_ovref_print
, DB_db_ovref
)) != 0)
1444 if ((ret
= __db_add_recovery(dbenv
,
1445 __db_relink_print
, DB_db_relink
)) != 0)
1447 if ((ret
= __db_add_recovery(dbenv
,
1448 __db_addpage_print
, DB_db_addpage
)) != 0)
1450 if ((ret
= __db_add_recovery(dbenv
,
1451 __db_debug_print
, DB_db_debug
)) != 0)
1453 if ((ret
= __db_add_recovery(dbenv
,
1454 __db_noop_print
, DB_db_noop
)) != 0)
1460 * PUBLIC: int __db_init_recover __P((DB_ENV *));
1463 __db_init_recover(dbenv
)
1468 if ((ret
= __db_add_recovery(dbenv
,
1469 __db_addrem_recover
, DB_db_addrem
)) != 0)
1471 if ((ret
= __db_add_recovery(dbenv
,
1472 __db_split_recover
, DB_db_split
)) != 0)
1474 if ((ret
= __db_add_recovery(dbenv
,
1475 __db_big_recover
, DB_db_big
)) != 0)
1477 if ((ret
= __db_add_recovery(dbenv
,
1478 __db_ovref_recover
, DB_db_ovref
)) != 0)
1480 if ((ret
= __db_add_recovery(dbenv
,
1481 __db_relink_recover
, DB_db_relink
)) != 0)
1483 if ((ret
= __db_add_recovery(dbenv
,
1484 __db_addpage_recover
, DB_db_addpage
)) != 0)
1486 if ((ret
= __db_add_recovery(dbenv
,
1487 __db_debug_recover
, DB_db_debug
)) != 0)
1489 if ((ret
= __db_add_recovery(dbenv
,
1490 __db_noop_recover
, DB_db_noop
)) != 0)