You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by se...@apache.org on 2017/08/31 05:08:55 UTC

[3/7] incubator-trafodion git commit: [TRAFODION-2727] Memory leak in the compiler part of the code in Trafodion

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/35a656be/core/sql/optimizer/SynthType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/SynthType.cpp b/core/sql/optimizer/SynthType.cpp
index c7362f6..1445562 100644
--- a/core/sql/optimizer/SynthType.cpp
+++ b/core/sql/optimizer/SynthType.cpp
@@ -748,30 +748,29 @@ static const NAType *synthAvgSum(const NAType& operand,
 	    {
 	      if (scale > 0)
 		return new HEAP
-		  SQLNumeric(8, // length = 8 bytes
+		  SQLNumeric(HEAP, 8, // length = 8 bytes
 			     precision,
 			     scale,
                              (precision > 9 ? TRUE : type->isSigned()),
 			     aggNeedsToBeNullable);
 
 	      else
-		return new HEAP SQLLargeInt(TRUE, aggNeedsToBeNullable);
+		return new HEAP SQLLargeInt(HEAP, TRUE, aggNeedsToBeNullable);
 
 	    }
 	  else
             {
 	      return new HEAP
-	        SQLBigNum(precision,
+	        SQLBigNum(HEAP, precision,
 			  scale,
 			  isARealBigNum,
 			  type->isSigned(),
-			  aggNeedsToBeNullable,
-			  NULL);
+			  aggNeedsToBeNullable);
             }
 	}
       else
 	{
-	  return new HEAP SQLDoublePrecision(aggNeedsToBeNullable);
+	  return new HEAP SQLDoublePrecision(HEAP, aggNeedsToBeNullable);
 	}
     }
   break;
@@ -782,7 +781,7 @@ static const NAType *synthAvgSum(const NAType& operand,
       if (type->isSupportedType())
       {
        return new HEAP
-         SQLInterval(aggNeedsToBeNullable,
+         SQLInterval(HEAP, aggNeedsToBeNullable,
                      type->getStartField(),
                      type->computeLeadingPrecision(type->getStartField(),
                                                    MAX_NUMERIC_PRECISION,
@@ -925,7 +924,7 @@ const NAType *ItemExpr::synthesizeType()
 {
   if (getArity() > 0)
     return &child(0)->castToItemExpr()->getValueId().getType();
-  return new HEAP SQLUnknown();
+  return new HEAP SQLUnknown(HEAP);
 }
 
 // Propagate type information down the ItemExpr tree.
@@ -993,7 +992,7 @@ const NAType *BuiltinFunction::synthesizeType()
 	ValueId vid1 = child(0)->getValueId();
 
 	// untyped param operands are typed as Int32 Unsigned.
-	SQLInt si(FALSE);
+	SQLInt si(NULL, FALSE);
 	vid1.coerceType(si, NA_NUMERIC_TYPE);
 
 	const NAType &typ1 = vid1.getType();
@@ -1005,17 +1004,17 @@ const NAType *BuiltinFunction::synthesizeType()
 	if ( typ1.getTypeQualifier() == NA_CHARACTER_TYPE &&
 	     typ1.isVaryingLen() == TRUE )
 	  retType = new HEAP
-	    SQLVarChar(maxLength, typ1.supportsSQLnull());
+	    SQLVarChar(HEAP, maxLength, typ1.supportsSQLnull());
 	else
 	  retType = new HEAP
-	    SQLChar(maxLength, typ1.supportsSQLnull());
+	    SQLChar(HEAP, maxLength, typ1.supportsSQLnull());
       }
     break;
     case ITM_SHA1:
       {
         // type cast any params
         ValueId vid1 = child(0)->getValueId();
-        SQLChar c1(ComSqlId::MAX_QUERY_ID_LEN);
+        SQLChar c1(NULL, ComSqlId::MAX_QUERY_ID_LEN);
         vid1.coerceType(c1, NA_CHARACTER_TYPE);
         //input type must be string
         const NAType &typ1 = child(0)->getValueId().getType();
@@ -1027,7 +1026,7 @@ const NAType *BuiltinFunction::synthesizeType()
           }
 
         retType = new HEAP
-           SQLChar(128, FALSE);
+           SQLChar(HEAP, 128, FALSE);
 	if (typ1.supportsSQLnull())
 	  {
 	    retType->setNullable(TRUE);
@@ -1041,7 +1040,7 @@ const NAType *BuiltinFunction::synthesizeType()
     case ITM_SHA2_512:
       {
         ValueId vid1 = child(0)->getValueId();
-        SQLChar c1(ComSqlId::MAX_QUERY_ID_LEN);
+        SQLChar c1(NULL, ComSqlId::MAX_QUERY_ID_LEN);
         vid1.coerceType(c1, NA_CHARACTER_TYPE);
 
         const NAType &typ1 = child(0)->getValueId().getType();
@@ -1070,7 +1069,7 @@ const NAType *BuiltinFunction::synthesizeType()
             break;
         }
         retType = new HEAP
-          SQLChar(resultLen, typ1.supportsSQLnull());
+          SQLChar(HEAP, resultLen, typ1.supportsSQLnull());
       }
     break;
 
@@ -1078,7 +1077,7 @@ const NAType *BuiltinFunction::synthesizeType()
       {
         // type cast any params
         ValueId vid1 = child(0)->getValueId();
-        SQLChar c1(ComSqlId::MAX_QUERY_ID_LEN);
+        SQLChar c1(NULL, ComSqlId::MAX_QUERY_ID_LEN);
         vid1.coerceType(c1, NA_CHARACTER_TYPE);
         //input type must be string
         const NAType &typ1 = child(0)->getValueId().getType();
@@ -1090,7 +1089,7 @@ const NAType *BuiltinFunction::synthesizeType()
           }
 
         retType = new HEAP
-           SQLChar(32, FALSE);
+           SQLChar(HEAP, 32, FALSE);
 	if (typ1.supportsSQLnull())
 	  {
 	    retType->setNullable(TRUE);
@@ -1101,7 +1100,7 @@ const NAType *BuiltinFunction::synthesizeType()
       {
         const NAType &typ1 = child(0)->getValueId().getType();
         retType = new HEAP
-           SQLInt(FALSE, FALSE); //unsigned int
+           SQLInt(HEAP, FALSE, FALSE); //unsigned int
         if (typ1.supportsSQLnull())
           {
             retType->setNullable(TRUE);
@@ -1113,7 +1112,7 @@ const NAType *BuiltinFunction::synthesizeType()
       {
         // type cast any params
         ValueId vid1 = child(0)->getValueId();
-        SQLChar c1(ComSqlId::MAX_QUERY_ID_LEN);
+        SQLChar c1(NULL, ComSqlId::MAX_QUERY_ID_LEN);
         vid1.coerceType(c1, NA_CHARACTER_TYPE);
         //input type must be string
         const NAType &typ1 = child(0)->getValueId().getType();
@@ -1124,7 +1123,7 @@ const NAType *BuiltinFunction::synthesizeType()
 	    return NULL;
           }
         retType = new HEAP
-           SQLSmall(TRUE, FALSE);
+           SQLSmall(HEAP, TRUE, FALSE);
 	if (typ1.supportsSQLnull())
 	  {
 	    retType->setNullable(TRUE);
@@ -1135,7 +1134,7 @@ const NAType *BuiltinFunction::synthesizeType()
       {
         // type cast any params
         ValueId vid1 = child(0)->getValueId();
-        SQLChar c1(ComSqlId::MAX_QUERY_ID_LEN);
+        SQLChar c1(NULL, ComSqlId::MAX_QUERY_ID_LEN);
         vid1.coerceType(c1, NA_CHARACTER_TYPE);
 
         //input type must be string
@@ -1147,7 +1146,7 @@ const NAType *BuiltinFunction::synthesizeType()
 	    return NULL;
           }
         retType = new HEAP
-           SQLInt(FALSE, FALSE);
+           SQLInt(HEAP, FALSE, FALSE);
 	if (typ1.supportsSQLnull())
 	  {
 	    retType->setNullable(TRUE);
@@ -1174,7 +1173,7 @@ const NAType *BuiltinFunction::synthesizeType()
 	  }
 
 	retType = new HEAP
-	  SQLVarChar(15, FALSE);
+	  SQLVarChar(HEAP, 15, FALSE);
 
 	if (typ1.supportsSQLnull())
 	  {
@@ -1264,7 +1263,7 @@ const NAType *BuiltinFunction::synthesizeType()
         }
 
         retType = new HEAP
-        SQLVarChar(typ1.getNominalSize(), typ1.supportsSQLnull());
+        SQLVarChar(HEAP, typ1.getNominalSize(), typ1.supportsSQLnull());
     }
     break;
 
@@ -1272,11 +1271,11 @@ const NAType *BuiltinFunction::synthesizeType()
       {
 	// type cast any params
 	ValueId vid1 = child(0)->getValueId();
-	SQLChar c1(ComSqlId::MAX_QUERY_ID_LEN);
+	SQLChar c1(NULL, ComSqlId::MAX_QUERY_ID_LEN);
 	vid1.coerceType(c1, NA_CHARACTER_TYPE);
 
 	ValueId vid2 = child(1)->getValueId();
-	SQLChar c2(40, FALSE);
+	SQLChar c2(NULL, 40, FALSE);
 	vid2.coerceType(c2, NA_CHARACTER_TYPE);
 
 	const CharType &typ1 = (CharType&)child(0)->getValueId().getType();
@@ -1300,7 +1299,7 @@ const NAType *BuiltinFunction::synthesizeType()
 	  }
 
 	retType = new HEAP
-	  SQLVarChar(ComSqlId::MAX_QUERY_ID_LEN,
+	  SQLVarChar(HEAP, ComSqlId::MAX_QUERY_ID_LEN,
                      (typ1.supportsSQLnull() || typ2.supportsSQLnull()),
                      FALSE, // not upshifted
                      FALSE, // not case-insensitive
@@ -1331,7 +1330,7 @@ const NAType *BuiltinFunction::synthesizeType()
 	  }
 
 	retType = new HEAP
-	  SQLVarChar(typ2.getNominalSize(), typ2.supportsSQLnull());
+	  SQLVarChar(HEAP, typ2.getNominalSize(), typ2.supportsSQLnull());
       }
     break;
 
@@ -1359,7 +1358,7 @@ const NAType *BuiltinFunction::synthesizeType()
 
     case ITM_UNIQUE_ID:
       {
-	retType = new HEAP SQLChar(16, FALSE);
+	retType = new HEAP SQLChar(HEAP, 16, FALSE);
       }
       break;
 
@@ -1367,7 +1366,7 @@ const NAType *BuiltinFunction::synthesizeType()
       {
           // type cast any params
           ValueId vid1 = child(0)->getValueId();
-          SQLChar c1(ComSqlId::MAX_QUERY_ID_LEN);
+          SQLChar c1(NULL, ComSqlId::MAX_QUERY_ID_LEN);
           vid1.coerceType(c1, NA_CHARACTER_TYPE);
           
           //input type must be string
@@ -1379,7 +1378,7 @@ const NAType *BuiltinFunction::synthesizeType()
               return NULL;
           }
 
-          retType = new HEAP SQLChar(4, FALSE);
+          retType = new HEAP SQLChar(HEAP, 4, FALSE);
           if (typ1.supportsSQLnull())
           {
               retType->setNullable(TRUE);
@@ -1435,7 +1434,7 @@ const NAType *BuiltinFunction::synthesizeType()
         }
 
         retType = new HEAP
-            SQLVarChar(maxLength, TRUE);
+            SQLVarChar(HEAP, maxLength, TRUE);
       }
       break;
 
@@ -1483,7 +1482,7 @@ const NAType *Abs::synthesizeType()
 
   // type cast any params
   ValueId vid = child(0)->getValueId();
-  SQLDoublePrecision dp(TRUE);
+  SQLDoublePrecision dp(NULL, TRUE);
   vid.coerceType(dp, NA_NUMERIC_TYPE);
 
   const NAType &typ1 = child(0)->getValueId().getType();
@@ -1512,19 +1511,19 @@ const NAType *Abs::synthesizeType()
           else
             length = 8;
 
-          result = new HEAP SQLNumeric(length,
+          result = new HEAP SQLNumeric(HEAP, length,
                                        precision,
                                        ntyp1.getScale(),
                                        ntyp1.isSigned());
         }
       else if (NOT ntyp1.isBigNum() && (ntyp1.getScale()==0) ) // this must be LargeInt
-        result = new HEAP SQLLargeInt(ntyp1.isSigned());
+        result = new HEAP SQLLargeInt(HEAP, ntyp1.isSigned());
       else
-        result = new HEAP SQLDoublePrecision();
+        result = new HEAP SQLDoublePrecision(HEAP);
     }
   else
     {
-      result = new HEAP SQLDoublePrecision();
+      result = new HEAP SQLDoublePrecision(HEAP);
     }
 
   if (ntyp1.supportsSQLnullLogical()) result->setNullable(TRUE);
@@ -1638,7 +1637,7 @@ const NAType *CodeVal::synthesizeType()
       return NULL;
   }
 
-  NAType *result = new (HEAP) SQLInt(FALSE, typ1.supportsSQLnullLogical());
+  NAType *result = new (HEAP) SQLInt(HEAP, FALSE, typ1.supportsSQLnullLogical());
 
   return result;
 }
@@ -1654,7 +1653,7 @@ const NAType *Aggregate::synthesizeType()
   case ITM_COUNT:
   case ITM_COUNT_NONULL:
     result = new HEAP
-      SQLLargeInt(TRUE /* 'long long' on NSK can't be unsigned */,
+      SQLLargeInt(HEAP, TRUE /* 'long long' on NSK can't be unsigned */,
 		  FALSE /*not null*/);
     break;
   case ITM_AVG:
@@ -1723,7 +1722,7 @@ const NAType *Aggregate::synthesizeType()
     {
 	  // grouping result is an unsigned int (32 bit)
       result = new HEAP
-        SQLInt(FALSE /*unsigned*/,
+        SQLInt(HEAP, FALSE /*unsigned*/,
                FALSE /*not null*/);
     }
   break;
@@ -1745,7 +1744,7 @@ const NAType *Aggregate::synthesizeType()
     // The argument of a ONE/ANY TRUE must be of type SQLBoolean
     CMPASSERT(operand.getTypeQualifier() == NA_BOOLEAN_TYPE);
 
-    result = new HEAP SQLBooleanRelat(operand.canBeSQLUnknown());
+    result = new HEAP SQLBooleanRelat(HEAP, operand.canBeSQLUnknown());
     break;
   }
   default:
@@ -1774,7 +1773,7 @@ const NAType *AggrMinMax::synthesizeType()
 const NAType *AggrGrouping::synthesizeType()
 {
   // result unsigned 32 bit integer
-  const NAType *result = new HEAP SQLInt(FALSE, FALSE);
+  const NAType *result = new HEAP SQLInt(HEAP, FALSE, FALSE);
 
   return result;
 }
@@ -1784,7 +1783,7 @@ const NAType *AggrGrouping::synthesizeType()
 // -----------------------------------------------------------------------
 const NAType *PivotGroup::synthesizeType()
 {
-  return new HEAP SQLVarChar(maxLen_, TRUE);
+  return new HEAP SQLVarChar(HEAP, maxLen_, TRUE);
 }
 
 // -----------------------------------------------------------------------
@@ -1798,7 +1797,7 @@ static const Lng32 OPT_MAX_USERNAME_LEN	 = ComSqlId::MAX_LDAP_USER_NAME_LEN+1;
 
 const NAType *AnsiUSERFunction::synthesizeType()
 {
-  return new HEAP SQLVarChar(OPT_MAX_USERNAME_LEN, FALSE);
+  return new HEAP SQLVarChar(HEAP, OPT_MAX_USERNAME_LEN, FALSE);
 }
 
 const NAType *MonadicUSERFunction::synthesizeType()
@@ -1808,7 +1807,7 @@ const NAType *MonadicUSERFunction::synthesizeType()
   //
   ValueId vid = child(0)->getValueId();
 
-  SQLInt si(TRUE);
+  SQLInt si(NULL, TRUE);
   vid.coerceType(si, NA_NUMERIC_TYPE);
 
   //
@@ -1841,7 +1840,7 @@ const NAType *MonadicUSERFunction::synthesizeType()
   //
   // Return the result.
   //
-  return new HEAP SQLVarChar(OPT_MAX_USERNAME_LEN, typ1.supportsSQLnullLogical());
+  return new HEAP SQLVarChar(HEAP, OPT_MAX_USERNAME_LEN, typ1.supportsSQLnullLogical());
 }
 
 const NAType *MonadicUSERIDFunction::synthesizeType()
@@ -1864,7 +1863,7 @@ const NAType *MonadicUSERIDFunction::synthesizeType()
   //
   // Return the result.
   //
-  return new HEAP SQLVarChar(OPT_MAX_USERNAME_LEN, operand.supportsSQLnullLogical());
+  return new HEAP SQLVarChar(HEAP, OPT_MAX_USERNAME_LEN, operand.supportsSQLnullLogical());
 }
 
 // -----------------------------------------------------------------------
@@ -2089,7 +2088,7 @@ const NAType *Between::synthesizeType()
   //
   // Return the result.
   //
-  return new HEAP SQLBooleanRelat(allowsUnknown);
+  return new HEAP SQLBooleanRelat(HEAP, allowsUnknown);
 }
 
 // -----------------------------------------------------------------------
@@ -2259,7 +2258,7 @@ const NAType *UnArith::synthesizeType()
       return NULL;
     }
 
