Exemplo n.º 1
0
//---------------------------------------------------------------------------
//	@function:
//		CErrorHandlerStandard::Process
//
//	@doc:
//		Process pending error context;
//
//---------------------------------------------------------------------------
void
CErrorHandlerStandard::Process
	(
	CException exc
	)
{
	CTask *ptsk = CTask::PtskSelf();

	GPOS_ASSERT(NULL != ptsk && "No task in current context");

	IErrorContext *perrctxt = ptsk->Perrctxt();
	CLogger *plog = dynamic_cast<CLogger*>(ptsk->PlogErr());
	
	GPOS_ASSERT(perrctxt->FPending() && "No error to process");
	GPOS_ASSERT(perrctxt->Exc() == exc && 
			"Exception processed different from pending");

	// print error stack trace
	if (CException::ExmaSystem == exc.UlMajor() && !perrctxt->FRethrow())
	{
		if ((CException::ExmiIOError == exc.UlMinor() ||
		    CException::ExmiNetError == exc.UlMinor() ) &&
			0 < errno)
		{
			perrctxt->AppendErrnoMsg();
		}

		if (ILogger::EeilMsgHeaderStack <= plog->Eil())
		{
			perrctxt->AppendStackTrace();
		}
	}

	// scope for suspending cancellation
	{
		// suspend cancellation
		CAutoSuspendAbort asa;

		// log error message
		plog->Log(perrctxt->WszMsg(), perrctxt->UlSev(), __FILE__, __LINE__);
	}
}
Exemplo n.º 2
0
//---------------------------------------------------------------------------
//	@function:
//		CTreeMapTest::EresUnittest_Memo
//
//	@doc:
//		Test loading map from actual memo
//
//---------------------------------------------------------------------------
GPOS_RESULT
CTreeMapTest::EresUnittest_Memo()
{
	GPOS_SET_TRACE(EtraceDisablePrintMemoryLeak);

	CAutoMemoryPool amp;
	IMemoryPool *pmp = amp.Pmp();

	// setup a file-based provider
	CMDProviderMemory *pmdp = CTestUtils::m_pmdpf;
	pmdp->AddRef();
	CMDAccessor mda(pmp, CMDCache::Pcache(), CTestUtils::m_sysidDefault, pmdp);

	CEngine *peng = NULL;
	CExpression *pexpr = NULL;
	CQueryContext *pqc = NULL;
	CExpression *pexprPlan = NULL;
	{
		// install opt context in TLS
		CAutoOptCtxt aoc
				(
				pmp,
				&mda,
				NULL,  /* pceeval */
				CTestUtils::Pcm(pmp)
				);

		CAutoTraceFlag atf(EopttraceEnumeratePlans, true);

		peng = GPOS_NEW(pmp) CEngine(pmp);

		// generate join expression
		pexpr = CTestUtils::PexprLogicalJoin<CLogicalInnerJoin>(pmp);

		// generate query context
		pqc = CTestUtils::PqcGenerate(pmp, pexpr);

		// Initialize engine
		peng->Init(pqc, NULL /*pdrgpss*/);

		// optimize query
		peng->Optimize();

		// extract plan
		pexprPlan = peng->PexprExtractPlan();
		GPOS_ASSERT(NULL != pexprPlan);

		peng->Trace();
		{
			CAutoTrace at(pmp);
			ULLONG ullCount = peng->Pmemotmap()->UllCount();
#ifdef GPOS_DEBUG
			// test resetting map and re-creating it
			peng->ResetTreeMap();
			ULLONG ullCount2 = peng->Pmemotmap()->UllCount();
			GPOS_ASSERT(ullCount == ullCount2);
#endif // GPOS_DEBUG

			for (ULONG ulRank = 0; ulRank < ullCount; ulRank++)
			{
				CDrvdPropCtxtPlan *pdpctxtplan = GPOS_NEW(pmp) CDrvdPropCtxtPlan(pmp, false /*fUpdateCTEMap*/);
				CExpression *pexprAlt = NULL;
				GPOS_TRY
				{
					pexprAlt = peng->Pmemotmap()->PrUnrank(pmp, pdpctxtplan, ulRank);
					at.Os() << std::endl << "ALTERNATIVE ["<< ulRank <<"]:" << std::endl << *pexprAlt << std::endl;
				}
				GPOS_CATCH_EX(ex)
				{
					if (!GPOS_MATCH_EX(ex, gpopt::ExmaGPOPT, gpopt::ExmiUnsatisfiedRequiredProperties))
					{
						GPOS_RETHROW(ex);
					}
					IErrorContext *perrctxt = CTask::PtskSelf()->Perrctxt();
					at.Os() << perrctxt->WszMsg() << std::endl;
					GPOS_RESET_EX;
				}
				GPOS_CATCH_END;
				CRefCount::SafeRelease(pexprAlt);
				CRefCount::SafeRelease(pdpctxtplan);
			}
		}
	}

	// clean up
	CRefCount::SafeRelease(pexprPlan);
	GPOS_DELETE(pqc);
	CRefCount::SafeRelease(pexpr);
	GPOS_DELETE(peng);

	return GPOS_OK;
}