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

Support primary keys on virtual columns

Details

    Description

      From the manual I can find out that:

      There are two types of virtual , or computed, columns: PERSISTENT, which are stored in the table, and VIRTUAL, which are generated when the table is queried.

      Why PERSISTENT column is Computed when it is stored in the table?

      DROP TABLE IF EXISTS `raw__categories`;
      create table `raw__categories` (
      `id` BINARY(32) as (md5(CONCAT_WS('~',`ID_CATEGORY`,`ID_LANG`))) PERSISTENT,
      `ID_CATEGORY` varchar(29) NOT NULL,
      `ID_LANG` varchar(2) NOT NULL,
      `NAME` varchar(40) NOT NULL,
      PRIMARY KEY(`id`)
      )
      engine=InnoDB CHARSET=utf8;

      I have an error:
      #1903 - Primary key cannot be defined upon a computed column

      It would be very useful to set up an ID algorithm using DDL

      Attachments

        Issue Links

          Activity

            Why PERSISTENT column is Computed when it is stored in the table?

            Because it is computed; as per the general definition, "its value automatically calculated using a deterministic expression, in particular from the values of other fields in the table".
            The difference is when it's calculated – upon storing or upon retrieval.

            The fact that primary keys are not supported is also explicitly documented here: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/.

            If you wish, we can treat this report as a feature request.

            elenst Elena Stepanova added a comment - Why PERSISTENT column is Computed when it is stored in the table? Because it is computed; as per the general definition, "its value automatically calculated using a deterministic expression, in particular from the values of other fields in the table". The difference is when it's calculated – upon storing or upon retrieval. The fact that primary keys are not supported is also explicitly documented here: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/ . If you wish, we can treat this report as a feature request.

            If you wish, we can treat this report as a feature request.

            Yes, It would be great.

            Thank you.

            a.formella Artur Formella added a comment - If you wish, we can treat this report as a feature request. Yes, It would be great. Thank you.

            Duplicate of MDEV-5590

            serg Sergei Golubchik added a comment - Duplicate of MDEV-5590

            People

              Unassigned Unassigned
              a.formella Artur Formella
              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.