1 /* Do not edit: automatically built by dist/db_gen.sh. */
4 #ifndef NO_SYSTEM_INCLUDES
15 #include "db_dispatch.h"
18 #include "common_ext.h"
21 * PUBLIC: int __ham_insdel_log
22 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
23 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, u_int32_t,
24 * PUBLIC: DB_LSN *, DBT *, DBT *));
26 int __ham_insdel_log(logp, txnid, ret_lsnp, flags,
27 opcode, fileid, pgno, ndx, pagelsn, key,
42 DB_LSN *lsnp, null_lsn;
44 u_int32_t rectype, txn_num;
48 rectype = DB_ham_insdel;
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) + (key == NULL ? 0 : key->size)
63 + sizeof(u_int32_t) + (data == NULL ? 0 : data->size);
64 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
68 memcpy(bp, &rectype, sizeof(rectype));
69 bp += sizeof(rectype);
70 memcpy(bp, &txn_num, sizeof(txn_num));
71 bp += sizeof(txn_num);
72 memcpy(bp, lsnp, sizeof(DB_LSN));
74 memcpy(bp, &opcode, sizeof(opcode));
76 memcpy(bp, &fileid, sizeof(fileid));
78 memcpy(bp, &pgno, sizeof(pgno));
80 memcpy(bp, &ndx, sizeof(ndx));
83 memcpy(bp, pagelsn, sizeof(*pagelsn));
85 memset(bp, 0, sizeof(*pagelsn));
86 bp += sizeof(*pagelsn);
89 memcpy(bp, &zero, sizeof(u_int32_t));
90 bp += sizeof(u_int32_t);
92 memcpy(bp, &key->size, sizeof(key->size));
93 bp += sizeof(key->size);
94 memcpy(bp, key->data, key->size);
99 memcpy(bp, &zero, sizeof(u_int32_t));
100 bp += sizeof(u_int32_t);
102 memcpy(bp, &data->size, sizeof(data->size));
103 bp += sizeof(data->size);
104 memcpy(bp, data->data, data->size);
108 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
109 fprintf(stderr, "Error in log record length");
111 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
113 txnid->last_lsn = *ret_lsnp;
119 * PUBLIC: int __ham_insdel_print
120 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
124 __ham_insdel_print(notused1, dbtp, lsnp, notused3, notused4)
131 __ham_insdel_args *argp;
141 if((ret = __ham_insdel_read(dbtp->data, &argp)) != 0)
143 printf("[%lu][%lu]ham_insdel: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
145 (u_long)lsnp->offset,
147 (u_long)argp->txnid->txnid,
148 (u_long)argp->prev_lsn.file,
149 (u_long)argp->prev_lsn.offset);
150 printf("\topcode: %lu\n", (u_long)argp->opcode);
151 printf("\tfileid: %lu\n", (u_long)argp->fileid);
152 printf("\tpgno: %lu\n", (u_long)argp->pgno);
153 printf("\tndx: %lu\n", (u_long)argp->ndx);
154 printf("\tpagelsn: [%lu][%lu]\n",
155 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
157 for (i = 0; i < argp->key.size; i++) {
158 c = ((char *)argp->key.data)[i];
159 if (isprint(c) || c == 0xa)
166 for (i = 0; i < argp->data.size; i++) {
167 c = ((char *)argp->data.data)[i];
168 if (isprint(c) || c == 0xa)
180 * PUBLIC: int __ham_insdel_read __P((void *, __ham_insdel_args **));
183 __ham_insdel_read(recbuf, argpp)
185 __ham_insdel_args **argpp;
187 __ham_insdel_args *argp;
190 argp = (__ham_insdel_args *)malloc(sizeof(__ham_insdel_args) +
194 argp->txnid = (DB_TXN *)&argp[1];
196 memcpy(&argp->type, bp, sizeof(argp->type));
197 bp += sizeof(argp->type);
198 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
199 bp += sizeof(argp->txnid->txnid);
200 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
201 bp += sizeof(DB_LSN);
202 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
203 bp += sizeof(argp->opcode);
204 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
205 bp += sizeof(argp->fileid);
206 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
207 bp += sizeof(argp->pgno);
208 memcpy(&argp->ndx, bp, sizeof(argp->ndx));
209 bp += sizeof(argp->ndx);
210 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
211 bp += sizeof(argp->pagelsn);
212 memcpy(&argp->key.size, bp, sizeof(u_int32_t));
213 bp += sizeof(u_int32_t);
215 bp += argp->key.size;
216 memcpy(&argp->data.size, bp, sizeof(u_int32_t));
217 bp += sizeof(u_int32_t);
218 argp->data.data = bp;
219 bp += argp->data.size;
225 * PUBLIC: int __ham_newpage_log
226 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
227 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, DB_LSN *,
228 * PUBLIC: db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *));
230 int __ham_newpage_log(logp, txnid, ret_lsnp, flags,
231 opcode, fileid, prev_pgno, prevlsn, new_pgno, pagelsn,
247 DB_LSN *lsnp, null_lsn;
248 u_int32_t rectype, txn_num;
252 rectype = DB_ham_newpage;
253 txn_num = txnid == NULL ? 0 : txnid->txnid;
259 lsnp = &txnid->last_lsn;
260 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
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, &prev_pgno, sizeof(prev_pgno));
284 bp += sizeof(prev_pgno);
286 memcpy(bp, prevlsn, sizeof(*prevlsn));
288 memset(bp, 0, sizeof(*prevlsn));
289 bp += sizeof(*prevlsn);
290 memcpy(bp, &new_pgno, sizeof(new_pgno));
291 bp += sizeof(new_pgno);
293 memcpy(bp, pagelsn, sizeof(*pagelsn));
295 memset(bp, 0, sizeof(*pagelsn));
296 bp += sizeof(*pagelsn);
297 memcpy(bp, &next_pgno, sizeof(next_pgno));
298 bp += sizeof(next_pgno);
300 memcpy(bp, nextlsn, sizeof(*nextlsn));
302 memset(bp, 0, sizeof(*nextlsn));
303 bp += sizeof(*nextlsn);
305 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
306 fprintf(stderr, "Error in log record length");
308 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
310 txnid->last_lsn = *ret_lsnp;
316 * PUBLIC: int __ham_newpage_print
317 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
321 __ham_newpage_print(notused1, dbtp, lsnp, notused3, notused4)
328 __ham_newpage_args *argp;
338 if((ret = __ham_newpage_read(dbtp->data, &argp)) != 0)
340 printf("[%lu][%lu]ham_newpage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
342 (u_long)lsnp->offset,
344 (u_long)argp->txnid->txnid,
345 (u_long)argp->prev_lsn.file,
346 (u_long)argp->prev_lsn.offset);
347 printf("\topcode: %lu\n", (u_long)argp->opcode);
348 printf("\tfileid: %lu\n", (u_long)argp->fileid);
349 printf("\tprev_pgno: %lu\n", (u_long)argp->prev_pgno);
350 printf("\tprevlsn: [%lu][%lu]\n",
351 (u_long)argp->prevlsn.file, (u_long)argp->prevlsn.offset);
352 printf("\tnew_pgno: %lu\n", (u_long)argp->new_pgno);
353 printf("\tpagelsn: [%lu][%lu]\n",
354 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
355 printf("\tnext_pgno: %lu\n", (u_long)argp->next_pgno);
356 printf("\tnextlsn: [%lu][%lu]\n",
357 (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset);
364 * PUBLIC: int __ham_newpage_read __P((void *, __ham_newpage_args **));
367 __ham_newpage_read(recbuf, argpp)
369 __ham_newpage_args **argpp;
371 __ham_newpage_args *argp;
374 argp = (__ham_newpage_args *)malloc(sizeof(__ham_newpage_args) +
378 argp->txnid = (DB_TXN *)&argp[1];
380 memcpy(&argp->type, bp, sizeof(argp->type));
381 bp += sizeof(argp->type);
382 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
383 bp += sizeof(argp->txnid->txnid);
384 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
385 bp += sizeof(DB_LSN);
386 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
387 bp += sizeof(argp->opcode);
388 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
389 bp += sizeof(argp->fileid);
390 memcpy(&argp->prev_pgno, bp, sizeof(argp->prev_pgno));
391 bp += sizeof(argp->prev_pgno);
392 memcpy(&argp->prevlsn, bp, sizeof(argp->prevlsn));
393 bp += sizeof(argp->prevlsn);
394 memcpy(&argp->new_pgno, bp, sizeof(argp->new_pgno));
395 bp += sizeof(argp->new_pgno);
396 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
397 bp += sizeof(argp->pagelsn);
398 memcpy(&argp->next_pgno, bp, sizeof(argp->next_pgno));
399 bp += sizeof(argp->next_pgno);
400 memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn));
401 bp += sizeof(argp->nextlsn);
407 * PUBLIC: int __ham_splitmeta_log
408 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
409 * PUBLIC: u_int32_t, u_int32_t, u_int32_t, u_int32_t,
410 * PUBLIC: DB_LSN *));
412 int __ham_splitmeta_log(logp, txnid, ret_lsnp, flags,
413 fileid, bucket, ovflpoint, spares, metalsn)
425 DB_LSN *lsnp, null_lsn;
426 u_int32_t rectype, txn_num;
430 rectype = DB_ham_splitmeta;
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 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
448 memcpy(bp, &rectype, sizeof(rectype));
449 bp += sizeof(rectype);
450 memcpy(bp, &txn_num, sizeof(txn_num));
451 bp += sizeof(txn_num);
452 memcpy(bp, lsnp, sizeof(DB_LSN));
453 bp += sizeof(DB_LSN);
454 memcpy(bp, &fileid, sizeof(fileid));
455 bp += sizeof(fileid);
456 memcpy(bp, &bucket, sizeof(bucket));
457 bp += sizeof(bucket);
458 memcpy(bp, &ovflpoint, sizeof(ovflpoint));
459 bp += sizeof(ovflpoint);
460 memcpy(bp, &spares, sizeof(spares));
461 bp += sizeof(spares);
463 memcpy(bp, metalsn, sizeof(*metalsn));
465 memset(bp, 0, sizeof(*metalsn));
466 bp += sizeof(*metalsn);
468 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
469 fprintf(stderr, "Error in log record length");
471 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
473 txnid->last_lsn = *ret_lsnp;
479 * PUBLIC: int __ham_splitmeta_print
480 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
484 __ham_splitmeta_print(notused1, dbtp, lsnp, notused3, notused4)
491 __ham_splitmeta_args *argp;
501 if((ret = __ham_splitmeta_read(dbtp->data, &argp)) != 0)
503 printf("[%lu][%lu]ham_splitmeta: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
505 (u_long)lsnp->offset,
507 (u_long)argp->txnid->txnid,
508 (u_long)argp->prev_lsn.file,
509 (u_long)argp->prev_lsn.offset);
510 printf("\tfileid: %lu\n", (u_long)argp->fileid);
511 printf("\tbucket: %lu\n", (u_long)argp->bucket);
512 printf("\tovflpoint: %lu\n", (u_long)argp->ovflpoint);
513 printf("\tspares: %lu\n", (u_long)argp->spares);
514 printf("\tmetalsn: [%lu][%lu]\n",
515 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
522 * PUBLIC: int __ham_splitmeta_read __P((void *, __ham_splitmeta_args **));
525 __ham_splitmeta_read(recbuf, argpp)
527 __ham_splitmeta_args **argpp;
529 __ham_splitmeta_args *argp;
532 argp = (__ham_splitmeta_args *)malloc(sizeof(__ham_splitmeta_args) +
536 argp->txnid = (DB_TXN *)&argp[1];
538 memcpy(&argp->type, bp, sizeof(argp->type));
539 bp += sizeof(argp->type);
540 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
541 bp += sizeof(argp->txnid->txnid);
542 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
543 bp += sizeof(DB_LSN);
544 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
545 bp += sizeof(argp->fileid);
546 memcpy(&argp->bucket, bp, sizeof(argp->bucket));
547 bp += sizeof(argp->bucket);
548 memcpy(&argp->ovflpoint, bp, sizeof(argp->ovflpoint));
549 bp += sizeof(argp->ovflpoint);
550 memcpy(&argp->spares, bp, sizeof(argp->spares));
551 bp += sizeof(argp->spares);
552 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
553 bp += sizeof(argp->metalsn);
559 * PUBLIC: int __ham_splitdata_log
560 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
561 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, DBT *,
562 * PUBLIC: DB_LSN *));
564 int __ham_splitdata_log(logp, txnid, ret_lsnp, flags,
565 fileid, opcode, pgno, pageimage, pagelsn)
577 DB_LSN *lsnp, null_lsn;
579 u_int32_t rectype, txn_num;
583 rectype = DB_ham_splitdata;
584 txn_num = txnid == NULL ? 0 : txnid->txnid;
590 lsnp = &txnid->last_lsn;
591 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
595 + sizeof(u_int32_t) + (pageimage == NULL ? 0 : pageimage->size)
597 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
601 memcpy(bp, &rectype, sizeof(rectype));
602 bp += sizeof(rectype);
603 memcpy(bp, &txn_num, sizeof(txn_num));
604 bp += sizeof(txn_num);
605 memcpy(bp, lsnp, sizeof(DB_LSN));
606 bp += sizeof(DB_LSN);
607 memcpy(bp, &fileid, sizeof(fileid));
608 bp += sizeof(fileid);
609 memcpy(bp, &opcode, sizeof(opcode));
610 bp += sizeof(opcode);
611 memcpy(bp, &pgno, sizeof(pgno));
613 if (pageimage == NULL) {
615 memcpy(bp, &zero, sizeof(u_int32_t));
616 bp += sizeof(u_int32_t);
618 memcpy(bp, &pageimage->size, sizeof(pageimage->size));
619 bp += sizeof(pageimage->size);
620 memcpy(bp, pageimage->data, pageimage->size);
621 bp += pageimage->size;
624 memcpy(bp, pagelsn, sizeof(*pagelsn));
626 memset(bp, 0, sizeof(*pagelsn));
627 bp += sizeof(*pagelsn);
629 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
630 fprintf(stderr, "Error in log record length");
632 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
634 txnid->last_lsn = *ret_lsnp;
640 * PUBLIC: int __ham_splitdata_print
641 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
645 __ham_splitdata_print(notused1, dbtp, lsnp, notused3, notused4)
652 __ham_splitdata_args *argp;
662 if((ret = __ham_splitdata_read(dbtp->data, &argp)) != 0)
664 printf("[%lu][%lu]ham_splitdata: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
666 (u_long)lsnp->offset,
668 (u_long)argp->txnid->txnid,
669 (u_long)argp->prev_lsn.file,
670 (u_long)argp->prev_lsn.offset);
671 printf("\tfileid: %lu\n", (u_long)argp->fileid);
672 printf("\topcode: %lu\n", (u_long)argp->opcode);
673 printf("\tpgno: %lu\n", (u_long)argp->pgno);
674 printf("\tpageimage: ");
675 for (i = 0; i < argp->pageimage.size; i++) {
676 c = ((char *)argp->pageimage.data)[i];
677 if (isprint(c) || c == 0xa)
683 printf("\tpagelsn: [%lu][%lu]\n",
684 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
691 * PUBLIC: int __ham_splitdata_read __P((void *, __ham_splitdata_args **));
694 __ham_splitdata_read(recbuf, argpp)
696 __ham_splitdata_args **argpp;
698 __ham_splitdata_args *argp;
701 argp = (__ham_splitdata_args *)malloc(sizeof(__ham_splitdata_args) +
705 argp->txnid = (DB_TXN *)&argp[1];
707 memcpy(&argp->type, bp, sizeof(argp->type));
708 bp += sizeof(argp->type);
709 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
710 bp += sizeof(argp->txnid->txnid);
711 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
712 bp += sizeof(DB_LSN);
713 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
714 bp += sizeof(argp->fileid);
715 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
716 bp += sizeof(argp->opcode);
717 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
718 bp += sizeof(argp->pgno);
719 memcpy(&argp->pageimage.size, bp, sizeof(u_int32_t));
720 bp += sizeof(u_int32_t);
721 argp->pageimage.data = bp;
722 bp += argp->pageimage.size;
723 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
724 bp += sizeof(argp->pagelsn);
730 * PUBLIC: int __ham_replace_log
731 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
732 * PUBLIC: u_int32_t, db_pgno_t, u_int32_t, DB_LSN *,
733 * PUBLIC: int32_t, DBT *, DBT *, u_int32_t));
735 int __ham_replace_log(logp, txnid, ret_lsnp, flags,
736 fileid, pgno, ndx, pagelsn, off, olditem,
752 DB_LSN *lsnp, null_lsn;
754 u_int32_t rectype, txn_num;
758 rectype = DB_ham_replace;
759 txn_num = txnid == NULL ? 0 : txnid->txnid;
765 lsnp = &txnid->last_lsn;
766 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
772 + sizeof(u_int32_t) + (olditem == NULL ? 0 : olditem->size)
773 + sizeof(u_int32_t) + (newitem == NULL ? 0 : newitem->size)
775 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
779 memcpy(bp, &rectype, sizeof(rectype));
780 bp += sizeof(rectype);
781 memcpy(bp, &txn_num, sizeof(txn_num));
782 bp += sizeof(txn_num);
783 memcpy(bp, lsnp, sizeof(DB_LSN));
784 bp += sizeof(DB_LSN);
785 memcpy(bp, &fileid, sizeof(fileid));
786 bp += sizeof(fileid);
787 memcpy(bp, &pgno, sizeof(pgno));
789 memcpy(bp, &ndx, sizeof(ndx));
792 memcpy(bp, pagelsn, sizeof(*pagelsn));
794 memset(bp, 0, sizeof(*pagelsn));
795 bp += sizeof(*pagelsn);
796 memcpy(bp, &off, sizeof(off));
798 if (olditem == NULL) {
800 memcpy(bp, &zero, sizeof(u_int32_t));
801 bp += sizeof(u_int32_t);
803 memcpy(bp, &olditem->size, sizeof(olditem->size));
804 bp += sizeof(olditem->size);
805 memcpy(bp, olditem->data, olditem->size);
808 if (newitem == NULL) {
810 memcpy(bp, &zero, sizeof(u_int32_t));
811 bp += sizeof(u_int32_t);
813 memcpy(bp, &newitem->size, sizeof(newitem->size));
814 bp += sizeof(newitem->size);
815 memcpy(bp, newitem->data, newitem->size);
818 memcpy(bp, &makedup, sizeof(makedup));
819 bp += sizeof(makedup);
821 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
822 fprintf(stderr, "Error in log record length");
824 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
826 txnid->last_lsn = *ret_lsnp;
832 * PUBLIC: int __ham_replace_print
833 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
837 __ham_replace_print(notused1, dbtp, lsnp, notused3, notused4)
844 __ham_replace_args *argp;
854 if((ret = __ham_replace_read(dbtp->data, &argp)) != 0)
856 printf("[%lu][%lu]ham_replace: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
858 (u_long)lsnp->offset,
860 (u_long)argp->txnid->txnid,
861 (u_long)argp->prev_lsn.file,
862 (u_long)argp->prev_lsn.offset);
863 printf("\tfileid: %lu\n", (u_long)argp->fileid);
864 printf("\tpgno: %lu\n", (u_long)argp->pgno);
865 printf("\tndx: %lu\n", (u_long)argp->ndx);
866 printf("\tpagelsn: [%lu][%lu]\n",
867 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
868 printf("\toff: %ld\n", (long)argp->off);
869 printf("\tolditem: ");
870 for (i = 0; i < argp->olditem.size; i++) {
871 c = ((char *)argp->olditem.data)[i];
872 if (isprint(c) || c == 0xa)
878 printf("\tnewitem: ");
879 for (i = 0; i < argp->newitem.size; i++) {
880 c = ((char *)argp->newitem.data)[i];
881 if (isprint(c) || c == 0xa)
887 printf("\tmakedup: %lu\n", (u_long)argp->makedup);
894 * PUBLIC: int __ham_replace_read __P((void *, __ham_replace_args **));
897 __ham_replace_read(recbuf, argpp)
899 __ham_replace_args **argpp;
901 __ham_replace_args *argp;
904 argp = (__ham_replace_args *)malloc(sizeof(__ham_replace_args) +
908 argp->txnid = (DB_TXN *)&argp[1];
910 memcpy(&argp->type, bp, sizeof(argp->type));
911 bp += sizeof(argp->type);
912 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
913 bp += sizeof(argp->txnid->txnid);
914 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
915 bp += sizeof(DB_LSN);
916 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
917 bp += sizeof(argp->fileid);
918 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
919 bp += sizeof(argp->pgno);
920 memcpy(&argp->ndx, bp, sizeof(argp->ndx));
921 bp += sizeof(argp->ndx);
922 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
923 bp += sizeof(argp->pagelsn);
924 memcpy(&argp->off, bp, sizeof(argp->off));
925 bp += sizeof(argp->off);
926 memcpy(&argp->olditem.size, bp, sizeof(u_int32_t));
927 bp += sizeof(u_int32_t);
928 argp->olditem.data = bp;
929 bp += argp->olditem.size;
930 memcpy(&argp->newitem.size, bp, sizeof(u_int32_t));
931 bp += sizeof(u_int32_t);
932 argp->newitem.data = bp;
933 bp += argp->newitem.size;
934 memcpy(&argp->makedup, bp, sizeof(argp->makedup));
935 bp += sizeof(argp->makedup);
941 * PUBLIC: int __ham_newpgno_log
942 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
943 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, db_pgno_t,
944 * PUBLIC: u_int32_t, db_pgno_t, u_int32_t, DB_LSN *,
945 * PUBLIC: DB_LSN *));
947 int __ham_newpgno_log(logp, txnid, ret_lsnp, flags,
948 opcode, fileid, pgno, free_pgno, old_type, old_pgno,
949 new_type, pagelsn, metalsn)
965 DB_LSN *lsnp, null_lsn;
966 u_int32_t rectype, txn_num;
970 rectype = DB_ham_newpgno;
971 txn_num = txnid == NULL ? 0 : txnid->txnid;
977 lsnp = &txnid->last_lsn;
978 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
988 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
992 memcpy(bp, &rectype, sizeof(rectype));
993 bp += sizeof(rectype);
994 memcpy(bp, &txn_num, sizeof(txn_num));
995 bp += sizeof(txn_num);
996 memcpy(bp, lsnp, sizeof(DB_LSN));
997 bp += sizeof(DB_LSN);
998 memcpy(bp, &opcode, sizeof(opcode));
999 bp += sizeof(opcode);
1000 memcpy(bp, &fileid, sizeof(fileid));
1001 bp += sizeof(fileid);
1002 memcpy(bp, &pgno, sizeof(pgno));
1004 memcpy(bp, &free_pgno, sizeof(free_pgno));
1005 bp += sizeof(free_pgno);
1006 memcpy(bp, &old_type, sizeof(old_type));
1007 bp += sizeof(old_type);
1008 memcpy(bp, &old_pgno, sizeof(old_pgno));
1009 bp += sizeof(old_pgno);
1010 memcpy(bp, &new_type, sizeof(new_type));
1011 bp += sizeof(new_type);
1012 if (pagelsn != NULL)
1013 memcpy(bp, pagelsn, sizeof(*pagelsn));
1015 memset(bp, 0, sizeof(*pagelsn));
1016 bp += sizeof(*pagelsn);
1017 if (metalsn != NULL)
1018 memcpy(bp, metalsn, sizeof(*metalsn));
1020 memset(bp, 0, sizeof(*metalsn));
1021 bp += sizeof(*metalsn);
1023 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
1024 fprintf(stderr, "Error in log record length");
1026 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
1028 txnid->last_lsn = *ret_lsnp;
1034 * PUBLIC: int __ham_newpgno_print
1035 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1039 __ham_newpgno_print(notused1, dbtp, lsnp, notused3, notused4)
1046 __ham_newpgno_args *argp;
1056 if((ret = __ham_newpgno_read(dbtp->data, &argp)) != 0)
1058 printf("[%lu][%lu]ham_newpgno: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1060 (u_long)lsnp->offset,
1062 (u_long)argp->txnid->txnid,
1063 (u_long)argp->prev_lsn.file,
1064 (u_long)argp->prev_lsn.offset);
1065 printf("\topcode: %lu\n", (u_long)argp->opcode);
1066 printf("\tfileid: %lu\n", (u_long)argp->fileid);
1067 printf("\tpgno: %lu\n", (u_long)argp->pgno);
1068 printf("\tfree_pgno: %lu\n", (u_long)argp->free_pgno);
1069 printf("\told_type: %lu\n", (u_long)argp->old_type);
1070 printf("\told_pgno: %lu\n", (u_long)argp->old_pgno);
1071 printf("\tnew_type: %lu\n", (u_long)argp->new_type);
1072 printf("\tpagelsn: [%lu][%lu]\n",
1073 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
1074 printf("\tmetalsn: [%lu][%lu]\n",
1075 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
1082 * PUBLIC: int __ham_newpgno_read __P((void *, __ham_newpgno_args **));
1085 __ham_newpgno_read(recbuf, argpp)
1087 __ham_newpgno_args **argpp;
1089 __ham_newpgno_args *argp;
1092 argp = (__ham_newpgno_args *)malloc(sizeof(__ham_newpgno_args) +
1096 argp->txnid = (DB_TXN *)&argp[1];
1098 memcpy(&argp->type, bp, sizeof(argp->type));
1099 bp += sizeof(argp->type);
1100 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
1101 bp += sizeof(argp->txnid->txnid);
1102 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
1103 bp += sizeof(DB_LSN);
1104 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
1105 bp += sizeof(argp->opcode);
1106 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
1107 bp += sizeof(argp->fileid);
1108 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
1109 bp += sizeof(argp->pgno);
1110 memcpy(&argp->free_pgno, bp, sizeof(argp->free_pgno));
1111 bp += sizeof(argp->free_pgno);
1112 memcpy(&argp->old_type, bp, sizeof(argp->old_type));
1113 bp += sizeof(argp->old_type);
1114 memcpy(&argp->old_pgno, bp, sizeof(argp->old_pgno));
1115 bp += sizeof(argp->old_pgno);
1116 memcpy(&argp->new_type, bp, sizeof(argp->new_type));
1117 bp += sizeof(argp->new_type);
1118 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
1119 bp += sizeof(argp->pagelsn);
1120 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
1121 bp += sizeof(argp->metalsn);
1127 * PUBLIC: int __ham_ovfl_log
1128 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
1129 * PUBLIC: u_int32_t, db_pgno_t, u_int32_t, db_pgno_t,
1130 * PUBLIC: DB_LSN *));
1132 int __ham_ovfl_log(logp, txnid, ret_lsnp, flags,
1133 fileid, start_pgno, npages, free_pgno, metalsn)
1139 db_pgno_t start_pgno;
1141 db_pgno_t free_pgno;
1145 DB_LSN *lsnp, null_lsn;
1146 u_int32_t rectype, txn_num;
1150 rectype = DB_ham_ovfl;
1151 txn_num = txnid == NULL ? 0 : txnid->txnid;
1152 if (txnid == NULL) {
1154 null_lsn.offset = 0;
1157 lsnp = &txnid->last_lsn;
1158 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
1160 + sizeof(start_pgno)
1164 if ((logrec.data = (void *)malloc(logrec.size)) == NULL)
1168 memcpy(bp, &rectype, sizeof(rectype));
1169 bp += sizeof(rectype);
1170 memcpy(bp, &txn_num, sizeof(txn_num));
1171 bp += sizeof(txn_num);
1172 memcpy(bp, lsnp, sizeof(DB_LSN));
1173 bp += sizeof(DB_LSN);
1174 memcpy(bp, &fileid, sizeof(fileid));
1175 bp += sizeof(fileid);
1176 memcpy(bp, &start_pgno, sizeof(start_pgno));
1177 bp += sizeof(start_pgno);
1178 memcpy(bp, &npages, sizeof(npages));
1179 bp += sizeof(npages);
1180 memcpy(bp, &free_pgno, sizeof(free_pgno));
1181 bp += sizeof(free_pgno);
1182 if (metalsn != NULL)
1183 memcpy(bp, metalsn, sizeof(*metalsn));
1185 memset(bp, 0, sizeof(*metalsn));
1186 bp += sizeof(*metalsn);
1188 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
1189 fprintf(stderr, "Error in log record length");
1191 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
1193 txnid->last_lsn = *ret_lsnp;
1199 * PUBLIC: int __ham_ovfl_print
1200 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1204 __ham_ovfl_print(notused1, dbtp, lsnp, notused3, notused4)
1211 __ham_ovfl_args *argp;
1221 if((ret = __ham_ovfl_read(dbtp->data, &argp)) != 0)
1223 printf("[%lu][%lu]ham_ovfl: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1225 (u_long)lsnp->offset,
1227 (u_long)argp->txnid->txnid,
1228 (u_long)argp->prev_lsn.file,
1229 (u_long)argp->prev_lsn.offset);
1230 printf("\tfileid: %lu\n", (u_long)argp->fileid);
1231 printf("\tstart_pgno: %lu\n", (u_long)argp->start_pgno);
1232 printf("\tnpages: %lu\n", (u_long)argp->npages);
1233 printf("\tfree_pgno: %lu\n", (u_long)argp->free_pgno);
1234 printf("\tmetalsn: [%lu][%lu]\n",
1235 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
1242 * PUBLIC: int __ham_ovfl_read __P((void *, __ham_ovfl_args **));
1245 __ham_ovfl_read(recbuf, argpp)
1247 __ham_ovfl_args **argpp;
1249 __ham_ovfl_args *argp;
1252 argp = (__ham_ovfl_args *)malloc(sizeof(__ham_ovfl_args) +
1256 argp->txnid = (DB_TXN *)&argp[1];
1258 memcpy(&argp->type, bp, sizeof(argp->type));
1259 bp += sizeof(argp->type);
1260 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
1261 bp += sizeof(argp->txnid->txnid);
1262 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
1263 bp += sizeof(DB_LSN);
1264 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
1265 bp += sizeof(argp->fileid);
1266 memcpy(&argp->start_pgno, bp, sizeof(argp->start_pgno));
1267 bp += sizeof(argp->start_pgno);
1268 memcpy(&argp->npages, bp, sizeof(argp->npages));
1269 bp += sizeof(argp->npages);
1270 memcpy(&argp->free_pgno, bp, sizeof(argp->free_pgno));
1271 bp += sizeof(argp->free_pgno);
1272 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
1273 bp += sizeof(argp->metalsn);
1279 * PUBLIC: int __ham_init_print __P((DB_ENV *));
1282 __ham_init_print(dbenv)
1287 if ((ret = __db_add_recovery(dbenv,
1288 __ham_insdel_print, DB_ham_insdel)) != 0)
1290 if ((ret = __db_add_recovery(dbenv,
1291 __ham_newpage_print, DB_ham_newpage)) != 0)
1293 if ((ret = __db_add_recovery(dbenv,
1294 __ham_splitmeta_print, DB_ham_splitmeta)) != 0)
1296 if ((ret = __db_add_recovery(dbenv,
1297 __ham_splitdata_print, DB_ham_splitdata)) != 0)
1299 if ((ret = __db_add_recovery(dbenv,
1300 __ham_replace_print, DB_ham_replace)) != 0)
1302 if ((ret = __db_add_recovery(dbenv,
1303 __ham_newpgno_print, DB_ham_newpgno)) != 0)
1305 if ((ret = __db_add_recovery(dbenv,
1306 __ham_ovfl_print, DB_ham_ovfl)) != 0)
1312 * PUBLIC: int __ham_init_recover __P((DB_ENV *));
1315 __ham_init_recover(dbenv)
1320 if ((ret = __db_add_recovery(dbenv,
1321 __ham_insdel_recover, DB_ham_insdel)) != 0)
1323 if ((ret = __db_add_recovery(dbenv,
1324 __ham_newpage_recover, DB_ham_newpage)) != 0)
1326 if ((ret = __db_add_recovery(dbenv,
1327 __ham_splitmeta_recover, DB_ham_splitmeta)) != 0)
1329 if ((ret = __db_add_recovery(dbenv,
1330 __ham_splitdata_recover, DB_ham_splitdata)) != 0)
1332 if ((ret = __db_add_recovery(dbenv,
1333 __ham_replace_recover, DB_ham_replace)) != 0)
1335 if ((ret = __db_add_recovery(dbenv,
1336 __ham_newpgno_recover, DB_ham_newpgno)) != 0)
1338 if ((ret = __db_add_recovery(dbenv,
1339 __ham_ovfl_recover, DB_ham_ovfl)) != 0)