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

ROW START/END columns added with ALTER TABLE are never INVISIBLE

    XMLWordPrintable

Details

    Description

      Normally, system-versioned tables can have invisible temporal columns:

      MariaDB [test]> CREATE OR REPLACE TABLE t (
          ->     x INT PRIMARY KEY,
          ->     valid_since TIMESTAMP(6) AS ROW START INVISIBLE,
          ->     valid_until TIMESTAMP(6) AS ROW END INVISIBLE,
          ->     PERIOD FOR SYSTEM_TIME (valid_since, valid_until)
          -> )
          ->     WITH SYSTEM VERSIONING
          -> ;
      Query OK, 0 rows affected (0.018 sec)
       
      MariaDB [test]> INSERT INTO t (x) VALUES (1), (2), (3);
      Query OK, 3 rows affected (0.001 sec)
      Records: 3  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> SELECT * FROM t;
      +---+
      | x |
      +---+
      | 1 |
      | 2 |
      | 3 |
      +---+
      3 rows in set (0.000 sec)
      

      MDEV-27293 introduced the ability to add temporal columns later. But in this case, the INVISIBLE keyword is ignored:

      MariaDB [test]> CREATE OR REPLACE TABLE t (
          ->     x INT PRIMARY KEY
          -> )
          ->     WITH SYSTEM VERSIONING
          -> ;
      Query OK, 0 rows affected (0.020 sec)
       
      MariaDB [test]> SET SESSION system_versioning_alter_history = KEEP;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [test]> ALTER TABLE t
          ->     ADD COLUMN valid_since TIMESTAMP(6) AS ROW START INVISIBLE,
          ->     ADD COLUMN valid_until TIMESTAMP(6) AS ROW END INVISIBLE,
          ->     ADD PERIOD FOR SYSTEM_TIME (valid_since, valid_until);
      Query OK, 0 rows affected (0.019 sec)
      Records: 0  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> SET SESSION system_versioning_alter_history = ERROR;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [test]> INSERT INTO t (x) VALUES (1), (2), (3);
      Query OK, 3 rows affected (0.001 sec)
      Records: 3  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> SELECT * FROM t;
      +---+----------------------------+----------------------------+
      | x | valid_since                | valid_until                |
      +---+----------------------------+----------------------------+
      | 1 | 2025-06-15 15:51:54.185627 | 2106-02-07 06:28:15.999999 |
      | 2 | 2025-06-15 15:51:54.185627 | 2106-02-07 06:28:15.999999 |
      | 3 | 2025-06-15 15:51:54.185627 | 2106-02-07 06:28:15.999999 |
      +---+----------------------------+----------------------------+
       
      MariaDB [test]> SHOW CREATE TABLE t \G
      *************************** 1. row ***************************
             Table: t
      Create Table: CREATE TABLE `t` (
        `x` int(11) NOT NULL,
        `valid_since` timestamp(6) GENERATED ALWAYS AS ROW START,
        `valid_until` timestamp(6) GENERATED ALWAYS AS ROW END,
        PRIMARY KEY (`x`,`valid_until`),
        PERIOD FOR SYSTEM_TIME (`valid_since`, `valid_until`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci WITH SYSTEM VERSIONING
      

      Trying to run ALTER TABLE ... CHANGE COLUMN ... INVISIBLE is also useless.

      Attachments

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              f_razzoli Federico Razzoli
              Votes:
              0 Vote for this issue
              Watchers:
              7 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.