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

"CREATE TABLE t1 SELECT int_sp_argument" produces a too large column

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.1(EOL), 10.2(EOL)
    • 10.4(EOL)
    • Data types
    • None

    Description

      DROP TABLE IF EXISTS t1;
      DROP PROCEDURE IF EXISTS p1;
      CREATE PROCEDURE p1(a INT) CREATE TABLE t1 SELECT a;
      CALL p1(1);
      DESC t1;

      returns

      +-------+------------+------+-----+---------+-------+
      | Field | Type       | Null | Key | Default | Extra |
      +-------+------------+------+-----+---------+-------+
      | a     | bigint(11) | YES  |     | NULL    |       |
      +-------+------------+------+-----+---------+-------+

      int(11) would be enough.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov added a comment - - edited

            A similar problem:

            CREATE OR REPLACE TABLE t1 (a int);
            CREATE OR REPLACE VIEW v1 AS SELECT COALESCE(a) AS a FROM t1;
            DESC v1;

            returns

            +-------+------------+------+-----+---------+-------+
            | Field | Type       | Null | Key | Default | Extra |
            +-------+------------+------+-----+---------+-------+
            | a     | bigint(11) | YES  |     | NULL    |       |
            +-------+------------+------+-----+---------+-------+

            int(11) should be ok.

            bar Alexander Barkov added a comment - - edited A similar problem: CREATE OR REPLACE TABLE t1 (a int); CREATE OR REPLACE VIEW v1 AS SELECT COALESCE(a) AS a FROM t1; DESC v1; returns +-------+------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+------+-----+---------+-------+ | a | bigint(11) | YES | | NULL | | +-------+------------+------+-----+---------+-------+ int(11) should be ok.

            A similar problem:

            CREATE OR REPLACE TABLE t1 AS SELECT 999999999 AS a,2147483647 AS b;

            returns

            +-------+------------+------+-----+---------+-------+
            | Field | Type       | Null | Key | Default | Extra |
            +-------+------------+------+-----+---------+-------+
            | a     | int(9)     | NO   |     | NULL    |       |
            | b     | bigint(10) | NO   |     | NULL    |       |
            +-------+------------+------+-----+---------+-------+

            int(10) for b should be enough.

            bar Alexander Barkov added a comment - A similar problem: CREATE OR REPLACE TABLE t1 AS SELECT 999999999 AS a,2147483647 AS b; returns +-------+------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+------+-----+---------+-------+ | a | int(9) | NO | | NULL | | | b | bigint(10) | NO | | NULL | | +-------+------------+------+-----+---------+-------+ int(10) for b should be enough.

            People

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