00001
00002 #include "config.h"
00003
00004 #ifndef NO_SYSTEM_INCLUDES
00005 #include <sys/types.h>
00006
00007 #include <ctype.h>
00008 #include <errno.h>
00009 #include <string.h>
00010 #endif
00011
00012 #include "db_int.h"
00013 #include "db_page.h"
00014 #include "db_dispatch.h"
00015 #include "db_am.h"
00016 #include "txn.h"
00017
00018 int
00019 CDB___txn_old_regop_print(dbenv, dbtp, lsnp, notused2, notused3)
00020 DB_ENV *dbenv;
00021 DBT *dbtp;
00022 DB_LSN *lsnp;
00023 db_recops notused2;
00024 void *notused3;
00025 {
00026 __txn_old_regop_args *argp;
00027 u_int32_t i;
00028 u_int ch;
00029 int ret;
00030
00031 i = 0;
00032 ch = 0;
00033 notused2 = 0;
00034 notused3 = NULL;
00035
00036 if ((ret = CDB___txn_old_regop_read(dbenv, dbtp->data, &argp)) != 0)
00037 return (ret);
00038 printf("[%lu][%lu]txn_old_regop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00039 (u_long)lsnp->file,
00040 (u_long)lsnp->offset,
00041 (u_long)argp->type,
00042 (u_long)argp->txnid->txnid,
00043 (u_long)argp->prev_lsn.file,
00044 (u_long)argp->prev_lsn.offset);
00045 printf("\topcode: %lu\n", (u_long)argp->opcode);
00046 printf("\n");
00047 CDB___os_free(argp, 0);
00048 return (0);
00049 }
00050
00051 int
00052 CDB___txn_old_regop_read(dbenv, recbuf, argpp)
00053 DB_ENV *dbenv;
00054 void *recbuf;
00055 __txn_old_regop_args **argpp;
00056 {
00057 __txn_old_regop_args *argp;
00058 u_int8_t *bp;
00059 int ret;
00060
00061 ret = CDB___os_malloc(dbenv, sizeof(__txn_old_regop_args) +
00062 sizeof(DB_TXN), NULL, &argp);
00063 if (ret != 0)
00064 return (ret);
00065 argp->txnid = (DB_TXN *)&argp[1];
00066 bp = recbuf;
00067 memcpy(&argp->type, bp, sizeof(argp->type));
00068 bp += sizeof(argp->type);
00069 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00070 bp += sizeof(argp->txnid->txnid);
00071 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00072 bp += sizeof(DB_LSN);
00073 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00074 bp += sizeof(argp->opcode);
00075 *argpp = argp;
00076 return (0);
00077 }
00078
00079 int CDB___txn_regop_log(dbenv, txnid, ret_lsnp, flags,
00080 opcode, timestamp)
00081 DB_ENV *dbenv;
00082 DB_TXN *txnid;
00083 DB_LSN *ret_lsnp;
00084 u_int32_t flags;
00085 u_int32_t opcode;
00086 int32_t timestamp;
00087 {
00088 DBT logrec;
00089 DB_LSN *lsnp, null_lsn;
00090 u_int32_t rectype, txn_num;
00091 int ret;
00092 u_int8_t *bp;
00093
00094 if (txnid != NULL &&
00095 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00096 return (CDB___db_child_active_err(dbenv));
00097 rectype = DB_txn_regop;
00098 txn_num = txnid == NULL ? 0 : txnid->txnid;
00099 if (txnid == NULL) {
00100 ZERO_LSN(null_lsn);
00101 lsnp = &null_lsn;
00102 } else
00103 lsnp = &txnid->last_lsn;
00104 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00105 + sizeof(opcode)
00106 + sizeof(timestamp);
00107 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00108 return (ret);
00109
00110 bp = logrec.data;
00111 memcpy(bp, &rectype, sizeof(rectype));
00112 bp += sizeof(rectype);
00113 memcpy(bp, &txn_num, sizeof(txn_num));
00114 bp += sizeof(txn_num);
00115 memcpy(bp, lsnp, sizeof(DB_LSN));
00116 bp += sizeof(DB_LSN);
00117 memcpy(bp, &opcode, sizeof(opcode));
00118 bp += sizeof(opcode);
00119 memcpy(bp, ×tamp, sizeof(timestamp));
00120 bp += sizeof(timestamp);
00121 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00122 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00123 if (txnid != NULL)
00124 txnid->last_lsn = *ret_lsnp;
00125 CDB___os_free(logrec.data, logrec.size);
00126 return (ret);
00127 }
00128
00129 int
00130 CDB___txn_regop_print(dbenv, dbtp, lsnp, notused2, notused3)
00131 DB_ENV *dbenv;
00132 DBT *dbtp;
00133 DB_LSN *lsnp;
00134 db_recops notused2;
00135 void *notused3;
00136 {
00137 __txn_regop_args *argp;
00138 u_int32_t i;
00139 u_int ch;
00140 int ret;
00141
00142 i = 0;
00143 ch = 0;
00144 notused2 = 0;
00145 notused3 = NULL;
00146
00147 if ((ret = CDB___txn_regop_read(dbenv, dbtp->data, &argp)) != 0)
00148 return (ret);
00149 printf("[%lu][%lu]txn_regop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00150 (u_long)lsnp->file,
00151 (u_long)lsnp->offset,
00152 (u_long)argp->type,
00153 (u_long)argp->txnid->txnid,
00154 (u_long)argp->prev_lsn.file,
00155 (u_long)argp->prev_lsn.offset);
00156 printf("\topcode: %lu\n", (u_long)argp->opcode);
00157 printf("\ttimestamp: %ld\n", (long)argp->timestamp);
00158 printf("\n");
00159 CDB___os_free(argp, 0);
00160 return (0);
00161 }
00162
00163 int
00164 CDB___txn_regop_read(dbenv, recbuf, argpp)
00165 DB_ENV *dbenv;
00166 void *recbuf;
00167 __txn_regop_args **argpp;
00168 {
00169 __txn_regop_args *argp;
00170 u_int8_t *bp;
00171 int ret;
00172
00173 ret = CDB___os_malloc(dbenv, sizeof(__txn_regop_args) +
00174 sizeof(DB_TXN), NULL, &argp);
00175 if (ret != 0)
00176 return (ret);
00177 argp->txnid = (DB_TXN *)&argp[1];
00178 bp = recbuf;
00179 memcpy(&argp->type, bp, sizeof(argp->type));
00180 bp += sizeof(argp->type);
00181 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00182 bp += sizeof(argp->txnid->txnid);
00183 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00184 bp += sizeof(DB_LSN);
00185 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00186 bp += sizeof(argp->opcode);
00187 memcpy(&argp->timestamp, bp, sizeof(argp->timestamp));
00188 bp += sizeof(argp->timestamp);
00189 *argpp = argp;
00190 return (0);
00191 }
00192
00193 int
00194 CDB___txn_old_ckp_print(dbenv, dbtp, lsnp, notused2, notused3)
00195 DB_ENV *dbenv;
00196 DBT *dbtp;
00197 DB_LSN *lsnp;
00198 db_recops notused2;
00199 void *notused3;
00200 {
00201 __txn_old_ckp_args *argp;
00202 u_int32_t i;
00203 u_int ch;
00204 int ret;
00205
00206 i = 0;
00207 ch = 0;
00208 notused2 = 0;
00209 notused3 = NULL;
00210
00211 if ((ret = CDB___txn_old_ckp_read(dbenv, dbtp->data, &argp)) != 0)
00212 return (ret);
00213 printf("[%lu][%lu]txn_old_ckp: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00214 (u_long)lsnp->file,
00215 (u_long)lsnp->offset,
00216 (u_long)argp->type,
00217 (u_long)argp->txnid->txnid,
00218 (u_long)argp->prev_lsn.file,
00219 (u_long)argp->prev_lsn.offset);
00220 printf("\tckp_lsn: [%lu][%lu]\n",
00221 (u_long)argp->ckp_lsn.file, (u_long)argp->ckp_lsn.offset);
00222 printf("\tlast_ckp: [%lu][%lu]\n",
00223 (u_long)argp->last_ckp.file, (u_long)argp->last_ckp.offset);
00224 printf("\n");
00225 CDB___os_free(argp, 0);
00226 return (0);
00227 }
00228
00229 int
00230 CDB___txn_old_ckp_read(dbenv, recbuf, argpp)
00231 DB_ENV *dbenv;
00232 void *recbuf;
00233 __txn_old_ckp_args **argpp;
00234 {
00235 __txn_old_ckp_args *argp;
00236 u_int8_t *bp;
00237 int ret;
00238
00239 ret = CDB___os_malloc(dbenv, sizeof(__txn_old_ckp_args) +
00240 sizeof(DB_TXN), NULL, &argp);
00241 if (ret != 0)
00242 return (ret);
00243 argp->txnid = (DB_TXN *)&argp[1];
00244 bp = recbuf;
00245 memcpy(&argp->type, bp, sizeof(argp->type));
00246 bp += sizeof(argp->type);
00247 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00248 bp += sizeof(argp->txnid->txnid);
00249 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00250 bp += sizeof(DB_LSN);
00251 memcpy(&argp->ckp_lsn, bp, sizeof(argp->ckp_lsn));
00252 bp += sizeof(argp->ckp_lsn);
00253 memcpy(&argp->last_ckp, bp, sizeof(argp->last_ckp));
00254 bp += sizeof(argp->last_ckp);
00255 *argpp = argp;
00256 return (0);
00257 }
00258
00259 int CDB___txn_ckp_log(dbenv, txnid, ret_lsnp, flags,
00260 ckp_lsn, last_ckp, timestamp)
00261 DB_ENV *dbenv;
00262 DB_TXN *txnid;
00263 DB_LSN *ret_lsnp;
00264 u_int32_t flags;
00265 DB_LSN * ckp_lsn;
00266 DB_LSN * last_ckp;
00267 int32_t timestamp;
00268 {
00269 DBT logrec;
00270 DB_LSN *lsnp, null_lsn;
00271 u_int32_t rectype, txn_num;
00272 int ret;
00273 u_int8_t *bp;
00274
00275 if (txnid != NULL &&
00276 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00277 return (CDB___db_child_active_err(dbenv));
00278 rectype = DB_txn_ckp;
00279 txn_num = txnid == NULL ? 0 : txnid->txnid;
00280 if (txnid == NULL) {
00281 ZERO_LSN(null_lsn);
00282 lsnp = &null_lsn;
00283 } else
00284 lsnp = &txnid->last_lsn;
00285 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00286 + sizeof(*ckp_lsn)
00287 + sizeof(*last_ckp)
00288 + sizeof(timestamp);
00289 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00290 return (ret);
00291
00292 bp = logrec.data;
00293 memcpy(bp, &rectype, sizeof(rectype));
00294 bp += sizeof(rectype);
00295 memcpy(bp, &txn_num, sizeof(txn_num));
00296 bp += sizeof(txn_num);
00297 memcpy(bp, lsnp, sizeof(DB_LSN));
00298 bp += sizeof(DB_LSN);
00299 if (ckp_lsn != NULL)
00300 memcpy(bp, ckp_lsn, sizeof(*ckp_lsn));
00301 else
00302 memset(bp, 0, sizeof(*ckp_lsn));
00303 bp += sizeof(*ckp_lsn);
00304 if (last_ckp != NULL)
00305 memcpy(bp, last_ckp, sizeof(*last_ckp));
00306 else
00307 memset(bp, 0, sizeof(*last_ckp));
00308 bp += sizeof(*last_ckp);
00309 memcpy(bp, ×tamp, sizeof(timestamp));
00310 bp += sizeof(timestamp);
00311 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00312 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00313 if (txnid != NULL)
00314 txnid->last_lsn = *ret_lsnp;
00315 CDB___os_free(logrec.data, logrec.size);
00316 return (ret);
00317 }
00318
00319 int
00320 CDB___txn_ckp_print(dbenv, dbtp, lsnp, notused2, notused3)
00321 DB_ENV *dbenv;
00322 DBT *dbtp;
00323 DB_LSN *lsnp;
00324 db_recops notused2;
00325 void *notused3;
00326 {
00327 __txn_ckp_args *argp;
00328 u_int32_t i;
00329 u_int ch;
00330 int ret;
00331
00332 i = 0;
00333 ch = 0;
00334 notused2 = 0;
00335 notused3 = NULL;
00336
00337 if ((ret = CDB___txn_ckp_read(dbenv, dbtp->data, &argp)) != 0)
00338 return (ret);
00339 printf("[%lu][%lu]txn_ckp: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00340 (u_long)lsnp->file,
00341 (u_long)lsnp->offset,
00342 (u_long)argp->type,
00343 (u_long)argp->txnid->txnid,
00344 (u_long)argp->prev_lsn.file,
00345 (u_long)argp->prev_lsn.offset);
00346 printf("\tckp_lsn: [%lu][%lu]\n",
00347 (u_long)argp->ckp_lsn.file, (u_long)argp->ckp_lsn.offset);
00348 printf("\tlast_ckp: [%lu][%lu]\n",
00349 (u_long)argp->last_ckp.file, (u_long)argp->last_ckp.offset);
00350 printf("\ttimestamp: %ld\n", (long)argp->timestamp);
00351 printf("\n");
00352 CDB___os_free(argp, 0);
00353 return (0);
00354 }
00355
00356 int
00357 CDB___txn_ckp_read(dbenv, recbuf, argpp)
00358 DB_ENV *dbenv;
00359 void *recbuf;
00360 __txn_ckp_args **argpp;
00361 {
00362 __txn_ckp_args *argp;
00363 u_int8_t *bp;
00364 int ret;
00365
00366 ret = CDB___os_malloc(dbenv, sizeof(__txn_ckp_args) +
00367 sizeof(DB_TXN), NULL, &argp);
00368 if (ret != 0)
00369 return (ret);
00370 argp->txnid = (DB_TXN *)&argp[1];
00371 bp = recbuf;
00372 memcpy(&argp->type, bp, sizeof(argp->type));
00373 bp += sizeof(argp->type);
00374 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00375 bp += sizeof(argp->txnid->txnid);
00376 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00377 bp += sizeof(DB_LSN);
00378 memcpy(&argp->ckp_lsn, bp, sizeof(argp->ckp_lsn));
00379 bp += sizeof(argp->ckp_lsn);
00380 memcpy(&argp->last_ckp, bp, sizeof(argp->last_ckp));
00381 bp += sizeof(argp->last_ckp);
00382 memcpy(&argp->timestamp, bp, sizeof(argp->timestamp));
00383 bp += sizeof(argp->timestamp);
00384 *argpp = argp;
00385 return (0);
00386 }
00387
00388 int CDB___txn_xa_regop_log(dbenv, txnid, ret_lsnp, flags,
00389 opcode, xid, formatID, gtrid, bqual)
00390 DB_ENV *dbenv;
00391 DB_TXN *txnid;
00392 DB_LSN *ret_lsnp;
00393 u_int32_t flags;
00394 u_int32_t opcode;
00395 const DBT *xid;
00396 int32_t formatID;
00397 u_int32_t gtrid;
00398 u_int32_t bqual;
00399 {
00400 DBT logrec;
00401 DB_LSN *lsnp, null_lsn;
00402 u_int32_t zero;
00403 u_int32_t rectype, txn_num;
00404 int ret;
00405 u_int8_t *bp;
00406
00407 if (txnid != NULL &&
00408 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00409 return (CDB___db_child_active_err(dbenv));
00410 rectype = DB_txn_xa_regop;
00411 txn_num = txnid == NULL ? 0 : txnid->txnid;
00412 if (txnid == NULL) {
00413 ZERO_LSN(null_lsn);
00414 lsnp = &null_lsn;
00415 } else
00416 lsnp = &txnid->last_lsn;
00417 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00418 + sizeof(opcode)
00419 + sizeof(u_int32_t) + (xid == NULL ? 0 : xid->size)
00420 + sizeof(formatID)
00421 + sizeof(gtrid)
00422 + sizeof(bqual);
00423 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00424 return (ret);
00425
00426 bp = logrec.data;
00427 memcpy(bp, &rectype, sizeof(rectype));
00428 bp += sizeof(rectype);
00429 memcpy(bp, &txn_num, sizeof(txn_num));
00430 bp += sizeof(txn_num);
00431 memcpy(bp, lsnp, sizeof(DB_LSN));
00432 bp += sizeof(DB_LSN);
00433 memcpy(bp, &opcode, sizeof(opcode));
00434 bp += sizeof(opcode);
00435 if (xid == NULL) {
00436 zero = 0;
00437 memcpy(bp, &zero, sizeof(u_int32_t));
00438 bp += sizeof(u_int32_t);
00439 } else {
00440 memcpy(bp, &xid->size, sizeof(xid->size));
00441 bp += sizeof(xid->size);
00442 memcpy(bp, xid->data, xid->size);
00443 bp += xid->size;
00444 }
00445 memcpy(bp, &formatID, sizeof(formatID));
00446 bp += sizeof(formatID);
00447 memcpy(bp, >rid, sizeof(gtrid));
00448 bp += sizeof(gtrid);
00449 memcpy(bp, &bqual, sizeof(bqual));
00450 bp += sizeof(bqual);
00451 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00452 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00453 if (txnid != NULL)
00454 txnid->last_lsn = *ret_lsnp;
00455 CDB___os_free(logrec.data, logrec.size);
00456 return (ret);
00457 }
00458
00459 int
00460 CDB___txn_xa_regop_print(dbenv, dbtp, lsnp, notused2, notused3)
00461 DB_ENV *dbenv;
00462 DBT *dbtp;
00463 DB_LSN *lsnp;
00464 db_recops notused2;
00465 void *notused3;
00466 {
00467 __txn_xa_regop_args *argp;
00468 u_int32_t i;
00469 u_int ch;
00470 int ret;
00471
00472 i = 0;
00473 ch = 0;
00474 notused2 = 0;
00475 notused3 = NULL;
00476
00477 if ((ret = CDB___txn_xa_regop_read(dbenv, dbtp->data, &argp)) != 0)
00478 return (ret);
00479 printf("[%lu][%lu]txn_xa_regop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00480 (u_long)lsnp->file,
00481 (u_long)lsnp->offset,
00482 (u_long)argp->type,
00483 (u_long)argp->txnid->txnid,
00484 (u_long)argp->prev_lsn.file,
00485 (u_long)argp->prev_lsn.offset);
00486 printf("\topcode: %lu\n", (u_long)argp->opcode);
00487 printf("\txid: ");
00488 for (i = 0; i < argp->xid.size; i++) {
00489 ch = ((u_int8_t *)argp->xid.data)[i];
00490 if (isprint(ch) || ch == 0xa)
00491 putchar(ch);
00492 else
00493 printf("%#x ", ch);
00494 }
00495 printf("\n");
00496 printf("\tformatID: %ld\n", (long)argp->formatID);
00497 printf("\tgtrid: %u\n", argp->gtrid);
00498 printf("\tbqual: %u\n", argp->bqual);
00499 printf("\n");
00500 CDB___os_free(argp, 0);
00501 return (0);
00502 }
00503
00504 int
00505 CDB___txn_xa_regop_read(dbenv, recbuf, argpp)
00506 DB_ENV *dbenv;
00507 void *recbuf;
00508 __txn_xa_regop_args **argpp;
00509 {
00510 __txn_xa_regop_args *argp;
00511 u_int8_t *bp;
00512 int ret;
00513
00514 ret = CDB___os_malloc(dbenv, sizeof(__txn_xa_regop_args) +
00515 sizeof(DB_TXN), NULL, &argp);
00516 if (ret != 0)
00517 return (ret);
00518 argp->txnid = (DB_TXN *)&argp[1];
00519 bp = recbuf;
00520 memcpy(&argp->type, bp, sizeof(argp->type));
00521 bp += sizeof(argp->type);
00522 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00523 bp += sizeof(argp->txnid->txnid);
00524 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00525 bp += sizeof(DB_LSN);
00526 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00527 bp += sizeof(argp->opcode);
00528 memset(&argp->xid, 0, sizeof(argp->xid));
00529 memcpy(&argp->xid.size, bp, sizeof(u_int32_t));
00530 bp += sizeof(u_int32_t);
00531 argp->xid.data = bp;
00532 bp += argp->xid.size;
00533 memcpy(&argp->formatID, bp, sizeof(argp->formatID));
00534 bp += sizeof(argp->formatID);
00535 memcpy(&argp->gtrid, bp, sizeof(argp->gtrid));
00536 bp += sizeof(argp->gtrid);
00537 memcpy(&argp->bqual, bp, sizeof(argp->bqual));
00538 bp += sizeof(argp->bqual);
00539 *argpp = argp;
00540 return (0);
00541 }
00542
00543 int CDB___txn_child_log(dbenv, txnid, ret_lsnp, flags,
00544 opcode, parent)
00545 DB_ENV *dbenv;
00546 DB_TXN *txnid;
00547 DB_LSN *ret_lsnp;
00548 u_int32_t flags;
00549 u_int32_t opcode;
00550 u_int32_t parent;
00551 {
00552 DBT logrec;
00553 DB_LSN *lsnp, null_lsn;
00554 u_int32_t rectype, txn_num;
00555 int ret;
00556 u_int8_t *bp;
00557
00558 if (txnid != NULL &&
00559 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00560 return (CDB___db_child_active_err(dbenv));
00561 rectype = DB_txn_child;
00562 txn_num = txnid == NULL ? 0 : txnid->txnid;
00563 if (txnid == NULL) {
00564 ZERO_LSN(null_lsn);
00565 lsnp = &null_lsn;
00566 } else
00567 lsnp = &txnid->last_lsn;
00568 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00569 + sizeof(opcode)
00570 + sizeof(parent);
00571 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00572 return (ret);
00573
00574 bp = logrec.data;
00575 memcpy(bp, &rectype, sizeof(rectype));
00576 bp += sizeof(rectype);
00577 memcpy(bp, &txn_num, sizeof(txn_num));
00578 bp += sizeof(txn_num);
00579 memcpy(bp, lsnp, sizeof(DB_LSN));
00580 bp += sizeof(DB_LSN);
00581 memcpy(bp, &opcode, sizeof(opcode));
00582 bp += sizeof(opcode);
00583 memcpy(bp, &parent, sizeof(parent));
00584 bp += sizeof(parent);
00585 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00586 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00587 if (txnid != NULL)
00588 txnid->last_lsn = *ret_lsnp;
00589 CDB___os_free(logrec.data, logrec.size);
00590 return (ret);
00591 }
00592
00593 int
00594 CDB___txn_child_print(dbenv, dbtp, lsnp, notused2, notused3)
00595 DB_ENV *dbenv;
00596 DBT *dbtp;
00597 DB_LSN *lsnp;
00598 db_recops notused2;
00599 void *notused3;
00600 {
00601 __txn_child_args *argp;
00602 u_int32_t i;
00603 u_int ch;
00604 int ret;
00605
00606 i = 0;
00607 ch = 0;
00608 notused2 = 0;
00609 notused3 = NULL;
00610
00611 if ((ret = CDB___txn_child_read(dbenv, dbtp->data, &argp)) != 0)
00612 return (ret);
00613 printf("[%lu][%lu]txn_child: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00614 (u_long)lsnp->file,
00615 (u_long)lsnp->offset,
00616 (u_long)argp->type,
00617 (u_long)argp->txnid->txnid,
00618 (u_long)argp->prev_lsn.file,
00619 (u_long)argp->prev_lsn.offset);
00620 printf("\topcode: %lu\n", (u_long)argp->opcode);
00621 printf("\tparent: 0x%lx\n", (u_long)argp->parent);
00622 printf("\n");
00623 CDB___os_free(argp, 0);
00624 return (0);
00625 }
00626
00627 int
00628 CDB___txn_child_read(dbenv, recbuf, argpp)
00629 DB_ENV *dbenv;
00630 void *recbuf;
00631 __txn_child_args **argpp;
00632 {
00633 __txn_child_args *argp;
00634 u_int8_t *bp;
00635 int ret;
00636
00637 ret = CDB___os_malloc(dbenv, sizeof(__txn_child_args) +
00638 sizeof(DB_TXN), NULL, &argp);
00639 if (ret != 0)
00640 return (ret);
00641 argp->txnid = (DB_TXN *)&argp[1];
00642 bp = recbuf;
00643 memcpy(&argp->type, bp, sizeof(argp->type));
00644 bp += sizeof(argp->type);
00645 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00646 bp += sizeof(argp->txnid->txnid);
00647 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00648 bp += sizeof(DB_LSN);
00649 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00650 bp += sizeof(argp->opcode);
00651 memcpy(&argp->parent, bp, sizeof(argp->parent));
00652 bp += sizeof(argp->parent);
00653 *argpp = argp;
00654 return (0);
00655 }
00656
00657 int
00658 CDB___txn_init_print(dbenv)
00659 DB_ENV *dbenv;
00660 {
00661 int ret;
00662
00663 if ((ret = CDB___db_add_recovery(dbenv,
00664 CDB___txn_old_regop_print, DB_txn_old_regop)) != 0)
00665 return (ret);
00666 if ((ret = CDB___db_add_recovery(dbenv,
00667 CDB___txn_regop_print, DB_txn_regop)) != 0)
00668 return (ret);
00669 if ((ret = CDB___db_add_recovery(dbenv,
00670 CDB___txn_old_ckp_print, DB_txn_old_ckp)) != 0)
00671 return (ret);
00672 if ((ret = CDB___db_add_recovery(dbenv,
00673 CDB___txn_ckp_print, DB_txn_ckp)) != 0)
00674 return (ret);
00675 if ((ret = CDB___db_add_recovery(dbenv,
00676 CDB___txn_xa_regop_print, DB_txn_xa_regop)) != 0)
00677 return (ret);
00678 if ((ret = CDB___db_add_recovery(dbenv,
00679 CDB___txn_child_print, DB_txn_child)) != 0)
00680 return (ret);
00681 return (0);
00682 }
00683
00684 int
00685 CDB___txn_init_recover(dbenv)
00686 DB_ENV *dbenv;
00687 {
00688 int ret;
00689
00690 if ((ret = CDB___db_add_recovery(dbenv,
00691 CDB___deprecated_recover, DB_txn_old_regop)) != 0)
00692 return (ret);
00693 if ((ret = CDB___db_add_recovery(dbenv,
00694 CDB___txn_regop_recover, DB_txn_regop)) != 0)
00695 return (ret);
00696 if ((ret = CDB___db_add_recovery(dbenv,
00697 CDB___deprecated_recover, DB_txn_old_ckp)) != 0)
00698 return (ret);
00699 if ((ret = CDB___db_add_recovery(dbenv,
00700 CDB___txn_ckp_recover, DB_txn_ckp)) != 0)
00701 return (ret);
00702 if ((ret = CDB___db_add_recovery(dbenv,
00703 CDB___txn_xa_regop_recover, DB_txn_xa_regop)) != 0)
00704 return (ret);
00705 if ((ret = CDB___db_add_recovery(dbenv,
00706 CDB___txn_child_recover, DB_txn_child)) != 0)
00707 return (ret);
00708 return (0);
00709 }
00710