~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/foreign_key.test

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 01:02:23 UTC
  • mto: (960.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321010223-j8cph7eeyt1u3xol
Fixed function object to ensure it correctly returns a boolean type since
memcmp returns an integer. Added some more comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# Test syntax of foreign keys
3
3
#
4
4
 
5
 
--disable_warnings
6
 
drop table if exists t1;
7
 
--enable_warnings
8
 
 
9
 
create table t1 (
10
 
        a int not null references t2,
11
 
        b int not null references t2 (c),
12
 
        primary key (a,b),
13
 
        foreign key (a) references t3 match full,
14
 
        foreign key (a) references t3 match partial,
15
 
        foreign key (a,b) references t3 (c,d) on delete no action
16
 
          on update no action,
17
 
        foreign key (a,b) references t3 (c,d) on update cascade,
18
 
        foreign key (a,b) references t3 (c,d) on delete set default,
19
 
        foreign key (a,b) references t3 (c,d) on update set null);
20
 
 
21
 
create index a on t1 (a);
22
 
create unique index b on t1 (a,b);
23
 
drop table t1;
 
5
CREATE TABLE product (category INT NOT NULL, id INT NOT NULL,
 
6
    price DECIMAL,
 
7
    PRIMARY KEY(category, id)) ENGINE=INNODB;
 
8
CREATE TABLE customer (id INT NOT NULL,
 
9
    PRIMARY KEY (id)) ENGINE=INNODB;
 
10
CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT,
 
11
    product_category INT NOT NULL,
 
12
    product_id INT NOT NULL,
 
13
    customer_id INT NOT NULL,
 
14
    PRIMARY KEY(no),
 
15
    INDEX (product_category, product_id),
 
16
    FOREIGN KEY (product_category, product_id)
 
17
    REFERENCES product(category, id)
 
18
    ON UPDATE CASCADE ON DELETE RESTRICT,
 
19
    INDEX (customer_id),
 
20
    FOREIGN KEY (customer_id)
 
21
    REFERENCES customer(id)) ENGINE=INNODB;
 
22
 
 
23
show create table product_order;
 
24
 
 
25
drop table product_order, customer, product;
24
26
 
25
27
# End of 4.1 tests
26
28