~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/t/information_schema_inno.test

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- source include/testdb_only.inc
 
2
--disable_warnings
 
3
DROP TABLE IF EXISTS t1,t2,t3;
 
4
--enable_warnings
 
5
 
 
6
#
 
7
# Test for KEY_COLUMN_USAGE & TABLE_CONSTRAINTS tables
 
8
#
 
9
 
 
10
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
 
11
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id, id),
 
12
FOREIGN KEY (t1_id) REFERENCES t1(id)  ON DELETE CASCADE,
 
13
FOREIGN KEY (t1_id) REFERENCES t1(id)  ON UPDATE CASCADE) ENGINE=INNODB;
 
14
 
 
15
CREATE TABLE t3 (id INT PRIMARY KEY, t2_id INT, INDEX par_ind (t2_id),
 
16
FOREIGN KEY (id, t2_id) REFERENCES t2(t1_id, id)  ON DELETE CASCADE) ENGINE=INNODB;
 
17
 
 
18
#select * from information_schema.OLD_TABLE_CONSTRAINTS where
 
19
#TABLE_SCHEMA= "test";
 
20
select * from data_dictionary.indexes where TABLE_SCHEMA= "test";
 
21
 
 
22
drop table t3, t2, t1;
 
23
 
 
24
#
 
25
# Test for REFERENTIAL_CONSTRAINTS table
 
26
#
 
27
CREATE TABLE t1(a1 INT NOT NULL, a2 INT NOT NULL,
 
28
                PRIMARY KEY(a1, a2)) ENGINE=INNODB;
 
29
CREATE TABLE t2(b1 INT, b2 INT, INDEX (b1, b2),
 
30
                CONSTRAINT A1
 
31
                FOREIGN KEY (b1, b2) REFERENCES t1(a1, a2)
 
32
                ON UPDATE CASCADE ON DELETE NO ACTION) ENGINE=INNODB;
 
33
CREATE TABLE t3(b1 INT, b2 INT, INDEX t3_indx (b1, b2),
 
34
                CONSTRAINT A2
 
35
                FOREIGN KEY (b1, b2) REFERENCES t2(b1, b2)
 
36
                ON UPDATE SET NULL ON DELETE RESTRICT) ENGINE=INNODB;
 
37
CREATE TABLE t4(b1 INT, b2 INT, UNIQUE KEY t4_ukey (b1, b2),
 
38
                CONSTRAINT A3
 
39
                FOREIGN KEY (b1, b2) REFERENCES t3(b1, b2)
 
40
                ON UPDATE NO ACTION ON DELETE SET NULL) ENGINE=INNODB;
 
41
CREATE TABLE t5(b1 INT, b2 INT, INDEX (b1, b2),
 
42
                CONSTRAINT A4
 
43
                FOREIGN KEY (b1, b2) REFERENCES t4(b1, b2)
 
44
                ON UPDATE RESTRICT ON DELETE CASCADE) ENGINE=INNODB;
 
45
                
 
46
#select a.CONSTRAINT_SCHEMA, b.TABLE_NAME, CONSTRAINT_TYPE,
 
47
#       b.CONSTRAINT_NAME, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME,
 
48
#       MATCH_OPTION, UPDATE_RULE, DELETE_RULE, b.REFERENCED_TABLE_NAME
 
49
#from information_schema.OLD_TABLE_CONSTRAINTS a,
 
50
#     information_schema.OLD_REFERENTIAL_CONSTRAINTS b
 
51
#where a.CONSTRAINT_SCHEMA = 'test' and a.CONSTRAINT_SCHEMA = b.CONSTRAINT_SCHEMA and
 
52
#a.CONSTRAINT_NAME = b.CONSTRAINT_NAME;
 
53
drop tables t5, t4, t3, t2, t1;
 
54
 
 
55
#
 
56
# Bug#25026  `information_schema.KEY_COLUMN_USAGE`.`REFERENCED_TABLE_NAME` returns garbage
 
57
#
 
58
create database `db-1`;
 
59
use `db-1`;
 
60
create table `t-2` (
 
61
  id int not null auto_increment,
 
62
  primary key (id)
 
63
) engine=innodb;
 
64
 
 
65
create table `t-1` (
 
66
  id int not null auto_increment,
 
67
  idtype int not null,
 
68
  primary key (id),
 
69
  key fk_t1_1 (idtype),
 
70
  constraint fk_t1_1 foreign key (idtype) references `t-2` (id)
 
71
) engine=innodb;
 
72
use test;
 
73
#select referenced_table_schema, referenced_table_name 
 
74
#from data_dictionary.indexes
 
75
#where constraint_schema = 'db-1';
 
76
drop database `db-1`;
 
77
 
 
78
#
 
79
# Bug#35108 SELECT FROM REFERENTIAL_CONSTRAINTS crashes
 
80
#
 
81
create table t1(id int primary key) engine = Innodb;
 
82
create table t2(pid int, foreign key (pid) references t1(id)) engine = Innodb;
 
83
set foreign_key_checks = 0;
 
84
drop table t1;
 
85
#select UNIQUE_CONSTRAINT_NAME
 
86
#from data_dictionary.OLD_referential_constraints
 
87
#where constraint_schema = schema();
 
88
drop table t2;
 
89
set foreign_key_checks = 1;