void CRUEmpCheck::
PerformSingleCheck(CRUEmpCheckVector::Elem &elem, 
				   CRUTbl::IUDLogContentType ct,
				   StmtType stmtType)
{
	if (0 == (ct & checkMask_))
	{
		// We are not interested in this check
		return;
	}

	if (0 != (ct & elem.checkBitmap_))
	{
		// The check of the larger epoch has produced a positive result
		return;
	}

	CDMPreparedStatement *pStmt = 
		pSQLContainer_->GetPreparedStatement(stmtType);

	RUASSERT(NULL != pStmt);
	
	TInt32 ep = elem.epoch_;
	if (CRUTbl::RANGE == ct)
	{
		ep = -ep;	// Range records reside in negative epochs
	}

	pStmt->SetInt(1, ep);

	//	Execute the "SELECT [FIRST 1] ... " query.
	//	If a row is fetched, the specific delta is non-empty.
	pStmt->ExecuteQuery();

	CDMResultSet *pResultSet = pStmt->GetResultSet();
	BOOL isNonEmpty = pResultSet->Next();

	// The statement must be closed before the next invocation
	pStmt->Close();

	if (TRUE == isNonEmpty)
	{
		pVec_->SetDeltaNonEmpty(elem.epoch_, ct);
	}
}
void CRUIUDLogRecord::
ReadCKColumns(CDMResultSet &rs, Int32 startCKColumn)
{
	// Performance optimization - switch the IsNull check off!
	rs.PresetNotNullable(TRUE);

	Lng32 len = GetCKLength();

	for (Int32 i=0; i<len; i++)
	{
		Int32 colIndex = i + startCKColumn;

#pragma nowarn(1506)   // warning elimination 
		ckTuple_.GetItem(i).Build(rs, colIndex);
#pragma warn(1506)  // warning elimination 
	}

	rs.PresetNotNullable(FALSE);
}
TInt64 CRULogCleanupTaskExecutor::getRowCount()
{
  CDMPreparedStatement *pStat = 
    logCleanupTEDynamicContainer_.GetPreparedStatement(CLEAN_ROWCOUNT);

  ExecuteStatement(*pStat,
		    IDS_RU_LOG_CLEANUP_FAILED,
		    NULL, /* error argument */
		    TRUE, /* Obtain row count */
                    TRUE  /* isQuery */);

  CDMResultSet *resultSet = pStat->GetResultSet();
  resultSet->Next();
  TInt64 rowCount = resultSet->GetLargeInt(1);

  pStat->Close();

  return rowCount;
}
void CRUIUDLogRecord::ReadControlColumns(CDMResultSet &rs, Int32 startCKColumn)
{
	// Performance optimization - switch the IsNull check off!
	rs.PresetNotNullable(TRUE);

	// Read the mandatory columns
	epoch_  = rs.GetInt(CRUDupElimConst::OFS_EPOCH+1);

	opType_  = rs.GetInt(CRUDupElimConst::OFS_OPTYPE+1);
	if (FALSE == IsSingleRowOp())
	{
		// The range records are logged in the negative epochs.
		// Logically, however, they belong to the positive epochs.
		epoch_ = -epoch_;	
	}

	if (FALSE == IsSingleRowOp() && FALSE == IsBeginRange())
	{
		// End-range record
		rangeSize_ = rs.GetInt(CRUDupElimConst::OFS_RNGSIZE+1);
	}
	else
	{
		rangeSize_ = 0;
	}

	Int32 numCKCols = startCKColumn-2;	// Count from 1 + syskey
	if (CRUDupElimConst::NUM_IUD_LOG_CONTROL_COLS_EXTEND == numCKCols)
	{
		// This is DE level 3, read the optional columns
		ignore_ = rs.GetInt(CRUDupElimConst::OFS_IGNORE+1);

		// The update bitmap buffer must be setup
		RUASSERT(NULL != pUpdateBitmap_);
		// The update bitmap can be a null
		rs.PresetNotNullable(FALSE); 

		rs.GetString(CRUDupElimConst::OFS_UPD_BMP+1, 
					pUpdateBitmap_->GetBuffer(), 
					pUpdateBitmap_->GetSize());
	}

	// Syskey is always the last column before the CK
	syskey_ = rs.GetLargeInt(startCKColumn-1);
}