Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / nvi / common / vi_auto.c
blobe0208e18878df14a99cfa7b7f5e8e1a9d5fb21cf
1 /* $NetBSD$ */
3 /* Do not edit: automatically built by gen_rec.awk. */
4 #include <sys/types.h>
5 #include <sys/queue.h>
6 #include <sys/stat.h>
7 #include <bitstring.h>
8 #include <errno.h>
9 #include <fcntl.h>
10 #include <limits.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include "common.h"
15 #include <db_int.h>
16 #include "db_page.h"
17 #include "db_am.h"
18 #include "rep.h"
19 #include "txn.h"
21 * PUBLIC: #ifdef USE_DB4_LOGGING
24 * PUBLIC: int __vi_marker_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
25 * PUBLIC: u_int32_t));
27 int
28 __vi_marker_log(dbenv, txnid, ret_lsnp, flags,
29 opcode)
30 DB_ENV *dbenv;
31 DB_TXN *txnid;
32 DB_LSN *ret_lsnp;
33 u_int32_t flags;
34 u_int32_t opcode;
36 DBT logrec;
37 DB_LSN *lsnp, null_lsn;
38 u_int32_t uinttmp;
39 u_int32_t rectype, txn_num;
40 int ret;
41 u_int8_t *bp;
43 rectype = DB_vi_marker;
44 if (txnid != NULL &&
45 TAILQ_FIRST(&txnid->kids) != NULL &&
46 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
47 return (ret);
48 txn_num = txnid == NULL ? 0 : txnid->txnid;
49 if (txnid == NULL) {
50 ZERO_LSN(null_lsn);
51 lsnp = &null_lsn;
52 } else
53 lsnp = &txnid->last_lsn;
54 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
55 + sizeof(u_int32_t);
56 if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
57 return (ret);
59 bp = logrec.data;
61 memcpy(bp, &rectype, sizeof(rectype));
62 bp += sizeof(rectype);
64 memcpy(bp, &txn_num, sizeof(txn_num));
65 bp += sizeof(txn_num);
67 memcpy(bp, lsnp, sizeof(DB_LSN));
68 bp += sizeof(DB_LSN);
70 uinttmp = (u_int32_t)opcode;
71 memcpy(bp, &uinttmp, sizeof(uinttmp));
72 bp += sizeof(uinttmp);
74 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
75 ret = dbenv->log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
76 if (txnid != NULL && ret == 0)
77 txnid->last_lsn = *ret_lsnp;
78 #ifdef LOG_DIAGNOSTIC
79 if (ret != 0)
80 (void)__vi_marker_print(dbenv,
81 (DBT *)&logrec, ret_lsnp, NULL, NULL);
82 #endif
83 __os_free(dbenv, logrec.data, logrec.size);
84 return (ret);
88 * PUBLIC: int __vi_marker_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
89 * PUBLIC: void *));
91 int
92 __vi_marker_getpgnos(dbenv, rec, lsnp, notused1, summary)
93 DB_ENV *dbenv;
94 DBT *rec;
95 DB_LSN *lsnp;
96 db_recops notused1;
97 void *summary;
99 TXN_RECS *t;
100 int ret;
101 COMPQUIET(rec, NULL);
102 COMPQUIET(notused1, DB_TXN_ABORT);
104 t = (TXN_RECS *)summary;
106 if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
107 return (ret);
109 t->array[t->npages].flags = LSN_PAGE_NOLOCK;
110 t->array[t->npages].lsn = *lsnp;
111 t->array[t->npages].fid = DB_LOGFILEID_INVALID;
112 memset(&t->array[t->npages].pgdesc, 0,
113 sizeof(t->array[t->npages].pgdesc));
115 t->npages++;
117 return (0);
121 * PUBLIC: int __vi_marker_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
122 * PUBLIC: void *));
125 __vi_marker_print(dbenv, dbtp, lsnp, notused2, notused3)
126 DB_ENV *dbenv;
127 DBT *dbtp;
128 DB_LSN *lsnp;
129 db_recops notused2;
130 void *notused3;
132 __vi_marker_args *argp;
133 int ret;
135 notused2 = DB_TXN_ABORT;
136 notused3 = NULL;
138 if ((ret = __vi_marker_read(dbenv, dbtp->data, &argp)) != 0)
139 return (ret);
140 (void)printf(
141 "[%lu][%lu]vi_marker: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
142 (u_long)lsnp->file,
143 (u_long)lsnp->offset,
144 (u_long)argp->type,
145 (u_long)argp->txnid->txnid,
146 (u_long)argp->prev_lsn.file,
147 (u_long)argp->prev_lsn.offset);
148 (void)printf("\topcode: %lu\n", (u_long)argp->opcode);
149 (void)printf("\n");
150 __os_free(dbenv, argp, 0);
151 return (0);
155 * PUBLIC: int __vi_marker_read __P((DB_ENV *, void *, __vi_marker_args **));
158 __vi_marker_read(dbenv, recbuf, argpp)
159 DB_ENV *dbenv;
160 void *recbuf;
161 __vi_marker_args **argpp;
163 __vi_marker_args *argp;
164 int ret;
165 u_int32_t uinttmp;
166 u_int8_t *bp;
168 ret = __os_malloc(dbenv, sizeof(__vi_marker_args) +
169 sizeof(DB_TXN), &argp);
170 if (ret != 0)
171 return (ret);
172 argp->txnid = (DB_TXN *)&argp[1];
174 bp = recbuf;
175 memcpy(&argp->type, bp, sizeof(argp->type));
176 bp += sizeof(argp->type);
178 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
179 bp += sizeof(argp->txnid->txnid);
181 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
182 bp += sizeof(DB_LSN);
184 memcpy(&uinttmp, bp, sizeof(uinttmp));
185 argp->opcode = (u_int32_t)uinttmp;
186 bp += sizeof(uinttmp);
188 *argpp = argp;
189 return (0);
193 * PUBLIC: int __vi_cursor_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
194 * PUBLIC: u_int32_t, db_recno_t, size_t));
197 __vi_cursor_log(dbenv, txnid, ret_lsnp, flags,
198 opcode, lno, cno)
199 DB_ENV *dbenv;
200 DB_TXN *txnid;
201 DB_LSN *ret_lsnp;
202 u_int32_t flags;
203 u_int32_t opcode;
204 db_recno_t lno;
205 size_t cno;
207 DBT logrec;
208 DB_LSN *lsnp, null_lsn;
209 u_int32_t uinttmp;
210 u_int32_t rectype, txn_num;
211 int ret;
212 u_int8_t *bp;
214 rectype = DB_vi_cursor;
215 if (txnid != NULL &&
216 TAILQ_FIRST(&txnid->kids) != NULL &&
217 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
218 return (ret);
219 txn_num = txnid == NULL ? 0 : txnid->txnid;
220 if (txnid == NULL) {
221 ZERO_LSN(null_lsn);
222 lsnp = &null_lsn;
223 } else
224 lsnp = &txnid->last_lsn;
225 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
226 + sizeof(u_int32_t)
227 + sizeof(u_int32_t)
228 + sizeof(u_int32_t);
229 if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
230 return (ret);
232 bp = logrec.data;
234 memcpy(bp, &rectype, sizeof(rectype));
235 bp += sizeof(rectype);
237 memcpy(bp, &txn_num, sizeof(txn_num));
238 bp += sizeof(txn_num);
240 memcpy(bp, lsnp, sizeof(DB_LSN));
241 bp += sizeof(DB_LSN);
243 uinttmp = (u_int32_t)opcode;
244 memcpy(bp, &uinttmp, sizeof(uinttmp));
245 bp += sizeof(uinttmp);
247 uinttmp = (u_int32_t)lno;
248 memcpy(bp, &uinttmp, sizeof(uinttmp));
249 bp += sizeof(uinttmp);
251 uinttmp = (u_int32_t)cno;
252 memcpy(bp, &uinttmp, sizeof(uinttmp));
253 bp += sizeof(uinttmp);
255 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
256 ret = dbenv->log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
257 if (txnid != NULL && ret == 0)
258 txnid->last_lsn = *ret_lsnp;
259 #ifdef LOG_DIAGNOSTIC
260 if (ret != 0)
261 (void)__vi_cursor_print(dbenv,
262 (DBT *)&logrec, ret_lsnp, NULL, NULL);
263 #endif
264 __os_free(dbenv, logrec.data, logrec.size);
265 return (ret);
269 * PUBLIC: int __vi_cursor_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
270 * PUBLIC: void *));
273 __vi_cursor_getpgnos(dbenv, rec, lsnp, notused1, summary)
274 DB_ENV *dbenv;
275 DBT *rec;
276 DB_LSN *lsnp;
277 db_recops notused1;
278 void *summary;
280 TXN_RECS *t;
281 int ret;
282 COMPQUIET(rec, NULL);
283 COMPQUIET(notused1, DB_TXN_ABORT);
285 t = (TXN_RECS *)summary;
287 if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
288 return (ret);
290 t->array[t->npages].flags = LSN_PAGE_NOLOCK;
291 t->array[t->npages].lsn = *lsnp;
292 t->array[t->npages].fid = DB_LOGFILEID_INVALID;
293 memset(&t->array[t->npages].pgdesc, 0,
294 sizeof(t->array[t->npages].pgdesc));
296 t->npages++;
298 return (0);
302 * PUBLIC: int __vi_cursor_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
303 * PUBLIC: void *));
306 __vi_cursor_print(dbenv, dbtp, lsnp, notused2, notused3)
307 DB_ENV *dbenv;
308 DBT *dbtp;
309 DB_LSN *lsnp;
310 db_recops notused2;
311 void *notused3;
313 __vi_cursor_args *argp;
314 int ret;
316 notused2 = DB_TXN_ABORT;
317 notused3 = NULL;
319 if ((ret = __vi_cursor_read(dbenv, dbtp->data, &argp)) != 0)
320 return (ret);
321 (void)printf(
322 "[%lu][%lu]vi_cursor: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
323 (u_long)lsnp->file,
324 (u_long)lsnp->offset,
325 (u_long)argp->type,
326 (u_long)argp->txnid->txnid,
327 (u_long)argp->prev_lsn.file,
328 (u_long)argp->prev_lsn.offset);
329 (void)printf("\topcode: %lu\n", (u_long)argp->opcode);
330 (void)printf("\tlno: %lu\n", (u_long)argp->lno);
331 (void)printf("\tcno: %d\n", argp->cno);
332 (void)printf("\n");
333 __os_free(dbenv, argp, 0);
334 return (0);
338 * PUBLIC: int __vi_cursor_read __P((DB_ENV *, void *, __vi_cursor_args **));
341 __vi_cursor_read(dbenv, recbuf, argpp)
342 DB_ENV *dbenv;
343 void *recbuf;
344 __vi_cursor_args **argpp;
346 __vi_cursor_args *argp;
347 int ret;
348 u_int32_t uinttmp;
349 u_int8_t *bp;
351 ret = __os_malloc(dbenv, sizeof(__vi_cursor_args) +
352 sizeof(DB_TXN), &argp);
353 if (ret != 0)
354 return (ret);
355 argp->txnid = (DB_TXN *)&argp[1];
357 bp = recbuf;
358 memcpy(&argp->type, bp, sizeof(argp->type));
359 bp += sizeof(argp->type);
361 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
362 bp += sizeof(argp->txnid->txnid);
364 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
365 bp += sizeof(DB_LSN);
367 memcpy(&uinttmp, bp, sizeof(uinttmp));
368 argp->opcode = (u_int32_t)uinttmp;
369 bp += sizeof(uinttmp);
371 memcpy(&uinttmp, bp, sizeof(uinttmp));
372 argp->lno = (db_recno_t)uinttmp;
373 bp += sizeof(uinttmp);
375 memcpy(&uinttmp, bp, sizeof(uinttmp));
376 argp->cno = (size_t)uinttmp;
377 bp += sizeof(uinttmp);
379 *argpp = argp;
380 return (0);
384 * PUBLIC: int __vi_mark_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
385 * PUBLIC: LMARK *));
388 __vi_mark_log(dbenv, txnid, ret_lsnp, flags,
389 lmp)
390 DB_ENV *dbenv;
391 DB_TXN *txnid;
392 DB_LSN *ret_lsnp;
393 u_int32_t flags;
394 LMARK * lmp;
396 DBT logrec;
397 DB_LSN *lsnp, null_lsn;
398 u_int32_t rectype, txn_num;
399 int ret;
400 u_int8_t *bp;
402 rectype = DB_vi_mark;
403 if (txnid != NULL &&
404 TAILQ_FIRST(&txnid->kids) != NULL &&
405 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
406 return (ret);
407 txn_num = txnid == NULL ? 0 : txnid->txnid;
408 if (txnid == NULL) {
409 ZERO_LSN(null_lsn);
410 lsnp = &null_lsn;
411 } else
412 lsnp = &txnid->last_lsn;
413 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
414 + sizeof(*lmp);
415 if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
416 return (ret);
418 bp = logrec.data;
420 memcpy(bp, &rectype, sizeof(rectype));
421 bp += sizeof(rectype);
423 memcpy(bp, &txn_num, sizeof(txn_num));
424 bp += sizeof(txn_num);
426 memcpy(bp, lsnp, sizeof(DB_LSN));
427 bp += sizeof(DB_LSN);
429 if (lmp != NULL)
430 memcpy(bp, lmp, sizeof(*lmp));
431 else
432 memset(bp, 0, sizeof(*lmp));
433 bp += sizeof(*lmp);
435 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
436 ret = dbenv->log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
437 if (txnid != NULL && ret == 0)
438 txnid->last_lsn = *ret_lsnp;
439 #ifdef LOG_DIAGNOSTIC
440 if (ret != 0)
441 (void)__vi_mark_print(dbenv,
442 (DBT *)&logrec, ret_lsnp, NULL, NULL);
443 #endif
444 __os_free(dbenv, logrec.data, logrec.size);
445 return (ret);
449 * PUBLIC: int __vi_mark_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
450 * PUBLIC: void *));
453 __vi_mark_getpgnos(dbenv, rec, lsnp, notused1, summary)
454 DB_ENV *dbenv;
455 DBT *rec;
456 DB_LSN *lsnp;
457 db_recops notused1;
458 void *summary;
460 TXN_RECS *t;
461 int ret;
462 COMPQUIET(rec, NULL);
463 COMPQUIET(notused1, DB_TXN_ABORT);
465 t = (TXN_RECS *)summary;
467 if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
468 return (ret);
470 t->array[t->npages].flags = LSN_PAGE_NOLOCK;
471 t->array[t->npages].lsn = *lsnp;
472 t->array[t->npages].fid = DB_LOGFILEID_INVALID;
473 memset(&t->array[t->npages].pgdesc, 0,
474 sizeof(t->array[t->npages].pgdesc));
476 t->npages++;
478 return (0);
482 * PUBLIC: int __vi_mark_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
483 * PUBLIC: void *));
486 __vi_mark_print(dbenv, dbtp, lsnp, notused2, notused3)
487 DB_ENV *dbenv;
488 DBT *dbtp;
489 DB_LSN *lsnp;
490 db_recops notused2;
491 void *notused3;
493 __vi_mark_args *argp;
494 int ret;
496 notused2 = DB_TXN_ABORT;
497 notused3 = NULL;
499 if ((ret = __vi_mark_read(dbenv, dbtp->data, &argp)) != 0)
500 return (ret);
501 (void)printf(
502 "[%lu][%lu]vi_mark: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
503 (u_long)lsnp->file,
504 (u_long)lsnp->offset,
505 (u_long)argp->type,
506 (u_long)argp->txnid->txnid,
507 (u_long)argp->prev_lsn.file,
508 (u_long)argp->prev_lsn.offset);
509 (void)printf("\tlmp: %%\n", argp->lmp);
510 (void)printf("\n");
511 __os_free(dbenv, argp, 0);
512 return (0);
516 * PUBLIC: int __vi_mark_read __P((DB_ENV *, void *, __vi_mark_args **));
519 __vi_mark_read(dbenv, recbuf, argpp)
520 DB_ENV *dbenv;
521 void *recbuf;
522 __vi_mark_args **argpp;
524 __vi_mark_args *argp;
525 int ret;
526 u_int8_t *bp;
528 ret = __os_malloc(dbenv, sizeof(__vi_mark_args) +
529 sizeof(DB_TXN), &argp);
530 if (ret != 0)
531 return (ret);
532 argp->txnid = (DB_TXN *)&argp[1];
534 bp = recbuf;
535 memcpy(&argp->type, bp, sizeof(argp->type));
536 bp += sizeof(argp->type);
538 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
539 bp += sizeof(argp->txnid->txnid);
541 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
542 bp += sizeof(DB_LSN);
544 memcpy(&argp->lmp, bp, sizeof(argp->lmp));
545 bp += sizeof(argp->lmp);
547 *argpp = argp;
548 return (0);
552 * PUBLIC: int __vi_change_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
553 * PUBLIC: u_int32_t, db_recno_t));
556 __vi_change_log(dbenv, txnid, ret_lsnp, flags,
557 opcode, lno)
558 DB_ENV *dbenv;
559 DB_TXN *txnid;
560 DB_LSN *ret_lsnp;
561 u_int32_t flags;
562 u_int32_t opcode;
563 db_recno_t lno;
565 DBT logrec;
566 DB_LSN *lsnp, null_lsn;
567 u_int32_t uinttmp;
568 u_int32_t rectype, txn_num;
569 int ret;
570 u_int8_t *bp;
572 rectype = DB_vi_change;
573 if (txnid != NULL &&
574 TAILQ_FIRST(&txnid->kids) != NULL &&
575 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
576 return (ret);
577 txn_num = txnid == NULL ? 0 : txnid->txnid;
578 if (txnid == NULL) {
579 ZERO_LSN(null_lsn);
580 lsnp = &null_lsn;
581 } else
582 lsnp = &txnid->last_lsn;
583 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
584 + sizeof(u_int32_t)
585 + sizeof(u_int32_t);
586 if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
587 return (ret);
589 bp = logrec.data;
591 memcpy(bp, &rectype, sizeof(rectype));
592 bp += sizeof(rectype);
594 memcpy(bp, &txn_num, sizeof(txn_num));
595 bp += sizeof(txn_num);
597 memcpy(bp, lsnp, sizeof(DB_LSN));
598 bp += sizeof(DB_LSN);
600 uinttmp = (u_int32_t)opcode;
601 memcpy(bp, &uinttmp, sizeof(uinttmp));
602 bp += sizeof(uinttmp);
604 uinttmp = (u_int32_t)lno;
605 memcpy(bp, &uinttmp, sizeof(uinttmp));
606 bp += sizeof(uinttmp);
608 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
609 ret = dbenv->log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
610 if (txnid != NULL && ret == 0)
611 txnid->last_lsn = *ret_lsnp;
612 #ifdef LOG_DIAGNOSTIC
613 if (ret != 0)
614 (void)__vi_change_print(dbenv,
615 (DBT *)&logrec, ret_lsnp, NULL, NULL);
616 #endif
617 __os_free(dbenv, logrec.data, logrec.size);
618 return (ret);
622 * PUBLIC: int __vi_change_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
623 * PUBLIC: void *));
626 __vi_change_getpgnos(dbenv, rec, lsnp, notused1, summary)
627 DB_ENV *dbenv;
628 DBT *rec;
629 DB_LSN *lsnp;
630 db_recops notused1;
631 void *summary;
633 TXN_RECS *t;
634 int ret;
635 COMPQUIET(rec, NULL);
636 COMPQUIET(notused1, DB_TXN_ABORT);
638 t = (TXN_RECS *)summary;
640 if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
641 return (ret);
643 t->array[t->npages].flags = LSN_PAGE_NOLOCK;
644 t->array[t->npages].lsn = *lsnp;
645 t->array[t->npages].fid = DB_LOGFILEID_INVALID;
646 memset(&t->array[t->npages].pgdesc, 0,
647 sizeof(t->array[t->npages].pgdesc));
649 t->npages++;
651 return (0);
655 * PUBLIC: int __vi_change_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
656 * PUBLIC: void *));
659 __vi_change_print(dbenv, dbtp, lsnp, notused2, notused3)
660 DB_ENV *dbenv;
661 DBT *dbtp;
662 DB_LSN *lsnp;
663 db_recops notused2;
664 void *notused3;
666 __vi_change_args *argp;
667 int ret;
669 notused2 = DB_TXN_ABORT;
670 notused3 = NULL;
672 if ((ret = __vi_change_read(dbenv, dbtp->data, &argp)) != 0)
673 return (ret);
674 (void)printf(
675 "[%lu][%lu]vi_change: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
676 (u_long)lsnp->file,
677 (u_long)lsnp->offset,
678 (u_long)argp->type,
679 (u_long)argp->txnid->txnid,
680 (u_long)argp->prev_lsn.file,
681 (u_long)argp->prev_lsn.offset);
682 (void)printf("\topcode: %lu\n", (u_long)argp->opcode);
683 (void)printf("\tlno: %lu\n", (u_long)argp->lno);
684 (void)printf("\n");
685 __os_free(dbenv, argp, 0);
686 return (0);
690 * PUBLIC: int __vi_change_read __P((DB_ENV *, void *, __vi_change_args **));
693 __vi_change_read(dbenv, recbuf, argpp)
694 DB_ENV *dbenv;
695 void *recbuf;
696 __vi_change_args **argpp;
698 __vi_change_args *argp;
699 int ret;
700 u_int32_t uinttmp;
701 u_int8_t *bp;
703 ret = __os_malloc(dbenv, sizeof(__vi_change_args) +
704 sizeof(DB_TXN), &argp);
705 if (ret != 0)
706 return (ret);
707 argp->txnid = (DB_TXN *)&argp[1];
709 bp = recbuf;
710 memcpy(&argp->type, bp, sizeof(argp->type));
711 bp += sizeof(argp->type);
713 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
714 bp += sizeof(argp->txnid->txnid);
716 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
717 bp += sizeof(DB_LSN);
719 memcpy(&uinttmp, bp, sizeof(uinttmp));
720 argp->opcode = (u_int32_t)uinttmp;
721 bp += sizeof(uinttmp);
723 memcpy(&uinttmp, bp, sizeof(uinttmp));
724 argp->lno = (db_recno_t)uinttmp;
725 bp += sizeof(uinttmp);
727 *argpp = argp;
728 return (0);
732 * PUBLIC: int __vi_init_print __P((DB_ENV *, int (***)(DB_ENV *, DBT *,
733 * PUBLIC: DB_LSN *, db_recops, void *), size_t *));
736 __vi_init_print(dbenv, dtabp, dtabsizep)
737 DB_ENV *dbenv;
738 int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
739 size_t *dtabsizep;
741 int ret;
743 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
744 __vi_marker_print, DB_vi_marker)) != 0)
745 return (ret);
746 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
747 __vi_cursor_print, DB_vi_cursor)) != 0)
748 return (ret);
749 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
750 __vi_mark_print, DB_vi_mark)) != 0)
751 return (ret);
752 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
753 __vi_change_print, DB_vi_change)) != 0)
754 return (ret);
755 return (0);
759 * PUBLIC: int __vi_init_getpgnos __P((DB_ENV *, int (***)(DB_ENV *, DBT *,
760 * PUBLIC: DB_LSN *, db_recops, void *), size_t *));
763 __vi_init_getpgnos(dbenv, dtabp, dtabsizep)
764 DB_ENV *dbenv;
765 int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
766 size_t *dtabsizep;
768 int ret;
770 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
771 __vi_marker_getpgnos, DB_vi_marker)) != 0)
772 return (ret);
773 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
774 __vi_cursor_getpgnos, DB_vi_cursor)) != 0)
775 return (ret);
776 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
777 __vi_mark_getpgnos, DB_vi_mark)) != 0)
778 return (ret);
779 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
780 __vi_change_getpgnos, DB_vi_change)) != 0)
781 return (ret);
782 return (0);
786 * PUBLIC: int __vi_init_recover __P((DB_ENV *));
789 __vi_init_recover(dbenv)
790 DB_ENV *dbenv;
792 int ret;
794 if ((ret = __db_add_recovery(dbenv, &dbenv->dtab, &dbenv->dtab_size,
795 __vi_marker_recover, DB_vi_marker)) != 0)
796 return (ret);
797 if ((ret = __db_add_recovery(dbenv, &dbenv->dtab, &dbenv->dtab_size,
798 __vi_cursor_recover, DB_vi_cursor)) != 0)
799 return (ret);
800 if ((ret = __db_add_recovery(dbenv, &dbenv->dtab, &dbenv->dtab_size,
801 __vi_mark_recover, DB_vi_mark)) != 0)
802 return (ret);
803 if ((ret = __db_add_recovery(dbenv, &dbenv->dtab, &dbenv->dtab_size,
804 __vi_change_recover, DB_vi_change)) != 0)
805 return (ret);
806 return (0);
809 * PUBLIC: #endif