[
https://issues.apache.org/jira/browse/TRAFODION-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14628426#comment-14628426
]
ASF GitHub Bot commented on TRAFODION-37:
-----------------------------------------
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.
> Get "ROLLBACK WORK" and "COMMIT WORK" transactions be prepared when T2 driver
> is establishing connection
> --------------------------------------------------------------------------------------------------------
>
> Key: TRAFODION-37
> URL: https://issues.apache.org/jira/browse/TRAFODION-37
> Project: Apache Trafodion
> Issue Type: Improvement
> Reporter: RuoYu Zuo
> Assignee: RuoYu Zuo
> Labels: features
>
> To make T2 driver supports rowset operation to enhance the performance of
> batch insert and update, two SQL transactions ("commit" to make a succeeded
> execution and "rollback" for failure) are required to be prepared in advance,
> which shall be triggered in executing phase of rowset operation.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)