hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ent...@apache.org
Subject [4/4] incubator-hawq git commit: HAWQ-246. Refactor and cleanup of memory management of the new optimizer.
Date Fri, 11 Dec 2015 01:39:51 GMT
HAWQ-246. Refactor and cleanup of memory management of the new optimizer.

This commit eliminates the global new/delete overrides that were causing
compatibility problems (the Allocators.(h/cpp/inl) files have been
completely removed). The GPOS `New()` macro is retained and works the
same way, but has been renamed `GPOS_NEW()` to avoid confusion and
possible name collisions. `GPOS_NEW()` works only for allocating
singleton objects. For allocating arrays, `GPOS_NEW_ARRAY()` is
provided. Because we no longer override the global delete,
objects/arrays allocated by `GPOS_NEW()` and `GPOS_NEW_ARRAY()` must now
be deleted by the new functions `GPOS_DELETE()` and
`GPOS_DELETE_ARRAY()` respectively. All code in GPOS has been
retrofitted for these changes, but Orca and other code that depends on
GPOS should also be changed.

Note that `GPOS_NEW()` and `GPOS_NEW_ARRAY()` should both be
exception-safe and not leak memory when a constructor throws.

Closes #181


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/9b65a5ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/9b65a5ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/9b65a5ad

Branch: refs/heads/master
Commit: 9b65a5adcdda343ad9c6c0c087e44b6c02c424c0
Parents: 4b60c6c
Author: Entong Shen <eshen@pivotal.io>
Authored: Wed Dec 9 22:02:52 2015 -0800
Committer: Entong Shen <shenentong@gmail.com>
Committed: Thu Dec 10 17:39:15 2015 -0800

----------------------------------------------------------------------
 src/backend/gpopt/Allocators.cpp                | 299 ------------
 src/backend/gpopt/CGPOptimizer.cpp              |   1 -
 src/backend/gpopt/Makefile                      |   4 +-
 .../gpopt/config/CConfigParamMapping.cpp        |   2 +-
 src/backend/gpopt/gpdbwrappers.cpp              |   8 +-
 src/backend/gpopt/translate/CCTEListEntry.cpp   |  10 +-
 .../gpopt/translate/CContextDXLToPlStmt.cpp     |  14 +-
 .../gpopt/translate/CDXLTranslateContext.cpp    |  16 +-
 .../translate/CDXLTranslateContextBaseTable.cpp |   6 +-
 .../gpopt/translate/CMappingColIdVarQuery.cpp   |   4 +-
 .../gpopt/translate/CMappingParamIdScalarId.cpp |   4 +-
 .../gpopt/translate/CMappingVarColId.cpp        |  36 +-
 .../gpopt/translate/CStateDXLToQuery.cpp        |   4 +-
 .../gpopt/translate/CTranslatorDXLToPlStmt.cpp  |  72 +--
 .../gpopt/translate/CTranslatorDXLToQuery.cpp   |  26 +-
 .../gpopt/translate/CTranslatorDXLToScalar.cpp  |  26 +-
 .../gpopt/translate/CTranslatorPlStmtToDXL.cpp  | 214 ++++-----
 .../gpopt/translate/CTranslatorQueryToDXL.cpp   | 451 ++++++++++---------
 .../translate/CTranslatorRelcacheToDXL.cpp      | 220 ++++-----
 .../gpopt/translate/CTranslatorScalarToDXL.cpp  | 192 ++++----
 .../gpopt/translate/CTranslatorUtils.cpp        | 156 +++----
 src/backend/gpopt/unexported_symbols_list.txt   |  11 -
 .../gpopt/utils/CConstExprEvaluatorProxy.cpp    |   2 +-
 src/backend/gpopt/utils/COptTasks.cpp           |  86 ++--
 src/include/gpopt/Allocators.h                  | 145 ------
 src/include/gpopt/Allocators.inl                | 287 ------------
 src/include/gpopt/gpdbwrappers.h                |   8 +-
 src/include/gpopt/translate/COptColInfo.h       |   2 +-
 28 files changed, 791 insertions(+), 1515 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/Allocators.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/Allocators.cpp b/src/backend/gpopt/Allocators.cpp
