void CRURefreshTaskExecutor::ComposeControlTableStmtForUsedTable(CRUTbl &tbl,
																 Int32 &stmtIndex,
																 CRUForceOptions::MdamOptions mdamOpt)
{
   	CRURefreshSQLComposer myComposer(GetRefreshTask());
	

	if (CRUForceOptions::MDAM_NO_FORCE == mdamOpt)
	{
		CRUTableForceOptions *forceOpt = GetForceOptionForTable(tbl.GetFullName());
		
		if (NULL == forceOpt)
		{
			mdamOpt = GetDefaultMdamOptForTable(tbl);
		}
		else
		{
			mdamOpt = forceOpt->GetMdamOptions();
		}
	}

	if (CRUForceOptions::MDAM_NO_FORCE != mdamOpt)
	{
		// Compose CONTROL TABLE table_name MDAM option
		myComposer.ComposeCntrlTableMDAMText(mdamOpt, &(tbl.GetFullName()));
		pRefreshTEDynamicContainer_->SetStatementText
#pragma nowarn(1506)   // warning elimination 
			(stmtIndex++, myComposer.GetSQL());
#pragma warn(1506)  // warning elimination 
		
		forceFlags_ |= FORCE_TABLE_MDAM;
	}

}
void CRUUnAuditRefreshTaskExecutor::ComposeMySql()
{
	CRURefreshTask *pTask = GetRefreshTask();
	CRUMV &mv = pTask->GetRootMV();

	CRUSimpleRefreshSQLComposer myComposer(pTask);

	// UNLOCK TABLE statement
	myComposer.ComposeUnLock(GetRootMVName());
	
	unAuditRefreshTEDynamicContainer_.SetStatementText
				(RU_UNLOCK_TABLE, myComposer.GetSQL());

	// POPINDEX CatApi request
	if (TRUE == isPopindex_)
	{
		numOfIndexes_ = mv.GetIndexList().GetCount();
		
		if (0 < numOfIndexes_)
		{
			ComposeIndexesSql();
		}
	}

	// Compose the LOCK TABLE sql statements for locking all tables 
	// in the on statement MV initialization 
	if (CDDObject::eON_STATEMENT == GetRootMVType())
	{	
		CRUTblList &tblList = mv.GetTablesUsedByMe();
		
		DSListPosition pos = tblList.GetHeadPosition();
		
		pLockTablesTEDynamicContainer_ = 
			new CRUSQLDynamicStatementContainer((short)tblList.GetCount());
		
		Int32 i=0;
		
		while (NULL != pos)
		{
			CRUTbl *pTbl = tblList.GetNext(pos);
			myComposer.ComposeLock(pTbl->GetFullName(), FALSE /*shared*/);
			pLockTablesTEDynamicContainer_->SetStatementText
#pragma nowarn(1506)   // warning elimination 
				(i,myComposer.GetSQL());
#pragma warn(1506)  // warning elimination 
			i++;
		}
	}
}
void CRUAuditRefreshTaskExecutor::ComposeMySql()
{
	CRUSimpleRefreshSQLComposer myComposer(GetRefreshTask());
	CRUMV &rootMV = GetRootMV();        	

	if (TRUE == isDeleteMultiTxnContext_)
	{
		myComposer.ComposeDeleteContextLogTable();

		auditRefreshTEDynamicContainer_.SetStatementText
			(DELETE_MULT_TXN_CTX_TBL,myComposer.GetSQL());
	}

        // POPINDEX CatApi request
	if (TRUE == isPopindex_)
	{
		numOfIndexes_ = rootMV.GetIndexList().GetCount();
		              
		if (0 < numOfIndexes_)
		{
			ComposeIndexesSql();
		}
	}

	// Compose the LOCK TABLE sql statements for locking all tables 
	// in the on statement MV initialization 
	if (CDDObject::eON_STATEMENT == GetRootMVType())
	{	
		CRUTblList &tblList = rootMV.GetTablesUsedByMe();
		
		DSListPosition pos = tblList.GetHeadPosition();
		
		pLockTablesTEDynamicContainer_ = 
			new CRUSQLDynamicStatementContainer((short)tblList.GetCount());
		
		Int32 i=0;
		
		while (NULL != pos)
		{
			CRUTbl *pTbl = tblList.GetNext(pos);
			myComposer.ComposeLock(pTbl->GetFullName(), FALSE /*shared*/);
			pLockTablesTEDynamicContainer_->SetStatementText
				(i,myComposer.GetSQL());
			i++;
		}
	}
}
CDSString CRULockEquivSetTask::GetTaskName() const
{
	CDSString name("LOCK SET(");

	DSListPosition pos = tblList_.GetHeadPosition();
	while (NULL != pos)
	{
		CRUTbl *pTbl = tblList_.GetNext(pos);
		name += pTbl->GetFullName(); 
		if (NULL != pos) 
		{
			name += ",";
		}
	}
	name += ")";
	return name;
}
void CRUTblEquivSetBuilder::DumpSets()
{
	CDSString msg;

	msg = "\n Equivalent sets: \n" ;

	CRUGlobals::GetInstance()->GetJournal().LogMessage(msg);
	for (Int32 i=0;i<GetNumOfSets();i++)
	{
		msg = "\n Table Set: \n" ;
		
		CRUGlobals::GetInstance()->GetJournal().LogMessage(msg);

		DSListPosition tblPos = GetSet(i).GetHeadPosition();

		while (NULL != tblPos)
		{
			CRUTbl *pTbl = GetSet(i).GetNext(tblPos);
			
			CRUGlobals::GetInstance()->GetJournal().
				                          LogMessage(pTbl->GetFullName());
		}
	}
}