Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-3661

LP:482846 - integer math errors with large numbers and no errors or warnings given

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      mysql> select version();
      -----------------------------

      version()

      -----------------------------

      5.1.39-maria-beta-debug-log

      -----------------------------
      1 row in set (0.00 sec)

      mysql> SELECT 4294967296 * 4294967296;
      -------------------------

      4294967296 * 4294967296

      -------------------------

      0

      -------------------------
      1 row in set (0.00 sec)

      mysql> show warnings;
      Empty set (0.00 sec)

      mysql> SELECT 3037000500 * 3037000500;
      -------------------------

      3037000500 * 3037000500

      -------------------------

      -9223372036709301616

      -------------------------
      1 row in set (0.00 sec)

      mysql> show warnings;
      Empty set (0.00 sec)

      mysql> SELECT 4294967296 * 4294967297;
      -------------------------

      4294967296 * 4294967297

      -------------------------

      4294967296

      -------------------------
      1 row in set (0.00 sec)

      mysql> show warnings;
      Empty set (0.00 sec)

      mysql> SELECT 4294967296 * 4294967298;
      -------------------------

      4294967296 * 4294967298

      -------------------------

      8589934592

      -------------------------
      1 row in set (0.00 sec)

      mysql> show warnings;
      Empty set (0.00 sec)

      mysql> SELECT 4294967296.0 * 4294967298.0;
      -----------------------------

      4294967296.0 * 4294967298.0

      -----------------------------

      18446744082299486208.00

      -----------------------------
      1 row in set (0.08 sec)

      mysql> show warnings;
      Empty set (0.00 sec)

      mysql> quit;
      Bye
      archivist@cnc:~/archivist-cnc/archivist-cnc/build/mysql-test$ uname -a
      Linux cnc 2.6.24-16-rtai #1 Tue Sep 30 22:54:33 EEST 2008 i686 GNU/Linux

      adding a .0 to the large number gets it to use float/double maths, the integer maths does not seem to check its range or overflow conditions correctly thus giving incorrect results.

      1. Bug#xxxxx: Reproducible MariaDB server integer math fault
        #
      2. this returns 0 incorrectly it appears to be the left side * 0
        --exec $MYSQL test -e "SELECT 4294967296 * 4294967296\g" 2>&1
        #
      3. this gives an incorrect negative number
        --exec $MYSQL test -e "SELECT 3037000500 * 3037000500\g" 2>&1
        #
      4. this returns 4294967296 the number on the left times 1
        --exec $MYSQL test -e "SELECT 4294967296 * 4294967297\g" 2>&1
        #
      5. this returns 8589934592 the number on the left times 2
        --exec $MYSQL test -e "SELECT 4294967296 * 4294967298\g" 2>&1
        #
      6. this seems to be correct it has cast to a float/double
        --exec $MYSQL test -e "SELECT 4294967296.0 * 4294967298.0;\g" 2>&1

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            monty Michael Widenius added a comment -

            Re: integer math errors with large numbers and no errors or warnings given
            The issue is that you are using integer arithmetic, which is described at:
            http://dev.mysql.com/doc/refman/5.1/en/arithmetic-functions.html

            Not much we can do with this, as we are trying to be compatible with MySQL.

            We should however consider to find a way to create a warning in cases when you get overflow.

            I will create a worklog entry for this.

            Show
            monty Michael Widenius added a comment - Re: integer math errors with large numbers and no errors or warnings given The issue is that you are using integer arithmetic, which is described at: http://dev.mysql.com/doc/refman/5.1/en/arithmetic-functions.html Not much we can do with this, as we are trying to be compatible with MySQL. We should however consider to find a way to create a warning in cases when you get overflow. I will create a worklog entry for this.
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 482846

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 482846

              People

              • Assignee:
                Unassigned
                Reporter:
                archivist archivist
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: