[MDEV-14849] CREATE + ALTER with user-invisible columns produce invalid table definition Created: 2018-01-01  Updated: 2018-02-06  Resolved: 2018-02-06

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: 10.3
Fix Version/s: 10.3.5

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sachin Setiya (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Sprint: 10.1.31

 Description   

Even though user invisible columns are supposed to have default values, this works:

MariaDB [test]> create or replace table t1 (pk int auto_increment primary key invisible, i int);
# Query OK, 0 rows affected (0.16 sec)
 
MariaDB [test]> alter table t1 modify pk int invisible;
# Query OK, 0 rows affected (0.80 sec)
# Records: 0  Duplicates: 0  Warnings: 0

The resulting table structure is this:

MariaDB [test]> show create table t1;
+-------+------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                   |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `pk` int(11) NOT NULL INVISIBLE,
  `i` int(11) DEFAULT NULL,
  PRIMARY KEY (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

If you try to execute it, it produces an error:

MariaDB [test]> drop table t1;
Query OK, 0 rows affected (0.07 sec)
 
MariaDB [test]> CREATE TABLE `t1` (
    ->   `pk` int(11) NOT NULL INVISIBLE,
    ->   `i` int(11) DEFAULT NULL,
    ->   PRIMARY KEY (`pk`)
    -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ERROR 4106 (HY000): Invisible column `pk` must have a default value

My guess is that ALTER in the initial pair of commands should be rejected.


Generated at Thu Feb 08 08:16:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.