void CRUUnAuditRefreshTaskExecutor::Refresh()
{
	try 
	{
		// ?????
		// Temporary - Should be removed when read commited from unaudited table is implemented
		BeginTransaction(); 

		ApplyIRCompilerDefaults();

		if(TRUE == IsSingleDeltaRefresh())
		{
			CDMPreparedStatement *pStat = PrepareSingleDeltaRefresh();

			// ?????
			// Temporary - Should be removed when read commited from unaudited table is implemented
			CommitTransaction();
			BeginTransaction();

			ExecuteSingleDeltaRefresh(pStat);
		}
		else
		{
			StmtList *stmts = PrepareMultiDeltasRefresh();

			// ?????
			// Temporary - Should be removed when read commited from unaudited table is implemented
			CommitTransaction();
			BeginTransaction();

			ExecuteMultiDeltasRefresh(stmts);
		}

		ResetIRCompilerDefaults();

		ExecuteShowExplain();

		// ?????
		// Temporary - Should be removed when read commited from unaudited table is implemented
		CommitTransaction();

		TESTPOINT2(CRUGlobals::TESTPOINT106, GetRootMVName());
		
		SetState(EX_EPILOGUE);
	}
	catch (CRUSimpleRefreshTaskExecutor::NeedRecomputeException)
	{
		SetState(EX_RECOMPUTE);
		SetRecompute(TRUE);
	}
}
void CRUAuditRefreshTaskExecutor::Refresh()
{
	RUASSERT(TRUE == IsTransactionOpen());

	// Simulate a system error at this point!
	TESTPOINT_SEVERE(CRUGlobals::SEVERE_REFRESH_CRASH);

	try 
	{		
		ApplyIRCompilerDefaults();

		if(TRUE == IsSingleDeltaRefresh())
		{
			CDMPreparedStatement *pStat = PrepareSingleDeltaRefresh();

			CommitTransaction();
			BeginTransaction();

			ExecuteSingleDeltaRefresh(pStat);
		}
		else
		{
			StmtList *stmts = PrepareMultiDeltasRefresh();

			CommitTransaction();
			BeginTransaction();

			ExecuteMultiDeltasRefresh(stmts);
		}

		ResetIRCompilerDefaults();

		ExecuteShowExplain();

		SetState(EX_REMOTE_END);
	}
	catch (CRUSimpleRefreshTaskExecutor::NeedRecomputeException)
	{
		// If a min/max value was deleted an exception will be thrown and
		// then we need to recompute the mv
		SetState(EX_RECOMPUTE);
		SetRecompute(TRUE);
	}
}
void CRURefreshTaskExecutor::Init()
{
	inherited::Init(); 

	CRUMV &rootMV = GetRefreshTask()->GetRootMV();

	SetRecompute(rootMV.WillBeRecomputed());

	rootMVName_   = rootMV.GetFullName();
	rootMVSchema_ = rootMV.GetCatName() + "." + rootMV.GetSchName();
	rootMVCatalog_ = rootMV.GetCatName();

	rootMVType_   = rootMV.GetRefreshType();
	rootMVUID_	  = rootMV.GetUID();

	// Runtime consistency check.
	// Check requirement that the regular table's deltas 
	// are empty (if they must be).
	CheckSingleDeltaRestriction();

	ComposeMySql();
}