/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
/*
* Copyright (c) 1990, 1993, 1994, 1995, 1996
* Keith Bostic. All rights reserved.
*/
/*
* Copyright (c) 1990, 1993, 1994, 1995
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Mike Olson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#ifndef lint
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <errno.h>
#include <string.h>
#endif
#include "db_int.h"
#include "db_page.h"
#include "db_am.h"
#include "common_ext.h"
/*
*
* Big key and data entries are stored on linked lists of pages. The initial
* reference is a structure with the total length of the item and the page
* number where it begins. Each entry in the linked list contains a pointer
* to the next page of data, and so on.
*/
/*
* __db_goff --
* Get an offpage item.
*
* PUBLIC: int __db_goff __P((DB *, DBT *,
* PUBLIC: u_int32_t, db_pgno_t, void **, u_int32_t *));
*/
int
void **bpp;
{
PAGE *h;
int ret;
/*
* Check if the buffer is big enough; if it is not and we are
* allowed to malloc space, then we'll malloc it. If we are
* not (DB_DBT_USERMEM), then we'll set the dbt and return
* appropriately.
*/
} else {
start = 0;
}
/* Allocate any necessary memory. */
return (ENOMEM);
}
if ((ret =
return (ret);
return (ret);
} else
/*
* Step through the linked list of pages, copying the data on each
* one into the buffer. Never copy more than the total data length.
*/
return (ret);
}
/* Check if we need any bytes from this page. */
}
p += bytes;
}
}
return (0);
}
/*
* __db_poff --
* Put an offpage item.
*
* PUBLIC: int __db_poff __P((DBC *, const DBT *, db_pgno_t *,
* PUBLIC: int (*)(DBC *, u_int32_t, PAGE **)));
*/
int
{
u_int8_t *p;
int ret;
/*
* number of bytes we get for pages we fill completely with a single
* item.
*/
/*
* Reduce pagespace so we terminate the loop correctly and
* don't copy too much data.
*/
/*
* Allocate and initialize a new page and copy all or part of
* the item onto the page. If sz is less than pagespace, we
* have a partial record.
*/
return (ret);
if (DB_LOGGING(dbc)) {
&null_lsn)) != 0)
return (ret);
/* Move lsn onto page. */
if (lastp)
}
/*
* If this is the first entry, update the user's info.
* Otherwise, update the entry on the last page filled
* in and release that page.
*/
else {
}
}
return (0);
}
/*
* __db_ovref --
*
* PUBLIC: int __db_ovref __P((DBC *, db_pgno_t, int32_t));
*/
int
{
PAGE *h;
int ret;
return (ret);
}
if (DB_LOGGING(dbc))
&LSN(h))) != 0)
return (ret);
return (0);
}
/*
* __db_doff --
* Delete an offpage chain of overflow pages.
*
* PUBLIC: int __db_doff __P((DBC *, db_pgno_t, int (*)(DBC *, PAGE *)));
*/
int
{
int ret;
do {
return (ret);
}
/*
* If it's an overflow page and it's referenced by more than
*/
}
if (DB_LOGGING(dbc)) {
return (ret);
}
return (ret);
} while (pgno != PGNO_INVALID);
return (0);
}
/*
* __db_moff --
* Match on overflow pages.
*
* Given a starting page number and a key, return <0, 0, >0 to indicate if the
* key on the page is less than, equal to or greater than the key specified.
* We optimize this by doing chunk at a time comparison unless the user has
* specified a comparison function. In this case, we need to materialize
* the entire object and call their comparison routine.
*
* PUBLIC: int __db_moff __P((DB *, const DBT *, db_pgno_t, u_int32_t,
* PUBLIC: int (*)(const DBT *, const DBT *), int *));
*/
int
{
void *buf;
int ret;
/*
* If there is a user-specified comparison function, build a
* contiguous copy of the key, and call it.
*/
bufsize = 0;
return (ret);
return (0);
}
/* While there are both keys to compare. */
return (ret);
for (p2 =
break;
}
return (ret);
if (*cmpp != 0)
return (0);
}
if (key_left > 0) /* DBT is longer than page key. */
*cmpp = -1;
*cmpp = 1;
else
*cmpp = 0;
return (0);
}