Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
67f1c04f
Commit
67f1c04f
authored
May 14, 2004
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better fix for bug#3749 - do not consider already removed keys in key removal process
parent
a7177178
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
15 deletions
+41
-15
mysql-test/r/innodb.result
mysql-test/r/innodb.result
+24
-1
mysql-test/t/innodb.test
mysql-test/t/innodb.test
+11
-1
sql/sql_table.cc
sql/sql_table.cc
+6
-13
No files found.
mysql-test/r/innodb.result
View file @
67f1c04f
...
@@ -1540,4 +1540,27 @@ t2 CREATE TABLE `t2` (
...
@@ -1540,4 +1540,27 @@ t2 CREATE TABLE `t2` (
drop table t2;
drop table t2;
create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
ERROR HY000: Can't create table './test/t2.frm' (errno: 150)
ERROR HY000: Can't create table './test/t2.frm' (errno: 150)
drop table t1;
create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) NOT NULL auto_increment,
`b` int(11) default NULL,
PRIMARY KEY (`a`),
UNIQUE KEY `b_2` (`b`),
KEY `b` (`b`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t2;
create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) NOT NULL auto_increment,
`b` int(11) default NULL,
PRIMARY KEY (`a`),
UNIQUE KEY `b` (`b`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`),
CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t2, t1;
mysql-test/t/innodb.test
View file @
67f1c04f
...
@@ -1086,4 +1086,14 @@ drop table t2;
...
@@ -1086,4 +1086,14 @@ drop table t2;
--
error
1005
--
error
1005
create
table
t2
(
id
int
(
11
)
not
null
,
id2
int
(
11
)
not
null
,
constraint
t1_id_fk
foreign
key
(
id2
,
id
)
references
t1
(
id
))
engine
=
innodb
;
create
table
t2
(
id
int
(
11
)
not
null
,
id2
int
(
11
)
not
null
,
constraint
t1_id_fk
foreign
key
(
id2
,
id
)
references
t1
(
id
))
engine
=
innodb
;
drop
table
t1
;
# bug#3749
create
table
t2
(
a
int
auto_increment
primary
key
,
b
int
,
index
(
b
),
foreign
key
(
b
)
references
t1
(
id
),
unique
(
b
))
engine
=
innodb
;
show
create
table
t2
;
drop
table
t2
;
create
table
t2
(
a
int
auto_increment
primary
key
,
b
int
,
foreign
key
(
b
)
references
t1
(
id
),
foreign
key
(
b
)
references
t1
(
id
),
unique
(
b
))
engine
=
innodb
;
show
create
table
t2
;
drop
table
t2
,
t1
;
sql/sql_table.cc
View file @
67f1c04f
...
@@ -688,9 +688,10 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
...
@@ -688,9 +688,10 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
'generated', and a generated key is a prefix of the other key. Then we
'generated', and a generated key is a prefix of the other key. Then we
do not need the generated shorter key.
do not need the generated shorter key.
*/
*/
if
((
key2
->
type
!=
Key
::
FOREIGN_KEY
&&
!
foreign_key_prefix
(
key
,
key2
)))
if
(
key2
->
name
!=
ignore_key
&&
key2
->
type
!=
Key
::
FOREIGN_KEY
&&
!
foreign_key_prefix
(
key
,
key2
))
{
{
/* TO
DO: issue warning message */
/* TODO: issue warning message */
/* mark that the generated key should be ignored */
/* mark that the generated key should be ignored */
if
(
!
key2
->
generated
||
if
(
!
key2
->
generated
||
(
key
->
generated
&&
key
->
columns
.
elements
<
(
key
->
generated
&&
key
->
columns
.
elements
<
...
@@ -698,17 +699,9 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
...
@@ -698,17 +699,9 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
key
->
name
=
ignore_key
;
key
->
name
=
ignore_key
;
else
else
{
{
/*
key2
->
name
=
ignore_key
;
Remove the previous, generated key if it has not yet been
key_parts
-=
key2
->
columns
.
elements
;
removed. Note that if we have several identical generated keys,
(
*
key_count
)
--
;
the last one will remain and others get removed here.
*/
if
(
key2
->
name
!=
ignore_key
)
{
key2
->
name
=
ignore_key
;
key_parts
-=
key2
->
columns
.
elements
;
(
*
key_count
)
--
;
}
}
}
break
;
break
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment