Skip to content

Commit a5eff04

Browse files
committed
MDEV-22602 Disable UPDATE CASCADE for SQL constraints
fix it for named constraints too
1 parent 107d546 commit a5eff04

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

mysql-test/suite/innodb/r/foreign_key.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,8 @@ DROP TABLE t1;
943943
#
944944
# TODO: enable them after MDEV-16417 is finished
945945
create or replace table t1 (a int primary key) engine=innodb;
946+
create or replace table t2 (a int, constraint foo check(a > 0), foreign key(a) references t1(a) on update cascade) engine=innodb;
947+
ERROR HY000: Function or expression 'a' cannot be used in the CHECK clause of `foo`
946948
create or replace table t2 (a int, check(a > 0), foreign key(a) references t1(a) on update cascade) engine=innodb;
947949
ERROR HY000: Function or expression 'a' cannot be used in the CHECK clause of `CONSTRAINT_1`
948950
create or replace table t1 (f1 int, f2 date, f3 date, key(f1,f3,f2)) engine=innodb;

mysql-test/suite/innodb/t/foreign_key.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,8 @@ DROP TABLE t1;
971971
--echo # TODO: enable them after MDEV-16417 is finished
972972
create or replace table t1 (a int primary key) engine=innodb;
973973
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
974+
create or replace table t2 (a int, constraint foo check(a > 0), foreign key(a) references t1(a) on update cascade) engine=innodb;
975+
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
974976
create or replace table t2 (a int, check(a > 0), foreign key(a) references t1(a) on update cascade) engine=innodb;
975977

976978
create or replace table t1 (f1 int, f2 date, f3 date, key(f1,f3,f2)) engine=innodb;

sql/sql_table.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4622,7 +4622,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
46224622
my_error(ER_TOO_LONG_IDENT, MYF(0), check->name.str);
46234623
DBUG_RETURN(TRUE);
46244624
}
4625-
if (check_expression(check, &check->name, VCOL_CHECK_TABLE))
4625+
if (check_expression(check, &check->name, VCOL_CHECK_TABLE, alter_info))
46264626
DBUG_RETURN(TRUE);
46274627
}
46284628
}

0 commit comments

Comments
 (0)