-  NAType * retType = new HEAP SQLBooleanNative(operand1.supportsSQLnull());
+  NAType * retType = new HEAP SQLBooleanNative(HEAP, operand1.supportsSQLnull());
 
   return retType;
 }
@@ -2276,7 +2275,7 @@ const NAType *BiLogic::synthesizeType()
   NABoolean allowsUnknown = operand0.canBeSQLUnknown() OR
                             operand1.canBeSQLUnknown();
 
-  return new HEAP SQLBooleanRelat(allowsUnknown);
+  return new HEAP SQLBooleanRelat(HEAP, allowsUnknown);
 }
 
 // -----------------------------------------------------------------------
@@ -2312,7 +2311,7 @@ const NAType *BiRelat::synthesizeType()
   if (!synthItemExprLists(exprList1, exprList2, allowIncompatibleComparison,
 			  allowsUnknown, this))
     return NULL;
-  return new HEAP SQLBooleanRelat(allowsUnknown);
+  return new HEAP SQLBooleanRelat(HEAP, allowsUnknown);
 }
 
 // -----------------------------------------------------------------------
@@ -2321,7 +2320,7 @@ const NAType *BiRelat::synthesizeType()
 
 const NAType *BoolResult::synthesizeType()
 {
-  return new HEAP SQLBooleanRelat(getOperatorType() == ITM_RETURN_NULL);
+  return new HEAP SQLBooleanRelat(HEAP, getOperatorType() == ITM_RETURN_NULL);
 }
 
 // -----------------------------------------------------------------------
@@ -2330,7 +2329,7 @@ const NAType *BoolResult::synthesizeType()
 
 const NAType *BoolVal::synthesizeType()
 {
-  return new HEAP SQLBooleanRelat(getOperatorType() == ITM_RETURN_NULL);
+  return new HEAP SQLBooleanRelat(HEAP, getOperatorType() == ITM_RETURN_NULL);
 }
 
 //------------------------------------------------------------------
@@ -2743,11 +2742,11 @@ const NAType *CastConvert::synthesizeType()
   CharType * origType = (CharType *)getType();
   if (DFS2REC::isAnyVarChar(origType->getFSDatatype()) == FALSE)
     type = new HEAP
