00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _DB_AM_H_
00010 #define _DB_AM_H_
00011
00012
00013
00014
00015
00016 #define IS_ENV_AUTO_COMMIT(dbenv, txn, flags) \
00017 (LF_ISSET(DB_AUTO_COMMIT) || \
00018 ((txn) == NULL && F_ISSET((dbenv), DB_ENV_AUTO_COMMIT) && \
00019 !LF_ISSET(DB_NO_AUTO_COMMIT)))
00020
00021
00022
00023
00024
00025 #define IS_DB_AUTO_COMMIT(dbp, txn) \
00026 ((txn) == NULL && F_ISSET((dbp), DB_AM_TXN))
00027
00028
00029
00030
00031
00032
00033 #define STRIP_AUTO_COMMIT(f) FLD_CLR((f), DB_AUTO_COMMIT)
00034
00035
00036 #define DB_ADD_DUP 1
00037 #define DB_REM_DUP 2
00038 #define DB_ADD_BIG 3
00039 #define DB_REM_BIG 4
00040
00041
00042
00043
00044 #define REC_INTRO(func, inc_count, do_cursor) do { \
00045 argp = NULL; \
00046 file_dbp = NULL; \
00047 COMPQUIET(dbc, NULL); \
00048 \
00049 COMPQUIET(mpf, NULL); \
00050 if ((ret = func(dbenv, dbtp->data, &argp)) != 0) \
00051 goto out; \
00052 if ((ret = __dbreg_id_to_db(dbenv, argp->txnid, \
00053 &file_dbp, argp->fileid, inc_count)) != 0) { \
00054 if (ret == DB_DELETED) { \
00055 ret = 0; \
00056 goto done; \
00057 } \
00058 goto out; \
00059 } \
00060 if (do_cursor) { \
00061 if ((ret = __db_cursor(file_dbp, NULL, &dbc, 0)) != 0) \
00062 goto out; \
00063 F_SET(dbc, DBC_RECOVER); \
00064 } \
00065 mpf = file_dbp->mpf; \
00066 } while (0)
00067
00068 #define REC_CLOSE { \
00069 int __t_ret; \
00070 if (argp != NULL) \
00071 __os_free(dbenv, argp); \
00072 if (dbc != NULL && \
00073 (__t_ret = __db_c_close(dbc)) != 0 && ret == 0) \
00074 ret = __t_ret; \
00075 } \
00076 return (ret)
00077
00078
00079
00080
00081 #define REC_NOOP_INTRO(func) do { \
00082 argp = NULL; \
00083 if ((ret = func(dbenv, dbtp->data, &argp)) != 0) \
00084 return (ret); \
00085 } while (0)
00086 #define REC_NOOP_CLOSE \
00087 if (argp != NULL) \
00088 __os_free(dbenv, argp); \
00089 return (ret)
00090
00091
00092
00093
00094
00095
00096 #ifndef HAVE_FTRUNCATE
00097 #define REC_FGET(mpf, pgno, pagep, cont) \
00098 if ((ret = __memp_fget(mpf, &(pgno), 0, pagep)) != 0) { \
00099 if (ret != DB_PAGE_NOTFOUND || DB_REDO(op)) { \
00100 ret = __db_pgerr(file_dbp, pgno, ret); \
00101 goto out; \
00102 } else \
00103 goto cont; \
00104 }
00105 #else
00106 #define REC_FGET(mpf, pgno, pagep, cont) \
00107 if ((ret = __memp_fget(mpf, &(pgno), 0, pagep)) != 0) { \
00108 if (ret != DB_PAGE_NOTFOUND) { \
00109 ret = __db_pgerr(file_dbp, pgno, ret); \
00110 goto out; \
00111 } else \
00112 goto cont; \
00113 }
00114 #endif
00115
00116
00117
00118
00119 #ifdef DEBUG_RECOVER
00120 #define REC_PRINT(func) \
00121 (void)func(dbenv, dbtp, lsnp, op, info);
00122 #else
00123 #define REC_PRINT(func)
00124 #endif
00125
00126
00127
00128
00129 #define LCK_ALWAYS 1
00130 #define LCK_COUPLE 2
00131 #define LCK_COUPLE_ALWAYS 3
00132 #define LCK_DOWNGRADE 4
00133 #define LCK_ROLLBACK 5
00134
00135
00136
00137
00138
00139
00140
00141 #define __LPUT(dbc, lock) \
00142 __ENV_LPUT((dbc)->dbp->dbenv, lock)
00143
00144 #define __ENV_LPUT(dbenv, lock) \
00145 (LOCK_ISSET(lock) ? __lock_put(dbenv, &(lock)) : 0)
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 #define __TLPUT(dbc, lock) \
00158 (LOCK_ISSET(lock) ? __db_lput(dbc, &(lock)) : 0)
00159
00160 typedef struct {
00161 DBC *dbc;
00162 u_int32_t count;
00163 } db_trunc_param;
00164
00165
00166
00167
00168
00169
00170 #define DB_IS_READONLY(dbp) \
00171 (F_ISSET(dbp, DB_AM_RDONLY) || \
00172 (IS_REP_CLIENT((dbp)->dbenv) && \
00173 !F_ISSET((dbp), DB_AM_CL_WRITER)))
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 #include "dbinc/db_swap.h"
00184
00185 #define SWAP_IF_NEEDED(pdbp, sdbp, pkey) \
00186 do { \
00187 if (((pdbp)->type == DB_QUEUE || \
00188 (pdbp)->type == DB_RECNO) && \
00189 F_ISSET((sdbp), DB_AM_SWAP)) \
00190 P_32_SWAP((pkey)->data); \
00191 } while (0)
00192
00193 #include "dbinc/db_dispatch.h"
00194 #include "dbinc_auto/db_auto.h"
00195 #include "dbinc_auto/crdel_auto.h"
00196 #include "dbinc_auto/db_ext.h"
00197 #endif