00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #include "db_config.h"
00046
00047 #ifndef NO_SYSTEM_INCLUDES
00048 #include <sys/types.h>
00049
00050 #include <string.h>
00051 #endif
00052
00053 #include "db_int.h"
00054 #include "dbinc/db_page.h"
00055 #include "dbinc/db_shash.h"
00056 #include "dbinc/btree.h"
00057 #include "dbinc/mp.h"
00058
00059 static int __bam_build
00060 __P((DBC *, u_int32_t, DBT *, PAGE *, u_int32_t, u_int32_t));
00061 static int __bam_dup_check __P((DBC *, u_int32_t,
00062 PAGE *, u_int32_t, u_int32_t, db_indx_t *));
00063 static int __bam_dup_convert __P((DBC *, PAGE *, u_int32_t, u_int32_t));
00064 static int __bam_ovput
00065 __P((DBC *, u_int32_t, db_pgno_t, PAGE *, u_int32_t, DBT *));
00066 static u_int32_t
00067 __bam_partsize __P((DB *, u_int32_t, DBT *, PAGE *, u_int32_t));
00068
00069
00070
00071
00072
00073
00074
00075 int
00076 __bam_iitem(dbc, key, data, op, flags)
00077 DBC *dbc;
00078 DBT *key, *data;
00079 u_int32_t op, flags;
00080 {
00081 DB_ENV *dbenv;
00082 BKEYDATA *bk, bk_tmp;
00083 BTREE *t;
00084 BTREE_CURSOR *cp;
00085 DB *dbp;
00086 DBT bk_hdr, tdbt;
00087 DB_MPOOLFILE *mpf;
00088 PAGE *h;
00089 db_indx_t cnt, indx;
00090 u_int32_t data_size, have_bytes, need_bytes, needed, pages, pagespace;
00091 int cmp, bigkey, bigdata, dupadjust, padrec, replace, ret, was_deleted;
00092
00093 COMPQUIET(bk, NULL);
00094 COMPQUIET(cnt, 0);
00095
00096 dbp = dbc->dbp;
00097 dbenv = dbp->dbenv;
00098 mpf = dbp->mpf;
00099 cp = (BTREE_CURSOR *)dbc->internal;
00100 t = dbp->bt_internal;
00101 h = cp->page;
00102 indx = cp->indx;
00103 dupadjust = replace = was_deleted = 0;
00104
00105
00106
00107
00108
00109 if (F_ISSET(dbp, DB_AM_FIXEDLEN) &&
00110 F_ISSET(data, DB_DBT_PARTIAL) && data->size != data->dlen)
00111 return (__db_rec_repl(dbenv, data->size, data->dlen));
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 data_size = F_ISSET(data, DB_DBT_PARTIAL) ?
00122 __bam_partsize(dbp, op, data, h, indx) : data->size;
00123 padrec = 0;
00124 if (F_ISSET(dbp, DB_AM_FIXEDLEN)) {
00125 if (data_size > t->re_len)
00126 return (__db_rec_toobig(dbenv, data_size, t->re_len));
00127
00128
00129 if (!LF_ISSET(BI_DELETED) && data_size < t->re_len) {
00130 padrec = 1;
00131 data_size = t->re_len;
00132 }
00133 }
00134
00135
00136
00137
00138
00139 if (padrec || F_ISSET(data, DB_DBT_PARTIAL)) {
00140 tdbt = *data;
00141 if ((ret =
00142 __bam_build(dbc, op, &tdbt, h, indx, data_size)) != 0)
00143 return (ret);
00144 data = &tdbt;
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154 if (op == DB_CURRENT && dbp->dup_compare != NULL) {
00155 if ((ret = __bam_cmp(dbp, data, h,
00156 indx + (TYPE(h) == P_LBTREE ? O_INDX : 0),
00157 dbp->dup_compare, &cmp)) != 0)
00158 return (ret);
00159 if (cmp != 0) {
00160 __db_err(dbenv,
00161 "Existing data sorts differently from put data");
00162 return (EINVAL);
00163 }
00164 }
00165
00166
00167
00168
00169
00170 needed = 0;
00171 bigdata = data_size > cp->ovflsize;
00172 switch (op) {
00173 case DB_KEYFIRST:
00174
00175 bigkey = key->size > cp->ovflsize;
00176 if (bigkey)
00177 needed += BOVERFLOW_PSIZE;
00178 else
00179 needed += BKEYDATA_PSIZE(key->size);
00180 if (bigdata)
00181 needed += BOVERFLOW_PSIZE;
00182 else
00183 needed += BKEYDATA_PSIZE(data_size);
00184 break;
00185 case DB_AFTER:
00186 case DB_BEFORE:
00187 case DB_CURRENT:
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 bigkey = 0;
00199 if (op == DB_CURRENT) {
00200 bk = GET_BKEYDATA(dbp, h,
00201 indx + (TYPE(h) == P_LBTREE ? O_INDX : 0));
00202 if (B_TYPE(bk->type) == B_KEYDATA)
00203 have_bytes = BKEYDATA_PSIZE(bk->len);
00204 else
00205 have_bytes = BOVERFLOW_PSIZE;
00206 need_bytes = 0;
00207 } else {
00208 have_bytes = 0;
00209 need_bytes = sizeof(db_indx_t);
00210 }
00211 if (bigdata)
00212 need_bytes += BOVERFLOW_PSIZE;
00213 else
00214 need_bytes += BKEYDATA_PSIZE(data_size);
00215
00216 if (have_bytes < need_bytes)
00217 needed += need_bytes - have_bytes;
00218 break;
00219 default:
00220 return (__db_unknown_flag(dbenv, "DB->put", op));
00221 }
00222
00223
00224 if (P_FREESPACE(dbp, h) < needed)
00225 return (DB_NEEDSPLIT);
00226
00227
00228
00229
00230
00231 if (F_ISSET(dbp, DB_AM_DUP) &&
00232 TYPE(h) == P_LBTREE && op != DB_KEYFIRST &&
00233 P_FREESPACE(dbp, h) - needed <= dbp->pgsize / 2 &&
00234 __bam_dup_check(dbc, op, h, indx, needed, &cnt)) {
00235 pages = 1;
00236 dupadjust = 1;
00237 } else
00238 pages = 0;
00239
00240
00241
00242
00243
00244
00245 if (dbc->txn == NULL && dbp->mpf->mfp->maxpgno != 0) {
00246 pagespace = P_MAXSPACE(dbp, dbp->pgsize);
00247 if (bigdata)
00248 pages += ((data_size - 1) / pagespace) + 1;
00249 if (bigkey)
00250 pages += ((key->size - 1) / pagespace) + 1;
00251
00252 if (pages > (dbp->mpf->mfp->maxpgno - dbp->mpf->mfp->last_pgno))
00253 return (__db_space_err(dbp));
00254 }
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 switch (op) {
00266 case DB_KEYFIRST:
00267 if (bigkey) {
00268 if ((ret = __bam_ovput(dbc,
00269 B_OVERFLOW, PGNO_INVALID, h, indx, key)) != 0)
00270 return (ret);
00271 } else
00272 if ((ret = __db_pitem(dbc, h, indx,
00273 BKEYDATA_SIZE(key->size), NULL, key)) != 0)
00274 return (ret);
00275
00276 if ((ret = __bam_ca_di(dbc, PGNO(h), indx, 1)) != 0)
00277 return (ret);
00278 ++indx;
00279 break;
00280 case DB_AFTER:
00281 if (TYPE(h) == P_LBTREE) {
00282
00283 if ((ret =
00284 __bam_adjindx(dbc, h, indx + P_INDX, indx, 1)) != 0)
00285 return (ret);
00286 if ((ret =
00287 __bam_ca_di(dbc, PGNO(h), indx + P_INDX, 1)) != 0)
00288 return (ret);
00289
00290 indx += 3;
00291
00292 cp->indx += 2;
00293 } else {
00294 ++indx;
00295 cp->indx += 1;
00296 }
00297 break;
00298 case DB_BEFORE:
00299 if (TYPE(h) == P_LBTREE) {
00300
00301 if ((ret = __bam_adjindx(dbc, h, indx, indx, 1)) != 0)
00302 return (ret);
00303 if ((ret = __bam_ca_di(dbc, PGNO(h), indx, 1)) != 0)
00304 return (ret);
00305
00306 ++indx;
00307 }
00308 break;
00309 case DB_CURRENT:
00310
00311
00312
00313
00314
00315
00316
00317 if ((ret = __bam_ca_delete(dbp, PGNO(h), indx, 0, NULL)) != 0)
00318 return (ret);
00319
00320 if (TYPE(h) == P_LBTREE) {
00321 ++indx;
00322 }
00323
00324
00325
00326
00327
00328
00329
00330
00331 if (TYPE(h) == P_LBTREE || TYPE(h) == P_LDUP)
00332 was_deleted = B_DISSET(bk->type);
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343 if (bigdata || B_TYPE(bk->type) != B_KEYDATA) {
00344 if ((ret = __bam_ditem(dbc, h, indx)) != 0)
00345 return (ret);
00346 break;
00347 }
00348
00349
00350 replace = 1;
00351 break;
00352 default:
00353 return (__db_unknown_flag(dbenv, "DB->put", op));
00354 }
00355
00356
00357 if (bigdata) {
00358
00359
00360
00361
00362 DB_ASSERT(!LF_ISSET(BI_DELETED));
00363 if ((ret = __bam_ovput(dbc,
00364 B_OVERFLOW, PGNO_INVALID, h, indx, data)) != 0)
00365 return (ret);
00366 } else {
00367 if (LF_ISSET(BI_DELETED)) {
00368 B_TSET(bk_tmp.type, B_KEYDATA, 1);
00369 bk_tmp.len = data->size;
00370 bk_hdr.data = &bk_tmp;
00371 bk_hdr.size = SSZA(BKEYDATA, data);
00372 ret = __db_pitem(dbc, h, indx,
00373 BKEYDATA_SIZE(data->size), &bk_hdr, data);
00374 } else if (replace)
00375 ret = __bam_ritem(dbc, h, indx, data);
00376 else
00377 ret = __db_pitem(dbc, h, indx,
00378 BKEYDATA_SIZE(data->size), NULL, data);
00379 if (ret != 0)
00380 return (ret);
00381 }
00382 if ((ret = __memp_fset(mpf, h, DB_MPOOL_DIRTY)) != 0)
00383 return (ret);
00384
00385
00386
00387
00388
00389 if (op != DB_CURRENT) {
00390 if ((ret = __bam_ca_di(dbc, PGNO(h), indx, 1)) != 0)
00391 return (ret);
00392 cp->indx = TYPE(h) == P_LBTREE ? indx - O_INDX : indx;
00393 }
00394
00395
00396
00397
00398
00399
00400 if (F_ISSET(cp, C_RECNUM) && (op != DB_CURRENT || was_deleted))
00401 if ((ret = __bam_adjust(dbc, 1)) != 0)
00402 return (ret);
00403
00404
00405
00406
00407
00408
00409
00410 if (dupadjust &&
00411 (ret = __bam_dup_convert(dbc, h, indx - O_INDX, cnt)) != 0)
00412 return (ret);
00413
00414
00415 if (dbc->dbtype == DB_RECNO)
00416 t->re_modified = 1;
00417
00418 return (ret);
00419 }
00420
00421
00422
00423
00424
00425 static u_int32_t
00426 __bam_partsize(dbp, op, data, h, indx)
00427 DB *dbp;
00428 u_int32_t op, indx;
00429 DBT *data;
00430 PAGE *h;
00431 {
00432 BKEYDATA *bk;
00433 u_int32_t nbytes;
00434
00435
00436
00437
00438
00439 if (op != DB_CURRENT)
00440 return (data->doff + data->size);
00441
00442
00443
00444
00445
00446 bk = GET_BKEYDATA(dbp, h, indx + (TYPE(h) == P_LBTREE ? O_INDX : 0));
00447 nbytes =
00448 B_TYPE(bk->type) == B_OVERFLOW ? ((BOVERFLOW *)bk)->tlen : bk->len;
00449
00450 return (__db_partsize(nbytes, data));
00451 }
00452
00453
00454
00455
00456
00457 static int
00458 __bam_build(dbc, op, dbt, h, indx, nbytes)
00459 DBC *dbc;
00460 u_int32_t op, indx, nbytes;
00461 DBT *dbt;
00462 PAGE *h;
00463 {
00464 BKEYDATA *bk, tbk;
00465 BOVERFLOW *bo;
00466 BTREE *t;
00467 DB *dbp;
00468 DBT copy, *rdata;
00469 u_int32_t len, tlen;
00470 u_int8_t *p;
00471 int ret;
00472
00473 COMPQUIET(bo, NULL);
00474
00475 dbp = dbc->dbp;
00476 t = dbp->bt_internal;
00477
00478
00479 rdata = &dbc->my_rdata;
00480 if (rdata->ulen < nbytes) {
00481 if ((ret = __os_realloc(dbp->dbenv,
00482 nbytes, &rdata->data)) != 0) {
00483 rdata->ulen = 0;
00484 rdata->data = NULL;
00485 return (ret);
00486 }
00487 rdata->ulen = nbytes;
00488 }
00489
00490
00491
00492
00493
00494 memset(rdata->data,
00495 F_ISSET(dbp, DB_AM_FIXEDLEN) ? t->re_pad : 0, nbytes);
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506 if (!F_ISSET(dbt, DB_DBT_PARTIAL) || op != DB_CURRENT) {
00507 p = (u_int8_t *)rdata->data + dbt->doff;
00508 tlen = dbt->doff;
00509 goto user_copy;
00510 }
00511
00512
00513 if (indx < NUM_ENT(h)) {
00514 bk = GET_BKEYDATA(dbp, h, indx + (TYPE(h) == P_LBTREE ?
00515 O_INDX : 0));
00516 bo = (BOVERFLOW *)bk;
00517 } else {
00518 bk = &tbk;
00519 B_TSET(bk->type, B_KEYDATA, 0);
00520 bk->len = 0;
00521 }
00522 if (B_TYPE(bk->type) == B_OVERFLOW) {
00523
00524
00525
00526
00527 memset(©, 0, sizeof(copy));
00528 if ((ret = __db_goff(dbp, ©, bo->tlen,
00529 bo->pgno, &rdata->data, &rdata->ulen)) != 0)
00530 return (ret);
00531
00532
00533 tlen = dbt->doff;
00534 p = (u_int8_t *)rdata->data + dbt->doff;
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 if (bo->tlen > dbt->doff + dbt->dlen) {
00548 len = bo->tlen - (dbt->doff + dbt->dlen);
00549 if (dbt->dlen != dbt->size)
00550 memmove(p + dbt->size, p + dbt->dlen, len);
00551 tlen += len;
00552 }
00553 } else {
00554
00555 memcpy(rdata->data,
00556 bk->data, dbt->doff > bk->len ? bk->len : dbt->doff);
00557 tlen = dbt->doff;
00558 p = (u_int8_t *)rdata->data + dbt->doff;
00559
00560
00561 len = dbt->doff + dbt->dlen;
00562 if (bk->len > len) {
00563 memcpy(p + dbt->size, bk->data + len, bk->len - len);
00564 tlen += bk->len - len;
00565 }
00566 }
00567
00568 user_copy:
00569
00570
00571
00572
00573 memcpy(p, dbt->data, dbt->size);
00574 tlen += dbt->size;
00575
00576
00577 rdata->size = F_ISSET(dbp, DB_AM_FIXEDLEN) ? t->re_len : tlen;
00578 rdata->dlen = 0;
00579 rdata->doff = 0;
00580 rdata->flags = 0;
00581 *dbt = *rdata;
00582 return (0);
00583 }
00584
00585
00586
00587
00588
00589
00590
00591 int
00592 __bam_ritem(dbc, h, indx, data)
00593 DBC *dbc;
00594 PAGE *h;
00595 u_int32_t indx;
00596 DBT *data;
00597 {
00598 BKEYDATA *bk;
00599 DB *dbp;
00600 DBT orig, repl;
00601 db_indx_t cnt, lo, ln, min, off, prefix, suffix;
00602 int32_t nbytes;
00603 int ret;
00604 db_indx_t *inp;
00605 u_int8_t *p, *t;
00606
00607 dbp = dbc->dbp;
00608
00609
00610
00611
00612
00613
00614 bk = GET_BKEYDATA(dbp, h, indx);
00615
00616
00617 if (DBC_LOGGING(dbc)) {
00618
00619
00620
00621
00622
00623 min = data->size < bk->len ? data->size : bk->len;
00624 for (prefix = 0,
00625 p = bk->data, t = data->data;
00626 prefix < min && *p == *t; ++prefix, ++p, ++t)
00627 ;
00628
00629 min -= prefix;
00630 for (suffix = 0,
00631 p = (u_int8_t *)bk->data + bk->len - 1,
00632 t = (u_int8_t *)data->data + data->size - 1;
00633 suffix < min && *p == *t; ++suffix, --p, --t)
00634 ;
00635
00636
00637 orig.data = (u_int8_t *)bk->data + prefix;
00638 orig.size = bk->len - (prefix + suffix);
00639 repl.data = (u_int8_t *)data->data + prefix;
00640 repl.size = data->size - (prefix + suffix);
00641 if ((ret = __bam_repl_log(dbp, dbc->txn, &LSN(h), 0, PGNO(h),
00642 &LSN(h), (u_int32_t)indx, (u_int32_t)B_DISSET(bk->type),
00643 &orig, &repl, (u_int32_t)prefix, (u_int32_t)suffix)) != 0)
00644 return (ret);
00645 } else
00646 LSN_NOT_LOGGED(LSN(h));
00647
00648
00649
00650
00651
00652 inp = P_INP(dbp, h);
00653 p = (u_int8_t *)h + HOFFSET(h);
00654 t = (u_int8_t *)bk;
00655
00656
00657
00658
00659
00660
00661
00662 lo = BKEYDATA_SIZE(bk->len);
00663 ln = (db_indx_t)BKEYDATA_SIZE(data->size);
00664 if (lo != ln) {
00665 nbytes = lo - ln;
00666 if (p == t)
00667 inp[indx] += nbytes;
00668 else {
00669 memmove(p + nbytes, p, (size_t)(t - p));
00670
00671
00672 off = inp[indx];
00673 for (cnt = 0; cnt < NUM_ENT(h); ++cnt)
00674 if (inp[cnt] <= off)
00675 inp[cnt] += nbytes;
00676 }
00677
00678
00679 HOFFSET(h) += nbytes;
00680 t += nbytes;
00681 }
00682
00683
00684 bk = (BKEYDATA *)t;
00685 B_TSET(bk->type, B_KEYDATA, 0);
00686 bk->len = data->size;
00687 memcpy(bk->data, data->data, data->size);
00688
00689 return (0);
00690 }
00691
00692
00693
00694
00695
00696 static int
00697 __bam_dup_check(dbc, op, h, indx, sz, cntp)
00698 DBC *dbc;
00699 u_int32_t op;
00700 PAGE *h;
00701 u_int32_t indx, sz;
00702 db_indx_t *cntp;
00703 {
00704 BKEYDATA *bk;
00705 DB *dbp;
00706 db_indx_t cnt, first, *inp;
00707
00708 dbp = dbc->dbp;
00709 inp = P_INP(dbp, h);
00710
00711
00712
00713
00714
00715 while (indx > 0 && inp[indx] == inp[indx - P_INDX])
00716 indx -= P_INDX;
00717
00718
00719 bk = GET_BKEYDATA(dbp, h, indx);
00720 sz += B_TYPE(bk->type) == B_KEYDATA ?
00721 BKEYDATA_PSIZE(bk->len) : BOVERFLOW_PSIZE;
00722
00723
00724 first = indx;
00725
00726
00727
00728
00729
00730
00731
00732
00733 cnt = op == DB_CURRENT ? 0 : 1;
00734 for (first = indx;
00735 indx < NUM_ENT(h) && inp[first] == inp[indx];
00736 ++cnt, indx += P_INDX) {
00737 bk = GET_BKEYDATA(dbp, h, indx + O_INDX);
00738 sz += B_TYPE(bk->type) == B_KEYDATA ?
00739 BKEYDATA_PSIZE(bk->len) : BOVERFLOW_PSIZE;
00740 }
00741
00742
00743
00744
00745
00746
00747
00748
00749 if (cnt == 1)
00750 return (0);
00751
00752
00753
00754
00755
00756
00757
00758 if (sz < dbp->pgsize / 4)
00759 return (0);
00760
00761 *cntp = cnt;
00762 return (1);
00763 }
00764
00765
00766
00767
00768
00769 static int
00770 __bam_dup_convert(dbc, h, indx, cnt)
00771 DBC *dbc;
00772 PAGE *h;
00773 u_int32_t indx, cnt;
00774 {
00775 BKEYDATA *bk;
00776 DB *dbp;
00777 DBT hdr;
00778 DB_MPOOLFILE *mpf;
00779 PAGE *dp;
00780 db_indx_t cpindx, dindx, first, *inp;
00781 int ret;
00782
00783 dbp = dbc->dbp;
00784 mpf = dbp->mpf;
00785 inp = P_INP(dbp, h);
00786
00787
00788 while (indx > 0 && inp[indx] == inp[indx - P_INDX])
00789 indx -= P_INDX;
00790
00791
00792 if ((ret = __db_new(dbc,
00793 dbp->dup_compare == NULL ? P_LRECNO : P_LDUP, &dp)) != 0)
00794 return (ret);
00795 P_INIT(dp, dbp->pgsize, dp->pgno,
00796 PGNO_INVALID, PGNO_INVALID, LEAFLEVEL, TYPE(dp));
00797
00798
00799
00800
00801
00802
00803 memset(&hdr, 0, sizeof(hdr));
00804 first = indx;
00805 dindx = indx;
00806 cpindx = 0;
00807 do {
00808
00809 if ((ret = __bam_ca_dup(dbc, first,
00810 PGNO(h), indx, PGNO(dp), cpindx)) != 0)
00811 goto err;
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822 bk = GET_BKEYDATA(dbp, h, dindx + 1);
00823 hdr.data = bk;
00824 hdr.size = B_TYPE(bk->type) == B_KEYDATA ?
00825 BKEYDATA_SIZE(bk->len) : BOVERFLOW_SIZE;
00826 if (dbp->dup_compare == NULL && B_DISSET(bk->type)) {
00827
00828
00829
00830
00831
00832 if (B_TYPE(bk->type) == B_OVERFLOW &&
00833 (ret = __db_doff(dbc,
00834 (GET_BOVERFLOW(dbp, h, dindx + 1))->pgno)) != 0)
00835 goto err;
00836 } else {
00837 if ((ret = __db_pitem(
00838 dbc, dp, cpindx, hdr.size, &hdr, NULL)) != 0)
00839 goto err;
00840 ++cpindx;
00841 }
00842
00843 if (cnt != 1) {
00844 if ((ret = __bam_adjindx(dbc,
00845 h, dindx, first + 1, 0)) != 0)
00846 goto err;
00847 } else
00848 dindx++;
00849
00850
00851 if ((ret = __db_ditem(dbc, h, dindx, hdr.size)) != 0)
00852 goto err;
00853 indx += P_INDX;
00854 } while (--cnt);
00855
00856
00857 if ((ret = __bam_ovput(dbc,
00858 B_DUPLICATE, dp->pgno, h, first + 1, NULL)) != 0)
00859 goto err;
00860
00861
00862 if ((ret = __bam_ca_di(dbc,
00863 PGNO(h), first + P_INDX, (int)(first + P_INDX - indx))) != 0)
00864 goto err;
00865
00866 return (__memp_fput(mpf, dp, DB_MPOOL_DIRTY));
00867
00868 err: (void)__memp_fput(mpf, dp, 0);
00869 return (ret);
00870 }
00871
00872
00873
00874
00875
00876
00877 static int
00878 __bam_ovput(dbc, type, pgno, h, indx, item)
00879 DBC *dbc;
00880 u_int32_t type, indx;
00881 db_pgno_t pgno;
00882 PAGE *h;
00883 DBT *item;
00884 {
00885 BOVERFLOW bo;
00886 DBT hdr;
00887 int ret;
00888
00889 UMRW_SET(bo.unused1);
00890 B_TSET(bo.type, type, 0);
00891 UMRW_SET(bo.unused2);
00892
00893
00894
00895
00896
00897
00898 if (type == B_OVERFLOW) {
00899 if ((ret = __db_poff(dbc, item, &bo.pgno)) != 0)
00900 return (ret);
00901 bo.tlen = item->size;
00902 } else {
00903 bo.pgno = pgno;
00904 bo.tlen = 0;
00905 }
00906
00907
00908 memset(&hdr, 0, sizeof(hdr));
00909 hdr.data = &bo;
00910 hdr.size = BOVERFLOW_SIZE;
00911 return (__db_pitem(dbc, h, indx, BOVERFLOW_SIZE, &hdr, NULL));
00912 }