← Back to team overview

maria-developers team mailing list archive

Re: c29706f: MDEV-17286 Decimal field multiplication bug.

 

Hi, Alexey!

On Oct 24, Alexey Botchkov wrote:
> revision-id: c29706f7560148488791acca3c92dde1b188334e (mariadb-5.5.61-32-gc29706f)
> parent(s): e31e697f17f79ffa6913499e7e2d29866f24b475
> committer: Alexey Botchkov
> timestamp: 2018-10-24 01:26:49 +0400
> message:
> 
> MDEV-17286 Decimal field multiplication bug.
> 
> We should clear trailing zeroes in frac part. Otherwise
> that tail is growing quickly and forces unnecessary truncating of
> arguments.

This looks good, thanks.
Please add a test for create select, as discussed.
And fix the bug number in the commit comment.

See one question below.

> @@ -2109,6 +2104,14 @@ int decimal_mul(const decimal_t *from1, const decimal_t *from2, decimal_t *to)
>      for (; d_to_move--; cur_d++, buf1++)
>        *cur_d= *buf1;
>    }
> +
> +  /* Now we have to check for -0.000 case */
> +  if (to->sign && to->intg <= DIG_PER_DEC1 && to->frac == 0 &&
> +      to->buf[0] == 0)

What if both arguments will be zeros, but have intg=DIG_PER_DEC1-1.
Won't the result have more that DIG_PER_DEC1 zeros?

> +  {
> +    /* We got decimal zero */
> +    decimal_make_zero(to);
> +  }
>    return error;
>  }
>  
Regards,
Sergei
Chief Architect MariaDB
and security@xxxxxxxxxxx