aboutsummaryrefslogtreecommitdiff
path: root/db2/db
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-06-09 15:16:55 +0000
committerUlrich Drepper <drepper@redhat.com>1998-06-09 15:16:55 +0000
commitbf7997b65c7887d2acda95f5201d818a19d81711 (patch)
treeda3583de3a0b5892f90a4b1eb773a87b554ae37e /db2/db
parent7646e67e6cc4c738a7b402c60fed39d52db0433b (diff)
downloadglibc-bf7997b65c7887d2acda95f5201d818a19d81711.zip
glibc-bf7997b65c7887d2acda95f5201d818a19d81711.tar.gz
glibc-bf7997b65c7887d2acda95f5201d818a19d81711.tar.bz2
Update.
1998-06-09 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/netinet/ip.h (struct ip_options): Define __data member only for gcc. Reported by ak@muc.de. * misc/mntent.h: Undo last patch. * sysdeps/unix/sysv/linux/fstatvfs.c (fstatvfs): Undo last patch. * misc/tst/mntent.c: Adjust code for this change. * io/fts.c: Updated from a slightly more recent BSD version. * io/fts.h: Likewise. * libc.map: Add __libc_stack_end. * db2/Makefile (routines): Add lock_region. * db2/config.h: Update from db-2.4.14. * db2/db.h: Likewise. * db2/db_185.h: Likewise. * db2/db_int.h: Likewise. * db2/bt_close.c: Likewise. * db2/bt_compare.c: Likewise. * db2/bt_conv.c: Likewise. * db2/bt_cursor.c: Likewise. * db2/bt_delete.c: Likewise. * db2/bt_open.c: Likewise. * db2/bt_page.c: Likewise. * db2/bt_put.c: Likewise. * db2/bt_rec.c: Likewise. * db2/bt_recno.c: Likewise. * db2/bt_rsearch.c: Likewise. * db2/bt_search.c: Likewise. * db2/bt_split.c: Likewise. * db2/bt_stat.c: Likewise. * db2/btree.src: Likewise. * db2/btree_auto.c: Likewise. * db2/getlong.c: Likewise. * db2/db_appinit.c: Likewise. * db2/db_apprec.c: Likewise. * db2/db_byteorder.c: Likewise. * db2/db_err.c: Likewise. * db2/db_log2.c: Likewise. * db2/db_region.c: Likewise. * db2/db_salloc.c: Likewise. * db2/db_shash.c: Likewise. * db2/db.c: Likewise. * db2/db.src: Likewise. * db2/db_auto.c: Likewise. * db2/db_conv.c: Likewise. * db2/db_dispatch.c: Likewise. * db2/db_dup.c: Likewise. * db2/db_overflow.c: Likewise. * db2/db_pr.c: Likewise. * db2/db_rec.c: Likewise. * db2/db_ret.c: Likewise. * db2/db_thread.c: Likewise. * db2/db185.c: Likewise. * db2/db185_int.h: Likewise. * db2/dbm.c: Likewise. * db2/hash.c: Likewise. * db2/hash.src: Likewise. * db2/hash_auto.c: Likewise. * db2/hash_conv.c: Likewise. * db2/hash_debug.c: Likewise. * db2/hash_dup.c: Likewise. * db2/hash_func.c: Likewise. * db2/hash_page.c: Likewise. * db2/hash_rec.c: Likewise. * db2/hash_stat.c: Likewise. * db2/btree.h: Likewise. * db2/btree_ext.h: Likewise. * db2/clib_ext.h: Likewise. * db2/common_ext.h: Likewise. * db2/cxx_int.h: Likewise. * db2/db.h.src: Likewise. * db2/db_185.h.src: Likewise. * db2/db_am.h: Likewise. * db2/db_auto.h: Likewise. * db2/db_cxx.h: Likewise. * db2/db_dispatch.h: Likewise. * db2/db_ext.h: Likewise. * db2/db_int.h.src: Likewise. * db2/db_page.h: Likewise. * db2/db_shash.h: Likewise. * db2/db_swap.h: Likewise. * db2/hash.h: Likewise. * db2/hash_ext.h: Likewise. * db2/lock.h: Likewise. * db2/lock_ext.h: Likewise. * db2/log.h: Likewise. * db2/log_ext.h: Likewise. * db2/mp.h: Likewise. * db2/mp_ext.h: Likewise. * db2/mutex_ext.h: Likewise. * db2/os_ext.h: Likewise. * db2/os_func.h: Likewise. * db2/queue.h: Likewise. * db2/shqueue.h: Likewise. * db2/txn.h: Likewise. * db2/lock.c: Likewise. * db2/lock_conflict.c: Likewise. * db2/lock_deadlock.c: Likewise. * db2/lock_region.c: Likewise. * db2/lock_util.c: Likewise. * db2/log.c: Likewise. * db2/log.src: Likewise. * db2/log_archive.c: Likewise. * db2/log_auto.c: Likewise. * db2/log_compare.c: Likewise. * db2/log_findckp.c: Likewise. * db2/log_get.c: Likewise. * db2/log_put.c: Likewise. * db2/log_rec.c: Likewise. * db2/log_register.c: Likewise. * db2/mp_bh.c: Likewise. * db2/mp_fget.c: Likewise. * db2/mp_fopen.c: Likewise. * db2/mp_fput.c: Likewise. * db2/mp_fset.c: Likewise. * db2/mp_open.c: Likewise. * db2/mp_pr.c: Likewise. * db2/mp_region.c: Likewise. * db2/mp_sync.c: Likewise. * db2/68020.gcc: Likewise. * db2/mutex.c: Likewise. * db2/parisc.gcc: Likewise. * db2/parisc.hp: Likewise. * db2/sco.cc: Likewise. * db2/os_abs.c: Likewise. * db2/os_alloc.c: Likewise. * db2/os_config.c: Likewise. * db2/os_dir.c: Likewise. * db2/os_fid.c: Likewise. * db2/os_fsync.c: Likewise. * db2/os_map.c: Likewise. * db2/os_oflags.c: Likewise. * db2/os_open.c: Likewise. * db2/os_rpath.c: Likewise. * db2/os_rw.c: Likewise. * db2/os_seek.c: Likewise. * db2/os_sleep.c: Likewise. * db2/os_spin.c: Likewise. * db2/os_stat.c: Likewise. * db2/os_unlink.c: Likewise. * db2/db_archive.c: Likewise. * db2/db_checkpoint.c: Likewise. * db2/db_deadlock.c: Likewise. * db2/db_dump.c: Likewise. * db2/db_dump185.c: Likewise. * db2/db_load.c: Likewise. * db2/db_printlog.c: Likewise. * db2/db_recover.c: Likewise. * db2/db_stat.c: Likewise. * db2/txn.c: Likewise. * db2/txn.src: Likewise. * db2/txn_auto.c: Likewise. * db2/txn_rec.c: Likewise. * elf/rtld.c: Move definition of __libc_stack_end to ... * sysdeps/generic/dl-sysdep.h: ...here. * sysdeps/unix/sysv/linux/fstatvfs.c: Handle nodiratime option. * sysdeps/unix/sysv/linux/bits/statvfs.h: Define ST_NODIRATIME. * sysdeps/unix/sysv/linux/sys/mount.h: Define MS_NODIRATIME. 1998-06-08 21:44 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/fstatvfs.c: Handle constant option string from mntent correctly. 1998-06-06 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sunrpc/Makefile (generated): Correct typo. 1998-06-04 Philip Blundell <philb@gnu.org> * elf/elf.h (EM_ARM, et al.): New definitions. * sysdeps/arm/dl-machine.h: Update for new draft ARM ELF ABI.
Diffstat (limited to 'db2/db')
-rw-r--r--db2/db/db.c113
-rw-r--r--db2/db/db.src9
-rw-r--r--db2/db/db_auto.c227
-rw-r--r--db2/db/db_conv.c25
-rw-r--r--db2/db/db_dispatch.c117
-rw-r--r--db2/db/db_dup.c21
-rw-r--r--db2/db/db_overflow.c17
-rw-r--r--db2/db/db_pr.c92
-rw-r--r--db2/db/db_rec.c51
-rw-r--r--db2/db/db_ret.c7
-rw-r--r--db2/db/db_thread.c6
11 files changed, 413 insertions, 272 deletions
diff --git a/db2/db/db.c b/db2/db/db.c
index 8df7634..9951ebd 100644
--- a/db2/db/db.c
+++ b/db2/db/db.c
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
/*
@@ -44,20 +44,16 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)db.c 10.45 (Sleepycat) 12/4/97";
+static const char sccsid[] = "@(#)db.c 10.57 (Sleepycat) 5/7/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
-#include <sys/stat.h>
#include <errno.h>
-#include <fcntl.h>
#include <stddef.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#endif
#include "db_int.h"
@@ -71,7 +67,7 @@ static const char sccsid[] = "@(#)db.c 10.45 (Sleepycat) 12/4/97";
#include "db_am.h"
#include "common_ext.h"
-static int db_close __P((DB *, int));
+static int db_close __P((DB *, u_int32_t));
static int db_fd __P((DB *, int *));
/*
@@ -99,7 +95,8 @@ int
db_open(fname, type, flags, mode, dbenv, dbinfo, dbpp)
const char *fname;
DBTYPE type;
- int flags, mode;
+ u_int32_t flags;
+ int mode;
DB_ENV *dbenv;
DB_INFO *dbinfo;
DB **dbpp;
@@ -108,6 +105,7 @@ db_open(fname, type, flags, mode, dbenv, dbinfo, dbpp)
DB *dbp;
DBT pgcookie;
DB_ENV *envp, t_dbenv;
+ DB_MPOOL_FINFO finfo;
DB_PGINFO pginfo;
HASHHDR *hashm;
size_t cachesize;
@@ -125,10 +123,26 @@ db_open(fname, type, flags, mode, dbenv, dbinfo, dbpp)
if ((ret = __db_fchk(dbenv, "db_open", flags, OKFLAGS)) != 0)
return (ret);
- if (dbenv != NULL &&
- LF_ISSET(DB_THREAD) && !F_ISSET(dbenv, DB_ENV_THREAD)) {
- __db_err(dbenv, "environment not created using DB_THREAD");
- return (EINVAL);
+ if (dbenv != NULL) {
+ /*
+ * You can't specify threads during the db_open() if the
+ * environment wasn't configured with them.
+ */
+ if (LF_ISSET(DB_THREAD) && !F_ISSET(dbenv, DB_ENV_THREAD)) {
+ __db_err(dbenv,
+ "environment not created using DB_THREAD");
+ return (EINVAL);
+ }
+
+ /*
+ * Specifying a cachesize to db_open(3), after creating an
+ * environment, is a common mistake.
+ */
+ if (dbinfo != NULL && dbinfo->db_cachesize != 0) {
+ __db_err(dbenv,
+ "cachesize will be ignored if environment exists");
+ return (EINVAL);
+ }
}
/* Initialize for error return. */
@@ -203,7 +217,7 @@ db_open(fname, type, flags, mode, dbenv, dbinfo, dbpp)
/* Fill in the default file mode. */
if (mode == 0)
- mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
+ mode = __db_omode("rwrw--");
/* Check if the user wants us to swap byte order. */
if (dbinfo != NULL)
@@ -230,7 +244,7 @@ db_open(fname, type, flags, mode, dbenv, dbinfo, dbpp)
if (fname != NULL && fname[0] != '\0') {
/* Get the real file name. */
if ((ret = __db_appname(dbenv,
- DB_APP_DATA, NULL, fname, NULL, &real_name)) != 0)
+ DB_APP_DATA, NULL, fname, 0, NULL, &real_name)) != 0)
goto err;
/*
@@ -455,22 +469,6 @@ empty: /*
}
/*
- * Set and/or correct the cache size; must be a multiple of the
- * page size.
- */
- if (dbinfo == NULL || dbinfo->db_cachesize == 0)
- cachesize = dbp->pgsize * DB_MINCACHE;
- else {
- cachesize = dbinfo->db_cachesize;
- if (cachesize & (dbp->pgsize - 1))
- cachesize += (~cachesize & (dbp->pgsize - 1)) + 1;
- if (cachesize < dbp->pgsize * DB_MINCACHE)
- cachesize = dbp->pgsize * DB_MINCACHE;
- if (cachesize < 20 * 1024)
- cachesize = 20 * 1024;
- }
-
- /*
* If no mpool supplied by the application, attach to a local,
* created buffer pool.
*
@@ -499,10 +497,28 @@ empty: /*
envp = dbenv;
restore = 1;
}
+
+ /*
+ * Set and/or correct the cache size; must be a multiple of
+ * the page size.
+ */
+ if (dbinfo == NULL || dbinfo->db_cachesize == 0)
+ cachesize = dbp->pgsize * DB_MINCACHE;
+ else {
+ cachesize = dbinfo->db_cachesize;
+ if (cachesize & (dbp->pgsize - 1))
+ cachesize +=
+ (~cachesize & (dbp->pgsize - 1)) + 1;
+ if (cachesize < dbp->pgsize * DB_MINCACHE)
+ cachesize = dbp->pgsize * DB_MINCACHE;
+ if (cachesize < 20 * 1024)
+ cachesize = 20 * 1024;
+ }
envp->mp_size = cachesize;
+
if ((ret = memp_open(NULL, DB_CREATE | DB_MPOOL_PRIVATE |
(F_ISSET(dbp, DB_AM_THREAD) ? DB_THREAD : 0),
- S_IRUSR | S_IWUSR, envp, &dbp->mp)) != 0)
+ __db_omode("rw----"), envp, &dbp->mp)) != 0)
goto err;
if (restore)
*dbenv = t_dbenv;
@@ -566,9 +582,18 @@ empty: /*
pgcookie.data = &pginfo;
pgcookie.size = sizeof(DB_PGINFO);
- if ((ret = memp_fopen(dbp->mp, fname, ftype,
- F_ISSET(dbp, DB_AM_RDONLY) ? DB_RDONLY : 0, 0, dbp->pgsize,
- 0, &pgcookie, dbp->lock.fileid, &dbp->mpf)) != 0)
+ /*
+ * Set up additional memp_fopen information.
+ */
+ memset(&finfo, 0, sizeof(finfo));
+ finfo.ftype = ftype;
+ finfo.pgcookie = &pgcookie;
+ finfo.fileid = dbp->lock.fileid;
+ finfo.lsn_offset = 0;
+ finfo.clear_len = DB_PAGE_CLEAR_LEN;
+ if ((ret = memp_fopen(dbp->mp, fname,
+ F_ISSET(dbp, DB_AM_RDONLY) ? DB_RDONLY : 0,
+ 0, dbp->pgsize, &finfo, &dbp->mpf)) != 0)
goto err;
/*
@@ -673,7 +698,7 @@ err: /* Close the file descriptor. */
static int
db_close(dbp, flags)
DB *dbp;
- int flags;
+ u_int32_t flags;
{
DBC *dbc;
DB *tdbp;
@@ -734,7 +759,7 @@ db_close(dbp, flags)
}
/* Sync the memory pool. */
- if ((t_ret = memp_fsync(dbp->mpf)) != 0 &&
+ if (!LF_ISSET(DB_NOSYNC) && (t_ret = memp_fsync(dbp->mpf)) != 0 &&
t_ret != DB_INCOMPLETE && ret == 0)
ret = t_ret;
@@ -796,18 +821,11 @@ db_fd(dbp, fdp)
DB *dbp;
int *fdp;
{
- /* In-memory database can't have a file descriptor. */
- if (F_ISSET(dbp, DB_AM_INMEM))
- return (ENOENT);
-
/*
* XXX
- * Truly spectacular layering violation. As we don't open the
- * underlying file until we need it, it may not be initialized.
+ * Truly spectacular layering violation.
*/
- if ((*fdp = dbp->mpf->fd) == -1)
- return (ENOENT);
- return (0);
+ return (__mp_xxx_fd(dbp->mpf, fdp));
}
/*
@@ -821,6 +839,11 @@ __db_pgerr(dbp, pgno)
DB *dbp;
db_pgno_t pgno;
{
+ /*
+ * Three things are certain:
+ * Death, taxes, and lost data.
+ * Guess which has occurred.
+ */
__db_err(dbp->dbenv,
"unable to create/retrieve page %lu", (u_long)pgno);
return (__db_panic(dbp));
diff --git a/db2/db/db.src b/db2/db/db.src
index 07d9812..91d8b39 100644
--- a/db2/db/db.src
+++ b/db2/db/db.src
@@ -1,11 +1,11 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
- * @(#)db.src 10.4 (Sleepycat) 11/2/97
+ *
+ * @(#)db.src 10.6 (Sleepycat) 4/28/98
*/
-#include "config.h"
PREFIX db
@@ -153,4 +153,7 @@ END
* noop -- do nothing, but get an LSN.
*/
BEGIN noop
+ARG fileid u_int32_t lu
+ARG pgno db_pgno_t lu
+POINTER prevlsn DB_LSN * lu
END
diff --git a/db2/db/db_auto.c b/db2/db/db_auto.c
index 5d35264..5203e0a 100644
--- a/db2/db/db_auto.c
+++ b/db2/db/db_auto.c
@@ -14,8 +14,6 @@
#include "db_page.h"
#include "db_dispatch.h"
#include "db_am.h"
-#include "common_ext.h"
-
/*
* PUBLIC: int __db_addrem_log
* PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
@@ -107,7 +105,7 @@ int __db_addrem_log(logp, txnid, ret_lsnp, flags,
else
memset(bp, 0, sizeof(*pagelsn));
bp += sizeof(*pagelsn);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
fprintf(stderr, "Error in log record length");
#endif
@@ -123,22 +121,23 @@ int __db_addrem_log(logp, txnid, ret_lsnp, flags,
* PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
*/
int
-__db_addrem_print(notused1, dbtp, lsnp, notused3, notused4)
+__db_addrem_print(notused1, dbtp, lsnp, notused2, notused3)
DB_LOG *notused1;
DBT *dbtp;
DB_LSN *lsnp;
- int notused3;
- void *notused4;
+ int notused2;
+ void *notused3;
{
__db_addrem_args *argp;
u_int32_t i;
- int c, ret;
+ u_int ch;
+ int ret;
i = 0;
- c = 0;
+ ch = 0;
notused1 = NULL;
- notused3 = 0;
- notused4 = NULL;
+ notused2 = 0;
+ notused3 = NULL;
if ((ret = __db_addrem_read(dbtp->data, &argp)) != 0)
return (ret);
@@ -156,20 +155,20 @@ __db_addrem_print(notused1, dbtp, lsnp, notused3, notused4)
printf("\tnbytes: %lu\n", (u_long)argp->nbytes);
printf("\thdr: ");
for (i = 0; i < argp->hdr.size; i++) {
- c = ((char *)argp->hdr.data)[i];
- if (isprint(c) || c == 0xa)
- putchar(c);
+ ch = ((u_int8_t *)argp->hdr.data)[i];
+ if (isprint(ch) || ch == 0xa)
+ putchar(ch);
else
- printf("%#x ", c);
+ printf("%#x ", ch);
}
printf("\n");
printf("\tdbt: ");
for (i = 0; i < argp->dbt.size; i++) {
- c = ((char *)argp->dbt.data)[i];
- if (isprint(c) || c == 0xa)
- putchar(c);
+ ch = ((u_int8_t *)argp->dbt.data)[i];
+ if (isprint(ch) || ch == 0xa)
+ putchar(ch);
else
- printf("%#x ", c);
+ printf("%#x ", ch);
}
printf("\n");
printf("\tpagelsn: [%lu][%lu]\n",
@@ -296,7 +295,7 @@ int __db_split_log(logp, txnid, ret_lsnp, flags,
else
memset(bp, 0, sizeof(*pagelsn));
bp += sizeof(*pagelsn);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
fprintf(stderr, "Error in log record length");
#endif
@@ -312,22 +311,23 @@ int __db_split_log(logp, txnid, ret_lsnp, flags,
* PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
*/
int
-__db_split_print(notused1, dbtp, lsnp, notused3, notused4)
+__db_split_print(notused1, dbtp, lsnp, notused2, notused3)
DB_LOG *notused1;
DBT *dbtp;
DB_LSN *lsnp;
- int notused3;
- void *notused4;
+ int notused2;
+ void *notused3;
{
__db_split_args *argp;
u_int32_t i;
- int c, ret;
+ u_int ch;
+ int ret;
i = 0;
- c = 0;
+ ch = 0;
notused1 = NULL;
- notused3 = 0;
- notused4 = NULL;
+ notused2 = 0;
+ notused3 = NULL;
if ((ret = __db_split_read(dbtp->data, &argp)) != 0)
return (ret);
@@ -343,11 +343,11 @@ __db_split_print(notused1, dbtp, lsnp, notused3, notused4)
printf("\tpgno: %lu\n", (u_long)argp->pgno);
printf("\tpageimage: ");
for (i = 0; i < argp->pageimage.size; i++) {
- c = ((char *)argp->pageimage.data)[i];
- if (isprint(c) || c == 0xa)
- putchar(c);
+ ch = ((u_int8_t *)argp->pageimage.data)[i];
+ if (isprint(ch) || ch == 0xa)
+ putchar(ch);
else
- printf("%#x ", c);
+ printf("%#x ", ch);
}
printf("\n");
printf("\tpagelsn: [%lu][%lu]\n",
@@ -490,7 +490,7 @@ int __db_big_log(logp, txnid, ret_lsnp, flags,
else
memset(bp, 0, sizeof(*nextlsn));
bp += sizeof(*nextlsn);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
fprintf(stderr, "Error in log record length");
#endif
@@ -506,22 +506,23 @@ int __db_big_log(logp, txnid, ret_lsnp, flags,
* PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
*/
int
-__db_big_print(notused1, dbtp, lsnp, notused3, notused4)
+__db_big_print(notused1, dbtp, lsnp, notused2, notused3)
DB_LOG *notused1;
DBT *dbtp;
DB_LSN *lsnp;
- int notused3;
- void *notused4;
+ int notused2;
+ void *notused3;
{
__db_big_args *argp;
u_int32_t i;
- int c, ret;
+ u_int ch;
+ int ret;
i = 0;
- c = 0;
+ ch = 0;
notused1 = NULL;
- notused3 = 0;
- notused4 = NULL;
+ notused2 = 0;
+ notused3 = NULL;
if ((ret = __db_big_read(dbtp->data, &argp)) != 0)
return (ret);
@@ -539,11 +540,11 @@ __db_big_print(notused1, dbtp, lsnp, notused3, notused4)
printf("\tnext_pgno: %lu\n", (u_long)argp->next_pgno);
printf("\tdbt: ");
for (i = 0; i < argp->dbt.size; i++) {
- c = ((char *)argp->dbt.data)[i];
- if (isprint(c) || c == 0xa)
- putchar(c);
+ ch = ((u_int8_t *)argp->dbt.data)[i];
+ if (isprint(ch) || ch == 0xa)
+ putchar(ch);
else
- printf("%#x ", c);
+ printf("%#x ", ch);
}
printf("\n");
printf("\tpagelsn: [%lu][%lu]\n",
@@ -660,7 +661,7 @@ int __db_ovref_log(logp, txnid, ret_lsnp, flags,
else
memset(bp, 0, sizeof(*lsn));
bp += sizeof(*lsn);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
fprintf(stderr, "Error in log record length");
#endif
@@ -676,22 +677,23 @@ int __db_ovref_log(logp, txnid, ret_lsnp, flags,
* PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
*/
int
-__db_ovref_print(notused1, dbtp, lsnp, notused3, notused4)
+__db_ovref_print(notused1, dbtp, lsnp, notused2, notused3)
DB_LOG *notused1;
DBT *dbtp;
DB_LSN *lsnp;
- int notused3;
- void *notused4;
+ int notused2;
+ void *notused3;
{
__db_ovref_args *argp;
u_int32_t i;
- int c, ret;
+ u_int ch;
+ int ret;
i = 0;
- c = 0;
+ ch = 0;
notused1 = NULL;
- notused3 = 0;
- notused4 = NULL;
+ notused2 = 0;
+ notused3 = NULL;
if ((ret = __db_ovref_read(dbtp->data, &argp)) != 0)
return (ret);
@@ -823,7 +825,7 @@ int __db_relink_log(logp, txnid, ret_lsnp, flags,
else
memset(bp, 0, sizeof(*lsn_next));
bp += sizeof(*lsn_next);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
fprintf(stderr, "Error in log record length");
#endif
@@ -839,22 +841,23 @@ int __db_relink_log(logp, txnid, ret_lsnp, flags,
* PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
*/
int
-__db_relink_print(notused1, dbtp, lsnp, notused3, notused4)
+__db_relink_print(notused1, dbtp, lsnp, notused2, notused3)
DB_LOG *notused1;
DBT *dbtp;
DB_LSN *lsnp;
- int notused3;
- void *notused4;
+ int notused2;
+ void *notused3;
{
__db_relink_args *argp;
u_int32_t i;
- int c, ret;
+ u_int ch;
+ int ret;
i = 0;
- c = 0;
+ ch = 0;
notused1 = NULL;
- notused3 = 0;
- notused4 = NULL;
+ notused2 = 0;
+ notused3 = NULL;
if ((ret = __db_relink_read(dbtp->data, &argp)) != 0)
return (ret);
@@ -985,7 +988,7 @@ int __db_addpage_log(logp, txnid, ret_lsnp, flags,
else
memset(bp, 0, sizeof(*nextlsn));
bp += sizeof(*nextlsn);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
fprintf(stderr, "Error in log record length");
#endif
@@ -1001,22 +1004,23 @@ int __db_addpage_log(logp, txnid, ret_lsnp, flags,
* PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
*/
int
-__db_addpage_print(notused1, dbtp, lsnp, notused3, notused4)
+__db_addpage_print(notused1, dbtp, lsnp, notused2, notused3)
DB_LOG *notused1;
DBT *dbtp;
DB_LSN *lsnp;
- int notused3;
- void *notused4;
+ int notused2;
+ void *notused3;
{
__db_addpage_args *argp;
u_int32_t i;
- int c, ret;
+ u_int ch;
+ int ret;
i = 0;
- c = 0;
+ ch = 0;
notused1 = NULL;
- notused3 = 0;
- notused4 = NULL;
+ notused2 = 0;
+ notused3 = NULL;
if ((ret = __db_addpage_read(dbtp->data, &argp)) != 0)
return (ret);
@@ -1159,7 +1163,7 @@ int __db_debug_log(logp, txnid, ret_lsnp, flags,
}
memcpy(bp, &arg_flags, sizeof(arg_flags));
bp += sizeof(arg_flags);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
fprintf(stderr, "Error in log record length");
#endif
@@ -1175,22 +1179,23 @@ int __db_debug_log(logp, txnid, ret_lsnp, flags,
* PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
*/
int
-__db_debug_print(notused1, dbtp, lsnp, notused3, notused4)
+__db_debug_print(notused1, dbtp, lsnp, notused2, notused3)
DB_LOG *notused1;
DBT *dbtp;
DB_LSN *lsnp;
- int notused3;
- void *notused4;
+ int notused2;
+ void *notused3;
{
__db_debug_args *argp;
u_int32_t i;
- int c, ret;
+ u_int ch;
+ int ret;
i = 0;
- c = 0;
+ ch = 0;
notused1 = NULL;
- notused3 = 0;
- notused4 = NULL;
+ notused2 = 0;
+ notused3 = NULL;
if ((ret = __db_debug_read(dbtp->data, &argp)) != 0)
return (ret);
@@ -1203,30 +1208,30 @@ __db_debug_print(notused1, dbtp, lsnp, notused3, notused4)
(u_long)argp->prev_lsn.offset);
printf("\top: ");
for (i = 0; i < argp->op.size; i++) {
- c = ((char *)argp->op.data)[i];
- if (isprint(c) || c == 0xa)
- putchar(c);
+ ch = ((u_int8_t *)argp->op.data)[i];
+ if (isprint(ch) || ch == 0xa)
+ putchar(ch);
else
- printf("%#x ", c);
+ printf("%#x ", ch);
}
printf("\n");
printf("\tfileid: %lu\n", (u_long)argp->fileid);
printf("\tkey: ");
for (i = 0; i < argp->key.size; i++) {
- c = ((char *)argp->key.data)[i];
- if (isprint(c) || c == 0xa)
- putchar(c);
+ ch = ((u_int8_t *)argp->key.data)[i];
+ if (isprint(ch) || ch == 0xa)
+ putchar(ch);
else
- printf("%#x ", c);
+ printf("%#x ", ch);
}
printf("\n");
printf("\tdata: ");
for (i = 0; i < argp->data.size; i++) {
- c = ((char *)argp->data.data)[i];
- if (isprint(c) || c == 0xa)
- putchar(c);
+ ch = ((u_int8_t *)argp->data.data)[i];
+ if (isprint(ch) || ch == 0xa)
+ putchar(ch);
else
- printf("%#x ", c);
+ printf("%#x ", ch);
}
printf("\n");
printf("\targ_flags: %lu\n", (u_long)argp->arg_flags);
@@ -1280,13 +1285,18 @@ __db_debug_read(recbuf, argpp)
/*
* PUBLIC: int __db_noop_log
- * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t));
+ * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
+ * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *));
*/
-int __db_noop_log(logp, txnid, ret_lsnp, flags)
+int __db_noop_log(logp, txnid, ret_lsnp, flags,
+ fileid, pgno, prevlsn)
DB_LOG *logp;
DB_TXN *txnid;
DB_LSN *ret_lsnp;
u_int32_t flags;
+ u_int32_t fileid;
+ db_pgno_t pgno;
+ DB_LSN * prevlsn;
{
DBT logrec;
DB_LSN *lsnp, null_lsn;
@@ -1302,7 +1312,10 @@ int __db_noop_log(logp, txnid, ret_lsnp, flags)
lsnp = &null_lsn;
} else
lsnp = &txnid->last_lsn;
- logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN);
+ logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
+ + sizeof(fileid)
+ + sizeof(pgno)
+ + sizeof(*prevlsn);
if ((logrec.data = (void *)__db_malloc(logrec.size)) == NULL)
return (ENOMEM);
@@ -1313,7 +1326,16 @@ int __db_noop_log(logp, txnid, ret_lsnp, flags)
bp += sizeof(txn_num);
memcpy(bp, lsnp, sizeof(DB_LSN));
bp += sizeof(DB_LSN);
-#ifdef DEBUG
+ memcpy(bp, &fileid, sizeof(fileid));
+ bp += sizeof(fileid);
+ memcpy(bp, &pgno, sizeof(pgno));
+ bp += sizeof(pgno);
+ if (prevlsn != NULL)
+ memcpy(bp, prevlsn, sizeof(*prevlsn));
+ else
+ memset(bp, 0, sizeof(*prevlsn));
+ bp += sizeof(*prevlsn);
+#ifdef DIAGNOSTIC
if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
fprintf(stderr, "Error in log record length");
#endif
@@ -1329,22 +1351,23 @@ int __db_noop_log(logp, txnid, ret_lsnp, flags)
* PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
*/
int
-__db_noop_print(notused1, dbtp, lsnp, notused3, notused4)
+__db_noop_print(notused1, dbtp, lsnp, notused2, notused3)
DB_LOG *notused1;
DBT *dbtp;
DB_LSN *lsnp;
- int notused3;
- void *notused4;
+ int notused2;
+ void *notused3;
{
__db_noop_args *argp;
u_int32_t i;
- int c, ret;
+ u_int ch;
+ int ret;
i = 0;
- c = 0;
+ ch = 0;
notused1 = NULL;
- notused3 = 0;
- notused4 = NULL;
+ notused2 = 0;
+ notused3 = NULL;
if ((ret = __db_noop_read(dbtp->data, &argp)) != 0)
return (ret);
@@ -1355,6 +1378,10 @@ __db_noop_print(notused1, dbtp, lsnp, notused3, notused4)
(u_long)argp->txnid->txnid,
(u_long)argp->prev_lsn.file,
(u_long)argp->prev_lsn.offset);
+ printf("\tfileid: %lu\n", (u_long)argp->fileid);
+ printf("\tpgno: %lu\n", (u_long)argp->pgno);
+ printf("\tprevlsn: [%lu][%lu]\n",
+ (u_long)argp->prevlsn.file, (u_long)argp->prevlsn.offset);
printf("\n");
__db_free(argp);
return (0);
@@ -1383,6 +1410,12 @@ __db_noop_read(recbuf, argpp)
bp += sizeof(argp->txnid->txnid);
memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
bp += sizeof(DB_LSN);
+ memcpy(&argp->fileid, bp, sizeof(argp->fileid));
+ bp += sizeof(argp->fileid);
+ memcpy(&argp->pgno, bp, sizeof(argp->pgno));
+ bp += sizeof(argp->pgno);
+ memcpy(&argp->prevlsn, bp, sizeof(argp->prevlsn));
+ bp += sizeof(argp->prevlsn);
*argpp = argp;
return (0);
}
diff --git a/db2/db/db_conv.c b/db2/db/db_conv.c
index e9c4bf9..8b5cf5f 100644
--- a/db2/db/db_conv.c
+++ b/db2/db/db_conv.c
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
/*
@@ -44,7 +44,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)db_conv.c 10.8 (Sleepycat) 1/8/98";
+static const char sccsid[] = "@(#)db_conv.c 10.13 (Sleepycat) 4/26/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -160,6 +160,13 @@ __db_convert(pg, pp, pagesize, pgin)
}
}
+
+ /*
+ * The offsets in the inp array are used to determine
+ * the size of entries on a page; therefore they
+ * cannot be converted until we've done all the
+ * entries.
+ */
if (!pgin)
for (i = 0; i < NUM_ENT(h); i++)
M_16_SWAP(h->inp[i]);
@@ -179,8 +186,8 @@ __db_convert(pg, pp, pagesize, pgin)
case B_DUPLICATE:
case B_OVERFLOW:
bo = (BOVERFLOW *)bk;
- M_32_SWAP(bo->tlen);
M_32_SWAP(bo->pgno);
+ M_32_SWAP(bo->tlen);
break;
}
@@ -194,17 +201,18 @@ __db_convert(pg, pp, pagesize, pgin)
M_16_SWAP(h->inp[i]);
bi = GET_BINTERNAL(h, i);
+ M_16_SWAP(bi->len);
+ M_32_SWAP(bi->pgno);
+ M_32_SWAP(bi->nrecs);
+
switch (B_TYPE(bi->type)) {
case B_KEYDATA:
- M_16_SWAP(bi->len);
- M_32_SWAP(bi->pgno);
- M_32_SWAP(bi->nrecs);
break;
case B_DUPLICATE:
case B_OVERFLOW:
- bo = (BOVERFLOW *)bi;
- M_32_SWAP(bo->tlen);
+ bo = (BOVERFLOW *)bi->data;
M_32_SWAP(bo->pgno);
+ M_32_SWAP(bo->tlen);
break;
}
@@ -224,6 +232,7 @@ __db_convert(pg, pp, pagesize, pgin)
if (!pgin)
M_16_SWAP(h->inp[i]);
}
+ break;
case P_OVERFLOW:
case P_INVALID:
/* Nothing to do. */
diff --git a/db2/db/db_dispatch.c b/db2/db/db_dispatch.c
index 736575a..8645948 100644
--- a/db2/db/db_dispatch.c
+++ b/db2/db/db_dispatch.c
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
/*
@@ -43,14 +43,13 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)db_dispatch.c 10.9 (Sleepycat) 1/17/98";
+static const char sccsid[] = "@(#)db_dispatch.c 10.14 (Sleepycat) 5/3/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <errno.h>
-#include <fcntl.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -62,6 +61,7 @@ static const char sccsid[] = "@(#)db_dispatch.c 10.9 (Sleepycat) 1/17/98";
#include "db_am.h"
#include "common_ext.h"
#include "log_auto.h"
+#include "txn_auto.h"
/*
* Data structures to manage the DB dispatch table. The dispatch table
@@ -114,7 +114,7 @@ __db_dispatch(logp, db, lsnp, redo, info)
* seen it, then we call the appropriate recovery routine
* in "abort mode".
*/
- if (rectype == DB_log_register ||
+ if (rectype == DB_log_register || rectype == DB_txn_ckp ||
__db_txnlist_find(info, txnid) == DB_NOTFOUND)
return ((dispatch_table[rectype])(logp,
db, lsnp, TXN_UNDO, info));
@@ -124,7 +124,7 @@ __db_dispatch(logp, db, lsnp, redo, info)
* In the forward pass, if we haven't seen the transaction,
* do nothing, else recovery it.
*/
- if (rectype == DB_log_register ||
+ if (rectype == DB_log_register || rectype == DB_txn_ckp ||
__db_txnlist_find(info, txnid) != DB_NOTFOUND)
return ((dispatch_table[rectype])(logp,
db, lsnp, TXN_REDO, info));
@@ -188,14 +188,14 @@ int
__db_txnlist_init(retp)
void *retp;
{
- __db_txnhead *headp;
+ DB_TXNHEAD *headp;
- if ((headp = (struct __db_txnhead *)
- __db_malloc(sizeof(struct __db_txnhead))) == NULL)
+ if ((headp = (DB_TXNHEAD *)__db_malloc(sizeof(DB_TXNHEAD))) == NULL)
return (ENOMEM);
LIST_INIT(&headp->head);
headp->maxid = 0;
+ headp->generation = 1;
*(void **)retp = headp;
return (0);
@@ -212,25 +212,26 @@ __db_txnlist_add(listp, txnid)
void *listp;
u_int32_t txnid;
{
- __db_txnhead *hp;
- __db_txnlist *elp;
+ DB_TXNHEAD *hp;
+ DB_TXNLIST *elp;
- if ((elp = (__db_txnlist *)__db_malloc(sizeof(__db_txnlist))) == NULL)
+ if ((elp = (DB_TXNLIST *)__db_malloc(sizeof(DB_TXNLIST))) == NULL)
return (ENOMEM);
elp->txnid = txnid;
- hp = (struct __db_txnhead *)listp;
+ hp = (DB_TXNHEAD *)listp;
LIST_INSERT_HEAD(&hp->head, elp, links);
if (txnid > hp->maxid)
hp->maxid = txnid;
+ elp->generation = hp->generation;
return (0);
}
/*
* __db_txnlist_find --
- * Checks to see if txnid is in the txnid list, returns 1 if found,
- * 0 if not found.
+ * Checks to see if a txnid with the current generation is in the
+ * txnid list.
*
* PUBLIC: int __db_txnlist_find __P((void *, u_int32_t));
*/
@@ -239,45 +240,19 @@ __db_txnlist_find(listp, txnid)
void *listp;
u_int32_t txnid;
{
- __db_txnhead *hp;
- __db_txnlist *p;
+ DB_TXNHEAD *hp;
+ DB_TXNLIST *p;
- if ((hp = (struct __db_txnhead *)listp) == NULL)
+ if ((hp = (DB_TXNHEAD *)listp) == NULL)
return (DB_NOTFOUND);
- if (hp->maxid < txnid) {
- hp->maxid = txnid;
- return (DB_NOTFOUND);
- }
-
for (p = hp->head.lh_first; p != NULL; p = p->links.le_next)
- if (p->txnid == txnid)
+ if (p->txnid == txnid && hp->generation == p->generation)
return (0);
return (DB_NOTFOUND);
}
-#ifdef DEBUG
-/*
- * __db_txnlist_print --
- * Print out the transaction list.
- *
- * PUBLIC: void __db_txnlist_print __P((void *));
- */
-void
-__db_txnlist_print(listp)
- void *listp;
-{
- __db_txnhead *hp;
- __db_txnlist *p;
-
- hp = (struct __db_txnhead *)listp;
- printf("Maxid: %lu\n", (u_long)hp->maxid);
- for (p = hp->head.lh_first; p != NULL; p = p->links.le_next)
- printf("TXNID: %lu\n", (u_long)p->txnid);
-}
-#endif
-
/*
* __db_txnlist_end --
* Discard transaction linked list.
@@ -288,13 +263,61 @@ void
__db_txnlist_end(listp)
void *listp;
{
- __db_txnhead *hp;
- __db_txnlist *p;
+ DB_TXNHEAD *hp;
+ DB_TXNLIST *p;
- hp = (struct __db_txnhead *)listp;
+ hp = (DB_TXNHEAD *)listp;
while ((p = LIST_FIRST(&hp->head)) != LIST_END(&hp->head)) {
LIST_REMOVE(p, links);
__db_free(p);
}
__db_free(listp);
}
+
+/*
+ * __db_txnlist_gen --
+ * Change the current generation number.
+ *
+ * PUBLIC: void __db_txnlist_gen __P((void *, int));
+ */
+void
+__db_txnlist_gen(listp, incr)
+ void *listp;
+ int incr;
+{
+ DB_TXNHEAD *hp;
+
+ /*
+ * During recovery generation numbers keep track of how many "restart"
+ * checkpoints we've seen. Restart checkpoints occur whenever we take
+ * a checkpoint and there are no outstanding transactions. When that
+ * happens, we can reset transaction IDs back to 1. It always happens
+ * at recovery and it prevents us from exhausting the transaction IDs
+ * name space.
+ */
+ hp = (DB_TXNHEAD *)listp;
+ hp->generation += incr;
+}
+
+#ifdef DEBUG
+/*
+ * __db_txnlist_print --
+ * Print out the transaction list.
+ *
+ * PUBLIC: void __db_txnlist_print __P((void *));
+ */
+void
+__db_txnlist_print(listp)
+ void *listp;
+{
+ DB_TXNHEAD *hp;
+ DB_TXNLIST *p;
+
+ hp = (DB_TXNHEAD *)listp;
+ printf("Maxid: %lu Generation: %lu\n", (u_long)hp->maxid,
+ (u_long)hp->generation);
+ for (p = hp->head.lh_first; p != NULL; p = p->links.le_next)
+ printf("TXNID: %lu(%lu)\n", (u_long)p->txnid,
+ (u_long)p->generation);
+}
+#endif
diff --git a/db2/db/db_dup.c b/db2/db/db_dup.c
index 59dfb85..6379fc1 100644
--- a/db2/db/db_dup.c
+++ b/db2/db/db_dup.c
@@ -1,35 +1,27 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)db_dup.c 10.11 (Sleepycat) 1/8/98";
+static const char sccsid[] = "@(#)db_dup.c 10.18 (Sleepycat) 5/31/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
-#include <sys/stat.h>
#include <errno.h>
-#include <fcntl.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#endif
#include "db_int.h"
#include "db_page.h"
-#include "db_swap.h"
#include "btree.h"
#include "db_am.h"
-#include "common_ext.h"
static int __db_addpage __P((DB *,
PAGE **, db_indx_t *, int (*)(DB *, u_int32_t, PAGE **)));
@@ -209,9 +201,8 @@ __db_dsplit(dbp, hp, indxp, size, newfunc)
PAGE *h, *np, *tp;
BKEYDATA *bk;
DBT page_dbt;
- db_indx_t indx, nindex, oindex, sum;
- db_indx_t halfbytes, i, lastsum;
- int did_indx, ret, s;
+ db_indx_t halfbytes, i, indx, lastsum, nindex, oindex, s, sum;
+ int did_indx, ret;
h = *hp;
indx = *indxp;
@@ -219,7 +210,7 @@ __db_dsplit(dbp, hp, indxp, size, newfunc)
/* Create a temporary page to do compaction onto. */
if ((tp = (PAGE *)__db_malloc(dbp->pgsize)) == NULL)
return (ENOMEM);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
memset(tp, 0xff, dbp->pgsize);
#endif
/* Create new page for the split. */
@@ -239,6 +230,7 @@ __db_dsplit(dbp, hp, indxp, size, newfunc)
for (sum = 0, lastsum = 0, i = 0; i < NUM_ENT(h); i++) {
if (i == indx) {
sum += size;
+ did_indx = 1;
if (lastsum < halfbytes && sum >= halfbytes) {
/* We've crossed the halfway point. */
if ((db_indx_t)(halfbytes - lastsum) <
@@ -252,7 +244,6 @@ __db_dsplit(dbp, hp, indxp, size, newfunc)
}
*indxp = i;
lastsum = sum;
- did_indx = 1;
}
if (B_TYPE(GET_BKEYDATA(h, i)->type) == B_KEYDATA)
sum += BKEYDATA_SIZE(GET_BKEYDATA(h, i)->len);
diff --git a/db2/db/db_overflow.c b/db2/db/db_overflow.c
index 8c6619f..d28740d 100644
--- a/db2/db/db_overflow.c
+++ b/db2/db/db_overflow.c
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
/*
@@ -47,22 +47,19 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)db_overflow.c 10.7 (Sleepycat) 11/2/97";
+static const char sccsid[] = "@(#)db_overflow.c 10.11 (Sleepycat) 5/7/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#endif
#include "db_int.h"
#include "db_page.h"
#include "db_am.h"
-#include "common_ext.h"
/*
* Big key/data code.
@@ -91,9 +88,9 @@ __db_goff(dbp, dbt, tlen, pgno, bpp, bpsz)
{
PAGE *h;
db_indx_t bytes;
- int ret;
u_int32_t curoff, needed, start;
u_int8_t *p, *src;
+ int ret;
/*
* Check if the buffer is big enough; if it is not and we are
@@ -259,13 +256,13 @@ __db_poff(dbp, dbt, pgnop, newfunc)
* __db_ovref --
* Increment/decrement the reference count on an overflow page.
*
- * PUBLIC: int __db_ovref __P((DB *, db_pgno_t, int));
+ * PUBLIC: int __db_ovref __P((DB *, db_pgno_t, int32_t));
*/
int
__db_ovref(dbp, pgno, adjust)
DB *dbp;
db_pgno_t pgno;
- int adjust;
+ int32_t adjust;
{
PAGE *h;
int ret;
@@ -277,7 +274,7 @@ __db_ovref(dbp, pgno, adjust)
if (DB_LOGGING(dbp))
if ((ret = __db_ovref_log(dbp->dbenv->lg_info, dbp->txn,
- &LSN(h), 0, dbp->log_fileid, h->pgno, (int32_t)adjust,
+ &LSN(h), 0, dbp->log_fileid, h->pgno, adjust,
&LSN(h))) != 0)
return (ret);
OV_REF(h) += adjust;
@@ -353,8 +350,8 @@ __db_moff(dbp, dbt, pgno)
{
PAGE *pagep;
u_int32_t cmp_bytes, key_left;
- int ret;
u_int8_t *p1, *p2;
+ int ret;
/* While there are both keys to compare. */
for (ret = 0, p1 = dbt->data,
diff --git a/db2/db/db_pr.c b/db2/db/db_pr.c
index 1135a9e..a294cdd 100644
--- a/db2/db/db_pr.c
+++ b/db2/db/db_pr.c
@@ -1,14 +1,14 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)db_pr.c 10.20 (Sleepycat) 1/8/98";
+static const char sccsid[] = "@(#)db_pr.c 10.29 (Sleepycat) 5/23/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -16,7 +16,6 @@ static const char sccsid[] = "@(#)db_pr.c 10.20 (Sleepycat) 1/8/98";
#include <ctype.h>
#include <errno.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -160,7 +159,7 @@ __db_prdb(dbp)
}
fprintf(fp, "%s ", t);
- __db_prflags(dbp->flags, fn);
+ __db_prflags(dbp->flags, fn, fp);
fprintf(fp, "\n");
return (0);
@@ -179,12 +178,16 @@ __db_prbtree(dbp)
static const FN mfn[] = {
{ BTM_DUP, "duplicates" },
{ BTM_RECNO, "recno" },
+ { BTM_RECNUM, "btree:records" },
+ { BTM_FIXEDLEN, "recno:fixed-length" },
+ { BTM_RENUMBER, "recno:renumber" },
{ 0 },
};
BTMETA *mp;
BTREE *t;
EPG *epg;
FILE *fp;
+ PAGE *h;
RECNO *rp;
db_pgno_t i;
int ret;
@@ -193,19 +196,29 @@ __db_prbtree(dbp)
fp = __db_prinit(NULL);
(void)fprintf(fp, "%s\nOn-page metadata:\n", DB_LINE);
- i = PGNO_METADATA;
+ i = PGNO_METADATA;
if ((ret = __bam_pget(dbp, (PAGE **)&mp, &i, 0)) != 0)
return (ret);
(void)fprintf(fp, "magic %#lx\n", (u_long)mp->magic);
- (void)fprintf(fp, "version %lu\n", (u_long)mp->version);
+ (void)fprintf(fp, "version %#lx\n", (u_long)mp->version);
(void)fprintf(fp, "pagesize %lu\n", (u_long)mp->pagesize);
(void)fprintf(fp, "maxkey: %lu minkey: %lu\n",
(u_long)mp->maxkey, (u_long)mp->minkey);
- (void)fprintf(fp, "free %lu\n", (u_long)mp->free);
- (void)fprintf(fp, "flags %lu", (u_long)mp->flags);
- __db_prflags(mp->flags, mfn);
+
+ (void)fprintf(fp, "free %lu", (u_long)mp->free);
+ for (i = mp->free; i != PGNO_INVALID;) {
+ if ((ret = __bam_pget(dbp, &h, &i, 0)) != 0)
+ return (ret);
+ i = h->next_pgno;
+ (void)memp_fput(dbp->mpf, h, 0);
+ (void)fprintf(fp, ", %lu", (u_long)i);
+ }
+ (void)fprintf(fp, "\n");
+
+ (void)fprintf(fp, "flags %#lx", (u_long)mp->flags);
+ __db_prflags(mp->flags, mfn, fp);
(void)fprintf(fp, "\n");
(void)memp_fput(dbp->mpf, mp, 0);
@@ -576,7 +589,7 @@ __db_isbad(h, die)
BKEYDATA *bk;
FILE *fp;
db_indx_t i;
- int type;
+ u_int type;
fp = __db_prinit(NULL);
@@ -668,7 +681,8 @@ __db_pr(p, len)
u_int32_t len;
{
FILE *fp;
- int i, lastch;
+ u_int lastch;
+ int i;
fp = __db_prinit(NULL);
@@ -681,7 +695,7 @@ __db_pr(p, len)
if (isprint(*p) || *p == '\n')
fprintf(fp, "%c", *p);
else
- fprintf(fp, "%#x", (u_int)*p);
+ fprintf(fp, "0x%.2x", (u_int)*p);
}
if (len > 20) {
fprintf(fp, "...");
@@ -693,6 +707,50 @@ __db_pr(p, len)
}
/*
+ * __db_prdbt --
+ * Print out a DBT data element.
+ *
+ * PUBLIC: int __db_prdbt __P((DBT *, int, FILE *));
+ */
+int
+__db_prdbt(dbtp, checkprint, fp)
+ DBT *dbtp;
+ int checkprint;
+ FILE *fp;
+{
+ static const char hex[] = "0123456789abcdef";
+ u_int8_t *p;
+ u_int32_t len;
+
+ /*
+ * !!!
+ * This routine is the routine that dumps out items in the format
+ * used by db_dump(1) and db_load(1). This means that the format
+ * cannot change.
+ */
+ if (checkprint) {
+ for (len = dbtp->size, p = dbtp->data; len--; ++p)
+ if (isprint(*p)) {
+ if (*p == '\\' && fprintf(fp, "\\") != 1)
+ return (EIO);
+ if (fprintf(fp, "%c", *p) != 1)
+ return (EIO);
+ } else
+ if (fprintf(fp, "\\%c%c",
+ hex[(u_int8_t)(*p & 0xf0) >> 4],
+ hex[*p & 0x0f]) != 3)
+ return (EIO);
+ } else
+ for (len = dbtp->size, p = dbtp->data; len--; ++p)
+ if (fprintf(fp, "%c%c",
+ hex[(u_int8_t)(*p & 0xf0) >> 4],
+ hex[*p & 0x0f]) != 2)
+ return (EIO);
+
+ return (fprintf(fp, "\n") == 1 ? 0 : EIO);
+}
+
+/*
* __db_proff --
* Print out an off-page element.
*/
@@ -721,23 +779,21 @@ __db_proff(vp)
* __db_prflags --
* Print out flags values.
*
- * PUBLIC: void __db_prflags __P((u_int32_t, const FN *));
+ * PUBLIC: void __db_prflags __P((u_int32_t, const FN *, FILE *));
*/
void
-__db_prflags(flags, fn)
+__db_prflags(flags, fn, fp)
u_int32_t flags;
FN const *fn;
-{
FILE *fp;
+{
const FN *fnp;
int found;
const char *sep;
- fp = __db_prinit(NULL);
-
sep = " (";
for (found = 0, fnp = fn; fnp->mask != 0; ++fnp)
- if (fnp->mask & flags) {
+ if (LF_ISSET(fnp->mask)) {
fprintf(fp, "%s%s", sep, fnp->name);
sep = ", ";
found = 1;
diff --git a/db2/db/db_rec.c b/db2/db/db_rec.c
index 48e09e6..fe7c807 100644
--- a/db2/db/db_rec.c
+++ b/db2/db/db_rec.c
@@ -1,30 +1,25 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)db_rec.c 10.12 (Sleepycat) 1/8/98";
+static const char sccsid[] = "@(#)db_rec.c 10.16 (Sleepycat) 4/28/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
-#endif
-#include <ctype.h>
-#include <errno.h>
-#include <stddef.h>
-#include <stdlib.h>
#include <string.h>
+#endif
#include "db_int.h"
#include "shqueue.h"
#include "db_page.h"
-#include "db_dispatch.h"
#include "log.h"
#include "hash.h"
#include "btree.h"
@@ -48,7 +43,8 @@ __db_addrem_recover(logp, dbtp, lsnp, redo, info)
DB *file_dbp, *mdbp;
DB_MPOOLFILE *mpf;
PAGE *pagep;
- int change, cmp_n, cmp_p, ret;
+ u_int32_t change;
+ int cmp_n, cmp_p, ret;
REC_PRINT(__db_addrem_print);
REC_INTRO(__db_addrem_read);
@@ -193,7 +189,8 @@ __db_big_recover(logp, dbtp, lsnp, redo, info)
DB *file_dbp, *mdbp;
DB_MPOOLFILE *mpf;
PAGE *pagep;
- int change, cmp_n, cmp_p, ret;
+ u_int32_t change;
+ int cmp_n, cmp_p, ret;
REC_PRINT(__db_big_print);
REC_INTRO(__db_big_read);
@@ -503,7 +500,8 @@ __db_addpage_recover(logp, dbtp, lsnp, redo, info)
DB *file_dbp, *mdbp;
DB_MPOOLFILE *mpf;
PAGE *pagep;
- int change, cmp_n, cmp_p, ret;
+ u_int32_t change;
+ int cmp_n, cmp_p, ret;
REC_PRINT(__db_addpage_print);
REC_INTRO(__db_addpage_read);
@@ -601,8 +599,7 @@ __db_debug_recover(logp, dbtp, lsnp, redo, info)
* __db_noop_recover --
* Recovery function for noop.
*
- * PUBLIC: int __db_noop_recover
- * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
+ * PUBLIC: int __db_noop_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
*/
int
__db_noop_recover(logp, dbtp, lsnp, redo, info)
@@ -613,16 +610,30 @@ __db_noop_recover(logp, dbtp, lsnp, redo, info)
void *info;
{
__db_noop_args *argp;
- int ret;
-
- COMPQUIET(redo, 0);
- COMPQUIET(logp, NULL);
+ DB *file_dbp, *mdbp;
+ DB_MPOOLFILE *mpf;
+ PAGE *pagep;
+ u_int32_t change;
+ int cmp_n, cmp_p, ret;
REC_PRINT(__db_noop_print);
- REC_NOOP_INTRO(__db_noop_read);
+ REC_INTRO(__db_noop_read);
+
+ if ((ret = memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0)
+ goto out;
+ cmp_n = log_compare(lsnp, &LSN(pagep));
+ cmp_p = log_compare(&LSN(pagep), &argp->prevlsn);
+ change = 0;
+ if (cmp_p == 0 && redo) {
+ LSN(pagep) = *lsnp;
+ change = DB_MPOOL_DIRTY;
+ } else if (cmp_n == 0 && !redo) {
+ LSN(pagep) = argp->prevlsn;
+ change = DB_MPOOL_DIRTY;
+ }
*lsnp = argp->prev_lsn;
- ret = 0;
+ ret = memp_fput(mpf, pagep, change);
- REC_NOOP_CLOSE;
+out: REC_CLOSE;
}
diff --git a/db2/db/db_ret.c b/db2/db/db_ret.c
index 65441aa..9d9b599 100644
--- a/db2/db/db_ret.c
+++ b/db2/db/db_ret.c
@@ -1,29 +1,26 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)db_ret.c 10.10 (Sleepycat) 11/28/97";
+static const char sccsid[] = "@(#)db_ret.c 10.13 (Sleepycat) 5/7/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#endif
#include "db_int.h"
#include "db_page.h"
#include "btree.h"
-#include "hash.h"
#include "db_am.h"
/*
diff --git a/db2/db/db_thread.c b/db2/db/db_thread.c
index d908691..73e2a51 100644
--- a/db2/db/db_thread.c
+++ b/db2/db/db_thread.c
@@ -1,27 +1,25 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)db_thread.c 8.13 (Sleepycat) 10/25/97";
+static const char sccsid[] = "@(#)db_thread.c 8.15 (Sleepycat) 4/26/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <errno.h>
-#include <stdlib.h>
#include <string.h>
#endif
#include "db_int.h"
#include "db_page.h"
-#include "shqueue.h"
#include "db_am.h"
static int __db_getlockid __P((DB *, DB *));