-      SQLChar(maxLength, childType.supportsSQLnull(),
+      SQLChar(HEAP, maxLength, childType.supportsSQLnull(),
 	      origType->isUpshifted());
   else
     type = new HEAP
-      SQLVarChar(maxLength, childType.supportsSQLnull(),
+      SQLVarChar(HEAP, maxLength, childType.supportsSQLnull(),
 		 origType->isUpshifted());
 
   return type;
@@ -2782,7 +2781,7 @@ const NAType *CharFunc::synthesizeType()
   //
   // Type cast any params.
   //
-  SQLInt nType(FALSE);
+  SQLInt nType(NULL, FALSE);
   ValueId vid1 = child(0)->getValueId();
   vid1.coerceType(nType, NA_NUMERIC_TYPE);
 
@@ -2817,14 +2816,14 @@ const NAType *CharFunc::synthesizeType()
   CharType *result;
 
   if(charSet_ == CharInfo::UCS2 || charSet_ < 0)  // UCS2, kanji and KSC5601_MP
-    result = new (HEAP) SQLChar ( 1,
+    result = new (HEAP) SQLChar ( HEAP, 1,
                                   typ1.supportsSQLnullLogical(),
                                   FALSE/*not upshift*/,
                                   FALSE/*case sensitive*/,
                                   FALSE/*not varchar*/,
                                   charSet_);
   else
-    result = new (HEAP) SQLVarChar(CharInfo::maxBytesPerChar( cs_to_use )
+    result = new (HEAP) SQLVarChar(HEAP, CharInfo::maxBytesPerChar( cs_to_use )
                                   , typ1.supportsSQLnullLogical()
                                   , FALSE /*not upshift*/
                                   , FALSE /*case sensitive*/
@@ -2889,10 +2888,10 @@ const NAType *ConvertHex::synthesizeType()
        ( (const CharType*)operand)->getCharSet()==CharInfo::UTF8 )
      )
     type = new HEAP
-      SQLVarChar(maxLength, operand->supportsSQLnull());
+      SQLVarChar(HEAP, maxLength, operand->supportsSQLnull());
   else
     type = new HEAP
-      SQLChar(maxLength, operand->supportsSQLnull());
+      SQLChar(HEAP, maxLength, operand->supportsSQLnull());
 
   //
   // Return the result.
@@ -2953,7 +2952,7 @@ const NAType *CharLength::synthesizeType()
   // Return the result.
   //
   return new HEAP
-    SQLInt(FALSE  // unsigned
+    SQLInt(HEAP, FALSE  // unsigned
 	   ,operand.supportsSQLnullLogical()
 	   );
 }
@@ -3055,7 +3054,7 @@ const NAType *ConvertTimestamp::synthesizeType()
   // Type cast any params.
   //
   ValueId vid = child(0)->getValueId();
-  SQLLargeInt largeintType;
+  SQLLargeInt largeintType(NULL);
   vid.coerceType(largeintType);
   //
   // Check that the operands are compatible.
@@ -3070,9 +3069,8 @@ const NAType *ConvertTimestamp::synthesizeType()
   //
   // Return the result.
   //
-  return new HEAP SQLTimestamp (operand.supportsSQLnullLogical(),
-                               SQLTimestamp::DEFAULT_FRACTION_PRECISION,
-                               HEAP);
+  return new HEAP SQLTimestamp (HEAP, operand.supportsSQLnullLogical(),
+                               SQLTimestamp::DEFAULT_FRACTION_PRECISION);
 
 }
 
@@ -3082,9 +3080,8 @@ const NAType *ConvertTimestamp::synthesizeType()
 
 const NAType *CurrentTimestamp::synthesizeType()
 {
-  return new HEAP SQLTimestamp (FALSE,
-                                SQLTimestamp::DEFAULT_FRACTION_PRECISION,
-                                HEAP);
+  return new HEAP SQLTimestamp (HEAP, FALSE,
+                                SQLTimestamp::DEFAULT_FRACTION_PRECISION);
 }
 
 // -----------------------------------------------------------------------
@@ -3093,7 +3090,7 @@ const NAType *CurrentTimestamp::synthesizeType()
 
 const NAType *InternalTimestamp::synthesizeType()
 {
-  return new SQLTimestamp(FALSE);
+  return new HEAP SQLTimestamp(HEAP, FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -3102,7 +3099,7 @@ const NAType *InternalTimestamp::synthesizeType()
 
 const NAType *CurrentTimestampRunning::synthesizeType()
 {
-  return new HEAP SQLTimestamp(FALSE);
+  return new HEAP SQLTimestamp(HEAP, FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -3114,7 +3111,7 @@ const NAType *DateFormat::synthesizeType()
   // Type cast any params.
   //
   ValueId vid = child(0)->getValueId();
-  SQLTimestamp timestampType;
+  SQLTimestamp timestampType(NULL);
   vid.coerceType(timestampType);
   //
   // Check that the operands are compatible.
@@ -3179,13 +3176,13 @@ const NAType *DateFormat::synthesizeType()
     }
 
   if (formatAsDate)
-    return new HEAP SQLDate(vid.getType().supportsSQLnullLogical());
+    return new HEAP SQLDate(HEAP, vid.getType().supportsSQLnullLogical());
   else if (formatAsTimestamp)
-    return new HEAP SQLTimestamp(vid.getType().supportsSQLnullLogical());
+    return new HEAP SQLTimestamp(HEAP, vid.getType().supportsSQLnullLogical());
   else if (formatAsTime)
-    return new HEAP SQLTime(vid.getType().supportsSQLnullLogical());
+    return new HEAP SQLTime(HEAP, vid.getType().supportsSQLnullLogical());
   else
-    return new HEAP SQLChar(length, vid.getType().supportsSQLnullLogical());
+    return new HEAP SQLChar(HEAP, length, vid.getType().supportsSQLnullLogical());
 }
 
 // -----------------------------------------------------------------------
@@ -3198,7 +3195,7 @@ const NAType *DayOfWeek::synthesizeType()
   // Type cast any params.
   //
   ValueId vid = child(0)->getValueId();
-  SQLTimestamp timestampType;
+  SQLTimestamp timestampType(NULL);
   vid.coerceType(timestampType);
   //
   // Check that the operand contains a DAY field
@@ -3217,7 +3214,7 @@ const NAType *DayOfWeek::synthesizeType()
   // Return the result.
   //
   const Int16 DisAmbiguate = 0; // added for 64bit project
-  return new HEAP SQLNumeric(FALSE, 1, 0, DisAmbiguate,
+  return new HEAP SQLNumeric(HEAP, FALSE, 1, 0, DisAmbiguate,
                              operand.supportsSQLnullLogical());
 }
 
@@ -3228,7 +3225,7 @@ const NAType *DayOfWeek::synthesizeType()
 const NAType *DynamicParam::synthesizeType()
 {
   // dynamic params are always nullable.
-  return new HEAP SQLUnknown(TRUE);
+  return new HEAP SQLUnknown(HEAP, TRUE);
 }
 
 
@@ -3312,7 +3309,7 @@ if (0)
 const NAType *Hash::synthesizeType()
 {
   // result of hash function is always a non-nullable, unsigned 32 bit integer
-  return new HEAP SQLInt(FALSE, FALSE);
+  return new HEAP SQLInt(HEAP, FALSE, FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -3349,7 +3346,7 @@ const NAType *HashComb::synthesizeType()
 
   // result of hashcomb function is always a non-nullable,
   // unsigned 32 bit integer
-  return new HEAP SQLInt(FALSE, FALSE);
+  return new HEAP SQLInt(HEAP, FALSE, FALSE);
 }
 
 const NAType *HiveHashComb::synthesizeType()
@@ -3363,7 +3360,7 @@ const NAType *HiveHashComb::synthesizeType()
 
   // result of hashcomb function is always a non-nullable,
   // unsigned 32 bit integer
-  return new HEAP SQLInt(FALSE, FALSE);
+  return new HEAP SQLInt(HEAP, FALSE, FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -3376,7 +3373,7 @@ const NAType *HiveHashComb::synthesizeType()
 const NAType *HashDistPartHash::synthesizeType()
 {
   // result of hash function is always a non-nullable, unsigned 32 bit integer
-  return new HEAP SQLInt(FALSE, FALSE);
+  return new HEAP SQLInt(HEAP, FALSE, FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -3385,7 +3382,7 @@ const NAType *HashDistPartHash::synthesizeType()
 const NAType *HiveHash::synthesizeType()
 {
   // result of hivehash function is always a non-nullable, unsigned 32 bit integer
-  return new HEAP SQLInt(FALSE, FALSE);
+  return new HEAP SQLInt(HEAP, FALSE, FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -3424,7 +3421,7 @@ const NAType *HashDistPartHashComb::synthesizeType()
 
   // result of hashcomb function is always a non-nullable,
   // unsigned 32 bit integer
-  return new HEAP SQLInt(FALSE, FALSE);
+  return new HEAP SQLInt(HEAP, FALSE, FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -3451,7 +3448,7 @@ const NAType *JulianTimestamp::synthesizeType()
   // Type cast any params.
   //
   ValueId vid = child(0)->getValueId();
-  SQLTimestamp timestampType;
+  SQLTimestamp timestampType(NULL);
   vid.coerceType(timestampType);
   //
   // Check that the operands are compatible.
@@ -3465,7 +3462,7 @@ const NAType *JulianTimestamp::synthesizeType()
   //
   // Return the result.
   //
-  return new HEAP SQLLargeInt(TRUE, operand.supportsSQLnullLogical());
+  return new HEAP SQLLargeInt(HEAP, TRUE, operand.supportsSQLnullLogical());
 }
 
 // -----------------------------------------------------------------------
@@ -3473,7 +3470,7 @@ const NAType *JulianTimestamp::synthesizeType()
 // -----------------------------------------------------------------------
 const NAType * StatementExecutionCount::synthesizeType()
 {
-  return new HEAP SQLLargeInt(TRUE,FALSE);
+  return new HEAP SQLLargeInt(HEAP, TRUE,FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -3481,7 +3478,7 @@ const NAType * StatementExecutionCount::synthesizeType()
 // -----------------------------------------------------------------------
 const NAType * CurrentTransId::synthesizeType()
 {
-  return new HEAP SQLLargeInt(TRUE,FALSE);
+  return new HEAP SQLLargeInt(HEAP, TRUE,FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -3495,7 +3492,7 @@ const NAType *BitOperFunc::synthesizeType()
       // type cast any params
       ValueId vid = child(i)->getValueId();
       // untyped param operands are typed as Int32 Unsigned.
-      SQLInt dp(FALSE);
+      SQLInt dp(NULL, FALSE);
       vid.coerceType(dp, NA_NUMERIC_TYPE);
 
       const NAType &typ = vid.getType();
@@ -3599,7 +3596,7 @@ const NAType *BitOperFunc::synthesizeType()
 	else
 	  {
 	    const Int16 DisAmbiguate = 0;
-	    result1 = new HEAP SQLNumeric(NOT ntyp1.isUnsigned(),
+	    result1 = new HEAP SQLNumeric(HEAP, NOT ntyp1.isUnsigned(),
 					  ntyp1.getPrecision(),
 					  ntyp1.getScale(),
 					  DisAmbiguate); // added for 64bit proj.
@@ -3647,9 +3644,9 @@ const NAType *BitOperFunc::synthesizeType()
 	// Make the result an Int32 or Int64.
 	NAType * result1 = NULL;
 	if (ntyp1.getNominalSize() <= 9)
-	  result = new HEAP SQLInt(TRUE, nullable);
+	  result = new HEAP SQLInt(HEAP, TRUE, nullable);
 	else
-	  result = new HEAP SQLLargeInt(TRUE, nullable);
+	  result = new HEAP SQLLargeInt(HEAP, TRUE, nullable);
       }
     break;
 
@@ -3699,11 +3696,10 @@ NAType* MathFunc::findReturnTypeForFloorCeil(NABoolean nullable)
         // for SQLDecimal
         case REC_DECIMAL_UNSIGNED:
         case REC_DECIMAL_LSE:
-          return new HEAP SQLDecimal(nuTyp.getNominalSize()
+          return new HEAP SQLDecimal(HEAP, nuTyp.getNominalSize()
                                     ,0
                                     ,!nuTyp.isUnsigned()
                                     ,nuTyp.supportsSQLnull()
-                                    ,HEAP
                                     );
           break;
 
@@ -3716,19 +3712,18 @@ NAType* MathFunc::findReturnTypeForFloorCeil(NABoolean nullable)
         case REC_BIN16_SIGNED:
         case REC_BIN32_SIGNED:
         case REC_BIN64_SIGNED:
-           return new HEAP SQLNumeric(nuTyp.getNominalSize()
+           return new HEAP SQLNumeric(HEAP, nuTyp.getNominalSize()
                                      ,nuTyp.getPrecision()
                                      ,0
                                      ,!nuTyp.isUnsigned()
                                      ,nuTyp.supportsSQLnull()
-                                     ,HEAP
                                      );
 
         default: 
           break;
     }
   }
-  return new HEAP SQLDoublePrecision(nullable);
+  return new HEAP SQLDoublePrecision(HEAP, nullable);
 }
 
 const NAType *MathFunc::synthesizeType()
@@ -3742,7 +3737,7 @@ const NAType *MathFunc::synthesizeType()
       // type cast any params
       ValueId vid = child(i)->getValueId();
 
-      SQLDoublePrecision dp(TRUE);
+      SQLDoublePrecision dp(NULL, TRUE);
       vid.coerceType(dp, NA_NUMERIC_TYPE);
 
       const NAType &typ = vid.getType();
@@ -3794,7 +3789,7 @@ const NAType *MathFunc::synthesizeType()
     case ITM_TAN:
     case ITM_TANH:
       {
-	result = new HEAP SQLDoublePrecision(nullable);
+	result = new HEAP SQLDoublePrecision(HEAP, nullable);
       }
       break;
 
@@ -3835,7 +3830,7 @@ const NAType *Modulus::synthesizeType()
   //
   ValueId vid1 = child(0)->getValueId();
   ValueId vid2 = child(1)->getValueId();
-  SQLInt si(TRUE);
+  SQLInt si(NULL, TRUE);
   vid1.coerceType(si, NA_NUMERIC_TYPE);
   vid2.coerceType(si, NA_NUMERIC_TYPE);
 
@@ -4017,7 +4012,7 @@ const NAType *Repeat::synthesizeType()
     }
 
   NAType *result =
-    new (HEAP) SQLVarChar(CharLenInfo((Lng32)size_in_chars, (Lng32)size_in_bytes),
+    new (HEAP) SQLVarChar(HEAP, CharLenInfo((Lng32)size_in_chars, (Lng32)size_in_bytes),
 			  (typ1.supportsSQLnullLogical() ||
 			   typ2.supportsSQLnullLogical()),
 			  ctyp1.isUpshifted(),
@@ -4166,7 +4161,7 @@ const NAType *Replace::synthesizeType()
   CharLenInfo CLInfo( size_in_chars, size_in_bytes );
 
   NAType *result =
-    new (HEAP) SQLVarChar(CLInfo,
+    new (HEAP) SQLVarChar(HEAP, CLInfo,
 			  (typ1->supportsSQLnullLogical() ||
 			   typ2->supportsSQLnullLogical() ||
 			   typ3->supportsSQLnullLogical()),
@@ -4234,7 +4229,7 @@ const NAType *HashDistrib::synthesizeType()
 const NAType *ProgDistribKey::synthesizeType()
 {
   // return: Large Int.
-  return new HEAP SQLLargeInt(TRUE, FALSE);
+  return new HEAP SQLLargeInt(HEAP, TRUE, FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -4324,7 +4319,7 @@ const NAType *CompEncode::synthesizeType()
 
   if (src.getTypeQualifier() != NA_CHARACTER_TYPE)
     {
-      return new HEAP SQLChar(keyLength, supportsSQLnull);
+      return new HEAP SQLChar(HEAP, keyLength, supportsSQLnull);
     }
   else
     {
@@ -4355,17 +4350,17 @@ const NAType *CompEncode::synthesizeType()
 	    case CollationInfo::Sort:
 	      {
 		// in this case the encode is non nullable if not regularNullability
-		return new HEAP SQLChar(keyLength, 
+		return new HEAP SQLChar(HEAP, keyLength, 
 					supportsSQLnull); 
 	      }
 	    case CollationInfo::Compare:
 	      {
-		return new HEAP SQLChar(keyLength, 
+		return new HEAP SQLChar(HEAP, keyLength, 
 					cSrc.supportsSQLnull());
 	      }
 	    case CollationInfo::Search:
 	      {
-		return new HEAP SQLVarChar(keyLength,   
+		return new HEAP SQLVarChar(HEAP, keyLength,   
 					   cSrc.supportsSQLnull());
 	      }
 	    default:
@@ -4377,7 +4372,7 @@ const NAType *CompEncode::synthesizeType()
 	}
       else
 	{
-	  return new HEAP SQLChar(keyLength, supportsSQLnull);
+	  return new HEAP SQLChar(HEAP, keyLength, supportsSQLnull);
 	}
     }
 }
@@ -4470,7 +4465,7 @@ const NAType *Extract::synthesizeType()
   }
   const Int16 disAmbiguate = 0; // added for 64bit project
   return new HEAP
-    SQLNumeric(type == NA_INTERVAL_TYPE, /*allowNegValues*/
+    SQLNumeric(HEAP, type == NA_INTERVAL_TYPE, /*allowNegValues*/
 	       prec,
 	       scale,
                disAmbiguate,
@@ -4546,7 +4541,7 @@ const NAType *TriRelational::synthesizeType()
   //
   // Return the result.
   //
-  return new HEAP SQLBooleanRelat(allowsUnknown);
+  return new HEAP SQLBooleanRelat(HEAP, allowsUnknown);
 }
 
 // -----------------------------------------------------------------------
@@ -4556,7 +4551,7 @@ const NAType *TriRelational::synthesizeType()
 const NAType *RangeLookup::synthesizeType()
 {
   // the result is a signed 32 bit number
-  return new HEAP SQLInt(TRUE,FALSE);
+  return new HEAP SQLInt(HEAP, TRUE,FALSE);
 }
 
 // -----------------------------------------------------------------------
@@ -4625,7 +4620,7 @@ const NAType *PatternMatchingFunction::synthesizeType()
 
   if (getArity() > 2) {   // Escape clause was specified
     vid3 = child(2)->getValueId();
-    const SQLChar charType(1);
+    const SQLChar charType(NULL, 1);
     vid3.coerceType(charType);
     typ3 = &vid3.getType();
   }
@@ -4681,7 +4676,7 @@ const NAType *PatternMatchingFunction::synthesizeType()
 			   (typ3 AND
 			    typ3->supportsSQLnull());
 
-  return new HEAP SQLBooleanRelat(allowsUnknown);
+  return new HEAP SQLBooleanRelat(HEAP, allowsUnknown);
 }
 
 // -----------------------------------------------------------------------
@@ -4731,7 +4726,7 @@ const NAType *Lower::synthesizeType()
   //
   if (ct->getCharSet() == CharInfo::UTF8) {
     // NOTE: See comment near end of Upper::synthesizeType() for reason we don't multiply by 3 here.
-    ct =  new (HEAP) SQLVarChar(CharLenInfo(ct->getStrCharLimit(), (ct->getDataStorageSize()))
+    ct =  new (HEAP) SQLVarChar(HEAP, CharLenInfo(ct->getStrCharLimit(), (ct->getDataStorageSize()))
 				,ct->supportsSQLnull()
 				,ct->isUpshifted()
 				,ct->isCaseinsensitive()
@@ -4778,7 +4773,7 @@ const NAType *Upper::synthesizeType()
   }
 
   if (ct->getCharSet() == CharInfo::UNICODE) {
-    ct =  new (HEAP) SQLVarChar(3*(ct->getStrCharLimit())
+    ct =  new (HEAP) SQLVarChar(HEAP, 3*(ct->getStrCharLimit())
 				,ct->supportsSQLnull()
 				,ct->isUpshifted()
 				,ct->isCaseinsensitive()
@@ -4794,7 +4789,7 @@ const NAType *Upper::synthesizeType()
   // and for that reason, the UPPER function provides for 3 times as much output as the
   // input string is long.  HOWEVER, such is never the case for the LOWER function.
   //
-    ct =  new (HEAP) SQLVarChar(CharLenInfo(3*ct->getStrCharLimit(), 3*(ct->getDataStorageSize()))
+    ct =  new (HEAP) SQLVarChar(HEAP, CharLenInfo(3*ct->getStrCharLimit(), 3*(ct->getDataStorageSize()))
 				,ct->supportsSQLnull()
 				,ct->isUpshifted()
 				,ct->isCaseinsensitive()
@@ -4872,7 +4867,7 @@ const NAType *OctetLength::synthesizeType()
   //
   // Return the result.
   //
-  return new HEAP SQLInt(FALSE  // unsigned
+  return new HEAP SQLInt(HEAP, FALSE  // unsigned
 		     ,operand.supportsSQLnullLogical()
 		     );
 }
@@ -4916,7 +4911,7 @@ const NAType *PositionFunc::synthesizeType()
   if (getArity() == 3)
     {
       ValueId vid3 = child(2)->getValueId();
-      SQLInt si;
+      SQLInt si(NULL);
 
       vid3.coerceType(si, NA_NUMERIC_TYPE);
       operand3 = &vid3.getType();
@@ -5008,7 +5003,7 @@ const NAType *PositionFunc::synthesizeType()
   // Return the result.
   //
   return new HEAP
-    SQLInt(FALSE,  // unsigned
+    SQLInt(HEAP, FALSE,  // unsigned
 	   operand1->supportsSQLnullLogical() ||
 	   operand2->supportsSQLnullLogical()
 	  );
@@ -5027,7 +5022,7 @@ const NAType *Substring::synthesizeType()
   ValueId vid2 = child(1)->getValueId();
   vid1.coerceType(NA_CHARACTER_TYPE);
 
-  SQLInt si;
+  SQLInt si(NULL);
   vid2.coerceType(si, NA_NUMERIC_TYPE);
   if (getArity() == 3)
     {
@@ -5172,7 +5167,7 @@ const NAType *Substring::synthesizeType()
   if (operand1->getFSDatatype() == REC_CLOB)
     {
       return new HEAP
-	SQLClob(maxLength_bytes, Lob_Invalid_Storage,
+	SQLClob(HEAP, maxLength_bytes, Lob_Invalid_Storage,
 		operand1->supportsSQLnull() OR
 		operand2->supportsSQLnull() OR
 		((operand3 != NULL) AND operand3->supportsSQLnull()));
@@ -5182,7 +5177,7 @@ const NAType *Substring::synthesizeType()
     
 
       return new HEAP
-	SQLVarChar(CharLenInfo(maxLength_chars, maxLength_bytes), // OLD: maxLength
+	SQLVarChar(HEAP, CharLenInfo(maxLength_chars, maxLength_bytes), // OLD: maxLength
 		   operand1->supportsSQLnull() OR
 		   operand2->supportsSQLnull() OR
 		   ((operand3 != NULL) AND operand3->supportsSQLnull())
@@ -5286,7 +5281,7 @@ const NAType *Trim::synthesizeType()
   Int32 size = trimSource->getDataStorageSize();
 
   return new HEAP
-    SQLVarChar(CharLenInfo(trimSource->getStrCharLimit(), size )
+    SQLVarChar(HEAP, CharLenInfo(trimSource->getStrCharLimit(), size )
 	      ,trimChar->supportsSQLnull() OR trimSource->supportsSQLnull()
 	      ,trimSource->isUpshifted()
 	      ,trimSource->isCaseinsensitive()
@@ -5332,7 +5327,7 @@ const NAType *UnLogic::synthesizeType()
       break;
   }
 
-  return new HEAP SQLBooleanRelat(allowsUnknown);
+  return new HEAP SQLBooleanRelat(HEAP, allowsUnknown);
 }
 
 // -----------------------------------------------------------------------
@@ -5518,7 +5513,7 @@ const NAType *Translate::synthesizeType()
                                             translateSource->getNominalSize(),
                                             charsetTarget);
 
-      return new HEAP SQLVarChar(CharLenInfo(translateSource->getStrCharLimit(), resultLen),
+      return new HEAP SQLVarChar(HEAP, CharLenInfo(translateSource->getStrCharLimit(), resultLen),
                                  TRUE, FALSE, 
                                  translateSource->isCaseinsensitive(),
                                  charsetTarget,
@@ -5687,7 +5682,7 @@ HostVar::pushDownType(NAType& desiredType,
   // If this is a rowset host var, we need to propagate the desired type into it
   if (varType_->getTypeQualifier() == NA_ROWSET_TYPE) {
     SQLRowset *rw1 = (SQLRowset *) varType_;
-    SQLRowset *rw2 = new HEAP SQLRowset(&desiredType, rw1->getMaxNumElements(),
+    SQLRowset *rw2 = new HEAP SQLRowset(HEAP, &desiredType, rw1->getMaxNumElements(),
                                                       rw1->getNumElements());
     NAType *tempType = &desiredType;
     rw2->setNullable(*tempType);
@@ -5727,7 +5722,7 @@ ValueIdProxy::pushDownType(NAType& desiredType,
 
 const NAType *VEGPredicate::synthesizeType()
 {
-  return new HEAP SQLBooleanRelat();
+  return new HEAP SQLBooleanRelat(HEAP);
 }
 
 // -----------------------------------------------------------------------
@@ -5792,7 +5787,7 @@ const NAType *VEGReference::synthesizeType()
   }
   else
   {
-    type = new HEAP SQLUnknown();
+    type = new HEAP SQLUnknown(HEAP);
   }
 
   getVEG()->markAsNotSeenBefore();
@@ -5802,7 +5797,7 @@ const NAType *VEGReference::synthesizeType()
 
 const NAType *ScalarVariance::synthesizeType()
 {
-  return new HEAP SQLDoublePrecision(TRUE); // Variance is always Nullable
+  return new HEAP SQLDoublePrecision(HEAP, TRUE); // Variance is always Nullable
 }
 
 // UnPackCol::synthesizeType() --------------------------------
@@ -5841,7 +5836,7 @@ const NAType *RandomNum::synthesizeType()
       //
       // Type cast any params.
       //
-      SQLInt nType(FALSE);
+      SQLInt nType(NULL, FALSE);
       ValueId vid = child(0)->getValueId();
       vid.coerceType(nType, NA_NUMERIC_TYPE);
 
@@ -5870,12 +5865,12 @@ const NAType *RandomNum::synthesizeType()
 	}
 
      // return: int unsigned 
-      result = (NAType *) new HEAP SQLInt(FALSE, ntyp1.supportsSQLnullLogical());
+      result = (NAType *) new HEAP SQLInt(HEAP, FALSE, ntyp1.supportsSQLnullLogical());
     }
   else
     {
       // return: int unsigned not null 
-      result = (NAType *) new HEAP SQLInt(FALSE,FALSE);
+      result = (NAType *) new HEAP SQLInt(HEAP, FALSE,FALSE);
     }
 
   return result;
@@ -5971,7 +5966,7 @@ const NAType * ZZZBinderFunction::synthesizeType()
     case ITM_DATEDIFF_MONTH:
     case ITM_DATEDIFF_QUARTER:
     case ITM_DATEDIFF_WEEK:
-      return new HEAP SQLInt(TRUE,
+      return new HEAP SQLInt(HEAP, TRUE,
                              child(0)->getValueId().getType().supportsSQLnull() ||
                              child(1)->getValueId().getType().supportsSQLnull());
       
@@ -5987,7 +5982,7 @@ const NAType * ZZZBinderFunction::synthesizeType()
 
     case ITM_YEARWEEK:
     case ITM_YEARWEEKD:
-      return new HEAP SQLNumeric(4,
+      return new HEAP SQLNumeric(HEAP, 4,
                                  6,
                                  0,
                                  TRUE,
@@ -6001,7 +5996,7 @@ const NAType * ZZZBinderFunction::synthesizeType()
 
 const NAType *Subquery::synthesizeType()
 {
-  return new HEAP SQLBooleanRelat();
+  return new HEAP SQLBooleanRelat(HEAP);
 }
 
 const NAType *RowSubquery::synthesizeType()
@@ -6055,7 +6050,7 @@ const NAType *QuantifiedComp::synthesizeType()
   if (!synthItemExprLists(exprList1, exprList2, allowIncompatibleComparison,
 			  allowsUnknown, this))
     return NULL;
-  return new HEAP SQLBooleanRelat(allowsUnknown);
+  return new HEAP SQLBooleanRelat(HEAP, allowsUnknown);
 }
 
 // MV,
@@ -6069,7 +6064,7 @@ const NAType *GenericUpdateOutputFunction::synthesizeType()
     // Type cast any params.
     //
     ValueId vid = child(0)->getValueId();
-    SQLTimestamp timestampType;
+    SQLTimestamp timestampType(NULL);
     vid.coerceType(timestampType);
     //
     // Check that the operands are compatible.
@@ -6081,11 +6076,11 @@ const NAType *GenericUpdateOutputFunction::synthesizeType()
       return NULL;
     }
   
-    type = new HEAP SQLLargeInt(TRUE, operand.supportsSQLnullLogical());
+    type = new HEAP SQLLargeInt(HEAP, TRUE, operand.supportsSQLnullLogical());
   }
   else
   {
-    type = new HEAP SQLInt(TRUE, FALSE);
+    type = new HEAP SQLInt(HEAP, TRUE, FALSE);
   }
 
   return type;
@@ -6095,13 +6090,13 @@ const NAType *GenericUpdateOutputFunction::synthesizeType()
 
 const NAType *UniqueExecuteId::synthesizeType()
 {
-  return new HEAP SQLChar(SIZEOF_UNIQUE_EXECUTE_ID, FALSE);
+  return new HEAP SQLChar(HEAP, SIZEOF_UNIQUE_EXECUTE_ID, FALSE);
 }
 
 
 const NAType *GetTriggersStatus::synthesizeType()
 {
-  return new HEAP SQLChar(TRIGGERS_STATUS_VECTOR_SIZE, FALSE);
+  return new HEAP SQLChar(HEAP, TRIGGERS_STATUS_VECTOR_SIZE, FALSE);
 }
 
 const NAType *GetBitValueAt::synthesizeType()
@@ -6119,7 +6114,7 @@ const NAType *GetBitValueAt::synthesizeType()
     *CmpCommon::diags() << DgSqlCode(-4052) << DgString0(getTextUpper());
     return NULL;
   }
-  return new HEAP SQLInt(FALSE, FALSE);
+  return new HEAP SQLInt(HEAP, FALSE, FALSE);
 }
 
 //--Triggers,
@@ -6160,10 +6155,10 @@ const NAType *ItemList::synthesizeType()
   }
   else
   {
-    restOfRecord = new HEAP SQLRecord(&child(1)->getValueId().getType(),NULL);
+    restOfRecord = new HEAP SQLRecord(HEAP, &child(1)->getValueId().getType(),NULL);
   }
 
-  return new HEAP SQLRecord(elementType,restOfRecord);
+  return new HEAP SQLRecord(HEAP, elementType,restOfRecord);
 }
 // -----------------------------------------------------------------------
 // member functions for class ItmSeqOffset
@@ -6307,7 +6302,7 @@ const NAType *ItmSeqDiff1::synthesizeType()
   const NAType *result2 = operand2.synthesizeType(SYNTH_RULE_SUB, operand2, operand2, HEAP);
   if (result2->getTypeQualifier() == NA_INTERVAL_TYPE)
   {
-    result2 = new HEAP SQLLargeInt(TRUE, FALSE );
+    result2 = new HEAP SQLLargeInt(HEAP, TRUE, FALSE );
   }
   result = (NAType *)result2->synthesizeType(SYNTH_RULE_DIV, *result1, *result2, HEAP);
  }
@@ -6356,7 +6351,7 @@ const NAType *ItmSeqDiff2::synthesizeType()
   const NAType *result2 = operand2.synthesizeType(SYNTH_RULE_SUB, operand2, operand2, HEAP);
   if (result2->getTypeQualifier() == NA_INTERVAL_TYPE)
   {
-    result2 = new HEAP SQLLargeInt(TRUE, FALSE );
+    result2 = new HEAP SQLLargeInt(HEAP, TRUE, FALSE );
   }
   result = (NAType *)result2->synthesizeType(SYNTH_RULE_DIV, *result, *result2, HEAP);
  }
@@ -6379,7 +6374,7 @@ const NAType *ItmSeqRunningFunction::synthesizeType()
       (getOperatorType() == ITM_RUNNING_DRANK)  ||
       (getOperatorType() == ITM_RUNNING_CHANGE)) {
     result = new HEAP
-      SQLLargeInt(TRUE /* 'long long' on NSK can't be unsigned */,
+      SQLLargeInt(HEAP, TRUE /* 'long long' on NSK can't be unsigned */,
 		  FALSE /*not null*/);
   }
   else {
@@ -6388,7 +6383,7 @@ const NAType *ItmSeqRunningFunction::synthesizeType()
     switch (getOperatorType())  {
      case ITM_RUNNING_AVG:  {         // needs to mimic what will happen after transformation
        const NAType *operand1 = synthAvgSum(operand, FALSE);
-       const NAType *newInt =  new HEAP SQLLargeInt(TRUE,FALSE);
+       const NAType *newInt =  new HEAP SQLLargeInt(HEAP, TRUE,FALSE);
        if (operand1){
         result = operand1->synthesizeType(SYNTH_RULE_DIV, *operand1, *newInt, HEAP);
        }
@@ -6407,7 +6402,7 @@ const NAType *ItmSeqRunningFunction::synthesizeType()
 
      case ITM_RUNNING_SDEV:
      case ITM_RUNNING_VARIANCE:
-       result = new HEAP SQLDoublePrecision(TRUE); // See ScalarVariance::synthesizeType()
+       result = new HEAP SQLDoublePrecision(HEAP, TRUE); // See ScalarVariance::synthesizeType()
        break;
 
      default:
@@ -6431,7 +6426,7 @@ const NAType *ItmSeqOlapFunction::synthesizeType()
   if (getOperatorType() == ITM_OLAP_COUNT) 
   {
     result = new HEAP
-              SQLLargeInt(TRUE /* 'long long' on NSK can't be unsigned */,
+              SQLLargeInt(HEAP, TRUE /* 'long long' on NSK can't be unsigned */,
 		          TRUE /* null*/);
   }
   else
@@ -6440,7 +6435,7 @@ const NAType *ItmSeqOlapFunction::synthesizeType()
       (getOperatorType() == ITM_OLAP_DRANK)) 
   {
     result = new HEAP
-              SQLLargeInt(TRUE /* 'long long' on NSK can't be unsigned */,
+              SQLLargeInt(HEAP, TRUE /* 'long long' on NSK can't be unsigned */,
 		          FALSE /*not null*/);
   }
   else 
@@ -6452,7 +6447,7 @@ const NAType *ItmSeqOlapFunction::synthesizeType()
      case ITM_OLAP_AVG:  
      {         // needs to mimic what will happen after transformation
        const NAType *operand1 = synthAvgSum(operand, FALSE);
-       const NAType *newInt =  new HEAP SQLLargeInt(TRUE, TRUE /*FALSE*/);
+       const NAType *newInt =  new HEAP SQLLargeInt(HEAP, TRUE, TRUE /*FALSE*/);
        if (operand1)
        {
         result = operand1->synthesizeType(SYNTH_RULE_DIV, *operand1, *newInt, HEAP);
@@ -6471,7 +6466,7 @@ const NAType *ItmSeqOlapFunction::synthesizeType()
 
      case ITM_OLAP_SDEV:
      case ITM_OLAP_VARIANCE:
-       result = new HEAP SQLDoublePrecision(TRUE); 
+       result = new HEAP SQLDoublePrecision(HEAP, TRUE); 
        break;
 
      default:
@@ -6502,7 +6497,7 @@ const NAType *ItmSeqRowsSince::synthesizeType()
     }
   }
   return  new HEAP
-    SQLInt(TRUE /* 'long long' on NSK can't be unsigned */,
+    SQLInt(HEAP, TRUE /* 'long long' on NSK can't be unsigned */,
 	   TRUE /* nullable */);
 }
 
@@ -6542,7 +6537,7 @@ const NAType *ItmSeqMovingFunction::synthesizeType()
       (getOperatorType() == ITM_MOVING_RANK)  ||
       (getOperatorType() == ITM_MOVING_DRANK)) {
     result = new HEAP
-      SQLLargeInt(TRUE /* 'long long' on NSK can't be unsigned */,
+      SQLLargeInt(HEAP, TRUE /* 'long long' on NSK can't be unsigned */,
 		  FALSE /*not null*/);
   }
   else  {
@@ -6551,7 +6546,7 @@ const NAType *ItmSeqMovingFunction::synthesizeType()
    switch (getOperatorType())  {
     case ITM_MOVING_AVG: {          // needs to mimic what will happen after transformation
        const NAType *operand1 = synthAvgSum(operand, FALSE);
-       const NAType *newInt =  new HEAP SQLLargeInt(TRUE,FALSE);
+       const NAType *newInt =  new HEAP SQLLargeInt(HEAP, TRUE,FALSE);
        if (operand1) {
        result = operand1->synthesizeType(SYNTH_RULE_DIV, *operand1, *newInt, HEAP);
        }
@@ -6569,7 +6564,7 @@ const NAType *ItmSeqMovingFunction::synthesizeType()
 
     case ITM_MOVING_SDEV:
     case ITM_MOVING_VARIANCE:
-       result = new HEAP SQLDoublePrecision(TRUE); // See ScalarVariance::synthesizeType()
+       result = new HEAP SQLDoublePrecision(HEAP, TRUE); // See ScalarVariance::synthesizeType()
        break;
 
     default:
@@ -6721,7 +6716,7 @@ const NAType *AuditImage::synthesizeType()
   const Lng32 recordLength = naTable->getRecordLength();
 
   type = new HEAP
-    SQLVarChar(recordLength);
+    SQLVarChar(HEAP, recordLength);
 
   return type;
 }
@@ -6733,14 +6728,14 @@ const NAType * HbaseColumnLookup::synthesizeType()
   if (naType_)
     type = (NAType*)naType_;
   else
-    type = new HEAP SQLVarChar(100000);
+    type = new HEAP SQLVarChar(HEAP, 100000);
 
   return type;
 }
 
 const NAType * HbaseColumnsDisplay::synthesizeType()
 {
-  NAType * type = new HEAP SQLVarChar(displayWidth_);
+  NAType * type = new HEAP SQLVarChar(HEAP, displayWidth_);
 
   return type;
 }
@@ -6752,7 +6747,7 @@ const NAType * HbaseColumnCreate::synthesizeType()
   if (resultType_)
     type = (NAType*)resultType_;
   else
-    type = new HEAP SQLVarChar(100000);
+    type = new HEAP SQLVarChar(HEAP, 100000);
 
   return type;
 }
@@ -6761,7 +6756,7 @@ const NAType * SequenceValue::synthesizeType()
 {
   NAType * type = NULL;
 
-  type = new HEAP SQLLargeInt(TRUE, FALSE);
+  type = new HEAP SQLLargeInt(HEAP, TRUE, FALSE);
 
   return type;
 }
@@ -6770,7 +6765,7 @@ const NAType * HbaseTimestamp::synthesizeType()
 {
   NAType * type = NULL;
 
-  type = new HEAP SQLLargeInt(TRUE,  
+  type = new HEAP SQLLargeInt(HEAP, TRUE,  
                               col_->getValueId().getType().supportsSQLnull());
 
   return type;
@@ -6780,7 +6775,7 @@ const NAType * HbaseVersion::synthesizeType()
 {
   NAType * type = NULL;
 
-  type = new HEAP SQLLargeInt(TRUE, FALSE); 
+  type = new HEAP SQLLargeInt(HEAP, TRUE, FALSE); 
 
   return type;
 }
@@ -6789,7 +6784,7 @@ const NAType * RowNumFunc::synthesizeType()
 {
   NAType * type = NULL;
 
-  type = new HEAP SQLLargeInt(TRUE, FALSE);
+  type = new HEAP SQLLargeInt(HEAP, TRUE, FALSE);
 
   return type;
 }
@@ -6798,7 +6793,7 @@ const NAType *LOBoper::synthesizeType()
 {
   // Return blob or clob type
   
-  NAType *result = new HEAP SQLBlob(1000);
+  NAType *result = new HEAP SQLBlob(HEAP, 1000);
 
   if (child(0))
     {
@@ -6807,12 +6802,12 @@ const NAType *LOBoper::synthesizeType()
       
       if (typ1.getFSDatatype() == REC_BLOB)
 	{
-	  result = new HEAP SQLBlob(1000, Lob_Local_File,
+	  result = new HEAP SQLBlob(HEAP, 1000, Lob_Local_File,
 				    typ1.supportsSQLnull());
 	}
       else if (typ1.getFSDatatype() == REC_CLOB)
 	{
-	  result = new HEAP SQLClob(1000, Lob_Invalid_Storage,
+	  result = new HEAP SQLClob(HEAP, 1000, Lob_Invalid_Storage,
 				    typ1.supportsSQLnull());
 	}
     } 
@@ -6883,12 +6878,12 @@ const NAType *LOBinsert::synthesizeType()
   NAType * result = NULL;
   if (lobFsType() == REC_BLOB)
     {
-      result = new HEAP SQLBlob(lobSize(), Lob_Invalid_Storage,
+      result = new HEAP SQLBlob(HEAP, lobSize(), Lob_Invalid_Storage,
 				(obj_ ==EMPTY_LOB_) ? FALSE:typ1->supportsSQLnull());
     }
   else if (lobFsType() == REC_CLOB)
     {
-      result = new HEAP SQLClob(lobSize(), Lob_Invalid_Storage,
+      result = new HEAP SQLClob(HEAP, lobSize(), Lob_Invalid_Storage,
 				(obj_ == EMPTY_LOB_)? FALSE:typ1->supportsSQLnull());
     }
     
@@ -6978,14 +6973,14 @@ const NAType *LOBupdate::synthesizeType()
   if (typ2->getFSDatatype() == REC_BLOB)
     {
       SQLBlob &blob = (SQLBlob&)*typ2;
-      result = new HEAP SQLBlob(blob.getLobLength(), Lob_Invalid_Storage,
+      result = new HEAP SQLBlob(HEAP, blob.getLobLength(), Lob_Invalid_Storage,
 				(obj_ ==EMPTY_LOB_) ? FALSE:typ2->supportsSQLnull());
     }
   else if (typ2->getFSDatatype() == REC_CLOB)
     {
       SQLClob &clob = (SQLClob&)*typ2;
 
-      result = new HEAP SQLClob(clob.getLobLength(), Lob_Invalid_Storage,
+      result = new HEAP SQLClob(HEAP, clob.getLobLength(), Lob_Invalid_Storage,
 				(obj_ ==EMPTY_LOB_) ? FALSE:typ2->supportsSQLnull());
     }
     
@@ -7015,7 +7010,7 @@ const NAType *LOBconvertHandle::synthesizeType()
 	{
 	  SQLBlob& op1 = (SQLBlob&)vid1.getType();
 	  
-	  result = new HEAP SQLBlob(op1.getLobLength(), Lob_Invalid_Storage,
+	  result = new HEAP SQLBlob(HEAP, op1.getLobLength(), Lob_Invalid_Storage,
 				    typ1.supportsSQLnull(), FALSE, 
 				    TRUE);
 	}
@@ -7023,7 +7018,7 @@ const NAType *LOBconvertHandle::synthesizeType()
 	{
 	  SQLClob& op1 = (SQLClob&)vid1.getType();
 	  
-	  result = new HEAP SQLClob(op1.getLobLength(), Lob_Invalid_Storage,
+	  result = new HEAP SQLClob(HEAP, op1.getLobLength(), Lob_Invalid_Storage,
 				    typ1.supportsSQLnull(), FALSE, 
 				    TRUE);
 	}
@@ -7040,7 +7035,7 @@ const NAType *LOBconvertHandle::synthesizeType()
 	  return NULL;
 	}
       
-      result = new HEAP SQLBlob(1000, Lob_Invalid_Storage, typ1.supportsSQLnull(), FALSE, 
+      result = new HEAP SQLBlob(HEAP, 1000, Lob_Invalid_Storage, typ1.supportsSQLnull(), FALSE, 
 					FALSE);
       return result;
     }
@@ -7073,7 +7068,7 @@ const NAType *LOBconvert::synthesizeType()
 
       Lng32 tgtSize = MINOF((Lng32)op1.getLobLength(), tgtSize_);
 
-      NAType *result = new HEAP SQLVarChar(tgtSize, Lob_Invalid_Storage,
+      NAType *result = new HEAP SQLVarChar(HEAP, tgtSize, Lob_Invalid_Storage,
 					   typ1.supportsSQLnull());
       return result;
     }
@@ -7105,7 +7100,7 @@ const NAType *LOBextract::synthesizeType()
   
   Lng32 tgtSize = MINOF((Lng32)op1.getLobLength(), tgtSize_);
   
-  NAType *result = new HEAP SQLVarChar(tgtSize, Lob_Invalid_Storage,
+  NAType *result = new HEAP SQLVarChar(HEAP, tgtSize, Lob_Invalid_Storage,
 				       typ1.supportsSQLnull());
   return result;
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/35a656be/core/sql/optimizer/UdfDllInteraction.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/UdfDllInteraction.cpp b/core/sql/optimizer/UdfDllInteraction.cpp
index c1bfdc6..b9dbd46 100644
--- a/core/sql/optimizer/UdfDllInteraction.cpp
+++ b/core/sql/optimizer/UdfDllInteraction.cpp
@@ -1851,31 +1851,27 @@ NAType *TMUDFInternalSetup::createNATypeFromTypeInfo(
     case tmudr::TypeInfo::TINYINT:
     case tmudr::TypeInfo::TINYINT_UNSIGNED:
       result = new(heap)
-        SQLTiny((typeCode == tmudr::TypeInfo::TINYINT),
-                src.getIsNullable(),
-                heap);
+        SQLTiny(heap, (typeCode == tmudr::TypeInfo::TINYINT),
+                src.getIsNullable());
       break;
 
     case tmudr::TypeInfo::SMALLINT:
     case tmudr::TypeInfo::SMALLINT_UNSIGNED:
       result = new(heap)
-        SQLSmall((typeCode == tmudr::TypeInfo::SMALLINT),
-                 src.getIsNullable(),
-                 heap);
+        SQLSmall(heap, (typeCode == tmudr::TypeInfo::SMALLINT),
+                 src.getIsNullable());
       break;
 
     case tmudr::TypeInfo::INT:
     case tmudr::TypeInfo::INT_UNSIGNED:
       result = new(heap)
-        SQLInt((typeCode == tmudr::TypeInfo::INT),
-               src.getIsNullable(),
-               heap);
+        SQLInt(heap, (typeCode == tmudr::TypeInfo::INT),
+               src.getIsNullable());
       break;
 
     case tmudr::TypeInfo::LARGEINT:
-      result = new(heap) SQLLargeInt(TRUE,
-                                     src.getIsNullable(),
-                                     heap);
+      result = new(heap) SQLLargeInt(heap, TRUE,
+                                     src.getIsNullable());
       break;
 
     case tmudr::TypeInfo::NUMERIC:
@@ -1893,33 +1889,29 @@ NAType *TMUDFInternalSetup::createNATypeFromTypeInfo(
           }
         else
           result = new(heap) 
-            SQLNumeric(storageSize,
+            SQLNumeric(heap, storageSize,
                        src.getPrecision(),
                        src.getScale(),
                        (typeCode == tmudr::TypeInfo::NUMERIC),
-                       src.getIsNullable(),
-                       heap);
+                       src.getIsNullable());
       }
       break;
 
     case tmudr::TypeInfo::DECIMAL_LSE:
     case tmudr::TypeInfo::DECIMAL_UNSIGNED:
       result = new(heap)
-        SQLDecimal(src.getPrecision(),
+        SQLDecimal(heap, src.getPrecision(),
                    src.getScale(),
                    (typeCode == tmudr::TypeInfo::DECIMAL_LSE),
-                   src.getIsNullable(),
-                   heap);
+                   src.getIsNullable());
       break;
 
     case tmudr::TypeInfo::REAL:
-      result = new(heap) SQLReal(src.getIsNullable(),
-                                 heap);
+      result = new(heap) SQLReal(heap, src.getIsNullable());
       break;
 
     case tmudr::TypeInfo::DOUBLE_PRECISION:
-      result = new(heap) SQLDoublePrecision(src.getIsNullable(),
-                                            heap);
+      result = new(heap) SQLDoublePrecision(heap, src.getIsNullable());
       break;
 
     case tmudr::TypeInfo::CHAR:
@@ -1954,7 +1946,7 @@ NAType *TMUDFInternalSetup::createNATypeFromTypeInfo(
 
             if (typeCode == tmudr::TypeInfo::CHAR)
               result = new(heap)
-                SQLChar(lenInfo,
+                SQLChar(heap, lenInfo,
                         src.getIsNullable(),
                         FALSE,
                         FALSE,
@@ -1962,7 +1954,7 @@ NAType *TMUDFInternalSetup::createNATypeFromTypeInfo(
                         cs);
             else
               result = new(heap)
-                SQLVarChar(lenInfo,
+                SQLVarChar(heap, lenInfo,
                            src.getIsNullable(),
                            FALSE,
                            FALSE,
@@ -1972,20 +1964,17 @@ NAType *TMUDFInternalSetup::createNATypeFromTypeInfo(
       break;
 
     case tmudr::TypeInfo::DATE:
-      result = new(heap) SQLDate(src.getIsNullable(),
-                                 heap);
+      result = new(heap) SQLDate(heap, src.getIsNullable());
       break;
 
     case tmudr::TypeInfo::TIME:
-      result = new(heap) SQLTime(src.getIsNullable(),
-                                 src.getScale(),
-                                 heap);
+      result = new(heap) SQLTime(heap, src.getIsNullable(),
+                                 src.getScale());
       break;
 
     case tmudr::TypeInfo::TIMESTAMP:
-      result = new(heap) SQLTimestamp(src.getIsNullable(),
-                                      src.getScale(),
-                                      heap);
+      result = new(heap) SQLTimestamp(heap, src.getIsNullable(),
+                                      src.getScale());
       break;
 
     case tmudr::TypeInfo::INTERVAL:
@@ -2069,12 +2058,11 @@ NAType *TMUDFInternalSetup::createNATypeFromTypeInfo(
 
         if (startField != REC_DATE_UNKNOWN)
           {
-            result = new(heap) SQLInterval(src.getIsNullable(),
+            result = new(heap) SQLInterval(heap, src.getIsNullable(),
                                            startField,
                                            src.getPrecision(),
                                            endField,
-                                           src.getScale(),
-                                           heap);
+                                           src.getScale());
             if (!static_cast<SQLInterval *>(result)->checkValid(diags))
               {
                 *diags << DgSqlCode(-11152)
@@ -2088,8 +2076,7 @@ NAType *TMUDFInternalSetup::createNATypeFromTypeInfo(
       break;
 
     case tmudr::TypeInfo::BOOLEAN:
-      result = new(heap) SQLBooleanNative(src.getIsNullable(),
-                                          heap);
+      result = new(heap) SQLBooleanNative(heap, src.getIsNullable());
       break;
 
     default:

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/35a656be/core/sql/optimizer/ValueDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp
index 2aa288b..073c77b 100644
--- a/core/sql/optimizer/ValueDesc.cpp
+++ b/core/sql/optimizer/ValueDesc.cpp
@@ -247,7 +247,7 @@ void ValueId::coerceType(enum NABuiltInTypeEnum desiredQualifier,
   NAType *desiredType = NULL;
   switch (desiredQualifier) {
   case NA_BOOLEAN_TYPE:
-    desiredType = new STMTHEAP SQLBooleanNative(originalType.supportsSQLnull());
+    desiredType = new STMTHEAP SQLBooleanNative(STMTHEAP, originalType.supportsSQLnull());
     break;
   case NA_CHARACTER_TYPE:
     {
@@ -258,7 +258,7 @@ void ValueId::coerceType(enum NABuiltInTypeEnum desiredQualifier,
 #pragma warning (default : 4244)  // warning elimination
 
       desiredType = new STMTHEAP
-	SQLVarChar(len, //DEFAULT_CHARACTER_LENGTH,
+	SQLVarChar(STMTHEAP, len, //DEFAULT_CHARACTER_LENGTH,
 		   originalType.supportsSQLnull(),
 		   FALSE/*isUpShifted*/,
 		   FALSE/*isCaseinsensitive*/,
@@ -271,7 +271,7 @@ void ValueId::coerceType(enum NABuiltInTypeEnum desiredQualifier,
     {
       Int16 DisAmbiguate = 0;
       desiredType = new STMTHEAP
-      SQLNumeric(TRUE,   		// signed
+      SQLNumeric(STMTHEAP, TRUE,   		// signed
                  MAX_NUMERIC_PRECISION,	// precision
                  6,    			// scale
                  DisAmbiguate, // added for 64bit proj.
@@ -355,16 +355,14 @@ void ValueId::coerceType(const NAType& desiredType,
     {
       if (desiredType.getFSDatatype() == REC_FLOAT32)
         newType = new STMTHEAP
-          SQLReal(desiredType.supportsSQLnull(),
-                  STMTHEAP,
+          SQLReal(STMTHEAP, desiredType.supportsSQLnull(),
                   desiredType.getPrecision());
       else
         // ieee double, tandem real and tandem double are all
         // cast as IEEE double. Tandem real is cast as ieee double as
         // it won't 'fit' into ieee real.
         newType = new STMTHEAP
-          SQLDoublePrecision(desiredType.supportsSQLnull(),
-                             STMTHEAP,
+          SQLDoublePrecision(STMTHEAP, desiredType.supportsSQLnull(),
                              desiredType.getPrecision());
     }
   else {
@@ -383,10 +381,10 @@ void ValueId::coerceType(const NAType& desiredType,
              NABoolean isSigned = numType.isSigned();
              if (numType.getScale() == 0)
                newType = new (STMTHEAP)
-                 SQLSmall(isSigned, desiredType.supportsSQLnull());
+                 SQLSmall(STMTHEAP, isSigned, desiredType.supportsSQLnull());
              else
                newType = new (STMTHEAP)
-                 SQLNumeric(sizeof(short), 
+                 SQLNumeric(STMTHEAP, sizeof(short), 
                             numType.getPrecision(), 
                             numType.getScale(),
                             isSigned, 
@@ -401,28 +399,26 @@ void ValueId::coerceType(const NAType& desiredType,
                {
 		 Int16 DisAmbiguate = 0;
                  newType = new (STMTHEAP)
-                   SQLLargeInt(nTyp.getScale(),
+                   SQLLargeInt(STMTHEAP, nTyp.getScale(),
                                DisAmbiguate,
                                TRUE,
-                               nTyp.supportsSQLnull(),
-                               NULL);
+                               nTyp.supportsSQLnull());
                }
              else
                {
                  newType = new (STMTHEAP)
-                   SQLBigNum(MAX_HARDWARE_SUPPORTED_UNSIGNED_NUMERIC_PRECISION,
+                   SQLBigNum(STMTHEAP, MAX_HARDWARE_SUPPORTED_UNSIGNED_NUMERIC_PRECISION,
                              nTyp.getScale(),
                              FALSE,
                              FALSE,
-                             nTyp.supportsSQLnull(),
-                             NULL);
+                             nTyp.supportsSQLnull());
                }
            }
 	 else if ((desiredType.getFSDatatype() == REC_BOOLEAN) &&
                   (CmpCommon::getDefault(TRAF_BOOLEAN_IO) == DF_OFF))
            {
              newType = new (STMTHEAP)
-               SQLVarChar(SQL_BOOLEAN_DISPLAY_SIZE, 
+               SQLVarChar(STMTHEAP, SQL_BOOLEAN_DISPLAY_SIZE, 
                           desiredType.supportsSQLnull());
            }
 	 else if (DFS2REC::isBigNum(desiredType.getFSDatatype()))
@@ -455,11 +451,10 @@ void ValueId::coerceType(const NAType& desiredType,
 			 CmpCommon::getDefaultNumeric(MAX_NUMERIC_PRECISION_ALLOWED));
 		 Lng32 scale     = MINOF(desiredType.getScale(), precision);
 		 newType = new (STMTHEAP)
-		   SQLBigNum(precision, scale, 
+		   SQLBigNum(STMTHEAP, precision, scale, 
 			     ((SQLBigNum&)desiredType).isARealBigNum(),
 			     ((NumericType&)desiredType).isSigned(),
-			     desiredType.supportsSQLnull(),
-			     NULL);
+			     desiredType.supportsSQLnull());
 	       }
 	     else
 	       {
@@ -472,7 +467,7 @@ void ValueId::coerceType(const NAType& desiredType,
 		   
 		 Int16 DisAmbiguate = 0;
 		 newType = new (STMTHEAP)
-		   SQLNumeric(isSigned,
+		   SQLNumeric(STMTHEAP, isSigned,
 			      precision,
 			      scale,
 			      DisAmbiguate, // added for 64bit proj.
@@ -5128,7 +5123,7 @@ NABoolean ValueIdList::canSimplify(ItemExpr *itemExpr,
 	return FALSE;
 
       NumericType * ntyp = new (CmpCommon::statementHeap())
-	SQLNumeric(4, scale, scale, TRUE, FALSE);
+	SQLNumeric(CmpCommon::statementHeap(), 4, scale, scale, TRUE, FALSE);
       Lng32 cval = (Lng32)div;
       char cvalStr[20];
       cvalStr[0] = '.';

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/35a656be/core/sql/optimizer/mdam.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/mdam.cpp b/core/sql/optimizer/mdam.cpp
index 01d99f4..05db172 100644
--- a/core/sql/optimizer/mdam.cpp
+++ b/core/sql/optimizer/mdam.cpp
@@ -1016,7 +1016,7 @@ static ItemExpr *convertCastToNarrow(ItemExpr *expr,
       return new(outHeap)
         Narrow(expr->child(0),
                new(outHeap) HostVar("_sys_ignored_CC_convErrorFlag",
-                                    new (outHeap) SQLInt(TRUE,FALSE),
+                                    new (outHeap) SQLInt(outHeap, TRUE,FALSE),
                                     TRUE),
                src->getType()->newCopy(outHeap));
     }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/35a656be/core/sql/parser/SqlParserAux.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/SqlParserAux.cpp b/core/sql/parser/SqlParserAux.cpp
index 6f533c9..58196dd 100644
--- a/core/sql/parser/SqlParserAux.cpp
+++ b/core/sql/parser/SqlParserAux.cpp
@@ -477,7 +477,7 @@ RelRoot *finalize(RelExpr *top, NABoolean outputVarCntValid)
                       argInfo = TheProcArgTypes->get(ivName);
                       if (!argInfo)
                         argInfo = new (PARSERHEAP()) HVArgType
-                          (ivName, new (PARSERHEAP()) SQLUnknown);
+                          (ivName, new (PARSERHEAP()) SQLUnknown(PARSERHEAP()));
                       argInfo->useCount()++;
                       argInfo->intoCount()++;
                     }
@@ -658,7 +658,7 @@ HostVar *makeHostVar(NAString *hvName, NAString *indName, NABoolean isDynamic)
   HVArgType *argInfo = TheProcArgTypes ?
 		       TheProcArgTypes->get(hvName) : NULL;
   NAType    *naType  = argInfo ?
-		       argInfo->getType() : new (PARSERHEAP()) SQLUnknown;
+		       argInfo->getType() : new (PARSERHEAP()) SQLUnknown(PARSERHEAP());
   ComASSERT(naType);
   naType->setNullable(!!indName);
 
@@ -889,7 +889,7 @@ ItemExpr *literalOfNumericPassingScale(NAString *strptr, char sign,
 	returnValue = 
 	  new (PARSERHEAP()) ConstValue
 	  (new (PARSERHEAP()) SQLLargeInt
-	    ((Lng32)scale, 
+	    (PARSERHEAP(), (Lng32)scale, 
              (UInt16) 0, // 64-bit
 	     TRUE,
 	     FALSE),
@@ -900,7 +900,7 @@ ItemExpr *literalOfNumericPassingScale(NAString *strptr, char sign,
 	returnValue = 
 	  new (PARSERHEAP()) ConstValue
 	  (new (PARSERHEAP()) SQLNumeric
-	   (length,
+	   (PARSERHEAP(), length,
 	    (Lng32)strSize, // precision
 	    (Lng32)scale, 
 	    createSignedDatatype,
@@ -956,12 +956,11 @@ ItemExpr *literalOfNumericPassingScale(NAString *strptr, char sign,
     
       returnValue = new (PARSERHEAP()) ConstValue
 #pragma nowarn(1506)   // warning elimination 
-        (new (PARSERHEAP()) SQLBigNum(strSize, 
+        (new (PARSERHEAP()) SQLBigNum(PARSERHEAP(), strSize, 
                                       scale,
                                       TRUE,
                                       TRUE,
-                                      FALSE,
-				      NULL),
+                                      FALSE),
          (void *) bigNumData,
          bigNumSize,
          strptr);
@@ -1162,7 +1161,7 @@ ItemExpr *literalOfApproxNumeric(NAString *strptr, char sign)
     }
 
   returnValue = new (PARSERHEAP()) ConstValue (new (PARSERHEAP())
-					       SQLDoublePrecision(FALSE),
+					       SQLDoublePrecision(PARSERHEAP(), FALSE),
 					       (void *)&doubleVal,
 					       sizeof(double),
 					       strptr);
@@ -1184,12 +1183,11 @@ ItemExpr *literalOfInterval(NAString *strptr,
                               qualifier->getFractionPrecision(),
                               sign);
   IntervalType *intervalType = new (PARSERHEAP())
-		  SQLInterval(FALSE,
+		  SQLInterval(PARSERHEAP(), FALSE,
 			      qualifier->getStartField(),
 			      qualifier->getLeadingPrecision(),
 			      qualifier->getEndField(),
-			      qualifier->getFractionPrecision(),
-                              PARSERHEAP());
+			      qualifier->getFractionPrecision());
   strptr->prepend("'");
   strptr->append ("' ");
   strptr->append (intervalType->getIntervalQualifierAsString());
@@ -1229,7 +1227,7 @@ ItemExpr *literalOfDate(NAString *strptr, NABoolean noDealloc)
      *SqlParser_Diags << DgSqlCode(-3045) << DgString0(*strptr);
   else
     returnValue = new (PARSERHEAP()) ConstValue (new (PARSERHEAP())
-		    SQLDate(FALSE, PARSERHEAP()),
+		    SQLDate(PARSERHEAP(), FALSE),
 		    (void *) dtValue.getValue(),
 		    dtValue.getValueLen(),
 		    strptr);
@@ -1251,7 +1249,7 @@ ItemExpr *literalOfTime(NAString *strptr)
       *SqlParser_Diags << DgSqlCode(-3046) << DgString0(*strptr);
   else
     returnValue = new (PARSERHEAP()) ConstValue (new (PARSERHEAP())
-		    SQLTime(FALSE, fractionPrec,PARSERHEAP()),
+		    SQLTime(PARSERHEAP(), FALSE, fractionPrec),
 		    (void *) dtValue.getValue(),
 		    dtValue.getValueLen(),
 		    strptr);
@@ -1330,7 +1328,7 @@ ItemExpr *literalOfTimestamp(NAString *strptr)
   else
     returnValue = new (PARSERHEAP())
       ConstValue (new (PARSERHEAP())
-                  SQLTimestamp (FALSE, fractionPrec, PARSERHEAP()),
+                  SQLTimestamp (PARSERHEAP(), FALSE, fractionPrec),
                   (void *) dtValue.getValue(),
                   dtValue.getValueLen(),
                   strptr);
@@ -2057,7 +2055,7 @@ NAType *picNAType(const NABoolean      isString,
             Int32 maxBytesPerChar = CharInfo::maxBytesPerChar(charset);
             returnValue = new (PARSERHEAP())
               //            SQLChar(precision,TRUE,FALSE,isCaseinsensitive,FALSE,charset,collation,coerc);
-              SQLChar(CharLenInfo(characterLimit, maxLenInBytes),
+              SQLChar(PARSERHEAP(), CharLenInfo(characterLimit, maxLenInBytes),
                       TRUE,FALSE,isCaseinsensitive,FALSE,
                       charset,collation,coerc,eEncodingCharSet);
             assert(returnValue);
@@ -2066,7 +2064,7 @@ NAType *picNAType(const NABoolean      isString,
         case STYLE_UPSHIFT:
 	    returnValue = new (PARSERHEAP())
 #pragma nowarn(1506)   // warning elimination 
-  		SQLChar(precision,TRUE,TRUE,isCaseinsensitive,FALSE,charset,collation,coerc);
+  		SQLChar(PARSERHEAP(), precision,TRUE,TRUE,isCaseinsensitive,FALSE,charset,collation,coerc);
 #pragma warn(1506)  // warning elimination 
             assert(returnValue);
             break;
@@ -2105,7 +2103,7 @@ NAType *picNAType(const NABoolean      isString,
            else
               returnValue = new (PARSERHEAP())
 #pragma nowarn(1506)   // warning elimination 
-		SQLDecimal(precision,scale,hasSign);
+		SQLDecimal(PARSERHEAP(), precision,scale,hasSign);
 #pragma warn(1506)  // warning elimination 
            assert(returnValue);
            break;
@@ -2128,7 +2126,7 @@ NAType *picNAType(const NABoolean      isString,
               const Int16 DisAmbiguate = 0; // added for 64bit project
               returnValue = new (PARSERHEAP())
 #pragma nowarn(1506)   // warning elimination 
-		SQLNumeric(hasSign, precision, scale, DisAmbiguate);
+		SQLNumeric(PARSERHEAP(), hasSign, precision, scale, DisAmbiguate);
 #pragma warn(1506)  // warning elimination 
               assert(returnValue);
            }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/35a656be/core/sql/parser/StmtDDLCreate.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCreate.cpp b/core/sql/parser/StmtDDLCreate.cpp
index 47973b3..56cf307 100644
--- a/core/sql/parser/StmtDDLCreate.cpp
+++ b/core/sql/parser/StmtDDLCreate.cpp
@@ -2913,32 +2913,32 @@ StmtDDLCreateRoutine::synthesize()
             {
             case COM_UUDF_PARAM_ACTION:
               pParamName2     = new(STMTHEAP) ElemDDLParamName("ACTION");
-              pParamDataType2 = new(STMTHEAP) SQLVarChar ( 1024  // long maxLength
+              pParamDataType2 = new(STMTHEAP) SQLVarChar (STMTHEAP, 1024  // long maxLength
                                                          , FALSE // NABoolean allowSQLnull
                                                          );
               break;
             case COM_UUDF_PARAM_SAS_FORMAT:
               pParamName2     = new(STMTHEAP) ElemDDLParamName("SAS_FORMAT");
-              pParamDataType2 = new(STMTHEAP) SQLVarChar ( 1024  // long maxLength
+              pParamDataType2 = new(STMTHEAP) SQLVarChar (STMTHEAP, 1024  // long maxLength
                                                          , FALSE // NABoolean allowSQLnull
                                                          );
               break;
             case COM_UUDF_PARAM_SAS_LOCALE:
               pParamName2     = new(STMTHEAP) ElemDDLParamName("SAS_LOCALE");
-              pParamDataType2 = new(STMTHEAP) SQLInt ( TRUE  // NABoolean allowNegValues
+              pParamDataType2 = new(STMTHEAP) SQLInt (STMTHEAP,  TRUE  // NABoolean allowNegValues
                                                      , FALSE // NABoolean allowSQLnull
                                                      );
               break;
             case COM_UUDF_PARAM_SAS_MODEL_INPUT_TABLE:
               pParamName2     = new(STMTHEAP) ElemDDLParamName("SAS_MODEL_INPUT_TABLE");
-              pParamDataType2 = new(STMTHEAP) SQLVarChar ( 1024  // long maxLength
+              pParamDataType2 = new(STMTHEAP) SQLVarChar (STMTHEAP, 1024  // long maxLength
                                                          , FALSE // NABoolean allowSQLnull
                                                          );
               break;
             default:
             case COM_UUDF_PARAM_OMITTED:           // any dummy data type would do
               pParamName2     = NULL;
-              pParamDataType2 = new(STMTHEAP) SQLChar ( 1     // long maxLength
+              pParamDataType2 = new(STMTHEAP) SQLChar (STMTHEAP, 1     // long maxLength
                                                       , FALSE // NABoolean allowSQLnull
                                                       );
               break;