[MDEV-11428] Inconsistent Alter column / modify column behavior Created: 2016-11-30  Updated: 2016-11-30  Resolved: 2016-11-30

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

Type: Bug Priority: Major
Reporter: Marcin Gryszkalis Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None


 Description   

CURRENT_TIMESTAMP can be set as DEFAULT with MODIFY but not with ALTER:

> ALTER TABLE attachment_version ALTER COLUMN created_at SET DEFAULT CURRENT_TIMESTAMP;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CURRENT_TIMESTAMP' at line 1

> ALTER TABLE attachment_version MODIFY COLUMN created_at timestamp DEFAULT CURRENT_TIMESTAMP;

Query OK, 0 rows affected (0.02 sec)

The table in example is InnoDB.



 Comments   
Comment by Elena Stepanova [ 2016-11-30 ]

It was a documented limitation, both in MariaDB and MySQL:
http://dev.mysql.com/doc/refman/5.6/en/alter-table.html

| ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}

However, in 10.2 the limitation has been already lifted:

MariaDB [test]>  ALTER TABLE attachment_version ALTER COLUMN created_at SET DEFAULT CURRENT_TIMESTAMP;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [test]> select @@version;
+----------------+
| @@version      |
+----------------+
| 10.2.1-MariaDB |
+----------------+
1 row in set (0.00 sec)

Generated at Thu Feb 08 07:49:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.