MariaDB Development
  1. MariaDB Development
  2. MDEV-4859

Wrong value and data type of "SELECT MAX(time_column) + 1 FROM t1"

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.0.3, 5.5.32, 5.3.12
    • Fix Version/s: 10.0.7, 5.5.35
    • Labels:
      None
    • Global Rank:
      3424

      Description

      DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1 (t0 TIME);
      INSERT INTO t1 VALUES ('10:10:10'); 
      CREATE TABLE t2 AS SELECT MAX(t0)+1 FROM t1; SELECT * FROM t2; SHOW COLUMNS FROM t2;
      

      produces this output in MariaDB-5.5 and MariaDB-10.0:

      +-------------+
      | MAX(t0)+1   |
      +-------------+
      | 36610000001 |
      +-------------+
      +-----------+---------------+------+-----+---------+-------+
      | Field     | Type          | Null | Key | Default | Extra |
      +-----------+---------------+------+-----+---------+-------+
      | MAX(t0)+1 | decimal(11,0) | YES  |     | NULL    |       |
      +-----------+---------------+------+-----+---------+-------+
      

      36610000001 is a wrong value. The expected value is 101011.

      DECIMAL(11,0) is a wrong type. The expected type is INT(9).

      Note, MariaDB-5.3 returns 11 instead of 36610000001, which is also wrong.

      Similar problem is observed with a DATETIME column.
      This script:

      CREATE TABLE t1 (t0 DATETIME);
      INSERT INTO t1 VALUES ('2001-01-01 10:10:10');
      CREATE TABLE t2 AS SELECT MAX(t0)+1 FROM t1;
      SELECT * FROM t2;
      SHOW COLUMNS FROM t2;
      

      produces this output:

      +-------------------+
      | MAX(t0)+1         |
      +-------------------+
      | 71923630210000001 |
      +-------------------+
      +-----------+---------------+------+-----+---------+-------+
      | Field     | Type          | Null | Key | Default | Extra |
      +-----------+---------------+------+-----+---------+-------+
      | MAX(t0)+1 | decimal(20,0) | YES  |     | NULL    |       |
      +-----------+---------------+------+-----+---------+-------+
      

        Activity

        Hide
        Alexander Barkov added a comment -

        Pushed into 5.3, 5.5, 10.0-base.

        Show
        Alexander Barkov added a comment - Pushed into 5.3, 5.5, 10.0-base.
        Show
        Daniel Bartholomew added a comment - http://bazaar.launchpad.net/~maria-captains/maria/5.5/revision/3977

          People

          • Assignee:
            Alexander Barkov
            Reporter:
            Alexander Barkov
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: