本文整理汇总了C++中ConnectionIPtr::dbTxn方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionIPtr::dbTxn方法的具体用法?C++ ConnectionIPtr::dbTxn怎么用?C++ ConnectionIPtr::dbTxn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionIPtr
的用法示例。
在下文中一共展示了ConnectionIPtr::dbTxn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: out
int
Freeze::MapIndexI::untypedCount(const Key& k, const ConnectionIPtr& connection) const
{
Dbt dbKey;
initializeInDbt(k, dbKey);
#if (DB_VERSION_MAJOR <= 4)
//
// When we have a custom-comparison function, Berkeley DB returns
// the key on-disk (when it finds one). We disable this behavior:
// (ref Oracle SR 5925672.992)
//
dbKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
#else
//
// In DB 5.x we can not set DB_DBT_PARTIAL in the key Dbt,
// when using DB_SET, we must resize the Dbt key param to hold enought
// space or Dbc::get fails with DB_BUFFER_SMALL.
//
dbKey.set_flags(DB_DBT_USERMEM);
dbKey.set_ulen(static_cast<u_int32_t>(k.size()));
#endif
Dbt dbValue;
dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
int result = 0;
DbTxn* txn = connection->dbTxn();
try
{
for(;;)
{
Dbc* dbc = 0;
try
{
//
// Move to the first record
//
_db->cursor(txn, &dbc, 0);
bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
if(found)
{
db_recno_t count = 0;
dbc->count(&count, 0);
result = static_cast<int>(count);
}
Dbc* toClose = dbc;
dbc = 0;
toClose->close();
break; // for (;;)
}
catch(const DbDeadlockException&)
{
if(dbc != 0)
{
try
{
dbc->close();
}
catch(const DbDeadlockException&)
{
if(txn != 0)
{
throw;
}
else
{
//
// Ignored
//
}
}
}
if(connection->deadlockWarning())
{
Warning out(connection->communicator()->getLogger());
out << "Deadlock in Freeze::MapIndexI::untypedCount while searching \""
<< _dbName << "\"";
}
if(txn != 0)
{
throw;
}
//
// Otherwise retry
//
}
catch(...)
{
if(dbc != 0)
{
try
{
dbc->close();
//.........这里部分代码省略.........