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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
ed70e034
Commit
ed70e034
authored
Nov 21, 2020
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-20865 FIXMEs
parent
e0145df6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
17 deletions
+20
-17
mysql-test/main/foreign_key.result
mysql-test/main/foreign_key.result
+14
-8
mysql-test/main/foreign_key.test
mysql-test/main/foreign_key.test
+1
-1
sql/sql_alter.h
sql/sql_alter.h
+1
-1
sql/unireg.cc
sql/unireg.cc
+4
-7
No files found.
mysql-test/main/foreign_key.result
View file @
ed70e034
...
...
@@ -241,46 +241,52 @@ test.t3 check status OK
drop tables ch1, t2, t1, t3;
# Rename column on referenced table
create or replace table t1 (id int primary key);
create or replace table t2 (id int references t1);
create or replace table t2 (id int references t1
, id2 int references t1(id)
);
select * from t2;
id
id
id2
alter table t1 change id xid int;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`id` int(11) DEFAULT NULL,
`id2` int(11) DEFAULT NULL,
KEY `fk_t2` (`id`),
CONSTRAINT `fk_t2` FOREIGN KEY (`id`) REFERENCES `t1` (`xid`)
KEY `fk_t2_2` (`id2`),
CONSTRAINT `fk_t2` FOREIGN KEY (`id`) REFERENCES `t1` (`xid`),
CONSTRAINT `fk_t2_2` FOREIGN KEY (`id2`) REFERENCES `t1` (`xid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
select * from t1;
xid
check table t2;
Table Op Msg_type Msg_text
test.t2 check Note Found
1
foreign keys
test.t2 check Note Found
2
foreign keys
test.t2 check status OK
flush table t2;
check table t2;
Table Op Msg_type Msg_text
test.t2 check Note Found
1
foreign keys
test.t2 check Note Found
2
foreign keys
test.t2 check status OK
alter table t1 rename column xid to yid;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`id` int(11) DEFAULT NULL,
`id2` int(11) DEFAULT NULL,
KEY `fk_t2` (`id`),
CONSTRAINT `fk_t2` FOREIGN KEY (`id`) REFERENCES `t1` (`yid`)
KEY `fk_t2_2` (`id2`),
CONSTRAINT `fk_t2` FOREIGN KEY (`id`) REFERENCES `t1` (`yid`),
CONSTRAINT `fk_t2_2` FOREIGN KEY (`id2`) REFERENCES `t1` (`yid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
select * from t1;
yid
check table t2;
Table Op Msg_type Msg_text
test.t2 check Note Found
1
foreign keys
test.t2 check Note Found
2
foreign keys
test.t2 check status OK
flush table t2;
check table t2;
Table Op Msg_type Msg_text
test.t2 check Note Found
1
foreign keys
test.t2 check Note Found
2
foreign keys
test.t2 check status OK
drop tables t2, t1;
# Check rename table
...
...
mysql-test/main/foreign_key.test
View file @
ed70e034
...
...
@@ -242,7 +242,7 @@ drop tables ch1, t2, t1, t3;
--
echo
# Rename column on referenced table
create
or
replace
table
t1
(
id
int
primary
key
);
create
or
replace
table
t2
(
id
int
references
t1
);
create
or
replace
table
t2
(
id
int
references
t1
,
id2
int
references
t1
(
id
)
);
select
*
from
t2
;
alter
table
t1
change
id
xid
int
;
show
create
table
t2
;
...
...
sql/sql_alter.h
View file @
ed70e034
...
...
@@ -416,7 +416,7 @@ class Alter_table_ctx
Table_name
ref
;
const
FK_info
*
fk
;
};
//
FIXME: why this stored in std::set?
//
NB: multiple foreign keys can utilize same column (see fk_prepare_rename())
mbd
::
set
<
FK_rename_col
>
fk_renamed_cols
;
mbd
::
set
<
FK_rename_col
>
rk_renamed_cols
;
mbd
::
vector
<
FK_add_new
>
fk_added
;
...
...
sql/unireg.cc
View file @
ed70e034
...
...
@@ -1546,11 +1546,7 @@ bool TABLE_SHARE::fk_resolve_referenced_keys(THD *thd, TABLE_SHARE *from)
if
(
!
ids
.
insert
(
rk
.
foreign_id
,
&
inserted
))
return
true
;
if
(
!
inserted
)
// FIXME: assert instead error
{
my_error
(
ER_DUP_CONSTRAINT_NAME
,
MYF
(
0
),
"FOREIGN KEY"
,
rk
.
foreign_id
.
str
);
return
true
;
}
DBUG_ASSERT
(
inserted
);
}
for
(
FK_info
&
fk
:
from
->
foreign_keys
)
...
...
@@ -1564,8 +1560,9 @@ bool TABLE_SHARE::fk_resolve_referenced_keys(THD *thd, TABLE_SHARE *from)
if
(
!
inserted
)
{
my_error
(
ER_DUP_CONSTRAINT_NAME
,
MYF
(
0
),
"FOREIGN KEY"
,
fk
.
foreign_id
.
str
);
return
true
;
// FIXME: warn instead fail
push_warning_printf
(
thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
ER_DUP_CONSTRAINT_NAME
,
"Foreign ID already exists `%s`"
,
fk
.
foreign_id
.
str
);
continue
;
}
for
(
Lex_cstring
&
fld
:
fk
.
referenced_fields
)
...
...
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