void ExProcessIdsOfFrag::unpackObj(IpcMessageObjType objType,
				   IpcMessageObjVersion objVersion,
				   NABoolean sameEndianness,
				   IpcMessageObjSize objSize,
				   IpcConstMessageBufferPtr buffer)
{
  ex_assert(objType == ESP_PROCESS_IDS_OF_FRAG AND
	    objVersion == CurrProcessIdsOfFragVersion AND
	    sameEndianness AND
	    objSize >= baseClassPackedLength() +
	       sizeof(fragmentId_) + sizeof(CollIndex),
            "Received invalid ProcessIdsOfFrag object");

  unpackBaseClass(buffer);

  // unpack fragment id and number of entries
  Int32 np;
  buffer += sizeof(spare_);
  str_cpy_all((char *) &fragmentId_, buffer, sizeof(fragmentId_));
  buffer += sizeof(fragmentId_);
  str_cpy_all((char *) &np, buffer, sizeof(np));
  buffer += sizeof(np);

  // unpack the process ids
  for (CollIndex i = 0; i < (CollIndex) np; i++)
    {
      alignBufferForNextObj(buffer);
      processIds_.insert(IpcProcessId());
      processIds_[i].unpackDependentObjFromBuffer(buffer,sameEndianness);
    }
}
// copy_chars(): create a copy of given chars on the specified heap.
// The C runtime heap is used if heap is NULL. Target string is null
// terminated if terminate is TRUE. A pointer to the copy is returned.
char *copy_chars(NAMemory *heap, const char *src, ComUInt32 len,
                 NABoolean terminate)
{
  if (!src)
    return NULL;

  if (terminate)
    len++;

  char *tgt;
  if (heap)
    tgt = new (heap) char [len];
  else
    tgt = (char *) malloc(len);
  
  LMCOMMON_ASSERT(tgt);
  
  if (terminate)
  {
    str_cpy_all(tgt, src, (Lng32)len-1);
    tgt[len-1] = '\0';
  }
  else
    str_cpy_all(tgt, src, (Lng32)len);
  
  return tgt;
}
IpcMessageObjSize ExProcessIdsOfFrag::packObjIntoMessage(
     IpcMessageBufferPtr buffer)
{
  IpcMessageObjSize result = packBaseClassIntoMessage(buffer);
  Int32 np = processIds_.entries();

  // pack fragment id and number of entries
  str_cpy_all(buffer, (const char *) &spare_, sizeof(spare_));
  result += sizeof(spare_);
  buffer += sizeof(spare_);
  str_cpy_all(buffer, (const char *) &fragmentId_, sizeof(fragmentId_));
  result += sizeof(fragmentId_);
  buffer += sizeof(fragmentId_);
  str_cpy_all(buffer, (const char *) &np, sizeof(np));
  result += sizeof(np);
  buffer += sizeof(np);

  // pack each process id, as an IpcMessageObj
  for (CollIndex i = 0; i < (CollIndex) np; i++)
    {
      alignSizeForNextObj(result);
      alignBufferForNextObj(buffer);
      IpcMessageObjSize pidsize =
	processIds_[i].packDependentObjIntoMessage(buffer);
      result += pidsize;
      buffer += pidsize;
    }

  return result;
}
void CmpCompileInfo::packVars(char * buffer, CmpCompileInfo *ci,
                              Lng32 &nextOffset)
{
  if (sqltext_ && (sqlTextLen_ > 0))
    {
      str_cpy_all(&buffer[nextOffset], sqltext_, sqlTextLen_);
      ci->sqltext_ = (char *)nextOffset;
      nextOffset += ROUND8(sqlTextLen_);
    }
  
  if (rlnil_ && (rlnilLen_ > 0))
    {
      str_cpy_all(&buffer[nextOffset], (char *)rlnil_, rlnilLen_);
      ci->rlnil_ = (RecompLateNameInfoList *)nextOffset;
      nextOffset += ROUND8(rlnilLen_);
    }

  if (schemaName_ && (schemaNameLen_ > 0))
    {
      str_cpy_all(&buffer[nextOffset], (char *)schemaName_, schemaNameLen_);
      ci->schemaName_ = (char *)nextOffset;
      nextOffset += ROUND8(schemaNameLen_);
    }

  if (recompControlInfo_ && (recompControlInfoLen_ > 0))
    {
      str_cpy_all(&buffer[nextOffset], (char *)recompControlInfo_, recompControlInfoLen_);
      ci->recompControlInfo_ = (char *)nextOffset;
      nextOffset += ROUND8(recompControlInfoLen_);
    }
}
void MdamColumn::completeKey(char *bktarget,
			     char *ektarget,
			     short bkexcl,
			     short ekexcl)
{
  Int32 len = Int32(columnGenInfo_->getLength());
  char *extremalValue;

  bktarget = bktarget + columnGenInfo_->getOffset();
  ektarget = ektarget + columnGenInfo_->getOffset();

  if (bkexcl)
    // use hi value if begin key is excluded
    extremalValue = hi_.getDataPointer();  
  else
    // use lo value if begin key is included
    extremalValue = lo_.getDataPointer(); 
  
  str_cpy_all(bktarget,extremalValue,len);
  
  if (ekexcl)
    // use lo value if end key is excluded
    extremalValue = lo_.getDataPointer(); 
  else
    // use hi value if end key is included
    extremalValue = hi_.getDataPointer(); 
  
  str_cpy_all(ektarget,extremalValue,len);
};
Example #6
0
short ex_tcb::moveRowToUpQueue(ex_queue_pair *qparent,
                               UInt16 tuppIndex,
                               const char * row, Lng32 len, 
                               short * rc, NABoolean isVarchar)
{
  if (qparent->up->isFull())
    {
      if (rc)
	*rc = WORK_CALL_AGAIN;
      return -1;
    }

  Lng32 length;
  if (len <= 0)
    length = strlen(row);
  else
    length = len;

  tupp p;
  if (pool_->get_free_tuple(p, (Lng32)
			    ((isVarchar ? SQL_VARCHAR_HDR_SIZE : 0)
			     + length)))
    {
      if (rc)
	*rc = WORK_POOL_BLOCKED;
      return -1;
    }
  
  char * dp = p.getDataPointer();
  if (isVarchar)
    {
      *(short*)dp = (short)length;
      str_cpy_all(&dp[SQL_VARCHAR_HDR_SIZE], row, length);
    }
  else
    {
      str_cpy_all(dp, row, length);
    }

  ex_queue_entry * pentry_down = qparent->down->getHeadEntry();
  ex_queue_entry * up_entry = qparent->up->getTailEntry();
  
  up_entry->copyAtp(pentry_down);
  up_entry->getAtp()->getTupp((Lng32)tuppIndex) = p;

  up_entry->upState.parentIndex = 
    pentry_down->downState.parentIndex;
  
  up_entry->upState.setMatchNo(0);
  up_entry->upState.status = ex_queue::Q_OK_MMORE;

  // insert into parent
  qparent->up->insert();

  return 0;
}
Example #7
0
IpcMessageObjSize ExMsgFragment::packObjIntoMessage(IpcMessageBufferPtr buffer)
{
  // See description of packed format in packedLength() method

  IpcMessageBufferPtr start = buffer;

  // Pack the base class
  packBaseClassIntoMessage(buffer);
  alignBufferForNextObj(buffer);

  // Pack the fixed length fields
  str_cpy_all(buffer, (const char *) &f_, sizeof(f_));
  buffer += sizeof(f_);
  alignBufferForNextObj(buffer);

  // Pack the query ID
  if (f_.queryId_ != NULL)
  {
    str_cpy_all(buffer, f_.queryId_, f_.queryIdLen_);
    buffer += f_.queryIdLen_;
    alignBufferForNextObj(buffer);
  }

  // Pack the user name
  if (f_.userName_ != NULL)
  {
    str_cpy_all(buffer, f_.userName_, f_.userNameLen_);
    buffer += f_.userNameLen_;
    alignBufferForNextObj(buffer);
  }

  // Pack the fragment itself
  if (f_.compressedLength_ > 0 && f_.compressedLength_ < f_.fragmentLength_)
  {
    size_t cmprSize = str_compress(buffer,fragment_,f_.fragmentLength_);
    ex_assert(cmprSize == f_.compressedLength_,
              "Error during compress a fragment for download");
    buffer += f_.compressedLength_;

  }
  else
  {
#pragma nowarn(1506)   // warning elimination 
    str_cpy_all(buffer,fragment_,f_.fragmentLength_);
#pragma warn(1506)  // warning elimination 
    buffer += f_.fragmentLength_;
  }

  alignBufferForNextObj(buffer);

  // Pack the fragment key (is an IpcMessageObj itself)
  buffer += key_.packDependentObjIntoMessage(buffer);

  return (IpcMessageObjSize) (buffer - start);
}
void SQLMXLoggingArea::logCompNQCretryEvent(char *stmt)
{
  const char m[]="Statement was compiled as if query plan caching were off: ";
  Int32 mLen = sizeof(m);
  Int32 sLen = str_len(stmt);
  char msg[8192];
  str_cpy_all(msg, m, mLen);
  str_cpy_all(msg+mLen, stmt, MINOF(sLen, 8192-mLen));
  logSQLMXEventForError(SQEV_CMP_NQC_RETRY_OCCURED, "ADVANCED", "INFRM", 
                        "LOGONLY", msg); 
}
Example #9
0
/////////////////////////////////////////////////
// class ex_aggr_min_max_clause
/////////////////////////////////////////////////
ex_expr::exp_return_type ex_aggr_min_max_clause::eval(char * op_data[],
						      CollHeap*,
						      ComDiagsArea **)
{
  ex_expr::exp_return_type retcode = ex_expr::EXPR_OK;
  
  // if the second expression is true, make child to be current
  // aggregate.
  if (*(Lng32 *)op_data[2] == 1)
    {
      if (getOperand(0)->getNullFlag())
        {
          // A pointer to the null indicators of the operands.
          //
          char **null_data = &op_data[-2 * ex_clause::MAX_OPERANDS];
          
	  if ((getOperand(1)->getNullFlag()) &&
	      (! null_data[1])) // missing value, indicates
	                        // child is null. Keep the current result.
	    return ex_expr::EXPR_OK;

          ExpTupleDesc::clearNullValue(null_data[0],
                                       getOperand(0)->getNullBitIndex(),
                                       getOperand(0)->getTupleFormat() );
        }

      if (getOperand(0)->getVCIndicatorLength() > 0)
	{
	  // variable length operand. Note that first child (operand1)
	  // and result have the SAME attributes for min/max aggr.
#pragma nowarn(1506)   // warning elimination 
	  Lng32 src_length = getOperand(1)->getLength(op_data[-MAX_OPERANDS + 1]);
#pragma warn(1506)  // warning elimination 
	  Lng32 tgt_length = getOperand(0)->getLength(); // max varchar length
	
	  str_cpy_all(op_data[0], op_data[1], src_length);
	  
	  // copy source length bytes to target length bytes.
	  // Note that the array index -MAX_OPERANDS will get to
	  // the corresponding varlen entry for that operand.
	  getOperand(0)->setVarLength(src_length, op_data[- MAX_OPERANDS]);
	}
      else
	{
	  str_cpy_all(op_data[0], op_data[1], getOperand(0)->getLength());
	}
    }
  
  return retcode;
}
Example #10
0
IpcMessageObjSize ExMsgResourceInfo::packObjIntoMessage(
     IpcMessageBufferPtr buffer)
{
  IpcMessageBufferPtr start = buffer;

  packBaseClassIntoMessage(buffer);

  str_cpy_all(buffer,(char *) &totalNameLength_, sizeof(totalNameLength_));
  buffer += sizeof(totalNameLength_);
  str_cpy_all(buffer,(char *) &spare_, sizeof(spare_));
  buffer += sizeof(spare_);
  buffer += sfo_->ipcPackObjIntoMessage(buffer);

  return (IpcMessageObjSize) (buffer - start);
}
ex_expr::exp_return_type ex_function_substring_doublebyte::eval(char *op_data[],
						 CollHeap* heap,
						 ComDiagsArea** diagsArea)
{
#pragma nowarn(1506)   // warning elimination 
  Lng32 len1 = getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]);
