[
https://issues.apache.org/jira/browse/TRAFODION-1676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15455921#comment-15455921
]
ASF GitHub Bot commented on TRAFODION-1676:
-------------------------------------------
Github user zellerh commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/684#discussion_r77207795
--- Diff: core/sql/exp/exp_datetime.cpp ---
@@ -92,6 +92,30 @@ copyDatetimeFields(rec_datetime_field startField,
Lng32 dstLen,
NABoolean *roundedDownFlag);
+// Helper function to format extra error message text and report error
+// srcData is not null terminated, so need a buffer copy to build a
C-style string
+//
+static void
+raiseDateConvErrorWithSrcData(int srcLen, ComDiagsArea** diagsArea, char
*srcData, CollHeap *heap)
+{
+ char errstr[MAX_OFFENDING_SOURCE_DATA_DISPLAY_LEN];
+ memset(errstr, 0 , sizeof(errstr) );
+ if(srcLen > MAX_OFFENDING_SOURCE_DATA_DISPLAY_LEN -1 )
+ srcLen = MAX_OFFENDING_SOURCE_DATA_DISPLAY_LEN -1;
+ strncpy(errstr, srcData, srcLen);
+ ExRaiseSqlError(heap, diagsArea,
EXE_CONVERT_DATETIME_ERROR,NULL,NULL,NULL,NULL,errstr);
+}
+
+// Helper function to format extra error message text and report error
+//
+static void
+raiseDateConvErrorWithSrcDataNumeric(ComDiagsArea** diagsArea, long
srcData, CollHeap *heap)
+{
+ char errstr[MAX_OFFENDING_SOURCE_DATA_DISPLAY_LEN];
+ memset(errstr, 0 , sizeof(errstr) );
+ sprintf(errstr,"%ld",srcData);
--- End diff --
Minor comment: I try not to use sprintf anymore and use snprintf instead.
Some static analysis tools flag this type of code as a potential buffer
overrun, even though the length may be long enough.
> support better runtime error message when a SQL function meet fital error
> -------------------------------------------------------------------------
>
> Key: TRAFODION-1676
> URL: https://issues.apache.org/jira/browse/TRAFODION-1676
> Project: Apache Trafodion
> Issue Type: Improvement
> Components: sql-exe
> Reporter: liu ming
> Assignee: liu ming
> Priority: Minor
> Fix For: 2.1-incubating
>
>
> A sql contains some SQL function, for example UPPER(), when the input data of
> UPPER() contains invalid data, UPPER() will fail. In this case, the whole
> query abort, and the error message cannot tell which row has invalid data, so
> it is very hard to fix the problem.
> It will be good to have row id or the real value of the error row in the
> error message to help trouble shooting.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)