blob: 50ffb3c2aaa097514bf51bb8dcca4d9e14929619 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//---------------------------------------------------------------------------
// @filename:
// CMDProviderRelcache.cpp
//
// @doc:
// Implementation of a relcache-based metadata provider, which uses GPDB's
// relcache to lookup objects given their ids.
//
// @test:
//
//
//---------------------------------------------------------------------------
#include "postgres.h"
#include "gpopt/relcache/CMDProviderRelcache.h"
#include "gpopt/translate/CTranslatorRelcacheToDXL.h"
#include "gpopt/mdcache/CMDAccessor.h"
#include "gpos/io/COstreamString.h"
#include "naucrates/dxl/CDXLUtils.h"
#include "naucrates/exception.h"
using namespace gpos;
using namespace gpdxl;
using namespace gpmd;
//---------------------------------------------------------------------------
// @function:
// CMDProviderRelcache::CMDProviderRelcache
//
// @doc:
// Constructs a file-based metadata provider
//
//---------------------------------------------------------------------------
CMDProviderRelcache::CMDProviderRelcache
(
IMemoryPool *pmp
)
:
m_pmp(pmp)
{
GPOS_ASSERT(NULL != m_pmp);
}
//---------------------------------------------------------------------------
// @function:
// CMDProviderRelcache::PstrObject
//
// @doc:
// Returns the DXL of the requested object in the provided memory pool
//
//---------------------------------------------------------------------------
CWStringBase *
CMDProviderRelcache::PstrObject
(
IMemoryPool *pmp,
CMDAccessor *pmda,
IMDId *pmdid
)
const
{
IMDCacheObject *pimdobj = CTranslatorRelcacheToDXL::Pimdobj(pmp, pmda, pmdid);
GPOS_ASSERT(NULL != pimdobj);
CWStringDynamic *pstr = CDXLUtils::PstrSerializeMDObj(m_pmp, pimdobj, true /*fSerializeHeaders*/, false /*findent*/);
// cleanup DXL object
pimdobj->Release();
return pstr;
}
// EOF