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

Automatic invisible primary key

    XMLWordPrintable

Details

    Description

      Feature request - new option innodb_automatic_pk (default off, global/session)

      During CREATE TABLE for InnoDB, automatically translate

      -- FROM:

      CREATE TABLE t1 (c2 INT) ENGINE=InnoDB;
      

      -- TO:

      CREATE TABLE t1 (_inv_PK SERIAL INVISIBLE PRIMARY KEY, c2 INT) ENGINE=InnoDB;
      

      -- FROM:

      ALTER TABLE t1 ADD PRIMARY KEY (`c2`);
      

      -- TO:

      ALTER TABLE t1 DROP COLUMN IF EXISTS _inv_PK, ADD PRIMARY KEY (`c2`);
      

      It might be a good idea to modify or suppress warning "Can't DROP COLUMN `_inv_PK`" and to issue a warning that _inv_PK was created.


      Here's a question, should the user be able to do

      select _inv_PK from t1;
      

      or should the column be completely internal and "not exist" from the user point of view?
      If one can select it, it's be kind of like ROWID in Oracle.

      Attachments

        Issue Links

          Activity

            People

              gkodinov Georgi Kodinov
              mg MG
              Votes:
              4 Vote for this issue
              Watchers:
              16 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.