void UdrGuaControlConnection::actOnSystemMessage( short messageNum, IpcMessageBufferPtr sysMsg, IpcMessageObjSize sysMsgLen, short clientFileNumber, const GuaProcessHandle &clientPhandle, GuaConnectionToClient *connection) { const char * moduleName = "UdrGuaControlConnection::actOnSystemMessage"; switch (messageNum) { case ZSYS_VAL_SMSG_OPEN: { if (udrGlob_->verbose_ && udrGlob_->traceLevel_ >= TRACE_IPMS && udrGlob_->showMain_) { ServerDebug( "[UdrServ (%s)] A new connection %p is opened to the Server.", moduleName, connection); } // Create a new message stream. Link the connection. // Then call receive on it to bring it into receiving mode. UdrServerControlStream *newControlStream = new (udrGlob_->getIpcHeap()) UdrServerControlStream(udrGlob_->getIpcEnvironment(), udrGlob_, UDR_STREAM_SERVER_CONTROL, UdrServerControlStreamVersionNumber); newControlStream->addRecipient(connection); newControlStream->receive(FALSE); } break; default: // do nothing for all other kinds of system messages break; } // switch // The parent class already handles the job of closing all connections // who lost their client process by failed processes, failed CPUs and // failed systems or networks. Check here that we die if all our // requestors go away, but don't die if the first system message is // something other than an OPEN message. if (getNumRequestors() == 0 AND initialized_) { NAExit(0); } else if (NOT initialized_ AND getNumRequestors() > 0) { // the first requestor came in initialized_ = TRUE; } } // UdrGuaControlConnection::actOnSystemMessage()
void dumpLmParameter(LmParameter &p, Lng32 i, const char *prefix) { if (prefix == NULL) prefix = ""; ServerDebug("%s [%ld] Name [%s]", prefix, i, p.getParamName() ? p.getParamName() : ""); ServerDebug("%s FS type %s, prec %d, scale %d, charset %d", prefix, getDatatypeAsString(p.fsType()), (Int32) p.prec(), (Int32) p.scale(), (Int32) p.encodingCharSet()); ServerDebug("%s direction %s, collation %d, objMap %ld, resultSet %s", prefix, getDirectionName(p.direction()), (Int32) p.collation(), (Int32) p.objMapping(), TF_STRING(p.resultSet())); ServerDebug("%s IN offset %d, len %d, null offset %d, null len %d", prefix, (Int32) p.inDataOffset(), (Int32) p.inSize(), (Int32) p.inNullIndOffset(), (Int32) p.inNullIndSize()); ServerDebug("%s vclen offset %d, vclen len %d", prefix, (Int32) p.inVCLenIndOffset(), (Int32) p.inVCLenIndSize()); ServerDebug("%s OUT offset %d, len %d, null offset %d, null len %d", prefix, (Int32) p.outDataOffset(), (Int32) p.outSize(), (Int32) p.outNullIndOffset(), (Int32) p.outNullIndSize()); ServerDebug("%s vclen offset %d, vclen len %d", prefix, (Int32) p.outVCLenIndOffset(), (Int32) p.outVCLenIndSize()); } // dumpLmParameter
void UdrServerControlStream::actOnReceive(IpcConnection *conn) { const char *moduleName = "UdrServerControlStream::actOnReceive"; NABoolean doTrace = (udrGlob_->verbose_ && udrGlob_->traceLevel_ >= TRACE_IPMS && udrGlob_->showMain_) ? TRUE : FALSE; if (doTrace) { ServerDebug("[UdrServ (%s)]", moduleName); ServerDebug(" A new message arrived on connection %p.", conn); } // Create a new stream and give the message to that stream UdrServerReplyStream *newReplyStream = new (udrGlob_->getUdrHeap()) UdrServerReplyStream( udrGlob_->getIpcEnvironment(), udrGlob_, UDR_STREAM_SERVER_REPLY, UdrServerReplyStreamVersionNumber); giveMessageTo(*newReplyStream, conn); // Add the stream to Udr Globals list of streams udrGlob_->addReplyStream(newReplyStream); if (doTrace) { ServerDebug(" The new message is scheduled for processing."); ServerDebug(" The connection %p will be placed on receive mode.", conn); ServerDebug("[UdrServ (%s)] Done", moduleName); } // We have retrieved the message from stream, make it ready for // next message. receive(FALSE); } // UdrServerControlStream::actOnReceive()
void get_fifo_size(void) { unsigned int i; set_dla_write(); raw_dla_off(); for(i=0; ((inp(dmla_info)&0x02)!=0x02); i+=2) outpw(fifo_location,0); fifo_size=i; fifo_hold = 2*fifo_size; ServerDebug("FIFO size is %d bytes\n", fifo_size); }
void reportLoadResults(UdrGlobals *UdrGlob, SPInfo *sp, LmRoutine *lmr_) { const char *moduleName = "reportLoadResults"; doMessageBox(UdrGlob, TRACE_SHOW_DIALOGS, UdrGlob->showLoad_, moduleName); if (UdrGlob->verbose_ && UdrGlob->traceLevel_ >= TRACE_DETAILS && UdrGlob->showLoad_ ) { ServerDebug(""); ServerDebug("[UdrServ (%s)] LOAD message results:", moduleName); ServerDebug(" LOAD Udr Handle : " INT64_SPEC , (Int64) sp->getUdrHandle()); ServerDebug(" LM result parameter : %d", (Int32) sp->getNumParameters()); if (sp->getReturnValue() != NULL) { dumpLmParameter(*sp->getReturnValue(), 0, " "); } if (lmr_) { ServerDebug(" LM routine : "); dumpBuffer((unsigned char *)lmr_, sizeof(LmRoutine)); } ServerDebug(""); } } // reportLoadResults
void UdrServerDataStream::actOnReceive(IpcConnection *conn) { const char *moduleName = "UdrServerDataStream::actOnReceive()"; IpcMessageObjType t; NABoolean somethingArrived = FALSE; // // A note about control flow in this method. It was originally // written under the assumption that only one message arrives at a // time. It would call getNextReceiveMsg() only once, then process // incoming objects, then return. It turns out this creates a memory // leak. Internally within the stream, the incoming message buffer // never moved from the "receive" list to the "in use" list and // never got cleaned up. Now this method calls getNextReceiveMsg() // until it returns FALSE. The result is that after the incoming // message has been processed, the next getNextReceiveMsg() call // will move the request buffer to the "in use" list where it later // gets cleaned up by a call to cleanupBuffers() or // releaseBuffers(). // while (getNextReceiveMsg(t)) { somethingArrived = TRUE; while (getNextObjType(t)) { switch (t) { case UDR_MSG_DATA_HEADER: { // Do nothing for now except extract the object from the stream UdrDataHeader *h = new (receiveMsgObj()) UdrDataHeader(this); } // case UDR_MSG_DATA_HEADER break; case UDR_MSG_CONTINUE_REQUEST: { // Extract the object from the stream and call SPInfo's work() UdrContinueMsg *m = new (receiveMsgObj()) UdrContinueMsg(this); if(spinfo_->getParamStyle() == COM_STYLE_TM) spinfo_->workTM(); else spinfo_->work(); } // case UDR_MSG_CONTINUE_REQUEST break; case UDR_MSG_DATA_REQUEST: { UdrDataBuffer *request = new (receiveMsgObj()) UdrDataBuffer(this); if (udrGlob_->verbose_ && udrGlob_->traceLevel_ >= TRACE_DETAILS && udrGlob_->showMain_) { ServerDebug( ""); ServerDebug("[UdrServ (%s)] Invoke Request has %ld tupps.", moduleName, request->getSqlBuffer()->getTotalTuppDescs()); ServerDebug("[UdrServ (%s)] Invoke Request SQL Buffer", moduleName); displaySqlBuffer(request->getSqlBuffer(), (Lng32) request->getSqlBufferLength()); } udrGlob_->numReqInvokeSP_++; // Let the SPInfo process the request spinfo_->setCurrentRequest(request); spinfo_->work(); } // case UDR_MSG_DATA_REQUEST break; case UDR_MSG_TMUDF_DATA_HEADER: { // Extract the object. UDR Handle and RS Handle are // interesting things in this message. UdrTmudfDataHeader *h = new (receiveMsgObj()) UdrTmudfDataHeader(this); UdrHandle udrHandle = h->getHandle(); NABoolean anyMore = getNextObjType(t); UDR_ASSERT(anyMore, "DATA_REQUEST must follow TMUDF DATA_HEADER"); UDR_ASSERT(t == UDR_MSG_DATA_REQUEST, "DATA_REQUEST must follow TMUDF DATA_HEADER"); UdrDataBuffer *request = new (receiveMsgObj()) UdrDataBuffer(this, FALSE); //Avoid unpack. // Let the SPInfo process the request spinfo_->setCurrentRequest(request); spinfo_->workTM(); } break; case UDR_MSG_RS_DATA_HEADER: { // Extract the object. UDR Handle and RS Handle are // interesting things in this message. UdrRSDataHeader *h = new (receiveMsgObj()) UdrRSDataHeader(this); UdrHandle udrHandle = h->getHandle(); RSHandle rsHandle = h->getRSHandle(); NABoolean anyMore = getNextObjType(t); UDR_ASSERT(anyMore, "DATA_REQUEST must follow RS_DATA_HEADER"); UDR_ASSERT(t == UDR_MSG_DATA_REQUEST, "DATA_REQUEST must follow RS_DATA_HEADER"); UdrDataBuffer *request = new (receiveMsgObj()) UdrDataBuffer(this); udrGlob_->numReqRSFetch_++; processAnRSFetchMessage(udrGlob_, *this, udrHandle, rsHandle, request); // We need the request buffer in a state where the stream // knows it can be freed. We call SqlBuffer::bufferFull() to // accomplish this even though the method name is a bit // misleading. SqlBuffer *sqlBuf = request->getSqlBuffer(); UDR_ASSERT(sqlBuf, "UDR request buffer is corrupt or contains no data"); sqlBuf->bufferFull(); } break; case UDR_MSG_RS_CONTINUE: { UdrRSContinueMsg *rsContinue = new (receiveMsgObj()) UdrRSContinueMsg(this); udrGlob_->numReqRSContinue_++; processAnRSContinueMessage(udrGlob_, *this, *rsContinue); } break; default: { UDR_ASSERT(FALSE, "Unknown message type arrived on UDR data stream"); } // default break; } // switch (t) } // while (getNextObjType(t)) } // while (getNextReceiveMsg(t)) // Make sure all reply buffers have been given to the connection. If // the only objects that arrived during this callback were continue // requests, then this action allows reply buffers associated with // those continue requests to propagate out of the stream and onto // the connection. // // If numOfInputBuffers() is > 0 then we do not need to do anything // at this point. This callback will be invoked again when the // incoming message is complete and ready to be processed. Lng32 numInputBuffers = numOfInputBuffers(); if (somethingArrived && numInputBuffers == 0 && spinfo_->getCurrentRequest() == NULL) { responseDone(); if (udrGlob_->verbose_ && udrGlob_->traceLevel_ >= TRACE_IPMS && udrGlob_->showMain_) { ServerDebug("[UdrServ (%s)] All messages marked as replied", moduleName); } // Cleanup any unpacked message buffers containing only objects // that are no longer in use, as determined by the virtual method // IpcMessageObj::msgObjIsFree() releaseBuffers(); // Do final garbage collection } } // UdrServerDataStream::actOnReceive()
// LCOV_EXCL_START void displaySqlBuffer(SqlBuffer *sbuf, Lng32 sbuflen, ostream &os) { os << "Display an SQL Buffer:" << endl; os << " Buffer Size : " << sbuf->get_buffer_size() << endl; os << " Used Size : " << sbuf->get_used_size() << endl; os << " Free Size : " << (sbuf->get_buffer_size() - sbuf->get_used_size()) << endl; switch (sbuf->bufType()) { case SqlBufferBase::NORMAL_: os << " Buffer Type : Normal" << endl; break; case SqlBufferBase::DENSE_: os << " Buffer Type : Dense" << endl; break; case SqlBufferBase::OLT_: os << " Buffer Type : OLT" << endl; break; default: os << " Buffer Type : Unknown (" << sbuf->bufType() << ")" << endl; break; } os << " Packed? : " << TF_STRING(sbuf->packed()) << endl; os << " Empty? : " << TF_STRING(sbuf->isFull()) << endl; os << " Full? : " << TF_STRING(sbuf->isEmpty()) << endl; os << " Free? : " << TF_STRING(sbuf->isFree()) << endl; Lng32 numtuppdescs = sbuf->getTotalTuppDescs(); os << " Total Tupp Descs : " << numtuppdescs << endl; os << " Processed Tupp Descs : " << sbuf->getProcessedTuppDescs() << endl; #ifdef SQL_BUFFER_SIGNATURE char csig[100]; convertInt64ToAscii(sbuf->getSignature(), csig); os << " Signature : " << csig << endl; #endif tupp_descriptor *td; char *ctupp; ControlInfo *ci; for (Lng32 i = 1; i <= numtuppdescs; i++) { td = sbuf->getTuppDescriptor(i); if (td == NULL) { break; } ctupp = td->getTupleAddress(); if (td->isDataTuple()) { ServerDebug(""); ServerDebug("Data Tuple:"); os << " Tupp(" << i << ") Ref Count : " << td->getReferenceCount() << endl; os << " Tupp(" << i << ") Allocated Size: " << td->getAllocatedSize() << endl; dumpBuffer((unsigned char *)ctupp, td->getAllocatedSize()); } else if (td->isStatsTuple()) { ServerDebug(""); ServerDebug("Stats Tuple:"); os << " Tupp(" << i << ") Ref Count : " << td->getReferenceCount() << endl; os << " Tupp(" << i << ") Allocated Size: " << td->getAllocatedSize() << endl; } else if (td->isDiagsTuple()) { ServerDebug(""); ServerDebug("Diags Tuple:"); os << " Tupp(" << i << ") Ref Count : " << td->getReferenceCount() << endl; os << " Tupp(" << i << ") Allocated Size: " << td->getAllocatedSize() << endl; } else if (td->isControlTuple()) { ServerDebug(""); ServerDebug("Control Tuple:"); os << " Tupp(" << i << ") Ref Count : " << td->getReferenceCount() << endl; os << " Tupp(" << i << ") Allocated Size: " << td->getAllocatedSize() << endl; ci = (ControlInfo *)td->getTupleAddress(); up_state us = ci->getUpState(); down_state ds = ci->getDownState(); os << " Tupp(" << i << ") UpState : " << endl; os << " Tupp(" << i << ") Parent Index : " << us.parentIndex << endl; os << " Tupp(" << i << ") Down Index : " << us.downIndex << endl; switch (us.status) { case ex_queue::Q_NO_DATA: { os << " Tupp(" << i << ") Status : Q_NO_DATA" << endl; break; } case ex_queue::Q_OK_MMORE: { os << " Tupp(" << i << ") Status : Q_OK_MMORE" << endl; break; } case ex_queue::Q_SQLERROR: { os << " Tupp(" << i << ") Status : Q_SQLERROR" << endl; break; } case ex_queue::Q_INVALID: { os << " Tupp(" << i<< ") Status : Q_INVALID" << endl; break; } case ex_queue::Q_GET_DONE: { os << " Tupp(" << i << ") Status : Q_GET_DONE" << endl; break; } default: { os << " Tupp(" << i << ") Request : Unknown (" << us.status << ")" << endl; break; } } os << " Tupp(" << i << ") Match Nbr : " << us.getMatchNo() << endl; os << " Tupp(" << i << ") DownState : " << endl; switch (ds.request) { case ex_queue::GET_N: { os << " Tupp(" << i << ") Request : GET_N" << endl; break; } case ex_queue::GET_ALL: { os << " Tupp(" << i << ") Request : GET_ALL" << endl; break; } case ex_queue::GET_NOMORE: { os << " Tupp(" << i << ") Request : GET_NOMORE" << endl; break; } case ex_queue::GET_EMPTY: { os << " Tupp(" << i << ") Request : GET_EMPTY" << endl; break; } case ex_queue::GET_EOD: { os << " Tupp(" << i << ") Request : GET_EOD" << endl; break; } case ex_queue::GET_NEXT_N: { os << " Tupp(" << i << ") Request : GET_NEXT_N" << endl; break; } case ex_queue::GET_NEXT_N_MAYBE_WAIT: { os << " Tupp(" << i << ") Request : GET_NEXT_N_MAYBE_WAIT" << endl; break; } case ex_queue::GET_NEXT_0_MAYBE_WAIT: { os << " Tupp(" << i << ") Request : GET_NEXT_0_MAYBE_WAIT" << endl; break; } default: { os << " Tupp(" << i << ") Request : Unknown (" << ds.request << ")" << endl; break; } } os << " Tupp(" << i << ") Request : " << ds.request << endl; os << " Tupp(" << i << ") Request Value : " << ds.requestValue << endl; os << " Tupp(" << i << ") Nbr Get Nexts : " << ds.numGetNextsIssued << endl; os << " Tupp(" << i << ") Parent Index : " << ds.parentIndex << endl; os << " Tupp(" << i << ") Buff Seq Nbr : " << ci->getBufferSequenceNumber() << endl; os << " Tupp(" << i << ") Diags Area? : " << TF_STRING(ci->getIsDiagsAreaPresent()) << endl; os << " Tupp(" << i << ") Ext Diags Area? : " << TF_STRING(ci->getIsExtDiagsAreaPresent()) << endl; os << " Tupp(" << i << ") Data Row? : " << TF_STRING(ci->getIsDataRowPresent()) << endl; os << " Tupp(" << i << ") Stats Area? : " << TF_STRING(ci->getIsStatsAreaPresent()) << endl; os << " Tupp(" << i << ") ExtStats Area? : " << TF_STRING(ci->getIsExtStatsAreaPresent()) << endl; } // if (td->isControlTuple()) else { // some other type of tuple... ServerDebug(""); ServerDebug("Unknown Tuple:"); os << " Tupp(" << i << ") Ref Count : " << td->getReferenceCount() << endl; os << " Tupp(" << i << ") Allocated Size: " << td->getAllocatedSize() << endl; } } // for (long i = 1; i <= numtuppdescs; i++) os << endl; } // displaySqlBuffer
void dumpDiagnostics (ComDiagsArea *diags, Lng32 indent) { ComCondition *cc; Lng32 ii; Lng32 nbrW, nbrE, nbrA; Lng32 indmax; if (indent > 99) { indmax = 99; } else { indmax = indent; } char ind[100]; Lng32 indIdx = 0; for (indIdx = 0; indIdx < indmax; indIdx++) ind[indIdx] = ' '; ind[indIdx] = '\0'; nbrW = diags->getNumber(DgSqlCode::WARNING_); nbrE = diags->getNumber(DgSqlCode::ERROR_); nbrA = diags->getNumber(); // errors followed by warnings... ServerDebug(" "); ServerDebug("%sContents of Diagnostics Area:", ind ); ServerDebug("%s-----------------------------", ind ); ServerDebug("%sMain Error : %ld", ind, (Lng32) diags->mainSQLCODE()); ServerDebug("%sNumber : %ld", ind, (Lng32) diags->getNumber()); ServerDebug("%sAre More? : %s", ind, (diags->areMore() ? "TRUE" : "FALSE")); ServerDebug("%sRow Count : %ld", ind, (Lng32) diags->getRowCount()); ServerDebug("%sCost : %le", ind, (double) diags->getCost()); ServerDebug("%sAvg Stream Wait Time : %ld", ind, (Lng32) diags->getAvgStreamWaitTime()); ServerDebug("%sLength Limit : %ld", ind, (Lng32) diags->getLengthLimit()); ServerDebug("%sSQL Function : %ld", ind, (Lng32) diags->getFunction()); ServerDebug("%sSQL Function Name : %s", ind, diags->getFunctionName()); ServerDebug("%sNbr Warnings : %ld", ind, (Lng32) nbrW); ServerDebug("%sNbr Errors : %ld", ind, (Lng32) nbrE); for (ii=1; ii <= nbrW; ii++) { cc = diags->getWarningEntry(ii); ServerDebug("%sWarning(%ld) :", ind, (Lng32) ii); dumpComCondition(cc, ind); } for (ii=1; ii <= nbrE; ii++) { cc = diags->getErrorEntry(ii); ServerDebug("%sError(%ld) :", ind, (Lng32) ii); dumpComCondition(cc, ind); } ServerDebug(" "); return; // errors and warnings in order added #pragma nowarn(220) // warning elimination for (ii=1; ii <= nbrA; ii++) #pragma warn(220) // warning elimination { ServerDebug("%sErrors/Warnings(%ld) :", ind, (Lng32) ii); dumpComCondition(cc, ind); } } // dumpDiagnostics
void dumpComCondition(ComCondition *cc, char *ind) { //ServerDebug("%s Class Origin : %s", ind, cc->getClassOrigin()); //ServerDebug("%s Sub Class Origin : %s", ind, cc->getSubClassOrigin()); //ServerDebug("%s Message : %s", ind, cc->getMessageText()); //ServerDebug("%s Message Length : %ld", ind, // (long) cc->getMessageLength()); ServerDebug("%s Condition Nbr : %ld", ind, (Lng32) cc->getConditionNumber()); ServerDebug("%s SQL Code : %ld", ind, (Lng32) cc->getSQLCODE()); ServerDebug("%s Server Name : %s", ind, cc->getServerName()); ServerDebug("%s Connection Name : %s", ind, cc->getConnectionName()); ServerDebug("%s Constraint Name : %s", ind, cc->getConstraintName()); ServerDebug("%s Constraint Catalog : %s", ind, cc->getConstraintCatalog()); ServerDebug("%s Constraint Schema : %s", ind, cc->getConstraintSchema()); ServerDebug("%s Catalog Name : %s", ind, cc->getCatalogName()); ServerDebug("%s Schema Name : %s", ind, cc->getSchemaName()); ServerDebug("%s Table Name : %s", ind, cc->getTableName()); ServerDebug("%s Column Name : %s", ind, cc->getColumnName()); ServerDebug("%s Cursor Name : ", ind, cc->getSqlID()); ServerDebug("%s Row Number : %ld", ind, (Lng32) cc->getRowNumber()); for (Int32 jj=0; jj<ComCondition::NumOptionalParms;jj++) { if (cc->getOptionalString(jj) != NULL) { ServerDebug("%s OptionalString(%ld) : %s", ind, (Lng32) jj, cc->getOptionalString(jj)); } if (cc->getOptionalInteger(jj) != ComDiags_UnInitialized_Int) { ServerDebug("%s OptionalInteger(%ld): %ld", ind, (Lng32) jj, (Lng32) cc->getOptionalInteger(jj)); } } } // dumpComCondition...
void dumpBuffer(unsigned char *buffer, size_t len) { if (buffer == NULL) { return; } // // We will print the buffer 16 characters at a time. For each group // of 16 characters will we build two strings. One we call the "hex" // string and the other the "ascii" string. They will be formatted // as follows: // // hex: "<hex pair> <hex pair> ..." // ascii: "<ascii value><ascii value>..." // // where each <hex pair> is a 4-character hex representation of // 2-bytes and each <ascii value> is 1 character. // const Int32 CHARS_PER_LINE = 16; const Int32 ASCII_BUF_LEN = CHARS_PER_LINE + 1; const Int32 HEX_BUF_LEN = (2 * CHARS_PER_LINE) // 2 hex characters per byte of input + (CHARS_PER_LINE / 2) // one space between each <hex pair> + 1; // null terminator // // The 100-byte pads in the following two buffers are only used as // safeguards to prevent corrupting the stack. The code should work // without the padding. // char hexBuf[HEX_BUF_LEN + 100]; char asciiBuf[ASCII_BUF_LEN + 100]; size_t i, j, hexOffset, asciiOffset; size_t startingOffset; Int32 nCharsWritten; // // This message will be used for buffer overflow assertion failures // const char *msg = "Buffer overflow in dumpBuffer() routine"; i = 0; while (i < len) { // // Initialize the two buffers with blank padding and null // terminators // memset(hexBuf, ' ', HEX_BUF_LEN); memset(asciiBuf, ' ', ASCII_BUF_LEN); hexBuf[HEX_BUF_LEN - 1] = '\0'; asciiBuf[ASCII_BUF_LEN - 1] = '\0'; hexOffset = 0; asciiOffset = 0; startingOffset = i; // // Inside the following for loop hexOffset should be incremented // by 2 or 3 and asciiOffset incremented by 1. // for (j = 0; j < CHARS_PER_LINE && i < len; j++, i++) { // // Write a 2-character hex value to the hex buffer. The %X // format expects an int value. // nCharsWritten = sprintf(&hexBuf[hexOffset], "%02X", (Int32) buffer[i]); UDR_ASSERT(nCharsWritten == 2, msg); hexOffset += 2; // // Add a space to the hex buffer following each pair of bytes // if (j % 2 == 1) { hexBuf[hexOffset++] = ' '; } // // Write one character to the ascii buffer // char c; if (!isprint(buffer[i])) { c = '.'; } else { c = buffer[i]; } asciiBuf[asciiOffset++] = c; } // for (j = 0; j < CHARSPERLINE && i < len; j++, i++) UDR_ASSERT(hexOffset < HEX_BUF_LEN, msg); UDR_ASSERT(asciiOffset < ASCII_BUF_LEN, msg); UDR_ASSERT(hexBuf[HEX_BUF_LEN - 1] == '\0', msg); UDR_ASSERT(asciiBuf[ASCII_BUF_LEN - 1] == '\0', msg); ServerDebug("%08X %-*s | %s", (Int32) startingOffset, (Int32) (HEX_BUF_LEN - 1), hexBuf, asciiBuf); } // while (i < len) ServerDebug(""); } // dumpBuffer
void processALoadMessage(UdrGlobals *UdrGlob, UdrServerReplyStream &msgStream, UdrLoadMsg &request, IpcEnvironment &env) { const char *moduleName = "processALoadMessage"; char errorText[MAXERRTEXT]; ComDiagsArea *diags = ComDiagsArea::allocate(UdrGlob->getIpcHeap()); doMessageBox(UdrGlob, TRACE_SHOW_DIALOGS, UdrGlob->showLoad_, moduleName); NABoolean showLoadLogic = (UdrGlob->verbose_ && UdrGlob->traceLevel_ >= TRACE_IPMS && UdrGlob->showLoad_); if (showLoadLogic) { ServerDebug("[UdrServ (%s)] Processing load request", moduleName); } // UDR_LOAD message always comes with transaction and they are out // side Enter Tx and Exit Tx pair. Make sure we are under correct // transaction. msgStream.activateCurrentMsgTransaction(); // // Check to see if the incoming UDR handle has already been seen // NABoolean handleAlreadyExists = FALSE; SPInfo *sp = UdrGlob->getSPList()->spFind(request.getHandle()); if (sp) { handleAlreadyExists = TRUE; if (showLoadLogic) { ServerDebug(" Duplicate handle arrived"); ServerDebug(" SPInfoState is %s", sp->getSPInfoStateString()); } if (sp->getSPInfoState() != SPInfo::UNLOADING) { // // An SPInfo exists but it is not one of the token instances to // represent an out-of-sequence LOAD/UNLOAD. This is an internal // error. Something has been botched in the message protocol. // char buf[100]; convertInt64ToAscii(request.getHandle(), buf); *diags << DgSqlCode(-UDR_ERR_DUPLICATE_LOADS); *diags << DgString0(buf); } else { // The LOAD/UNLOAD requests for this handle arrived // out-of-sequence. Nothing to do at this point. An empty reply // will be generated later in this function. } } if (!handleAlreadyExists) { if (!UdrHandleIsValid(request.getHandle())) { *diags << DgSqlCode(-UDR_ERR_MISSING_UDRHANDLE); *diags << DgString0("Load Message"); } else { // // First process the metadata in the LOAD requests and then // contact Language Manager to load the SP. // sp = processLoadParameters(UdrGlob, request, *diags); if (showLoadLogic) { ServerDebug("[UdrServ (%s)] About to call LM::getRoutine", moduleName); } if (sp == NULL) { *diags << DgSqlCode(-UDR_ERR_UNABLE_TO_ALLOCATE_MEMORY); *diags << DgString0("SPInfo"); } else { UdrGlob->setCurrSP(sp); LmRoutine *lmRoutine; LmResult lmResult; LmLanguageManager *lm = UdrGlob->getOrCreateLM(lmResult, sp->getLanguage(), diags); LmHandle emitRowFuncPtr; if (sp->getParamStyle() == COM_STYLE_CPP_OBJ) emitRowFuncPtr = (LmHandle)&SpInfoEmitRowCpp; else emitRowFuncPtr = (LmHandle)&SpInfoEmitRow; if (lm) { if (sp->getParamStyle() == COM_STYLE_JAVA_OBJ || sp->getParamStyle() == COM_STYLE_CPP_OBJ) { lmResult = lm->getObjRoutine( request.getUDRSerInvocationInfo(), request.getUDRSerInvocationInfoLen(), request.getUDRSerPlanInfo(), request.getUDRSerPlanInfoLen(), sp->getLanguage(), sp->getParamStyle(), sp->getExternalName(), sp->getContainerName(), sp->getExternalPathName(), sp->getLibrarySqlName(), &lmRoutine, diags); if (lmRoutine) { LmRoutineCppObj *objRoutine = static_cast<LmRoutineCppObj *>(lmRoutine); if (sp->getParamStyle() == COM_STYLE_CPP_OBJ) // set function pointers for functions provided // by tdm_udrserv objRoutine->setFunctionPtrs(SpInfoGetNextRow, SpInfoEmitRowCpp); // add items to the UDRInvocationInfo that are not // known at compile time (total # of instances is // kind of known, but we want to give the executor a // chance to change it) lmRoutine->setRuntimeInfo(request.getParentQid(), request.getNumInstances(), request.getInstanceNum()); #ifndef NDEBUG int debugLoop = 2; if (objRoutine->getInvocationInfo()->getDebugFlags() & tmudr::UDRInvocationInfo::DEBUG_LOAD_MSG_LOOP) debugLoop = 1; // go into a loop to allow the user to attach a debugger, // if requested, set debugLoop = 2 in the debugger to get out while (debugLoop < 2) debugLoop = 1-debugLoop; #endif } } else lmResult = lm->getRoutine(sp->getNumParameters(), sp->getLmParameters(), sp->getNumTables(), sp->getLmTables(), sp->getReturnValue(), sp->getParamStyle(), sp->getTransactionAttrs(), sp->getSQLAccessMode(), sp->getParentQid(), sp->getRequestRowSize(), sp->getReplyRowSize(), sp->getSqlName(), sp->getExternalName(), sp->getRoutineSig(), sp->getContainerName(), sp->getExternalPathName(), sp->getLibrarySqlName(), UdrGlob->getCurrentUserName(), UdrGlob->getSessionUserName(), sp->getExternalSecurity(), sp->getRoutineOwnerId(), &lmRoutine, (LmHandle)&SpInfoGetNextRow, emitRowFuncPtr, sp->getMaxNumResultSets(), diags); } if (lmResult == LM_OK) { if (lmRoutine == NULL) { *diags << DgSqlCode(-UDR_ERR_MISSING_LMROUTINE); *diags << DgString0("error: returned a null LM handle"); *diags << DgInt1((Int32)0); } else { sp->setLMHandle(lmRoutine); // Retrieve any optional data from UdrLoadMsg. copyRoutineOptionalData(request, sp); reportLoadResults(UdrGlob, sp, lmRoutine); sp->setSPInfoState(SPInfo::LOADED); } } // lmResult == LM_OK if (showLoadLogic) { if (lmResult == LM_OK) { sprintf(errorText, "[UdrServ (%.30s)] LM::getRoutine was successful.", moduleName); } else { sprintf(errorText, "[UdrServ (%.30s)] LM::getRoutine resulted in error.", moduleName); } ServerDebug(errorText); doMessageBox(UdrGlob, TRACE_SHOW_DIALOGS, UdrGlob->showMain_, errorText); } if (sp && !(sp->isLoaded())) { sp->setSPInfoState(SPInfo::LOAD_FAILED); } } // if (sp == NULL) else ... } // if (handle is not valid) else ... } // !handleAlreadyExists // build a reply and send it msgStream.clearAllObjects(); UdrLoadReply *reply = new (UdrGlob->getIpcHeap()) UdrLoadReply(UdrGlob->getIpcHeap()); if (reply == NULL) { // no reply buffer build... controlErrorReply(UdrGlob, msgStream, UDR_ERR_MESSAGE_PROCESSING, INVOKE_ERR_NO_REPLY_BUFFER, NULL); return; } // Only return a valid UDR Handle if diagnostics are not present and // no LM errors occurred. We also return a valid handle if this LOAD // arrived out-of-sequence after the UNLOAD and no diagnostics have // been generated yet. if (diags && diags->getNumber() > 0) { reply->setHandle(INVALID_UDR_HANDLE); } else if (sp) { if (sp->isLoaded() || handleAlreadyExists) { reply->setHandle(sp->getUdrHandle()); } else { reply->setHandle(INVALID_UDR_HANDLE); } } msgStream << *reply; if (diags && diags->getNumber() > 0) { msgStream << *diags; UdrGlob->numErrUDR_++; UdrGlob->numErrSP_++; UdrGlob->numErrLoadSP_++; if (showLoadLogic) dumpDiagnostics(diags, 2); } if (showLoadLogic) { ServerDebug("[UdrServ (%s)] About to send LOAD reply", moduleName); } #ifdef NA_DEBUG_C_RUNTIME if (UdrGlob && UdrGlob->getJavaLM()) { sleepIfPropertySet(*(UdrGlob->getJavaLM()), "MXUDR_LOAD_DELAY", diags); } #endif // NA_DEBUG_C_RUNTIME sendControlReply(UdrGlob, msgStream, sp); if (diags) { diags->decrRefCount(); } reply->decrRefCount(); } // processALoadMessage
// LCOV_EXCL_START void displayLoadParameters(UdrLoadMsg &request) { ServerDebug(""); ServerDebug("UDR load parameters:"); ServerDebug(" UDR handle : " INT64_SPEC , request.getHandle()); ServerDebug(" sql name : %s", request.getSqlName()); ServerDebug(" routine name : %s", request.getRoutineName()); ServerDebug(" routine signature : %s", request.getSignature()); ServerDebug(" container name : %s", request.getContainerName()); ServerDebug(" external path name : %s", request.getExternalPath()); ServerDebug(" library SQL name : %s", request.getLibrarySqlName()); ServerDebug(" parent QID : %s", request.getParentQid()); const char *transString; switch (request.getTransactionAttrs() ) { case COM_NO_TRANSACTION_REQUIRED: transString = "NO TRANSACTION REQUIRED"; break; case COM_TRANSACTION_REQUIRED: transString = "TRANSACTION REQUIRED"; break; default: transString = "*** UNKNOWN ***"; break; } ServerDebug(" transaction required : %s", transString); const char *modeString; switch (request.getSqlAccessMode() ) { case COM_NO_SQL: modeString = "NO SQL"; break; case COM_CONTAINS_SQL: modeString = "CONTAINS SQL"; break; case COM_READS_SQL: modeString = "READS SQL DATA"; break; case COM_MODIFIES_SQL: modeString = "MODIFIES SQL DATA"; break; default: modeString = "*** UNKNOWN ***"; break; } ServerDebug(" sql access mode : %s", modeString); const char *language; switch (request.getLanguage()) { case COM_LANGUAGE_JAVA: language = "Java"; break; case COM_LANGUAGE_C: language = "C"; break; case COM_LANGUAGE_CPP: language = "C++"; break; case COM_LANGUAGE_SQL: language = "SQL"; break; default: language = "*** UNKNOWN ***"; break; } ServerDebug(" language : %s", language); const char *externalSecurity; switch (request.getExternalSecurity()) { case COM_ROUTINE_EXTERNAL_SECURITY_INVOKER: externalSecurity = "EXTERNAL SECURITY INVOKER"; break; case COM_ROUTINE_EXTERNAL_SECURITY_DEFINER: externalSecurity = "EXTERNAL SECURITY DEFINER"; break; default: externalSecurity = "*** UNKNOWN ***"; break; } ServerDebug(" externalSecurity : %s", externalSecurity); ServerDebug(" routine Owner Id : %d", (Int32) request.getRoutineOwnerId()); ServerDebug(" max result sets : %d", (Int32) request.getMaxResultSets()); ServerDebug(" num params : %d", (Int32) request.getNumParameters()); ServerDebug(" num in values : %d", (Int32) request.getNumInValues()); ServerDebug(" num out values : %d", (Int32) request.getNumOutValues()); ServerDebug(" udr flags : %d", (Int32) request.getUdrFlags()); if (request.isIsolate()) ServerDebug(" isolate : TRUE"); else ServerDebug(" isolate : FALSE"); if (request.isCallOnNull()) ServerDebug(" call on NULL : TRUE"); else ServerDebug(" call on NULL : FALSE"); if (request.isExtraCall()) ServerDebug(" extra call : TRUE"); else ServerDebug(" extra call : FALSE"); if (request.isDeterministic()) ServerDebug(" deterministic : TRUE"); else ServerDebug(" deterministic : FALSE"); ServerDebug(""); } // displayLoadParameters
SPInfo *processLoadParameters(UdrGlobals *UdrGlob, UdrLoadMsg &request, ComDiagsArea &d) { const char *moduleName = "processLoadParameters"; Lng32 oldDiags = 0; Lng32 newDiags = 0; doMessageBox(UdrGlob, TRACE_SHOW_DIALOGS, UdrGlob->showLoad_, moduleName); // check for test mode processing... SPInfo *sp = NULL; int numRetries = 0; // process message parameters... if (UdrGlob->traceLevel_ >= TRACE_DETAILS && UdrGlob->showLoad_) { displayLoadParameters(request); } doMessageBox(UdrGlob, TRACE_SHOW_DIALOGS, UdrGlob->showLoad_, "create SPInfo"); oldDiags = d.getNumber(); while (sp == NULL && numRetries < 1) { sp = new (UdrGlob->getUdrHeap()) SPInfo(UdrGlob, UdrGlob->getUdrHeap(), request.getHandle(), (char *)request.getSqlName(), (char *)request.getRoutineName(), (char *)request.getSignature(), (char *)request.getContainerName(), (char *)request.getExternalPath(), (char *)request.getLibrarySqlName(), request.getNumParameters(), request.getNumInValues(), request.getNumOutValues(), request.getMaxResultSets(), request.getTransactionAttrs(), request.getSqlAccessMode(), request.getLanguage(), request.getParamStyle(), request.isIsolate(), request.isCallOnNull(), request.isExtraCall(), request.isDeterministic(), request.getExternalSecurity(), request.getRoutineOwnerId(), request.getInBufferSize(), request.getOutBufferSize(), request.getInputRowSize(), request.getOutputRowSize(), /* ComDiagsArea */ d, (char *)request.getParentQid()); if (sp == NULL) { // memory problem UdrGlob->getSPList()->releaseOldestSPJ(/* ComDiagsArea */ d); numRetries++; } } if (sp == NULL) { return NULL; } newDiags = d.getNumber(); if (oldDiags != newDiags) { // diagnostics generated in ctor for SPInfo // something bad has happened. Bail out. delete sp; return NULL; } // Process IN/INOUT parameters ComUInt32 i; for (i = 0; i < sp->getNumInParameters(); i++) { UdrParameterInfo &pi = (UdrParameterInfo &)request.getInParam(i); // Copy information from the UdrParameterInfo into the spinfo. The // spinfo will initialize an LmParameter instance for this // parameter. sp->setInParam(i, pi); } // Process OUT/INOUT parameters for (ComUInt32 j = 0; j < sp->getNumOutParameters(); j++) { UdrParameterInfo &po = (UdrParameterInfo &)request.getOutParam(j); // Copy information from the UdrParameterInfo into the spinfo. The // spinfo will initialize an LmParameter instance for this // parameter. Note for INOUT parameters, the LmParameter will not // be completely re-initialized. It was partially initialized in // the loop above for input parameters. This setOutParam call // completes the LmParameter initialization. sp->setOutParam(j, po); } // Process table input info if any if(sp->getParamStyle() == COM_STYLE_SQLROW_TM || sp->getParamStyle() == COM_STYLE_CPP_OBJ || sp->getParamStyle() == COM_STYLE_JAVA_OBJ) { sp->setNumTableInfo(request.getNumInputTables()); sp->setTableInputInfo(request.getInputTables()); } if (UdrGlob->verbose_ && UdrGlob->traceLevel_ >= TRACE_DETAILS && UdrGlob->showLoad_) { sp->displaySPInfo(2); } if (UdrGlob->verbose_ && UdrGlob->traceLevel_ >= TRACE_DATA_AREAS && UdrGlob->showLoad_) { ServerDebug(" LmParameter array:"); for (ComUInt32 i = 0; i < sp->getNumParameters(); i++) { dumpLmParameter(sp->getLmParameter(i), i, " "); } } if (UdrGlob->verbose_ && UdrGlob->traceLevel_ >= TRACE_DATA_AREAS && UdrGlob->showLoad_) ServerDebug(""); return sp; } // processLoadParameters