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

INSERT .. DEFAULT broken when when columns are out of order

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.4(EOL), 10.5, 10.6, 10.10(EOL), 10.11, 11.0(EOL), 11.1(EOL), 11.2(EOL), 11.3(EOL)
    • None
    • None

    Description

      Defining a column default that refers to a column earlier in the schema doesn't work when using the DEFAULT keyword in insert statements if the set of insert columns is given in a different order than table schema order.

      Repro:

      mysql> CREATE TABLE t1 (a int default 1, b int default (a+1));
      Query OK, 0 rows affected (0.03 sec)
       
      mysql> INSERT INTO t1 (b,a) values (DEFAULT, 3);
      Query OK, 1 row affected (0.01 sec)
       
      mysql> select * from t1;
      +------+------+
      | a    | b    |
      +------+------+
      |    3 |    2 |
      +------+------+
      1 row in set (0.00 sec)
      

      Expected result is [3,4]

      MySQL has the same bug, which they deny is a bug:

      https://bugs.mysql.com/bug.php?id=112708

      I wrote a blog post about why I think that's the wrong call here:

      https://www.dolthub.com/blog/2023-10-13-fixing-mysql-bugs-in-dolt/

      Attachments

        Activity

          People

            Unassigned Unassigned
            zachmu Zach Musgrave
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.