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

Analyse wrong and possibly redundant code in Decimal::integralWideRound

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 6.1.1
    • Fix Version/s: 6.3.1
    • Component/s: PrimProc
    • Labels:
      None

      Description

      This code:

                      return Decimal(value,
                                     scale,
                                     precision,
                                     (div.quot < 0) ? div.quot-- : div.quot++);
      

      looks wrong. The increment and decrement happens AFTER the value is passed to the constructor. So the supposed rounding does not actually happen.

      The intended code was most likely as follows:

                      return Decimal(value,
                                     scale,
                                     precision,
                                     (div.quot < 0) ? div.quot - 1 : div.quot + 1);
      

      However, there is a chance that the entire Decimal::integralWideRound() is a dead code.

      This method is used only once in functioncolumn.h in FunctionColumn::getDecimalVal(). This is a snippet:

                  if (scaleMultiplier > 1)
                  {
                      if (scaleDiff > 0)
                      {
                          // WIP MCOL-641 Unconditional overflow check
                          datatypes::MultiplicationNoOverflowCheck mul;
                          mul(decimal.s128Value, scaleMultiplier, decimal.s128Value);
                      }
                      else
                      {
                          decimal = decimal.integralWideRound();
      

      Gagan Goel and Alexander Barkov could not find an SQL script which would make the execution enter the branch calling integralWideRound().

      The code should be further analysed what we should do:

      • either remove the redundant method
      • or fix it to perform rounding correctly

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tntnatbry Gagan Goel
              Reporter:
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:

                  Git Integration