Exemplo n.º 1
0
// print MDFWriter errors to cout
void SQLJFile::printMDFWriterErrors(char *errFileName)
{
  char args[1024], EorW[10];
  Int32  errNum;
  FILE *errFile = fopen(errFileName, "r");
  if (errFile) {
    // accommodate case of MDFWriter dumping more entries into its errFile
    // than can fit into the fixed-size diags area. Do this by feeding
    // and then dumping diags one entry at a time.
    ComDiagsArea *myDiags = ComDiagsArea::allocate(mxCUMptr->heap());
    while (fscanf(errFile, "%s %d ", EorW, &errNum) != EOF) {
      size_t sLen = 0;
      if (fgets(args, 1024, errFile) == NULL) { // fgets got EOF or an error
        args[0] = 0; // empty string
        *mxCUMptr << FAIL;
      }
      else { // fgets got something
        sLen = strlen(args);
        // chop off terminating newline
        if (args[sLen-1] == '\n') {
          args[sLen-1] = 0;
        }
        if (sLen >= 1023) { // diagnostic msg is too long
          // toss rest of line
          Int32 nxtCh;
          do {
            nxtCh = fgetc(errFile);
          } while (nxtCh != '\n' && nxtCh != EOF);
        }
      }
      if (!myDiags) { // no diags
        *mxCUMptr << FAIL;
        if (sLen >= 1023) { // diagnostic msg is too long
          cerr << "Diagnostic message is over 1023 characters long." << endl;
        }
        // echo error file entry to cerr
        cerr << EorW << " " << errNum << " " << args << endl;
      }
      else {
        if (sLen >= 1023) { // diagnostic msg is too long
          *mxCUMptr << WARNING;
          *myDiags << DgSqlCode(2237);
        }
        switch (errNum) {
        case 2224:
        case 2225:
        case 2226:
          *mxCUMptr << FAIL; 
          *myDiags << DgSqlCode(-errNum);
          break;
        case 2227:
        case 2228:
        case 2230:
          *mxCUMptr << FAIL;
          *myDiags << DgSqlCode(-errNum) << DgString0(args);
          break;
        case 2229:
          *mxCUMptr << ERROR;
          *myDiags << DgSqlCode(-errNum) << DgString0(args);
          break;
        default:
          *mxCUMptr << (EorW[0]=='E' ? ERROR :
                        (EorW[0]=='W' ? WARNING : FAIL));
          *myDiags << DgSqlCode(-2231) << DgInt0(errNum) 
                   << DgString0(EorW) << DgString1(args);
          break;
        } // end switch
        NADumpDiags(cerr, myDiags, TRUE);
        myDiags->clear();
      } // end if
    } // end while
    if (myDiags) {
      myDiags->decrRefCount();
    }
    fclose(errFile);
  }
  else {
    *mxCUMptr << FAIL << DgSqlCode(-2218) << DgString0(errFileName);
  }
  // clean up temporary file (MDFWriter errors)
  remove(errFileName);
}
Exemplo n.º 2
0
static ostream &operator<<(ostream &dest, ComDiagsArea& diags)
{
  NADumpDiags(dest, &diags, FALSE, NO_COMMENT /*info msg style*/);
  return dest;
}
Exemplo n.º 3
0
void CmpCommon::dumpDiags(ostream& outStream, NABoolean newline)
{
  NADumpDiags(outStream, diags(), newline);
}
Exemplo n.º 4
0
//////////////////////////////////////////////
// Begin ERROR
////////////////////////////////////////////////
short Error::process(SqlciEnv * sqlci_env)
{
  NAWchar   *error_msg;
  Int32        codeE, codeW;
  char       stateE[10], stateW[10];
  NABoolean  msgNotFound;

  ostringstream omsg;

  #define GETERRORMESS(in, out, typ)	GetErrorMessage(in, (NAWchar *&)out, typ)

  codeW = ABS(atoi(get_argument()));	// >= 0, i.e. warning
  codeE = -codeW;			// <= 0, i.e. error

  // These calls must be done before any of the GETERRORMESS(),
  // as they all use (overwrite) the same static buffer in GetErrorMessage.cpp.
  ComSQLSTATE(codeE, stateE);
  ComSQLSTATE(codeW, stateW);
  msgNotFound = GETERRORMESS(codeE, error_msg, ERROR_TEXT);

  if (type == ENVCMD_)
    {
      if (msgNotFound)
        {
	  error_msg[0] = NAWchar('\n');
	  error_msg[1] = NAWchar('\0');
	}
      else
        {
	  // Extract the {braces-enclosed version string}
	  // that msgfileVrsn.ksh (called by GenErrComp.bat)
	  // has put into this ENVCMD_ message.
	  NAWchar *v = NAWstrchr(error_msg, NAWchar(']'));
	  if (v) error_msg = v;
	  v = NAWstrchr(error_msg, NAWchar('{'));
	  if (v) error_msg = v;
	  v = NAWstrchr(error_msg, NAWchar('}'));
	  if (v++ && *v == NAWchar('.')) *v = NAWchar(' ');
	}
      NAWriteConsole(error_msg, omsg, FALSE);
    }
  else if (!msgNotFound || codeE == 0)		// SQL "success", special case
    {
      omsg << "\n*** SQLSTATE (Err): " << stateE
           << " SQLSTATE (Warn): " << stateW;
      omsg << endl;
      NAWriteConsole(error_msg,omsg, TRUE);
    }
  else
    {
      // Msg not found.  
      ComDiagsArea diags;
      diags << DgSqlCode(codeW);
      NADumpDiags(omsg, &diags, TRUE/*newline*/);
    }

#if 0			// CAUSE/EFFECT/RECOVERY text not implemented yet!
  if (!msgNotFound && type == DETAIL_)
    {
      GETERRORMESS(codeE, error_msg, CAUSE_TEXT);
      NAWriteConsole(error_msg,omsg, TRUE);

      GETERRORMESS(codeE, error_msg, EFFECT_TEXT);
      NAWriteConsole(error_msg,omsg, TRUE);

      GETERRORMESS(codeE, error_msg, RECOVERY_TEXT);
      NAWriteConsole(error_msg,omsg, TRUE);

    }
#endif // 0		// CAUSE/EFFECT/RECOVERY text not implemented yet!

  omsg << ends;					// to tack on a null-terminator
  sqlci_env->get_logfile()->WriteAllWithoutEOL(omsg.str().c_str());
  return 0;
}
Exemplo n.º 5
0
void SqlciEnv::displayDiagnostics()
{
  NADumpDiags(cout, &sqlci_DA,
	      TRUE/*newline*/, FALSE/*comment-style*/,
	      get_logfile()->GetLogfile());
}