deleted file mode 100644
index de762ae..0000000
--- a/src/backend/gpopt/Allocators.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * 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:
-//		Allocators.h
-//
-//	@doc:
-//		Memory allocation/deallocation operators
-//
-//	@test:
-//
-//---------------------------------------------------------------------------
-
-#include "gpopt/Allocators.h"
-#include "gpos/memory/CMemoryPoolManager.h"
-
-using namespace gpos;
-
-//---------------------------------------------------------------------------
-//	@function:
-//		new
-//
-//	@doc:
-//		Overloaded throwing global singleton new operator
-//
-//---------------------------------------------------------------------------
-void* operator new
-	(
-	SIZE_T cSize
-	)
-	throw(BAD_ALLOC)
-{
-	return NewImpl
-				(
-				CMemoryPoolManager::Pmpm()->PmpGlobal(),
-				cSize,
-				NULL, // szFileName
-				0, // ulLine
-				IMemoryPool::EatSingleton
-				);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		new[]
-//
-//	@doc:
-//		Overloaded throwing global array new operator
-//
-//---------------------------------------------------------------------------
-void* operator new []
-	(
-	SIZE_T cSize
-	)
-	throw(BAD_ALLOC)
-{
-	return NewImpl
-				(
-				CMemoryPoolManager::Pmpm()->PmpGlobal(),
-				cSize,
-				NULL, // szFileName
-				0, // ulLine
-				IMemoryPool::EatArray
-				);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		new
-//
-//	@doc:
-//		Overloaded non-throwing global singleton new operator
-//
-//---------------------------------------------------------------------------
-void *operator new
-	(
-	SIZE_T  cSize,
-	const NO_THROW &
-	)
-	throw()
-{
-	return NewImplNoThrow
-				(
-				CMemoryPoolManager::Pmpm()->PmpGlobal(),
-				cSize,
-				NULL, // szFileName
-				0, // ulLine
-				IMemoryPool::EatSingleton
-				);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		new
-//
-//	@doc:
-//		Overloaded non-throwing global array new operator
-//
-//---------------------------------------------------------------------------
-void* operator new []
-	(
-	SIZE_T cSize,
-	const NO_THROW &
-	)
-	throw()
-{
-	return NewImplNoThrow
-				(
-				CMemoryPoolManager::Pmpm()->PmpGlobal(),
-				cSize,
-				NULL, // szFileName
-				0, // ulLine
-				IMemoryPool::EatArray
-				);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		new
-//
-//	@doc:
-//		overloaded placement new operator
-//
-//---------------------------------------------------------------------------
-void *
-operator new
-	(
-	SIZE_T cSize,
-	IMemoryPool *pmp,
-	const CHAR *szFilename,
-	ULONG ulLine
-	)
-{
-	return NewImpl(pmp, cSize, szFilename, ulLine, IMemoryPool::EatSingleton);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		new[]
-//
-//	@doc:
-//		Overload for array allocation; raises OOM exception if
-//		unable to allocate
-//
-//---------------------------------------------------------------------------
-void *
-operator new []
-	(
-	SIZE_T cSize,
-	IMemoryPool *pmp,
-	const CHAR *szFilename,
-	ULONG ulLine
-	)
-{
-	return NewImpl(pmp, cSize, szFilename, ulLine, IMemoryPool::EatArray);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		delete
-//
-//	@doc:
-//		Overload for singleton deletion
-//
-//---------------------------------------------------------------------------
-void
-operator delete
-	(
-	void *pv
-	)
-	throw()
-{
-	DeleteImpl(pv, IMemoryPool::EatSingleton);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		delete
-//
-//	@doc:
-//		Placement delete; only used if constructor throws
-//
-//---------------------------------------------------------------------------
-void
-operator delete
-	(
-	void *pv,
-	IMemoryPool *, // pmp,
-	const CHAR *, // szFilename,
-	ULONG // ulLine
-	)
-{
-	DeleteImpl(pv, IMemoryPool::EatSingleton);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		delete []
-//
-//	@doc:
-//		Overload for array deletion
-//
-//---------------------------------------------------------------------------
-void
-operator delete []
-	(
-	void *pv
-	)
-	throw()
-{
-	DeleteImpl(pv, IMemoryPool::EatArray);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		delete []
-//
-//	@doc:
-//		Placement delete []; only used if constructor throws
-//
-//---------------------------------------------------------------------------
-void
-operator delete []
-	(
-	void *pv,
-	IMemoryPool *, // pmp,
-	const CHAR *, // szFilename,
-	ULONG // ulLine
-	)
-{
-	DeleteImpl(pv, IMemoryPool::EatArray);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		delete
-//
-//	@doc:
-//		Non-throwing singleton delete operator
-//
-//---------------------------------------------------------------------------
-void
-operator delete
-	(
-	void* pv,
-	const gpos::NO_THROW&
-	)
-	throw()
-{
-	DeleteImplNoThrow(pv, IMemoryPool::EatSingleton);
-}
-
-
-//---------------------------------------------------------------------------
-//	@function:
-//		delete
-//
-//	@doc:
-//		Non-throwing array delete operator
-//
-//---------------------------------------------------------------------------
-void
-operator delete []
-	(
-	void* pv,
-	const gpos::NO_THROW&
-	)
-	throw()
-{
-	DeleteImplNoThrow(pv, IMemoryPool::EatArray);
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/CGPOptimizer.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/CGPOptimizer.cpp b/src/backend/gpopt/CGPOptimizer.cpp
index ab88232..c0eaa3e 100644
--- a/src/backend/gpopt/CGPOptimizer.cpp
+++ b/src/backend/gpopt/CGPOptimizer.cpp
@@ -29,7 +29,6 @@
 //
 //---------------------------------------------------------------------------
 
-#include "gpopt/Allocators.h"
 #include "gpopt/CGPOptimizer.h"
 #include "gpopt/utils/COptTasks.h"
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/Makefile
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/Makefile b/src/backend/gpopt/Makefile
index eb58017..b587ffd 100644
--- a/src/backend/gpopt/Makefile
+++ b/src/backend/gpopt/Makefile
@@ -16,12 +16,12 @@ include $(top_builddir)/src/backend/gpopt/gpopt.mk
 
 SUBDIRS = config translate relcache utils
 
-OBJS = Allocators.o CGPOptimizer.o gpdbwrappers.o
+OBJS = CGPOptimizer.o gpdbwrappers.o
 
 OTHER_TASK = libdxltranslators.$(LDSFX) libgpoptudf.$(LDSFX)
 
 ifeq (Darwin, $(UNAME))
-	LDLIBFLAGS = -dynamiclib -flat_namespace -undefined dynamic_lookup -Wl,-unexported_symbols_list -Wl,unexported_symbols_list.txt
+	LDLIBFLAGS = -dynamiclib -flat_namespace -undefined dynamic_lookup -Wl
 endif
 
 ifeq (Linux, $(UNAME))

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/config/CConfigParamMapping.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/config/CConfigParamMapping.cpp b/src/backend/gpopt/config/CConfigParamMapping.cpp
index 4c54061..beb355e 100644
--- a/src/backend/gpopt/config/CConfigParamMapping.cpp
+++ b/src/backend/gpopt/config/CConfigParamMapping.cpp
@@ -409,7 +409,7 @@ CConfigParamMapping::PbsPack
 	ULONG ulXforms // number of available xforms
 	)
 {
-	CBitSet *pbs = New(pmp) CBitSet(pmp, EopttraceSentinel);
+	CBitSet *pbs = GPOS_NEW(pmp) CBitSet(pmp, EopttraceSentinel);
 
 	for (ULONG ul = 0; ul < GPOS_ARRAY_SIZE(m_elem); ul++)
 	{

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/gpdbwrappers.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/gpdbwrappers.cpp b/src/backend/gpopt/gpdbwrappers.cpp
index 45a7349..8be3fd7 100644
--- a/src/backend/gpopt/gpdbwrappers.cpp
+++ b/src/backend/gpopt/gpdbwrappers.cpp
@@ -888,7 +888,7 @@ Query *
 gpdb::PqueryFlattenJoinAliasVar
 	(
 	Query *pquery,
-	ULONG ulQueryLevel
+	gpos::ULONG ulQueryLevel
 	)
 {
 	GP_WRAP_START;
@@ -2403,7 +2403,7 @@ gpdb::PqrActiveQueryResource(void)
 }
 
 
-BOOL
+gpos::BOOL
 gpdb::FChildPartDistributionMismatch
 	(
 	Relation rel
@@ -2417,7 +2417,7 @@ gpdb::FChildPartDistributionMismatch
     return false;
 }
 
-BOOL
+gpos::BOOL
 gpdb::FChildTriggers
 	(
 	Oid oid,
@@ -3100,7 +3100,7 @@ gpdb::OptTasksFaultInjector
 	return FaultInjectorTypeNotSpecified;
 }
 
-ULONG
+gpos::ULONG
 gpdb::UlLeafPartitions
        (
        Oid oidRelation

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CCTEListEntry.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CCTEListEntry.cpp b/src/backend/gpopt/translate/CCTEListEntry.cpp
index 077bd55..372b4c5 100644
--- a/src/backend/gpopt/translate/CCTEListEntry.cpp
+++ b/src/backend/gpopt/translate/CCTEListEntry.cpp
@@ -65,13 +65,13 @@ CCTEListEntry::CCTEListEntry
 {
 	GPOS_ASSERT(NULL != pcte && NULL != pdxlnCTEProducer);
 	
-	m_phmszcteinfo = New(pmp) HMSzCTEInfo(pmp);
+	m_phmszcteinfo = GPOS_NEW(pmp) HMSzCTEInfo(pmp);
 	Query *pqueryCTE = (Query*) pcte->ctequery;
 		
 #ifdef GPOS_DEBUG
 		BOOL fResult =
 #endif
-	m_phmszcteinfo->FInsert(pcte->ctename, New(pmp) SCTEProducerInfo(pdxlnCTEProducer, pqueryCTE->targetList));
+	m_phmszcteinfo->FInsert(pcte->ctename, GPOS_NEW(pmp) SCTEProducerInfo(pdxlnCTEProducer, pqueryCTE->targetList));
 		
 	GPOS_ASSERT(fResult);
 }
@@ -98,7 +98,7 @@ CCTEListEntry::CCTEListEntry
 	GPOS_ASSERT(NULL != pdrgpdxln);
 	GPOS_ASSERT(pdrgpdxln->UlLength() == gpdb::UlListLength(plCTE));
 	
-	m_phmszcteinfo = New(pmp) HMSzCTEInfo(pmp);
+	m_phmszcteinfo = GPOS_NEW(pmp) HMSzCTEInfo(pmp);
 	const ULONG ulCTEs = pdrgpdxln->UlLength();
 	
 	for (ULONG ul = 0; ul < ulCTEs; ul++)
@@ -110,7 +110,7 @@ CCTEListEntry::CCTEListEntry
 #ifdef GPOS_DEBUG
 		BOOL fResult =
 #endif
-		m_phmszcteinfo->FInsert(pcte->ctename, New(pmp) SCTEProducerInfo(pdxlnCTEProducer, pqueryCTE->targetList));
+		m_phmszcteinfo->FInsert(pcte->ctename, GPOS_NEW(pmp) SCTEProducerInfo(pdxlnCTEProducer, pqueryCTE->targetList));
 		
 		GPOS_ASSERT(fResult);
 		GPOS_ASSERT(NULL != m_phmszcteinfo->PtLookup(pcte->ctename));
@@ -187,7 +187,7 @@ CCTEListEntry::AddCTEProducer
 #ifdef GPOS_DEBUG
 	BOOL fResult =
 #endif
-	m_phmszcteinfo->FInsert(pcte->ctename, New(pmp) SCTEProducerInfo(pdxlnCTEProducer, pqueryCTE->targetList));
+	m_phmszcteinfo->FInsert(pcte->ctename, GPOS_NEW(pmp) SCTEProducerInfo(pdxlnCTEProducer, pqueryCTE->targetList));
 	
 	GPOS_ASSERT(fResult);
 }

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CContextDXLToPlStmt.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CContextDXLToPlStmt.cpp b/src/backend/gpopt/translate/CContextDXLToPlStmt.cpp
index f886148..bc48575 100644
--- a/src/backend/gpopt/translate/CContextDXLToPlStmt.cpp
+++ b/src/backend/gpopt/translate/CContextDXLToPlStmt.cpp
@@ -71,9 +71,9 @@ CContextDXLToPlStmt::CContextDXLToPlStmt
 	m_pintocl(NULL),
 	m_pdistrpolicy(NULL)
 {
-	m_phmuldxltrctxSharedScan = New(m_pmp) HMUlDxltrctx(m_pmp);
-	m_phmulcteconsumerinfo = New(m_pmp) HMUlCTEConsumerInfo(m_pmp);
-	m_pdrgpulNumSelectors = New(m_pmp) DrgPul(m_pmp);
+	m_phmuldxltrctxSharedScan = GPOS_NEW(m_pmp) HMUlDxltrctx(m_pmp);
+	m_phmulcteconsumerinfo = GPOS_NEW(m_pmp) HMUlCTEConsumerInfo(m_pmp);
+	m_pdrgpulNumSelectors = GPOS_NEW(m_pmp) DrgPul(m_pmp);
 }
 
 //---------------------------------------------------------------------------
@@ -187,11 +187,11 @@ CContextDXLToPlStmt::AddCTEConsumerInfo
 
 	List *plPlanCTE = ListMake1(pshscan);
 
-	ULONG *pulKey = New(m_pmp) ULONG(ulCteId);
+	ULONG *pulKey = GPOS_NEW(m_pmp) ULONG(ulCteId);
 #ifdef GPOS_DEBUG
 	BOOL fResult =
 #endif
-			m_phmulcteconsumerinfo->FInsert(pulKey, New(m_pmp) SCTEConsumerInfo(plPlanCTE));
+			m_phmulcteconsumerinfo->FInsert(pulKey, GPOS_NEW(m_pmp) SCTEConsumerInfo(plPlanCTE));
 
 	GPOS_ASSERT(fResult);
 }
@@ -313,7 +313,7 @@ CContextDXLToPlStmt::IncrementPartitionSelectors
 	const ULONG ulLen = m_pdrgpulNumSelectors->UlLength();
 	for (ULONG ul = ulLen; ul <= ulScanId; ul++)
 	{
-		ULONG *pul = New(m_pmp) ULONG(0);
+		ULONG *pul = GPOS_NEW(m_pmp) ULONG(0);
 		m_pdrgpulNumSelectors->Append(pul);
 	}
 
@@ -412,7 +412,7 @@ CContextDXLToPlStmt::AddSharedScanTranslationContext
 	CDXLTranslateContext *pdxltrctx
 	)
 {
-	ULONG *pul = New(m_pmp) ULONG(ulSpoolId);
+	ULONG *pul = GPOS_NEW(m_pmp) ULONG(ulSpoolId);
 
 #ifdef GPOS_DEBUG
 	BOOL fInserted =

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CDXLTranslateContext.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CDXLTranslateContext.cpp b/src/backend/gpopt/translate/CDXLTranslateContext.cpp
index fa2140a..434a800 100644
--- a/src/backend/gpopt/translate/CDXLTranslateContext.cpp
+++ b/src/backend/gpopt/translate/CDXLTranslateContext.cpp
@@ -52,8 +52,8 @@ CDXLTranslateContext::CDXLTranslateContext
 	m_fChildAggNode(fChildAggNode)
 {
 	// initialize hash table
-	m_phmulte = New(m_pmp) HMUlTe(m_pmp);
-	m_phmcolparam = New(m_pmp) HMColParam(m_pmp);
+	m_phmulte = GPOS_NEW(m_pmp) HMUlTe(m_pmp);
+	m_phmcolparam = GPOS_NEW(m_pmp) HMColParam(m_pmp);
 }
 
 //---------------------------------------------------------------------------
@@ -74,8 +74,8 @@ CDXLTranslateContext::CDXLTranslateContext
 	m_pmp(pmp),
 	m_fChildAggNode(fChildAggNode)
 {
-	m_phmulte = New(m_pmp) HMUlTe(m_pmp);
-	m_phmcolparam = New(m_pmp) HMColParam(m_pmp);
+	m_phmulte = GPOS_NEW(m_pmp) HMUlTe(m_pmp);
+	m_phmcolparam = GPOS_NEW(m_pmp) HMColParam(m_pmp);
 	CopyParamHashmap(phmOriginal);
 }
 
@@ -128,7 +128,7 @@ CDXLTranslateContext::CopyParamHashmap
 		CMappingElementColIdParamId *pmecolidparamid = const_cast<CMappingElementColIdParamId *>(hashmapiter.Pt());
 
 		const ULONG ulColId = pmecolidparamid->UlColId();
-		ULONG *pulKey = New(m_pmp) ULONG(ulColId);
+		ULONG *pulKey = GPOS_NEW(m_pmp) ULONG(ulColId);
 		pmecolidparamid->AddRef();
 		m_phmcolparam->FInsert(pulKey, pmecolidparamid);
 	}
@@ -186,14 +186,14 @@ CDXLTranslateContext::InsertMapping
 	)
 {
 	// copy key
-	ULONG *pulKey = New(m_pmp) ULONG(ulColId);
+	ULONG *pulKey = GPOS_NEW(m_pmp) ULONG(ulColId);
 
 	// insert colid->target entry mapping in the hash map
 	BOOL fResult = m_phmulte->FInsert(pulKey, pte);
 
 	if (!fResult)
 	{
-		delete pulKey;
+		GPOS_DELETE(pulKey);
 	}
 }
 
@@ -213,7 +213,7 @@ CDXLTranslateContext::FInsertParamMapping
 	)
 {
 	// copy key
-	ULONG *pulKey = New(m_pmp) ULONG(ulColId);
+	ULONG *pulKey = GPOS_NEW(m_pmp) ULONG(ulColId);
 
 	// insert colid->target entry mapping in the hash map
 	return m_phmcolparam->FInsert(pulKey, pmecolidparamid);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CDXLTranslateContextBaseTable.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CDXLTranslateContextBaseTable.cpp b/src/backend/gpopt/translate/CDXLTranslateContextBaseTable.cpp
index a4a2c1d..7ad61cf 100644
--- a/src/backend/gpopt/translate/CDXLTranslateContextBaseTable.cpp
+++ b/src/backend/gpopt/translate/CDXLTranslateContextBaseTable.cpp
@@ -54,7 +54,7 @@ CDXLTranslateContextBaseTable::CDXLTranslateContextBaseTable
 	m_iRel(0)
 {
 	// initialize hash table
-	m_phmuli = New(m_pmp) HMUlI(m_pmp);
+	m_phmuli = GPOS_NEW(m_pmp) HMUlI(m_pmp);
 }
 
 //---------------------------------------------------------------------------
@@ -179,8 +179,8 @@ CDXLTranslateContextBaseTable::FInsertMapping
 	)
 {
 	// copy key and value
-	ULONG *pulKey = New(m_pmp) ULONG(ulDXLColId);
-	INT *piValue = New(m_pmp) INT(iAttno);
+	ULONG *pulKey = GPOS_NEW(m_pmp) ULONG(ulDXLColId);
+	INT *piValue = GPOS_NEW(m_pmp) INT(iAttno);
 
 	// insert colid-idx mapping in the hash map
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CMappingColIdVarQuery.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CMappingColIdVarQuery.cpp b/src/backend/gpopt/translate/CMappingColIdVarQuery.cpp
index 37ee8c8..e059f02 100644
--- a/src/backend/gpopt/translate/CMappingColIdVarQuery.cpp
+++ b/src/backend/gpopt/translate/CMappingColIdVarQuery.cpp
@@ -109,10 +109,10 @@ CMappingColIdVarQuery::FInsertMapping
 	GPOS_ASSERT(NULL == m_ptemap->PtLookup(&ulColId));
 
 	// create mapping element
-	CMappingElementColIdTE *pmappingelement = New (m_pmp) CMappingElementColIdTE(ulColId, m_ulQueryLevel, pte);
+	CMappingElementColIdTE *pmappingelement = GPOS_NEW(m_pmp) CMappingElementColIdTE(ulColId, m_ulQueryLevel, pte);
 
 	// insert ColId->TE mapping
-	ULONG *pulKey1 = New(m_pmp) ULONG(ulColId);
+	ULONG *pulKey1 = GPOS_NEW(m_pmp) ULONG(ulColId);
 	BOOL fRes1 = m_ptemap->FInsert(pulKey1, pmappingelement);
 	GPOS_ASSERT(fRes1);
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CMappingParamIdScalarId.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CMappingParamIdScalarId.cpp b/src/backend/gpopt/translate/CMappingParamIdScalarId.cpp
index e041efc..df1c4ad 100644
--- a/src/backend/gpopt/translate/CMappingParamIdScalarId.cpp
+++ b/src/backend/gpopt/translate/CMappingParamIdScalarId.cpp
@@ -47,7 +47,7 @@ CMappingParamIdScalarId::CMappingParamIdScalarId
 	:
 	m_pmp(pmp)
 {
-	m_phmps = New(m_pmp) HMParamScalar(m_pmp);
+	m_phmps = GPOS_NEW(m_pmp) HMParamScalar(m_pmp);
 }
 
 //---------------------------------------------------------------------------
@@ -84,7 +84,7 @@ CMappingParamIdScalarId::FInsertMapping
 	)
 {
 	// copy key
-	ULONG *pulKey = New(m_pmp) ULONG(ulParamId);
+	ULONG *pulKey = GPOS_NEW(m_pmp) ULONG(ulParamId);
 
 	// insert mapping in the hash map
 	return m_phmps->FInsert(pulKey, pscid);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CMappingVarColId.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CMappingVarColId.cpp b/src/backend/gpopt/translate/CMappingVarColId.cpp
index 798efcc..4745517 100644
--- a/src/backend/gpopt/translate/CMappingVarColId.cpp
+++ b/src/backend/gpopt/translate/CMappingVarColId.cpp
@@ -67,7 +67,7 @@ CMappingVarColId::CMappingVarColId
 	:
 	m_pmp(pmp)
 {
-	m_pmvcmap = New(m_pmp) CMVCMap(m_pmp);
+	m_pmvcmap = GPOS_NEW(m_pmp) CMVCMap(m_pmp);
 }
 
 //---------------------------------------------------------------------------
@@ -102,7 +102,7 @@ CMappingVarColId::Pgpdbattoptcol
 		ulVarNo = OUTER;
 	}
 
-	CGPDBAttInfo *pgpdbattinfo = New(m_pmp) CGPDBAttInfo(ulAbsQueryLevel, ulVarNo, pvar->varattno);
+	CGPDBAttInfo *pgpdbattinfo = GPOS_NEW(m_pmp) CGPDBAttInfo(ulAbsQueryLevel, ulVarNo, pvar->varattno);
 	CGPDBAttOptCol *pgpdbattoptcol = m_pmvcmap->PtLookup(pgpdbattinfo);
 	
 	if (NULL == pgpdbattoptcol)
@@ -178,14 +178,14 @@ CMappingVarColId::Insert
 	GPOS_ASSERT(ulVarNo > 0);
 
 	// create key
-	CGPDBAttInfo *pgpdbattinfo = New(m_pmp) CGPDBAttInfo(ulQueryLevel, ulVarNo, iAttNo);
+	CGPDBAttInfo *pgpdbattinfo = GPOS_NEW(m_pmp) CGPDBAttInfo(ulQueryLevel, ulVarNo, iAttNo);
 
 	// create value
-	COptColInfo *poptcolinfo = New(m_pmp) COptColInfo(ulColId, pstrColName);
+	COptColInfo *poptcolinfo = GPOS_NEW(m_pmp) COptColInfo(ulColId, pstrColName);
 
 	// key is part of value, bump up refcount
 	pgpdbattinfo->AddRef();
-	CGPDBAttOptCol *pgpdbattoptcol = New(m_pmp) CGPDBAttOptCol(pgpdbattinfo, poptcolinfo);
+	CGPDBAttOptCol *pgpdbattoptcol = GPOS_NEW(m_pmp) CGPDBAttOptCol(pgpdbattinfo, poptcolinfo);
 
 #ifdef GPOS_DEBUG
 	BOOL fResult =
@@ -308,7 +308,7 @@ CMappingVarColId::Load
 				);
 
 		ul ++;
-		delete(pstrColName);
+		GPOS_DELETE(pstrColName);
 	}
 }
 
@@ -485,7 +485,7 @@ CMappingVarColId::PmapvarcolidCopy
 	)
 	const
 {
-	CMappingVarColId *pmapvarcolid = New(m_pmp) CMappingVarColId(m_pmp);
+	CMappingVarColId *pmapvarcolid = GPOS_NEW(m_pmp) CMappingVarColId(m_pmp);
 
 	// iterate over full map
 	CMVCMapIter mvcmi(this->m_pmvcmap);
@@ -498,10 +498,10 @@ CMappingVarColId::PmapvarcolidCopy
 		if (pgpdbattinfo->UlQueryLevel() <= ulQueryLevel)
 		{
 			// include all variables defined at same query level or before
-			CGPDBAttInfo *pgpdbattinfoNew = New(m_pmp) CGPDBAttInfo(pgpdbattinfo->UlQueryLevel(), pgpdbattinfo->UlVarNo(), pgpdbattinfo->IAttNo());
-			COptColInfo *poptcolinfoNew = New(m_pmp) COptColInfo(poptcolinfo->UlColId(), New(m_pmp) CWStringConst(m_pmp, poptcolinfo->PstrColName()->Wsz()));
+			CGPDBAttInfo *pgpdbattinfoNew = GPOS_NEW(m_pmp) CGPDBAttInfo(pgpdbattinfo->UlQueryLevel(), pgpdbattinfo->UlVarNo(), pgpdbattinfo->IAttNo());
+			COptColInfo *poptcolinfoNew = GPOS_NEW(m_pmp) COptColInfo(poptcolinfo->UlColId(), GPOS_NEW(m_pmp) CWStringConst(m_pmp, poptcolinfo->PstrColName()->Wsz()));
 			pgpdbattinfoNew->AddRef();
-			CGPDBAttOptCol *pgpdbattoptcolNew = New(m_pmp) CGPDBAttOptCol(pgpdbattinfoNew, poptcolinfoNew);
+			CGPDBAttOptCol *pgpdbattoptcolNew = GPOS_NEW(m_pmp) CGPDBAttOptCol(pgpdbattinfoNew, poptcolinfoNew);
 
 			// insert into hashmap
 #ifdef GPOS_DEBUG
@@ -530,7 +530,7 @@ CMappingVarColId::PmapvarcolidCopy
 	)
 	const
 {
-	CMappingVarColId *pmapvarcolid = New(pmp) CMappingVarColId(pmp);
+	CMappingVarColId *pmapvarcolid = GPOS_NEW(pmp) CMappingVarColId(pmp);
 
 	// iterate over full map
 	CMVCMapIter mvcmi(this->m_pmvcmap);
@@ -540,10 +540,10 @@ CMappingVarColId::PmapvarcolidCopy
 		const CGPDBAttInfo *pgpdbattinfo = pgpdbattoptcol->Pgpdbattinfo();
 		const COptColInfo *poptcolinfo = pgpdbattoptcol->Poptcolinfo();
 
-		CGPDBAttInfo *pgpdbattinfoNew = New(pmp) CGPDBAttInfo(pgpdbattinfo->UlQueryLevel(), pgpdbattinfo->UlVarNo(), pgpdbattinfo->IAttNo());
-		COptColInfo *poptcolinfoNew = New(pmp) COptColInfo(poptcolinfo->UlColId(), New(pmp) CWStringConst(pmp, poptcolinfo->PstrColName()->Wsz()));
+		CGPDBAttInfo *pgpdbattinfoNew = GPOS_NEW(pmp) CGPDBAttInfo(pgpdbattinfo->UlQueryLevel(), pgpdbattinfo->UlVarNo(), pgpdbattinfo->IAttNo());
+		COptColInfo *poptcolinfoNew = GPOS_NEW(pmp) COptColInfo(poptcolinfo->UlColId(), GPOS_NEW(pmp) CWStringConst(pmp, poptcolinfo->PstrColName()->Wsz()));
 		pgpdbattinfoNew->AddRef();
-		CGPDBAttOptCol *pgpdbattoptcolNew = New(pmp) CGPDBAttOptCol(pgpdbattinfoNew, poptcolinfoNew);
+		CGPDBAttOptCol *pgpdbattoptcolNew = GPOS_NEW(pmp) CGPDBAttOptCol(pgpdbattinfoNew, poptcolinfoNew);
 
 		// insert into hashmap
 #ifdef GPOS_DEBUG
@@ -580,7 +580,7 @@ CMappingVarColId::PmapvarcolidRemap
 	// construct a mapping old cols -> new cols
 	HMUlUl *phmulul = CTranslatorUtils::PhmululMap(pmp, pdrgpulOld, pdrgpulNew);
 		
-	CMappingVarColId *pmapvarcolid = New(pmp) CMappingVarColId(pmp);
+	CMappingVarColId *pmapvarcolid = GPOS_NEW(pmp) CMappingVarColId(pmp);
 
 	CMVCMapIter mvcmi(this->m_pmvcmap);
 	while (mvcmi.FAdvance())
@@ -589,7 +589,7 @@ CMappingVarColId::PmapvarcolidRemap
 		const CGPDBAttInfo *pgpdbattinfo = pgpdbattoptcol->Pgpdbattinfo();
 		const COptColInfo *poptcolinfo = pgpdbattoptcol->Poptcolinfo();
 
-		CGPDBAttInfo *pgpdbattinfoNew = New(pmp) CGPDBAttInfo(pgpdbattinfo->UlQueryLevel(), pgpdbattinfo->UlVarNo(), pgpdbattinfo->IAttNo());
+		CGPDBAttInfo *pgpdbattinfoNew = GPOS_NEW(pmp) CGPDBAttInfo(pgpdbattinfo->UlQueryLevel(), pgpdbattinfo->UlVarNo(), pgpdbattinfo->IAttNo());
 		ULONG ulColId = poptcolinfo->UlColId();
 		ULONG *pulColIdNew = phmulul->PtLookup(&ulColId);
 		if (NULL != pulColIdNew)
@@ -597,9 +597,9 @@ CMappingVarColId::PmapvarcolidRemap
 			ulColId = *pulColIdNew;
 		}
 		
-		COptColInfo *poptcolinfoNew = New(pmp) COptColInfo(ulColId, New(pmp) CWStringConst(pmp, poptcolinfo->PstrColName()->Wsz()));
+		COptColInfo *poptcolinfoNew = GPOS_NEW(pmp) COptColInfo(ulColId, GPOS_NEW(pmp) CWStringConst(pmp, poptcolinfo->PstrColName()->Wsz()));
 		pgpdbattinfoNew->AddRef();
-		CGPDBAttOptCol *pgpdbattoptcolNew = New(pmp) CGPDBAttOptCol(pgpdbattinfoNew, poptcolinfoNew);
+		CGPDBAttOptCol *pgpdbattoptcolNew = GPOS_NEW(pmp) CGPDBAttOptCol(pgpdbattinfoNew, poptcolinfoNew);
 
 #ifdef GPOS_DEBUG
 		BOOL fResult =

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CStateDXLToQuery.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CStateDXLToQuery.cpp b/src/backend/gpopt/translate/CStateDXLToQuery.cpp
index 8bd7533..f69a56a 100644
--- a/src/backend/gpopt/translate/CStateDXLToQuery.cpp
+++ b/src/backend/gpopt/translate/CStateDXLToQuery.cpp
@@ -58,7 +58,7 @@ CStateDXLToQuery::CStateDXLToQuery
 	m_plTEColumns(NIL),
 	m_plColumnNames(NIL)
 {
-	m_pdrgpulColIds = New(m_pmp) DrgPul(m_pmp);
+	m_pdrgpulColIds = GPOS_NEW(m_pmp) DrgPul(m_pmp);
 }
 
 
@@ -96,7 +96,7 @@ CStateDXLToQuery::AddOutputColumnEntry
 	GPOS_ASSERT((ULONG) gpdb::UlListLength(m_plTEColumns) == m_pdrgpulColIds->UlLength());
 	m_plTEColumns = gpdb::PlAppendElement(m_plTEColumns, pte);
 	m_plColumnNames = gpdb::PlAppendElement(m_plColumnNames, szColumnName);
-	m_pdrgpulColIds->Append(New(m_pmp) ULONG(ulColId));
+	m_pdrgpulColIds->Append(GPOS_NEW(m_pmp) ULONG(ulColId));
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CTranslatorDXLToPlStmt.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CTranslatorDXLToPlStmt.cpp b/src/backend/gpopt/translate/CTranslatorDXLToPlStmt.cpp
index ec0c511..12ef75f 100644
--- a/src/backend/gpopt/translate/CTranslatorDXLToPlStmt.cpp
+++ b/src/backend/gpopt/translate/CTranslatorDXLToPlStmt.cpp
@@ -134,7 +134,7 @@ CTranslatorDXLToPlStmt::CTranslatorDXLToPlStmt
 	m_ulSegments(ulSegments),
 	m_ulPartitionSelectorCounter(0)
 {
-	m_pdxlsctranslator = New (m_pmp) CTranslatorDXLToScalar(m_pmp, m_pmda, m_ulSegments);
+	m_pdxlsctranslator = GPOS_NEW(m_pmp) CTranslatorDXLToScalar(m_pmp, m_pmda, m_ulSegments);
 	InitTranslators();
 }
 
@@ -148,7 +148,7 @@ CTranslatorDXLToPlStmt::CTranslatorDXLToPlStmt
 //---------------------------------------------------------------------------
 CTranslatorDXLToPlStmt::~CTranslatorDXLToPlStmt()
 {
-	delete m_pdxlsctranslator;
+	GPOS_DELETE(m_pdxlsctranslator);
 }
 
 //---------------------------------------------------------------------------
@@ -234,7 +234,7 @@ CTranslatorDXLToPlStmt::PplstmtFromDXL
 
 	CDXLTranslateContext dxltrctx(m_pmp, false);
 
-	DrgPdxltrctx *pdrgpdxltrctxPrevSiblings = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctxPrevSiblings = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	Plan *pplan = PplFromDXL(pdxln, &dxltrctx, NULL, pdrgpdxltrctxPrevSiblings);
 	pdrgpdxltrctxPrevSiblings->Release();
 
@@ -1511,7 +1511,7 @@ CTranslatorDXLToPlStmt::TranslateIndexConditions
 	)
 {
 	// array of index qual info
-	DrgPindexqualinfo *pdrgpindexqualinfo = New(m_pmp) DrgPindexqualinfo(m_pmp);
+	DrgPindexqualinfo *pdrgpindexqualinfo = GPOS_NEW(m_pmp) DrgPindexqualinfo(m_pmp);
 
 	// build colid->var mapping
 	CMappingColIdVarPlStmt mapcidvarplstmt(m_pmp, pdxltrctxbt, pdrgpdxltrctxPrevSiblings, pdxltrctxOut, m_pctxdxltoplstmt, pplanParent);
@@ -1565,7 +1565,7 @@ CTranslatorDXLToPlStmt::TranslateIndexConditions
 		GPOS_ASSERT(!fRecheck);
 		
 		// create index qual
-		pdrgpindexqualinfo->Append(New(m_pmp) CIndexQualInfo(iAttno, (OpExpr *)pexprIndexCond, (OpExpr *)pexprOrigIndexCond, (StrategyNumber) iSN, oidIndexSubtype));
+		pdrgpindexqualinfo->Append(GPOS_NEW(m_pmp) CIndexQualInfo(iAttno, (OpExpr *)pexprIndexCond, (OpExpr *)pexprOrigIndexCond, (StrategyNumber) iSN, oidIndexSubtype));
 	}
 
 	// the index quals much be ordered by attribute number
@@ -1665,7 +1665,7 @@ CTranslatorDXLToPlStmt::PlimitFromDXLLimit
 	// NOTE: Limit node has only the left plan while the right plan is left empty
 	Plan *pplanLeft = PplFromDXL(pdxlnChildPlan, &dxltrctxLeft, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(&dxltrctxLeft);
 
 	pplan->targetlist = PlTargetListFromProjList
@@ -1760,12 +1760,12 @@ CTranslatorDXLToPlStmt::PhjFromDXLHJ
 	Plan *pplanLeft = PplFromDXL(pdxlnLeft, &dxltrctxLeft, pplan, pdrgpdxltrctxPrevSiblings);
 
 	// the right side of the join is the one where the hash phase is done
-	DrgPdxltrctx *pdrgpdxltrctxWithSiblings = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctxWithSiblings = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctxWithSiblings->Append(&dxltrctxLeft);
 	pdrgpdxltrctxWithSiblings->AppendArray(pdrgpdxltrctxPrevSiblings);
 	Plan *pplanRight = (Plan*) PhhashFromDXL(pdxlnRight, &dxltrctxRight, pplan, pdrgpdxltrctxWithSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxLeft));
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxRight));
 	// translate proj list and filter
@@ -2114,7 +2114,7 @@ CTranslatorDXLToPlStmt::PnljFromDXLNLJ
 	// because inner child depends on variables coming from outer child
 	pj->prefetch_inner = !pdxlnlj->FIndexNLJ();
 
-	DrgPdxltrctx *pdrgpdxltrctxWithSiblings = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctxWithSiblings = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	Plan *pplanLeft = NULL;
 	Plan *pplanRight = NULL;
 	if (pdxlnlj->FIndexNLJ())
@@ -2141,7 +2141,7 @@ CTranslatorDXLToPlStmt::PnljFromDXLNLJ
 		// translate left child after right child translation is complete
 		pplanLeft = PplFromDXL(pdxlnLeft, &dxltrctxLeft, pplan, pdrgpdxltrctxWithSiblings);
 	}
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(&dxltrctxLeft);
 	pdrgpdxltrctx->Append(&dxltrctxRight);
 
@@ -2237,13 +2237,13 @@ CTranslatorDXLToPlStmt::PmjFromDXLMJ
 
 	Plan *pplanLeft = PplFromDXL(pdxlnLeft, &dxltrctxLeft, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctxWithSiblings = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctxWithSiblings = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctxWithSiblings->Append(&dxltrctxLeft);
 	pdrgpdxltrctxWithSiblings->AppendArray(pdrgpdxltrctxPrevSiblings);
 
 	Plan *pplanRight = PplFromDXL(pdxlnRight, &dxltrctxRight, pplan, pdrgpdxltrctxWithSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxLeft));
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxRight));
 
