/*-
* 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 <limits.h>
#include <string.h>
#endif
#include "db_int.h"
#include "db_page.h"
#include "btree.h"
/*
* __bam_open --
* Open a btree.
*
* PUBLIC: int __bam_open __P((DB *, DB_INFO *));
*/
int
{
BTREE *t;
int ret;
/* Allocate and initialize the private btree structure. */
return (ret);
/*
* Intention is to make sure all of the user's selections are okay
* here and then use them without checking.
*/
t->bt_minkey = DEFMINKEYPAGE;
t->bt_compare = __bam_defcmp;
t->bt_prefix = __bam_defpfx;
} else {
/* Minimum number of keys per page. */
t->bt_minkey = DEFMINKEYPAGE;
else {
goto einval;
}
/* Maximum number of keys per page. */
t->bt_maxkey = 0;
else {
goto einval;
}
/*
* If no comparison, use default comparison. If no comparison
* and no prefix, use default prefix. (We can't default the
* prefix if the user supplies a comparison routine; shortening
* the keys may break their comparison algorithm. We don't
* permit the user to specify a prefix routine if they didn't
* also specify a comparison routine, they can't know enough
* about our comparison routine to get it right.)
*/
goto einval;
t->bt_compare = __bam_defcmp;
t->bt_prefix = __bam_defpfx;
} else
}
/* Start up the tree. */
goto err;
/* Set the overflow page size. */
return (0);
return (ret);
}
/*
* __bam_close --
* Close a btree.
*
* PUBLIC: int __bam_close __P((DB *));
*/
int
{
return (0);
}
/*
* __bam_setovflsize --
*
* PUBLIC: void __bam_setovflsize __P((DB *));
*/
void
{
BTREE *t;
/*
* !!!
* Correction for recno, which doesn't know anything about minimum
* keys per page.
*/
if (t->bt_minkey == 0)
t->bt_minkey = DEFMINKEYPAGE;
/*
* can fit on a page, but other than that there's no fixed requirement.
* can use before being placed on an overflow page. We calculate for
* the worst possible alignment by assuming every item requires the
* maximum alignment for padding.
*
* Recno uses the btree bt_ovflsize value -- it's close enough.
*/
}
/*
* __bam_read_root --
* Check (and optionally create) a tree.
*
* PUBLIC: int __bam_read_root __P((DB *));
*/
int
{
BTREE *t;
ret = 0;
/* Get a cursor. */
return (ret);
/* Get, and optionally create the metadata page. */
if ((ret =
goto err;
if ((ret =
goto err;
}
/*
* If the magic number is correct, we're not creating the tree.
* Correct any fields that may not be right. Note, all of the
* local flags were set by db_open(3).
*/
goto done;
}
/* Initialize the tree structure metadata information. */
/* Create and initialize a root page. */
if ((ret =
goto err;
goto err;
}
/* Release the metadata and root pages. */
goto err;
goto err;
/*
* Flush the metadata and root pages to disk -- since the user can't
* transaction protect open, the pages have to exist during recovery.
*
* XXX
* It's not useful to return not-yet-flushed here -- convert it to
* an error.
*/
/* Release the locks. */
err:
return (ret);
}