Uploaded image for project: 'MariaDB ColumnStore'
  1. MariaDB ColumnStore
  2. MCOL-4633

Remove duplicate code for DECIMAL to int64_t rounding conversion

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 6.1.1
    • 6.1.1
    • PrimProc
    • None

    Description

      This code in Func_cast_signed::getIntVal():

              case execplan::CalpontSystemCatalog::DECIMAL:
              case execplan::CalpontSystemCatalog::UDECIMAL:
              {
                  IDB_Decimal d = parm[0]->data()->getDecimalVal(row, isNull);
       
                  if (parm[0]->data()->resultType().colWidth == datatypes::MAXDECIMALWIDTH)
                  {
                      return static_cast<int64_t>(d.getPosNegRoundedIntegralPart(4));
                  }
                  else
                  {
                      double dscale = d.scale;
                      int64_t value = d.value / pow(10.0, dscale);
                      int lefto = (d.value - value * pow(10.0, dscale)) / pow(10.0, dscale - 1);
       
                      if ( value >= 0 && lefto > 4 )
                          value++;
       
                      if ( value < 0 && lefto < -4 )
                          value--;
       
                      return value;
                  }
              }
      

      is also repeated in:

      • func_makedate.cpp - 2 times
      • func_maketime.cpp - 3 times
      • func_char.cpp - in Func_char::getStrVal() - not precisely the same, but a very similar code

      In order to make the patch for MCOL-4631 smaller, let's remove this duplicate code as a separate change.
      Note, under terms of MCOL-4633 the new shared code will still use pow(), which will be replaced to a dictionary lookup later - in the final patch for MCOL-4361.

      Attachments

        Issue Links

          Activity

            People

              tntnatbry Gagan Goel (Inactive)
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.