@@ -2438,7 +2438,7 @@ CTranslatorDXLToPlStmt::PplanMotionFromDXLMotion
 
 	Plan *pplanChild = PplFromDXL(pdxlnChild, &dxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxChild));
 
 	// translate proj list and filter
@@ -2635,7 +2635,7 @@ CTranslatorDXLToPlStmt::PplanResultHashFilters
 
 	Plan *pplanChild = PplFromDXL(pdxlnChild, &dxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxChild));
 
 	// translate proj list and filter
@@ -2766,7 +2766,7 @@ CTranslatorDXLToPlStmt::PaggFromDXLAgg
 
 	Plan *pplanChild = PplFromDXL(pdxlnChild, &dxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxChild));
 
 	// translate proj list and filter
@@ -2879,7 +2879,7 @@ CTranslatorDXLToPlStmt::PwindowFromDXLWindow
 	CDXLTranslateContext dxltrctxChild(m_pmp, true, pdxltrctxOut->PhmColParam());
 	Plan *pplanChild = PplFromDXL(pdxlnChild, &dxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxChild));
 
 	// translate proj list and filter
@@ -2986,7 +2986,7 @@ CTranslatorDXLToPlStmt::Pwindowframe
 	pwindowframe->exclude = CTranslatorUtils::Windowexclusion(pdxlwf->Edxlfes());
 
 	// translate the CDXLNodes representing the leading and trailing edge
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(pdxltrctxChild);
 
 	CMappingColIdVarPlStmt mapcidvarplstmt = CMappingColIdVarPlStmt
