trafodion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Song Hao-Lin" <haolin.s...@esgyn.cn>
Subject RE: One question about the code of mxosrvr
Date Wed, 30 Jan 2019 03:42:41 GMT

Hi
yes, I think it will be nice to make a change.
Haolin

On 29 一月, 2019 01:32 CST, Dave Birdsall <dave.birdsall@esgyn.com> 撰寫:
 Hi,

Did you get an answer to your question?

Dave

-----Original Message-----
From: Song Hao-Lin <haolin.song@esgyn.cn>
Sent: Monday, January 21, 2019 3:19 AM
To: dev@trafodion.apache.org
Subject: One question about the code of mxosrvr


Hi all

I found that the function GETMXCSWARNINGORERROR, which used to set warnings or errors in
mxosrvr, could only record one warning or error during one client request.
If you call the function twice , it will remove the message which is recorded in the first
time(by bzero(WarningOrError,sizeof(WarningOrError))),while errors or warnings from sql engine
could be recorded by SRVR::GETSQLWARNINGORERROR2 no matter how many they are. If I make a
mistake, please let me know.

The function GETMXCSWARNINGORERROR is in the file core/conn/odbc/src/odbc/nsksrvrcore/srvrcommon.cpp.
I want to modify the related code and suggestions are welcome. 


// DO NOT call this function using pSrvrStmt->sqlWarningOrErrorLength and pSrvrStmt->sqlWarningOrError,
// Since the WarningOrError is static and pSrvrStmt->sqlWarningOrError will deallocate
this memory.
extern "C" void GETMXCSWARNINGORERROR(
/* In */ Int32 sqlcode
, /* In */ char *sqlState
, /* In */ char *msg_buf
, /* Out */ Int32 *MXCSWarningOrErrorLength , /* Out */ BYTE *&MXCSWarningOrError) {
    Int32 total_conds = 1;
    Int32 buf_len;
    Int32 curr_cond = 1;
    Int32 msg_buf_len = strlen(msg_buf)+1;
    Int32 time_and_msg_buf_len = 0;
    Int32 msg_total_len = 0;
    Int32 rowId = 0; // use this for rowset recovery.
    char tsqlState[6];
    static BYTE WarningOrError[1024];
    char strNow[TIMEBUFSIZE + 1];
    char* time_and_msg_buf = NULL;
    memset(tsqlState,0,sizeof(tsqlState));
    memcpy(tsqlState,sqlState,sizeof(tsqlState)-1);
    
    bzero(WarningOrError,sizeof(WarningOrError));
    *MXCSWarningOrErrorLength = 0;
    MXCSWarningOrError = WarningOrError; // Size of internally generated message should
be enough
    *(Int32 *)(MXCSWarningOrError+msg_total_len) = total_conds;
    msg_total_len += sizeof(total_conds);
    *(Int32 *)(MXCSWarningOrError+msg_total_len) = rowId;
    msg_total_len += sizeof(rowId);
    *(Int32 *)(MXCSWarningOrError+msg_total_len) = sqlcode;
    msg_total_len += sizeof(sqlcode);
    time_and_msg_buf_len = msg_buf_len + TIMEBUFSIZE;
    *(Int32 *)(MXCSWarningOrError+msg_total_len) = time_and_msg_buf_len;
    msg_total_len += sizeof(time_and_msg_buf_len);
    //Get the timetsamp
    time_and_msg_buf = new char[time_and_msg_buf_len];
    strncpy(time_and_msg_buf, msg_buf, msg_buf_len);
    time_t now = time(NULL);
    bzero(strNow, sizeof(strNow));
    strftime(strNow, sizeof(strNow), " [%Y-%m-%d %H:%M:%S]", localtime(&now));
    strcat(time_and_msg_buf, strNow);
    memcpy(MXCSWarningOrError+msg_total_len, time_and_msg_buf, time_and_msg_buf_len);
    msg_total_len += time_and_msg_buf_len;
    delete time_and_msg_buf;
    memcpy(MXCSWarningOrError+msg_total_len, tsqlState, sizeof(tsqlState));
    msg_total_len += sizeof(tsqlState);
    *MXCSWarningOrErrorLength = msg_total_len;
    return;
}


 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message