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
4383e16c
Commit
4383e16c
authored
Dec 25, 2016
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IB: skip check_ref on historical record [fixes #101]
parent
ea60760e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
6 deletions
+65
-6
mysql-test/suite/versioning/r/foreign.result
mysql-test/suite/versioning/r/foreign.result
+25
-2
mysql-test/suite/versioning/t/foreign.test
mysql-test/suite/versioning/t/foreign.test
+26
-2
storage/innobase/row/row0ins.cc
storage/innobase/row/row0ins.cc
+14
-2
No files found.
mysql-test/suite/versioning/r/foreign.result
View file @
4383e16c
...
...
@@ -80,13 +80,36 @@ on delete cascade
on update restrict
)
engine innodb;
insert into parent (id) values (
1
);
insert into child (x, parent_id) values (
1, 1
);
insert into parent (id) values (
2
);
insert into child (x, parent_id) values (
2, 2
);
delete from parent;
select * from child;
x parent_id
drop table child;
drop table parent;
create or replace table parent (
id int primary key
)
engine innodb;
create or replace table child (
id int primary key,
parent_id int not null,
constraint `parent-fk`
foreign key (parent_id) references parent (id)
on delete cascade
on update restrict
) with system versioning
engine innodb;
insert into parent (id) values (3);
insert into child (id, parent_id) values (3, 3);
delete from parent;
select * from child;
id parent_id
select * from child for system_time all;
id parent_id
3 3
drop table child;
drop table parent;
create table parent(
id int unique key
) engine innodb;
...
...
mysql-test/suite/versioning/t/foreign.test
View file @
4383e16c
...
...
@@ -102,14 +102,38 @@ create or replace table child (
)
engine
innodb
;
insert
into
parent
(
id
)
values
(
1
);
insert
into
child
(
x
,
parent_id
)
values
(
1
,
1
);
insert
into
parent
(
id
)
values
(
2
);
insert
into
child
(
x
,
parent_id
)
values
(
2
,
2
);
delete
from
parent
;
select
*
from
child
;
drop
table
child
;
drop
table
parent
;
create
or
replace
table
parent
(
id
int
primary
key
)
engine
innodb
;
create
or
replace
table
child
(
id
int
primary
key
,
parent_id
int
not
null
,
constraint
`parent-fk`
foreign
key
(
parent_id
)
references
parent
(
id
)
on
delete
cascade
on
update
restrict
)
with
system
versioning
engine
innodb
;
insert
into
parent
(
id
)
values
(
3
);
insert
into
child
(
id
,
parent_id
)
values
(
3
,
3
);
delete
from
parent
;
select
*
from
child
;
select
*
from
child
for
system_time
all
;
drop
table
child
;
drop
table
parent
;
#################
# Test SET NULL #
#################
...
...
storage/innobase/row/row0ins.cc
View file @
4383e16c
...
...
@@ -1686,10 +1686,22 @@ row_ins_check_foreign_constraint(
/* If any of the foreign key fields in entry is SQL NULL, we
suppress the foreign key check: this is compatible with Oracle,
for example */
for
(
ulint
i
=
0
;
i
<
foreign
->
n_fields
;
i
++
)
{
if
(
dfield_is_null
(
dtuple_get_nth_field
(
entry
,
i
)))
{
for
(
ulint
i
=
0
;
i
<
entry
->
n_fields
;
i
++
)
{
dfield_t
*
field
=
dtuple_get_nth_field
(
entry
,
i
);
if
(
i
<
foreign
->
n_fields
&&
dfield_is_null
(
field
))
{
goto
exit_func
;
}
/* System Versioning: if sys_trx_end != Inf, we
suppress the foreign key check */
if
(
DICT_TF2_FLAG_IS_SET
(
table
,
DICT_TF2_VERSIONED
)
&&
dfield_get_type
(
field
)
->
prtype
&
DATA_VERS_ROW_END
)
{
byte
*
data
=
static_cast
<
byte
*>
(
dfield_get_data
(
field
));
ut_ad
(
data
);
trx_id_t
end_trx_id
=
mach_read_from_8
(
data
);
if
(
end_trx_id
!=
TRX_ID_MAX
)
goto
exit_func
;
}
}
if
(
que_node_get_type
(
thr
->
run_node
)
==
QUE_NODE_UPDATE
)
{
...
...
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