@@ -3071,7 +3071,7 @@ CTranslatorDXLToPlStmt::PsortFromDXLSort
 
 	Plan *pplanChild = PplFromDXL(pdxlnChild, &dxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxChild));
 
 	// translate proj list and filter
@@ -3318,7 +3318,7 @@ CTranslatorDXLToPlStmt::PresultFromDXLResult
 
 	List *plQuals = NULL;
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxChild));
 
 	// translate proj list and filter
@@ -3399,8 +3399,8 @@ CTranslatorDXLToPlStmt::PplanPartitionSelector
 	pplan->nMotionNodes = 0;
 
 	CDXLNode *pdxlnChild = NULL;
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
-	DrgPdxltrctx *pdrgpdxltrctxWithSiblings = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctxWithSiblings = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 
 	CDXLTranslateContext dxltrctxChild(m_pmp, false, pdxltrctxOut->PhmColParam());
 
@@ -3631,7 +3631,7 @@ CTranslatorDXLToPlStmt::PappendFromDXLAppend
 		pplan->targetlist = gpdb::PlAppendElement(pplan->targetlist, pte);
 	}
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(pdxltrctxOut));
 
 	// translate filter
@@ -3700,7 +3700,7 @@ CTranslatorDXLToPlStmt::PmatFromDXLMaterialize
 
 	Plan *pplanChild = PplFromDXL(pdxlnChild, &dxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxChild));
 
 	// translate proj list and filter
