ExControlEntry::~ExControlEntry()
{
  NADELETEBASIC(sqlText_, heap_);
  for (Int32 i = 0; i < this->getNumValues(); i++)
      NADELETEBASIC(this->getValue(i+1), heap_) ;
      
}
NABoolean  ExSequenceTcb::removeOLAPBuffer()
{

  if (lastOLAPBuffer_ == NULL || firstOLAPBuffer_ == NULL)
  {
    // LCOV_EXCL_START
    return FALSE;
    // LCOV_EXCL_STOP
  }

  if (lastOLAPBuffer_ == firstOLAPBuffer_)
  {
   // LCOV_EXCL_START
   // since we keep a minimum number of buffers this code won't be visited
   // this code should not be removed. if we decide to not keep a min number 
   // of buffers in the list it will be used
    NADELETEBASIC( lastOLAPBuffer_ ,heap_);
    numberOfOLAPBuffers_ = 0;
    maxNumberHistoryRows_ = myTdb().maxHistoryRows_;
    lastOLAPBuffer_ = NULL;
    firstOLAPBuffer_ = NULL;
    return TRUE;
    // LCOV_EXCL_STOP
  }

  HashBuffer * tmpBuf = lastOLAPBuffer_;
  lastOLAPBuffer_ = lastOLAPBuffer_->getPrev();
  NADELETEBASIC( tmpBuf ,heap_);
  lastOLAPBuffer_->setNext(NULL);
  numberOfOLAPBuffers_ --;
  maxNumberHistoryRows_ = numberOfOLAPBuffers_ * maxRowsInOLAPBuffer_;
  return TRUE;
}
Example #3
0
NARoutine::~NARoutine()
{
  // Call deepDelete() on NAColumnArray's.  
  // The destructor does not do this.
  inParams_->deepDelete();
  outParams_->deepDelete();
  delete inParams_;
  delete outParams_;
  delete params_;    // Do not do a deepDelete() on params_ the
                     // elements are shared with in|outParams_.
  delete extRoutineName_;
  delete extActionName_;
  delete intActionName_;
  uecValues_.clear(); // delete all its elements.  
  if (passThruData_ NEQ NULL)
  {
    for (Int32 i = 0; i < passThruDataNumEntries_; i++)
      NADELETEBASIC(passThruData_[i], heap_); // Can't use NADELETEARRAY on C types.
    NADELETEBASIC(passThruData_, heap_);      // Can't use NADELETEARRAY on C types.
  }
  if (passThruDataSize_ NEQ NULL) // Use NADELETEARRAY for any 'new(heap)<class>[<size>]'
    NADELETEARRAY(passThruDataSize_, (UInt32)passThruDataNumEntries_, Int64, heap_);

  if (privInfo_)
   NADELETE(privInfo_, PrivMgrUserPrivs, heap_);
}
AQRStatementAttributes::~AQRStatementAttributes()
{
  if (uniqueStmtId_)
    NADELETEBASIC(uniqueStmtId_,heap_);
  if (parentQID_)
    NADELETEBASIC(parentQID_,heap_);
}
ExExeUtilTcb::~ExExeUtilTcb()
{
  delete qparent_.up;
  delete qparent_.down;
  if (workAtp_)
    {
      workAtp_->release();
      deallocateAtp(workAtp_, getGlobals()->getSpace());
      workAtp_ = NULL;
    }
  freeResources();

  if (extractedPartsObj_)
    {
      delete extractedPartsObj_;
      extractedPartsObj_ = NULL;
    }
  if (explQuery_)
    NADELETEBASIC(explQuery_, getHeap());
  if (childQueryId_ != NULL)
  {
    NADELETEBASIC(childQueryId_, getHeap());
    childQueryId_ = NULL;
    childQueryIdLen_ = 0;
  }
  if (outputBuf_ != NULL)
  {
    NADELETEBASIC(outputBuf_, getHeap());
    outputBuf_ = NULL;
    outputBuf_ = 0;
  }

};
SessionEnvvar& SessionEnvvar::operator =(const SessionEnvvar &other)
{
  if (envvarName_)
    NADELETEBASIC(envvarName_, heap_);

  if (envvarValue_)
    NADELETEBASIC(envvarValue_, heap_);

  heap_ = other.heap_;

  if (other.envvarName_)
    {
      envvarName_ = new(heap_) char[strlen(other.envvarName_)+1];
      strcpy(envvarName_, other.envvarName_);
    }
  else
    envvarName_ = NULL;

  if (other.envvarValue_)
    {
      envvarValue_ = new(heap_) char[strlen(other.envvarValue_)+1];
      strcpy(envvarValue_, other.envvarValue_);
    }
  else
    envvarValue_ = NULL;

  return (*this);
}
LmResult LmRoutineCppObj::dealloc(ComDiagsArea *diagsArea)
{
  LmResult result = LM_OK;

  delete invocationInfo_;
  invocationInfo_ = NULL;

  for (CollIndex i=0; i<planInfos_.getUsedLength(); i++)
    if (planInfos_.used(i))
      delete planInfos_[i];
  planInfos_.clear();

  if (paramRow_)
    {
      NADELETEBASIC(paramRow_, collHeap());
      paramRow_ = NULL;
    }

  if (inputRows_)
    {
      for (int i=0; i<numInputTables_; i++)
        if (inputRows_[i])
          NADELETEBASIC((inputRows_[i]), collHeap());
      NADELETEBASIC(inputRows_, collHeap());
      inputRows_ = NULL;
    }
  if (outputRow_)
    {
      // actually allocated buffer started where the wall starts
      NADELETEBASIC((outputRow_ - WALL_STRING_LEN), collHeap());
      outputRow_ = NULL;
    }

  try
    {
      // delete the interface object, the virtual destructor may call user code
      delete interfaceObj_;
    }
  catch (tmudr::UDRException e)
    {
      *diagsArea << DgSqlCode(-LME_UDR_METHOD_ERROR)
                 << DgString0("destructor")
                 << DgString1(getNameForDiags())
                 << DgString2(e.getMessage().c_str());
      result = LM_ERR;
    }
  catch (...)
    {
      *diagsArea << DgSqlCode(-LME_UDR_METHOD_ERROR)
                 << DgString0("destructor")
                 << DgString1(getNameForDiags())
                 << DgString2("General exception.");
      result = LM_ERR;
    }

  interfaceObj_ = NULL;

  return result;
}
Example #8
0
hive_column_desc::~hive_column_desc()
{
  CollHeap *h = CmpCommon::contextHeap();
  if (name_)
    NADELETEBASIC(name_, h);
  if (type_)
    NADELETEBASIC(type_, h);
}
SessionEnvvar::~SessionEnvvar()
{
  if (envvarName_)
    NADELETEBASIC(envvarName_, heap_);

  if (envvarValue_)
    NADELETEBASIC(envvarValue_, heap_);
}
Example #10
0
void CmpMessageRequest::destroyMe()
{
   NADELETEBASIC(data_, getHeap());
   if (allocated_ && parentQid_ != NULL)
   {
     NADELETEBASIC(parentQid_, getHeap());
     parentQid_ = NULL;
     parentQidLen_ = 0;
   }
} 
ExPCMgr::~ExPCMgr()
{
  if (buckets_ != NULL)
    NADELETEBASIC(buckets_, space_);
  buckets_ = NULL;

  if (entries_ != NULL)
    NADELETEBASIC(entries_, space_);
  entries_ = NULL;
}
Example #12
0
void CmpMessageISPRequest::destroyMe() 
{
  if (allocated_)
    {
      NADELETEBASIC(procName_, getHeap());
      NADELETEBASIC((char*)inputExpr_, getHeap());
      NADELETEBASIC((char*)outputExpr_, getHeap());
      NADELETEBASIC((char*)keyExpr_, getHeap());
      NADELETEBASIC((char*)inputData_, getHeap());
    }
}
void NAColumn::deepDelete()
{
  if(defaultValue_)
  NADELETEBASIC(defaultValue_,heap_);
  if(heading_)
  NADELETEBASIC(heading_,heap_);
  delete type_;
  delete isNotNullNondroppable_;
  if (computedColumnExpression_)
    NADELETEBASIC(computedColumnExpression_,heap_);
}
void HdfsClient::deleteHdfsFileInfo()
{
   for (int i = 0; i < numFiles_ ; i ++) {
      NADELETEBASIC(hdfsFileInfo_[i].mName, getHeap());
      NADELETEBASIC(hdfsFileInfo_[i].mOwner, getHeap());
      NADELETEBASIC(hdfsFileInfo_[i].mGroup, getHeap());
   }
   if (hdfsFileInfo_ != NULL)
      NADELETEBASICARRAY(hdfsFileInfo_, getHeap()); 
   numFiles_ = 0;
   hdfsFileInfo_ = NULL;
}
LmRoutineJava::~LmRoutineJava()
{
  JNIEnv *jni = (JNIEnv*)getLM()->jniEnv_;
  jvalue *jval = (jvalue*)javaParams_;

  // Free LmResultSet objects
  // This will also close the Java result set objects
  // and the Java connections that they are part of.
  cleanupResultSets();

  // Free LmConnection objects for default connections
  // Closes any open default connections that do not have 
  // result sets associated with them
  closeDefConnWithNoRS();

  connectionList_.clear();
    
  // Release array refs for params, indicated
  // by non-null object.
  for (Int32 i = 0; i < (Int32)numParamsInSig_; i++)
  {
    if (jval[i].l != NULL)
      jni->DeleteLocalRef(jval[i].l);
  }

  // Free the Java parameter array
  if (javaParams_)
    NADELETEBASIC((jvalue *)javaParams_, collHeap());
}
void ExProbeCacheTcb::freeResources()
{
  if (pool_) 
    {
      delete pool_;
      pool_ = NULL;
    }

  if (qparent_.up)
    {
      delete qparent_.up;
      qparent_.up = NULL;
    }
  
  if (qparent_.down)
    {
      delete qparent_.down;
      qparent_.down = NULL;
    }

  if (probeBytes_)  
    {
      NADELETEBASIC(probeBytes_, getSpace());
      probeBytes_ = NULL;
    }

  if (pcm_)
    {
      delete pcm_;
      pcm_ = NULL;
    }
}
void ProcessEnv::resetEnv(const char* envName)
{
  if (!envName)
    return;

  Int32 i;
  size_t nameLen=strlen(envName);
  CollHeap *stmtHeap = CmpCommon::statementHeap();
  NAList<Int32> deleteArray(stmtHeap, 16);  // 16 should be more than enough

  // find the env in existing env array
  for (i=0; i < envs_.getSize(); i++)
  {
    if (envs_.used(i))
    {
      char* pTemp = strchr(envs_[i], '=');
      if (pTemp) // found '='
        {
          Int32 envLen = (Int32)(pTemp - envs_[i]);
          if (envLen == nameLen && strncmp(envName, envs_[i], nameLen) == 0 )
            {  // found matching env var name
              *(pTemp) = '\0';
              PUTENV(envs_[i]);
              NADELETEBASIC(envs_[i], heap_);
              deleteArray.insert(i);
            }
        }
    }
  }

  // remove from the env array
  for (Int32 j = 0; j < deleteArray.entries(); j++) {
    envs_.remove(deleteArray[j]);
  }
}
ex_expr::exp_return_type ExExeUtilTcb::evalScanExpr(char * ptr, Lng32 len,
                                                    NABoolean copyToVCbuf)
{
  ex_expr::exp_return_type exprRetCode = ex_expr::EXPR_OK;

  if (exeUtilTdb().scanExpr_)
    {
      ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();

      char * exprPtr = ptr;
      if (copyToVCbuf)
        {
          exprPtr = new(getGlobals()->getDefaultHeap())
            char[SQL_VARCHAR_HDR_SIZE + len];
          short shortLen = (short)len;
          str_cpy_all((char*)exprPtr, (char*)&shortLen, SQL_VARCHAR_HDR_SIZE);
          str_cpy_all(&exprPtr[SQL_VARCHAR_HDR_SIZE], ptr, shortLen);
        }

      workAtp_->getTupp(exeUtilTdb().workAtpIndex())
	.setDataPointer(exprPtr);

      exprRetCode =
	exeUtilTdb().scanExpr_->eval(pentry_down->getAtp(), workAtp_);

      if (exprPtr != ptr)
        NADELETEBASIC(exprPtr, getGlobals()->getDefaultHeap());
    }

  return exprRetCode;
}
Example #19
0
CmpInternalSP::~CmpInternalSP()
{
  if ( state_ == COMPILE )
    {
      // needs to call the compileFunc_
      initSP_ERROR_STRUCT();
      if ( (*(procFuncs_.compileFunc_)) (SP_COMP_EXIT, &compHandle_,
        procFuncs_.spHandle_, &spError_[0]) !=SP_SUCCESS)
        appendDiags();
    }

  // if not being properly closed, could be an exception happened,
  // close the process properly 
  if ( state_ == PROCESS )
  {
    close(*ispData_);
    // When it gets here, there must be an assertion happened before. 
    // To pass back the error infomation from SP close interface routine,
    // the CoMDiags is moved into the context_ diags. 
    cmpContext()->diags()->mergeAfter(ispData_->output()->diags());
  }

  delete ispData_;

  for ( Int32 j=0; j < SP_MAX_ERROR_STRUCTS; j++ )
  {
    for (Int32 i=0; i < SP_ERROR_MAX_OPTIONAL_STRINGS; i++)
      NADELETEBASIC(spError_[j].optionalString[i], cmpContext()->statementHeap());  
  }
}
HdfsClient::~HdfsClient()
{
   QRLogger::log(CAT_SQL_HDFS, LL_DEBUG, "HdfsClient::~HdfsClient() called.");
   deleteHdfsFileInfo();
   if (path_ != NULL) 
      NADELETEBASIC(path_, getHeap());
}
void HdfsClient::setPath(const char *path)
{
   if (path_ != NULL) 
      NADELETEBASIC(path_, getHeap());
   short len = strlen(path);
   path_ = new (getHeap()) char[len+1];
   strcpy(path_, path); 
}
void ProcessEnv::addOrChangeEnv(char **newenvs, Lng32 nEnvs)
{
  Lng32 i,j;

  for (i=0; i < nEnvs; i++)
  {
    char* pTemp = strchr(newenvs[i], '=');
    if (pTemp)
    {
      NABoolean sameValue = FALSE;
      Int32 envNameLen = pTemp - (newenvs[i]) + 1; // including '='
      char* envName = new char[envNameLen+1];
      strncpy(envName, newenvs[i], envNameLen);
      envName[envNameLen] = '\0';

      NABoolean envChanged = FALSE;
      CollIndex entriesChecked = 0;
      for (j=0; entriesChecked < envs_.entries(); j++)
      {
        if ( envs_.used(j) )
        {
          if (strcmp(newenvs[i], envs_[j]) == 0)
          {
            sameValue = TRUE;
            break;
          }
          else if (strncmp(envName, envs_[j], envNameLen) == 0)
          {
            envChanged = TRUE;
            break;
          }
          entriesChecked++;
        }
      }
      if (!sameValue)
      {
        CollIndex index = j;  // Put to the same location if value changed
        if ( envChanged )
        {
          NADELETEBASIC(envs_[j], heap_);
          envs_.remove(j);
        }
        else
          index = envs_.unusedIndex();  // Insert a new env string

	UInt32 len = strlen(newenvs[i]);
	char *copyEnv = new (heap_) char[len + 1];
	strcpy(copyEnv, newenvs[i]);
	copyEnv[len] = 0;

        PUTENV(copyEnv);
        envs_.insertAt(index, copyEnv);
      }
      delete[] envName;
    }
  }
}
// Update the phase name with additional info.
// There are case (such the optimizer task count) that needs to updated
// to reflect the correct values that embedded in the phase name.
void MemoryUsage::updatePhaseName(char *updatedPhaseName)
{
  if (updatedPhaseName)
  {
    NADELETEBASIC(phaseName_, heap_);
    phaseName_ = new(heap_) char[strlen(updatedPhaseName)+1]; 
    strcpy(phaseName_, updatedPhaseName);
  }
}
Example #24
0
 void
 Allocator::deallocate(char*& buffer)
 {
   if (buffer)
   {
     NADELETEBASIC(buffer, heap_);
     buffer = NULL;
     memAllocated_ -= bufferSize_;
   }
 }
