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

Allowing insert into a view with columns that are not part the table

    XMLWordPrintable

Details

    Description

      Creating a view with some extra virtual/computed fields are not insertable
      The intention should be that 'extra computed fields' in a view should work identical
      to how virtual fields works for a table.

      • If one inserts into the table without specifying the virtual fields, it should work without any
        warnings.
      • If one tries to insert into a virtual field, one should get an error/warning that the field is ignored.

        CREATE TABLE table1 (x INT);
        CREATE VIEW view1 AS SELECT x, x as x1 FROM table1;
        INSERT INTO view1(x) VALUES (1);
        ERROR 1471 (HY000): The target table view1 of the INSERT is not insertable-into
         
        An example with virtual columns
        MariaDB [test]> create table t1 (a int, b int generated always as (a+1));
        MariaDB [test]> insert into t1 (a) values(1);
        MariaDB [test]> insert into t1 values(1,2);
        ERROR 1906 (HY000): The value specified for generated column 'b' in table 't1' has been ignored
        MariaDB [test]> insert ignore into t1 values(1,2);
        Query OK, 1 row affected, 1 warning (0.018 sec)
        

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            monty Michael Widenius
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.