@@ -3792,7 +3792,7 @@ CTranslatorDXLToPlStmt::PshscanFromDXLSharedScan
 	{
 		// translate shared scan child
 		CDXLNode *pdxlnChild = (*pdxlnSharedScan)[EdxlshscanIndexChild];
-		pdxltrctxChild = New(m_pmp) CDXLTranslateContext(m_pmp, false, pdxltrctxOut->PhmColParam());
+		pdxltrctxChild = GPOS_NEW(m_pmp) CDXLTranslateContext(m_pmp, false, pdxltrctxOut->PhmColParam());
 
 		Plan *pplanChild = PplFromDXL(pdxlnChild, pdxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 
@@ -3814,7 +3814,7 @@ CTranslatorDXLToPlStmt::PshscanFromDXLSharedScan
 	CDXLNode *pdxlnPrL = (*pdxlnSharedScan)[EdxlshscanIndexProjList];
 	CDXLNode *pdxlnFilter = (*pdxlnSharedScan)[EdxlshscanIndexFilter];
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(pdxltrctxChild);
 
 	// translate proj list and filter
@@ -3886,7 +3886,7 @@ CTranslatorDXLToPlStmt::PshscanFromDXLCTEProducer
 	Plan *pplanChild = PplFromDXL(pdxlnChild, &dxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 	GPOS_ASSERT(NULL != pplanChild && "child plan cannot be NULL");
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(&dxltrctxChild);
 	// translate proj list
 	pplan->targetlist = PlTargetListFromProjList
@@ -4188,7 +4188,7 @@ CTranslatorDXLToPlStmt::PplanSequence
 
 	CDXLNode *pdxlnPrL = (*pdxlnSequence)[0];
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxChild));
 
 	// translate proj list
@@ -4446,19 +4446,19 @@ CTranslatorDXLToPlStmt::PplanDML
 	
 	switch (pdxlop->EdxlDmlOpType())
 	{
-		case Edxldmldelete:
+		case gpdxl::Edxldmldelete:
 		{
 			m_cmdtype = CMD_DELETE;
 			aclmode = ACL_DELETE;
 			break;
 		}
-		case Edxldmlupdate:
+		case gpdxl::Edxldmlupdate:
 		{
 			m_cmdtype = CMD_UPDATE;
 			aclmode = ACL_UPDATE;
 			break;
 		}
-		case Edxldmlinsert:
+		case gpdxl::Edxldmlinsert:
 		{
 			m_cmdtype = CMD_INSERT;
 			aclmode = ACL_INSERT;
@@ -4497,7 +4497,7 @@ CTranslatorDXLToPlStmt::PplanDML
 
 	Plan *pplanChild = PplFromDXL(pdxlnChild, &dxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(&dxltrctxChild);
 
 	// translate proj list
@@ -4678,7 +4678,7 @@ CTranslatorDXLToPlStmt::PplanSplit
 
 	Plan *pplanChild = PplFromDXL(pdxlnChild, &dxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(&dxltrctxChild);
 
 	// translate proj list and filter
@@ -4805,7 +4805,7 @@ CTranslatorDXLToPlStmt::PplanAssert
 
 	List *plQuals = NULL;
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(const_cast<CDXLTranslateContext*>(&dxltrctxChild));
 
 	// translate proj list
@@ -4866,7 +4866,7 @@ CTranslatorDXLToPlStmt::PplanRowTrigger
 
 	Plan *pplanChild = PplFromDXL(pdxlnChild, &dxltrctxChild, pplan, pdrgpdxltrctxPrevSiblings);
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(&dxltrctxChild);
 
 	// translate proj list and filter
@@ -5458,7 +5458,7 @@ CTranslatorDXLToPlStmt::TranslateHashExprList
 	List *plHashExpr = NIL;
 	List *plHashExprTypes = NIL;
 
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(pdxltrctxChild);
 
 	const ULONG ulArity = pdxlnHashExprList->UlArity();
@@ -5745,7 +5745,7 @@ CTranslatorDXLToPlStmt::PplanCTAS
 	Plan *pplan = PplFromDXL(pdxlnChild, &dxltrctxChild, pplanParent, pdrgpdxltrctxPrevSiblings);
 	
 	// fix target list to match the required column names
-	DrgPdxltrctx *pdrgpdxltrctx = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctx = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	pdrgpdxltrctx->Append(&dxltrctxChild);
 	
 	List *plTargetList = PlTargetListFromProjList

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CTranslatorDXLToQuery.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CTranslatorDXLToQuery.cpp b/src/backend/gpopt/translate/CTranslatorDXLToQuery.cpp
index 8cee1d3..260fe63 100644
--- a/src/backend/gpopt/translate/CTranslatorDXLToQuery.cpp
+++ b/src/backend/gpopt/translate/CTranslatorDXLToQuery.cpp
@@ -79,7 +79,7 @@ CTranslatorDXLToQuery::CTranslatorDXLToQuery
 	m_ulSortgrouprefCounter(0),
 	m_ulSegments(ulSegments)
 {
-	m_pdxlsctranslator = New (m_pmp) CTranslatorDXLToScalar(m_pmp, m_pmda, m_ulSegments);
+	m_pdxlsctranslator = GPOS_NEW(m_pmp) CTranslatorDXLToScalar(m_pmp, m_pmda, m_ulSegments);
 }
 
 //---------------------------------------------------------------------------
@@ -92,7 +92,7 @@ CTranslatorDXLToQuery::CTranslatorDXLToQuery
 //---------------------------------------------------------------------------
 CTranslatorDXLToQuery::~CTranslatorDXLToQuery()
 {
-	delete m_pdxlsctranslator;
+	GPOS_DELETE(m_pdxlsctranslator);
 }
 
 //---------------------------------------------------------------------------
@@ -114,7 +114,7 @@ CTranslatorDXLToQuery::PqueryFromDXL
 	)
 {
 	// initialize the colid->var mapping
-	CMappingColIdVarQuery *pmapcidvarquery = New (m_pmp) CMappingColIdVarQuery(m_pmp, ptemap, ulQueryLevel);
+	CMappingColIdVarQuery *pmapcidvarquery = GPOS_NEW(m_pmp) CMappingColIdVarQuery(m_pmp, ptemap, ulQueryLevel);
 
 	GPOS_ASSERT(NULL != pdxln);
 
@@ -152,7 +152,7 @@ CTranslatorDXLToQuery::PqueryFromDXL
 	// TODO: venky; June 14 2011, We currently assume that all queries are of the type select.
 	pquery->commandType = CMD_SELECT;
 
-	delete pmapcidvarquery;
+	GPOS_DELETE(pmapcidvarquery);
 
 	if (m_pdxlsctranslator->FHasSubqueries())
 	{
@@ -182,7 +182,7 @@ CTranslatorDXLToQuery::PqueryFromDXLSubquery
 {
 
 	// initialize the colid->var mapping
-	CMappingColIdVarQuery *pmapcidvarquery = New (m_pmp) CMappingColIdVarQuery(m_pmp, ptemap, ulQueryLevel);
+	CMappingColIdVarQuery *pmapcidvarquery = GPOS_NEW (m_pmp) CMappingColIdVarQuery(m_pmp, ptemap, ulQueryLevel);
 
 	GPOS_ASSERT(NULL != pdxln);
 
@@ -201,7 +201,7 @@ CTranslatorDXLToQuery::PqueryFromDXLSubquery
 
 	pquery->commandType = CMD_SELECT;
 
-	delete pmapcidvarquery;
+	GPOS_DELETE(pmapcidvarquery);
 
 	if (m_pdxlsctranslator->FHasSubqueries())
 	{
@@ -229,7 +229,7 @@ CTranslatorDXLToQuery::SetSubqueryOutput
 	)
 {
 	GPOS_ASSERT(NULL != pquery);
-	CStateDXLToQuery *pstatedxltoqueryOutput = New(m_pmp) CStateDXLToQuery(m_pmp);
+	CStateDXLToQuery *pstatedxltoqueryOutput = GPOS_NEW(m_pmp) CStateDXLToQuery(m_pmp);
 
 	List *plTE = NIL;
 	ULONG ulResno = 1;
@@ -279,7 +279,7 @@ CTranslatorDXLToQuery::SetSubqueryOutput
 	}
 
 	pstatedxltoquery->Reload(pstatedxltoqueryOutput);
-	delete pstatedxltoqueryOutput;
+	GPOS_DELETE(pstatedxltoqueryOutput);
 
 	pquery->targetList = plTE;
 }
@@ -303,7 +303,7 @@ CTranslatorDXLToQuery::SetQueryOutput
 {
 	GPOS_ASSERT(NULL != pdrgpdxlnQueryOutput && NULL != pquery);
 
-	CStateDXLToQuery *pstatedxltoqueryOutput = New(m_pmp) CStateDXLToQuery(m_pmp);
+	CStateDXLToQuery *pstatedxltoqueryOutput = GPOS_NEW(m_pmp) CStateDXLToQuery(m_pmp);
 
 	List *plTE = NIL;
 
@@ -366,7 +366,7 @@ CTranslatorDXLToQuery::SetQueryOutput
 	}
 
 	pstatedxltoquery->Reload(pstatedxltoqueryOutput);
-	delete pstatedxltoqueryOutput;
+	GPOS_DELETE(pstatedxltoqueryOutput);
 
 	pquery->targetList = plTE;
 }
@@ -566,10 +566,10 @@ CTranslatorDXLToQuery::TranslateSetOp
 	{
 		CDXLNode *pdxlnChild = (*pdxln)[ul];
 
-		CStateDXLToQuery *pstatedxltoqueryChild = New(m_pmp) CStateDXLToQuery(m_pmp);
+		CStateDXLToQuery *pstatedxltoqueryChild = GPOS_NEW(m_pmp) CStateDXLToQuery(m_pmp);
 		RangeTblRef *prtrefChild = PrtrefFromDXLLgOp(pdxlnChild, pquery, pstatedxltoqueryChild, pmapcidvarquery);
 		MarkUnusedColumns(pquery, prtrefChild, pstatedxltoqueryChild, pdxlop->Pdrgpul(ul) /*array of colids of the first child*/);
-		delete pstatedxltoqueryChild;
+		GPOS_DELETE(pstatedxltoqueryChild);
 
 		if (0 == ul)
 		{
@@ -632,7 +632,7 @@ CTranslatorDXLToQuery::MarkUnusedColumns
 	Query *pqueryDerTbl = prte->subquery;
 
 	// maintain the list of used columns in a bit set
-	CBitSet *pds = New(m_pmp) CBitSet(m_pmp);
+	CBitSet *pds = GPOS_NEW(m_pmp) CBitSet(m_pmp);
 	const ULONG ulLen = pdrgpulColids->UlLength();
 	for (ULONG ul = 0; ul < ulLen; ul++)
 	{

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CTranslatorDXLToScalar.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CTranslatorDXLToScalar.cpp b/src/backend/gpopt/translate/CTranslatorDXLToScalar.cpp
index db086b8..7d0b0ce 100644
--- a/src/backend/gpopt/translate/CTranslatorDXLToScalar.cpp
+++ b/src/backend/gpopt/translate/CTranslatorDXLToScalar.cpp
@@ -634,7 +634,7 @@ CTranslatorDXLToScalar::PparamFromDXLNodeScInitPlan
 	// Since an init plan is not a scalar node, we create a new DXLTranslator to handle its translation
 	CContextDXLToPlStmt *pctxdxltoplstmt = (dynamic_cast<CMappingColIdVarPlStmt*>(pmapcidvar))->Pctxdxltoplstmt();
 	CTranslatorDXLToPlStmt trdxltoplstmt(m_pmp, m_pmda, pctxdxltoplstmt, m_ulSegments);
-	DrgPdxltrctx *pdrgpdxltrctxPrevSiblings = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctxPrevSiblings = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	Plan *pplanChild = trdxltoplstmt.PplFromDXL(pdxlnChild, pdxltrctxOut, pplan, pdrgpdxltrctxPrevSiblings);
 	pdrgpdxltrctxPrevSiblings->Release();
 
@@ -711,7 +711,7 @@ CTranslatorDXLToScalar::PsubplanFromDXLNodeScSubPlan
 		if (NULL == dxltrctxSubplan.Pmecolidparamid(ulColid))
 		{
 			// keep outer reference mapping to the original column for subsequent subplans
-			CMappingElementColIdParamId *pmecolidparamid = New (m_pmp) CMappingElementColIdParamId(ulColid, pctxdxltoplstmt->UlNextParamId(), pmdid);
+			CMappingElementColIdParamId *pmecolidparamid = GPOS_NEW(m_pmp) CMappingElementColIdParamId(ulColid, pctxdxltoplstmt->UlNextParamId(), pmdid);
 			
 #ifdef GPOS_DEBUG
 			BOOL fInserted =
@@ -744,7 +744,7 @@ CTranslatorDXLToScalar::PsubplanFromDXLNodeScSubPlan
 							(dynamic_cast<CMappingColIdVarPlStmt*>(pmapcidvar))->Pctxdxltoplstmt(),
 							m_ulSegments
 							);
-	DrgPdxltrctx *pdrgpdxltrctxPrevSiblings = New(m_pmp) DrgPdxltrctx(m_pmp);
+	DrgPdxltrctx *pdrgpdxltrctxPrevSiblings = GPOS_NEW(m_pmp) DrgPdxltrctx(m_pmp);
 	Plan *pplanChild = trdxltoplstmt.PplFromDXL(pdxlnChild, &dxltrctxSubplan, pplan, pdrgpdxltrctxPrevSiblings);
 	pdrgpdxltrctxPrevSiblings->Release();
 
@@ -891,7 +891,7 @@ CTranslatorDXLToScalar::TranslateSubplanParams
                 IMDId *pmdidType = pmecolidparamid->PmdidType();
                 pmdidType->AddRef();
 
-                CDXLScalarIdent *pdxlopIdent = New(m_pmp) CDXLScalarIdent(m_pmp, pdxlcr, pmdidType);
+                CDXLScalarIdent *pdxlopIdent = GPOS_NEW(m_pmp) CDXLScalarIdent(m_pmp, pdxlcr, pmdidType);
                 Expr *parg = (Expr *) pmapcidvar->PvarFromDXLNodeScId(pdxlopIdent);
 
                 // not found in mapping, it must be an external parameter
@@ -951,7 +951,7 @@ CTranslatorDXLToScalar::SzSubplanAlias
 	ULONG ulPlanId
 	)
 {
-	CWStringDynamic *pstr = New (m_pmp) CWStringDynamic(m_pmp);
+	CWStringDynamic *pstr = GPOS_NEW(m_pmp) CWStringDynamic(m_pmp);
 	pstr->AppendFormat(GPOS_WSZ_LIT("SubPlan %d"), ulPlanId);
 	const WCHAR *wsz = pstr->Wsz();
 
@@ -959,7 +959,7 @@ CTranslatorDXLToScalar::SzSubplanAlias
 	CHAR *sz = (CHAR *) gpdb::GPDBAlloc(ulMaxLength);
 	gpos::clib::LWcsToMbs(sz, const_cast<WCHAR *>(wsz), ulMaxLength);
 	sz[ulMaxLength - 1] = '\0';
-	delete pstr;
+	GPOS_DELETE(pstr);
 
 	return sz;
 }
@@ -1026,10 +1026,10 @@ CTranslatorDXLToScalar::PsublinkFromDXLNodeSubqueryExists
 	CDXLNode *pdxlnChild = (*pdxlnSubqueryExists)[0];
 
 	CTranslatorDXLToQuery trdxlquery(m_pmp, m_pmda, m_ulSegments);
-	CStateDXLToQuery *pstatedxltoquery = New(m_pmp) CStateDXLToQuery(m_pmp);
+	CStateDXLToQuery *pstatedxltoquery = GPOS_NEW(m_pmp) CStateDXLToQuery(m_pmp);
 
 	// empty list of output columns
-	DrgPdxln *pdrgpdxlnOutputCols = New(m_pmp) DrgPdxln(m_pmp);
+	DrgPdxln *pdrgpdxlnOutputCols = GPOS_NEW(m_pmp) DrgPdxln(m_pmp);
 	CMappingColIdVarQuery *pmapcidvarquery = dynamic_cast<CMappingColIdVarQuery *>(pmapcidvar);
 	TEMap *ptemapCopy = CTranslatorUtils::PtemapCopy(m_pmp, pmapcidvarquery->Ptemap());
 
@@ -1044,7 +1044,7 @@ CTranslatorDXLToScalar::PsublinkFromDXLNodeSubqueryExists
 
 	// clean up
 	pdrgpdxlnOutputCols->Release();
-	delete pstatedxltoquery;
+	GPOS_DELETE(pstatedxltoquery);
 	CRefCount::SafeRelease(ptemapCopy);
 
 	SubLink *psublink = MakeNode(SubLink);
@@ -1106,7 +1106,7 @@ CTranslatorDXLToScalar::PsublinkFromDXLNodeQuantifiedSubquery
 	CTranslatorDXLToQuery trdxlquery(m_pmp, m_pmda, m_ulSegments);
 	CMappingColIdVarQuery *pmapcidvarquery = dynamic_cast<CMappingColIdVarQuery *>(pmapcidvar);
 
-	CStateDXLToQuery *pstatedxltoquery = New(m_pmp) CStateDXLToQuery(m_pmp);
+	CStateDXLToQuery *pstatedxltoquery = GPOS_NEW(m_pmp) CStateDXLToQuery(m_pmp);
 
 	TEMap *ptemapCopy = CTranslatorUtils::PtemapCopy(m_pmp, pmapcidvarquery->Ptemap());
 
@@ -1143,7 +1143,7 @@ CTranslatorDXLToScalar::PsublinkFromDXLNodeQuantifiedSubquery
 
 	// clean up
 	ptemapCopy->Release();
-	delete pstatedxltoquery;
+	GPOS_DELETE(pstatedxltoquery);
 
 	return psublink;
 }
@@ -1168,7 +1168,7 @@ CTranslatorDXLToScalar::PsublinkFromDXLNodeScalarSubquery
 	CDXLNode *pdxlnChild = (*pdxlnSubquery)[0];
 
 	CTranslatorDXLToQuery trdxlquery(m_pmp, m_pmda, m_ulSegments);
-	CStateDXLToQuery *pstatedxltoquery = New(m_pmp) CStateDXLToQuery(m_pmp);
+	CStateDXLToQuery *pstatedxltoquery = GPOS_NEW(m_pmp) CStateDXLToQuery(m_pmp);
 
 	CMappingColIdVarQuery *pmapcidvarquery = dynamic_cast<CMappingColIdVarQuery *>(pmapcidvar);
 	TEMap *ptemapCopy = CTranslatorUtils::PtemapCopy(m_pmp, pmapcidvarquery->Ptemap());
@@ -1184,7 +1184,7 @@ CTranslatorDXLToScalar::PsublinkFromDXLNodeScalarSubquery
 
 	// clean up
 	CRefCount::SafeRelease(ptemapCopy);
-	delete pstatedxltoquery;
+	GPOS_DELETE(pstatedxltoquery);
 
 	SubLink *psublink = MakeNode(SubLink);
 	psublink->subLinkType = EXPR_SUBLINK;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/9b65a5ad/src/backend/gpopt/translate/CTranslatorPlStmtToDXL.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/translate/CTranslatorPlStmtToDXL.cpp b/src/backend/gpopt/translate/CTranslatorPlStmtToDXL.cpp
index e81b069..7657d4d 100644
--- a/src/backend/gpopt/translate/CTranslatorPlStmtToDXL.cpp
+++ b/src/backend/gpopt/translate/CTranslatorPlStmtToDXL.cpp
@@ -87,7 +87,7 @@ CTranslatorPlStmtToDXL::CTranslatorPlStmtToDXL
 	m_pparammapping(pmapps)
 {
 	GPOS_ASSERT(NULL != m_pplstmt);
-	m_psctranslator = New(m_pmp)
+	m_psctranslator = GPOS_NEW(m_pmp)
 							CTranslatorScalarToDXL
 								(
 								m_pmp,
@@ -101,7 +101,7 @@ CTranslatorPlStmtToDXL::CTranslatorPlStmtToDXL
 								NULL,  // CTE Mapping
 								NULL // pdrgpdxlnCTE
 								);
-	m_phmuldxlnSharedScanProjLists = New(m_pmp) HMUlPdxln(m_pmp);
+	m_phmuldxlnSharedScanProjLists = GPOS_NEW(m_pmp) HMUlPdxln(m_pmp);
 }
 
 //---------------------------------------------------------------------------
@@ -115,7 +115,7 @@ CTranslatorPlStmtToDXL::CTranslatorPlStmtToDXL
 CTranslatorPlStmtToDXL::~CTranslatorPlStmtToDXL()
 {
 	m_phmuldxlnSharedScanProjLists->Release();
-	delete m_psctranslator;
+	GPOS_DELETE(m_psctranslator);
 }
 
 //---------------------------------------------------------------------------
@@ -271,10 +271,10 @@ CTranslatorPlStmtToDXL::PdxlnHashjoinFromPlan
 	EdxlJoinType edxljt = CTranslatorUtils::EdxljtFromJoinType((phj->join).jointype);
 
 	// construct hash join operator
-	CDXLPhysicalHashJoin *pdxlopHj = New(m_pmp) CDXLPhysicalHashJoin(m_pmp, edxljt);
+	CDXLPhysicalHashJoin *pdxlopHj = GPOS_NEW(m_pmp) CDXLPhysicalHashJoin(m_pmp, edxljt);
 
 	// construct hash join operator node
-	CDXLNode *pdxlnHJ = New(m_pmp) CDXLNode(m_pmp, pdxlopHj);
+	CDXLNode *pdxlnHJ = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopHj);
 	pdxlnHJ->SetProperties(pdxlprop);
 
 	// translate left and right child
@@ -298,7 +298,7 @@ CTranslatorPlStmtToDXL::PdxlnHashjoinFromPlan
 	GPOS_ASSERT(pdxlnPrLRight->Pdxlop()->Edxlop() == EdxlopScalarProjectList);
 
 	// translate hash condition
-	CDXLNode *pdxlnHashCondList = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarHashCondList(m_pmp));
+	CDXLNode *pdxlnHashCondList = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarHashCondList(m_pmp));
 
 	List *plHashClauses = NIL;
 
@@ -409,10 +409,10 @@ CTranslatorPlStmtToDXL::PdxlnNLJoinFromPlan
 	BOOL fIndexNLJ = IsA(pplan->righttree, IndexScan);
 
 	// construct nested loop join operator
-	CDXLPhysicalNLJoin *pdxlnlj = New(m_pmp) CDXLPhysicalNLJoin(m_pmp, edxljt, fIndexNLJ);
+	CDXLPhysicalNLJoin *pdxlnlj = GPOS_NEW(m_pmp) CDXLPhysicalNLJoin(m_pmp, edxljt, fIndexNLJ);
 
 	// construct nested loop join operator node
-	CDXLNode *pdxlnNLJ = New(m_pmp) CDXLNode(m_pmp, pdxlnlj);
+	CDXLNode *pdxlnNLJ = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlnlj);
 	pdxlnNLJ->SetProperties(pdxlprop);
 
 	// translate left and right child
@@ -497,10 +497,10 @@ CTranslatorPlStmtToDXL::PdxlnMergeJoinFromPlan
 	EdxlJoinType edxljt = CTranslatorUtils::EdxljtFromJoinType((pmj->join).jointype);
 
 	// construct hash join operator
-	CDXLPhysicalMergeJoin *pdxlopMj = New(m_pmp) CDXLPhysicalMergeJoin(m_pmp, edxljt, pmj->unique_outer);
+	CDXLPhysicalMergeJoin *pdxlopMj = GPOS_NEW(m_pmp) CDXLPhysicalMergeJoin(m_pmp, edxljt, pmj->unique_outer);
 
 	// construct merge join operator node
-	CDXLNode *pdxlnMJ = New(m_pmp) CDXLNode(m_pmp, pdxlopMj);
+	CDXLNode *pdxlnMJ = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopMj);
 	pdxlnMJ->SetProperties(pdxlprop);
 
 	// translate left and right child
@@ -524,7 +524,7 @@ CTranslatorPlStmtToDXL::PdxlnMergeJoinFromPlan
 	GPOS_ASSERT(pdxlnPrLRight->Pdxlop()->Edxlop() == EdxlopScalarProjectList);
 
 	// translate hash condition
-	CDXLNode *pdxlnMergeCondList = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarMergeCondList(m_pmp));
+	CDXLNode *pdxlnMergeCondList = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarMergeCondList(m_pmp));
 
 	m_psctranslator->SetCallingPhysicalOpType(EpspotMergeJoin);
 