void
TriggerStatusWA::deallocateStatusArray()
{
	ex_assert(heap_, "heap of TriggerStatusArray must be initialized");
	if (currentNumEntries_ == 0)
		return;
	currentNumEntries_ = 0;
	NADELETEBASIC(triggerStatusArray_, heap_);
	triggerStatusArray_ = NULL;
}
//--------------------------------------------------------------------------
//~SQDisk()
//     The destructor.  It will destroy all the individual DiskDetails
//     but the table remains and will be destroyed by the destructor
//     for diskpo0l.
//--------------------------------------------------------------------------
SQDisk::~SQDisk()
{
  if (diskTablePtr_ != NULL) {
    for (short i=0; i < numberOfDisks_; i++) 
    {
       delete diskTablePtr_[i];
    }
    NADELETEBASIC(diskTablePtr_, heap_); //? USE NADELETEARRAY 
    diskTablePtr_ = NULL;
  }
}
Example #27
0
void TreeNode::deallocate() 
{
  // No need to delete scratch file, it is managed outside the scope
  // of this code. Infact sortMergeNode_->scrBlock1_ must be
  // deallocated in the same location as it got allocated.
  if (sortMergeNode_ != NULL)
  {
    sortMergeNode_->cleanup();
    NADELETEBASIC(sortMergeNode_, heap_);
    sortMergeNode_ = NULL;
  }
}
short ExExeUtilLongRunningTcb::finalizeDoLongRunning() 
{

  // Close the statements
  Lng32 rc = cliInterface()->prepareAndExecRowsEpilogue();

  NADELETE(initialOutputVarPtrList_, Queue, getHeap());
  NADELETE(continuingOutputVarPtrList_, Queue, getHeap());
  NADELETEBASIC(lruStmtAndPartInfo_, getHeap());
  NADELETEBASIC(lruStmtWithCKAndPartInfo_, getHeap());

  // if this is an ESP, deallocate transaction
  CliGlobals *cliGlobals = GetCliGlobals();
  if (cliGlobals->isESPProcess())
  {
     NADELETEBASIC(currTransaction_, getHeap());
     currTransaction_ = NULL;
  }

  return 0;
}
Example #29
0
hive_sd_desc::~hive_sd_desc()
{
  CollHeap *h = CmpCommon::contextHeap();
  if (location_)
    NADELETEBASIC(location_, h);
  if (inputFormat_)
    NADELETEBASIC(inputFormat_, h);
  if (outputFormat_)
    NADELETEBASIC(outputFormat_, h);

  hive_column_desc* ptr ;
  while (column_) {
    ptr = column_->next_;       
    NADELETEBASIC(column_, h);
    column_ = ptr;
  }
 
  hive_skey_desc* ptr1 ;
  while (skey_) {
    ptr1 = skey_->next_;       
    NADELETEBASIC(skey_, h);
    skey_ = ptr1;
  }

  hive_bkey_desc* ptr2 ;
  while (bkey_) {
    ptr2 = bkey_->next_;       
    NADELETEBASIC(bkey_, h);
    bkey_ = ptr2;
  }
}
//<pb>
//==============================================================================
//  Set up global pointer to cluster information if this hasn't been done 
// previously.
//
// Input:
//  none
//
// Output:
//  none
//
// Return:
//  none
//
//==============================================================================
void setUpClusterInfo(CollHeap* heap)
{
  #ifndef NDEBUG
  // LCOV_EXCL_START
  if (getenv("NO_SERVICES"))  // KSKSKS
    return;                   // KSKSKS
  // LCOV_EXCL_STOP
  #endif


  //-------------------------------------------------------
  // Set up cluster information based on hardware platform.
  //-------------------------------------------------------
  if (OSIM_runningSimulation() && !OSIM_ClusterInfoInitialized())
  {
    switch (CURRCONTEXT_OPTSIMULATOR->getCaptureSysType())
    {
        case OptimizerSimulator::OSIM_LINUX:
            if(gpClusterInfo) NADELETEBASIC(gpClusterInfo, heap);
            gpClusterInfo = new (heap) NAClusterInfoLinux (heap);
            break;
        default:
            CMPASSERT(0); // Case not handled
            break;
    }
  } 
  else if(OSIM_runningInCaptureMode() && !OSIM_ClusterInfoInitialized())
  {
      if(gpClusterInfo) NADELETEBASIC(gpClusterInfo, heap);
      gpClusterInfo = new (heap) NAClusterInfoLinux (heap);
  }
  else
  {
    //-------------------------------------------
    // Return now if cluster info already set up.
    //-------------------------------------------
    if (!gpClusterInfo)
        gpClusterInfo = new (heap) NAClusterInfoLinux (heap);
  }
}