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
e81f101d
Commit
e81f101d
authored
Jul 17, 2018
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create a reusable function that tells what FK actions can write
Backport of
794f71cb
parent
dd74332d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
3 deletions
+9
-3
sql/sql_base.cc
sql/sql_base.cc
+2
-3
sql/table.cc
sql/table.cc
+6
-0
sql/table.h
sql/table.h
+1
-0
No files found.
sql/sql_base.cc
View file @
e81f101d
...
@@ -4883,12 +4883,11 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
...
@@ -4883,12 +4883,11 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
while
((
fk
=
fk_list_it
++
))
while
((
fk
=
fk_list_it
++
))
{
{
// FK_OPTION_RESTRICT and FK_OPTION_NO_ACTION only need read access
// FK_OPTION_RESTRICT and FK_OPTION_NO_ACTION only need read access
static
bool
can_write
[]
=
{
true
,
false
,
true
,
true
,
false
,
true
};
uint8
op
=
table_list
->
trg_event_map
;
uint8
op
=
table_list
->
trg_event_map
;
thr_lock_type
lock_type
;
thr_lock_type
lock_type
;
if
((
op
&
(
1
<<
TRG_EVENT_DELETE
)
&&
can_write
[
fk
->
delete_method
]
)
if
((
op
&
(
1
<<
TRG_EVENT_DELETE
)
&&
fk_modifies_child
(
fk
->
delete_method
)
)
||
(
op
&
(
1
<<
TRG_EVENT_UPDATE
)
&&
can_write
[
fk
->
update_method
]
))
||
(
op
&
(
1
<<
TRG_EVENT_UPDATE
)
&&
fk_modifies_child
(
fk
->
update_method
)
))
lock_type
=
TL_WRITE_ALLOW_WRITE
;
lock_type
=
TL_WRITE_ALLOW_WRITE
;
else
else
lock_type
=
TL_READ
;
lock_type
=
TL_READ
;
...
...
sql/table.cc
View file @
e81f101d
...
@@ -7264,3 +7264,9 @@ LEX_CSTRING *fk_option_name(enum_fk_option opt)
...
@@ -7264,3 +7264,9 @@ LEX_CSTRING *fk_option_name(enum_fk_option opt)
};
};
return
names
+
opt
;
return
names
+
opt
;
}
}
bool
fk_modifies_child
(
enum_fk_option
opt
)
{
static
bool
can_write
[]
=
{
false
,
false
,
true
,
true
,
false
,
true
};
return
can_write
[
opt
];
}
sql/table.h
View file @
e81f101d
...
@@ -1447,6 +1447,7 @@ typedef struct st_foreign_key_info
...
@@ -1447,6 +1447,7 @@ typedef struct st_foreign_key_info
}
FOREIGN_KEY_INFO
;
}
FOREIGN_KEY_INFO
;
LEX_CSTRING
*
fk_option_name
(
enum_fk_option
opt
);
LEX_CSTRING
*
fk_option_name
(
enum_fk_option
opt
);
bool
fk_modifies_child
(
enum_fk_option
opt
);
#define MY_I_S_MAYBE_NULL 1
#define MY_I_S_MAYBE_NULL 1
#define MY_I_S_UNSIGNED 2
#define MY_I_S_UNSIGNED 2
...
...
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