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 *, const DBT *, const 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 *)__db_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;
114 __db_free(logrec.data);
119 * PUBLIC: int __ham_insdel_print
120 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
123 __ham_insdel_print(notused1, dbtp, lsnp, notused3, notused4)
130 __ham_insdel_args *argp;
140 if ((ret = __ham_insdel_read(dbtp->data, &argp)) != 0)
142 printf("[%lu][%lu]ham_insdel: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
144 (u_long)lsnp->offset,
146 (u_long)argp->txnid->txnid,
147 (u_long)argp->prev_lsn.file,
148 (u_long)argp->prev_lsn.offset);
149 printf("\topcode: %lu\n", (u_long)argp->opcode);
150 printf("\tfileid: %lu\n", (u_long)argp->fileid);
151 printf("\tpgno: %lu\n", (u_long)argp->pgno);
152 printf("\tndx: %lu\n", (u_long)argp->ndx);
153 printf("\tpagelsn: [%lu][%lu]\n",
154 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
156 for (i = 0; i < argp->key.size; i++) {
157 c = ((char *)argp->key.data)[i];
158 if (isprint(c) || c == 0xa)
165 for (i = 0; i < argp->data.size; i++) {
166 c = ((char *)argp->data.data)[i];
167 if (isprint(c) || c == 0xa)
179 * PUBLIC: int __ham_insdel_read __P((void *, __ham_insdel_args **));
182 __ham_insdel_read(recbuf, argpp)
184 __ham_insdel_args **argpp;
186 __ham_insdel_args *argp;
189 argp = (__ham_insdel_args *)__db_malloc(sizeof(__ham_insdel_args) +
193 argp->txnid = (DB_TXN *)&argp[1];
195 memcpy(&argp->type, bp, sizeof(argp->type));
196 bp += sizeof(argp->type);
197 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
198 bp += sizeof(argp->txnid->txnid);
199 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
200 bp += sizeof(DB_LSN);
201 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
202 bp += sizeof(argp->opcode);
203 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
204 bp += sizeof(argp->fileid);
205 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
206 bp += sizeof(argp->pgno);
207 memcpy(&argp->ndx, bp, sizeof(argp->ndx));
208 bp += sizeof(argp->ndx);
209 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
210 bp += sizeof(argp->pagelsn);
211 memcpy(&argp->key.size, bp, sizeof(u_int32_t));
212 bp += sizeof(u_int32_t);
214 bp += argp->key.size;
215 memcpy(&argp->data.size, bp, sizeof(u_int32_t));
216 bp += sizeof(u_int32_t);
217 argp->data.data = bp;
218 bp += argp->data.size;
224 * PUBLIC: int __ham_newpage_log
225 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
226 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, DB_LSN *,
227 * PUBLIC: db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *));
229 int __ham_newpage_log(logp, txnid, ret_lsnp, flags,
230 opcode, fileid, prev_pgno, prevlsn, new_pgno, pagelsn,
246 DB_LSN *lsnp, null_lsn;
247 u_int32_t rectype, txn_num;
251 rectype = DB_ham_newpage;
252 txn_num = txnid == NULL ? 0 : txnid->txnid;
258 lsnp = &txnid->last_lsn;
259 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
268 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
272 memcpy(bp, &rectype, sizeof(rectype));
273 bp += sizeof(rectype);
274 memcpy(bp, &txn_num, sizeof(txn_num));
275 bp += sizeof(txn_num);
276 memcpy(bp, lsnp, sizeof(DB_LSN));
277 bp += sizeof(DB_LSN);
278 memcpy(bp, &opcode, sizeof(opcode));
279 bp += sizeof(opcode);
280 memcpy(bp, &fileid, sizeof(fileid));
281 bp += sizeof(fileid);
282 memcpy(bp, &prev_pgno, sizeof(prev_pgno));
283 bp += sizeof(prev_pgno);
285 memcpy(bp, prevlsn, sizeof(*prevlsn));
287 memset(bp, 0, sizeof(*prevlsn));
288 bp += sizeof(*prevlsn);
289 memcpy(bp, &new_pgno, sizeof(new_pgno));
290 bp += sizeof(new_pgno);
292 memcpy(bp, pagelsn, sizeof(*pagelsn));
294 memset(bp, 0, sizeof(*pagelsn));
295 bp += sizeof(*pagelsn);
296 memcpy(bp, &next_pgno, sizeof(next_pgno));
297 bp += sizeof(next_pgno);
299 memcpy(bp, nextlsn, sizeof(*nextlsn));
301 memset(bp, 0, sizeof(*nextlsn));
302 bp += sizeof(*nextlsn);
304 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
305 fprintf(stderr, "Error in log record length");
307 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
309 txnid->last_lsn = *ret_lsnp;
310 __db_free(logrec.data);
315 * PUBLIC: int __ham_newpage_print
316 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
319 __ham_newpage_print(notused1, dbtp, lsnp, notused3, notused4)
326 __ham_newpage_args *argp;
336 if ((ret = __ham_newpage_read(dbtp->data, &argp)) != 0)
338 printf("[%lu][%lu]ham_newpage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
340 (u_long)lsnp->offset,
342 (u_long)argp->txnid->txnid,
343 (u_long)argp->prev_lsn.file,
344 (u_long)argp->prev_lsn.offset);
345 printf("\topcode: %lu\n", (u_long)argp->opcode);
346 printf("\tfileid: %lu\n", (u_long)argp->fileid);
347 printf("\tprev_pgno: %lu\n", (u_long)argp->prev_pgno);
348 printf("\tprevlsn: [%lu][%lu]\n",
349 (u_long)argp->prevlsn.file, (u_long)argp->prevlsn.offset);
350 printf("\tnew_pgno: %lu\n", (u_long)argp->new_pgno);
351 printf("\tpagelsn: [%lu][%lu]\n",
352 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
353 printf("\tnext_pgno: %lu\n", (u_long)argp->next_pgno);
354 printf("\tnextlsn: [%lu][%lu]\n",
355 (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset);
362 * PUBLIC: int __ham_newpage_read __P((void *, __ham_newpage_args **));
365 __ham_newpage_read(recbuf, argpp)
367 __ham_newpage_args **argpp;
369 __ham_newpage_args *argp;
372 argp = (__ham_newpage_args *)__db_malloc(sizeof(__ham_newpage_args) +
376 argp->txnid = (DB_TXN *)&argp[1];
378 memcpy(&argp->type, bp, sizeof(argp->type));
379 bp += sizeof(argp->type);
380 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
381 bp += sizeof(argp->txnid->txnid);
382 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
383 bp += sizeof(DB_LSN);
384 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
385 bp += sizeof(argp->opcode);
386 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
387 bp += sizeof(argp->fileid);
388 memcpy(&argp->prev_pgno, bp, sizeof(argp->prev_pgno));
389 bp += sizeof(argp->prev_pgno);
390 memcpy(&argp->prevlsn, bp, sizeof(argp->prevlsn));
391 bp += sizeof(argp->prevlsn);
392 memcpy(&argp->new_pgno, bp, sizeof(argp->new_pgno));
393 bp += sizeof(argp->new_pgno);
394 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
395 bp += sizeof(argp->pagelsn);
396 memcpy(&argp->next_pgno, bp, sizeof(argp->next_pgno));
397 bp += sizeof(argp->next_pgno);
398 memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn));
399 bp += sizeof(argp->nextlsn);
405 * PUBLIC: int __ham_splitmeta_log
406 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
407 * PUBLIC: u_int32_t, u_int32_t, u_int32_t, u_int32_t,
408 * PUBLIC: DB_LSN *));
410 int __ham_splitmeta_log(logp, txnid, ret_lsnp, flags,
411 fileid, bucket, ovflpoint, spares, metalsn)
423 DB_LSN *lsnp, null_lsn;
424 u_int32_t rectype, txn_num;
428 rectype = DB_ham_splitmeta;
429 txn_num = txnid == NULL ? 0 : txnid->txnid;
435 lsnp = &txnid->last_lsn;
436 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
442 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
446 memcpy(bp, &rectype, sizeof(rectype));
447 bp += sizeof(rectype);
448 memcpy(bp, &txn_num, sizeof(txn_num));
449 bp += sizeof(txn_num);
450 memcpy(bp, lsnp, sizeof(DB_LSN));
451 bp += sizeof(DB_LSN);
452 memcpy(bp, &fileid, sizeof(fileid));
453 bp += sizeof(fileid);
454 memcpy(bp, &bucket, sizeof(bucket));
455 bp += sizeof(bucket);
456 memcpy(bp, &ovflpoint, sizeof(ovflpoint));
457 bp += sizeof(ovflpoint);
458 memcpy(bp, &spares, sizeof(spares));
459 bp += sizeof(spares);
461 memcpy(bp, metalsn, sizeof(*metalsn));
463 memset(bp, 0, sizeof(*metalsn));
464 bp += sizeof(*metalsn);
466 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
467 fprintf(stderr, "Error in log record length");
469 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
471 txnid->last_lsn = *ret_lsnp;
472 __db_free(logrec.data);
477 * PUBLIC: int __ham_splitmeta_print
478 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
481 __ham_splitmeta_print(notused1, dbtp, lsnp, notused3, notused4)
488 __ham_splitmeta_args *argp;
498 if ((ret = __ham_splitmeta_read(dbtp->data, &argp)) != 0)
500 printf("[%lu][%lu]ham_splitmeta: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
502 (u_long)lsnp->offset,
504 (u_long)argp->txnid->txnid,
505 (u_long)argp->prev_lsn.file,
506 (u_long)argp->prev_lsn.offset);
507 printf("\tfileid: %lu\n", (u_long)argp->fileid);
508 printf("\tbucket: %lu\n", (u_long)argp->bucket);
509 printf("\tovflpoint: %lu\n", (u_long)argp->ovflpoint);
510 printf("\tspares: %lu\n", (u_long)argp->spares);
511 printf("\tmetalsn: [%lu][%lu]\n",
512 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
519 * PUBLIC: int __ham_splitmeta_read __P((void *, __ham_splitmeta_args **));
522 __ham_splitmeta_read(recbuf, argpp)
524 __ham_splitmeta_args **argpp;
526 __ham_splitmeta_args *argp;
529 argp = (__ham_splitmeta_args *)__db_malloc(sizeof(__ham_splitmeta_args) +
533 argp->txnid = (DB_TXN *)&argp[1];
535 memcpy(&argp->type, bp, sizeof(argp->type));
536 bp += sizeof(argp->type);
537 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
538 bp += sizeof(argp->txnid->txnid);
539 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
540 bp += sizeof(DB_LSN);
541 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
542 bp += sizeof(argp->fileid);
543 memcpy(&argp->bucket, bp, sizeof(argp->bucket));
544 bp += sizeof(argp->bucket);
545 memcpy(&argp->ovflpoint, bp, sizeof(argp->ovflpoint));
546 bp += sizeof(argp->ovflpoint);
547 memcpy(&argp->spares, bp, sizeof(argp->spares));
548 bp += sizeof(argp->spares);
549 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
550 bp += sizeof(argp->metalsn);
556 * PUBLIC: int __ham_splitdata_log
557 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
558 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, const DBT *,
559 * PUBLIC: DB_LSN *));
561 int __ham_splitdata_log(logp, txnid, ret_lsnp, flags,
562 fileid, opcode, pgno, pageimage, pagelsn)
570 const DBT *pageimage;
574 DB_LSN *lsnp, null_lsn;
576 u_int32_t rectype, txn_num;
580 rectype = DB_ham_splitdata;
581 txn_num = txnid == NULL ? 0 : txnid->txnid;
587 lsnp = &txnid->last_lsn;
588 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
592 + sizeof(u_int32_t) + (pageimage == NULL ? 0 : pageimage->size)
594 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
598 memcpy(bp, &rectype, sizeof(rectype));
599 bp += sizeof(rectype);
600 memcpy(bp, &txn_num, sizeof(txn_num));
601 bp += sizeof(txn_num);
602 memcpy(bp, lsnp, sizeof(DB_LSN));
603 bp += sizeof(DB_LSN);
604 memcpy(bp, &fileid, sizeof(fileid));
605 bp += sizeof(fileid);
606 memcpy(bp, &opcode, sizeof(opcode));
607 bp += sizeof(opcode);
608 memcpy(bp, &pgno, sizeof(pgno));
610 if (pageimage == NULL) {
612 memcpy(bp, &zero, sizeof(u_int32_t));
613 bp += sizeof(u_int32_t);
615 memcpy(bp, &pageimage->size, sizeof(pageimage->size));
616 bp += sizeof(pageimage->size);
617 memcpy(bp, pageimage->data, pageimage->size);
618 bp += pageimage->size;
621 memcpy(bp, pagelsn, sizeof(*pagelsn));
623 memset(bp, 0, sizeof(*pagelsn));
624 bp += sizeof(*pagelsn);
626 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
627 fprintf(stderr, "Error in log record length");
629 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
631 txnid->last_lsn = *ret_lsnp;
632 __db_free(logrec.data);
637 * PUBLIC: int __ham_splitdata_print
638 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
641 __ham_splitdata_print(notused1, dbtp, lsnp, notused3, notused4)
648 __ham_splitdata_args *argp;
658 if ((ret = __ham_splitdata_read(dbtp->data, &argp)) != 0)
660 printf("[%lu][%lu]ham_splitdata: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
662 (u_long)lsnp->offset,
664 (u_long)argp->txnid->txnid,
665 (u_long)argp->prev_lsn.file,
666 (u_long)argp->prev_lsn.offset);
667 printf("\tfileid: %lu\n", (u_long)argp->fileid);
668 printf("\topcode: %lu\n", (u_long)argp->opcode);
669 printf("\tpgno: %lu\n", (u_long)argp->pgno);
670 printf("\tpageimage: ");
671 for (i = 0; i < argp->pageimage.size; i++) {
672 c = ((char *)argp->pageimage.data)[i];
673 if (isprint(c) || c == 0xa)
679 printf("\tpagelsn: [%lu][%lu]\n",
680 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
687 * PUBLIC: int __ham_splitdata_read __P((void *, __ham_splitdata_args **));
690 __ham_splitdata_read(recbuf, argpp)
692 __ham_splitdata_args **argpp;
694 __ham_splitdata_args *argp;
697 argp = (__ham_splitdata_args *)__db_malloc(sizeof(__ham_splitdata_args) +
701 argp->txnid = (DB_TXN *)&argp[1];
703 memcpy(&argp->type, bp, sizeof(argp->type));
704 bp += sizeof(argp->type);
705 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
706 bp += sizeof(argp->txnid->txnid);
707 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
708 bp += sizeof(DB_LSN);
709 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
710 bp += sizeof(argp->fileid);
711 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
712 bp += sizeof(argp->opcode);
713 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
714 bp += sizeof(argp->pgno);
715 memcpy(&argp->pageimage.size, bp, sizeof(u_int32_t));
716 bp += sizeof(u_int32_t);
717 argp->pageimage.data = bp;
718 bp += argp->pageimage.size;
719 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
720 bp += sizeof(argp->pagelsn);
726 * PUBLIC: int __ham_replace_log
727 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
728 * PUBLIC: u_int32_t, db_pgno_t, u_int32_t, DB_LSN *,
729 * PUBLIC: int32_t, const DBT *, const DBT *, u_int32_t));
731 int __ham_replace_log(logp, txnid, ret_lsnp, flags,
732 fileid, pgno, ndx, pagelsn, off, olditem,
748 DB_LSN *lsnp, null_lsn;
750 u_int32_t rectype, txn_num;
754 rectype = DB_ham_replace;
755 txn_num = txnid == NULL ? 0 : txnid->txnid;
761 lsnp = &txnid->last_lsn;
762 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
768 + sizeof(u_int32_t) + (olditem == NULL ? 0 : olditem->size)
769 + sizeof(u_int32_t) + (newitem == NULL ? 0 : newitem->size)
771 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
775 memcpy(bp, &rectype, sizeof(rectype));
776 bp += sizeof(rectype);
777 memcpy(bp, &txn_num, sizeof(txn_num));
778 bp += sizeof(txn_num);
779 memcpy(bp, lsnp, sizeof(DB_LSN));
780 bp += sizeof(DB_LSN);
781 memcpy(bp, &fileid, sizeof(fileid));
782 bp += sizeof(fileid);
783 memcpy(bp, &pgno, sizeof(pgno));
785 memcpy(bp, &ndx, sizeof(ndx));
788 memcpy(bp, pagelsn, sizeof(*pagelsn));
790 memset(bp, 0, sizeof(*pagelsn));
791 bp += sizeof(*pagelsn);
792 memcpy(bp, &off, sizeof(off));
794 if (olditem == NULL) {
796 memcpy(bp, &zero, sizeof(u_int32_t));
797 bp += sizeof(u_int32_t);
799 memcpy(bp, &olditem->size, sizeof(olditem->size));
800 bp += sizeof(olditem->size);
801 memcpy(bp, olditem->data, olditem->size);
804 if (newitem == NULL) {
806 memcpy(bp, &zero, sizeof(u_int32_t));
807 bp += sizeof(u_int32_t);
809 memcpy(bp, &newitem->size, sizeof(newitem->size));
810 bp += sizeof(newitem->size);
811 memcpy(bp, newitem->data, newitem->size);
814 memcpy(bp, &makedup, sizeof(makedup));
815 bp += sizeof(makedup);
817 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
818 fprintf(stderr, "Error in log record length");
820 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
822 txnid->last_lsn = *ret_lsnp;
823 __db_free(logrec.data);
828 * PUBLIC: int __ham_replace_print
829 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
832 __ham_replace_print(notused1, dbtp, lsnp, notused3, notused4)
839 __ham_replace_args *argp;
849 if ((ret = __ham_replace_read(dbtp->data, &argp)) != 0)
851 printf("[%lu][%lu]ham_replace: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
853 (u_long)lsnp->offset,
855 (u_long)argp->txnid->txnid,
856 (u_long)argp->prev_lsn.file,
857 (u_long)argp->prev_lsn.offset);
858 printf("\tfileid: %lu\n", (u_long)argp->fileid);
859 printf("\tpgno: %lu\n", (u_long)argp->pgno);
860 printf("\tndx: %lu\n", (u_long)argp->ndx);
861 printf("\tpagelsn: [%lu][%lu]\n",
862 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
863 printf("\toff: %ld\n", (long)argp->off);
864 printf("\tolditem: ");
865 for (i = 0; i < argp->olditem.size; i++) {
866 c = ((char *)argp->olditem.data)[i];
867 if (isprint(c) || c == 0xa)
873 printf("\tnewitem: ");
874 for (i = 0; i < argp->newitem.size; i++) {
875 c = ((char *)argp->newitem.data)[i];
876 if (isprint(c) || c == 0xa)
882 printf("\tmakedup: %lu\n", (u_long)argp->makedup);
889 * PUBLIC: int __ham_replace_read __P((void *, __ham_replace_args **));
892 __ham_replace_read(recbuf, argpp)
894 __ham_replace_args **argpp;
896 __ham_replace_args *argp;
899 argp = (__ham_replace_args *)__db_malloc(sizeof(__ham_replace_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->ndx, bp, sizeof(argp->ndx));
916 bp += sizeof(argp->ndx);
917 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
918 bp += sizeof(argp->pagelsn);
919 memcpy(&argp->off, bp, sizeof(argp->off));
920 bp += sizeof(argp->off);
921 memcpy(&argp->olditem.size, bp, sizeof(u_int32_t));
922 bp += sizeof(u_int32_t);
923 argp->olditem.data = bp;
924 bp += argp->olditem.size;
925 memcpy(&argp->newitem.size, bp, sizeof(u_int32_t));
926 bp += sizeof(u_int32_t);
927 argp->newitem.data = bp;
928 bp += argp->newitem.size;
929 memcpy(&argp->makedup, bp, sizeof(argp->makedup));
930 bp += sizeof(argp->makedup);
936 * PUBLIC: int __ham_newpgno_log
937 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
938 * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, db_pgno_t,
939 * PUBLIC: u_int32_t, db_pgno_t, u_int32_t, DB_LSN *,
940 * PUBLIC: DB_LSN *));
942 int __ham_newpgno_log(logp, txnid, ret_lsnp, flags,
943 opcode, fileid, pgno, free_pgno, old_type, old_pgno,
944 new_type, pagelsn, metalsn)
960 DB_LSN *lsnp, null_lsn;
961 u_int32_t rectype, txn_num;
965 rectype = DB_ham_newpgno;
966 txn_num = txnid == NULL ? 0 : txnid->txnid;
972 lsnp = &txnid->last_lsn;
973 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
983 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
987 memcpy(bp, &rectype, sizeof(rectype));
988 bp += sizeof(rectype);
989 memcpy(bp, &txn_num, sizeof(txn_num));
990 bp += sizeof(txn_num);
991 memcpy(bp, lsnp, sizeof(DB_LSN));
992 bp += sizeof(DB_LSN);
993 memcpy(bp, &opcode, sizeof(opcode));
994 bp += sizeof(opcode);
995 memcpy(bp, &fileid, sizeof(fileid));
996 bp += sizeof(fileid);
997 memcpy(bp, &pgno, sizeof(pgno));
999 memcpy(bp, &free_pgno, sizeof(free_pgno));
1000 bp += sizeof(free_pgno);
1001 memcpy(bp, &old_type, sizeof(old_type));
1002 bp += sizeof(old_type);
1003 memcpy(bp, &old_pgno, sizeof(old_pgno));
1004 bp += sizeof(old_pgno);
1005 memcpy(bp, &new_type, sizeof(new_type));
1006 bp += sizeof(new_type);
1007 if (pagelsn != NULL)
1008 memcpy(bp, pagelsn, sizeof(*pagelsn));
1010 memset(bp, 0, sizeof(*pagelsn));
1011 bp += sizeof(*pagelsn);
1012 if (metalsn != NULL)
1013 memcpy(bp, metalsn, sizeof(*metalsn));
1015 memset(bp, 0, sizeof(*metalsn));
1016 bp += sizeof(*metalsn);
1018 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
1019 fprintf(stderr, "Error in log record length");
1021 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
1023 txnid->last_lsn = *ret_lsnp;
1024 __db_free(logrec.data);
1029 * PUBLIC: int __ham_newpgno_print
1030 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1033 __ham_newpgno_print(notused1, dbtp, lsnp, notused3, notused4)
1040 __ham_newpgno_args *argp;
1050 if ((ret = __ham_newpgno_read(dbtp->data, &argp)) != 0)
1052 printf("[%lu][%lu]ham_newpgno: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1054 (u_long)lsnp->offset,
1056 (u_long)argp->txnid->txnid,
1057 (u_long)argp->prev_lsn.file,
1058 (u_long)argp->prev_lsn.offset);
1059 printf("\topcode: %lu\n", (u_long)argp->opcode);
1060 printf("\tfileid: %lu\n", (u_long)argp->fileid);
1061 printf("\tpgno: %lu\n", (u_long)argp->pgno);
1062 printf("\tfree_pgno: %lu\n", (u_long)argp->free_pgno);
1063 printf("\told_type: %lu\n", (u_long)argp->old_type);
1064 printf("\told_pgno: %lu\n", (u_long)argp->old_pgno);
1065 printf("\tnew_type: %lu\n", (u_long)argp->new_type);
1066 printf("\tpagelsn: [%lu][%lu]\n",
1067 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
1068 printf("\tmetalsn: [%lu][%lu]\n",
1069 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
1076 * PUBLIC: int __ham_newpgno_read __P((void *, __ham_newpgno_args **));
1079 __ham_newpgno_read(recbuf, argpp)
1081 __ham_newpgno_args **argpp;
1083 __ham_newpgno_args *argp;
1086 argp = (__ham_newpgno_args *)__db_malloc(sizeof(__ham_newpgno_args) +
1090 argp->txnid = (DB_TXN *)&argp[1];
1092 memcpy(&argp->type, bp, sizeof(argp->type));
1093 bp += sizeof(argp->type);
1094 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
1095 bp += sizeof(argp->txnid->txnid);
1096 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
1097 bp += sizeof(DB_LSN);
1098 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
1099 bp += sizeof(argp->opcode);
1100 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
1101 bp += sizeof(argp->fileid);
1102 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
1103 bp += sizeof(argp->pgno);
1104 memcpy(&argp->free_pgno, bp, sizeof(argp->free_pgno));
1105 bp += sizeof(argp->free_pgno);
1106 memcpy(&argp->old_type, bp, sizeof(argp->old_type));
1107 bp += sizeof(argp->old_type);
1108 memcpy(&argp->old_pgno, bp, sizeof(argp->old_pgno));
1109 bp += sizeof(argp->old_pgno);
1110 memcpy(&argp->new_type, bp, sizeof(argp->new_type));
1111 bp += sizeof(argp->new_type);
1112 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
1113 bp += sizeof(argp->pagelsn);
1114 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
1115 bp += sizeof(argp->metalsn);
1121 * PUBLIC: int __ham_ovfl_log
1122 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
1123 * PUBLIC: u_int32_t, db_pgno_t, u_int32_t, db_pgno_t,
1124 * PUBLIC: u_int32_t, DB_LSN *));
1126 int __ham_ovfl_log(logp, txnid, ret_lsnp, flags,
1127 fileid, start_pgno, npages, free_pgno, ovflpoint, metalsn)
1133 db_pgno_t start_pgno;
1135 db_pgno_t free_pgno;
1136 u_int32_t ovflpoint;
1140 DB_LSN *lsnp, null_lsn;
1141 u_int32_t rectype, txn_num;
1145 rectype = DB_ham_ovfl;
1146 txn_num = txnid == NULL ? 0 : txnid->txnid;
1147 if (txnid == NULL) {
1149 null_lsn.offset = 0;
1152 lsnp = &txnid->last_lsn;
1153 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
1155 + sizeof(start_pgno)
1160 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
1164 memcpy(bp, &rectype, sizeof(rectype));
1165 bp += sizeof(rectype);
1166 memcpy(bp, &txn_num, sizeof(txn_num));
1167 bp += sizeof(txn_num);
1168 memcpy(bp, lsnp, sizeof(DB_LSN));
1169 bp += sizeof(DB_LSN);
1170 memcpy(bp, &fileid, sizeof(fileid));
1171 bp += sizeof(fileid);
1172 memcpy(bp, &start_pgno, sizeof(start_pgno));
1173 bp += sizeof(start_pgno);
1174 memcpy(bp, &npages, sizeof(npages));
1175 bp += sizeof(npages);
1176 memcpy(bp, &free_pgno, sizeof(free_pgno));
1177 bp += sizeof(free_pgno);
1178 memcpy(bp, &ovflpoint, sizeof(ovflpoint));
1179 bp += sizeof(ovflpoint);
1180 if (metalsn != NULL)
1181 memcpy(bp, metalsn, sizeof(*metalsn));
1183 memset(bp, 0, sizeof(*metalsn));
1184 bp += sizeof(*metalsn);
1186 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
1187 fprintf(stderr, "Error in log record length");
1189 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
1191 txnid->last_lsn = *ret_lsnp;
1192 __db_free(logrec.data);
1197 * PUBLIC: int __ham_ovfl_print
1198 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1201 __ham_ovfl_print(notused1, dbtp, lsnp, notused3, notused4)
1208 __ham_ovfl_args *argp;
1218 if ((ret = __ham_ovfl_read(dbtp->data, &argp)) != 0)
1220 printf("[%lu][%lu]ham_ovfl: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1222 (u_long)lsnp->offset,
1224 (u_long)argp->txnid->txnid,
1225 (u_long)argp->prev_lsn.file,
1226 (u_long)argp->prev_lsn.offset);
1227 printf("\tfileid: %lu\n", (u_long)argp->fileid);
1228 printf("\tstart_pgno: %lu\n", (u_long)argp->start_pgno);
1229 printf("\tnpages: %lu\n", (u_long)argp->npages);
1230 printf("\tfree_pgno: %lu\n", (u_long)argp->free_pgno);
1231 printf("\tovflpoint: %lu\n", (u_long)argp->ovflpoint);
1232 printf("\tmetalsn: [%lu][%lu]\n",
1233 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
1240 * PUBLIC: int __ham_ovfl_read __P((void *, __ham_ovfl_args **));
1243 __ham_ovfl_read(recbuf, argpp)
1245 __ham_ovfl_args **argpp;
1247 __ham_ovfl_args *argp;
1250 argp = (__ham_ovfl_args *)__db_malloc(sizeof(__ham_ovfl_args) +
1254 argp->txnid = (DB_TXN *)&argp[1];
1256 memcpy(&argp->type, bp, sizeof(argp->type));
1257 bp += sizeof(argp->type);
1258 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
1259 bp += sizeof(argp->txnid->txnid);
1260 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
1261 bp += sizeof(DB_LSN);
1262 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
1263 bp += sizeof(argp->fileid);
1264 memcpy(&argp->start_pgno, bp, sizeof(argp->start_pgno));
1265 bp += sizeof(argp->start_pgno);
1266 memcpy(&argp->npages, bp, sizeof(argp->npages));
1267 bp += sizeof(argp->npages);
1268 memcpy(&argp->free_pgno, bp, sizeof(argp->free_pgno));
1269 bp += sizeof(argp->free_pgno);
1270 memcpy(&argp->ovflpoint, bp, sizeof(argp->ovflpoint));
1271 bp += sizeof(argp->ovflpoint);
1272 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
1273 bp += sizeof(argp->metalsn);
1279 * PUBLIC: int __ham_copypage_log
1280 * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
1281 * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t,
1282 * PUBLIC: DB_LSN *, db_pgno_t, DB_LSN *, const DBT *));
1284 int __ham_copypage_log(logp, txnid, ret_lsnp, flags,
1285 fileid, pgno, pagelsn, next_pgno, nextlsn, nnext_pgno,
1294 db_pgno_t next_pgno;
1296 db_pgno_t nnext_pgno;
1301 DB_LSN *lsnp, null_lsn;
1303 u_int32_t rectype, txn_num;
1307 rectype = DB_ham_copypage;
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)
1321 + sizeof(nnext_pgno)
1323 + sizeof(u_int32_t) + (page == NULL ? 0 : page->size);
1324 if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
1328 memcpy(bp, &rectype, sizeof(rectype));
1329 bp += sizeof(rectype);
1330 memcpy(bp, &txn_num, sizeof(txn_num));
1331 bp += sizeof(txn_num);
1332 memcpy(bp, lsnp, sizeof(DB_LSN));
1333 bp += sizeof(DB_LSN);
1334 memcpy(bp, &fileid, sizeof(fileid));
1335 bp += sizeof(fileid);
1336 memcpy(bp, &pgno, sizeof(pgno));
1338 if (pagelsn != NULL)
1339 memcpy(bp, pagelsn, sizeof(*pagelsn));
1341 memset(bp, 0, sizeof(*pagelsn));
1342 bp += sizeof(*pagelsn);
1343 memcpy(bp, &next_pgno, sizeof(next_pgno));
1344 bp += sizeof(next_pgno);
1345 if (nextlsn != NULL)
1346 memcpy(bp, nextlsn, sizeof(*nextlsn));
1348 memset(bp, 0, sizeof(*nextlsn));
1349 bp += sizeof(*nextlsn);
1350 memcpy(bp, &nnext_pgno, sizeof(nnext_pgno));
1351 bp += sizeof(nnext_pgno);
1352 if (nnextlsn != NULL)
1353 memcpy(bp, nnextlsn, sizeof(*nnextlsn));
1355 memset(bp, 0, sizeof(*nnextlsn));
1356 bp += sizeof(*nnextlsn);
1359 memcpy(bp, &zero, sizeof(u_int32_t));
1360 bp += sizeof(u_int32_t);
1362 memcpy(bp, &page->size, sizeof(page->size));
1363 bp += sizeof(page->size);
1364 memcpy(bp, page->data, page->size);
1368 if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
1369 fprintf(stderr, "Error in log record length");
1371 ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
1373 txnid->last_lsn = *ret_lsnp;
1374 __db_free(logrec.data);
1379 * PUBLIC: int __ham_copypage_print
1380 * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1383 __ham_copypage_print(notused1, dbtp, lsnp, notused3, notused4)
1390 __ham_copypage_args *argp;
1400 if ((ret = __ham_copypage_read(dbtp->data, &argp)) != 0)
1402 printf("[%lu][%lu]ham_copypage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
1404 (u_long)lsnp->offset,
1406 (u_long)argp->txnid->txnid,
1407 (u_long)argp->prev_lsn.file,
1408 (u_long)argp->prev_lsn.offset);
1409 printf("\tfileid: %lu\n", (u_long)argp->fileid);
1410 printf("\tpgno: %lu\n", (u_long)argp->pgno);
1411 printf("\tpagelsn: [%lu][%lu]\n",
1412 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
1413 printf("\tnext_pgno: %lu\n", (u_long)argp->next_pgno);
1414 printf("\tnextlsn: [%lu][%lu]\n",
1415 (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset);
1416 printf("\tnnext_pgno: %lu\n", (u_long)argp->nnext_pgno);
1417 printf("\tnnextlsn: [%lu][%lu]\n",
1418 (u_long)argp->nnextlsn.file, (u_long)argp->nnextlsn.offset);
1420 for (i = 0; i < argp->page.size; i++) {
1421 c = ((char *)argp->page.data)[i];
1422 if (isprint(c) || c == 0xa)
1434 * PUBLIC: int __ham_copypage_read __P((void *, __ham_copypage_args **));
1437 __ham_copypage_read(recbuf, argpp)
1439 __ham_copypage_args **argpp;
1441 __ham_copypage_args *argp;
1444 argp = (__ham_copypage_args *)__db_malloc(sizeof(__ham_copypage_args) +
1448 argp->txnid = (DB_TXN *)&argp[1];
1450 memcpy(&argp->type, bp, sizeof(argp->type));
1451 bp += sizeof(argp->type);
1452 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
1453 bp += sizeof(argp->txnid->txnid);
1454 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
1455 bp += sizeof(DB_LSN);
1456 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
1457 bp += sizeof(argp->fileid);
1458 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
1459 bp += sizeof(argp->pgno);
1460 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
1461 bp += sizeof(argp->pagelsn);
1462 memcpy(&argp->next_pgno, bp, sizeof(argp->next_pgno));
1463 bp += sizeof(argp->next_pgno);
1464 memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn));
1465 bp += sizeof(argp->nextlsn);
1466 memcpy(&argp->nnext_pgno, bp, sizeof(argp->nnext_pgno));
1467 bp += sizeof(argp->nnext_pgno);
1468 memcpy(&argp->nnextlsn, bp, sizeof(argp->nnextlsn));
1469 bp += sizeof(argp->nnextlsn);
1470 memcpy(&argp->page.size, bp, sizeof(u_int32_t));
1471 bp += sizeof(u_int32_t);
1472 argp->page.data = bp;
1473 bp += argp->page.size;
1479 * PUBLIC: int __ham_init_print __P((DB_ENV *));
1482 __ham_init_print(dbenv)
1487 if ((ret = __db_add_recovery(dbenv,
1488 __ham_insdel_print, DB_ham_insdel)) != 0)
1490 if ((ret = __db_add_recovery(dbenv,
1491 __ham_newpage_print, DB_ham_newpage)) != 0)
1493 if ((ret = __db_add_recovery(dbenv,
1494 __ham_splitmeta_print, DB_ham_splitmeta)) != 0)
1496 if ((ret = __db_add_recovery(dbenv,
1497 __ham_splitdata_print, DB_ham_splitdata)) != 0)
1499 if ((ret = __db_add_recovery(dbenv,
1500 __ham_replace_print, DB_ham_replace)) != 0)
1502 if ((ret = __db_add_recovery(dbenv,
1503 __ham_newpgno_print, DB_ham_newpgno)) != 0)
1505 if ((ret = __db_add_recovery(dbenv,
1506 __ham_ovfl_print, DB_ham_ovfl)) != 0)
1508 if ((ret = __db_add_recovery(dbenv,
1509 __ham_copypage_print, DB_ham_copypage)) != 0)
1515 * PUBLIC: int __ham_init_recover __P((DB_ENV *));
1518 __ham_init_recover(dbenv)
1523 if ((ret = __db_add_recovery(dbenv,
1524 __ham_insdel_recover, DB_ham_insdel)) != 0)
1526 if ((ret = __db_add_recovery(dbenv,
1527 __ham_newpage_recover, DB_ham_newpage)) != 0)
1529 if ((ret = __db_add_recovery(dbenv,
1530 __ham_splitmeta_recover, DB_ham_splitmeta)) != 0)
1532 if ((ret = __db_add_recovery(dbenv,
1533 __ham_splitdata_recover, DB_ham_splitdata)) != 0)
1535 if ((ret = __db_add_recovery(dbenv,
1536 __ham_replace_recover, DB_ham_replace)) != 0)
1538 if ((ret = __db_add_recovery(dbenv,
1539 __ham_newpgno_recover, DB_ham_newpgno)) != 0)
1541 if ((ret = __db_add_recovery(dbenv,
1542 __ham_ovfl_recover, DB_ham_ovfl)) != 0)
1544 if ((ret = __db_add_recovery(dbenv,
1545 __ham_copypage_recover, DB_ham_copypage)) != 0)