88 lines
4.8 KiB
Plaintext
88 lines
4.8 KiB
Plaintext
drop table if exists t1;
|
|
create table t1 (
|
|
a int not null references t2,
|
|
b int not null references t2 (c),
|
|
primary key (a,b),
|
|
foreign key (a) references t3 match full,
|
|
foreign key (a) references t3 match partial,
|
|
foreign key (a,b) references t3 (c,d) on delete no action
|
|
on update no action,
|
|
foreign key (a,b) references t3 (c,d) on update cascade,
|
|
foreign key (a,b) references t3 (c,d) on delete set default,
|
|
foreign key (a,b) references t3 (c,d) on update set null);
|
|
create index a on t1 (a);
|
|
create unique index b on t1 (a,b);
|
|
drop table t1;
|
|
drop table if exists t_34455;
|
|
create table t_34455 (
|
|
a int not null,
|
|
foreign key (a) references t3 (a) match full match partial);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match partial)' at line 3
|
|
create table t_34455 (
|
|
a int not null,
|
|
foreign key (a) references t3 (a) on delete set default match full);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match full)' at line 3
|
|
create table t_34455 (
|
|
a int not null,
|
|
foreign key (a) references t3 (a) on update set default match full);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match full)' at line 3
|
|
create table t_34455 (
|
|
a int not null,
|
|
foreign key (a) references t3 (a)
|
|
on delete set default on delete set default);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete set default)' at line 4
|
|
create table t_34455 (
|
|
a int not null,
|
|
foreign key (a) references t3 (a)
|
|
on update set default on update set default);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'update set default)' at line 4
|
|
create table t_34455 (a int not null);
|
|
alter table t_34455
|
|
add foreign key (a) references t3 (a) match full match partial);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match partial)' at line 2
|
|
alter table t_34455
|
|
add foreign key (a) references t3 (a) on delete set default match full);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match full)' at line 2
|
|
alter table t_34455
|
|
add foreign key (a) references t3 (a) on update set default match full);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match full)' at line 2
|
|
alter table t_34455
|
|
add foreign key (a) references t3 (a)
|
|
on delete set default on delete set default);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete set default)' at line 3
|
|
alter table t_34455
|
|
add foreign key (a) references t3 (a)
|
|
on update set default on update set default);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'update set default)' at line 3
|
|
drop table t_34455;
|
|
#
|
|
# Bug#20752436: INNODB: FAILING ASSERTION: 0 IN FILE HANDLER0ALTER.CC
|
|
# LINE 6647
|
|
#
|
|
# Verify that index types that cannot be used as foreign keys are
|
|
# ignored when creating foreign keys.
|
|
set @@foreign_key_checks=0;
|
|
CREATE TABLE t1(a CHAR(100), b GEOMETRY NOT NULL) ENGINE InnoDB;
|
|
# Creating a foreign key on a GEOMETRY column is not supported
|
|
ALTER TABLE t1 ADD CONSTRAINT fi_b FOREIGN KEY(b) REFERENCES ti2(b);
|
|
ERROR 42000: BLOB/TEXT column 'b' used in key specification without a key length
|
|
# Adds FULLTEXT and SPATAL indices which cannot be used as foreign keys
|
|
ALTER TABLE t1 ADD FULLTEXT INDEX(a), ADD SPATIAL INDEX(b);
|
|
Warnings:
|
|
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
|
|
# Adds a foreign key on column with FULLTEXT index.
|
|
# The FULLTEXT index cannot be used and the generated key must be kept
|
|
ALTER TABLE t1 ADD CONSTRAINT fi_a FOREIGN KEY(a) REFERENCES ti2(a);
|
|
SHOW INDEXES FROM t1;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
t1 1 b 1 b A 0 32 NULL SPATIAL
|
|
t1 1 fi_a 1 a A 0 NULL NULL YES BTREE
|
|
t1 1 a 1 a NULL 0 NULL NULL YES FULLTEXT
|
|
# Attempt to add a foreign key on column with SPATIAL index.
|
|
# The SPATIAL index cannot be used so this becomes an attempt at
|
|
# creating a foreign key on a GEOMETRY column which is not supported
|
|
ALTER TABLE t1 ADD CONSTRAINT fi_b FOREIGN KEY(b) REFERENCES ti2(b);
|
|
ERROR 42000: BLOB/TEXT column 'b' used in key specification without a key length
|
|
DROP TABLE t1;
|
|
set @@foreign_key_checks= 1;
|