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, DBT *, 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 *)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;
122 * PUBLIC: int __db_addrem_print
123 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
127 __db_addrem_print(notused1, dbtp, lsnp, notused3, notused4)
134 __db_addrem_args *argp;
144 if((ret = __db_addrem_read(dbtp->data, &argp)) != 0)
146 printf("[%lu][%lu]db_addrem: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
148 (u_long)lsnp->offset,
150 (u_long)argp->txnid->txnid,
151 (u_long)argp->prev_lsn.file,
152 (u_long)argp->prev_lsn.offset);
153 printf("\topcode: %lu\n", (u_long)argp->opcode);
154 printf("\tfileid: %lu\n", (u_long)argp->fileid);
155 printf("\tpgno: %lu\n", (u_long)argp->pgno);
156 printf("\tindx: %lu\n", (u_long)argp->indx);
157 printf("\tnbytes: %lu\n", (u_long)argp->nbytes);
159 for (i = 0; i < argp->hdr.size; i++) {
160 c = ((char *)argp->hdr.data)[i];
161 if (isprint(c) || c == 0xa)
168 for (i = 0; i < argp->dbt.size; i++) {
169 c = ((char *)argp->dbt.data)[i];
170 if (isprint(c) || c == 0xa)
176 printf("\tpagelsn: [%lu][%lu]\n",
177 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
184 * PUBLIC: int __db_addrem_read __P((void *, __db_addrem_args **));
187 __db_addrem_read(recbuf, argpp)
189 __db_addrem_args **argpp;
191 __db_addrem_args *argp;
194 argp = (__db_addrem_args *)malloc(sizeof(__db_addrem_args) +
198 argp->txnid = (DB_TXN *)&argp[1];
200 memcpy(&argp->type, bp, sizeof(argp->type));
201 bp += sizeof(argp->type);
202 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
203 bp += sizeof(argp->txnid->txnid);
204 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
205 bp += sizeof(DB_LSN);
206 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
207 bp += sizeof(argp->opcode);
208 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
209 bp += sizeof(argp->fileid);
210 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
211 bp += sizeof(argp->pgno);
212 memcpy(&argp->indx, bp, sizeof(argp->indx));
213 bp += sizeof(argp->indx);
214 memcpy(&argp->nbytes, bp, sizeof(argp->nbytes));
215 bp += sizeof(argp->nbytes);
216 memcpy(&argp->hdr.size, bp, sizeof(u_int32_t));
217 bp += sizeof(u_int32_t);
219 bp += argp->hdr.size;
220 memcpy(&argp->dbt.size, bp, sizeof(u_int32_t));
221 bp += sizeof(u_int32_t);
223 bp += argp->dbt.size;
224 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
225 bp += sizeof(argp->pagelsn);
231 * PUBLIC: int __db_split_log
232 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
233 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, DBT *,
234 * PUBLIC: DB_LSN *));
236 int __db_split_log(logp, txnid, ret_lsnp, flags,
237 opcode, fileid, pgno, pageimage, pagelsn)
249 DB_LSN *lsnp, null_lsn;
251 u_int32_t rectype, txn_num;
255 rectype = DB_db_split;
256 txn_num = txnid == NULL ? 0 : txnid->txnid;
262 lsnp = &txnid->last_lsn;
263 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
267 + sizeof(u_int32_t) + (pageimage == NULL ? 0 : pageimage->size)
269 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
273 memcpy(bp, &rectype, sizeof(rectype));
274 bp += sizeof(rectype);
275 memcpy(bp, &txn_num, sizeof(txn_num));
276 bp += sizeof(txn_num);
277 memcpy(bp, lsnp, sizeof(DB_LSN));
278 bp += sizeof(DB_LSN);
279 memcpy(bp, &opcode, sizeof(opcode));
280 bp += sizeof(opcode);
281 memcpy(bp, &fileid, sizeof(fileid));
282 bp += sizeof(fileid);
283 memcpy(bp, &pgno, sizeof(pgno));
285 if (pageimage == NULL) {
287 memcpy(bp, &zero, sizeof(u_int32_t));
288 bp += sizeof(u_int32_t);
290 memcpy(bp, &pageimage->size, sizeof(pageimage->size));
291 bp += sizeof(pageimage->size);
292 memcpy(bp, pageimage->data, pageimage->size);
293 bp += pageimage->size;
296 memcpy(bp, pagelsn, sizeof(*pagelsn));
298 memset(bp, 0, sizeof(*pagelsn));
299 bp += sizeof(*pagelsn);
301 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
302 fprintf(stderr, "Error in log record length");
304 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
306 txnid->last_lsn = *ret_lsnp;
312 * PUBLIC: int __db_split_print
313 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
317 __db_split_print(notused1, dbtp, lsnp, notused3, notused4)
324 __db_split_args *argp;
334 if((ret = __db_split_read(dbtp->data, &argp)) != 0)
336 printf("[%lu][%lu]db_split: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
338 (u_long)lsnp->offset,
340 (u_long)argp->txnid->txnid,
341 (u_long)argp->prev_lsn.file,
342 (u_long)argp->prev_lsn.offset);
343 printf("\topcode: %lu\n", (u_long)argp->opcode);
344 printf("\tfileid: %lu\n", (u_long)argp->fileid);
345 printf("\tpgno: %lu\n", (u_long)argp->pgno);
346 printf("\tpageimage: ");
347 for (i = 0; i < argp->pageimage.size; i++) {
348 c = ((char *)argp->pageimage.data)[i];
349 if (isprint(c) || c == 0xa)
355 printf("\tpagelsn: [%lu][%lu]\n",
356 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
363 * PUBLIC: int __db_split_read __P((void *, __db_split_args **));
366 __db_split_read(recbuf, argpp)
368 __db_split_args **argpp;
370 __db_split_args *argp;
373 argp = (__db_split_args *)malloc(sizeof(__db_split_args) +
377 argp->txnid = (DB_TXN *)&argp[1];
379 memcpy(&argp->type, bp, sizeof(argp->type));
380 bp += sizeof(argp->type);
381 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
382 bp += sizeof(argp->txnid->txnid);
383 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
384 bp += sizeof(DB_LSN);
385 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
386 bp += sizeof(argp->opcode);
387 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
388 bp += sizeof(argp->fileid);
389 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
390 bp += sizeof(argp->pgno);
391 memcpy(&argp->pageimage.size, bp, sizeof(u_int32_t));
392 bp += sizeof(u_int32_t);
393 argp->pageimage.data = bp;
394 bp += argp->pageimage.size;
395 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
396 bp += sizeof(argp->pagelsn);
402 * PUBLIC: int __db_big_log
403 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
404 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, db_pgno_t,
405 * PUBLIC: db_pgno_t, DBT *, DB_LSN *, DB_LSN *,
406 * PUBLIC: DB_LSN *));
408 int __db_big_log(logp, txnid, ret_lsnp, flags,
409 opcode, fileid, pgno, prev_pgno, next_pgno, dbt,
410 pagelsn, prevlsn, nextlsn)
426 DB_LSN *lsnp, null_lsn;
428 u_int32_t rectype, txn_num;
433 txn_num = txnid == NULL ? 0 : txnid->txnid;
439 lsnp = &txnid->last_lsn;
440 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
446 + sizeof(u_int32_t) + (dbt == NULL ? 0 : dbt->size)
450 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
454 memcpy(bp, &rectype, sizeof(rectype));
455 bp += sizeof(rectype);
456 memcpy(bp, &txn_num, sizeof(txn_num));
457 bp += sizeof(txn_num);
458 memcpy(bp, lsnp, sizeof(DB_LSN));
459 bp += sizeof(DB_LSN);
460 memcpy(bp, &opcode, sizeof(opcode));
461 bp += sizeof(opcode);
462 memcpy(bp, &fileid, sizeof(fileid));
463 bp += sizeof(fileid);
464 memcpy(bp, &pgno, sizeof(pgno));
466 memcpy(bp, &prev_pgno, sizeof(prev_pgno));
467 bp += sizeof(prev_pgno);
468 memcpy(bp, &next_pgno, sizeof(next_pgno));
469 bp += sizeof(next_pgno);
472 memcpy(bp, &zero, sizeof(u_int32_t));
473 bp += sizeof(u_int32_t);
475 memcpy(bp, &dbt->size, sizeof(dbt->size));
476 bp += sizeof(dbt->size);
477 memcpy(bp, dbt->data, dbt->size);
481 memcpy(bp, pagelsn, sizeof(*pagelsn));
483 memset(bp, 0, sizeof(*pagelsn));
484 bp += sizeof(*pagelsn);
486 memcpy(bp, prevlsn, sizeof(*prevlsn));
488 memset(bp, 0, sizeof(*prevlsn));
489 bp += sizeof(*prevlsn);
491 memcpy(bp, nextlsn, sizeof(*nextlsn));
493 memset(bp, 0, sizeof(*nextlsn));
494 bp += sizeof(*nextlsn);
496 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
497 fprintf(stderr, "Error in log record length");
499 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
501 txnid->last_lsn = *ret_lsnp;
507 * PUBLIC: int __db_big_print
508 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
512 __db_big_print(notused1, dbtp, lsnp, notused3, notused4)
529 if((ret = __db_big_read(dbtp->data, &argp)) != 0)
531 printf("[%lu][%lu]db_big: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
533 (u_long)lsnp->offset,
535 (u_long)argp->txnid->txnid,
536 (u_long)argp->prev_lsn.file,
537 (u_long)argp->prev_lsn.offset);
538 printf("\topcode: %lu\n", (u_long)argp->opcode);
539 printf("\tfileid: %lu\n", (u_long)argp->fileid);
540 printf("\tpgno: %lu\n", (u_long)argp->pgno);
541 printf("\tprev_pgno: %lu\n", (u_long)argp->prev_pgno);
542 printf("\tnext_pgno: %lu\n", (u_long)argp->next_pgno);
544 for (i = 0; i < argp->dbt.size; i++) {
545 c = ((char *)argp->dbt.data)[i];
546 if (isprint(c) || c == 0xa)
552 printf("\tpagelsn: [%lu][%lu]\n",
553 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
554 printf("\tprevlsn: [%lu][%lu]\n",
555 (u_long)argp->prevlsn.file, (u_long)argp->prevlsn.offset);
556 printf("\tnextlsn: [%lu][%lu]\n",
557 (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset);
564 * PUBLIC: int __db_big_read __P((void *, __db_big_args **));
567 __db_big_read(recbuf, argpp)
569 __db_big_args **argpp;
574 argp = (__db_big_args *)malloc(sizeof(__db_big_args) +
578 argp->txnid = (DB_TXN *)&argp[1];
580 memcpy(&argp->type, bp, sizeof(argp->type));
581 bp += sizeof(argp->type);
582 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
583 bp += sizeof(argp->txnid->txnid);
584 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
585 bp += sizeof(DB_LSN);
586 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
587 bp += sizeof(argp->opcode);
588 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
589 bp += sizeof(argp->fileid);
590 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
591 bp += sizeof(argp->pgno);
592 memcpy(&argp->prev_pgno, bp, sizeof(argp->prev_pgno));
593 bp += sizeof(argp->prev_pgno);
594 memcpy(&argp->next_pgno, bp, sizeof(argp->next_pgno));
595 bp += sizeof(argp->next_pgno);
596 memcpy(&argp->dbt.size, bp, sizeof(u_int32_t));
597 bp += sizeof(u_int32_t);
599 bp += argp->dbt.size;
600 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
601 bp += sizeof(argp->pagelsn);
602 memcpy(&argp->prevlsn, bp, sizeof(argp->prevlsn));
603 bp += sizeof(argp->prevlsn);
604 memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn));
605 bp += sizeof(argp->nextlsn);
611 * PUBLIC: int __db_ovref_log
612 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
613 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *));
615 int __db_ovref_log(logp, txnid, ret_lsnp, flags,
626 DB_LSN *lsnp, null_lsn;
627 u_int32_t rectype, txn_num;
631 rectype = DB_db_ovref;
632 txn_num = txnid == NULL ? 0 : txnid->txnid;
638 lsnp = &txnid->last_lsn;
639 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
643 if ((logrec.data = (void *)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));
658 memcpy(bp, lsn, sizeof(*lsn));
660 memset(bp, 0, sizeof(*lsn));
663 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
664 fprintf(stderr, "Error in log record length");
666 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
668 txnid->last_lsn = *ret_lsnp;
674 * PUBLIC: int __db_ovref_print
675 * 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("\tlsn: [%lu][%lu]\n",
708 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
715 * PUBLIC: int __db_ovref_read __P((void *, __db_ovref_args **));
718 __db_ovref_read(recbuf, argpp)
720 __db_ovref_args **argpp;
722 __db_ovref_args *argp;
725 argp = (__db_ovref_args *)malloc(sizeof(__db_ovref_args) +
729 argp->txnid = (DB_TXN *)&argp[1];
731 memcpy(&argp->type, bp, sizeof(argp->type));
732 bp += sizeof(argp->type);
733 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
734 bp += sizeof(argp->txnid->txnid);
735 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
736 bp += sizeof(DB_LSN);
737 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
738 bp += sizeof(argp->fileid);
739 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
740 bp += sizeof(argp->pgno);
741 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
742 bp += sizeof(argp->lsn);
748 * PUBLIC: int __db_relink_log
749 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
750 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t,
751 * PUBLIC: DB_LSN *, db_pgno_t, DB_LSN *));
753 int __db_relink_log(logp, txnid, ret_lsnp, flags,
754 fileid, pgno, lsn, prev, lsn_prev, next,
769 DB_LSN *lsnp, null_lsn;
770 u_int32_t rectype, txn_num;
774 rectype = DB_db_relink;
775 txn_num = txnid == NULL ? 0 : txnid->txnid;
781 lsnp = &txnid->last_lsn;
782 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
790 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
794 memcpy(bp, &rectype, sizeof(rectype));
795 bp += sizeof(rectype);
796 memcpy(bp, &txn_num, sizeof(txn_num));
797 bp += sizeof(txn_num);
798 memcpy(bp, lsnp, sizeof(DB_LSN));
799 bp += sizeof(DB_LSN);
800 memcpy(bp, &fileid, sizeof(fileid));
801 bp += sizeof(fileid);
802 memcpy(bp, &pgno, sizeof(pgno));
805 memcpy(bp, lsn, sizeof(*lsn));
807 memset(bp, 0, sizeof(*lsn));
809 memcpy(bp, &prev, sizeof(prev));
811 if (lsn_prev != NULL)
812 memcpy(bp, lsn_prev, sizeof(*lsn_prev));
814 memset(bp, 0, sizeof(*lsn_prev));
815 bp += sizeof(*lsn_prev);
816 memcpy(bp, &next, sizeof(next));
818 if (lsn_next != NULL)
819 memcpy(bp, lsn_next, sizeof(*lsn_next));
821 memset(bp, 0, sizeof(*lsn_next));
822 bp += sizeof(*lsn_next);
824 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
825 fprintf(stderr, "Error in log record length");
827 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
829 txnid->last_lsn = *ret_lsnp;
835 * PUBLIC: int __db_relink_print
836 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
840 __db_relink_print(notused1, dbtp, lsnp, notused3, notused4)
847 __db_relink_args *argp;
857 if((ret = __db_relink_read(dbtp->data, &argp)) != 0)
859 printf("[%lu][%lu]db_relink: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
861 (u_long)lsnp->offset,
863 (u_long)argp->txnid->txnid,
864 (u_long)argp->prev_lsn.file,
865 (u_long)argp->prev_lsn.offset);
866 printf("\tfileid: %lu\n", (u_long)argp->fileid);
867 printf("\tpgno: %lu\n", (u_long)argp->pgno);
868 printf("\tlsn: [%lu][%lu]\n",
869 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
870 printf("\tprev: %lu\n", (u_long)argp->prev);
871 printf("\tlsn_prev: [%lu][%lu]\n",
872 (u_long)argp->lsn_prev.file, (u_long)argp->lsn_prev.offset);
873 printf("\tnext: %lu\n", (u_long)argp->next);
874 printf("\tlsn_next: [%lu][%lu]\n",
875 (u_long)argp->lsn_next.file, (u_long)argp->lsn_next.offset);
882 * PUBLIC: int __db_relink_read __P((void *, __db_relink_args **));
885 __db_relink_read(recbuf, argpp)
887 __db_relink_args **argpp;
889 __db_relink_args *argp;
892 argp = (__db_relink_args *)malloc(sizeof(__db_relink_args) +
896 argp->txnid = (DB_TXN *)&argp[1];
898 memcpy(&argp->type, bp, sizeof(argp->type));
899 bp += sizeof(argp->type);
900 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
901 bp += sizeof(argp->txnid->txnid);
902 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
903 bp += sizeof(DB_LSN);
904 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
905 bp += sizeof(argp->fileid);
906 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
907 bp += sizeof(argp->pgno);
908 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
909 bp += sizeof(argp->lsn);
910 memcpy(&argp->prev, bp, sizeof(argp->prev));
911 bp += sizeof(argp->prev);
912 memcpy(&argp->lsn_prev, bp, sizeof(argp->lsn_prev));
913 bp += sizeof(argp->lsn_prev);
914 memcpy(&argp->next, bp, sizeof(argp->next));
915 bp += sizeof(argp->next);
916 memcpy(&argp->lsn_next, bp, sizeof(argp->lsn_next));
917 bp += sizeof(argp->lsn_next);
923 * PUBLIC: int __db_addpage_log
924 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
925 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t,
926 * PUBLIC: DB_LSN *));
928 int __db_addpage_log(logp, txnid, ret_lsnp, flags,
929 fileid, pgno, lsn, nextpgno, nextlsn)
941 DB_LSN *lsnp, null_lsn;
942 u_int32_t rectype, txn_num;
946 rectype = DB_db_addpage;
947 txn_num = txnid == NULL ? 0 : txnid->txnid;
953 lsnp = &txnid->last_lsn;
954 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
960 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
964 memcpy(bp, &rectype, sizeof(rectype));
965 bp += sizeof(rectype);
966 memcpy(bp, &txn_num, sizeof(txn_num));
967 bp += sizeof(txn_num);
968 memcpy(bp, lsnp, sizeof(DB_LSN));
969 bp += sizeof(DB_LSN);
970 memcpy(bp, &fileid, sizeof(fileid));
971 bp += sizeof(fileid);
972 memcpy(bp, &pgno, sizeof(pgno));
975 memcpy(bp, lsn, sizeof(*lsn));
977 memset(bp, 0, sizeof(*lsn));
979 memcpy(bp, &nextpgno, sizeof(nextpgno));
980 bp += sizeof(nextpgno);
982 memcpy(bp, nextlsn, sizeof(*nextlsn));
984 memset(bp, 0, sizeof(*nextlsn));
985 bp += sizeof(*nextlsn);
987 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
988 fprintf(stderr, "Error in log record length");
990 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
992 txnid->last_lsn = *ret_lsnp;
998 * PUBLIC: int __db_addpage_print
999 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1003 __db_addpage_print(notused1, dbtp, lsnp, notused3, notused4)
1010 __db_addpage_args *argp;
1020 if((ret = __db_addpage_read(dbtp->data, &argp)) != 0)
1022 printf("[%lu][%lu]db_addpage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1024 (u_long)lsnp->offset,
1026 (u_long)argp->txnid->txnid,
1027 (u_long)argp->prev_lsn.file,
1028 (u_long)argp->prev_lsn.offset);
1029 printf("\tfileid: %lu\n", (u_long)argp->fileid);
1030 printf("\tpgno: %lu\n", (u_long)argp->pgno);
1031 printf("\tlsn: [%lu][%lu]\n",
1032 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
1033 printf("\tnextpgno: %lu\n", (u_long)argp->nextpgno);
1034 printf("\tnextlsn: [%lu][%lu]\n",
1035 (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset);
1042 * PUBLIC: int __db_addpage_read __P((void *, __db_addpage_args **));
1045 __db_addpage_read(recbuf, argpp)
1047 __db_addpage_args **argpp;
1049 __db_addpage_args *argp;
1052 argp = (__db_addpage_args *)malloc(sizeof(__db_addpage_args) +
1056 argp->txnid = (DB_TXN *)&argp[1];
1058 memcpy(&argp->type, bp, sizeof(argp->type));
1059 bp += sizeof(argp->type);
1060 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
1061 bp += sizeof(argp->txnid->txnid);
1062 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
1063 bp += sizeof(DB_LSN);
1064 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
1065 bp += sizeof(argp->fileid);
1066 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
1067 bp += sizeof(argp->pgno);
1068 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
1069 bp += sizeof(argp->lsn);
1070 memcpy(&argp->nextpgno, bp, sizeof(argp->nextpgno));
1071 bp += sizeof(argp->nextpgno);
1072 memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn));
1073 bp += sizeof(argp->nextlsn);
1079 * PUBLIC: int __db_debug_log
1080 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
1081 * PUBLIC: DBT *, u_int32_t, DBT *, DBT *,
1082 * PUBLIC: u_int32_t));
1084 int __db_debug_log(logp, txnid, ret_lsnp, flags,
1085 op, fileid, key, data, arg_flags)
1094 u_int32_t arg_flags;
1097 DB_LSN *lsnp, null_lsn;
1099 u_int32_t rectype, txn_num;
1103 rectype = DB_db_debug;
1104 txn_num = txnid == NULL ? 0 : txnid->txnid;
1105 if (txnid == NULL) {
1107 null_lsn.offset = 0;
1110 lsnp = &txnid->last_lsn;
1111 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
1112 + sizeof(u_int32_t) + (op == NULL ? 0 : op->size)
1114 + sizeof(u_int32_t) + (key == NULL ? 0 : key->size)
1115 + sizeof(u_int32_t) + (data == NULL ? 0 : data->size)
1116 + sizeof(arg_flags);
1117 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
1121 memcpy(bp, &rectype, sizeof(rectype));
1122 bp += sizeof(rectype);
1123 memcpy(bp, &txn_num, sizeof(txn_num));
1124 bp += sizeof(txn_num);
1125 memcpy(bp, lsnp, sizeof(DB_LSN));
1126 bp += sizeof(DB_LSN);
1129 memcpy(bp, &zero, sizeof(u_int32_t));
1130 bp += sizeof(u_int32_t);
1132 memcpy(bp, &op->size, sizeof(op->size));
1133 bp += sizeof(op->size);
1134 memcpy(bp, op->data, op->size);
1137 memcpy(bp, &fileid, sizeof(fileid));
1138 bp += sizeof(fileid);
1141 memcpy(bp, &zero, sizeof(u_int32_t));
1142 bp += sizeof(u_int32_t);
1144 memcpy(bp, &key->size, sizeof(key->size));
1145 bp += sizeof(key->size);
1146 memcpy(bp, key->data, key->size);
1151 memcpy(bp, &zero, sizeof(u_int32_t));
1152 bp += sizeof(u_int32_t);
1154 memcpy(bp, &data->size, sizeof(data->size));
1155 bp += sizeof(data->size);
1156 memcpy(bp, data->data, data->size);
1159 memcpy(bp, &arg_flags, sizeof(arg_flags));
1160 bp += sizeof(arg_flags);
1162 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
1163 fprintf(stderr, "Error in log record length");
1165 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
1167 txnid->last_lsn = *ret_lsnp;
1173 * PUBLIC: int __db_debug_print
1174 * 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 *)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 *)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;
1328 * PUBLIC: int __db_noop_print
1329 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1333 __db_noop_print(notused1, dbtp, lsnp, notused3, notused4)
1340 __db_noop_args *argp;
1350 if((ret = __db_noop_read(dbtp->data, &argp)) != 0)
1352 printf("[%lu][%lu]db_noop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1354 (u_long)lsnp->offset,
1356 (u_long)argp->txnid->txnid,
1357 (u_long)argp->prev_lsn.file,
1358 (u_long)argp->prev_lsn.offset);
1365 * PUBLIC: int __db_noop_read __P((void *, __db_noop_args **));
1368 __db_noop_read(recbuf, argpp)
1370 __db_noop_args **argpp;
1372 __db_noop_args *argp;
1375 argp = (__db_noop_args *)malloc(sizeof(__db_noop_args) +
1379 argp->txnid = (DB_TXN *)&argp[1];
1381 memcpy(&argp->type, bp, sizeof(argp->type));
1382 bp += sizeof(argp->type);
1383 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
1384 bp += sizeof(argp->txnid->txnid);
1385 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
1386 bp += sizeof(DB_LSN);
1392 * PUBLIC: int __db_init_print __P((DB_ENV *));
1395 __db_init_print(dbenv)
1400 if ((ret = __db_add_recovery(dbenv,
1401 __db_addrem_print, DB_db_addrem)) != 0)
1403 if ((ret = __db_add_recovery(dbenv,
1404 __db_split_print, DB_db_split)) != 0)
1406 if ((ret = __db_add_recovery(dbenv,
1407 __db_big_print, DB_db_big)) != 0)
1409 if ((ret = __db_add_recovery(dbenv,
1410 __db_ovref_print, DB_db_ovref)) != 0)
1412 if ((ret = __db_add_recovery(dbenv,
1413 __db_relink_print, DB_db_relink)) != 0)
1415 if ((ret = __db_add_recovery(dbenv,
1416 __db_addpage_print, DB_db_addpage)) != 0)
1418 if ((ret = __db_add_recovery(dbenv,
1419 __db_debug_print, DB_db_debug)) != 0)
1421 if ((ret = __db_add_recovery(dbenv,
1422 __db_noop_print, DB_db_noop)) != 0)
1428 * PUBLIC: int __db_init_recover __P((DB_ENV *));
1431 __db_init_recover(dbenv)
1436 if ((ret = __db_add_recovery(dbenv,
1437 __db_addrem_recover, DB_db_addrem)) != 0)
1439 if ((ret = __db_add_recovery(dbenv,
1440 __db_split_recover, DB_db_split)) != 0)
1442 if ((ret = __db_add_recovery(dbenv,
1443 __db_big_recover, DB_db_big)) != 0)
1445 if ((ret = __db_add_recovery(dbenv,
1446 __db_ovref_recover, DB_db_ovref)) != 0)
1448 if ((ret = __db_add_recovery(dbenv,
1449 __db_relink_recover, DB_db_relink)) != 0)
1451 if ((ret = __db_add_recovery(dbenv,
1452 __db_addpage_recover, DB_db_addpage)) != 0)
1454 if ((ret = __db_add_recovery(dbenv,
1455 __db_debug_recover, DB_db_debug)) != 0)
1457 if ((ret = __db_add_recovery(dbenv,
1458 __db_noop_recover, DB_db_noop)) != 0)