@@ -616,7 +616,7 @@ CTranslatorPlStmtToDXL::PdxlnResultFromPlan
 	GPOS_ASSERT(NULL != pdxlprop);
 
 	// construct result operator
-	CDXLPhysicalResult *pdxlopResult = New(m_pmp) CDXLPhysicalResult(m_pmp);
+	CDXLPhysicalResult *pdxlopResult = GPOS_NEW(m_pmp) CDXLPhysicalResult(m_pmp);
 
 	GPOS_ASSERT(innerPlan(pnresult) == NULL && "Result node cannot have right child");
 
@@ -668,7 +668,7 @@ CTranslatorPlStmtToDXL::PdxlnResultFromPlan
 								);
 
 	// construct motion operator node
-	CDXLNode *pdxln = New(m_pmp) CDXLNode(m_pmp, pdxlopResult);
+	CDXLNode *pdxln = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopResult);
 	pdxln->SetProperties(pdxlprop);
 
 	// add children in the right order
@@ -719,20 +719,20 @@ CTranslatorPlStmtToDXL::PdxlnMotionFromPlan
 	{
 		if (0 == pmotion->numOutputSegs)
 		{
-			pdxlopMotion = New(m_pmp) CDXLPhysicalBroadcastMotion(m_pmp);
+			pdxlopMotion = GPOS_NEW(m_pmp) CDXLPhysicalBroadcastMotion(m_pmp);
 		}
 		else
 		{
-			pdxlopMotion = New(m_pmp) CDXLPhysicalGatherMotion(m_pmp);
+			pdxlopMotion = GPOS_NEW(m_pmp) CDXLPhysicalGatherMotion(m_pmp);
 		}
 	}
 	else
 	{
-		pdxlopMotion = New(m_pmp) CDXLPhysicalRedistributeMotion(m_pmp, false /*fDuplicateSensitive*/);
+		pdxlopMotion = GPOS_NEW(m_pmp) CDXLPhysicalRedistributeMotion(m_pmp, false /*fDuplicateSensitive*/);
 	}
 
-	DrgPi *pdrgpiInputSegIds = New(m_pmp) DrgPi(m_pmp);
-	DrgPi *pdrgpiOutputSegIds = New(m_pmp) DrgPi(m_pmp);
+	DrgPi *pdrgpiInputSegIds = GPOS_NEW(m_pmp) DrgPi(m_pmp);
+	DrgPi *pdrgpiOutputSegIds = GPOS_NEW(m_pmp) DrgPi(m_pmp);
 
 	TranslateMotionSegmentInfo(pmotion, pdrgpiInputSegIds, pdrgpiOutputSegIds);
 
@@ -740,7 +740,7 @@ CTranslatorPlStmtToDXL::PdxlnMotionFromPlan
 	pdxlopMotion->SetOutputSegIds(pdrgpiOutputSegIds);
 
 	// construct motion operator node
-	CDXLNode *pdxln = New(m_pmp) CDXLNode(m_pmp, pdxlopMotion);
+	CDXLNode *pdxln = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopMotion);
 	pdxln->SetProperties(pdxlprop);
 
 	// translate child of motion node
@@ -844,7 +844,7 @@ CTranslatorPlStmtToDXL::PdxlnAggFromPlan
 	}
 
 	BOOL fStreamSafe = pagg->streaming;
-	CDXLPhysicalAgg *pdxlopAgg = New(m_pmp) CDXLPhysicalAgg(m_pmp, edxlaggstr, fStreamSafe);
+	CDXLPhysicalAgg *pdxlopAgg = GPOS_NEW(m_pmp) CDXLPhysicalAgg(m_pmp, edxlaggstr, fStreamSafe);
 
 	// translate child of aggregate operator
 	Plan *pplanChild = (pagg->plan).lefttree;
@@ -881,7 +881,7 @@ CTranslatorPlStmtToDXL::PdxlnAggFromPlan
 			     (0 < pagg->numCols && NULL != pagg->grpColIdx));
 
 	// translate output segment cols
-	DrgPul *pdrgpulGroupingCols = New(m_pmp) DrgPul(m_pmp);
+	DrgPul *pdrgpulGroupingCols = GPOS_NEW(m_pmp) DrgPul(m_pmp);
 
 	for(ULONG ul = 0; ul < (ULONG) pagg->numCols; ul++)
 	{
@@ -891,14 +891,14 @@ CTranslatorPlStmtToDXL::PdxlnAggFromPlan
 		CDXLNode *pdxlnGroupingCol = (*pdxlnPrLChild)[ulColIdx-1];
 		CDXLScalarProjElem *pdxlopPrEl = (CDXLScalarProjElem *) pdxlnGroupingCol->Pdxlop();
 
-		ULONG *pulGroupingColId = New(m_pmp) ULONG(pdxlopPrEl->UlId());
+		ULONG *pulGroupingColId = GPOS_NEW(m_pmp) ULONG(pdxlopPrEl->UlId());
 		pdrgpulGroupingCols->Append(pulGroupingColId);
 	}
 
 	pdxlopAgg->SetGroupingCols(pdrgpulGroupingCols);
 
 	// construct aggregate operator node
-	CDXLNode *pdxln = New(m_pmp) CDXLNode(m_pmp, pdxlopAgg);
+	CDXLNode *pdxln = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopAgg);
 	pdxln->SetProperties(pdxlprop);
 
 	// add children in the right order
@@ -962,7 +962,7 @@ CTranslatorPlStmtToDXL::PdxlnWindowFromPlan
 
 	const ULONG ulSize = (ULONG) pwindow->numPartCols;
 	// translate partition columns
-	DrgPul *pdrgpulPartCols = New(m_pmp) DrgPul(m_pmp);
+	DrgPul *pdrgpulPartCols = GPOS_NEW(m_pmp) DrgPul(m_pmp);
 	for(ULONG ul = 0; ul < ulSize; ul++)
 	{
 		ULONG ulColIdx = (ULONG) pwindow->partColIdx[ul];
@@ -971,17 +971,17 @@ CTranslatorPlStmtToDXL::PdxlnWindowFromPlan
 		CDXLNode *pdxlnPartCol = (*pdxlnPrLChild)[ulColIdx-1];
 		CDXLScalarProjElem *pdxlopPrEl = (CDXLScalarProjElem *) pdxlnPartCol->Pdxlop();
 
-		ULONG *pulPartColId = New(m_pmp) ULONG(pdxlopPrEl->UlId());
+		ULONG *pulPartColId = GPOS_NEW(m_pmp) ULONG(pdxlopPrEl->UlId());
 		pdrgpulPartCols->Append(pulPartColId);
 	}
 
 	// add the window keys
-	DrgPdxlwk *pdrgpdxlwk = New(m_pmp) DrgPdxlwk(m_pmp);
+	DrgPdxlwk *pdrgpdxlwk = GPOS_NEW(m_pmp) DrgPdxlwk(m_pmp);
 	ListCell *plcWindowKey = NULL;
 	ForEach (plcWindowKey, pwindow->windowKeys)
 	{
 		WindowKey *pwindowkey = (WindowKey *) lfirst(plcWindowKey);
-		CDXLWindowKey *pdxlWindowKey = New(m_pmp) CDXLWindowKey(m_pmp);
+		CDXLWindowKey *pdxlWindowKey = GPOS_NEW(m_pmp) CDXLWindowKey(m_pmp);
 
 		CDXLNode *pdxlnSortColList = PdxlnSortingColListFromPlan
 										(
@@ -1010,8 +1010,8 @@ CTranslatorPlStmtToDXL::PdxlnWindowFromPlan
 	}
 
 	// construct window operator node
-	CDXLPhysicalWindow *pdxlopWindow = New(m_pmp) CDXLPhysicalWindow(m_pmp, pdrgpulPartCols, pdrgpdxlwk);
-	CDXLNode *pdxln = New(m_pmp) CDXLNode(m_pmp, pdxlopWindow);
+	CDXLPhysicalWindow *pdxlopWindow = GPOS_NEW(m_pmp) CDXLPhysicalWindow(m_pmp, pdrgpulPartCols, pdrgpdxlwk);
+	CDXLNode *pdxln = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopWindow);
 
 	// extract plan properties
 	CDXLPhysicalProperties *pdxlprop = PdxlpropFromPlan(pplan);
@@ -1108,7 +1108,7 @@ CTranslatorPlStmtToDXL::PdxlnSortFromPlan
 	// TODO: antovl - Jan 19, 2011; currently GPDB supports only nullsLast behavior
 	GPOS_ASSERT(NULL == psort->nullsFirst);
 
-	CDXLPhysicalSort *pdxlopSort = New(m_pmp) CDXLPhysicalSort(m_pmp, psort->noduplicates);
+	CDXLPhysicalSort *pdxlopSort = GPOS_NEW(m_pmp) CDXLPhysicalSort(m_pmp, psort->noduplicates);
 
 	// translate child of sort operator
 	Plan *pplanChild = (psort->plan).lefttree;
@@ -1147,8 +1147,8 @@ CTranslatorPlStmtToDXL::PdxlnSortFromPlan
 
 	// translate limit information
 
-	CDXLNode *pdxlnLimitCount = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarLimitCount(m_pmp));
-	CDXLNode *pdxlnLimitOffset = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarLimitOffset(m_pmp));
+	CDXLNode *pdxlnLimitCount = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarLimitCount(m_pmp));
+	CDXLNode *pdxlnLimitOffset = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarLimitOffset(m_pmp));
 
 	if (NULL != psort->limitCount)
 	{
@@ -1179,7 +1179,7 @@ CTranslatorPlStmtToDXL::PdxlnSortFromPlan
 
 
 	// construct sort operator node
-	CDXLNode *pdxln = New(m_pmp) CDXLNode(m_pmp, pdxlopSort);
+	CDXLNode *pdxln = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopSort);
 	pdxln->SetProperties(pdxlprop);
 
 	// add children in the right order
@@ -1224,11 +1224,11 @@ CTranslatorPlStmtToDXL::PdxlnSubqueryScanFromPlan
 
 	CWStringDynamic *pstrSubqName = CDXLUtils::PstrFromSz(m_pmp, szSubqName);
 	// copy table name
-	CMDName *pmdnameSubqScan = New(m_pmp) CMDName(m_pmp, pstrSubqName);
-	delete pstrSubqName;
+	CMDName *pmdnameSubqScan = GPOS_NEW(m_pmp) CMDName(m_pmp, pstrSubqName);
+	GPOS_DELETE(pstrSubqName);
 
 	// construct DXL subquery scan operator
-	CDXLPhysicalSubqueryScan *pdxlopSubqScan = New(m_pmp) CDXLPhysicalSubqueryScan(m_pmp, pmdnameSubqScan);
+	CDXLPhysicalSubqueryScan *pdxlopSubqScan = GPOS_NEW(m_pmp) CDXLPhysicalSubqueryScan(m_pmp, pmdnameSubqScan);
 
 	// translate child of subquery operator
 	Plan *pplanChild = psubqscan->subplan;
@@ -1245,11 +1245,11 @@ CTranslatorPlStmtToDXL::PdxlnSubqueryScanFromPlan
 	// construct a fake table descriptor for the subquery scan
 	// since the project list and filter refer to the rtable rather than OUTER
 	// construct projection list and filter
-	CDXLTableDescr *pdxltabdesc = New(m_pmp) CDXLTableDescr
+	CDXLTableDescr *pdxltabdesc = GPOS_NEW(m_pmp) CDXLTableDescr
 											(
 											m_pmp,
-											New(m_pmp) CMDIdGPDB(CMDIdGPDB::m_mdidInvalidKey.OidObjectId()),
-											New(m_pmp) CMDName(pmdnameSubqScan->Pstr()),
+											GPOS_NEW(m_pmp) CMDIdGPDB(CMDIdGPDB::m_mdidInvalidKey.OidObjectId()),
+											GPOS_NEW(m_pmp) CMDName(pmdnameSubqScan->Pstr()),
 											prte->checkAsUser
 											);
 
