00001
00002
00003
00004
00005
00006
00007
00008 #include "config.h"
00009
00010 #ifndef lint
00011 static const char revid[] = "$Id: db__cam_8c-source.html,v 1.1 2008/06/08 10:17:22 sebdiaz Exp $";
00012 #endif
00013
00014 #ifndef NO_SYSTEM_INCLUDES
00015 #include <sys/types.h>
00016 #include <string.h>
00017 #include <errno.h>
00018 #endif
00019
00020 #include "db_int.h"
00021 #include "db_page.h"
00022 #include "db_shash.h"
00023 #include "lock.h"
00024 #include "btree.h"
00025 #include "hash.h"
00026 #include "qam.h"
00027 #include "db_ext.h"
00028
00029 static int __db_c_cleanup __P((DBC *, DBC *, int));
00030 static int __db_c_idup __P((DBC *, DBC **, u_int32_t));
00031 static int __db_wrlock_err __P((DB_ENV *));
00032
00033 #define LOCKING_INIT(dbp, dbc) \
00034
00035
00036
00037
00038
00039 \
00040 if (LOCKING((dbp)->dbenv)) { \
00041 if (!F_ISSET(dbc, DBC_WRITECURSOR | DBC_WRITER)) \
00042 return(__db_wrlock_err(dbp->dbenv)); \
00043 \
00044 if (F_ISSET(dbc, DBC_WRITECURSOR) && \
00045 (ret = CDB_lock_get((dbp)->dbenv, (dbc)->locker, \
00046 DB_LOCK_UPGRADE, &(dbc)->lock_dbt, DB_LOCK_WRITE, \
00047 &(dbc)->mylock)) != 0) \
00048 return (ret); \
00049 }
00050 #define LOCKING_DONE(dbp, dbc) \
00051 \
00052 if (F_ISSET(dbc, DBC_WRITECURSOR)) \
00053 (void)CDB___lock_downgrade( \
00054 (dbp)->dbenv, &(dbc)->mylock, DB_LOCK_IWRITE, 0);
00055
00056 #define IS_INITIALIZED(dbc) ((dbc)->internal->pgno != PGNO_INVALID)
00057
00058
00059
00060
00061
00062
00063
00064 int
00065 CDB___db_c_close(dbc)
00066 DBC *dbc;
00067 {
00068 DB *dbp;
00069 DBC *opd;
00070 DBC_INTERNAL *cp;
00071 int ret, t_ret;
00072
00073 dbp = dbc->dbp;
00074 ret = 0;
00075
00076 PANIC_CHECK(dbp->dbenv);
00077
00078
00079
00080
00081
00082
00083 if (!F_ISSET(dbc, DBC_ACTIVE)) {
00084 if (dbp && dbp->dbenv)
00085 CDB___db_err(dbp->dbenv, "Closing closed cursor");
00086 DB_ASSERT(0);
00087 return (EINVAL);
00088 }
00089
00090 cp = dbc->internal;
00091 opd = cp->opd;
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 MUTEX_THREAD_LOCK(dbp->mutexp);
00107
00108 if (opd != NULL) {
00109 F_CLR(opd, DBC_ACTIVE);
00110 TAILQ_REMOVE(&dbp->active_queue, opd, links);
00111 }
00112 F_CLR(dbc, DBC_ACTIVE);
00113 TAILQ_REMOVE(&dbp->active_queue, dbc, links);
00114
00115 MUTEX_THREAD_UNLOCK(dbp->mutexp);
00116
00117
00118 if ((t_ret =
00119 dbc->c_am_close(dbc, PGNO_INVALID, NULL)) != 0 && ret == 0)
00120 ret = t_ret;
00121
00122
00123
00124
00125
00126 if (LOCKING(dbc->dbp->dbenv)) {
00127
00128
00129
00130
00131 if (!F_ISSET(dbc, DBC_WRITEDUP) &&
00132 dbc->mylock.off != LOCK_INVALID) {
00133 if ((t_ret = CDB_lock_put(dbc->dbp->dbenv,
00134 &dbc->mylock)) != 0 && ret == 0)
00135 ret = t_ret;
00136 dbc->mylock.off = LOCK_INVALID;
00137 }
00138
00139
00140 memset(&dbc->mylock, 0, sizeof(dbc->mylock));
00141 F_CLR(dbc, DBC_WRITEDUP);
00142 }
00143
00144
00145 MUTEX_THREAD_LOCK(dbp->mutexp);
00146 if (opd != NULL) {
00147 TAILQ_INSERT_TAIL(&dbp->free_queue, opd, links);
00148 opd = NULL;
00149 }
00150 TAILQ_INSERT_TAIL(&dbp->free_queue, dbc, links);
00151 MUTEX_THREAD_UNLOCK(dbp->mutexp);
00152
00153 return (ret);
00154 }
00155
00156
00157
00158
00159
00160
00161
00162 int
00163 CDB___db_c_destroy(dbc)
00164 DBC *dbc;
00165 {
00166 DB *dbp;
00167 DBC_INTERNAL *cp;
00168 int ret;
00169
00170 dbp = dbc->dbp;
00171 cp = dbc->internal;
00172
00173
00174 MUTEX_THREAD_LOCK(dbp->mutexp);
00175 TAILQ_REMOVE(&dbp->free_queue, dbc, links);
00176 MUTEX_THREAD_UNLOCK(dbp->mutexp);
00177
00178
00179 if (dbc->rkey.data != NULL)
00180 CDB___os_free(dbc->rkey.data, dbc->rkey.ulen);
00181 if (dbc->rdata.data != NULL)
00182 CDB___os_free(dbc->rdata.data, dbc->rdata.ulen);
00183
00184
00185 ret = dbc->c_am_destroy == NULL ? 0 : dbc->c_am_destroy(dbc);
00186
00187 CDB___os_free(dbc, sizeof(*dbc));
00188
00189 return (ret);
00190 }
00191
00192
00193
00194
00195
00196
00197
00198 int
00199 CDB___db_c_count(dbc, recnop, flags)
00200 DBC *dbc;
00201 db_recno_t *recnop;
00202 u_int32_t flags;
00203 {
00204 DB *dbp;
00205 int ret;
00206
00207
00208
00209
00210
00211
00212
00213
00214 dbp = dbc->dbp;
00215
00216 PANIC_CHECK(dbp->dbenv);
00217
00218
00219 if ((ret = CDB___db_ccountchk(dbp, flags, IS_INITIALIZED(dbc))) != 0)
00220 return (ret);
00221
00222 switch (dbc->dbtype) {
00223 case DB_QUEUE:
00224 case DB_RECNO:
00225 *recnop = 1;
00226 break;
00227 case DB_HASH:
00228 if (dbc->internal->opd == NULL) {
00229 if ((ret = CDB___ham_c_count(dbc, recnop)) != 0)
00230 return (ret);
00231 break;
00232 }
00233
00234 case DB_BTREE:
00235 if ((ret = CDB___bam_c_count(dbc, recnop)) != 0)
00236 return (ret);
00237 break;
00238 default:
00239 return (CDB___db_unknown_type(dbp->dbenv,
00240 "CDB___db_c_count", dbp->type));
00241 }
00242 return (0);
00243 }
00244
00245
00246
00247
00248
00249
00250
00251 int
00252 CDB___db_c_del(dbc, flags)
00253 DBC *dbc;
00254 u_int32_t flags;
00255 {
00256 DB *dbp;
00257 DBC *opd;
00258 int ret;
00259
00260
00261
00262
00263
00264
00265
00266
00267 dbp = dbc->dbp;
00268
00269 PANIC_CHECK(dbp->dbenv);
00270
00271
00272 if ((ret = CDB___db_cdelchk(dbp, flags,
00273 F_ISSET(dbp, DB_AM_RDONLY), IS_INITIALIZED(dbc))) != 0)
00274 return (ret);
00275
00276 DEBUG_LWRITE(dbc, dbc->txn, "db_c_del", NULL, NULL, flags);
00277
00278 LOCKING_INIT(dbp, dbc);
00279
00280
00281
00282
00283
00284
00285
00286 opd = dbc->internal->opd;
00287 if (opd == NULL)
00288 ret = dbc->c_am_del(dbc);
00289 else
00290 if ((ret = dbc->c_am_writelock(dbc)) == 0)
00291 ret = opd->c_am_del(opd);
00292
00293 LOCKING_DONE(dbp, dbc);
00294
00295 return (ret);
00296 }
00297
00298
00299
00300
00301
00302
00303
00304 int
00305 CDB___db_c_dup(dbc_orig, dbcp, flags)
00306 DBC *dbc_orig;
00307 DBC **dbcp;
00308 u_int32_t flags;
00309 {
00310 DB_ENV *dbenv;
00311 DB *dbp;
00312 DBC *dbc_n, *dbc_nopd;
00313 int ret;
00314
00315 dbp = dbc_orig->dbp;
00316 dbenv = dbp->dbenv;
00317 dbc_n = dbc_nopd = NULL;
00318
00319 PANIC_CHECK(dbp->dbenv);
00320
00321
00322
00323
00324
00325 if (flags != DB_POSITIONI &&
00326 F_ISSET(dbc_orig, DBC_WRITER | DBC_WRITECURSOR)) {
00327 CDB___db_err(dbenv, "Cannot duplicate writeable cursor");
00328 return (EINVAL);
00329 }
00330
00331
00332 if ((ret = __db_c_idup(dbc_orig, &dbc_n, flags)) != 0)
00333 goto err;
00334 *dbcp = dbc_n;
00335
00336
00337
00338
00339
00340
00341
00342 if (LOCKING(dbenv) && flags != DB_POSITIONI) {
00343 DB_ASSERT(!F_ISSET(dbc_orig, DBC_WRITER | DBC_WRITECURSOR));
00344
00345 if ((ret = CDB_lock_get(dbenv, dbc_n->locker, 0,
00346 &dbc_n->lock_dbt, DB_LOCK_READ, &dbc_n->mylock)) != 0) {
00347 (void)CDB___db_c_close(dbc_n);
00348 return (ret);
00349 }
00350 }
00351
00352
00353
00354
00355
00356 if (dbc_orig->internal->opd != NULL) {
00357 if ((ret =
00358 __db_c_idup(dbc_orig->internal->opd, &dbc_nopd, flags)) != 0)
00359 goto err;
00360 dbc_n->internal->opd = dbc_nopd;
00361 }
00362
00363 return (0);
00364
00365 err: if (dbc_n != NULL)
00366 (void)dbc_n->c_close(dbc_n);
00367 if (dbc_nopd != NULL)
00368 (void)dbc_nopd->c_close(dbc_nopd);
00369
00370 return (ret);
00371 }
00372
00373
00374
00375
00376
00377 static int
00378 __db_c_idup(dbc_orig, dbcp, flags)
00379 DBC *dbc_orig, **dbcp;
00380 u_int32_t flags;
00381 {
00382 DB *dbp;
00383 DBC *dbc_n;
00384 DBC_INTERNAL *int_n, *int_orig;
00385 int ret;
00386
00387 dbp = dbc_orig->dbp;
00388 dbc_n = *dbcp;
00389
00390 if ((ret = CDB___db_icursor(dbp, dbc_orig->txn, dbc_orig->dbtype,
00391 dbc_orig->internal->root, F_ISSET(dbc_orig, DBC_OPD), &dbc_n)) != 0)
00392 return (ret);
00393
00394 dbc_n->locker = dbc_orig->locker;
00395
00396
00397 if (flags == DB_POSITION || flags == DB_POSITIONI) {
00398 int_n = dbc_n->internal;
00399 int_orig = dbc_orig->internal;
00400
00401 dbc_n->flags = dbc_orig->flags;
00402
00403 int_n->indx = int_orig->indx;
00404 int_n->pgno = int_orig->pgno;
00405 int_n->root = int_orig->root;
00406
00407 switch (dbc_orig->dbtype) {
00408 case DB_QUEUE:
00409 if ((ret = CDB___qam_c_dup(dbc_orig, dbc_n)) != 0)
00410 goto err;
00411 break;
00412 case DB_BTREE:
00413 case DB_RECNO:
00414 if ((ret = CDB___bam_c_dup(dbc_orig, dbc_n)) != 0)
00415 goto err;
00416 break;
00417 case DB_HASH:
00418 if ((ret = CDB___ham_c_dup(dbc_orig, dbc_n)) != 0)
00419 goto err;
00420 break;
00421 default:
00422 ret = CDB___db_unknown_type(dbp->dbenv,
00423 "__db_c_idup", dbc_orig->dbtype);
00424 goto err;
00425 }
00426 }
00427
00428 *dbcp = dbc_n;
00429 return (0);
00430
00431 err: (void)dbc_n->c_close(dbc_n);
00432 return (ret);
00433 }
00434
00435
00436
00437
00438
00439
00440
00441 int
00442 CDB___db_c_get(dbc_arg, key, data, flags)
00443 DBC *dbc_arg;
00444 DBT *key, *data;
00445 u_int32_t flags;
00446 {
00447 DB *dbp;
00448 DBC *dbc, *dbc_n, *opd;
00449 DBC_INTERNAL *cp, *cp_n;
00450 db_pgno_t pgno;
00451 u_int32_t tmp_flags, tmp_rmw;
00452 u_int8_t type;
00453 int ret, t_ret;
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464 dbp = dbc_arg->dbp;
00465 dbc_n = NULL;
00466 opd = NULL;
00467
00468 PANIC_CHECK(dbp->dbenv);
00469
00470
00471 if ((ret =
00472 CDB___db_cgetchk(dbp, key, data, flags, IS_INITIALIZED(dbc_arg))) != 0)
00473 return (ret);
00474
00475
00476 tmp_rmw = LF_ISSET(DB_RMW);
00477 LF_CLR(DB_RMW);
00478
00479 DEBUG_LREAD(dbc_arg, dbc_arg->txn, "db_c_get",
00480 flags == DB_SET || flags == DB_SET_RANGE ? key : NULL, NULL, flags);
00481
00482
00483
00484
00485
00486 if (flags == DB_GET_RECNO)
00487 return (CDB___bam_c_rget(dbc_arg, data, flags | tmp_rmw));
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500 cp = dbc_arg->internal;
00501 if (cp->opd != NULL &&
00502 (flags == DB_CURRENT || flags == DB_GET_BOTHC ||
00503 flags == DB_NEXT || flags == DB_NEXT_DUP || flags == DB_PREV)) {
00504 if (tmp_rmw && (ret = dbc_arg->c_am_writelock(dbc_arg)) != 0)
00505 return (ret);
00506 if ((ret = __db_c_idup(cp->opd, &opd, DB_POSITIONI)) != 0)
00507 return (ret);
00508
00509
00510
00511
00512
00513 if (LOCKING(dbp->dbenv))
00514 (void)CDB___db_cdb_cdup(dbc_arg, opd);
00515
00516 switch (ret = opd->c_am_get(
00517 opd, key, data, flags, NULL)) {
00518 case 0:
00519 goto done;
00520 case DB_NOTFOUND:
00521
00522
00523
00524
00525
00526 if (flags == DB_NEXT || flags == DB_PREV) {
00527 if ((ret = opd->c_close(opd)) != 0)
00528 goto err;
00529 opd = NULL;
00530 break;
00531 }
00532 goto err;
00533 default:
00534 goto err;
00535 }
00536 }
00537
00538
00539
00540
00541
00542 switch (flags) {
00543 case DB_CURRENT:
00544 case DB_GET_BOTHC:
00545 case DB_NEXT:
00546 case DB_NEXT_DUP:
00547 case DB_NEXT_NODUP:
00548 case DB_PREV:
00549 case DB_PREV_NODUP:
00550 tmp_flags = DB_POSITIONI;
00551 break;
00552 default:
00553 tmp_flags = 0;
00554 break;
00555 }
00556 if ((ret = __db_c_idup(dbc_arg, &dbc_n, tmp_flags)) != 0)
00557 goto err;
00558
00559
00560
00561
00562
00563 if (LOCKING(dbp->dbenv))
00564 (void)CDB___db_cdb_cdup(dbc_arg, dbc_n);
00565
00566 if (tmp_rmw)
00567 F_SET(dbc_n, DBC_RMW);
00568 pgno = PGNO_INVALID;
00569 ret = dbc_n->c_am_get(dbc_n, key, data, flags, &pgno);
00570 if (tmp_rmw)
00571 F_CLR(dbc_n, DBC_RMW);
00572 if (ret != 0)
00573 goto err;
00574
00575 cp_n = dbc_n->internal;
00576
00577
00578
00579
00580
00581 if (pgno != PGNO_INVALID) {
00582 if ((ret = CDB___db_icursor(dbp, dbc_arg->txn,
00583 dbp->dup_compare == NULL ? DB_RECNO : DB_BTREE,
00584 pgno, 1, &cp_n->opd)) != 0)
00585 goto err;
00586
00587 switch (flags) {
00588 case DB_FIRST:
00589 case DB_NEXT:
00590 case DB_NEXT_NODUP:
00591 case DB_SET:
00592 case DB_SET_RECNO:
00593 case DB_SET_RANGE:
00594 tmp_flags = DB_FIRST;
00595 break;
00596 case DB_LAST:
00597 case DB_PREV:
00598 case DB_PREV_NODUP:
00599 tmp_flags = DB_LAST;
00600 break;
00601 case DB_GET_BOTH:
00602 tmp_flags = DB_GET_BOTH;
00603 break;
00604 case DB_GET_BOTHC:
00605 tmp_flags = DB_GET_BOTHC;
00606 break;
00607 default:
00608 ret =
00609 CDB___db_unknown_flag(dbp->dbenv, "CDB___db_c_get", flags);
00610 goto err;
00611 }
00612 if ((ret = cp_n->opd->c_am_get(
00613 cp_n->opd, key, data, tmp_flags, NULL)) != 0)
00614 goto err;
00615 }
00616
00617 done:
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631 cp_n = dbc_n == NULL ? dbc_arg->internal : dbc_n->internal;
00632 if (!F_ISSET(key, DB_DBT_ISSET)) {
00633 if (cp_n->page == NULL && (ret =
00634 CDB_memp_fget(dbp->mpf, &cp_n->pgno, 0, &cp_n->page)) != 0)
00635 goto err;
00636
00637 if ((ret = CDB___db_ret(dbp, cp_n->page, cp_n->indx,
00638 key, &dbc_arg->rkey.data, &dbc_arg->rkey.ulen)) != 0)
00639 goto err;
00640 }
00641 dbc = opd != NULL ? opd : cp_n->opd != NULL ? cp_n->opd : dbc_n;
00642 if (!F_ISSET(data, DB_DBT_ISSET)) {
00643 type = TYPE(dbc->internal->page);
00644 ret = CDB___db_ret(dbp, dbc->internal->page, dbc->internal->indx +
00645 (type == P_LBTREE || type == P_HASH ? O_INDX : 0),
00646 data, &dbc_arg->rdata.data, &dbc_arg->rdata.ulen);
00647 }
00648
00649 err:
00650 F_CLR(key, DB_DBT_ISSET);
00651 F_CLR(data, DB_DBT_ISSET);
00652
00653
00654 if (opd != NULL) {
00655 if ((t_ret =
00656 __db_c_cleanup(dbc_arg->internal->opd,
00657 opd, ret)) != 0 && ret == 0)
00658 ret = t_ret;
00659
00660 }
00661
00662 if ((t_ret = __db_c_cleanup(dbc_arg, dbc_n, ret)) != 0 && ret == 0)
00663 ret = t_ret;
00664
00665 return (ret);
00666 }
00667
00668
00669
00670
00671
00672
00673
00674 int
00675 CDB___db_c_put(dbc_arg, key, data, flags)
00676 DBC *dbc_arg;
00677 DBT *key, *data;
00678 u_int32_t flags;
00679 {
00680 DB *dbp;
00681 DBC *dbc_n, *opd;
00682 db_pgno_t pgno;
00683 u_int32_t tmp_flags;
00684 int ret, t_ret;
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695 dbp = dbc_arg->dbp;
00696 dbc_n = NULL;
00697
00698 PANIC_CHECK(dbp->dbenv);
00699
00700
00701 if ((ret = CDB___db_cputchk(dbp, key, data, flags,
00702 F_ISSET(dbp, DB_AM_RDONLY), IS_INITIALIZED(dbc_arg))) != 0)
00703 return (ret);
00704
00705 DEBUG_LWRITE(dbc_arg, dbc_arg->txn, "db_c_put",
00706 flags == DB_KEYFIRST || flags == DB_KEYLAST ||
00707 flags == DB_NODUPDATA ? key : NULL, data, flags);
00708
00709 LOCKING_INIT(dbp, dbc_arg);
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721 if (dbc_arg->internal->opd != NULL &&
00722 (flags == DB_AFTER || flags == DB_BEFORE || flags == DB_CURRENT)) {
00723 if ((ret = dbc_arg->c_am_writelock(dbc_arg)) != 0)
00724 return (ret);
00725 if ((ret = CDB___db_c_dup(dbc_arg, &dbc_n, DB_POSITIONI)) != 0)
00726 goto err;
00727 opd = dbc_n->internal->opd;
00728 if ((ret = opd->c_am_put(
00729 opd, key, data, flags, NULL)) != 0)
00730 goto err;
00731 goto done;
00732 }
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743 tmp_flags = DB_POSITIONI;
00744
00745 if ((ret = __db_c_idup(dbc_arg, &dbc_n, tmp_flags)) != 0)
00746 goto err;
00747 pgno = PGNO_INVALID;
00748 if ((ret = dbc_n->c_am_put(dbc_n, key, data, flags, &pgno)) != 0)
00749 goto err;
00750
00751
00752
00753
00754
00755 if (pgno != PGNO_INVALID) {
00756 if ((ret = CDB___db_icursor(dbp, dbc_arg->txn,
00757 dbp->dup_compare == NULL ? DB_RECNO : DB_BTREE,
00758 pgno, 1, &dbc_n->internal->opd)) != 0)
00759 goto err;
00760
00761 opd = dbc_n->internal->opd;
00762 if ((ret = opd->c_am_put(
00763 opd, key, data, flags, NULL)) != 0)
00764 goto err;
00765 }
00766
00767 done:
00768 err:
00769 if ((t_ret = __db_c_cleanup(dbc_arg, dbc_n, ret)) != 0 && ret == 0)
00770 ret = t_ret;
00771
00772 LOCKING_DONE(dbp, dbc_arg);
00773
00774 return (ret);
00775 }
00776
00777
00778
00779
00780
00781
00782 int
00783 CDB___db_duperr(dbp, flags)
00784 DB *dbp;
00785 u_int32_t flags;
00786 {
00787 if (flags != DB_NODUPDATA)
00788 CDB___db_err(dbp->dbenv,
00789 "Duplicate data items are not supported with sorted data");
00790 return (DB_KEYEXIST);
00791 }
00792
00793
00794
00795
00796
00797 static int
00798 __db_c_cleanup(dbc, dbc_n, failed)
00799 DBC *dbc, *dbc_n;
00800 int failed;
00801 {
00802 DB *dbp;
00803 DBC *opd;
00804 DBC_INTERNAL *internal;
00805 int ret, t_ret;
00806
00807 dbp = dbc->dbp;
00808 internal = dbc->internal;
00809 ret = 0;
00810
00811
00812 if (internal->page != NULL) {
00813 if ((t_ret =
00814 CDB_memp_fput(dbp->mpf, internal->page, 0)) != 0 && ret == 0)
00815 ret = t_ret;
00816 internal->page = NULL;
00817 }
00818 opd = internal->opd;
00819 if (opd != NULL && opd->internal->page != NULL) {
00820 if ((t_ret = CDB_memp_fput(dbp->mpf,
00821 opd->internal->page, 0)) != 0 && ret == 0)
00822 ret = t_ret;
00823 opd->internal->page = NULL;
00824 }
00825
00826 if (dbc_n == NULL)
00827 return (ret);
00828
00829 if (dbc_n->internal->page != NULL) {
00830 if ((t_ret = CDB_memp_fput(dbp->mpf,
00831 dbc_n->internal->page, 0)) != 0 && ret == 0)
00832 ret = t_ret;
00833 dbc_n->internal->page = NULL;
00834 }
00835 opd = dbc_n->internal->opd;
00836 if (opd != NULL && opd->internal->page != NULL) {
00837 if ((t_ret = CDB_memp_fput(dbp->mpf,
00838 opd->internal->page, 0)) != 0 && ret == 0)
00839 ret = t_ret;
00840 opd->internal->page = NULL;
00841 }
00842
00843
00844
00845
00846
00847
00848 if (!failed && ret == 0) {
00849 dbc->internal = dbc_n->internal;
00850 dbc_n->internal = internal;
00851 }
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868 if ((t_ret = dbc_n->c_close(dbc_n)) != 0 && ret == 0)
00869 ret = t_ret;
00870
00871 return (ret);
00872 }
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897 int
00898 CDB___db_cdb_cdup(dbc_orig, dbc_n)
00899 DBC *dbc_orig, *dbc_n;
00900 {
00901 if (F_ISSET(dbc_orig, DBC_WRITECURSOR | DBC_WRITEDUP)) {
00902 memcpy(&dbc_n->mylock, &dbc_orig->mylock,
00903 sizeof(dbc_orig->mylock));
00904
00905
00906
00907
00908
00909
00910
00911 dbc_n->locker = dbc_orig->locker;
00912
00913
00914
00915
00916
00917 F_SET(dbc_n, DBC_WRITEDUP);
00918 }
00919
00920 return (0);
00921 }
00922
00923
00924
00925
00926 static int
00927 __db_wrlock_err(dbenv)
00928 DB_ENV *dbenv;
00929 {
00930 CDB___db_err(dbenv, "Write attempted on read-only cursor");
00931 return (EPERM);
00932 }