summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <aivanov@mysql.com>2006-01-30 15:17:33 +0300
committerunknown <aivanov@mysql.com>2006-01-30 15:17:33 +0300
commitcc47eb77913aa40fc7642ccf5d372675059ec8f2 (patch)
tree08ba2fde9e3237be148e59033c35f0b139b97a33
parent6cc16c50191951e1d4fe3eb657fa53eb3f44da9d (diff)
downloadmariadb-git-cc47eb77913aa40fc7642ccf5d372675059ec8f2.tar.gz
Fixed BUG#16387.
Applied innodb-4.1-ss17 snapshot. Do not mistake TABLENAME_ibfk_0 for auto-generated id. innobase/dict/dict0dict.c: Applied innodb-4.1-ss17 snapshot. dict_table_get_highest_foreign_id(): Ignore foreign constraint identifiers starting with the pattern TABLENAME_ibfk_0 (BUG#16387). mysql-test/r/innodb.result: Applied innodb-4.1-ss17 snapshot. Fixed results for added test case. mysql-test/t/innodb.test: Applied innodb-4.1-ss17 snapshot. Added test case.
-rw-r--r--innobase/dict/dict0dict.c3
-rw-r--r--mysql-test/r/innodb.result13
-rw-r--r--mysql-test/t/innodb.test13
3 files changed, 28 insertions, 1 deletions
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c
index 0cdd593b678..093df5118af 100644
--- a/innobase/dict/dict0dict.c
+++ b/innobase/dict/dict0dict.c
@@ -2755,7 +2755,8 @@ dict_table_get_highest_foreign_id(
if (ut_strlen(foreign->id) > ((sizeof dict_ibfk) - 1) + len
&& 0 == ut_memcmp(foreign->id, table->name, len)
&& 0 == ut_memcmp(foreign->id + len,
- dict_ibfk, (sizeof dict_ibfk) - 1)) {
+ dict_ibfk, (sizeof dict_ibfk) - 1)
+ && foreign->id[len + ((sizeof dict_ibfk) - 1)] != '0') {
/* It is of the >= 4.0.18 format */
id = strtoul(foreign->id + len + ((sizeof dict_ibfk) - 1),
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index 3ec78c518fc..c4fae109bd4 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -1794,3 +1794,16 @@ a hex(b)
7 D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2
update t1 set b = 'three' where a = 6;
drop table t1;
+CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
+CREATE TABLE t2(a INT) ENGINE=InnoDB;
+ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
+ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) default NULL,
+ KEY `t2_ibfk_0` (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t2,t1;
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index e2c12eedcae..ee411a1bb37 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -1365,4 +1365,17 @@ insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1
select a,hex(b) from t1 order by b;
update t1 set b = 'three' where a = 6;
drop table t1;
+
+# Ensure that <tablename>_ibfk_0 is not mistreated as a
+# generated foreign key identifier. (Bug #16387)
+
+CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
+CREATE TABLE t2(a INT) ENGINE=InnoDB;
+ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
+ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
+SHOW CREATE TABLE t2;
+DROP TABLE t2,t1;
+
# End of 4.1 tests