You are viewing a plain text version of this content. The canonical link for it is here.
Posted to codereview@trafodion.apache.org by ryzuo <gi...@git.apache.org> on 2015/07/15 08:34:53 UTC

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

GitHub user ryzuo opened a pull request:

    https://github.com/apache/incubator-trafodion/pull/28

    [TRAFODION-37] Prepare "ROLLBACK" and "COMMIT WORK" at connection phase for T2 Rowset purpose

    Get "ROLLBACK WORK" and "COMMIT WORK" transaction prepared during the connection phase. This is for Rowsets functionality purpose, either the "COMMIT WORK" Transaction need to be executed to make it work, or "ROLLBACK WORK" shall be executed for failure.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ryzuo/incubator-trafodion t2rsc

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-trafodion/pull/28.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #28
    
----
commit a9f1815ffaeb81122d6b579661962047f065d917
Author: Suresh Subbiah <su...@apache.org>
Date:   2015-06-27T22:08:32Z

    Merge remote branch 'origin/pr/12/head' into mrg_9

commit 0f27bac017e76ab4fa5b8c9dc047f6d8b08c068e
Author: RuoYu Zuo <ru...@hp.com>
Date:   2015-07-06T02:59:34Z

    Merge branch 'master' of https://github.com/apache/incubator-trafodion

commit e9a73a4b4f16c1dd172bf11fe2ae8129410bf78b
Author: RuoYu Zuo <ru...@hp.com>
Date:   2015-07-13T02:34:44Z

    Merge branch 'master' of https://github.com/apache/incubator-trafodion

commit 7428162dacfd5afddfed8e91e1ded60db3153c33
Author: RuoYu Zuo <ru...@hp.com>
Date:   2015-07-15T04:48:28Z

    Merge branch 'master' of https://github.com/apache/incubator-trafodion

commit 1be260eb9eaad40683ebb2d4af1a1e998732af69
Author: RuoYu Zuo <ru...@hp.com>
Date:   2015-07-14T06:10:52Z

    Prepare "ROLLBACK" and "COMMIT WORK" at connection phase
    
    Get "ROLLBACK WORK" and "COMMIT WORK" transaction prepared
    during the connection phase. This is for Rowsets functionality
    purpose, either the "COMMIT WORK" Transactioni need to be executed
    to make it work, or "ROLLBACK WORK" shall be executed for failure.
    
    PS: This includes a few interface changes related to Rowsets logic,
    the rowset implementation code will be committed in another one or
    more commits in the near future. This is step 1 check-in.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by ryzuo <gi...@git.apache.org>.
