db_am.h

Go to the documentation of this file.
00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1996, 1997, 1998, 1999, 2000
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: db__am_8h-source.html,v 1.1 2008/06/08 10:17:12 sebdiaz Exp $
00008  */
00009 #ifndef _DB_AM_H
00010 #define _DB_AM_H
00011 
00012 #define DB_MINPAGECACHE 10              /* Min pages access methods cache. */
00013 
00014 #define DB_ISBIG        0x01            /* DB recovery operation codes. */
00015 #define DB_ISSUBDB      0x02
00016 #define DB_ADD_DUP      0x10
00017 #define DB_REM_DUP      0x20
00018 #define DB_ADD_BIG      0x30
00019 #define DB_REM_BIG      0x40
00020 #define DB_SPLITOLD     0x50
00021 #define DB_SPLITNEW     0x60
00022 #define DB_ADD_PAGE     0x70
00023 #define DB_REM_PAGE     0x80
00024 #define DB_LOG_CREATE   0x90
00025 #define DB_LOG_DELETE   0xa0
00026 
00027 /*
00028  * This is a grotesque naming hack.  We have modified the btree page
00029  * allocation and freeing functions to be generic and have therefore
00030  * moved them into the access-method independent portion of the code.
00031  * However, since we didn't want to create new log records and routines
00032  * for them, we left their logging and recovery functions over in btree.
00033  * To make the code look prettier, we macro them, but this is sure to
00034  * confuse the heck out of everyone.
00035  */
00036 #define __db_pg_alloc_log       CDB___bam_pg_alloc_log
00037 #define __db_pg_free_log        CDB___bam_pg_free_log
00038 
00039 /*
00040  * Standard initialization and shutdown macros for all recovery functions.
00041  *
00042  * Requires the following local variables:
00043  *
00044  *      DB *file_dbp;
00045  *      DB_MPOOLFILE *mpf;
00046  *      int ret;
00047  */
00048 #define REC_INTRO(func, inc_count) {                                    \
00049         file_dbp = NULL;                                                \
00050         dbc = NULL;                                                     \
00051         if ((ret = func(dbenv, dbtp->data, &argp)) != 0)                \
00052                 goto out;                                               \
00053         if ((ret = CDB___db_fileid_to_db(dbenv,                         \
00054             &file_dbp, argp->fileid, inc_count)) != 0) {                \
00055                 if (ret == DB_DELETED) {                                \
00056                         ret = 0;                                        \
00057                         goto done;                                      \
00058                 }                                                       \
00059                 goto out;                                               \
00060         }                                                               \
00061         if (file_dbp == NULL)                                           \
00062                 goto out;                                               \
00063         if ((ret = file_dbp->cursor(file_dbp, NULL, &dbc, 0)) != 0)     \
00064                 goto out;                                               \
00065         F_SET(dbc, DBC_RECOVER);                                        \
00066         mpf = file_dbp->mpf;                                            \
00067 }
00068 
00069 #define REC_CLOSE                                                       \
00070         if (argp != NULL)                                               \
00071                 CDB___os_free(argp, sizeof(*argp));                             \
00072         if (dbc != NULL)                                                \
00073                 dbc->c_close(dbc);                                      \
00074         return (ret);
00075 
00076 /*
00077  * No-op versions of the same macros.
00078  */
00079 #define REC_NOOP_INTRO(func) {                                          \
00080         if ((ret = func(dbenv, dbtp->data, &argp)) != 0)                \
00081                 return (ret);                                           \
00082 }
00083 #define REC_NOOP_CLOSE                                                  \
00084         if (argp != NULL)                                               \
00085                 CDB___os_free(argp, sizeof(*argp));                             \
00086         return (ret);                                                   \
00087 
00088 /*
00089  * Standard debugging macro for all recovery functions.
00090  */
00091 #ifdef DEBUG_RECOVER
00092 #define REC_PRINT(func)                                                 \
00093         (void)func(dbenv, dbtp, lsnp, redo, info);
00094 #else
00095 #define REC_PRINT(func)
00096 #endif
00097 
00098 /*
00099  * Flags to CDB___db_lget
00100  */
00101 #define LCK_COUPLE      0x01    /* Lock Couple */
00102 #define LCK_ALWAYS      0x02    /* Lock even for off page dup cursors */
00103 #define LCK_ROLLBACK    0x04    /* Lock even if in rollback */
00104 
00105 /*
00106  * If doing transactions we have to hold the locks associated with a data item
00107  * from a page for the entire transaction.  However, we don't have to hold the
00108  * locks associated with walking the tree.  Distinguish between the two so that
00109  * we don't tie up the internal pages of the tree longer than necessary.
00110  */
00111 #define __LPUT(dbc, lock)                                               \
00112         (lock.off != LOCK_INVALID ?                                     \
00113             CDB_lock_put((dbc)->dbp->dbenv, &(lock)) : 0)
00114 #define __TLPUT(dbc, lock)                                              \
00115         (lock.off != LOCK_INVALID &&                                    \
00116             (dbc)->txn == NULL ? CDB_lock_put((dbc)->dbp->dbenv, &(lock)) : 0)
00117 
00118 #include "db_auto.h"
00119 #include "crdel_auto.h"
00120 #include "db_ext.h"
00121 #endif

Generated on Sun Jun 8 10:56:36 2008 for GNUmifluz by  doxygen 1.5.5