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

Computed default for INVISIBLE column is ignored in INSERT

Details

    Description

      When a table has an INVISIBLE column with a computed default, said default is only used in an INSERT if said column is not specified, but other columns are. Best illustrated with an example:

      MariaDB> CREATE TABLE t1(c1 INT NOT NULL PRIMARY KEY, c2 INTEGER NOT NULL DEFAULT (c1 + 1) INVISIBLE);
      MariaDB> INSERT INTO t1 VALUES(1),(2);
      MariaDB> INSERT INTO t1(c1) VALUES(3),(4);
      MariaDB> INSERT INTO t1 VALUES(5),(6);
      MariaDB [test]> SELECT c1, c2 FROM t1;
      +----+----+
      | c1 | c2 |
      +----+----+
      |  1 |  0 |
      |  2 |  0 |
      |  3 |  4 |
      |  4 |  5 |
      |  5 |  0 |
      |  6 |  0 |
      +----+----+
      

      As can be seen, when doing an INSERT without specifying the columns, 0 is inserted and the defined DEFAULT is ignored. If an INSERT specifying which columns to insert though, the DEFAULT is computed appropriately.

      Attachments

        Issue Links

          Activity

            Transition Time In Source Status Execution Times
            Alice Sherepa made transition -
            Open Confirmed
            1h 31m 1
            Aleksey Midenkov made transition -
            Confirmed In Progress
            110d 19h 15m 1
            Aleksey Midenkov made transition -
            In Progress In Review
            40s 1
            Oleksandr Byelkin made transition -
            In Review Stalled
            2d 1h 36m 1
            Aleksey Midenkov made transition -
            Stalled In Progress
            3d 23h 34m 1
            Aleksey Midenkov made transition -
            In Progress Closed
            5d 22h 38m 1

            People

              midenok Aleksey Midenkov
              karlsson Anders Karlsson
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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