Github user ryzuo commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34756488
  
    --- Diff: core/conn/jdbc_type2/native/CSrvrConnect.cpp ---
    @@ -268,10 +268,10 @@ void SRVR_CONNECT_HDL::addSrvrStmt(SRVR_STMT_HDL *pSrvrStmt,BOOL internalStmt)
             mapOfInternalSrvrStmt[pSrvrStmt->stmtName]= pSrvrStmt;  // +++ map error
         }
     
    -
         //End of Soln. No.: 10-100202-7923
     
         count++;
    +    //pSrvrStmt->myKey = count;
    --- End diff --
    
    this key will be needed once we use byte buffer to transport between JAVA and native, and it might be used for mapping the statements. I will remove the MFC related code one by one as in this work


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by ryzuo <gi...@git.apache.org>.
Github user ryzuo commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34756383
  
    --- Diff: core/conn/jdbc_type2/native/SrvrKds.cpp ---
    @@ -193,3 +196,43 @@ void kdsCopyToSQLValueSeq(SQLValueList_def *SQLValueList,
     	SQLValueList->_length++;
     	FUNCTION_RETURN_VOID((NULL));
     }
    +void kdsCopySQLErrorExceptionAndRowCount(
    +							odbc_SQLSvc_SQLError *SQLError, 
    +							char *msg_buf,
    +							long sqlcode,
    +							char *sqlState,
    +							long currentRowCount)
    +{
    +	SRVRTRACE_ENTER(FILE_KDS+6);
    +	ERROR_DESC_def *SqlErrorDesc;
    +	size_t	len;
    +
    +	len = strlen(msg_buf);
    +	// Allocate String Buffer
    +	
    +	SqlErrorDesc = (ERROR_DESC_def *)SQLError->errorList._buffer + SQLError->errorList._length;
    +	SqlErrorDesc->errorText = new char[len+1];
    +	if (SqlErrorDesc->errorText == NULL)
    +	{
    +		exit(0);
    --- End diff --
    
    T2 do has no memory allocation failure management, even in its wrapped MEMORY_ALLOC macros, it always simply exit. Memory control enhancement is another thing that we are trying to do. In the past in MXOSRVR, this kind of error is written into event repository, but now we don't have repository enabled yet, so we just keep it this way shortly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34707304
  
    --- Diff: core/conn/jdbc_type2/native/SrvrKds.cpp ---
    @@ -193,3 +196,43 @@ void kdsCopyToSQLValueSeq(SQLValueList_def *SQLValueList,
     	SQLValueList->_length++;
     	FUNCTION_RETURN_VOID((NULL));
     }
    +void kdsCopySQLErrorExceptionAndRowCount(
    +							odbc_SQLSvc_SQLError *SQLError, 
    +							char *msg_buf,
    +							long sqlcode,
    +							char *sqlState,
    +							long currentRowCount)
    +{
    +	SRVRTRACE_ENTER(FILE_KDS+6);
    +	ERROR_DESC_def *SqlErrorDesc;
    +	size_t	len;
    +
    +	len = strlen(msg_buf);
    +	// Allocate String Buffer
    +	
    +	SqlErrorDesc = (ERROR_DESC_def *)SQLError->errorList._buffer + SQLError->errorList._length;
    +	SqlErrorDesc->errorText = new char[len+1];
    +	if (SqlErrorDesc->errorText == NULL)
    +	{
    +		exit(0);
    --- End diff --
    
    Is this what the T2 driver code normally does on a memory allocation failure? How will we know that it was a memory allocation failure?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by ryzuo <gi...@git.apache.org>.
Github user ryzuo commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34756162
  
    --- Diff: core/conn/jdbc_type2/native/SrvrCommon.cpp ---
    @@ -2210,3 +2266,136 @@ void print_outputValueList(SQLValueList_def *oVL, long colCount, const char * fc
         fflush(stdout);
     }
     #endif
    +
    +// 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];
    +    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 *)(WarningOrError+msg_total_len) = total_conds;
    +    msg_total_len += sizeof(total_conds);
    +    *(Int32 *)(WarningOrError+msg_total_len) = rowId;
    +    msg_total_len += sizeof(rowId);
    +    *(Int32 *)(WarningOrError+msg_total_len) = sqlcode;
    +    msg_total_len += sizeof(sqlcode);
    +    time_and_msg_buf_len   = msg_buf_len + TIMEBUFSIZE;
    +    *(Int32 *)(WarningOrError+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(WarningOrError+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(WarningOrError+msg_total_len, tsqlState, sizeof(tsqlState));
    +    msg_total_len += sizeof(tsqlState);
    +
    +    memcpy(MXCSWarningOrError, WarningOrError, sizeof(WarningOrError));
    +    *MXCSWarningOrErrorLength = msg_total_len;
    +    return;
    +}
    +
    +bool isUTF8(const char *str)
    +{
    +    char c;
    --- End diff --
    
    Sorry for this, this is a whole sale copy for testing purpose, will remove it. However, strcpyUTF8() will be needed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by ryzuo <gi...@git.apache.org>.
Github user ryzuo commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34755868
  
    --- Diff: core/conn/jdbc_type2/native/CSrvrConnect.cpp ---
    @@ -457,6 +461,23 @@ SRVR_STMT_HDL *SRVR_CONNECT_HDL::getSrvrStmt(long dialogueId,long stmtId,long
         FUNCTION_RETURN_PTR(NULL,(NULL));
     }
     
    +SRVR_STMT_HDL *SRVR_CONNECT_HDL::getInternalSrvrStmt(long dialogueId, const char* stmtLabel, long *sqlcode)
    +{
    +    FUNCTION_ENTRY("getInternalSrvrStmt",("dialogueId=0x%08x, stmtLabel=0x%08x, sqlcode=0x%08x",
    +                dialogueId,
    +                stmtLabel,
    +                sqlcode));
    +
    +    SRVR_STMT_HDL *pSrvrStmt = NULL;
    +
    +    MapOfInternalSrvrStmt::iterator iterOfStmtId = mapOfInternalSrvrStmt.find(stmtLabel);
    +    if( !(iterOfStmtId == mapOfInternalSrvrStmt.end()) )
    +        pSrvrStmt =(SRVR_STMT_HDL *)iterOfStmtId->second;
    +
    +    if(pSrvrStmt != NULL)
    +        FUNCTION_RETURN_PTR(pSrvrStmt,(NULL));
    +}
    --- End diff --
    
    will fix and submit another commit within this pull request.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34690915
  
    --- Diff: core/conn/jdbc_type2/native/CSrvrConnect.h ---
    @@ -118,6 +128,8 @@ class SRVR_CONNECT_HDL
         MapOfSrvrStmt mapOfSrvrStmt;
         MapOfInternalSrvrStmt mapOfInternalSrvrStmt;
     
    +	//CReplyMsgMap            replyMsgMap;
    --- End diff --
    
    Why are we adding this comment?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-trafodion/pull/28


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by arvind-narain <gi...@git.apache.org>.
Github user arvind-narain commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34718734
  
    --- Diff: core/conn/jdbc_type2/native/CSrvrConnect.cpp ---
    @@ -268,10 +268,10 @@ void SRVR_CONNECT_HDL::addSrvrStmt(SRVR_STMT_HDL *pSrvrStmt,BOOL internalStmt)
             mapOfInternalSrvrStmt[pSrvrStmt->stmtName]= pSrvrStmt;  // +++ map error
         }
     
    -
         //End of Soln. No.: 10-100202-7923
     
         count++;
    +    //pSrvrStmt->myKey = count;
    --- End diff --
    
    Thanks for removing some unneeded comments. Is this particular one needed ? In general if it might be good to clean up the method being touched (remove sol numbers, commented out code if not needed or add more comments, remove any MFC related code etc)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34706740
  
    --- Diff: core/conn/jdbc_type2/native/SrvrCommon.cpp ---
    @@ -2210,3 +2266,136 @@ void print_outputValueList(SQLValueList_def *oVL, long colCount, const char * fc
         fflush(stdout);
     }
     #endif
    +
    +// 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];
    +    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 *)(WarningOrError+msg_total_len) = total_conds;
    +    msg_total_len += sizeof(total_conds);
    +    *(Int32 *)(WarningOrError+msg_total_len) = rowId;
    +    msg_total_len += sizeof(rowId);
    +    *(Int32 *)(WarningOrError+msg_total_len) = sqlcode;
    +    msg_total_len += sizeof(sqlcode);
    +    time_and_msg_buf_len   = msg_buf_len + TIMEBUFSIZE;
    +    *(Int32 *)(WarningOrError+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(WarningOrError+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(WarningOrError+msg_total_len, tsqlState, sizeof(tsqlState));
    +    msg_total_len += sizeof(tsqlState);
    +
    +    memcpy(MXCSWarningOrError, WarningOrError, sizeof(WarningOrError));
    +    *MXCSWarningOrErrorLength = msg_total_len;
    +    return;
    +}
    +
    +bool isUTF8(const char *str)
    +{
    +    char c;
    +    unsigned short byte = 1;
    +    size_t len = strlen(str);
    +
    +    for (size_t i=0; i<len; i++)
    +    {
    +        c = str[i];
    +
    +        if (c >= 0x00 && c < 0x80 && byte == 1) // ascii
    +            continue;
    +        else if (c >= 0x80 && c < 0xc0 && byte > 1) // second, third, or fourth byte of a multi-byte sequence
    +            byte--;
    +        else if (c == 0xc0 || c == 0xc1) // overlong encoding
    +            return false;
    +        else if (c >= 0xc2 && c < 0xe0 && byte == 1) // start of 2-byte sequence
    +            byte = 2;
    +        else if (c >= 0xe0 && c < 0xf0 && byte == 1) // start of 3-byte sequence
    +            byte = 3;
    +        else if (c >= 0xf0 && c < 0xf5 && byte == 1) // start of 4-byte sequence
    +            byte = 4;
    +        else
    +            return false;
    +    }
    +    return true;
    +}
    +
    +char* strcpyUTF8(char *dest, const char *src, size_t destSize, size_t copySize)
    +{
    +    char c;
    +    size_t len;
    +
    +    if (copySize == 0)
    +        len = strlen(src);
    +    else
    +        len = copySize;
    +
    +    if (len >= destSize)
    +        len = destSize-1; // truncation
    +
    +    while (len > 0)
    +    {
    +        c = src[len-1];
    +        if (c < 0x80 || c > 0xbf)
    --- End diff --
    
    I'm not sure these comparisons will work the way you want with signed char.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34705621
  
    --- Diff: core/conn/jdbc_type2/native/SqlInterface.cpp ---
    @@ -4440,3 +4440,45 @@ void CreateModulePlan(long inputParamCount, InputDescInfo *inputDescInfo, char *
     		}
     	}
     }
    +
    +SQLRETURN COMMIT_ROWSET(long dialogueId, bool& bSQLMessageSet, odbc_SQLSvc_SQLError* SQLError, Int32 currentRowCount)
    +{
    +    SQLRETURN retcode;
    +    long      sqlcode;
    +    SQLValueList_def inValueList;
    +    inValueList._buffer = NULL;
    +    inValueList._length = 0;
    +
    +    SRVR_STMT_HDL *CmwSrvrStmt = getInternalSrvrStmt(dialogueId, "STMT_COMMIT_1", &sqlcode);
    +    /* Should process the error here if CmwSrvrStmt is NULL */
    --- End diff --
    
    What's the risk in not having error processing here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by arvind-narain <gi...@git.apache.org>.
Github user arvind-narain commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34718933
  
    --- Diff: core/conn/jdbc_type2/native/CSrvrConnect.cpp ---
    @@ -338,7 +338,10 @@ SRVR_STMT_HDL *SRVR_CONNECT_HDL::createSrvrStmt(
         short   sqlStmtType,
         BOOL    useDefaultDesc,
         BOOL    internalStmt,
    -    long stmtId)
    +    long stmtId,
    +    short sqlQueryType,      // If sqlQueryType indicates it's SPJ statement, then the member variable
    +    Int32  resultSetIndex,   // resultSetIndex and callStmtId of SRVR_STMT_HDL should be initialized
    +    SQLSTMT_ID* callStmtId)  // with these passed in args
     {
         FUNCTION_ENTRY("SRVR_CONNECT_HDL::createSrvrStmt",("..."));
         DEBUG_OUT(DEBUG_LEVEL_ENTRY,("  stmtLabel=%s, sqlcode=0x%08x",
    --- End diff --
    
    Do please add the new parameters -sqlQueryType, resultSetIndex etc.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by ryzuo <gi...@git.apache.org>.
Github user ryzuo commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34756095
  
    --- Diff: core/conn/jdbc_type2/native/SqlInterface.cpp ---
    @@ -4440,3 +4440,45 @@ void CreateModulePlan(long inputParamCount, InputDescInfo *inputDescInfo, char *
     		}
     	}
     }
    +
    +SQLRETURN COMMIT_ROWSET(long dialogueId, bool& bSQLMessageSet, odbc_SQLSvc_SQLError* SQLError, Int32 currentRowCount)
    +{
    +    SQLRETURN retcode;
    +    long      sqlcode;
    +    SQLValueList_def inValueList;
    +    inValueList._buffer = NULL;
    +    inValueList._length = 0;
    +
    +    SRVR_STMT_HDL *CmwSrvrStmt = getInternalSrvrStmt(dialogueId, "STMT_COMMIT_1", &sqlcode);
    +    /* Should process the error here if CmwSrvrStmt is NULL */
    --- End diff --
    
    For now we make sure this statement is prepared during the connection phase, MXOSRVR do it the same way without a NULL validation, I'm not sure has anyone ever met this kind of problem yet. T2 now has no mechanism to process this kind of null statement error. I'm thinking to return the error back to JAVA layer to throw an exception out, it will be included in the new rowset execute() operation code.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34706492
  
    --- Diff: core/conn/jdbc_type2/native/SrvrCommon.cpp ---
    @@ -2210,3 +2266,136 @@ void print_outputValueList(SQLValueList_def *oVL, long colCount, const char * fc
         fflush(stdout);
     }
     #endif
    +
    +// 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];
    +    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 *)(WarningOrError+msg_total_len) = total_conds;
    +    msg_total_len += sizeof(total_conds);
    +    *(Int32 *)(WarningOrError+msg_total_len) = rowId;
    +    msg_total_len += sizeof(rowId);
    +    *(Int32 *)(WarningOrError+msg_total_len) = sqlcode;
    +    msg_total_len += sizeof(sqlcode);
    +    time_and_msg_buf_len   = msg_buf_len + TIMEBUFSIZE;
    +    *(Int32 *)(WarningOrError+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(WarningOrError+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(WarningOrError+msg_total_len, tsqlState, sizeof(tsqlState));
    +    msg_total_len += sizeof(tsqlState);
    +
    +    memcpy(MXCSWarningOrError, WarningOrError, sizeof(WarningOrError));
    +    *MXCSWarningOrErrorLength = msg_total_len;
    +    return;
    +}
    +
    +bool isUTF8(const char *str)
    +{
    +    char c;
    --- End diff --
    
    unsigned char is safer. On some platforms you'll get sign extension when comparing to literals such as 0x80, and the code won't work the way you expect.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-trafodion pull request: [TRAFODION-37] Prepare "ROLLBACK...

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/28#discussion_r34690758
  
    --- Diff: core/conn/jdbc_type2/native/CSrvrConnect.cpp ---
    @@ -457,6 +461,23 @@ SRVR_STMT_HDL *SRVR_CONNECT_HDL::getSrvrStmt(long dialogueId,long stmtId,long
         FUNCTION_RETURN_PTR(NULL,(NULL));
     }
     
    +SRVR_STMT_HDL *SRVR_CONNECT_HDL::getInternalSrvrStmt(long dialogueId, const char* stmtLabel, long *sqlcode)
    +{
    +    FUNCTION_ENTRY("getInternalSrvrStmt",("dialogueId=0x%08x, stmtLabel=0x%08x, sqlcode=0x%08x",
    +                dialogueId,
    +                stmtLabel,
    +                sqlcode));
    +
    +    SRVR_STMT_HDL *pSrvrStmt = NULL;
    +
    +    MapOfInternalSrvrStmt::iterator iterOfStmtId = mapOfInternalSrvrStmt.find(stmtLabel);
    +    if( !(iterOfStmtId == mapOfInternalSrvrStmt.end()) )
    +        pSrvrStmt =(SRVR_STMT_HDL *)iterOfStmtId->second;
    +
    +    if(pSrvrStmt != NULL)
    +        FUNCTION_RETURN_PTR(pSrvrStmt,(NULL));
    +}
    --- End diff --
    
    What happens if pSrvrStmt is NULL? (I don't see a return statement for this case.)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---