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 *)__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 *));
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 *)__db_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 *)__db_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;
307 __db_free(logrec.data);
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 *)__db_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 *)__db_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;
502 __db_free(logrec.data);
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 *)__db_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, int32_t, DB_LSN *));
615 int __db_ovref_log(logp, txnid, ret_lsnp, flags,
616 fileid, pgno, adjust, lsn)
627 DB_LSN *lsnp, null_lsn;
628 u_int32_t rectype, txn_num;
632 rectype = DB_db_ovref;
633 txn_num = txnid == NULL ? 0 : txnid->txnid;
639 lsnp = &txnid->last_lsn;
640 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
645 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
649 memcpy(bp, &rectype, sizeof(rectype));
650 bp += sizeof(rectype);
651 memcpy(bp, &txn_num, sizeof(txn_num));
652 bp += sizeof(txn_num);
653 memcpy(bp, lsnp, sizeof(DB_LSN));
654 bp += sizeof(DB_LSN);
655 memcpy(bp, &fileid, sizeof(fileid));
656 bp += sizeof(fileid);
657 memcpy(bp, &pgno, sizeof(pgno));
659 memcpy(bp, &adjust, sizeof(adjust));
660 bp += sizeof(adjust);
662 memcpy(bp, lsn, sizeof(*lsn));
664 memset(bp, 0, sizeof(*lsn));
667 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
668 fprintf(stderr, "Error in log record length");
670 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
672 txnid->last_lsn = *ret_lsnp;
673 __db_free(logrec.data);
678 * PUBLIC: int __db_ovref_print
679 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
683 __db_ovref_print(notused1, dbtp, lsnp, notused3, notused4)
690 __db_ovref_args *argp;
700 if ((ret = __db_ovref_read(dbtp->data, &argp)) != 0)
702 printf("[%lu][%lu]db_ovref: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
704 (u_long)lsnp->offset,
706 (u_long)argp->txnid->txnid,
707 (u_long)argp->prev_lsn.file,
708 (u_long)argp->prev_lsn.offset);
709 printf("\tfileid: %lu\n", (u_long)argp->fileid);
710 printf("\tpgno: %lu\n", (u_long)argp->pgno);
711 printf("\tadjust: %ld\n", (long)argp->adjust);
712 printf("\tlsn: [%lu][%lu]\n",
713 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
720 * PUBLIC: int __db_ovref_read __P((void *, __db_ovref_args **));
723 __db_ovref_read(recbuf, argpp)
725 __db_ovref_args **argpp;
727 __db_ovref_args *argp;
730 argp = (__db_ovref_args *)__db_malloc(sizeof(__db_ovref_args) +
734 argp->txnid = (DB_TXN *)&argp[1];
736 memcpy(&argp->type, bp, sizeof(argp->type));
737 bp += sizeof(argp->type);
738 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
739 bp += sizeof(argp->txnid->txnid);
740 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
741 bp += sizeof(DB_LSN);
742 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
743 bp += sizeof(argp->fileid);
744 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
745 bp += sizeof(argp->pgno);
746 memcpy(&argp->adjust, bp, sizeof(argp->adjust));
747 bp += sizeof(argp->adjust);
748 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
749 bp += sizeof(argp->lsn);
755 * PUBLIC: int __db_relink_log
756 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
757 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t,
758 * PUBLIC: DB_LSN *, db_pgno_t, DB_LSN *));
760 int __db_relink_log(logp, txnid, ret_lsnp, flags,
761 fileid, pgno, lsn, prev, lsn_prev, next,
776 DB_LSN *lsnp, null_lsn;
777 u_int32_t rectype, txn_num;
781 rectype = DB_db_relink;
782 txn_num = txnid == NULL ? 0 : txnid->txnid;
788 lsnp = &txnid->last_lsn;
789 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
797 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
801 memcpy(bp, &rectype, sizeof(rectype));
802 bp += sizeof(rectype);
803 memcpy(bp, &txn_num, sizeof(txn_num));
804 bp += sizeof(txn_num);
805 memcpy(bp, lsnp, sizeof(DB_LSN));
806 bp += sizeof(DB_LSN);
807 memcpy(bp, &fileid, sizeof(fileid));
808 bp += sizeof(fileid);
809 memcpy(bp, &pgno, sizeof(pgno));
812 memcpy(bp, lsn, sizeof(*lsn));
814 memset(bp, 0, sizeof(*lsn));
816 memcpy(bp, &prev, sizeof(prev));
818 if (lsn_prev != NULL)
819 memcpy(bp, lsn_prev, sizeof(*lsn_prev));
821 memset(bp, 0, sizeof(*lsn_prev));
822 bp += sizeof(*lsn_prev);
823 memcpy(bp, &next, sizeof(next));
825 if (lsn_next != NULL)
826 memcpy(bp, lsn_next, sizeof(*lsn_next));
828 memset(bp, 0, sizeof(*lsn_next));
829 bp += sizeof(*lsn_next);
831 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
832 fprintf(stderr, "Error in log record length");
834 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
836 txnid->last_lsn = *ret_lsnp;
837 __db_free(logrec.data);
842 * PUBLIC: int __db_relink_print
843 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
847 __db_relink_print(notused1, dbtp, lsnp, notused3, notused4)
854 __db_relink_args *argp;
864 if ((ret = __db_relink_read(dbtp->data, &argp)) != 0)
866 printf("[%lu][%lu]db_relink: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
868 (u_long)lsnp->offset,
870 (u_long)argp->txnid->txnid,
871 (u_long)argp->prev_lsn.file,
872 (u_long)argp->prev_lsn.offset);
873 printf("\tfileid: %lu\n", (u_long)argp->fileid);
874 printf("\tpgno: %lu\n", (u_long)argp->pgno);
875 printf("\tlsn: [%lu][%lu]\n",
876 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
877 printf("\tprev: %lu\n", (u_long)argp->prev);
878 printf("\tlsn_prev: [%lu][%lu]\n",
879 (u_long)argp->lsn_prev.file, (u_long)argp->lsn_prev.offset);
880 printf("\tnext: %lu\n", (u_long)argp->next);
881 printf("\tlsn_next: [%lu][%lu]\n",
882 (u_long)argp->lsn_next.file, (u_long)argp->lsn_next.offset);
889 * PUBLIC: int __db_relink_read __P((void *, __db_relink_args **));
892 __db_relink_read(recbuf, argpp)
894 __db_relink_args **argpp;
896 __db_relink_args *argp;
899 argp = (__db_relink_args *)__db_malloc(sizeof(__db_relink_args) +
903 argp->txnid = (DB_TXN *)&argp[1];
905 memcpy(&argp->type, bp, sizeof(argp->type));
906 bp += sizeof(argp->type);
907 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
908 bp += sizeof(argp->txnid->txnid);
909 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
910 bp += sizeof(DB_LSN);
911 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
912 bp += sizeof(argp->fileid);
913 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
914 bp += sizeof(argp->pgno);
915 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
916 bp += sizeof(argp->lsn);
917 memcpy(&argp->prev, bp, sizeof(argp->prev));
918 bp += sizeof(argp->prev);
919 memcpy(&argp->lsn_prev, bp, sizeof(argp->lsn_prev));
920 bp += sizeof(argp->lsn_prev);
921 memcpy(&argp->next, bp, sizeof(argp->next));
922 bp += sizeof(argp->next);
923 memcpy(&argp->lsn_next, bp, sizeof(argp->lsn_next));
924 bp += sizeof(argp->lsn_next);
930 * PUBLIC: int __db_addpage_log
931 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
932 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t,
933 * PUBLIC: DB_LSN *));
935 int __db_addpage_log(logp, txnid, ret_lsnp, flags,
936 fileid, pgno, lsn, nextpgno, nextlsn)
948 DB_LSN *lsnp, null_lsn;
949 u_int32_t rectype, txn_num;
953 rectype = DB_db_addpage;
954 txn_num = txnid == NULL ? 0 : txnid->txnid;
960 lsnp = &txnid->last_lsn;
961 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
967 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
971 memcpy(bp, &rectype, sizeof(rectype));
972 bp += sizeof(rectype);
973 memcpy(bp, &txn_num, sizeof(txn_num));
974 bp += sizeof(txn_num);
975 memcpy(bp, lsnp, sizeof(DB_LSN));
976 bp += sizeof(DB_LSN);
977 memcpy(bp, &fileid, sizeof(fileid));
978 bp += sizeof(fileid);
979 memcpy(bp, &pgno, sizeof(pgno));
982 memcpy(bp, lsn, sizeof(*lsn));
984 memset(bp, 0, sizeof(*lsn));
986 memcpy(bp, &nextpgno, sizeof(nextpgno));
987 bp += sizeof(nextpgno);
989 memcpy(bp, nextlsn, sizeof(*nextlsn));
991 memset(bp, 0, sizeof(*nextlsn));
992 bp += sizeof(*nextlsn);
994 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
995 fprintf(stderr, "Error in log record length");
997 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
999 txnid->last_lsn = *ret_lsnp;
1000 __db_free(logrec.data);
1005 * PUBLIC: int __db_addpage_print
1006 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1010 __db_addpage_print(notused1, dbtp, lsnp, notused3, notused4)
1017 __db_addpage_args *argp;
1027 if ((ret = __db_addpage_read(dbtp->data, &argp)) != 0)
1029 printf("[%lu][%lu]db_addpage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1031 (u_long)lsnp->offset,
1033 (u_long)argp->txnid->txnid,
1034 (u_long)argp->prev_lsn.file,
1035 (u_long)argp->prev_lsn.offset);
1036 printf("\tfileid: %lu\n", (u_long)argp->fileid);
1037 printf("\tpgno: %lu\n", (u_long)argp->pgno);
1038 printf("\tlsn: [%lu][%lu]\n",
1039 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
1040 printf("\tnextpgno: %lu\n", (u_long)argp->nextpgno);
1041 printf("\tnextlsn: [%lu][%lu]\n",
1042 (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset);
1049 * PUBLIC: int __db_addpage_read __P((void *, __db_addpage_args **));
1052 __db_addpage_read(recbuf, argpp)
1054 __db_addpage_args **argpp;
1056 __db_addpage_args *argp;
1059 argp = (__db_addpage_args *)__db_malloc(sizeof(__db_addpage_args) +
1063 argp->txnid = (DB_TXN *)&argp[1];
1065 memcpy(&argp->type, bp, sizeof(argp->type));
1066 bp += sizeof(argp->type);
1067 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
1068 bp += sizeof(argp->txnid->txnid);
1069 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
1070 bp += sizeof(DB_LSN);
1071 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
1072 bp += sizeof(argp->fileid);
1073 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
1074 bp += sizeof(argp->pgno);
1075 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
1076 bp += sizeof(argp->lsn);
1077 memcpy(&argp->nextpgno, bp, sizeof(argp->nextpgno));
1078 bp += sizeof(argp->nextpgno);
1079 memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn));
1080 bp += sizeof(argp->nextlsn);
1086 * PUBLIC: int __db_debug_log
1087 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
1088 * PUBLIC: DBT *, u_int32_t, DBT *, DBT *,
1089 * PUBLIC: u_int32_t));
1091 int __db_debug_log(logp, txnid, ret_lsnp, flags,
1092 op, fileid, key, data, arg_flags)
1101 u_int32_t arg_flags;
1104 DB_LSN *lsnp, null_lsn;
1106 u_int32_t rectype, txn_num;
1110 rectype = DB_db_debug;
1111 txn_num = txnid == NULL ? 0 : txnid->txnid;
1112 if (txnid == NULL) {
1114 null_lsn.offset = 0;
1117 lsnp = &txnid->last_lsn;
1118 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
1119 + sizeof(u_int32_t) + (op == NULL ? 0 : op->size)
1121 + sizeof(u_int32_t) + (key == NULL ? 0 : key->size)
1122 + sizeof(u_int32_t) + (data == NULL ? 0 : data->size)
1123 + sizeof(arg_flags);
1124 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
1128 memcpy(bp, &rectype, sizeof(rectype));
1129 bp += sizeof(rectype);
1130 memcpy(bp, &txn_num, sizeof(txn_num));
1131 bp += sizeof(txn_num);
1132 memcpy(bp, lsnp, sizeof(DB_LSN));
1133 bp += sizeof(DB_LSN);
1136 memcpy(bp, &zero, sizeof(u_int32_t));
1137 bp += sizeof(u_int32_t);
1139 memcpy(bp, &op->size, sizeof(op->size));
1140 bp += sizeof(op->size);
1141 memcpy(bp, op->data, op->size);
1144 memcpy(bp, &fileid, sizeof(fileid));
1145 bp += sizeof(fileid);
1148 memcpy(bp, &zero, sizeof(u_int32_t));
1149 bp += sizeof(u_int32_t);
1151 memcpy(bp, &key->size, sizeof(key->size));
1152 bp += sizeof(key->size);
1153 memcpy(bp, key->data, key->size);
1158 memcpy(bp, &zero, sizeof(u_int32_t));
1159 bp += sizeof(u_int32_t);
1161 memcpy(bp, &data->size, sizeof(data->size));
1162 bp += sizeof(data->size);
1163 memcpy(bp, data->data, data->size);
1166 memcpy(bp, &arg_flags, sizeof(arg_flags));
1167 bp += sizeof(arg_flags);
1169 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
1170 fprintf(stderr, "Error in log record length");
1172 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
1174 txnid->last_lsn = *ret_lsnp;
1175 __db_free(logrec.data);
1180 * PUBLIC: int __db_debug_print
1181 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1185 __db_debug_print(notused1, dbtp, lsnp, notused3, notused4)
1192 __db_debug_args *argp;
1202 if ((ret = __db_debug_read(dbtp->data, &argp)) != 0)
1204 printf("[%lu][%lu]db_debug: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1206 (u_long)lsnp->offset,
1208 (u_long)argp->txnid->txnid,
1209 (u_long)argp->prev_lsn.file,
1210 (u_long)argp->prev_lsn.offset);
1212 for (i = 0; i < argp->op.size; i++) {
1213 c = ((char *)argp->op.data)[i];
1214 if (isprint(c) || c == 0xa)
1220 printf("\tfileid: %lu\n", (u_long)argp->fileid);
1222 for (i = 0; i < argp->key.size; i++) {
1223 c = ((char *)argp->key.data)[i];
1224 if (isprint(c) || c == 0xa)
1231 for (i = 0; i < argp->data.size; i++) {
1232 c = ((char *)argp->data.data)[i];
1233 if (isprint(c) || c == 0xa)
1239 printf("\targ_flags: %lu\n", (u_long)argp->arg_flags);
1246 * PUBLIC: int __db_debug_read __P((void *, __db_debug_args **));
1249 __db_debug_read(recbuf, argpp)
1251 __db_debug_args **argpp;
1253 __db_debug_args *argp;
1256 argp = (__db_debug_args *)__db_malloc(sizeof(__db_debug_args) +
1260 argp->txnid = (DB_TXN *)&argp[1];
1262 memcpy(&argp->type, bp, sizeof(argp->type));
1263 bp += sizeof(argp->type);
1264 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
1265 bp += sizeof(argp->txnid->txnid);
1266 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
1267 bp += sizeof(DB_LSN);
1268 memcpy(&argp->op.size, bp, sizeof(u_int32_t));
1269 bp += sizeof(u_int32_t);
1271 bp += argp->op.size;
1272 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
1273 bp += sizeof(argp->fileid);
1274 memcpy(&argp->key.size, bp, sizeof(u_int32_t));
1275 bp += sizeof(u_int32_t);
1276 argp->key.data = bp;
1277 bp += argp->key.size;
1278 memcpy(&argp->data.size, bp, sizeof(u_int32_t));
1279 bp += sizeof(u_int32_t);
1280 argp->data.data = bp;
1281 bp += argp->data.size;
1282 memcpy(&argp->arg_flags, bp, sizeof(argp->arg_flags));
1283 bp += sizeof(argp->arg_flags);
1289 * PUBLIC: int __db_noop_log
1290 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t));
1292 int __db_noop_log(logp, txnid, ret_lsnp, flags)
1299 DB_LSN *lsnp, null_lsn;
1300 u_int32_t rectype, txn_num;
1304 rectype = DB_db_noop;
1305 txn_num = txnid == NULL ? 0 : txnid->txnid;
1306 if (txnid == NULL) {
1308 null_lsn.offset = 0;
1311 lsnp = &txnid->last_lsn;
1312 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN);
1313 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
1317 memcpy(bp, &rectype, sizeof(rectype));
1318 bp += sizeof(rectype);
1319 memcpy(bp, &txn_num, sizeof(txn_num));
1320 bp += sizeof(txn_num);
1321 memcpy(bp, lsnp, sizeof(DB_LSN));
1322 bp += sizeof(DB_LSN);
1324 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
1325 fprintf(stderr, "Error in log record length");
1327 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
1329 txnid->last_lsn = *ret_lsnp;
1330 __db_free(logrec.data);
1335 * PUBLIC: int __db_noop_print
1336 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1340 __db_noop_print(notused1, dbtp, lsnp, notused3, notused4)
1347 __db_noop_args *argp;
1357 if ((ret = __db_noop_read(dbtp->data, &argp)) != 0)
1359 printf("[%lu][%lu]db_noop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1361 (u_long)lsnp->offset,
1363 (u_long)argp->txnid->txnid,
1364 (u_long)argp->prev_lsn.file,
1365 (u_long)argp->prev_lsn.offset);
1372 * PUBLIC: int __db_noop_read __P((void *, __db_noop_args **));
1375 __db_noop_read(recbuf, argpp)
1377 __db_noop_args **argpp;
1379 __db_noop_args *argp;
1382 argp = (__db_noop_args *)__db_malloc(sizeof(__db_noop_args) +
1386 argp->txnid = (DB_TXN *)&argp[1];
1388 memcpy(&argp->type, bp, sizeof(argp->type));
1389 bp += sizeof(argp->type);
1390 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
1391 bp += sizeof(argp->txnid->txnid);
1392 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
1393 bp += sizeof(DB_LSN);
1399 * PUBLIC: int __db_init_print __P((DB_ENV *));
1402 __db_init_print(dbenv)
1407 if ((ret = __db_add_recovery(dbenv,
1408 __db_addrem_print, DB_db_addrem)) != 0)
1410 if ((ret = __db_add_recovery(dbenv,
1411 __db_split_print, DB_db_split)) != 0)
1413 if ((ret = __db_add_recovery(dbenv,
1414 __db_big_print, DB_db_big)) != 0)
1416 if ((ret = __db_add_recovery(dbenv,
1417 __db_ovref_print, DB_db_ovref)) != 0)
1419 if ((ret = __db_add_recovery(dbenv,
1420 __db_relink_print, DB_db_relink)) != 0)
1422 if ((ret = __db_add_recovery(dbenv,
1423 __db_addpage_print, DB_db_addpage)) != 0)
1425 if ((ret = __db_add_recovery(dbenv,
1426 __db_debug_print, DB_db_debug)) != 0)
1428 if ((ret = __db_add_recovery(dbenv,
1429 __db_noop_print, DB_db_noop)) != 0)
1435 * PUBLIC: int __db_init_recover __P((DB_ENV *));
1438 __db_init_recover(dbenv)
1443 if ((ret = __db_add_recovery(dbenv,
1444 __db_addrem_recover, DB_db_addrem)) != 0)
1446 if ((ret = __db_add_recovery(dbenv,
1447 __db_split_recover, DB_db_split)) != 0)
1449 if ((ret = __db_add_recovery(dbenv,
1450 __db_big_recover, DB_db_big)) != 0)
1452 if ((ret = __db_add_recovery(dbenv,
1453 __db_ovref_recover, DB_db_ovref)) != 0)
1455 if ((ret = __db_add_recovery(dbenv,
1456 __db_relink_recover, DB_db_relink)) != 0)
1458 if ((ret = __db_add_recovery(dbenv,
1459 __db_addpage_recover, DB_db_addpage)) != 0)
1461 if ((ret = __db_add_recovery(dbenv,
1462 __db_debug_recover, DB_db_debug)) != 0)
1464 if ((ret = __db_add_recovery(dbenv,
1465 __db_noop_recover, DB_db_noop)) != 0)