File: innodb_bug68148.test

package info (click to toggle)
mariadb-10.0 10.0.32-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 476,064 kB
  • sloc: cpp: 1,400,131; ansic: 832,140; perl: 54,391; sh: 41,304; pascal: 32,365; yacc: 14,921; xml: 5,257; sql: 4,667; cs: 4,647; makefile: 4,555; ruby: 4,465; python: 2,292; lex: 1,427; java: 941; asm: 295; awk: 54; php: 22; sed: 16
file content (41 lines) | stat: -rw-r--r-- 1,156 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- source include/have_innodb.inc
-- source include/not_embedded.inc

#
# Bug #68148: drop index on a foreign key column leads to missing table
# MDEV-8845: Table disappear after modifying FK
#

set global innodb_file_per_table=1;

CREATE TABLE ref_table1 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; 

CREATE TABLE ref_table2 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;

CREATE TABLE `main` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ref_id1` int(11) NOT NULL,
  `ref_id2` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_1` (`ref_id1`,`ref_id2`),
  KEY `FK_set_out_analysis_route_id` (`ref_id2`),
  CONSTRAINT `FK_1` FOREIGN KEY (`ref_id1`) REFERENCES `ref_table1` (`id`) ,
  CONSTRAINT `FK_2` FOREIGN KEY (`ref_id2`) REFERENCES `ref_table2` (`id`)
) ENGINE=InnoDB;

SET FOREIGN_KEY_CHECKS=0;

DROP INDEX `idx_1` ON `main`;
SHOW TABLES;

--echo # restart and see if we can still access the main table
--source include/restart_mysqld.inc

# This is required to access the table
SET FOREIGN_KEY_CHECKS=0;
ALTER TABLE `main` ADD INDEX `idx_1` (`ref_id1`);
SHOW CREATE TABLE `main`;

DROP TABLE  main, ref_table1, ref_table2;