polardbxengine/mysql-test/suite/ndb/t/ndb_fk_locase.test

87 lines
1.7 KiB
Plaintext

--source include/have_ndb.inc
--disable_query_log
CREATE TEMPORARY TABLE IF NOT EXISTS ndb_show_tables_results (
id INT,
type VARCHAR(20),
state VARCHAR(20),
logging VARCHAR(20),
_database VARCHAR(255),
_schema VARCHAR(20),
name VARCHAR(255)
);
--enable_query_log
select @@global.lower_case_table_names;
--echo # test FK name is stored lower case
create table T1 (
a int primary key
) engine=ndb;
insert into t1 values (1);
create table T2 (
a int primary key,
b int,
constraint myFK1 foreign key (a) references t1 (a),
key XB (b)
) engine=ndb;
alter table T2
add constraint MYfk2 foreign key (b) references test.t1 (a);
--disable_warnings
show create table t2;
--enable_warnings
--error ER_NO_REFERENCED_ROW_2
insert into t2 values (2,1);
--error ER_NO_REFERENCED_ROW_2
insert into t2 values (1,2);
--source ndb_show_tables_result.inc
select count(*) from ndb_show_tables_results
where type = "'UserTable'" and name in ( "'t1'", "'t2'");
select count(*) from ndb_show_tables_results
where type = "'ForeignKey'" and name like "'%myfk%'";
alter table T2
drop foreign key MYfk1;
alter table t2
drop foreign key myFK2,
algorithm=copy;
--disable_warnings
show create table t2;
--enable_warnings
--echo # test upper case parent database and table
drop table T2;
create table T2 (
a int primary key,
b int,
constraint myFK1 foreign key (a) references T1 (a),
key XB (b)
) engine=ndb;
alter table T2
add constraint MYfk2 foreign key (b) references TEST.T1 (a);
--disable_warnings
show create table t2;
--enable_warnings
--error ER_NO_REFERENCED_ROW_2
insert into t2 values (2,1);
--error ER_NO_REFERENCED_ROW_2
insert into t2 values (1,2);
drop table t2,t1;