Ejemplo n.º 1
0
//---------------------------------------------------------------------------
//	@function:
//		IMDRelation::PstrColumns
//
//	@doc:
//		Serialize an array of column ids into a comma-separated string
//
//---------------------------------------------------------------------------
CWStringDynamic *
IMDRelation::PstrColumns
	(
	IMemoryPool *pmp,
	DrgPul *pdrgpul
	)
{
	CWStringDynamic *pstr = GPOS_NEW(pmp) CWStringDynamic(pmp);

	ULONG ulLen = pdrgpul->UlLength();
	for (ULONG ul = 0; ul < ulLen; ul++)
	{
		ULONG ulId = *((*pdrgpul)[ul]);
		if (ul == ulLen - 1)
		{
			// last element: do not print a comma
			pstr->AppendFormat(GPOS_WSZ_LIT("%d"), ulId);
		}
		else
		{
			pstr->AppendFormat(GPOS_WSZ_LIT("%d%ls"), ulId, CDXLTokens::PstrToken(EdxltokenComma)->Wsz());
		}
	}

	return pstr;
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
//	@function:
//		CMDFunctionGPDB::PstrOutArgTypes
//
//	@doc:
//		Serialize the array of output argument types into a comma-separated string
//
//---------------------------------------------------------------------------
CWStringDynamic *
CMDFunctionGPDB::PstrOutArgTypes() const
{
	GPOS_ASSERT(NULL != m_pdrgpmdidTypes);
	CWStringDynamic *pstr = GPOS_NEW(m_pmp) CWStringDynamic(m_pmp);

	const ULONG ulLen = m_pdrgpmdidTypes->UlLength();
	for (ULONG ul = 0; ul < ulLen; ul++)
	{
		IMDId *pmdid = (*m_pdrgpmdidTypes)[ul];
		if (ul == ulLen - 1)
		{
			// last element: do not print a comma
			pstr->AppendFormat(GPOS_WSZ_LIT("%ls"), pmdid->Wsz());
		}
		else
		{
			pstr->AppendFormat(GPOS_WSZ_LIT("%ls%ls"), pmdid->Wsz(), CDXLTokens::PstrToken(EdxltokenComma)->Wsz());
		}
	}

	return pstr;
}
Ejemplo n.º 3
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalMotion::PstrSegIds
//
//	@doc:
//		Serialize the array of segment ids into a comma-separated string		
//
//---------------------------------------------------------------------------
CWStringDynamic *
CDXLPhysicalMotion::PstrSegIds(const DrgPi *pdrgpi) const
{
	GPOS_ASSERT(pdrgpi != NULL && 0 < pdrgpi->UlLength());
	
	CWStringDynamic *pstr = GPOS_NEW(m_pmp) CWStringDynamic(m_pmp);
	
	ULONG ulNumSegments = pdrgpi->UlLength();
	for (ULONG ul = 0; ul < ulNumSegments; ul++)
	{
		INT iSegId = *((*pdrgpi)[ul]);
		if (ul == ulNumSegments - 1)
		{
			// last element: do not print a comma
			pstr->AppendFormat(GPOS_WSZ_LIT("%d"), iSegId);
		}
		else
		{
			pstr->AppendFormat(GPOS_WSZ_LIT("%d%ls"), iSegId, CDXLTokens::PstrToken(EdxltokenComma)->Wsz());
		}
	}
	
	return pstr;
}
Ejemplo n.º 4
0
//---------------------------------------------------------------------------
//	@function:
//		CColumnFactory::PcrCreate
//
//	@doc:
//		Variant without name for computed columns
//
//---------------------------------------------------------------------------
CColRef *
CColumnFactory::PcrCreate
	(
	const IMDType *pmdtype
	)
{
	// increment atomic counter
	ULONG ulId = m_aul.TIncr();
	
	WCHAR wszFmt[] = GPOS_WSZ_LIT("ColRef_%04d");
	CWStringDynamic *pstrTempName = GPOS_NEW(m_pmp) CWStringDynamic(m_pmp);
	CAutoP<CWStringDynamic> a_pstrTempName(pstrTempName);
	pstrTempName->AppendFormat(wszFmt, ulId);
	CWStringConst strName(pstrTempName->Wsz());
	return PcrCreate(pmdtype, ulId, CName(&strName));
}
Ejemplo n.º 5
0
//---------------------------------------------------------------------------
//	@function:
//		CColumnFactory::PcrCreate
//
//	@doc:
//		Variant without name for computed columns
//
//---------------------------------------------------------------------------
CColRef *
CColumnFactory::PcrCreate
	(
	const IMDType *pmdtype,
	INT type_modifier
	)
{
	// increment atomic counter
	ULONG id = m_aul.Incr();
	
	WCHAR wszFmt[] = GPOS_WSZ_LIT("ColRef_%04d");
	CWStringDynamic *pstrTempName = GPOS_NEW(m_mp) CWStringDynamic(m_mp);
	CAutoP<CWStringDynamic> a_pstrTempName(pstrTempName);
	pstrTempName->AppendFormat(wszFmt, id);
	CWStringConst strName(pstrTempName->GetBuffer());
	return PcrCreate(pmdtype, type_modifier, id, CName(&strName));
}