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

CREATE..SELECT with DIV creates columns of a wrong data type

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.3
    • Fix Version/s: 10.3, 10.4
    • Component/s: Data types
    • Labels:
      None

      Description

      SET sql_mode='';
      SELECT 1e14 DIV 2 AS c1, '' DIV 2 AS c2;
      CREATE OR REPLACE TABLE t1 AS SELECT 1e14 DIV 2 AS c1, '' DIV 2 AS c2;
      SELECT * FROM t1;
      SHOW CREATE TABLE t1;
      

      +----------------+------+
      | c1             | c2   |
      +----------------+------+
      | 50000000000000 |    0 |
      +----------------+------+
      

      +------------+------+
      | c1         | c2   |
      +------------+------+
      | 2147483647 |    0 |
      +------------+------+
      

      +-------+-------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                      |
      +-------+-------------------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `c1` int(4) DEFAULT NULL,
        `c2` int(0) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+-------------------------------------------------------------------------------------------------------------------+
      

      Notice:

      • The value of c1 in the second result is wrong. It should be 50000000000000.
      • The data type for t1.c1 is wrong. It should be approximately bigint(14).
      • The data type for t1.c2 is wrong. It should be at least int(1).

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated: