trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anoopsharma00 <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #684: [TRAFODION-1676] rework, fix executor...
Date Thu, 01 Sep 2016 20:11:44 GMT
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.



---
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.
---

Mime
View raw message