[ https://issues.apache.org/jira/browse/TRAFODION-1676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15457053#comment-15457053 ]
ASF GitHub Bot commented on TRAFODION-1676: ------------------------------------------- Github user traflm commented on a diff in the pull request: https://github.com/apache/incubator-trafodion/pull/684#discussion_r77277081 --- 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 -- thanks Hans, Anoop, this is very good guidance, I will use these functions instead of C functions now and in the future. In fact, there are a lot of Trafodion's own underlying libraries, such as C-style string manipulation like above, and C++-style lib like NAString... However, there is no description about them, so it is rather difficult for new Trafodion engineer to use them, I will track down them as much as I learned during the process, and add into wiki page, people can enhance it one by one. Or maybe there is such a reference that I missed. > 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)