short ExExeUtilTcb::alterObjectState(NABoolean online,
				     char * tableName,
				     char * failReason,
				     NABoolean forPurgedata)
{
  char buf[4000];
  Lng32 cliRC = 0;

  // Get the globals stucture of the master executor.
  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();

  // make object online
  str_sprintf(buf, "ALTER TABLE %s %s %s",
	      tableName,
	      (online ? "ONLINE" : "OFFLINE"),
	      (forPurgedata ? "FOR PURGEDATA" : " "));
  
  // set sqlparserflags to allow 'FOR PURGEDATA' syntax
  masterGlob->getStatement()->getContext()->setSqlParserFlags(0x1);
  
  cliRC = cliInterface()->executeImmediate(buf);
  
  masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x1);
  
  if (cliRC < 0)
    {
      str_sprintf(failReason, "Could not alter the state of table %s to %s.",
		  tableName, (online ? "online" : "offline"));

      return -1;
    }
  
  return 0;
}
Пример #2
0
void log_message(LogLevel level, const char* function, int line, const char* msg, ...) {
	if (level < logger.level)
		return;

	char buffer[LOG_BUFFER_SIZE];

	va_list va;
	int preffixSize;

	time_format(buffer, "[%Y:%m:%d-%H:%M:%S]");
	str_sprintf(buffer, "%s %s %s ", buffer, log_getLevelStr(level), logger.program, function, line);

	if (logger.develOutput)
		str_sprintf(buffer, "%s[%s:%i] ", buffer, function, line);

	preffixSize = str_len(buffer);

	va_start(va, msg);
	vsnprintf(buffer + preffixSize, LOG_BUFFER_SIZE - preffixSize, msg, va);
	va_end(va);

	if (logger.stdOutput)
		puts(buffer);

	if (logger.logFileFd) {
		file_write(logger.logFileFd, buffer, str_len(buffer));
		file_write(logger.logFileFd, "\n", 1);
	}
}
short ExExeUtilTcb::alterAuditFlag(NABoolean audited, char * tableName,
				   NABoolean isIndex)
{
  char buf[4000];
  Lng32 cliRC = 0;

  // Get the globals stucture of the master executor.
  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();

  // change the corrupt bit in the label
  if (isIndex)
    str_sprintf(buf, "LABEL_ALTER INDEX_TABLE %s PARALLEL EXECUTION ON OPCODE %s ''",
		tableName, (audited ? "65" : "66"));
  else
    str_sprintf(buf, "LABEL_ALTER TABLE %s PARALLEL EXECUTION ON OPCODE %s ''",
  	      tableName, (audited ? "65" : "66"));
  
  // set sqlparserflags to allow 'label_alter' syntax
  masterGlob->getStatement()->getContext()->setSqlParserFlags(0x1);
  
  cliRC = cliInterface()->executeImmediate(buf);
  
  masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x1);
  
  if (cliRC < 0)
    {
      return -1;
    }
  
  return 0;
}
Пример #4
0
void SqlciEnv::sqlmxRegress()
{
  char * regr = getenv("SQLMX_REGRESS");
  if (regr)
    {
      char buf[1000];
      str_sprintf(buf, "set envvar sqlmx_regress %s;", regr);
      SqlCmd::executeQuery(buf, this);
      if (!specialError_)
	{
	  char *noexit = getenv("SQL_MXCI_NO_EXIT_ON_COMPILER_STARTUP_ERROR");
	  if (!noexit)
	    exit(EXIT_FAILURE);
	}

      str_sprintf(buf, "cqd sqlmx_regress 'ON';");
      SqlCmd::executeQuery(buf, this);
      if (!specialError_)
	{
	  char *noexit = getenv("SQL_MXCI_NO_EXIT_ON_COMPILER_STARTUP_ERROR");
	  if (!noexit)
	    exit(EXIT_FAILURE);
	}
    }

}
Пример #5
0
static str *call_update_lookup_udp(char **out, struct callmaster *m, enum call_opmode opmode) {
	struct call *c;
	struct call_monologue *monologue;
	GQueue q = G_QUEUE_INIT;
	struct stream_params sp;
	str *ret, callid, viabranch, fromtag, totag = STR_NULL;
	int i;

	str_init(&callid, out[RE_UDP_UL_CALLID]);
	str_init(&viabranch, out[RE_UDP_UL_VIABRANCH]);
	str_init(&fromtag, out[RE_UDP_UL_FROMTAG]);
	if (opmode == OP_ANSWER)
		str_init(&totag, out[RE_UDP_UL_TOTAG]);

	c = call_get_opmode(&callid, m, opmode);
	if (!c) {
		ilog(LOG_WARNING, "["STR_FORMAT"] Got UDP LOOKUP for unknown call-id",
			STR_FMT(&callid));
		return str_sprintf("%s 0 0.0.0.0\n", out[RE_UDP_COOKIE]);
	}
	monologue = call_get_mono_dialogue(c, &fromtag, &totag);
	if (!monologue)
		goto ml_fail;

	if (addr_parse_udp(&sp, out))
		goto addr_fail;

	g_queue_push_tail(&q, &sp);
	i = monologue_offer_answer(monologue, &q, NULL);
	g_queue_clear(&q);

	if (i)
		goto unlock_fail;

	ret = streams_print(&monologue->active_dialogue->medias,
			sp.index, sp.index, out[RE_UDP_COOKIE], SAF_UDP);
	rwlock_unlock_w(&c->master_lock);

	redis_update(c, m->conf.redis);

	ilog(LOG_INFO, "Returning to SIP proxy: "STR_FORMAT"", STR_FMT(ret));
	goto out;

ml_fail:
	ilog(LOG_ERR, "Invalid dialogue association");
	goto unlock_fail;

addr_fail:
	ilog(LOG_ERR, "Failed to parse a media stream: %s/%s:%s",
			out[RE_UDP_UL_ADDR4], out[RE_UDP_UL_ADDR6], out[RE_UDP_UL_PORT]);
	goto unlock_fail;

unlock_fail:
	rwlock_unlock_w(&c->master_lock);
	ret = str_sprintf("%s E8\n", out[RE_UDP_COOKIE]);
out:
	obj_put(c);
	return ret;
}
short ExExeUtilTcb::alterCorruptBit(short val, char * tableName,
				    char * failReason, Queue* indexList)
{
  char buf[4000];
  Lng32 cliRC = 0;

  // Get the globals stucture of the master executor.
  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();

  // change the corrupt bit in the label
  str_sprintf(buf, "LABEL_ALTER TABLE %s PARALLEL EXECUTION ON OPCODE 9 '%s'",
  	      tableName, (val == 1 ? "1" : "0"));
  
  // set sqlparserflags to allow 'label_alter' syntax
  masterGlob->getStatement()->getContext()->setSqlParserFlags(0x1);
  
  cliRC = cliInterface()->executeImmediate(buf);
  
  masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x1);
  
  if (cliRC < 0)
    {
      str_sprintf(failReason, "Could not %s the corrupt bit on table %s.",
		  (val == 1 ? "set" : "reset"), tableName);
      return -1;
    }

  if (indexList)
    {
      indexList->position();
      
      while (NOT indexList->atEnd())
	{
	  char * indexName = (char*)indexList->getNext();
	  
	  str_sprintf(buf, "LABEL_ALTER INDEX_TABLE %s PARALLEL EXECUTION ON OPCODE 9 '%s'",
	  	      indexName, (val == 1 ? "1" : "0"));

	  // set sqlparserflags to allow 'label_alter' syntax
	  masterGlob->getStatement()->getContext()->setSqlParserFlags(0x1);
	  
	  cliRC = cliInterface()->executeImmediate(buf);
	  
	  masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x1);
	  
	  if (cliRC < 0)
	    {
	      str_sprintf(failReason, "Could not %s the corrupt bit on index %s.",
			  (val == 1 ? "set" : "reset"), indexName);

	      return -1;
	    }
	} // while
      
    } // index present
  
  return 0;
}
// *****************************************************************************
// *                                                                           *
// * Function: dropOneTable                                                    *
// *                                                                           *
// *    Drops a table and all its dependent objects.                           *
// *                                                                           *
// *****************************************************************************
// *                                                                           *
// *  Parameters:                                                              *
// *                                                                           *
// *  <cliInterface>                  ExeCliInterface &               In       *
// *    is a reference to an Executor CLI interface handle.                    *
// *                                                                           *
// *  <catalogName>                   const char *                    In       *
// *    is the catalog of the table to drop.                                   *
// *                                                                           *
// *  <schemaName>                    const char *                    In       *
// *    is the schema of the table to drop.                                    *
// *                                                                           *
// *  <objectName>                    const char *                    In       *
// *    is the name of the table to drop.                                      *
// *                                                                           *
// *  <isVolatile>                    bool                            In       *
// *    is true if the object is volatile or part of a volatile schema.        *
// *                                                                           *
// *****************************************************************************
// *                                                                           *
// * Returns: bool                                                             *
// *                                                                           *
// * true: Could not drop table or one of its dependent objects.               *
// * false: Drop successful or could not set CQD for NATable cache reload.     *
// *                                                                           *
// *****************************************************************************
static bool dropOneTable(
   ExeCliInterface & cliInterface,
   const char * catalogName, 
   const char * schemaName, 
   const char * objectName,
   bool isVolatile)
   
{

char buf [1000];

bool someObjectsCouldNotBeDropped = false;

char volatileString[20] = {0};
Lng32 cliRC = 0;

   if (isVolatile)
      strcpy(volatileString,"VOLATILE");

   if (ComIsTrafodionExternalSchemaName(schemaName))
     str_sprintf(buf,"DROP EXTERNAL TABLE \"%s\" FOR \"%s\".\"%s\".\"%s\" CASCADE",
                 objectName,catalogName,schemaName,objectName);
   else
     str_sprintf(buf,"DROP %s TABLE \"%s\".\"%s\".\"%s\" CASCADE",
                 volatileString,catalogName,schemaName,objectName);
 
ULng32 savedParserFlags = Get_SqlParser_Flags(0xFFFFFFFF);

   try
   {            
      Set_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL);
               
      cliRC = cliInterface.executeImmediate(buf);
   }
   catch (...)
   {
      // Restore parser flags settings to what they originally were
      Assign_SqlParser_Flags(savedParserFlags);
      
      throw;
   }
   
// Restore parser flags settings to what they originally were
   Set_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL);
   
   if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
      someObjectsCouldNotBeDropped = true;
   
// remove NATable entry for this table
   CorrName cn(objectName,STMTHEAP,schemaName,catalogName);

   ActiveSchemaDB()->getNATableDB()->removeNATable(cn,
     NATableDB::REMOVE_FROM_ALL_USERS, COM_BASE_TABLE_OBJECT);

   return someObjectsCouldNotBeDropped;
   
}
Пример #8
0
// -----------------------------------------------------------------------
// Used by the internal SHOWPLAN command to get attributes of a TDB in a
// string.
// -----------------------------------------------------------------------
NA_EIDPROC void ComTdb::displayContents(Space * space,ULng32 flag)
{

#ifndef __EID
  char buf[100];
  str_sprintf(buf, "Contents of %s [%d]:", getNodeName(),getExplainNodeId());
  Int32 j = str_len(buf);
  space->allocateAndCopyToAlignedSpace(buf, j, sizeof(short));
  for (Int32 k = 0; k < j; k++) buf[k] = '-';
  buf[j] = '\n';
  buf[j+1] = 0;
  space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

  if(flag & 0x00000008)
    {
  		str_sprintf(buf,"For ComTdb :");
		space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

		str_sprintf(buf,"Class Version = %d, Class Size = %d",
                  getClassVersionID(),getClassSize());
  		space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

  		str_sprintf(buf,"InitialQueueSizeDown = %d, InitialQueueSizeUp = %d",
                   getInitialQueueSizeDown(),getInitialQueueSizeUp());
  		space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

  		str_sprintf(buf,"queueResizeLimit = %d, queueResizeFactor = %d",
                     getQueueResizeLimit(),getQueueResizeFactor());
  		space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

  		str_sprintf(buf, "queueSizeDown = %d, queueSizeUp = %d, numBuffers = %d, bufferSize = %d",
	        getMaxQueueSizeDown(), getMaxQueueSizeUp(), numBuffers_, bufferSize_);
  		space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

  		str_sprintf(buf, "estimatedRowUsed = %f, estimatedRowsAccessed = %f, expressionMode = %d", 
                  estRowsUsed_, estRowsAccessed_, expressionMode_);
  		space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

  		str_sprintf(buf, "Flag = %b",flags_);
  		space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

  		if (firstNRows() >= 0)
    		{
      		str_sprintf(buf, "Request Type: GET_N (%d) ", firstNRows());
      		space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
    		}
    }
 #endif

  if(flag & 0x00000001)
    {
      displayExpression(space,flag);
      displayChildren(space,flag);
    }
}
Пример #9
0
short ExExeUtilLongRunningTcb::processContinuing(Lng32 &rc) 
{

  Int64 rowsAffected = 0;

  rc = cliInterface()->execContinuingRows(getContinuingOutputVarPtrList(),
                                          rowsAffected);

  if (rc < 0)
    {
      return -1;
    }

  if (rowsAffected > 0)
    addRowsDeleted(rowsAffected);

#ifdef _DEBUG

   if ((rowsAffected > 0) && lrTdb().longRunningQueryPlan()) {

        char lruQPInfo[100];

        str_sprintf(lruQPInfo, "Continuing rows deleted: %ld\n\n", 
                                rowsAffected);

        ComDiagsArea * diagsArea = getDiagAreaFromUpQueueTail();
        (*diagsArea) << DgSqlCode(8427) << DgString0(lruQPInfo);
   }
#endif
 
  return 0;
}
Пример #10
0
// ----------------------------------------------------------------------------
// method:  authExists
//
// Input: none
//
// Output:
//   Returns true if authorization row exists in the metadata
//   Returns false if authorization row does not exist in the metadata
//
//  An exception is thrown if any unexpected errors occurred.
// ----------------------------------------------------------------------------
bool  CmpSeabaseDDLauth::authExists (bool isExternal)
{
  // Read the auths table based on the auth_db_name
  NAString sysCat = CmpSeabaseDDL::getSystemCatalogStatic();
  NAString colName = (isExternal) ? "auth_ext_name" : "auth_db_name";
  NAString authName = (isExternal) ?  getAuthExtName() : getAuthDbName();
  char buf[1000];
  str_sprintf(buf, "select count(*) from %s.\"%s\".%s where %s = '%s' ",
                sysCat.data(), SEABASE_MD_SCHEMA, SEABASE_AUTHS, colName.data(),
                authName.data());

  Lng32 len = 0;
  Int64 rowCount = 0;
  ExeCliInterface cliInterface(STMTHEAP);
  Lng32 cliRC = cliInterface.executeImmediate(buf, (char*)&rowCount, &len, NULL);

  // If unexpected error occurred, return an exception
  if (cliRC < 0)
  {
    cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
    UserException excp (NULL, 0);
    excp.throwException();
  }

  return (rowCount > 0) ? true : false;
}
Пример #11
0
// ----------------------------------------------------------------------------
// method:  getAuthDetails
//
// Create the CmpSeabaseDDLauth class containing auth details for the
// request authID
//
// Input:
//    authID - the database authorization ID to search for
//
//  Output:
//    A returned parameter:
//       0 - authorization details are available
//       < 0 - an error was returned trying to get details
//       100 - authorization details were not found
//       > 0 - (not 100) warning was returned
// ----------------------------------------------------------------------------
Int32 CmpSeabaseDDLauth::getAuthDetails (Int32 authID)
{
  try
  {
    NAString sysCat = CmpSeabaseDDL::getSystemCatalogStatic();
    char buf[1000];
   str_sprintf(buf, "select auth_id, auth_db_name, auth_ext_name, auth_type, auth_creator, auth_is_valid, auth_create_time, auth_redef_time from %s.\"%s\".%s where auth_id = %s ",
              sysCat.data(), SEABASE_MD_SCHEMA, SEABASE_AUTHS, authID);
    NAString cmd (buf);

    if (selectExactRow(cmd))
      return 0;
    return 100;
  }
  catch (DDLException e)
  {
    // At this time, an error should be in the diags area.
    return e.getSqlcode();
  }
  catch (...)
  {
    // If there is no error in the diags area, set up an internal error
    Int32 numErrors = CmpCommon::diags()->getNumber(DgSqlCode::ERROR_);
    if (numErrors == 0)
      *CmpCommon::diags() << DgSqlCode (-CAT_INTERNAL_EXCEPTION_ERROR)
                          << DgInt0(__LINE__)
                          << DgString0("getAuthDetails for authID");

    return -CAT_INTERNAL_EXCEPTION_ERROR;
  }
}
Пример #12
0
// ----------------------------------------------------------------------------
// method: getAuthDetails
//
// Creates the CmpSeabaseDDLauth class containing auth details for the
// requested authName
//
// Input:
//    authName - the database auth name to retrieve details for
//    isExternal -
//       true - the auth name is the external name (auth_ext_name)
//       false - the auth name is the database name (auth_db_name)
//
// Output:
//    A returned parameter:
//       0 - authorization details are available
//       < 0 - an error was returned trying to get details
//       100 - authorization details were not found
//       > 0 - (not 100) warning was returned
// ----------------------------------------------------------------------------
Int32 CmpSeabaseDDLauth::getAuthDetails(const char *pAuthName,
                                        bool isExternal)
{
  try
  {
    NAString sysCat = CmpSeabaseDDL::getSystemCatalogStatic();
    char buf[1000];
    NAString authNameCol = isExternal ? "auth_ext_name " : "auth_db_name ";
   str_sprintf(buf, "select auth_id, auth_db_name, auth_ext_name, auth_type, auth_creator, auth_is_valid, auth_create_time, auth_redef_time from %s.\"%s\".%s where %s = '%s' ",
              sysCat.data(), SEABASE_MD_SCHEMA, SEABASE_AUTHS, authNameCol.data(), pAuthName);
    NAString cmd (buf);

    if (selectExactRow(cmd))
      return 0;
    return 100;
  }
  catch (DDLException e)
  {
    return e.getSqlcode();
  }
  catch (...)
  {
    return -1;
  }
}
static void showStrColNames(Queue * listOfColNames, Space * space,
			    NABoolean nullTerminated = FALSE)
{
  char buf[1000];

  listOfColNames->position();
  for (Lng32 j = 0; j < listOfColNames->numEntries(); j++)
    {
      char * currPtr = (char*)listOfColNames->getCurr();
      
      char * colNamePtr = NULL;
      if (nullTerminated)
	{
	  colNamePtr = currPtr;
	}
      else
	{
	  short colNameLen = *(short*)currPtr;
	  char colName[500];
	  snprintf(colName,sizeof(colName),"%.*s",colNameLen,currPtr+sizeof(short));
	  colNamePtr = colName;
	}

      str_sprintf(buf, "  Entry #%d: %s",
		  j+1, 
		  colNamePtr);
      
      space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

      listOfColNames->advance();
    } // for
}
short CmpSeabaseDDL::getUsingRoutines(ExeCliInterface *cliInterface,
                                     Int64 objUID,
                                     Queue * & usingRoutinesQueue)
{
  Lng32 retcode = 0;
  Lng32 cliRC = 0;

  char buf[4000];
  str_sprintf(buf, "select trim(catalog_name) || '.' || trim(schema_name) || '.' || trim(object_name), object_type "
                   "from %s.\"%s\".%s T, %s.\"%s\".%s LU "
                   "where LU.using_library_uid = %Ld and "
                   "T.object_uid = LU.used_udr_uid  and T.valid_def = 'Y' ",
              getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
              getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_LIBRARIES_USAGE,
              objUID);

  usingRoutinesQueue = NULL;
  cliRC = cliInterface->fetchAllRows(usingRoutinesQueue, buf, 0, 
                                     FALSE, FALSE, TRUE);
  if (cliRC < 0)
    {
      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
      return cliRC;
    }
 
  if (usingRoutinesQueue->numEntries() == 0)
    return 100;


  return 0;
}
Пример #15
0
Int16 SqlSealogEvent::sendEvent(Int16 eventId, Lng32 slSeverity)
{
  Int32 rc = 0;
#ifndef SP_DIS
  char eventidStr[10]="        ";
  Lng32 eventidLen = 0;
  str_sprintf(eventidStr,"10%d%06d",SQEVL_SQL,eventId);
  str_strip_blanks(eventidStr,eventidLen);
  Lng32 eventIdVal = (Lng32)str_atoi(eventidStr,eventidLen);
   common::event_header * eventHeader = sqlInfoEvent_.mutable_header();
  common::info_header * infoHeader = eventHeader->mutable_header();  

   rc = initAMQPInfoHeader(infoHeader, SQEVL_SQL);
   if (rc)
     //add trace log
     return rc;
  sqlInfoEvent_.mutable_header()->set_event_id(eventIdVal);
  sqlInfoEvent_.mutable_header()->set_event_severity(slSeverity);
  setExperienceLevel("ADVANCED");
  setTarget("LOGONLY");

  AMQPRoutingKey routingKey(SP_EVENT, SP_SQLPACKAGE,  SP_INSTANCE, 
                              SP_PUBLIC,  SP_GPBPROTOCOL,  "info_event"); 
  try {
    rc = sendAMQPMessage(true, sqlInfoEvent_.SerializeAsString(), SP_CONTENT_TYPE_APP, routingKey);
  } catch(...) {
    rc = -1;
  }
#endif
  return rc;
}
Пример #16
0
str *call_delete_udp(char **out, struct callmaster *m) {
	str callid, branch, fromtag, totag;

	__C_DBG("got delete for callid '%s' and viabranch '%s'", 
		out[RE_UDP_DQ_CALLID], out[RE_UDP_DQ_VIABRANCH]);

	str_init(&callid, out[RE_UDP_DQ_CALLID]);
	str_init(&branch, out[RE_UDP_DQ_VIABRANCH]);
	str_init(&fromtag, out[RE_UDP_DQ_FROMTAG]);
	str_init(&totag, out[RE_UDP_DQ_TOTAG]);

	if (call_delete_branch(m, &callid, &branch, &fromtag, &totag, NULL))
		return str_sprintf("%s E8\n", out[RE_UDP_COOKIE]);

	return str_sprintf("%s 0\n", out[RE_UDP_COOKIE]);
}
short CmpSeabaseDDL::dropMetadataViews(ExeCliInterface * cliInterface)
{
  Lng32 cliRC = 0;
  Lng32 retcode = 0;

  char queryBuf[5000];

  for (Int32 i = 0; i < sizeof(allMDviewsInfo)/sizeof(MDViewInfo); i++)
    {
      const MDViewInfo &mdi = allMDviewsInfo[i];
      
      if (! mdi.viewName)
	continue;

      str_sprintf(queryBuf, "drop view %s.\"%s\".%s",
		  getSystemCatalog(), SEABASE_MD_SCHEMA,
		  mdi.viewName);

      NABoolean xnWasStartedHere = FALSE;
      if (beginXnIfNotInProgress(cliInterface, xnWasStartedHere))
        return -1;

      cliRC = cliInterface->executeImmediate(queryBuf);
      if (cliRC < 0)
	{
	  cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
	}
      
      if (endXnIfStartedHere(cliInterface, xnWasStartedHere, cliRC) < 0)
        return -1;
      
    } // for

  return 0;
}
Пример #18
0
//----------------------------------------------------------------------
// Name         : sortSendEnd
// 
// Parameters   : ...
//
// Description  : 
//
// Return Value :
//   SORT_SUCCESS if everything goes on well.
//   SORT_FAILURE if any error encounterd. 
//
//----------------------------------------------------------------------
Lng32 SortUtil::sortSendEnd(NABoolean& internalSort)
{
  Lng32 retcode = SORT_SUCCESS;
  state_ = SORT_SEND_END;

  retcode =   sortAlgo_->sortSendEnd() ;

  if (retcode)
   return retcode;

  if (sortAlgo_->isInternalSort()) 
  {
    internalSort = TRUE_L;
    if(config_->logInfoEvent())
    {
      char msg[500];
      str_sprintf(msg,
      "Sort is performing internal sort: NumRecs:%d", stats_.numRecs_);
      
      SQLMXLoggingArea::logExecRtInfo(NULL, 0,msg, explainNodeId_);
    }
  }
  else 
  {
    internalSort = FALSE_L;
    retcode =  sortSendEndProcessing() ; 
    return retcode;
  }

  return retcode;
}
Пример #19
0
//----------------------------------------------------------------------
// Name         : sortReceive
// 
// Parameters   : ...
//
// Description  : 
//
// Return Value :
//   SORT_SUCCESS if everything goes on well.
//   SORT_FAILURE if any error encounterd. 
//
//----------------------------------------------------------------------
Lng32 SortUtil::sortReceive(void*& record,ULng32& len,void*& tupp)
{
  NABoolean status;
  status = sortAlgo_->sortReceive(record, len, tupp);
  if ((len == 0) && (!config_->partialSort_)) {
    if(scratch_)
     {
      ScratchFileMap* tempFilesMap;
      tempFilesMap = scratch_->getScrFilesMap();
      //stats_.scrNumReads_ = tempFilesMap->totalNumOfReads();
      //stats_.scrNumAwaitio_ = tempFilesMap->totalNumOfAwaitio();      
      scratch_->getTotalIoWaitTime(stats_.ioWaitTime_);    
     }
    stats_.numCompares_ += sortAlgo_->getNumOfCompares();  
    Int64 currentTimeJ = NA_JulianTimestamp();
    stats_.elapsedTime_ = currentTimeJ - stats_.beginSortTime_; 
    if (config_->logInfoEvent()) {
      char msg[500];
      str_sprintf(msg, "Sort elapsed time : %Ld; Num runs : %d; runsize :%d",
		stats_.elapsedTime_,stats_.numInitRuns_,sortAlgo_->getRunSize());
      SQLMXLoggingArea::logExecRtInfo(NULL, 0,msg, explainNodeId_);
    }
  } 
  return status;
}
Пример #20
0
// creates LOB handle in string format.
void ExpLOBoper::createLOBhandleString(Int16 flags,
				       Lng32 lobType,
				       Int64 uid, 
				       Lng32 lobNum,
				       Int64 descKey, 
				       Int64 descTS,
				       short schNameLen,
				       char * schName,
				       char * lobHandleBuf)
{
  str_sprintf(lobHandleBuf, "LOBH%04d%02d%04d%020Ld%02d%Ld%02d%Ld%03d%s",
	      flags, lobType, lobNum, uid,
	      findNumDigits(descKey), descKey, 
	      findNumDigits(descTS), descTS,
	      schNameLen, schName);

  /*

  str_sprintf(lobHandleBuf, "LOBH%04d%020Ld%04d%02d%Ld%02d%Ld%03d%s",
  	      flags, uid, lobNum, 
	      findNumDigits(descKey), descKey, 
	      findNumDigits(descTS), descTS,
	      schNameLen, schName);
  */
}
// 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();
  
}
Пример #22
0
// A helper function convert an Interval type to its Text
short
getIntervalTypeText(char *text,                       // OUTPUT
                    rec_datetime_field datetimestart, // INPUT
                    UInt32 intervalleadingprec,     // INPUT
                    rec_datetime_field datetimeend,   // INPUT
                    UInt32 fractionPrecision)       // INPUT
{
  if (datetimestart >= REC_DATE_SECOND)
  {
    str_sprintf(text,
                "INTERVAL %s(%u,%u)",
                dtFieldToText(datetimestart),
                intervalleadingprec,
                fractionPrecision);
  }
  else if (datetimestart == datetimeend)
  {
    str_sprintf(text,
                "INTERVAL %s(%u)",
                dtFieldToText(datetimestart),
                intervalleadingprec);
  }
  else
  {
    if (datetimeend < REC_DATE_SECOND)
    {
      str_sprintf(text,
                  "INTERVAL %s(%u) TO %s",
                  dtFieldToText(datetimestart),
                  intervalleadingprec,
                  dtFieldToText(datetimeend));
    }
    else
    {
       str_sprintf(text,
                   "INTERVAL %s(%u) TO %s(%u)",
                   dtFieldToText(datetimestart),
                   intervalleadingprec,
                   dtFieldToText(datetimeend),
                   fractionPrecision);
    }
  }

  return 0;
} // getIntervalTypeText()
Пример #23
0
void ComTdbParallelLabelOp::displayContents(Space *space, ULng32 flag)
{
   ComTdb::displayContents(space, flag & 0xFFFFFFFE);
   if (flag & 0x00000008)
   {
      char buf[100];
      str_sprintf(buf,"\nFor ComTdbParallelLabelOp: ");
      space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
      str_sprintf(buf,"Operation = %d", operation_);
      space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
   }

   if (flag & 0x00000001)
   {
      displayExpression(space, flag);
      displayChildren(space, flag);
   }
}
Пример #24
0
void ExpLOBoper::displayContents(Space * space, const char * displayStr, 
				 Int32 clauseNum, char * constsArea)
{
  ex_clause::displayContents(space, displayStr, clauseNum, constsArea);

  char buf[100];
  str_sprintf(buf, "    lobNum_ = %d, lobStorageType_ = %d",
	      lobNum_, lobStorageType_);
  space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

  Lng32 len = MINOF(strlen(lobStorageLocation_), 50);
  char loc[100];
  str_cpy_all(loc, lobStorageLocation_, len);
  loc[len] = 0;
  str_sprintf(buf, "    lobStorageLocation_ = %s\n",
	      loc);
  space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
}
char * ExExeUtilTcb::getStatusString(const char * operation,
				     const char * status,
				     const char * object,
				     char * outBuf,
				     char * timeBuf,
				     char * queryBuf,
				     char * errorBuf)
{
  if (! outBuf)
    return NULL;

  char o[16];
  char s[10];
  byte_str_cpy(o, 15, operation, strlen(operation), ' ');
  o[15] = 0;
  byte_str_cpy(s, 9, status, strlen(status), ' ');
  s[9] = 0;
  if (queryBuf)
    {
      str_sprintf(outBuf, "Task: %s  Status: %s  Command: %s",
		  o, s, queryBuf);
    }
  else if (timeBuf)
    {
      str_sprintf(outBuf, "Task: %s  Status: %s  ET: %s",
		  o, s, timeBuf);
    }
  else if (errorBuf)
    {
      str_sprintf(outBuf, "Task: %s  Status: %s  Details: %s",
		  o, s, errorBuf);
    }
  else
    {
      if (object)
	str_sprintf(outBuf, "Task: %s  Status: %s  Object: %s",
		    o, s, object);
      else
	str_sprintf(outBuf, "Task: %s  Status: %s",
		    o, s);
    }

  return outBuf;
}
Пример #26
0
static void showColNames(Queue * listOfColNames, Space * space)
{
  char buf[1000];

  listOfColNames->position();
  for (Lng32 j = 0; j < listOfColNames->numEntries(); j++)
    {
      char * currPtr = (char*)listOfColNames->getCurr();
      
      Lng32 currPos = 0;
      Lng32 jj = 0;
      short colNameLen = *(short*)currPtr;
      currPos += sizeof(short);
      char colFam[100];
      while (currPtr[currPos] != ':')
	{
	  colFam[jj] = currPtr[currPos];
	  currPos++;
	  jj++;
	}
      colFam[jj] = ':';
      jj++;
      currPos++;
      colFam[jj] = 0;
      colNameLen -= jj;
      
      NABoolean withAt = FALSE;
      char * colName = &currPtr[currPos];
      if (colName[0] == '@')
	{
	  colNameLen--;
	  colName++;
	  withAt = TRUE;
	}
      
      Int64 v;
      if (colNameLen == sizeof(char))
	v = *(char*)colName;
      else if (colNameLen == sizeof(unsigned short))
	v = *(UInt16*)colName;
      else if (colNameLen == sizeof(Lng32))
	v = *(ULng32*)colName;
      else
	v = 0;
      
      str_sprintf(buf, "  Entry #%d: %s%s%Ld",
		  j+1, 
		  colFam, 
		  (withAt ? "@" : ""),
		  v);
      
      space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));

      listOfColNames->advance();
    } // for
}
Пример #27
0
void make_disk_comment(const char *program, const char *version, disk_t& disk) {
    time_t now = time(NULL);
    const struct tm *local = localtime(&now);

    disk.comment = str_sprintf(
        "%s %s: %02d/%02d/%04d %02d:%02d:%02d\r\n",
        program, version,
        local->tm_mday, local->tm_mon + 1, local->tm_year + 1900,
        local->tm_hour, local->tm_min, local->tm_sec);
}
Пример #28
0
char * ExpLOBoper::ExpGetLOBDescHandleObjNamePrefix(Int64 uid, 
					   char * outBuf, Lng32 outBufLen)
{
  if (outBufLen < 512)
    return NULL;
  
  str_sprintf(outBuf, "LOBDescHandle_%020Ld", uid);
  
  return outBuf;
}
Пример #29
0
char * ExpLOBoper::ExpGetLOBname(Int64 uid, Lng32 num, char * outBuf, Lng32 outBufLen)
{
  if (outBufLen < 31)
    return NULL;

  str_sprintf(outBuf, "LOBP_%020Ld_%04d",
	      uid, num);

  return outBuf;
}
Пример #30
0
void
cfg_get_str(const char *key, String *result)
{	
	assert(cfg_L != NULL && key != NULL && str_isvalid(result));
	lua_pushstring(cfg_L, key);		/* ... key */
	lua_rawget(cfg_L, cfg_index);	/* ... str? */
	L_assert(cfg_L, lua_isstring(cfg_L, -1), "String expected.");
	str_sprintf(result, lua_tostring(cfg_L, -1));
	lua_pop(cfg_L, 1);			/* ... */
}