#pragma warn(1506)  // warning elimination 

  len1 /= sizeof(NAWchar); // len1 now counts in terms of number of NCHARs.
  
  // Get the starting position from operand 2.
  Int64 start = *(Lng32 *)op_data[2];  
  
  // If operand 3 exists, get the length of substring from operand 3.
  // Otherwise, length of the substring is (len1 - start + 1).
  Int64 len = 0;
  Int64 temp = 0;
  if (getNumOperands() == 4)
    {
      len = *(Lng32 *)op_data[3];
      temp = start + len;
    }
  else
    {
      if (start > (len1 + 1)) 
	temp = start;
      else
	temp = len1 + 1;
    }
  
  // Check for error conditions.
  if (temp < start)
    {
      ExRaiseSqlError(heap, diagsArea, EXE_SUBSTRING_ERROR);
      return ex_expr::EXPR_ERROR;
    }
  
  Lng32 len0 = 0;
  if ((start <= len1) && (temp > 0)) 
    {
      if (start < 1)
        start = 1;
      if (temp > (len1 + 1))
        temp = len1 + 1;
      len0 = int64ToInt32(temp - start);     
    }

  len0 *= sizeof(NAWchar);  // convert the length back into the number of octets.
  
  // Result is always a varchar, so store the length of substring 
  // in the varlen indicator.
  getOperand(0)->setVarLength(len0, op_data[-MAX_OPERANDS]);
  
  // Now, copy the substring of operand 1 from the starting position into
  // operand 0, if len0 is greater than 0.
  if (len0 > 0) 
    str_cpy_all(op_data[0], &op_data[1][sizeof(NAWchar)*(int64ToInt32(start) - 1)], len0); 
  
  return ex_expr::EXPR_OK;
}
// Generates LOB handle that is stored in the SQL row.
// LOB handle len:  64 bytes
// <flags><LOBnum><objectUid><descKey><descTS><schNameLen><schName>
// <--4--><--4---><----8----><---8---><--8---><-----2----><--vc--->
void ExpLOBoper::genLOBhandle(Int64 uid, 
			      Lng32 lobNum,
			      short lobType,
			      Int64 descKey, 
			      Int64 descTS,
			      Lng32 flags,
			      short schNameLen,
			      char  * schName,
			      Lng32 &handleLen,
			      char * ptr)
{
  LOBHandle * lobHandle = (LOBHandle*)ptr;
  lobHandle->flags_ = flags;
  lobHandle->lobType_ = (char)lobType;
  lobHandle->filler1_ = 0;
  lobHandle->lobNum_ = lobNum;
  lobHandle->objUID_ = uid;
  lobHandle->descSyskey_ = descKey;
  lobHandle->descPartnkey_ = descTS;
  str_pad(lobHandle->filler_, 30, '\0');
  lobHandle->schNameLen_ = schNameLen;
  handleLen = sizeof(LOBHandle);
  if (schNameLen > 0)
    {
      char * s = &lobHandle->schName_;
      str_cpy_all(s, schName, schNameLen);
      s[schNameLen] = 0;

      handleLen += schNameLen;
    }
  //  lobHandle->inlinedLOBlen_ = 0;
}
// Extracts values from the LOB handle stored at ptr
Lng32 ExpLOBoper::extractFromLOBhandle(Int16 *flags,
				       Lng32 *lobType,
				       Lng32 *lobNum,
				       Int64 *uid, 
				       Int64 *descSyskey, 
				       Int64 *descPartnKey,
				       short *schNameLen,
				       char * schName,
				       char * ptrToLobHandle,
				       Lng32 handleLen)
{
  LOBHandle * lobHandle = (LOBHandle*)ptrToLobHandle;
  if (flags)
    *flags = lobHandle->flags_;
  if (lobType)
    *lobType = lobHandle->lobType_;
  if (lobNum)
    *lobNum = lobHandle->lobNum_;
  if (uid)
    *uid = lobHandle->objUID_;
  if (descSyskey)
    *descSyskey = lobHandle->descSyskey_;
  if (descPartnKey)
    *descPartnKey = lobHandle->descPartnkey_;
  if (schNameLen)
    *schNameLen = lobHandle->schNameLen_;
  if ((schNameLen) && (*schNameLen > 0) && (schName != NULL))
    {
      str_cpy_all(schName, &lobHandle->schName_, *schNameLen);
      schName[*schNameLen] = 0;
    }

  return 0;
}
Example #14
0
/////////////////////////////////////////
// class Define
/////////////////////////////////////////
Define::Define(const char * name_, const char * value_)
{
  if (name_)
    {
      name = new char[strlen(name_) + 1];
      strcpy(name, name_);

      defineNameInternal = new char[24];
      str_pad(defineNameInternal, 24, ' ');
#pragma nowarn(1506)   // warning elimination 
      short len = MINOF(strlen(name), 24);
#pragma warn(1506)  // warning elimination 
      str_cpy_all(defineNameInternal, name, len);
    }
  else
    name = 0;

  if (value_)
    {
      value = new char[strlen(value_) + 1];
      strcpy(value, value_);
    }
  else
    value = 0;
}
Example #15
0
ex_tcb::~ex_tcb()
{
  ex_assert(!str_cmp((char *)&eyeCatcher_, (char *)(&tdb.eyeCatcher_), 4),
            "TCB points to wrong TDB");
  // Change the eye catcher
  str_cpy_all((char *) &eyeCatcher_, eye_FREE, 4);
};
Example #16
0
void ExMsgResourceInfo::unpackObj(IpcMessageObjType objType,
				  IpcMessageObjVersion objVersion,
				  NABoolean sameEndianness,
				  IpcMessageObjSize objSize,
				  IpcConstMessageBufferPtr buffer)
{
  ExScratchFileOptions *sfo;
  IpcConstMessageBufferPtr start = buffer;

  ex_assert(objType == ESP_RESOURCE_INFO AND
	    objVersion == 100 AND
	    sameEndianness AND
	    objSize > sizeof(IpcMessageObj),
	    "invalid type or version for ExMsgResourceInfo::unpackObj()");
  unpackBaseClass(buffer);
  str_cpy_all((char *) &totalNameLength_,buffer,sizeof(totalNameLength_));
  buffer += sizeof(totalNameLength_);
  buffer += sizeof(spare_);
  if (bufferForDependentObjects_)
    {
      getHeap()->deallocateMemory(bufferForDependentObjects_);
      bufferForDependentObjects_ = NULL;
    }
  sfo = new(getHeap()) ExScratchFileOptions;

  // sfo_ is const
  sfo_ = sfo;

  sfo->ipcUnpackObj(objSize - (buffer-start),
		    buffer,
		    getHeap(),
		    totalNameLength_,
		    bufferForDependentObjects_);
}
Example #17
0
void TupMsgBuffer::unpackObj(IpcMessageObjType objType,
			     IpcMessageObjVersion objVersion,
			     NABoolean sameEndianness,
			     IpcMessageObjSize objSize,
			     IpcConstMessageBufferPtr buffer)
{
  ex_assert((objType == ESP_INPUT_SQL_BUFFER OR
	     objType == ESP_OUTPUT_SQL_BUFFER) AND
	    objVersion == 100 AND
	    sameEndianness AND
	    objSize > sizeof(IpcMessageObj),
	    "invalid type or version for TupMsgBuffer::unpackObj()");

  unpackBaseClass(buffer);

  IpcMessageObjSize sqlBufferSize = objSize - sizeof(IpcMessageObj);

  ex_assert(allocSize_ >= (Lng32) sqlBufferSize,
	    "TupMsgBuffer too small for unpack");

#pragma nowarn(1506)   // warning elimination 
  str_cpy_all((char *) theBuffer_, buffer, sqlBufferSize);
#pragma warn(1506)  // warning elimination 

  // convert offsets in buffer to pointers
  theBuffer_->driveUnpack();

  // just checking whether we really got the right size info
  ex_assert(sqlBufferSize == theBuffer_->get_buffer_size(),
	    "Buffer size mismatch");
}
void InputStmt::processInsert()
{
  size_t command_len = getCommandLen();

  if ((command_len > 0) && (text_maxlen > 0))
    {
      size_t j = text_maxlen - 1;
      while (j >= text_pos)
	{
	  text[j+command_len] = text[j];
	  if (j-- == 0) break;
	}

#pragma nowarn(1506)   // warning elimination 
      str_cpy_all(&text[text_pos], &command[command_pos], command_len);
#pragma warn(1506)  // warning elimination 
      command_pos += command_len;

      text_pos += 2 * command_len + 1;
      text_maxlen += command_len;

      if (text_pos > text_maxlen)
	text_maxlen = text_pos;
    }
}	// processInsert()
ex_expr::exp_return_type ExpLOBselect::eval(char *op_data[],
					    CollHeap*h,
					    ComDiagsArea** diagsArea)
{
  char * result = op_data[0];
  Lng32 rc = 0;
  Int64 uid;
  Lng32 lobType;
  Lng32 lobNum;
  Int64 descKey;
  Int16 flags;
  Int64 descTS = -1;
  short schNameLen = 0;
  char  schName[500];
  LobsSubOper so;
  Lng32 waitedOp = 0;
  Int64 lobLen = 0; 
  char *lobData = NULL;
  Lng32 cliError = 0;
  Lng32 lobOperStatus = checkLobOperStatus();
  if (lobOperStatus == DO_NOTHING_)
    return ex_expr::EXPR_OK;
  Int32 handleLen = getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]);
  char * lobHandle = op_data[1];
  extractFromLOBhandle(&flags, &lobType, &lobNum, &uid,
		       &descKey, &descTS, 
		       &schNameLen, schName,
		       lobHandle);
  // select returns lobhandle only
  str_pad(result, getOperand(0)->getLength());
  str_cpy_all(result, lobHandle, strlen(lobHandle));
  
  return ex_expr::EXPR_OK;
}
Example #20
0
void MdamColumn::reportProbeResult(char *keyData)
{
ex_assert(sparseProbeNeeded_,
	  "MdamColumn::reportProbeResult called unexpectedly.");

sparseProbeNeeded_ = FALSE;
if (keyData)
  {
    // the sparse probe was successful -- save the key value
    Int32 len = Int32(columnGenInfo_->getLength());
#pragma nowarn(1506)   // warning elimination 
    Lng32 offset = columnGenInfo_->getOffset();
#pragma warn(1506)  // warning elimination 
    char * cv = currentValue_.getDataPointer();

    str_cpy_all(cv,keyData + offset,len);

    sparseProbeSucceeded_ = TRUE;
  }
else
  {
    // the sparse probe returned no data
    sparseProbeFailed_ = TRUE;
  }

}
ExSPInputOutput::ExSPInputOutput() : NAVersionedObject(-1)
{
    str_cpy_all(eyeCatcher_, "SPIO", 4);
    totalLen_ = 0;
    tupleDesc_ = NULL;
    caseIndexArray_ = (Int16Ptr) NULL;
    flags_ = 0;
}
NA_EIDPROC ComTdb::~ComTdb()
{
  // ---------------------------------------------------------------------
  // Change the eye catcher
  // ---------------------------------------------------------------------
  str_cpy_all((char *) &eyeCatcher_, eye_FREE, 4);
  
}
Example #23
0
inline static char *copyString(const NAString &s)	// cf. readRealArk.cpp
{
#pragma nowarn(1506)   // warning elimination 
  char *c = new(CmpCommon::statementHeap()) char[s.length()+1];
  str_cpy_all(c, s.data(), s.length()+1);
  return c;
#pragma warn(1506)   // warning elimination 
}
/*
  DP2 Query Id Format:
    Each of the part is in binary numeric format.

  <segment><cpu><pin><processStartTS><queryNum>

  <segment>        :      1 byte
  <cpu>            :      1 byte
  <pin>            :      2 bytes(short)
  <processStartTS> :      8 bytes (Int64)
  <queryNum>       :      4 bytes (Lng32)
*/
Lng32 ComSqlId::getDp2QueryIdString
(char * queryId,                 // IN
 Lng32 queryIdLen,                // IN
 char * dp2QueryId,              // INOUT
 Lng32 &dp2QueryIdLen             // OUT
 )
{
  if ((!queryId) ||
      (queryIdLen < MAX_DP2_QUERY_ID_LEN))
    return -1;

  Int64 value;
  Lng32 currOffset = 0;
  // In case of Linux and NT, segment num and cpu num are same
  // Copy them as short
  // get cpu
  getSqlQueryIdAttr(SQLQUERYID_CPUNUM, queryId, queryIdLen,
		    value, NULL);
  *(short*)&dp2QueryId[currOffset] = (short)value;
  currOffset += sizeof(short);

  // get pin
  getSqlQueryIdAttr(SQLQUERYID_PIN, queryId, queryIdLen,
		    value, NULL);
  *(short*)&dp2QueryId[currOffset] = (short)value;
  currOffset += sizeof(short);

  // get process start time
  getSqlQueryIdAttr(SQLQUERYID_EXESTARTTIME, queryId, queryIdLen,
		    value, NULL);
  str_cpy_all(&dp2QueryId[currOffset], (char*)&value, sizeof(Int64));
  currOffset += sizeof(Int64);

  // get query num
  getSqlQueryIdAttr(SQLQUERYID_QUERYNUM, queryId, queryIdLen,
		    value, NULL);
  Lng32 qNum = (Lng32)value;
  str_cpy_all(&dp2QueryId[currOffset], (char*)&qNum, sizeof(Lng32));

  currOffset += sizeof(Lng32);

  dp2QueryIdLen = currOffset;

  return 0;
}
// log an ASSERTION FAILURE event
void
SQLMXLoggingArea::logSQLMXAssertionFailureEvent(const char* file, Int32 line, const char* msgTxt, const char* condition, const Lng32* tid)
{
  bool lockedMutex = lockMutex();
  
  Int32 LEN = 8192;
  char msg[8192];
  memset(msg, 0, LEN);

  Int32 sLen = str_len(msgTxt);
  Int32 sTotalLen = sLen;
  str_cpy_all (msg, msgTxt, sLen);

  char fileLineStr[200];
  if (file)
  {
    str_sprintf(fileLineStr, ", FILE: %s, LINE: %d ",file, line);
    sLen = str_len(fileLineStr);
    str_cpy_all (msg+sTotalLen, fileLineStr, sLen);
    sTotalLen += sLen;
  }

  if (tid && (*tid != -1))
  {
    char transId[100];
    str_sprintf(transId, " TRANSACTION ID: %d ", *tid);
    sLen = str_len(transId);
    str_cpy_all (msg+sTotalLen, transId, sLen);
    sTotalLen += sLen;
  }

  if (condition)
  {
    char condStr[100];
    str_sprintf(condStr, " CONDITION: %s ", condition);
    sLen = str_len(condStr);
    str_cpy_all (msg+sTotalLen, condStr, sLen);
  }

  QRLogger::log(QRLogger::instance().getMyDefaultCat(), LL_FATAL, "%s", msg);

  if (lockedMutex)
    unlockMutex();
  
}
Example #26
0
char *UDRCopyString ( const ComString &sourceString, CollHeap *heap )
{
  char *string = new(heap)char [sourceString.length()+1];
  str_cpy_all ( string
		, sourceString.data()
		, sourceString.length()+1
	      );
  return string;
} // UDRCopyString
jint JNICALL LmJavaHooks::vfprintfHookJVM(FILE *stream, const char *fmt,
                                          va_list printArgs)
{
  if (!fmt || !stream)
  {
    return 0;
  }

  LM_DEBUG0("[BEGIN vfprintf hook]");
  
  char tmpBuf[LMJ_HOOK_TEXT_BUF_SIZE] = "";

  // 1. First make a temporary copy of the output message
  ComSafePrinter safePrinter;
  safePrinter.vsnPrintf(tmpBuf, LMJ_HOOK_TEXT_BUF_SIZE, fmt, printArgs);

  // 2. Send the message to its intended FILE stream
  // Do not know why but inside this hook, writing to the FILE pointer
  // that was passed in seems to cause problems on Windows. Depending
  // on how the FILE pointer is used we have seen crashes inside JVM
  // code after hook returns, and inside fprintf. The JVM bug database
  // says a few things about the JVM being compiled with a version of
  // certain stdio structures such as va_list that may not be
  // compatible with all IDEs. Have not tried to verify that
  // though. For now on Windows we just write our temporary string to
  // stderr. And our observation has been that all JVM messages go to
  // stderr anyway, so this seems to serve the same purpose.
  //
  // For example the following line does not work
  //
  //   vfprintf(stream, fmt, printArgs)
  //
  // And neither does this
  //
  //   fprintf(stream, tmpBuf)
  //
  fprintf(stderr, tmpBuf);

  // Write as much as possible into our textBuf_ area
  Int32 currentLength = str_len(textBuf_);
  Int32 tmpLen = str_len(tmpBuf);
  if ((currentLength + 1) < LMJ_HOOK_TEXT_BUF_SIZE)
  {
    Int32 bytesToCopy =
      MINOF(tmpLen + 1, LMJ_HOOK_TEXT_BUF_SIZE - currentLength);
    str_cpy_all(&textBuf_[currentLength], tmpBuf, bytesToCopy);
    textBuf_[LMJ_HOOK_TEXT_BUF_SIZE - 1] = 0;
  }
  else
  {
    LM_DEBUG0("*** WARNING: textBuf_ buffer is full");
  }

  LM_DEBUG0("[END vfprintf hook]");
  return 0;
}
// ---------------------------------------------------------------------
// Constructor
//
// Note that imageSize_ and versionIDArray_ are only filled in at
// packing time. These values are not useful on the source platform
// where the objects are constructed. They are only useful at the
// destination while the objects are unpacked. Before the objects are
// packed, drivePack() will make sure their values are correctly set.
// This arrangement avoids the dependence on the constructors of sub-
// classes of NAVersionedObject on setting these values correctly.
// ---------------------------------------------------------------------
NA_EIDPROC NAVersionedObject::NAVersionedObject(Int16 classID)
    : classID_(classID),
      reallocatedAddress_(NULL),
      imageSize_(0)
  {
    clearFillers();
    initFlags();    // set to state of "not packed".
    clearVersionIDArray();
    str_cpy_all(eyeCatcher_,VOBJ_EYE_CATCHER,VOBJ_EYE_CATCHER_SIZE);
  }