@@ -1273,22 +1273,22 @@ CTranslatorPlStmtToDXL::PdxlnSubqueryScanFromPlan
 		CWStringDynamic *pstrColName = CDXLUtils::PstrFromSz(m_pmp, szColName);
 
 		// copy string into column name
-		CMDName *pmdnameColName = New(m_pmp) CMDName(m_pmp, pstrColName);
+		CMDName *pmdnameColName = GPOS_NEW(m_pmp) CMDName(m_pmp, pstrColName);
 
-		delete pstrColName;
+		GPOS_DELETE(pstrColName);
 
 		// get column id from the subplan's target list
 		CDXLNode *pdxlnPrEl = (*pdxlnPrLChild)[ulAttno-1];
 		ULONG ulId = ((CDXLScalarProjElem *) pdxlnPrEl->Pdxlop())->UlId();
 
 		// create a column descriptor for the column
-		CDXLColDescr *pdxlcd = New(m_pmp) CDXLColDescr
+		CDXLColDescr *pdxlcd = GPOS_NEW(m_pmp) CDXLColDescr
 											(
 											m_pmp,
 											pmdnameColName,
 											ulId,
 											ulAttno,
-											New(m_pmp) CMDIdGPDB(CMDIdGPDB::m_mdidInvalidKey.OidObjectId()),
+											GPOS_NEW(m_pmp) CMDIdGPDB(CMDIdGPDB::m_mdidInvalidKey.OidObjectId()),
 											fColDropped
 											);
 
@@ -1315,7 +1315,7 @@ CTranslatorPlStmtToDXL::PdxlnSubqueryScanFromPlan
 		);
 
 	// construct sort operator node
-	CDXLNode *pdxln = New(m_pmp) CDXLNode(m_pmp, pdxlopSubqScan);
+	CDXLNode *pdxln = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopSubqScan);
 	pdxln->SetProperties(pdxlprop);
 
 	// add children in the right order
@@ -1358,9 +1358,9 @@ CTranslatorPlStmtToDXL::PdxlnAppendFromPlan
 	GPOS_ASSERT(NULL != pdxlprop);
 
 	// construct DXL Append operator
-	CDXLPhysicalAppend *pdxlopAppend = New(m_pmp) CDXLPhysicalAppend(m_pmp, pappend->isTarget, pappend->isZapped);
+	CDXLPhysicalAppend *pdxlopAppend = GPOS_NEW(m_pmp) CDXLPhysicalAppend(m_pmp, pappend->isTarget, pappend->isZapped);
 
-	CDXLNode *pdxln = New(m_pmp) CDXLNode(m_pmp, pdxlopAppend);
+	CDXLNode *pdxln = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopAppend);
 	pdxln->SetProperties(pdxlprop);
 
 	// translate first child of append operator so we can translate the project list
@@ -1427,33 +1427,33 @@ CTranslatorPlStmtToDXL::PdxlnResultFromFoldedFuncExpr
 	CMappingVarColId *pmapvarcolid
 	)
 {
-	CDXLNode *pdxlnPrL = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarProjList(m_pmp));
+	CDXLNode *pdxlnPrL = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarProjList(m_pmp));
 
 	// construct a scalar operator for the expression
 	CDXLNode *pdxlnChild = m_psctranslator->PdxlnScOpFromExpr(pexpr, pmapvarcolid);
 
 	ULONG ulPrElId = m_pidgtor->UlNextId();
-	CMDName *pmdnameAlias = New(m_pmp) CMDName(m_pmp, pstrAlias);
+	CMDName *pmdnameAlias = GPOS_NEW(m_pmp) CMDName(m_pmp, pstrAlias);
 
-	CDXLNode *pdxlnPrEl = New(m_pmp) CDXLNode
+	CDXLNode *pdxlnPrEl = GPOS_NEW(m_pmp) CDXLNode
 										(
 										m_pmp,
-										New(m_pmp) CDXLScalarProjElem(m_pmp, ulPrElId, pmdnameAlias)
+										GPOS_NEW(m_pmp) CDXLScalarProjElem(m_pmp, ulPrElId, pmdnameAlias)
 										);
 	pdxlnPrEl->AddChild(pdxlnChild);
 
 	// add proj elem to proj list
 	pdxlnPrL->AddChild(pdxlnPrEl);
 
-	CDXLPhysicalResult *pdxlopResult = New(m_pmp) CDXLPhysicalResult(m_pmp);
+	CDXLPhysicalResult *pdxlopResult = GPOS_NEW(m_pmp) CDXLPhysicalResult(m_pmp);
 
-	CDXLNode *pdxlnFilter = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarFilter(m_pmp));
+	CDXLNode *pdxlnFilter = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarFilter(m_pmp));
 
 	pmapvarcolid->LoadProjectElements(DEFAULT_QUERY_LEVEL, OUTER, pdxlnPrL);
 
-	CDXLNode *pdxlnOneTimeFilter = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarOneTimeFilter(m_pmp));
+	CDXLNode *pdxlnOneTimeFilter = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarOneTimeFilter(m_pmp));
 
-	CDXLNode *pdxln = New(m_pmp) CDXLNode(m_pmp, pdxlopResult);
+	CDXLNode *pdxln = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopResult);
 	pdxln->SetProperties(pdxlprop);
 
 	pdxln->AddChild(pdxlnPrL);
@@ -1507,7 +1507,7 @@ CTranslatorPlStmtToDXL::PdxlnFunctionScanFromPlan
 							pdxlprop,
 							&mapvarcolid
 							);
-		delete pstrAlias;
+		GPOS_DELETE(pstrAlias);
 
 		return pdxln;
 	}
@@ -1516,11 +1516,11 @@ CTranslatorPlStmtToDXL::PdxlnFunctionScanFromPlan
 	CMDIdGPDB *pmdidFunc = CTranslatorUtils::PmdidWithVersion(m_pmp, pfuncexpr->funcid);
 	CMDIdGPDB *pmdidRetType = CTranslatorUtils::PmdidWithVersion(m_pmp, pfuncexpr->funcresulttype);
 
-	CWStringConst *pstrFunc = New(m_pmp) CWStringConst(m_pmp, pstrAlias->Wsz());
-	delete pstrAlias;
-	CDXLPhysicalTVF *pdxlop = New(m_pmp) CDXLPhysicalTVF(m_pmp, pmdidFunc, pmdidRetType, pstrFunc);
+	CWStringConst *pstrFunc = GPOS_NEW(m_pmp) CWStringConst(m_pmp, pstrAlias->Wsz());
+	GPOS_DELETE(pstrAlias);
+	CDXLPhysicalTVF *pdxlop = GPOS_NEW(m_pmp) CDXLPhysicalTVF(m_pmp, pmdidFunc, pmdidRetType, pstrFunc);
 
-	CDXLNode *pdxlnTVF = New(m_pmp) CDXLNode(m_pmp, pdxlop);
+	CDXLNode *pdxlnTVF = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlop);
 	// add properties
 	pdxlnTVF->SetProperties(pdxlprop);
 
@@ -1582,9 +1582,9 @@ CTranslatorPlStmtToDXL::PdxlnTblScanFromPlan
 	// get plan costs
 	CDXLPhysicalProperties *pdxlprop = PdxlpropFromPlan(pplan);
 
-	CDXLPhysicalTableScan *pdxlopTS = New(m_pmp) CDXLPhysicalTableScan(m_pmp, pdxltabdesc);
+	CDXLPhysicalTableScan *pdxlopTS = GPOS_NEW(m_pmp) CDXLPhysicalTableScan(m_pmp, pdxltabdesc);
 
-	CDXLNode *pdxlnTblScan = New(m_pmp) CDXLNode(m_pmp, pdxlopTS);
+	CDXLNode *pdxlnTblScan = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopTS);
 	pdxlnTblScan->SetProperties(pdxlprop);
 
 	// construct projection list and filter
@@ -1679,14 +1679,14 @@ CTranslatorPlStmtToDXL::PdxlnIndexScanFromGPDBIndexScan
 
 	GPOS_ASSERT(!fIndexOnlyScan);
 	//{
-	//	pdxlop = New(m_pmp) CDXLPhysicalIndexOnlyScan(m_pmp, pdxltabdesc, pdxlid, edxlissd);
+	//	pdxlop = GPOS_NEW(m_pmp) CDXLPhysicalIndexOnlyScan(m_pmp, pdxltabdesc, pdxlid, edxlissd);
 	//}
 	//else
 	//{
-		pdxlop = New(m_pmp) CDXLPhysicalIndexScan(m_pmp, pdxltabdesc, pdxlid, edxlissd);
+		pdxlop = GPOS_NEW(m_pmp) CDXLPhysicalIndexScan(m_pmp, pdxltabdesc, pdxlid, edxlissd);
 	//}
 
-	CDXLNode *pdxlnIndexScan = New(m_pmp) CDXLNode(m_pmp, pdxlop);
+	CDXLNode *pdxlnIndexScan = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlop);
 
 	// get plan costs
 	CDXLPhysicalProperties *pdxlprop = PdxlpropFromPlan((Plan *)pindexscan);
@@ -1701,7 +1701,7 @@ CTranslatorPlStmtToDXL::PdxlnIndexScanFromGPDBIndexScan
 	}
 
 	// translate index condition
-	CDXLNode *pdxlnIdxCondList = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarIndexCondList(m_pmp));
+	CDXLNode *pdxlnIdxCondList = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarIndexCondList(m_pmp));
 
 	ListCell *plcQual = NULL;
 	ForEach (plcQual, pindexscan->indexqual)
@@ -1763,8 +1763,8 @@ CTranslatorPlStmtToDXL::PdxlnLimitFromPlan
 	// get plan costs
 	CDXLPhysicalProperties *pdxlprop = PdxlpropFromPlan(pplan);
 
-	CDXLPhysicalLimit *pdxlopLimit = New(m_pmp) CDXLPhysicalLimit(m_pmp);
-	CDXLNode *pdxlnLimit = New(m_pmp) CDXLNode(m_pmp, pdxlopLimit);
+	CDXLPhysicalLimit *pdxlopLimit = GPOS_NEW(m_pmp) CDXLPhysicalLimit(m_pmp);
+	CDXLNode *pdxlnLimit = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopLimit);
 	pdxlnLimit->SetProperties(pdxlprop);
 
 	Plan *pplanChildPlan = outerPlan(plimit);
@@ -1787,8 +1787,8 @@ CTranslatorPlStmtToDXL::PdxlnLimitFromPlan
 	pdxlnLimit->AddChild(pdxlnPrL); 		// project list
 	pdxlnLimit->AddChild(pdxlnChildPlan);
 
-	CDXLScalarLimitCount *pdxlopLimitCount = New(m_pmp) CDXLScalarLimitCount(m_pmp);
-	CDXLNode *pdxlnLimitCount = New(m_pmp) CDXLNode(m_pmp, pdxlopLimitCount);
+	CDXLScalarLimitCount *pdxlopLimitCount = GPOS_NEW(m_pmp) CDXLScalarLimitCount(m_pmp);
+	CDXLNode *pdxlnLimitCount = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopLimitCount);
 
 	if(NULL != plimit->limitCount)
 	{
@@ -1801,8 +1801,8 @@ CTranslatorPlStmtToDXL::PdxlnLimitFromPlan
 	}
 	pdxlnLimit->AddChild(pdxlnLimitCount);
 
-	CDXLScalarLimitOffset *pdxlopLimitOffset = New(m_pmp) CDXLScalarLimitOffset(m_pmp);
-	CDXLNode *pdxlnLimitOffset = New(m_pmp) CDXLNode(m_pmp, pdxlopLimitOffset);
+	CDXLScalarLimitOffset *pdxlopLimitOffset = GPOS_NEW(m_pmp) CDXLScalarLimitOffset(m_pmp);
+	CDXLNode *pdxlnLimitOffset = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopLimitOffset);
 
 	if(NULL != plimit->limitOffset)
 	{
@@ -1843,15 +1843,15 @@ CTranslatorPlStmtToDXL::PdxlnMaterializeFromPlan
 	if (SHARE_NOTSHARED == pmat->share_type)
 	{
 		// materialize node is not shared
-		pdxlopMat = New(m_pmp) CDXLPhysicalMaterialize(m_pmp, pmat->cdb_strict);
+		pdxlopMat = GPOS_NEW(m_pmp) CDXLPhysicalMaterialize(m_pmp, pmat->cdb_strict);
 	}
 	else
 	{
 		// create a shared materialize node
-		pdxlopMat = New(m_pmp) CDXLPhysicalMaterialize(m_pmp, pmat->cdb_strict, pmat->share_id, pmat->driver_slice, pmat->nsharer_xslice);
+		pdxlopMat = GPOS_NEW(m_pmp) CDXLPhysicalMaterialize(m_pmp, pmat->cdb_strict, pmat->share_id, pmat->driver_slice, pmat->nsharer_xslice);
 	}
 
-	CDXLNode *pdxlnMaterialize = New(m_pmp) CDXLNode(m_pmp, pdxlopMat);
+	CDXLNode *pdxlnMaterialize = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopMat);
 	pdxlnMaterialize->SetProperties(pdxlprop);
 
 	Plan *pplanChildPlan = outerPlan(pmat);
@@ -1910,8 +1910,8 @@ CTranslatorPlStmtToDXL::PdxlnSharedScanFromPlan
  	CDXLPhysicalSharedScan *pdxlopShScan = NULL;
 
 	CDXLSpoolInfo *pspoolinfo = PspoolinfoFromSharedScan(pshscan);
-	pdxlopShScan = New(m_pmp) CDXLPhysicalSharedScan(m_pmp, pspoolinfo);
-	CDXLNode *pdxlnSharedScan = New(m_pmp) CDXLNode(m_pmp, pdxlopShScan);
+	pdxlopShScan = GPOS_NEW(m_pmp) CDXLPhysicalSharedScan(m_pmp, pspoolinfo);
+	CDXLNode *pdxlnSharedScan = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopShScan);
 	pdxlnSharedScan->SetProperties(pdxlprop);
 
 	Plan *pplanChildPlan = outerPlan(pshscan);
