1<!--$Id: txn_stat.so,v 10.68 2007/09/21 20:06:04 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DB_ENV->txn_stat</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DB_ENV->txn_stat</b> 14</td> 15<td align=right> 16<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db.h> 23<p> 24int 25DB_ENV->txn_stat(DB_ENV *env, DB_TXN_STAT **statp, u_int32_t flags); 26<p> 27int 28DB_ENV->txn_stat_print(DB_ENV *env, u_int32_t flags); 29</pre></b> 30<hr size=1 noshade> 31<b>Description: DB_ENV->txn_stat</b> 32<p>The DB_ENV->txn_stat method returns the transaction subsystem statistics.</p> 33<p>The DB_ENV->txn_stat method creates a statistical structure of type 34DB_TXN_STAT and copies a pointer to it into a user-specified memory 35location.</p> 36<p>Statistical structures are stored in allocated memory. If application-specific allocation 37routines have been declared (see <a href="../api_c/env_set_alloc.html">DB_ENV->set_alloc</a> for more 38information), they are used to allocate the memory; otherwise, the 39standard C library <b>malloc</b>(3) is used. The caller is 40responsible for deallocating the memory. To deallocate the memory, free 41the memory reference; references inside the returned memory need not be 42individually freed.</p> 43<p>The following DB_TXN_STAT fields will be filled in:</p> 44<br> 45<b>DbLsn st_last_ckp;</b><ul compact><li>The LSN of the last checkpoint.</ul> 46<b>time_t st_time_ckp;</b><ul compact><li>The time the last completed checkpoint finished (as the number of seconds 47since the Epoch, returned by the IEEE/ANSI Std 1003.1 (POSIX) <b>time</b> function).</ul> 48<b>u_int32_t st_last_txnid;</b><ul compact><li>The last transaction ID allocated.</ul> 49<b>u_int32_t st_maxtxns;</b><ul compact><li>The maximum number of active transactions configured.</ul> 50<b>u_int32_t st_nactive;</b><ul compact><li>The number of transactions that are currently active.</ul> 51<b>u_int32_t st_nsnapshot;</b><ul compact><li>The number of transactions on the snapshot list. These are transactions 52which modified a database opened with <a href="../api_c/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a>, 53and which have committed or aborted, but the copies of pages they 54created are still in the cache.</ul> 55<b>u_int32_t st_maxnactive;</b><ul compact><li>The maximum number of active transactions at any one time.</ul> 56<b>u_int32_t st_maxnsnapshot;</b><ul compact><li>The maximum number of transactions on the snapshot list at any one time.</ul> 57<b>u_int32_t st_nbegins;</b><ul compact><li>The number of transactions that have begun.</ul> 58<b>u_int32_t st_naborts;</b><ul compact><li>The number of transactions that have aborted.</ul> 59<b>u_int32_t st_ncommits;</b><ul compact><li>The number of transactions that have committed.</ul> 60<b>u_int32_t st_nrestores;</b><ul compact><li>The number of transactions that have been restored.</ul> 61<b>roff_t st_regsize;</b><ul compact><li>The size of the transaction region, in bytes.</ul> 62<b>u_int32_t st_region_wait;</b><ul compact><li>The number of times that a thread of control was forced to wait before 63obtaining the transaction region mutex.</ul> 64<b>u_int32_t st_region_nowait;</b><ul compact><li>The number of times that a thread of control was able to obtain 65the transaction region mutex without waiting.</ul> 66<b>DB_TXN_ACTIVE *st_txnarray;</b><ul compact><li>A pointer to an array of <b>st_nactive</b> DB_TXN_ACTIVE structures, 67describing the currently active transactions. The following fields of 68the DB_TXN_ACTIVE structure will be filled in:</ul> 69<br> 70<b>u_int32_t txnid;</b><ul compact><li>The transaction ID of the transaction.</ul> 71<b>u_int32_t parentid;</b><ul compact><li>The transaction ID of the parent transaction (or 0, if no parent).</ul> 72<b>pid_t pid;</b><ul compact><li>The process ID of the originator of the transaction.</ul> 73<b>uintmax_t tid;</b><ul compact><li>The thread of control ID of the originator of the transaction.</ul> 74<b>DbLsn lsn;</b><ul compact><li>The current log sequence number when the transaction was begun.</ul> 75<b>DbLsn read_lsn;</b><ul compact><li>The log sequence number of reads for snapshot transactions.</ul> 76<b>u_int32_t mvcc_ref;</b><ul compact><li>The number of buffer copies created by this transaction that remain in cache.</ul> 77<b>u_int32_t status;</b><ul compact><li>One of the following list of constants: TXN_ABORTED, TXN_COMMITTED, 78TXN_PREPARED, TXN_RUNNING.</ul> 79<b>u_int32_t xa_status;</b><ul compact><li>If the transaction is an XA transaction, the <b>xa_status</b> of the 80transaction will be one of the following list of constants: 81TXN_XA_ABORTED, TXN_XA_DEADLOCKED, TXN_XA_ENDED, TXN_XA_PREPARED, 82TXN_XA_STARTED, or TXN_XA_SUSPENDED. Otherwise, the <b>xa_status</b> 83will be 0.</ul> 84<b>u_int8_t xid[DB_XIDDATASIZE];</b><ul compact><li>If the transaction is an XA transaction, the transaction's XA ID. If 85the transaction was prepared separately from the XA interfaces, the 86transaction's Global ID. Otherwise, the <b>xid</b> contents are 87undefined.</ul> 88<b>char name[];</b><ul compact><li>If a name was specified for the transaction, up to the first 50 bytes 89of that name, followed by a nul termination byte.</ul> 90<br> 91<br> 92<p>The DB_ENV->txn_stat method may not be called before the <a href="../api_c/env_open.html">DB_ENV->open</a> method is called.</p> 93<p>The DB_ENV->txn_stat method 94returns a non-zero error value on failure 95and 0 on success. 96</p> 97<b>Parameters</b> <br> 98 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or 99the following value: 100<br> 101<b><a name="DB_STAT_CLEAR">DB_STAT_CLEAR</a></b><ul compact><li>Reset statistics after returning their values.</ul> 102<br></ul> 103 <b>statp</b><ul compact><li>The <b>statp</b> parameter references memory into which 104a pointer to the allocated statistics structure is copied.</ul> 105<br> 106<br><b>Errors</b> 107<p>The DB_ENV->txn_stat method 108may fail and return one of the following non-zero errors:</p> 109<br> 110<b>EINVAL</b><ul compact><li>An 111invalid flag value or parameter was specified.</ul> 112<br> 113<hr size=1 noshade> 114<b>Description: DB_ENV->txn_stat_print</b> 115<p>The DB_ENV->txn_stat_print method displays the 116transaction subsystem statistical information, as described for the DB_ENV->txn_stat method. 117The information is printed to a specified output channel (see the 118<a href="../api_c/env_set_msgfile.html">DB_ENV->set_msgfile</a> method for more information), or passed to an 119application callback function (see the <a href="../api_c/env_set_msgcall.html">DB_ENV->set_msgcall</a> method for 120more information).</p> 121<p>The DB_ENV->txn_stat_print method may not be called before the <a href="../api_c/env_open.html">DB_ENV->open</a> method is called.</p> 122<p>The DB_ENV->txn_stat_print method 123returns a non-zero error value on failure 124and 0 on success. 125</p> 126<b>Parameters</b> <br> 127 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one 128or more of the following values: 129<br> 130<b><a name="DB_STAT_ALL">DB_STAT_ALL</a></b><ul compact><li>Display all available information.</ul> 131<b><a name="DB_STAT_CLEAR">DB_STAT_CLEAR</a></b><ul compact><li>Reset statistics after displaying their values.</ul> 132<br></ul> 133<br> 134<hr size=1 noshade> 135<br><b>Class</b> 136<a href="../api_c/env_class.html">DB_ENV</a>, <a href="../api_c/txn_class.html">DB_TXN</a> 137<br><b>See Also</b> 138<a href="../api_c/txn_list.html">Transaction Subsystem and Related Methods</a> 139</tt> 140<table width="100%"><tr><td><br></td><td align=right> 141<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 142</td></tr></table> 143<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 144</body> 145</html> 146