[MDEV-17038] ALTER TABLE CHANGE COLUMN c1 c1 bigint NOT NULL - generates error if table uses SYSTEM VERSIONING Created: 2018-08-22  Updated: 2018-11-01  Resolved: 2018-11-01

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Versioned Tables
Affects Version/s: 10.3.9, 10.3
Fix Version/s: 10.3.11

Type: Bug Priority: Major
Reporter: Robert Dyas Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: None
Environment:

CentOS7


Issue Links:
Relates
relates to MDEV-14632 Assertion `!((new_col->prtype ^ col->... Closed

 Description   

If you issue an ALTER TABLE to make a column that is a foreign key NOT NULL you get the following error:

Cannot change column 'c1': used in a foreign key constraint 'p2c_ibfk_1'

In prior versions of MariaDB this was allowed and did not generate an error. Further, if you issue an ALTER TABLE to make a column that is a foreign key NULLable you do NOT get any error message.



 Comments   
Comment by Alice Sherepa [ 2018-08-24 ]

Thanks for the report! Reproducible with Innodb on MariaDB 10.3

--source include/have_innodb.inc
SET @@system_versioning_alter_history = 1;
 
create table t1 (a int not null, key(a))engine=innodb with system versioning;
create table t2 (b int, foreign key(b) references t1(a))engine=innodb with system versioning;
alter table t2 modify column b int default null;
drop table t2,t1;
 
create table t1 (a int, key(a))engine=innodb with system versioning;
create table t2 (b int, foreign key(b) references t1(a))engine=innodb with system versioning;
alter table t2 modify column b int not null;
drop table t2,t1;
 
mysqltest: At line 17: query 'alter table t2 modify column b int not null' failed: 1832: Cannot change column 'b': used in a foreign key constraint 't2_ibfk_1'

Comment by Marko Mäkelä [ 2018-10-31 ]

I think that the tests need a little more work.

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