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

ERROR_FOR_DIVISION_BY_ZERO not throwing error

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.0.19
    • N/A
    • Documentation
    • None
    • Windows 8.1

    Description

      ERROR_FOR_DIVISION_BY_ZERO doesn't appear to be honored.

      Welcome to the MariaDB monitor.  Commands end with ; or \g.
      Your MariaDB connection id is 1043
      Server version: 10.0.19-MariaDB mariadb.org binary distribution
       
      Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
       
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
       
      MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_mode';
      +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | Variable_name | Value                          |
      +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | sql_mode      | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
      +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.00 sec)
       
      MariaDB [(none)]> SELECT 1/0;
      +------+
      | 1/0  |
      +------+
      | NULL |
      +------+
      1 row in set, 1 warning (0.00 sec)
       
      MariaDB [(none)]> show warnings;
      +---------+------+---------------+
      | Level   | Code | Message       |
      +---------+------+---------------+
      | Warning | 1365 | Division by 0 |
      +---------+------+---------------+
      1 row in set (0.00 sec)

      There is a warning, but according to https://mariadb.com/kb/en/mariadb/sql_mode/ it should "Return a 1365 'Division by 0' error (instead of a warning)"

      Attachments

        Activity

          Sparticuz Kyle McNally created issue -
          Sparticuz Kyle McNally made changes -
          Field Original Value New Value
          Description ERROR_FOR_DIVISION_BY_ZERO doesn't appear to be honored.


          {code:command}
          Welcome to the MariaDB monitor. Commands end with ; or \g.
          Your MariaDB connection id is 1043
          Server version: 10.0.19-MariaDB mariadb.org binary distribution

          Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

          MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_mode';
          +---------------+---------------------------------------------------------------
          --------------------------------------------------------------------------------
          --------------------------+
          | Variable_name | Value

                                    |
          +---------------+---------------------------------------------------------------
          --------------------------------------------------------------------------------
          --------------------------+
          | sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZE
          RO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_US
          ER,NO_ENGINE_SUBSTITUTION |
          +---------------+---------------------------------------------------------------
          --------------------------------------------------------------------------------
          --------------------------+
          1 row in set (0.00 sec)

          MariaDB [(none)]> SELECT 1/0;
          +------+
          | 1/0 |
          +------+
          | NULL |
          +------+
          1 row in set, 1 warning (0.00 sec)
          {code}
          ERROR_FOR_DIVISION_BY_ZERO doesn't appear to be honored.


          {code:none}
          Welcome to the MariaDB monitor. Commands end with ; or \g.
          Your MariaDB connection id is 1043
          Server version: 10.0.19-MariaDB mariadb.org binary distribution

          Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

          MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_mode';
          +---------------+---------------------------------------------------------------
          --------------------------------------------------------------------------------
          --------------------------+
          | Variable_name | Value

                                    |
          +---------------+---------------------------------------------------------------
          --------------------------------------------------------------------------------
          --------------------------+
          | sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZE
          RO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_US
          ER,NO_ENGINE_SUBSTITUTION |
          +---------------+---------------------------------------------------------------
          --------------------------------------------------------------------------------
          --------------------------+
          1 row in set (0.00 sec)

          MariaDB [(none)]> SELECT 1/0;
          +------+
          | 1/0 |
          +------+
          | NULL |
          +------+
          1 row in set, 1 warning (0.00 sec)
          {code}
          Sparticuz Kyle McNally made changes -
          Description ERROR_FOR_DIVISION_BY_ZERO doesn't appear to be honored.


          {code:none}
          Welcome to the MariaDB monitor. Commands end with ; or \g.
          Your MariaDB connection id is 1043
          Server version: 10.0.19-MariaDB mariadb.org binary distribution

          Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

          MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_mode';
          +---------------+---------------------------------------------------------------
          --------------------------------------------------------------------------------
          --------------------------+
          | Variable_name | Value

                                    |
          +---------------+---------------------------------------------------------------
          --------------------------------------------------------------------------------
          --------------------------+
          | sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZE
          RO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_US
          ER,NO_ENGINE_SUBSTITUTION |
          +---------------+---------------------------------------------------------------
          --------------------------------------------------------------------------------
          --------------------------+
          1 row in set (0.00 sec)

          MariaDB [(none)]> SELECT 1/0;
          +------+
          | 1/0 |
          +------+
          | NULL |
          +------+
          1 row in set, 1 warning (0.00 sec)
          {code}
          ERROR_FOR_DIVISION_BY_ZERO doesn't appear to be honored.


          {code:none}
          Welcome to the MariaDB monitor. Commands end with ; or \g.
          Your MariaDB connection id is 1043
          Server version: 10.0.19-MariaDB mariadb.org binary distribution

          Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

          MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_mode';
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          | Variable_name | Value |
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          | sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          1 row in set (0.00 sec)

          MariaDB [(none)]> SELECT 1/0;
          +------+
          | 1/0 |
          +------+
          | NULL |
          +------+
          1 row in set, 1 warning (0.00 sec)
          {code}
          Sparticuz Kyle McNally made changes -
          Summary ERROR_FOR_DIVISION_BY_ZERO ERROR_FOR_DIVISION_BY_ZERO not throwing error
          Sparticuz Kyle McNally made changes -
          Description ERROR_FOR_DIVISION_BY_ZERO doesn't appear to be honored.


          {code:none}
          Welcome to the MariaDB monitor. Commands end with ; or \g.
          Your MariaDB connection id is 1043
          Server version: 10.0.19-MariaDB mariadb.org binary distribution

          Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

          MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_mode';
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          | Variable_name | Value |
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          | sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          1 row in set (0.00 sec)

          MariaDB [(none)]> SELECT 1/0;
          +------+
          | 1/0 |
          +------+
          | NULL |
          +------+
          1 row in set, 1 warning (0.00 sec)
          {code}
          ERROR_FOR_DIVISION_BY_ZERO doesn't appear to be honored.


          {code:none}
          Welcome to the MariaDB monitor. Commands end with ; or \g.
          Your MariaDB connection id is 1043
          Server version: 10.0.19-MariaDB mariadb.org binary distribution

          Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

          MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_mode';
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          | Variable_name | Value |
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          | sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          1 row in set (0.00 sec)

          MariaDB [(none)]> SELECT 1/0;
          +------+
          | 1/0 |
          +------+
          | NULL |
          +------+
          1 row in set, 1 warning (0.00 sec)
          {code}

          There is a warning, but according to https://mariadb.com/kb/en/mariadb/sql_mode/ it should "Return a 1365 'Division by 0' error"
          Sparticuz Kyle McNally made changes -
          Description ERROR_FOR_DIVISION_BY_ZERO doesn't appear to be honored.


          {code:none}
          Welcome to the MariaDB monitor. Commands end with ; or \g.
          Your MariaDB connection id is 1043
          Server version: 10.0.19-MariaDB mariadb.org binary distribution

          Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

          MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_mode';
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          | Variable_name | Value |
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          | sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          1 row in set (0.00 sec)

          MariaDB [(none)]> SELECT 1/0;
          +------+
          | 1/0 |
          +------+
          | NULL |
          +------+
          1 row in set, 1 warning (0.00 sec)
          {code}

          There is a warning, but according to https://mariadb.com/kb/en/mariadb/sql_mode/ it should "Return a 1365 'Division by 0' error"
          ERROR_FOR_DIVISION_BY_ZERO doesn't appear to be honored.


          {code:none}
          Welcome to the MariaDB monitor. Commands end with ; or \g.
          Your MariaDB connection id is 1043
          Server version: 10.0.19-MariaDB mariadb.org binary distribution

          Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

          MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_mode';
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          | Variable_name | Value |
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          | sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
          +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
          1 row in set (0.00 sec)

          MariaDB [(none)]> SELECT 1/0;
          +------+
          | 1/0 |
          +------+
          | NULL |
          +------+
          1 row in set, 1 warning (0.00 sec)

          MariaDB [(none)]> show warnings;
          +---------+------+---------------+
          | Level | Code | Message |
          +---------+------+---------------+
          | Warning | 1365 | Division by 0 |
          +---------+------+---------------+
          1 row in set (0.00 sec)
          {code}

          There is a warning, but according to https://mariadb.com/kb/en/mariadb/sql_mode/ it should "Return a 1365 'Division by 0' error (instead of a warning)"
          serg Sergei Golubchik made changes -
          Assignee Ian Gilfillan [ greenman ]
          serg Sergei Golubchik made changes -
          Component/s Documentation [ 10903 ]
          serg Sergei Golubchik made changes -
          Status Open [ 1 ] Confirmed [ 10101 ]
          serg Sergei Golubchik made changes -
          Fix Version/s N/A [ 14700 ]
          serg Sergei Golubchik made changes -
          Priority Minor [ 4 ] Major [ 3 ]
          greenman Ian Gilfillan added a comment -

          I am not sure what the intended behaviour is - to me it looks like a bug, as you would expect an option called "ERROR_*" to actually return an error, at least in strict mode. I have tested the behaviour on MariaDB 5.5, MySQL 5.6.19 and it works in the same undocumented way as well. The option has also been deprecated in MySQL 5.6. I'll update the documentation to reflect what happens now, but leaving the task open for re-assigning if its seen as a bug rather than intentional.

          greenman Ian Gilfillan added a comment - I am not sure what the intended behaviour is - to me it looks like a bug, as you would expect an option called "ERROR_*" to actually return an error, at least in strict mode. I have tested the behaviour on MariaDB 5.5, MySQL 5.6.19 and it works in the same undocumented way as well. The option has also been deprecated in MySQL 5.6. I'll update the documentation to reflect what happens now, but leaving the task open for re-assigning if its seen as a bug rather than intentional.
          greenman Ian Gilfillan made changes -
          Assignee Ian Gilfillan [ greenman ]
          Sparticuz Kyle McNally added a comment -

          According to this: https://dev.mysql.com/doc/refman/5.6/en/sql-mode.html#sqlmode_error_for_division_by_zero

          It looks like the warning would almost suffice: "If this mode is enabled, division by zero inserts NULL and produces a warning."
          Which is the behavior we see.

          However, "If this mode and strict mode are enabled, division by zero produces an error,..." which was the previously documented outcome.

          Either is fine with me. It doesn't affect my program at all. I was just tightening up my server after switching from MySql and noticed that this mode wasn't the same as the documentation.

          Sparticuz Kyle McNally added a comment - According to this: https://dev.mysql.com/doc/refman/5.6/en/sql-mode.html#sqlmode_error_for_division_by_zero It looks like the warning would almost suffice: "If this mode is enabled, division by zero inserts NULL and produces a warning." Which is the behavior we see. However, "If this mode and strict mode are enabled, division by zero produces an error,..." which was the previously documented outcome. Either is fine with me. It doesn't affect my program at all. I was just tightening up my server after switching from MySql and noticed that this mode wasn't the same as the documentation.
          serg Sergei Golubchik made changes -
          Assignee Ian Gilfillan [ greenman ]
          Resolution Fixed [ 1 ]
          Status Confirmed [ 10101 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 70010 ] MariaDB v4 [ 149272 ]

          People

            greenman Ian Gilfillan
            Sparticuz Kyle McNally
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.