Esempio n. 1
0
//CmpStoredProc::Status CmpInternalSP::open(CmpISPDataObject& data)
CmpStoredProc::ExecStatus CmpInternalSP::open(CmpISPDataObject& data)
{
  CMPASSERT(state_ == NONE);
  procFuncs_ = procFuncsLookupTable_[procName()];
  if (!procFuncsLookupTable_.ValidPFuncs(procFuncs_))
  {
    *(cmpContext()->diags()) << DgSqlCode(arkcmpErrorISPNotFound) 
      << DgString0(procName().data());
    return FAIL;       
  }

  initSP_ERROR_STRUCT();
  SP_STATUS spStatus =
      (*(procFuncs_.procFunc_))( SP_PROC_OPEN, 
				(SP_ROW_DATA)data.input(),
				CmpSPExtractFunc,
				(SP_ROW_DATA)data.output(), 
				CmpSPFormatFunc,
				(SP_KEY_VALUE)data.key(), 
				CmpSPKeyValueFunc,
				&procHandle_, 
				procFuncs_.spHandle_, 
				&spError_[0]);

  if (spStatus == SP_FAIL || spStatus == SP_SUCCESS_WARNING)
  {
    // Errors or warnings, go get them
    data.output()->MoveDiags(spError_, spStatus);
    if (spStatus == SP_FAIL)
      return FAIL;
  }
  state_ = PROCESS;
  return SUCCESS; 
}
Esempio n. 2
0
NAString CmpInternalSP::OutTableName()
{
  // To make the OutTableName unique, put in the timestamp
  // Note the timeStamp() above returns just lower 4 bytes of seconds since
  // 01/01/1970 00:00:00, so it may not be unique if we get here to soon.
  NAString tableName = "SPTableOut" + procName() + timeStamp();
  return tableName;
}
Esempio n. 3
0
void CloseProcess()
{
    C_TEXT name;
    PA_GetProcessInfo(PA_GetCurrentProcessNumber(), name, 0, 0);
    CUTF16String procName(name.getUTF16StringPtr());
    CUTF16String exitProcName((PA_Unichar *)"$\0x\0x\0\0\0");
    if (!procName.compare(exitProcName))
        SystemEventsManager::stopCallbackLoop();
}
Esempio n. 4
0
NABoolean CmpInternalSP::startCompileCycle()
{
  procFuncs_ = procFuncsLookupTable_[procName()];
  if (!procFuncsLookupTable_.ValidPFuncs(procFuncs_))
    {
       *(cmpContext()->diags()) << DgSqlCode(arkcmpErrorISPNotFound) 
	 << DgString0(procName().data());
       return FALSE;       
    }
  if ( state_ != COMPILE )
    {
      // needs to call the compileFunc_
      initSP_ERROR_STRUCT();
      if ( (*(procFuncs_.compileFunc_)) (SP_COMP_INIT, &compHandle_,
        procFuncs_.spHandle_, &spError_[0])!= SP_SUCCESS )
	{
	  appendDiags();
	  return FALSE;	  
	}      
    }
        
  state_ = COMPILE;  
  return TRUE;  
}
bool CertLauncher::monitorProgs()
{
    // get the output file to write the log data to
    string logFile = getLogFile();

    //remove the .exe from each program first
    int pos = 0;
    pos = tasks[mCurTask].SignalSource.find(".exe");
    if (pos >= 0)
        tasks[mCurTask].SignalSource.erase(pos, string::npos);
    pos = tasks[mCurTask].SigProc.find(".exe");
    if (pos >= 0)
        tasks[mCurTask].SigProc.erase(pos, string::npos);
    pos = tasks[mCurTask].App.find(".exe");
    if (pos >= 0)
        tasks[mCurTask].App.erase(pos, string::npos);

    //call the platform dependent cpu monitoring script
    stringstream comm;
    comm << "start cscript cpuMon.vbs " << tasks[mCurTask].SignalSource << " ";
    comm << tasks[mCurTask].SigProc << " " << tasks[mCurTask].App << " ";
    comm << logFile << " " << "1000";
    system(comm.str().c_str());

    //this function runs until the processes have exited
    DWORD aProcesses[1024], cbNeeded, cProcesses;
    unsigned int i;
    bool procNotFound = false;
    while (!procNotFound)
    {
        procNotFound = true;
        if (!EnumProcesses (aProcesses, sizeof(aProcesses), &cbNeeded) )
            return false;

        cProcesses = cbNeeded / sizeof(DWORD);

        Sleep(1000);
        for (i = 0; i < cProcesses; i++)
        {
            if (aProcesses[i] != 0)
            {
                HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
                                                false, aProcesses[i]);
                char szProcessName[MAX_PATH] = "<unknown>";
                if (hProcess != NULL)
                {
                    HMODULE hMod;
                    DWORD cbNeeded2;

                    if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded2))
                    {
                        GetModuleBaseName(hProcess, hMod, szProcessName,
                                sizeof(szProcessName)/sizeof(TCHAR));
                    }
                }
                string procName(szProcessName);
                CloseHandle(hProcess);

                if(procName == "operat.exe")
                    procNotFound = false;
            }
        }
        if (procNotFound)
        {
            //check if wscript is running?
            return true;
        }
    }
}
Esempio n. 6
0
CmpStoredProc::ExecStatus CmpInternalSP::fetch(CmpISPDataObject& data)
{
  CMPASSERT(state_ == PROCESS);

  // Need to send controls explicitly from the compiler space to the
  // cli context so ISP requests can perform CLI operations to extract
  // their values.
  // For now, only send controls for MODIFY, POPULATE INDEX, TRANSFORM,
  // PURGEDATA, MV_refresh and VALIDATE sp requests.
  // This also means RECOVER since these operations
  // can be perfomed through a RECOVER operation.
  //
  // VO, Versioning Light: Also send controls for sp_SchLevel
  //                       (UPGRADE and DOWNGRADE)
  if (procName() == "sp_partn" || 
      procName() == "sp_populate" ||
      procName() == "sp_purgedata" ||
      procName() == "sp_recover" ||
      procName() == "sp_transform" ||
      procName() == "sp_validate" || 
      procName() == "sp_purgedata" ||
      procName() == "sp_refresh" ||
      procName() == "sp_SchLevel")  
    {
      sendAllControls(FALSE, FALSE, TRUE);
      
      // set the parent qid for this session
      const char *parentQid = cmpContext()->sqlSession()->getParentQid();
      if (parentQid != NULL)
	{
	  setParentQidAtSession(cmpContext()->statementHeap(), parentQid);
	}
    }

  // Send sqlparser_flags
  if (Get_SqlParser_Flags(ALLOW_FUNNY_IDENTIFIER))
    sendParserFlag(ALLOW_FUNNY_IDENTIFIER);

  initSP_ERROR_STRUCT();
  SP_STATUS spStatus =
      (*(procFuncs_.procFunc_))( SP_PROC_FETCH, 
                                (SP_ROW_DATA)data.input(),
                                CmpSPExtractFunc,
                                (SP_ROW_DATA)data.output(), 
                                CmpSPFormatFunc,
                                (SP_KEY_VALUE)data.key(), 
                                CmpSPKeyValueFunc,
                                &procHandle_, 
                                procFuncs_.spHandle_, 
                                &spError_[0]);

  if (spStatus == SP_FAIL)
  {
    // Errors, go get them
    data.output()->MoveDiags(spError_, spStatus);
    if (CmpCommon::diags() != NULL)
    {
      data.output()->MergeDiags(CmpCommon::diags());
      CmpCommon::diags()->clear();
    }
    return FAIL;
  }

  if (CmpCommon::diags() != NULL)
  {
    data.output()->MergeDiags(CmpCommon::diags());
    CmpCommon::diags()->clear();
  }

  if ( spStatus == SP_MOREDATA)
  {
    return MOREDATA;
  }
  return SUCCESS;
}