[
https://issues.apache.org/jira/browse/TRAFODION-1676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15456483#comment-15456483
]
ASF GitHub Bot commented on TRAFODION-1676:
-------------------------------------------
Github user anoopsharma00 commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/684#discussion_r77244637
--- 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 --
we should also try to use the str_* methods from common/str.h, if possible.
At one point, use of local str_* methods was mandatory and code wouldn't
compile
without it, but over time we have started to use of native C string
functions.
In the code listed above, the C functions will be replaced by these str_*
methods:
memset ---> str_pad
strncpy ---> str_cpy_all
sprintf ---> str_sprintf
str_* methods may internally call native C functions but it provides a
common entry point for them.
> 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)