@@ -1958,7 +1958,7 @@ CTranslatorPlStmtToDXL::PdxlnSharedScanFromPlan
 	if (NULL != pplanChildPlan)
 	{
 		// first encounter of this shared scan id: store the translated proj list
-		ULONG *pulSharedScanId = New(m_pmp) ULONG(pshscan->share_id);
+		ULONG *pulSharedScanId = GPOS_NEW(m_pmp) ULONG(pshscan->share_id);
 
 		pdxlnPrL->AddRef();
 #ifdef GPOS_DEBUG
@@ -2007,9 +2007,9 @@ CTranslatorPlStmtToDXL::PdxlnSequence
 	GPOS_ASSERT(NULL != pdxlprop);
 
 	// construct DXL sequence operator
-	CDXLPhysicalSequence *pdxlop = New(m_pmp) CDXLPhysicalSequence(m_pmp);
+	CDXLPhysicalSequence *pdxlop = GPOS_NEW(m_pmp) CDXLPhysicalSequence(m_pmp);
 
-	CDXLNode *pdxln = New(m_pmp) CDXLNode(m_pmp, pdxlop);
+	CDXLNode *pdxln = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlop);
 	pdxln->SetProperties(pdxlprop);
 
 	// translate last child of sequence operator so we can translate the project list
@@ -2082,9 +2082,9 @@ CTranslatorPlStmtToDXL::PdxlnDynamicTableScan
 
 	CDXLTableDescr *pdxltabdesc = CTranslatorUtils::Pdxltabdesc(m_pmp, m_pmda, m_pidgtor, prte);
 
-	CDXLPhysicalDynamicTableScan *pdxlop = New(m_pmp) CDXLPhysicalDynamicTableScan(m_pmp, pdxltabdesc, pdts->partIndex, pdts->partIndexPrintable);
+	CDXLPhysicalDynamicTableScan *pdxlop = GPOS_NEW(m_pmp) CDXLPhysicalDynamicTableScan(m_pmp, pdxltabdesc, pdts->partIndex, pdts->partIndexPrintable);
 
-	CDXLNode *pdxln = New(m_pmp) CDXLNode(m_pmp, pdxlop);
+	CDXLNode *pdxln = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlop);
 	pdxln->SetProperties(pdxlprop);
 
 	// construct projection list
@@ -2188,7 +2188,7 @@ CTranslatorPlStmtToDXL::PdxlnPrLFromTL
 	CMappingVarColId *pmapvarcolid
 	)
 {
-	CDXLNode *pdxlnPrL = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarProjList(m_pmp));
+	CDXLNode *pdxlnPrL = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarProjList(m_pmp));
 	ListCell *plcte = NULL;
 
 	// construct a proj list node for each entry in the target list
@@ -2208,9 +2208,9 @@ CTranslatorPlStmtToDXL::PdxlnPrLFromTL
 		if (NULL != pte->resname)
 		{
 			CWStringDynamic *pstrAlias = CDXLUtils::PstrFromSz(m_pmp, pte->resname);
-			pmdnameAlias = New(m_pmp) CMDName(m_pmp, pstrAlias);
+			pmdnameAlias = GPOS_NEW(m_pmp) CMDName(m_pmp, pstrAlias);
 			// CName constructor copies string
-			delete pstrAlias;
+			GPOS_DELETE(pstrAlias);
 		}
 
 		if (IsA(pte->expr, Var))
@@ -2223,7 +2223,7 @@ CTranslatorPlStmtToDXL::PdxlnPrLFromTL
 			if (NULL == pte->resname)
 			{
 				// no alias provided - create a copy of the original column name
-				pmdnameAlias = New(m_pmp) CMDName
+				pmdnameAlias = GPOS_NEW(m_pmp) CMDName
 											(
 											m_pmp,
 											pdxlopIdent->Pdxlcr()->Pmdname()->Pstr()
@@ -2239,17 +2239,17 @@ CTranslatorPlStmtToDXL::PdxlnPrLFromTL
 			{
 				// no column name - make up one
 				CWStringConst strUnnamedCol(GPOS_WSZ_LIT("?column?"));
-				pmdnameAlias = New(m_pmp) CMDName(m_pmp, &strUnnamedCol);
+				pmdnameAlias = GPOS_NEW(m_pmp) CMDName(m_pmp, &strUnnamedCol);
 			}
 		}
 
 		GPOS_ASSERT(NULL != pmdnameAlias);
 
 		// construct a projection element operator
-		pdxlopPrEl = New(m_pmp) CDXLScalarProjElem(m_pmp, ulPrElId, pmdnameAlias);
+		pdxlopPrEl = GPOS_NEW(m_pmp) CDXLScalarProjElem(m_pmp, ulPrElId, pmdnameAlias);
 
 		// create the DXL node holding the proj elem
-		CDXLNode *pdxlnPrEl = New(m_pmp) CDXLNode(m_pmp, pdxlopPrEl);
+		CDXLNode *pdxlnPrEl = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopPrEl);
 		pdxlnPrEl->AddChild(pdxlnChild);
 
 		// add proj elem to proj list
@@ -2276,10 +2276,10 @@ CTranslatorPlStmtToDXL::PdxlpropFromPlan
 	const Plan *pplan
 	)
 {
-	CWStringDynamic *pstrTotalCost = New(m_pmp) CWStringDynamic(m_pmp);
-	CWStringDynamic *pstrStartupCost = New(m_pmp) CWStringDynamic(m_pmp);
-	CWStringDynamic *pstrRows = New(m_pmp) CWStringDynamic(m_pmp);
-	CWStringDynamic *pstrWidth = New(m_pmp) CWStringDynamic(m_pmp);
+	CWStringDynamic *pstrTotalCost = GPOS_NEW(m_pmp) CWStringDynamic(m_pmp);
+	CWStringDynamic *pstrStartupCost = GPOS_NEW(m_pmp) CWStringDynamic(m_pmp);
+	CWStringDynamic *pstrRows = GPOS_NEW(m_pmp) CWStringDynamic(m_pmp);
+	CWStringDynamic *pstrWidth = GPOS_NEW(m_pmp) CWStringDynamic(m_pmp);
 
 	const WCHAR wszFormat[] = GPOS_WSZ_LIT("%.2f");
 	pstrTotalCost->AppendFormat(wszFormat, pplan->total_cost);
@@ -2287,14 +2287,14 @@ CTranslatorPlStmtToDXL::PdxlpropFromPlan
 	pstrStartupCost->AppendFormat(wszFormat, pplan->startup_cost);
 	pstrRows->AppendFormat(wszFormat, pplan->plan_rows);
 
-	CDXLOperatorCost *pdxlopcost = New(m_pmp) CDXLOperatorCost
+	CDXLOperatorCost *pdxlopcost = GPOS_NEW(m_pmp) CDXLOperatorCost
 												(
 												pstrStartupCost,
 												pstrTotalCost,
 												pstrRows,
 												pstrWidth
 												);
-	CDXLPhysicalProperties *pdxlprop = New(m_pmp) CDXLPhysicalProperties(pdxlopcost);
+	CDXLPhysicalProperties *pdxlprop = GPOS_NEW(m_pmp) CDXLPhysicalProperties(pdxlopcost);
 
 	return pdxlprop;
 }
@@ -2321,7 +2321,7 @@ CTranslatorPlStmtToDXL::PdxlnHashExprLFromList
 	GPOS_ASSERT(NULL != plHashExprTypes);
 	GPOS_ASSERT(gpdb::UlListLength(plHashExpr) == gpdb::UlListLength(plHashExprTypes));
 
-	CDXLNode *pdxlnHashExprList = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarHashExprList(m_pmp));
+	CDXLNode *pdxlnHashExprList = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarHashExprList(m_pmp));
 
 	ListCell *plcHashExpr = NULL;
 	ListCell *plcHashExprType = NULL;
@@ -2335,7 +2335,7 @@ CTranslatorPlStmtToDXL::PdxlnHashExprLFromList
 
 		// construct a DXL hash expression node from the hash expression type id and the translated expression
 		CMDIdGPDB *pmdidExprType = CTranslatorUtils::PmdidWithVersion(m_pmp, oid);
-		CDXLNode *pdxlnHashExpr = New(m_pmp) CDXLNode(m_pmp, New(m_pmp) CDXLScalarHashExpr(m_pmp, pmdidExprType));
+		CDXLNode *pdxlnHashExpr = GPOS_NEW(m_pmp) CDXLNode(m_pmp, GPOS_NEW(m_pmp) CDXLScalarHashExpr(m_pmp, pmdidExprType));
 
 		CMappingVarColId mapvarcolid(m_pmp);
 
@@ -2371,8 +2371,8 @@ CTranslatorPlStmtToDXL::PdxlnSortingColListFromPlan
 	const CDXLNode *pdxlnPrL
 	)
 {
-	CDXLScalarSortColList *pdxlopSortColList = New(m_pmp) CDXLScalarSortColList(m_pmp);
-	CDXLNode *pdxlnSortColList = New(m_pmp) CDXLNode(m_pmp, pdxlopSortColList);
+	CDXLScalarSortColList *pdxlopSortColList = GPOS_NEW(m_pmp) CDXLScalarSortColList(m_pmp);
+	CDXLNode *pdxlnSortColList = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopSortColList);
 
 	if (0 == ulNumCols)
 	{
@@ -2404,16 +2404,16 @@ CTranslatorPlStmtToDXL::PdxlnSortingColListFromPlan
 
 		// TODO: antovl - Jan 19, 2011; read nullsFirst from the plan node;
 		// currently GPDB does not support this
-		CDXLScalarSortCol *pdxlopSortCol = New(m_pmp) CDXLScalarSortCol
+		CDXLScalarSortCol *pdxlopSortCol = GPOS_NEW(m_pmp) CDXLScalarSortCol
 													(
 													m_pmp,
 													ulSortColId,
 													pmdidSortOp,
-													New(m_pmp) CWStringConst(pstrSortOpName->Wsz()),
+													GPOS_NEW(m_pmp) CWStringConst(pstrSortOpName->Wsz()),
 													false	// nullsFirst
 													);
 
-		CDXLNode *pdxlnSortCol = New(m_pmp) CDXLNode(m_pmp, pdxlopSortCol);
+		CDXLNode *pdxlnSortCol = GPOS_NEW(m_pmp) CDXLNode(m_pmp, pdxlopSortCol);
 		pdxlnSortColList->AddChild(pdxlnSortCol);
 	}
 
@@ -2447,7 +2447,7 @@ CTranslatorPlStmtToDXL::TranslateMotionSegmentInfo
 	if (pChildFlow->flotype == FLOW_SINGLETON)
 	{
 		// only one segment sends data
-		INT *piInputSegId = New(m_pmp) INT(pChildFlow->segindex);
+		INT *piInputSegId = GPOS_NEW(m_pmp) INT(pChildFlow->segindex);
 		pdrgpiInputSegIds->Append(piInputSegId);
 	}
 	else
@@ -2455,7 +2455,7 @@ CTranslatorPlStmtToDXL::TranslateMotionSegmentInfo
 		// all segments send data
 		for (ULONG ul = 0; ul < ulSegmentCount; ul++)
 		{
-			INT *piInputSegId = New(m_pmp) INT(ul);
+			INT *piInputSegId = GPOS_NEW(m_pmp) INT(ul);
 			pdrgpiInputSegIds->Append(piInputSegId );
 		}
 	}
@@ -2468,7 +2468,7 @@ CTranslatorPlStmtToDXL::TranslateMotionSegmentInfo
 
 		for(ULONG ul = 0; ul < (ULONG) pmotion->numOutputSegs; ul++)
 		{
-			INT *piSegId = New(m_pmp) INT(pmotion->outputSegIdx[ul]);
+			INT *piSegId = GPOS_NEW(m_pmp) INT(pmotion->outputSegIdx[ul]);
 			pdrgpiOutputSegIds->Append(piSegId);
 		}
 	}
@@ -2477,7 +2477,7 @@ CTranslatorPlStmtToDXL::TranslateMotionSegmentInfo
 		// gather motion
 		GPOS_ASSERT(1 == pmotion->numOutputSegs);
 
-		INT *piOutputSegId = New(m_pmp) INT(pmotion->outputSegIdx[0]);
+		INT *piOutputSegId = GPOS_NEW(m_pmp) INT(pmotion->outputSegIdx[0]);
 		pdrgpiOutputSegIds->Append(piOutputSegId);
 	}
 	else
@@ -2485,7 +2485,7 @@ CTranslatorPlStmtToDXL::TranslateMotionSegmentInfo
 		// broadcast motion
 		for (ULONG ul = 0; ul < ulSegmentCount; ul++)
 		{
-			INT *piOutputSegId = New(m_pmp) INT(ul);
+			INT *piOutputSegId = GPOS_NEW(m_pmp) INT(ul);
 			pdrgpiOutputSegIds->Append(piOutputSegId);
 		}
 	}
@@ -2534,7 +2534,7 @@ CTranslatorPlStmtToDXL::PspoolinfoFromSharedScan
 		fMultiSlice = true;
 	}
 
-	CDXLSpoolInfo *pspoolinfo = New(m_pmp) CDXLSpoolInfo(pshscan->share_id, edxlsptype, fMultiSlice, pshscan->driver_slice);
+	CDXLSpoolInfo *pspoolinfo = GPOS_NEW(m_pmp) CDXLSpoolInfo(pshscan->share_id, edxlsptype, fMultiSlice, pshscan->driver_slice);
 	return pspoolinfo;
 }
 


Mime
View raw message