You are viewing a plain text version of this content. The canonical link for it is here.
Posted to codereview@trafodion.apache.org by kakaxi3019 <gi...@git.apache.org> on 2018/07/06 08:53:53 UTC

[GitHub] trafodion pull request #1632: [TRAFODION-3127] tochar enhancement

GitHub user kakaxi3019 opened a pull request:

    https://github.com/apache/trafodion/pull/1632

    [TRAFODION-3127] tochar enhancement

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/kakaxi3019/trafodion trafodion-3127

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/trafodion/pull/1632.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1632
    
----
commit 5c2c5d245d3a63bb368615d173be71fa1ebb1846
Author: kakaxi3019 <ju...@...>
Date:   2018-07-06T08:46:29Z

    tochar enhancement

----


---

[GitHub] trafodion pull request #1632: [TRAFODION-3127] tochar enhancement

Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1632#discussion_r201484661
  
    --- Diff: core/sql/exp/exp_datetime.cpp ---
    @@ -3294,6 +3338,39 @@ convertMonthToStr(Lng32 value, char *&result, UInt32 width)
       result += width;
     }
     
    +static void
    +convertDayOfWeekToStr(Lng32 value, char *&result, NABoolean bAbbreviation, UInt32 width)
    +{
    +  const char* dayofweek[] =
    +  {
    +    "SUNDAY   ",
    +    "MONDAY   ",
    +    "TUESDAY  ",
    +    "WEDNESDAY",
    +    "THURSDAY ",
    +    "FRIDAY   ",
    +    "SATURDAY "
    +  };
    +
    +  const char* dayofweek_abb[] =
    +  {
    +    "SUN",
    +    "MON",
    +    "TUE",
    +    "WED",
    +    "THU",
    +    "FRI",
    +    "SAT"
    +  };
    +
    +  if (bAbbreviation)
    +    strcpy(result, dayofweek_abb[value-1]);
    +  else
    +    strcpy(result, dayofweek[value-1]);
    +  // Update result pointer to point to end of string.
    +  result += width;
    --- End diff --
    
    Why width instead of strlen(result)? (This is probably OK; I'm just curious.)


---

[GitHub] trafodion pull request #1632: [TRAFODION-3127] tochar enhancement

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/trafodion/pull/1632


---

[GitHub] trafodion pull request #1632: [TRAFODION-3127] tochar enhancement

Posted by kakaxi3019 <gi...@git.apache.org>.
Github user kakaxi3019 commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1632#discussion_r201892154
  
    --- Diff: core/sql/exp/exp_datetime.cpp ---
    @@ -3294,6 +3338,39 @@ convertMonthToStr(Lng32 value, char *&result, UInt32 width)
       result += width;
     }
     
    +static void
    +convertDayOfWeekToStr(Lng32 value, char *&result, NABoolean bAbbreviation, UInt32 width)
    +{
    +  const char* dayofweek[] =
    +  {
    +    "SUNDAY   ",
    +    "MONDAY   ",
    +    "TUESDAY  ",
    +    "WEDNESDAY",
    +    "THURSDAY ",
    +    "FRIDAY   ",
    +    "SATURDAY "
    +  };
    +
    +  const char* dayofweek_abb[] =
    +  {
    +    "SUN",
    +    "MON",
    +    "TUE",
    +    "WED",
    +    "THU",
    +    "FRI",
    +    "SAT"
    +  };
    +
    +  if (bAbbreviation)
    +    strcpy(result, dayofweek_abb[value-1]);
    +  else
    +    strcpy(result, dayofweek[value-1]);
    +  // Update result pointer to point to end of string.
    +  result += width;
    --- End diff --
    
    Yes. The string length is always 3 or 9, so i assign the value for width. 
    For example 
    strlen("SUNDAY")=6, but strlen("WEDNESDAY")=9. 
    so the length will always be 9.
    But here "SUNDAY   "(with 3 whitespace), so your suggestion is good, thank you!


---