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

DECIMAL accepts out of range DEFAULT values

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5(EOL), 10.0(EOL), 10.1(EOL)
    • 10.1.15
    • OTHER
    • None

    Description

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 10000.1);

      correctly returns:

      +---------+------+--------------------------------------------+
      | Level   | Code | Message                                    |
      +---------+------+--------------------------------------------+
      | Warning | 1264 | Out of range value for column 'a' at row 1 |
      | Error   | 1067 | Invalid default value for 'a'              |
      +---------+------+--------------------------------------------+

      A similar script with a quoted default value:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '10000.1');

      Does not produce an error.

      The default value is adjusted to the data type range:

      SHOW CREATE TABLE t1; +-------+---------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                |
      +-------+---------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `a` decimal(2,1) DEFAULT '9.9'
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+---------------------------------------------------------------------------------------------+

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.