| 1 |
--source include/have_ndb.inc |
| 2 |
# |
| 3 |
# Test restoring of .sql file created with mysqldump |
| 4 |
# - somewhat more complex schema than ndb_fk_mysqldump.test |
| 5 |
|
| 6 |
--disable_query_log |
| 7 |
create table product ( |
| 8 |
category int not null, |
| 9 |
id int not null, |
| 10 |
price decimal, |
| 11 |
primary key(category, id)) |
| 12 |
engine=ndb; |
| 13 |
|
| 14 |
create table customer ( |
| 15 |
id int not null, |
| 16 |
primary key (id)) |
| 17 |
engine=ndb; |
| 18 |
|
| 19 |
create table address ( |
| 20 |
no int not null auto_increment, |
| 21 |
type int not null default 37, |
| 22 |
customer_id int not null, |
| 23 |
street varchar(255), |
| 24 |
country int, |
| 25 |
primary key (no), |
| 26 |
constraint ca_fk1 |
| 27 |
foreign key (customer_id) references customer(id) |
| 28 |
on update restrict on delete cascade) |
| 29 |
engine=ndb; |
| 30 |
|
| 31 |
create table product_order ( |
| 32 |
no int not null auto_increment, |
| 33 |
product_category int not null, |
| 34 |
product_id int not null, |
| 35 |
customer_id int not null, |
| 36 |
primary key(no), |
| 37 |
index (product_category, product_id), |
| 38 |
constraint po_fk1 |
| 39 |
foreign key (product_category, product_id) references product(category, id) |
| 40 |
on update restrict on delete cascade, |
| 41 |
index (customer_id), |
| 42 |
constraint po_fk2 |
| 43 |
foreign key (customer_id) references customer(id)) |
| 44 |
engine=ndb; |
| 45 |
|
| 46 |
insert into product values (1,1,5); |
| 47 |
insert into customer value (1); |
| 48 |
insert into address (customer_id, street, country) |
| 49 |
values (1, "Main st. 1215", 48); |
| 50 |
insert into product_order value (1,1,1,1); |
| 51 |
|
| 52 |
echo Creating dump...; |
| 53 |
let $dump_file = $MYSQLTEST_VARDIR/tmp/ndb_fk_dump2.sql; |
| 54 |
--exec $MYSQL_DUMP --databases test > $dump_file |
| 55 |
echo OK, dump created!; |
| 56 |
|
| 57 |
drop table product_order, address, customer, product; |
| 58 |
|
| 59 |
echo Restoring dump...; |
| 60 |
--exec $MYSQL test < $dump_file |
| 61 |
--remove_file $dump_file |
| 62 |
echo OK, dump restored!; |
| 63 |
|
| 64 |
drop table product_order, address, customer, product; |
| 65 |
--enable_query_log |