| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>DbEnv::txn_stat()</title> |
| 7 | <link rel="stylesheet" href="apiReference.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" /> |
| 10 | <link rel="up" href="txn.html" title="Chapter 13. The DbTxn Handle" /> |
| 11 | <link rel="prev" href="txncheckpoint.html" title="DbEnv::txn_checkpoint()" /> |
| 12 | <link rel="next" href="txnstat_print.html" title="DbEnv::txn_stat_print()" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">DbEnv::txn_stat()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="txncheckpoint.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 13. |
| 26 | The DbTxn Handle |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="txnstat_print.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="txnstat"></a>DbEnv::txn_stat()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db_cxx.h> |
| 42 | |
| 43 | int |
| 44 | DbEnv::txn_stat(DB_TXN_STAT **statp, u_int32_t flags); </pre> |
| 45 | <p> |
| 46 | The <code class="methodname">DbEnv::txn_stat()</code> method returns the transaction subsystem |
| 47 | statistics. |
| 48 | </p> |
| 49 | <p> |
| 50 | The <code class="methodname">DbEnv::txn_stat()</code> method creates a statistical structure of type |
| 51 | <code class="literal">DB_TXN_STAT</code> and copies a pointer to it into a user-specified memory |
| 52 | location. |
| 53 | </p> |
| 54 | <p> |
| 55 | Statistical structures are stored in allocated memory. If |
| 56 | application-specific allocation routines have been declared (see |
| 57 | <a class="xref" href="envset_alloc.html" title="DbEnv::set_alloc()">DbEnv::set_alloc()</a> |
| 58 | for more information), they are used to allocate the memory; |
| 59 | otherwise, the standard C library <span class="bold"><strong>malloc</strong></span>(3) is used. The caller is responsible |
| 60 | for deallocating the memory. To deallocate the memory, free the |
| 61 | memory reference; references inside the returned memory need not be |
| 62 | individually freed. |
| 63 | </p> |
| 64 | <p> |
| 65 | The following DB_TXN_STAT fields will be filled in: |
| 66 | </p> |
| 67 | <div class="itemizedlist"> |
| 68 | <ul type="disc"> |
| 69 | <li> |
| 70 | <p> |
| 71 | <span class="bold"><strong>u_int32_t st_inittxns;</strong></span> |
| 72 | </p> |
| 73 | <p> |
| 74 | The initial number of transactions configured. |
| 75 | </p> |
| 76 | </li> |
| 77 | <li> |
| 78 | <p> |
| 79 | <span class="bold"><strong>DB_LSN st_last_ckp;</strong></span> |
| 80 | </p> |
| 81 | <p> |
| 82 | The LSN of the last checkpoint. |
| 83 | </p> |
| 84 | </li> |
| 85 | <li> |
| 86 | <p> |
| 87 | <span class="bold"><strong>u_int32_t st_last_txnid;</strong></span> |
| 88 | </p> |
| 89 | <p> |
| 90 | The last transaction ID allocated. |
| 91 | </p> |
| 92 | </li> |
| 93 | <li> |
| 94 | <p> |
| 95 | <span class="bold"><strong>u_int32_t st_maxnactive;</strong></span> |
| 96 | </p> |
| 97 | <p> |
| 98 | The maximum number of active transactions at any one time. |
| 99 | </p> |
| 100 | </li> |
| 101 | <li> |
| 102 | <p> |
| 103 | <span class="bold"><strong>u_int32_t st_maxnsnapshot;</strong></span> |
| 104 | </p> |
| 105 | <p> |
| 106 | The maximum number of transactions on the snapshot list at any one |
| 107 | time. |
| 108 | </p> |
| 109 | </li> |
| 110 | <li> |
| 111 | <p> |
| 112 | <span class="bold"><strong>u_int32_t st_maxtxns;</strong></span> |
| 113 | </p> |
| 114 | <p> |
| 115 | The maximum number of active transactions configured. |
| 116 | </p> |
| 117 | </li> |
| 118 | <li> |
| 119 | <p> |
| 120 | <span class="bold"><strong>uintmax_t st_naborts;</strong></span> |
| 121 | </p> |
| 122 | <p> |
| 123 | The number of transactions that have aborted. |
| 124 | </p> |
| 125 | </li> |
| 126 | <li> |
| 127 | <p> |
| 128 | <span class="bold"><strong>u_int32_t st_nactive;</strong></span> |
| 129 | </p> |
| 130 | <p> |
| 131 | The number of transactions that are currently active. |
| 132 | </p> |
| 133 | </li> |
| 134 | <li> |
| 135 | <p> |
| 136 | <span class="bold"><strong>uintmax_t st_nbegins;</strong></span> |
| 137 | </p> |
| 138 | <p> |
| 139 | The number of transactions that have begun. |
| 140 | </p> |
| 141 | </li> |
| 142 | <li> |
| 143 | <p> |
| 144 | <span class="bold"><strong>uintmax_t st_ncommits;</strong></span> |
| 145 | </p> |
| 146 | <p> |
| 147 | The number of transactions that have committed. |
| 148 | </p> |
| 149 | </li> |
| 150 | <li> |
| 151 | <p> |
| 152 | <span class="bold"><strong>u_int32_t st_nrestores;</strong></span> |
| 153 | </p> |
| 154 | <p> |
| 155 | The number of transactions that have been restored. |
| 156 | </p> |
| 157 | </li> |
| 158 | <li> |
| 159 | <p> |
| 160 | <span class="bold"><strong>u_int32_t st_nsnapshot;</strong></span> |
| 161 | </p> |
| 162 | <p> |
| 163 | The number of transactions on the snapshot list. These are |
| 164 | transactions which modified a database opened with |
| 165 | <a class="link" href="dbopen.html#dbopen_DB_MULTIVERSION">DB_MULTIVERSION</a>, |
| 166 | and which have committed or aborted, but the copies of pages they |
| 167 | created are still in the cache. |
| 168 | </p> |
| 169 | </li> |
| 170 | <li> |
| 171 | <p> |
| 172 | <span class="bold"><strong>uintmax_t st_region_nowait;</strong></span> |
| 173 | </p> |
| 174 | <p> |
| 175 | The number of times that a thread of control was able to obtain the |
| 176 | transaction region mutex without waiting. |
| 177 | </p> |
| 178 | </li> |
| 179 | <li> |
| 180 | <p> |
| 181 | <span class="bold"><strong>uintmax_t st_region_wait;</strong></span> |
| 182 | </p> |
| 183 | <p> |
| 184 | The number of times that a thread of control was forced to wait before |
| 185 | obtaining the transaction region mutex. |
| 186 | </p> |
| 187 | </li> |
| 188 | <li> |
| 189 | <p> |
| 190 | <span class="bold"><strong>roff_t st_regsize;</strong></span> |
| 191 | </p> |
| 192 | <p> |
| 193 | The region size, in bytes. |
| 194 | </p> |
| 195 | </li> |
| 196 | <li> |
| 197 | <p> |
| 198 | <span class="bold"><strong>time_t st_time_ckp;</strong></span> |
| 199 | </p> |
| 200 | <p> |
| 201 | The time the last completed checkpoint finished (as the number of |
| 202 | seconds since the Epoch, returned by the IEEE/ANSI Std 1003.1 (POSIX) |
| 203 | <span class="bold"><strong>time</strong></span> function). |
| 204 | </p> |
| 205 | </li> |
| 206 | <li> |
| 207 | <p> |
| 208 | <span class="bold"><strong>DB_TXN_ACTIVE *st_txnarray;</strong></span> |
| 209 | </p> |
| 210 | <p> |
| 211 | A pointer to an array of <span class="bold"><strong>st_nactive</strong></span> |
| 212 | DB_TXN_ACTIVE structures, describing the currently active |
| 213 | transactions. The following fields of the DB_TXN_ACTIVE structure will |
| 214 | be filled in: |
| 215 | </p> |
| 216 | <div class="itemizedlist"> |
| 217 | <ul type="circle"> |
| 218 | <li> |
| 219 | <p> |
| 220 | <span class="bold"><strong>u_int32_t txnid;</strong></span> |
| 221 | </p> |
| 222 | <p> |
| 223 | The transaction ID of the transaction. |
| 224 | </p> |
| 225 | </li> |
| 226 | <li> |
| 227 | <p> |
| 228 | <span class="bold"><strong>u_int32_t parentid;</strong></span> |
| 229 | </p> |
| 230 | <p> |
| 231 | The transaction ID of the parent transaction (or 0, if no parent). |
| 232 | </p> |
| 233 | </li> |
| 234 | <li> |
| 235 | <p> |
| 236 | <span class="bold"><strong>pid_t pid;</strong></span> |
| 237 | </p> |
| 238 | <p> |
| 239 | The process ID of the originator of the transaction. |
| 240 | </p> |
| 241 | </li> |
| 242 | <li> |
| 243 | <p> |
| 244 | <span class="bold"><strong>db_threadid_t tid;</strong></span> |
| 245 | </p> |
| 246 | <p> |
| 247 | The thread of control ID of the originator of the transaction. |
| 248 | </p> |
| 249 | </li> |
| 250 | <li> |
| 251 | <p> |
| 252 | <span class="bold"><strong>DB_LSN lsn;</strong></span> |
| 253 | </p> |
| 254 | <p> |
| 255 | The current log sequence number when the transaction was begun. |
| 256 | </p> |
| 257 | </li> |
| 258 | <li> |
| 259 | <p> |
| 260 | <span class="bold"><strong>DB_LSN read_lsn;</strong></span> |
| 261 | </p> |
| 262 | <p> |
| 263 | The log sequence number of reads for snapshot transactions. |
| 264 | </p> |
| 265 | </li> |
| 266 | <li> |
| 267 | <p> |
| 268 | <span class="bold"><strong>u_int32_t mvcc_ref;</strong></span> |
| 269 | </p> |
| 270 | <p> |
| 271 | The number of buffer copies created by this transaction that remain |
| 272 | in cache. |
| 273 | </p> |
| 274 | </li> |
| 275 | <li> |
| 276 | <p> |
| 277 | <span class="bold"><strong>u_int32_t priority;</strong></span> |
| 278 | </p> |
| 279 | <p> |
| 280 | This transaction's deadlock resolution priority. |
| 281 | </p> |
| 282 | </li> |
| 283 | <li> |
| 284 | <p> |
| 285 | <span class="bold"><strong>u_int32_t status;</strong></span> |
| 286 | </p> |
| 287 | <p> |
| 288 | Provides one of the following constants, |
| 289 | indicating the transaction status: |
| 290 | </p> |
| 291 | <table class="simplelist" border="0" summary="Simple list"> |
| 292 | <tr> |
| 293 | <td>TXN_ABORTED</td> |
| 294 | </tr> |
| 295 | <tr> |
| 296 | <td>TXN_COMMITTED</td> |
| 297 | </tr> |
| 298 | <tr> |
| 299 | <td>TXN_NEED_ABORT</td> |
| 300 | </tr> |
| 301 | <tr> |
| 302 | <td>TXN_PREPARED</td> |
| 303 | </tr> |
| 304 | <tr> |
| 305 | <td>TXN_RUNNING</td> |
| 306 | </tr> |
| 307 | </table> |
| 308 | </li> |
| 309 | <li> |
| 310 | <p> |
| 311 | <span class="bold"><strong>u_int32_t xa_status;</strong></span> |
| 312 | </p> |
| 313 | <p> |
| 314 | Provides one of the following constants, which indicate the |
| 315 | XA status: |
| 316 | </p> |
| 317 | <table class="simplelist" border="0" summary="Simple list"> |
| 318 | <tr> |
| 319 | <td>TXN_XA_ACTIVE</td> |
| 320 | </tr> |
| 321 | <tr> |
| 322 | <td>TXN_XA_DEADLOCKED</td> |
| 323 | </tr> |
| 324 | <tr> |
| 325 | <td>TXN_XA_IDLE</td> |
| 326 | </tr> |
| 327 | <tr> |
| 328 | <td>TXN_XA_PREPARED</td> |
| 329 | </tr> |
| 330 | <tr> |
| 331 | <td>TXN_XA_ROLLEDBACK</td> |
| 332 | </tr> |
| 333 | </table> |
| 334 | </li> |
| 335 | <li> |
| 336 | <p> |
| 337 | <span class="bold"><strong>u_int8_t gid[DB_GID_SIZE];</strong></span> |
| 338 | </p> |
| 339 | <p> |
| 340 | If the transaction was prepared using |
| 341 | <a class="xref" href="txnprepare.html" title="DbTxn::prepare()">DbTxn::prepare()</a>, then |
| 342 | <span class="bold"><strong>gid</strong></span> contains the |
| 343 | transaction's Global ID. Otherwise, |
| 344 | <span class="bold"><strong>gid's</strong></span> contents are undefined. |
| 345 | </p> |
| 346 | </li> |
| 347 | <li> |
| 348 | <p> |
| 349 | <span class="bold"><strong>char name[];</strong></span> |
| 350 | </p> |
| 351 | <p> |
| 352 | If a name was specified for the transaction, up to the first 50 bytes |
| 353 | of that name, followed by a nul termination byte. |
| 354 | </p> |
| 355 | </li> |
| 356 | </ul> |
| 357 | </div> |
| 358 | </li> |
| 359 | </ul> |
| 360 | </div> |
| 361 | <p> |
| 362 | The <code class="methodname">DbEnv::txn_stat()</code> method may not be called before the |
| 363 | <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method is called. |
| 364 | </p> |
| 365 | <p> |
| 366 | The <code class="methodname">DbEnv::txn_stat()</code> <span> |
| 367 | |
| 368 | <span> |
| 369 | method either returns a non-zero error value or throws an |
| 370 | exception that encapsulates a non-zero error value on |
| 371 | failure, and returns 0 on success. |
| 372 | </span> |
| 373 | </span> |
| 374 | </p> |
| 375 | <div class="sect2" lang="en" xml:lang="en"> |
| 376 | <div class="titlepage"> |
| 377 | <div> |
| 378 | <div> |
| 379 | <h3 class="title"><a id="idp10389544"></a>Parameters</h3> |
| 380 | </div> |
| 381 | </div> |
| 382 | </div> |
| 383 | <div class="sect3" lang="en" xml:lang="en"> |
| 384 | <div class="titlepage"> |
| 385 | <div> |
| 386 | <div> |
| 387 | <h4 class="title"><a id="idp10388704"></a>statp</h4> |
| 388 | </div> |
| 389 | </div> |
| 390 | </div> |
| 391 | <p> |
| 392 | The <span class="bold"><strong>statp</strong></span> parameter references memory |
| 393 | into which a pointer to the allocated statistics structure is copied. |
| 394 | </p> |
| 395 | </div> |
| 396 | <div class="sect3" lang="en" xml:lang="en"> |
| 397 | <div class="titlepage"> |
| 398 | <div> |
| 399 | <div> |
| 400 | <h4 class="title"><a id="idp10410832"></a>flags</h4> |
| 401 | </div> |
| 402 | </div> |
| 403 | </div> |
| 404 | <p> |
| 405 | The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 |
| 406 | or the following value: |
| 407 | </p> |
| 408 | <div class="itemizedlist"> |
| 409 | <ul type="disc"> |
| 410 | <li> |
| 411 | <p> |
| 412 | <code class="literal">DB_STAT_CLEAR</code> |
| 413 | </p> |
| 414 | <p> |
| 415 | Reset statistics after returning their values. |
| 416 | </p> |
| 417 | </li> |
| 418 | </ul> |
| 419 | </div> |
| 420 | </div> |
| 421 | </div> |
| 422 | <div class="sect2" lang="en" xml:lang="en"> |
| 423 | <div class="titlepage"> |
| 424 | <div> |
| 425 | <div> |
| 426 | <h3 class="title"><a id="idp10407152"></a>Errors</h3> |
| 427 | </div> |
| 428 | </div> |
| 429 | </div> |
| 430 | <p> |
| 431 | The <code class="methodname">DbEnv::txn_stat()</code> <span> |
| 432 | |
| 433 | <span> |
| 434 | method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> |
| 435 | exception, encapsulating one of the following non-zero errors, or return one |
| 436 | of the following non-zero errors: |
| 437 | </span> |
| 438 | </span> |
| 439 | </p> |
| 440 | <div class="sect3" lang="en" xml:lang="en"> |
| 441 | <div class="titlepage"> |
| 442 | <div> |
| 443 | <div> |
| 444 | <h4 class="title"><a id="idp10420928"></a>EINVAL</h4> |
| 445 | </div> |
| 446 | </div> |
| 447 | </div> |
| 448 | <p> |
| 449 | An invalid flag value or parameter was specified. |
| 450 | </p> |
| 451 | </div> |
| 452 | </div> |
| 453 | <div class="sect2" lang="en" xml:lang="en"> |
| 454 | <div class="titlepage"> |
| 455 | <div> |
| 456 | <div> |
| 457 | <h3 class="title"><a id="idp10419632"></a>Class</h3> |
| 458 | </div> |
| 459 | </div> |
| 460 | </div> |
| 461 | <p> |
| 462 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a>, <a class="link" href="txn.html" title="Chapter 13. The DbTxn Handle">DbTxn</a> |
| 463 | </p> |
| 464 | </div> |
| 465 | <div class="sect2" lang="en" xml:lang="en"> |
| 466 | <div class="titlepage"> |
| 467 | <div> |
| 468 | <div> |
| 469 | <h3 class="title"><a id="idp10303000"></a>See Also</h3> |
| 470 | </div> |
| 471 | </div> |
| 472 | </div> |
| 473 | <p> |
| 474 | <a class="xref" href="txn.html#txnlist" title="Transaction Subsystem and Related Methods">Transaction Subsystem and Related Methods</a> |
| 475 | </p> |
| 476 | </div> |
| 477 | </div> |
| 478 | <div class="navfooter"> |
| 479 | <hr /> |
| 480 | <table width="100%" summary="Navigation footer"> |
| 481 | <tr> |
| 482 | <td width="40%" align="left"><a accesskey="p" href="txncheckpoint.html">Prev</a> </td> |
| 483 | <td width="20%" align="center"> |
| 484 | <a accesskey="u" href="txn.html">Up</a> |
| 485 | </td> |
| 486 | <td width="40%" align="right"> <a accesskey="n" href="txnstat_print.html">Next</a></td> |
| 487 | </tr> |
| 488 | <tr> |
| 489 | <td width="40%" align="left" valign="top">DbEnv::txn_checkpoint() </td> |
| 490 | <td width="20%" align="center"> |
| 491 | <a accesskey="h" href="index.html">Home</a> |
| 492 | </td> |
| 493 | <td width="40%" align="right" valign="top"> DbEnv::txn_stat_print()</td> |
| 494 | </tr> |
| 495 | </table> |
| 496 | </div> |
| 497 | </body> |
| 498 | </html> |