Example #29
0
Module::Module(const char * module_name, Lng32 len, char * pathName, 
               Lng32 pathNameLen, NAHeap *heap)
     : module_name_len_(len), path_name_len_(pathNameLen), 
       heap_(heap), statementCount_(0),
       stmtCntrsSpace_(NULL),
       vproc_(NULL)
{
  module_name_ = (char *)
   (heap->allocateMemory((size_t)(len+1)));

  str_cpy_all(module_name_, module_name, len);
  module_name_[len] = 0;

  path_name_ = (char *)
   (heap->allocateMemory((size_t)(pathNameLen+1)));

  str_cpy_all(path_name_, pathName, pathNameLen);
  path_name_[pathNameLen] = 0;

}
Example #30
0
void CmpDDLwithStatusInfo::pack(char * buffer)
{
  CmpDDLwithStatusInfo * ci = (CmpDDLwithStatusInfo *)buffer;

  Lng32 classSize = getClassSize();
  Lng32 nextOffset = 0;
  str_cpy_all(buffer, (char *)this, classSize);

  nextOffset += ROUND8(classSize);

  packVars(buffer, ci, nextOffset);

  if (blackBox_ && (blackBoxLen_ > 0))
    {
      str_cpy_all(&buffer[nextOffset], blackBox_, blackBoxLen_);
      ci->blackBox_ = (char *)nextOffset;
      nextOffset += ROUND8(blackBoxLen_);
    }

}