00001
00002
00003 #include "db_config.h"
00004
00005 #ifndef NO_SYSTEM_INCLUDES
00006 #include <sys/types.h>
00007
00008 #if TIME_WITH_SYS_TIME
00009 #include <sys/time.h>
00010 #include <time.h>
00011 #else
00012 #if HAVE_SYS_TIME_H
00013 #include <sys/time.h>
00014 #else
00015 #include <time.h>
00016 #endif
00017 #endif
00018
00019 #include <ctype.h>
00020 #include <string.h>
00021 #endif
00022
00023 #include "db_int.h"
00024 #include "dbinc/crypto.h"
00025 #include "dbinc/db_page.h"
00026 #include "dbinc/db_dispatch.h"
00027 #include "dbinc/db_am.h"
00028 #include "dbinc/db_shash.h"
00029 #include "dbinc/lock.h"
00030 #include "dbinc/log.h"
00031 #include "dbinc/txn.h"
00032
00033
00034
00035
00036
00037 int
00038 __txn_regop_print(dbenv, dbtp, lsnp, notused2, notused3)
00039 DB_ENV *dbenv;
00040 DBT *dbtp;
00041 DB_LSN *lsnp;
00042 db_recops notused2;
00043 void *notused3;
00044 {
00045 __txn_regop_args *argp;
00046 struct tm *lt;
00047 time_t timeval;
00048 int ret;
00049
00050 notused2 = DB_TXN_PRINT;
00051 notused3 = NULL;
00052
00053 if ((ret = __txn_regop_read(dbenv, dbtp->data, &argp)) != 0)
00054 return (ret);
00055 (void)printf(
00056 "[%lu][%lu]__txn_regop%s: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00057 (u_long)lsnp->file,
00058 (u_long)lsnp->offset,
00059 (argp->type & DB_debug_FLAG) ? "_debug" : "",
00060 (u_long)argp->type,
00061 (u_long)argp->txnid->txnid,
00062 (u_long)argp->prev_lsn.file,
00063 (u_long)argp->prev_lsn.offset);
00064 (void)printf("\topcode: %ld\n", (long)argp->opcode);
00065 timeval = (time_t)argp->timestamp;
00066 lt = localtime(&timeval);
00067 (void)printf(
00068 "\ttimestamp: %ld (%.24s, 20%02lu%02lu%02lu%02lu%02lu.%02lu)\n",
00069 (long)argp->timestamp, ctime(&timeval),
00070 (u_long)lt->tm_year - 100, (u_long)lt->tm_mon+1,
00071 (u_long)lt->tm_mday, (u_long)lt->tm_hour,
00072 (u_long)lt->tm_min, (u_long)lt->tm_sec);
00073 (void)printf("\tenvid: %ld\n", (long)argp->envid);
00074 (void)printf("\tlocks: \n");
00075 __lock_list_print(dbenv, &argp->locks);
00076 (void)printf("\n");
00077 __os_free(dbenv, argp);
00078 return (0);
00079 }
00080
00081
00082
00083
00084
00085 int
00086 __txn_ckp_print(dbenv, dbtp, lsnp, notused2, notused3)
00087 DB_ENV *dbenv;
00088 DBT *dbtp;
00089 DB_LSN *lsnp;
00090 db_recops notused2;
00091 void *notused3;
00092 {
00093 __txn_ckp_args *argp;
00094 struct tm *lt;
00095 time_t timeval;
00096 int ret;
00097
00098 notused2 = DB_TXN_PRINT;
00099 notused3 = NULL;
00100
00101 if ((ret = __txn_ckp_read(dbenv, dbtp->data, &argp)) != 0)
00102 return (ret);
00103 (void)printf(
00104 "[%lu][%lu]__txn_ckp%s: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00105 (u_long)lsnp->file,
00106 (u_long)lsnp->offset,
00107 (argp->type & DB_debug_FLAG) ? "_debug" : "",
00108 (u_long)argp->type,
00109 (u_long)argp->txnid->txnid,
00110 (u_long)argp->prev_lsn.file,
00111 (u_long)argp->prev_lsn.offset);
00112 (void)printf("\tckp_lsn: [%lu][%lu]\n",
00113 (u_long)argp->ckp_lsn.file, (u_long)argp->ckp_lsn.offset);
00114 (void)printf("\tlast_ckp: [%lu][%lu]\n",
00115 (u_long)argp->last_ckp.file, (u_long)argp->last_ckp.offset);
00116 timeval = (time_t)argp->timestamp;
00117 lt = localtime(&timeval);
00118 (void)printf(
00119 "\ttimestamp: %ld (%.24s, 20%02lu%02lu%02lu%02lu%02lu.%02lu)\n",
00120 (long)argp->timestamp, ctime(&timeval),
00121 (u_long)lt->tm_year - 100, (u_long)lt->tm_mon+1,
00122 (u_long)lt->tm_mday, (u_long)lt->tm_hour,
00123 (u_long)lt->tm_min, (u_long)lt->tm_sec);
00124 (void)printf("\tenvid: %ld\n", (long)argp->envid);
00125 (void)printf("\trep_gen: %ld\n", (long)argp->rep_gen);
00126 (void)printf("\n");
00127 __os_free(dbenv, argp);
00128 return (0);
00129 }
00130
00131
00132
00133
00134
00135 int
00136 __txn_child_print(dbenv, dbtp, lsnp, notused2, notused3)
00137 DB_ENV *dbenv;
00138 DBT *dbtp;
00139 DB_LSN *lsnp;
00140 db_recops notused2;
00141 void *notused3;
00142 {
00143 __txn_child_args *argp;
00144 int ret;
00145
00146 notused2 = DB_TXN_PRINT;
00147 notused3 = NULL;
00148
00149 if ((ret = __txn_child_read(dbenv, dbtp->data, &argp)) != 0)
00150 return (ret);
00151 (void)printf(
00152 "[%lu][%lu]__txn_child%s: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00153 (u_long)lsnp->file,
00154 (u_long)lsnp->offset,
00155 (argp->type & DB_debug_FLAG) ? "_debug" : "",
00156 (u_long)argp->type,
00157 (u_long)argp->txnid->txnid,
00158 (u_long)argp->prev_lsn.file,
00159 (u_long)argp->prev_lsn.offset);
00160 (void)printf("\tchild: 0x%lx\n", (u_long)argp->child);
00161 (void)printf("\tc_lsn: [%lu][%lu]\n",
00162 (u_long)argp->c_lsn.file, (u_long)argp->c_lsn.offset);
00163 (void)printf("\n");
00164 __os_free(dbenv, argp);
00165 return (0);
00166 }
00167
00168
00169
00170
00171
00172 int
00173 __txn_xa_regop_print(dbenv, dbtp, lsnp, notused2, notused3)
00174 DB_ENV *dbenv;
00175 DBT *dbtp;
00176 DB_LSN *lsnp;
00177 db_recops notused2;
00178 void *notused3;
00179 {
00180 __txn_xa_regop_args *argp;
00181 u_int32_t i;
00182 int ch;
00183 int ret;
00184
00185 notused2 = DB_TXN_PRINT;
00186 notused3 = NULL;
00187
00188 if ((ret = __txn_xa_regop_read(dbenv, dbtp->data, &argp)) != 0)
00189 return (ret);
00190 (void)printf(
00191 "[%lu][%lu]__txn_xa_regop%s: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00192 (u_long)lsnp->file,
00193 (u_long)lsnp->offset,
00194 (argp->type & DB_debug_FLAG) ? "_debug" : "",
00195 (u_long)argp->type,
00196 (u_long)argp->txnid->txnid,
00197 (u_long)argp->prev_lsn.file,
00198 (u_long)argp->prev_lsn.offset);
00199 (void)printf("\topcode: %lu\n", (u_long)argp->opcode);
00200 (void)printf("\txid: ");
00201 for (i = 0; i < argp->xid.size; i++) {
00202 ch = ((u_int8_t *)argp->xid.data)[i];
00203 printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
00204 }
00205 (void)printf("\n");
00206 (void)printf("\tformatID: %ld\n", (long)argp->formatID);
00207 (void)printf("\tgtrid: %u\n", argp->gtrid);
00208 (void)printf("\tbqual: %u\n", argp->bqual);
00209 (void)printf("\tbegin_lsn: [%lu][%lu]\n",
00210 (u_long)argp->begin_lsn.file, (u_long)argp->begin_lsn.offset);
00211 (void)printf("\tlocks: \n");
00212 __lock_list_print(dbenv, &argp->locks);
00213 (void)printf("\n");
00214 __os_free(dbenv, argp);
00215 return (0);
00216 }
00217
00218
00219
00220
00221
00222 int
00223 __txn_recycle_print(dbenv, dbtp, lsnp, notused2, notused3)
00224 DB_ENV *dbenv;
00225 DBT *dbtp;
00226 DB_LSN *lsnp;
00227 db_recops notused2;
00228 void *notused3;
00229 {
00230 __txn_recycle_args *argp;
00231 int ret;
00232
00233 notused2 = DB_TXN_PRINT;
00234 notused3 = NULL;
00235
00236 if ((ret = __txn_recycle_read(dbenv, dbtp->data, &argp)) != 0)
00237 return (ret);
00238 (void)printf(
00239 "[%lu][%lu]__txn_recycle%s: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00240 (u_long)lsnp->file,
00241 (u_long)lsnp->offset,
00242 (argp->type & DB_debug_FLAG) ? "_debug" : "",
00243 (u_long)argp->type,
00244 (u_long)argp->txnid->txnid,
00245 (u_long)argp->prev_lsn.file,
00246 (u_long)argp->prev_lsn.offset);
00247 (void)printf("\tmin: %u\n", argp->min);
00248 (void)printf("\tmax: %u\n", argp->max);
00249 (void)printf("\n");
00250 __os_free(dbenv, argp);
00251 return (0);
00252 }
00253
00254
00255
00256
00257
00258 int
00259 __txn_init_print(dbenv, dtabp, dtabsizep)
00260 DB_ENV *dbenv;
00261 int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
00262 size_t *dtabsizep;
00263 {
00264 int ret;
00265
00266 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
00267 __txn_regop_print, DB___txn_regop)) != 0)
00268 return (ret);
00269 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
00270 __txn_ckp_print, DB___txn_ckp)) != 0)
00271 return (ret);
00272 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
00273 __txn_child_print, DB___txn_child)) != 0)
00274 return (ret);
00275 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
00276 __txn_xa_regop_print, DB___txn_xa_regop)) != 0)
00277 return (ret);
00278 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
00279 __txn_recycle_print, DB___txn_recycle)) != 0)
00280 return (ret);
00281 return (0);
00282 }