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

ALTER to ENUM from INT,DOUBLE vs DECIMAL behave differently

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.5, 10.0, 10.1, 10.2
    • 10.2
    • OTHER
    • None

    Description

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (
        i INT,
        f DOUBLE,
        d DECIMAL(5,0)
      ) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (256,256,256);
      SELECT * FROM t1;

      returns

      +------+------+------+
      | i    | f    | d    |
      +------+------+------+
      |  256 |  256 |  256 |
      +------+------+------+

      i.e. three numbers with equal values.
      Now if I ALTER all three fields to ENUM('256'), the results are different:

      ALTER TABLE t1 MODIFY i ENUM('256'), MODIFY f ENUM('256'), MODIFY d ENUM('256');
      SHOW WARNINGS;
      SELECT * FROM t1;

      returns:

      +---------+------+----------------------------------------+
      | Level   | Code | Message                                |
      +---------+------+----------------------------------------+
      | Warning | 1265 | Data truncated for column 'd' at row 1 |
      +---------+------+----------------------------------------+
      +------+------+------+
      | i    | f    | d    |
      +------+------+------+
      | 256  | 256  |      |
      +------+------+------+
      1 row in set (0.00 sec)

      It's not clear why INT and DOUBLE behave differently comparing to DECIMAL.

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.