//--------------------------------------------------------------------------- // @function: // CICGTest::EresUnittest_NegativeIndexApplyTests // // @doc: // Negative IndexApply tests; // optimizer should not be able to generate a plan // //--------------------------------------------------------------------------- GPOS_RESULT CICGTest::EresUnittest_NegativeIndexApplyTests() { // enable (Redistribute, Broadcast) hash join plans CAutoTraceFlag atf(EopttraceEnableRedistributeBroadcastHashJoin, true /*fVal*/); // disable physical scans and NLJ to force using index-apply CAutoTraceFlag atfDTS(EopttraceDisableXformBase + CXform::ExfDynamicGet2DynamicTableScan, true); CAutoTraceFlag atfTS(EopttraceDisableXformBase + CXform::ExfGet2TableScan, true); CAutoTraceFlag atfNLJ(EopttraceDisableXformBase + CXform::ExfInnerJoin2NLJoin, true); CAutoMemoryPool amp(CAutoMemoryPool::ElcNone); IMemoryPool *pmp = amp.Pmp(); GPOS_RESULT eres = GPOS_OK; const ULONG ulTests = GPOS_ARRAY_SIZE(rgszNegativeIndexApplyFileNames); for (ULONG ul = m_ulNegativeIndexApplyTestCounter; ul < ulTests; ul++) { GPOS_TRY { ICostModel *pcm = CTestUtils::Pcm(pmp); COptimizerConfig *poconf = GPOS_NEW(pmp) COptimizerConfig ( CEnumeratorConfig::Pec(pmp, 0 /*ullPlanId*/), CStatisticsConfig::PstatsconfDefault(pmp), CCTEConfig::PcteconfDefault(pmp), pcm, CHint::PhintDefault(pmp) ); CDXLNode *pdxlnPlan = CMinidumperUtils::PdxlnExecuteMinidump ( pmp, rgszNegativeIndexApplyFileNames[ul], GPOPT_TEST_SEGMENTS /*ulSegments*/, 1 /*ulSessionId*/, 1, /*ulCmdId*/ poconf, NULL /*pceeval*/ ); GPOS_CHECK_ABORT; poconf->Release(); pdxlnPlan->Release(); pcm->Release(); // test should have thrown eres = GPOS_FAILED; break; } GPOS_CATCH_EX(ex) { if (GPOS_MATCH_EX(ex, gpopt::ExmaGPOPT, gpopt::ExmiNoPlanFound)) { GPOS_RESET_EX; } else { GPOS_RETHROW(ex); } } GPOS_CATCH_END; m_ulNegativeIndexApplyTestCounter++; } if (GPOS_OK == eres) { m_ulNegativeIndexApplyTestCounter = 0; } return eres; }
//--------------------------------------------------------------------------- // @function: // CICGTest::EresUnittest_RunUnsupportedMinidumpTests // // @doc: // Run all unsupported Minidump-based tests // //--------------------------------------------------------------------------- GPOS_RESULT CICGTest::EresUnittest_RunUnsupportedMinidumpTests() { // enable (Redistribute, Broadcast) hash join plans CAutoTraceFlag atf1(EopttraceEnableRedistributeBroadcastHashJoin, true /*fVal*/); CAutoTraceFlag atf2(EopttraceDisableXformBase + CXform::ExfDynamicGet2DynamicTableScan, true); CAutoMemoryPool amp(CAutoMemoryPool::ElcNone); IMemoryPool *pmp = amp.Pmp(); GPOS_RESULT eres = GPOS_OK; const ULONG ulTests = GPOS_ARRAY_SIZE(unSupportedTestCases); for (ULONG ul = m_ulUnsupportedTestCounter; ul < ulTests; ul++) { const CHAR *szFilename = unSupportedTestCases[ul].szFilename; CDXLMinidump *pdxlmd = CMinidumperUtils::PdxlmdLoad(pmp, szFilename); bool unmatchedException = false; ULONG unmatchedExceptionMajor = 0; ULONG unmatchedExceptionMinor = 0; GPOS_TRY { ICostModel *pcm = CTestUtils::Pcm(pmp); COptimizerConfig *poconf = pdxlmd->Poconf(); CDXLNode *pdxlnPlan = CMinidumperUtils::PdxlnExecuteMinidump ( pmp, szFilename, poconf->Pcm()->UlHosts() /*ulSegments*/, 1 /*ulSessionId*/, 1, /*ulCmdId*/ poconf, NULL /*pceeval*/ ); GPOS_CHECK_ABORT; pdxlnPlan->Release(); pcm->Release(); // test should have thrown eres = GPOS_FAILED; break; } GPOS_CATCH_EX(ex) { unmatchedExceptionMajor = ex.UlMajor(); unmatchedExceptionMinor = ex.UlMinor(); // verify expected exception if (unSupportedTestCases[ul].ulMajor == unmatchedExceptionMajor && unSupportedTestCases[ul].ulMinor == unmatchedExceptionMinor) { eres = GPOS_OK; } else { unmatchedException = true; eres = GPOS_FAILED; } GPOS_RESET_EX; } GPOS_CATCH_END; GPOS_DELETE(pdxlmd); m_ulUnsupportedTestCounter++; if (GPOS_FAILED == eres && unmatchedException) { CAutoTrace at(pmp); at.Os() << "Test failed due to unmatched exceptions." << std::endl; at.Os() << " Expected result: " << unSupportedTestCases[ul].ulMajor << "." << unSupportedTestCases[ul].ulMinor << std::endl; at.Os() << " Actual result: " << unmatchedExceptionMajor << "." << unmatchedExceptionMinor << std::endl; } } if (GPOS_OK == eres) { m_ulUnsupportedTestCounter = 0; } return eres; }