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
794f71cb
Commit
794f71cb
authored
Feb 23, 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
and few indentation changes
parent
17f8e0ec
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
19 deletions
+21
-19
sql/sql_base.cc
sql/sql_base.cc
+2
-3
sql/sql_delete.cc
sql/sql_delete.cc
+4
-4
sql/sql_table.cc
sql/sql_table.cc
+4
-8
sql/table.cc
sql/table.cc
+6
-0
sql/table.h
sql/table.h
+5
-4
No files found.
sql/sql_base.cc
View file @
794f71cb
...
...
@@ -4370,12 +4370,11 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
while
((
fk
=
fk_list_it
++
))
{
// 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
;
thr_lock_type
lock_type
;
if
((
op
&
(
1
<<
TRG_EVENT_DELETE
)
&&
can_write
[
fk
->
delete_method
]
)
||
(
op
&
(
1
<<
TRG_EVENT_UPDATE
)
&&
can_write
[
fk
->
update_method
]
))
if
((
op
&
(
1
<<
TRG_EVENT_DELETE
)
&&
fk_modifies_child
(
fk
->
delete_method
)
)
||
(
op
&
(
1
<<
TRG_EVENT_UPDATE
)
&&
fk_modifies_child
(
fk
->
update_method
)
))
lock_type
=
TL_WRITE_ALLOW_WRITE
;
else
lock_type
=
TL_READ
;
...
...
sql/sql_delete.cc
View file @
794f71cb
...
...
@@ -912,14 +912,14 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
wild_num - number of wildcards used in optional SELECT clause
field_list - list of items in optional SELECT clause
conds - conditions
l
RETURN VALUE
FALSE OK
TRUE error
*/
int
mysql_prepare_delete
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
uint
wild_num
,
List
<
Item
>
&
field_list
,
Item
**
conds
,
bool
*
delete_while_scanning
)
int
mysql_prepare_delete
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
uint
wild_num
,
List
<
Item
>
&
field_list
,
Item
**
conds
,
bool
*
delete_while_scanning
)
{
Item
*
fake_conds
=
0
;
SELECT_LEX
*
select_lex
=
&
thd
->
lex
->
select_lex
;
...
...
sql/sql_table.cc
View file @
794f71cb
...
...
@@ -3656,9 +3656,9 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if
(
key
->
type
==
Key
::
FOREIGN_KEY
)
{
fk_key_count
++
;
if
(((
Foreign_key
*
)
key
)
->
validate
(
alter_info
->
create_list
))
DBUG_RETURN
(
TRUE
);
Foreign_key
*
fk_key
=
(
Foreign_key
*
)
key
;
if
(
fk_key
->
validate
(
alter_info
->
create_list
))
DBUG_RETURN
(
TRUE
);
if
(
fk_key
->
ref_columns
.
elements
&&
fk_key
->
ref_columns
.
elements
!=
fk_key
->
columns
.
elements
)
{
...
...
@@ -4455,12 +4455,8 @@ bool Column_definition::sp_prepare_create_field(THD *thd, MEM_ROOT *mem_root)
}
static
bool
vers_prepare_keys
(
THD
*
thd
,
HA_CREATE_INFO
*
create_info
,
Alter_info
*
alter_info
,
KEY
**
key_info
,
uint
key_count
)
static
bool
vers_prepare_keys
(
THD
*
thd
,
HA_CREATE_INFO
*
create_info
,
Alter_info
*
alter_info
,
KEY
**
key_info
,
uint
key_count
)
{
DBUG_ASSERT
(
create_info
->
versioned
());
...
...
sql/table.cc
View file @
794f71cb
...
...
@@ -8554,6 +8554,12 @@ LEX_CSTRING *fk_option_name(enum_fk_option 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
];
}
enum
TR_table
::
enabled
TR_table
::
use_transaction_registry
=
TR_table
::
MAYBE
;
TR_table
::
TR_table
(
THD
*
_thd
,
bool
rw
)
:
...
...
sql/table.h
View file @
794f71cb
...
...
@@ -1620,6 +1620,7 @@ typedef struct st_foreign_key_info
}
FOREIGN_KEY_INFO
;
LEX_CSTRING
*
fk_option_name
(
enum_fk_option
opt
);
bool
fk_modifies_child
(
enum_fk_option
opt
);
#define MY_I_S_MAYBE_NULL 1U
#define MY_I_S_UNSIGNED 2U
...
...
@@ -1943,10 +1944,10 @@ struct TABLE_LIST
Prepare TABLE_LIST that consists of one table instance to use in
open_and_lock_tables
*/
inline
void
init_one_table
(
const
LEX_CSTRING
*
db_arg
,
const
LEX_CSTRING
*
table_name_arg
,
const
LEX_CSTRING
*
alias_arg
,
enum
thr_lock_type
lock_type_arg
)
inline
void
init_one_table
(
const
LEX_CSTRING
*
db_arg
,
const
LEX_CSTRING
*
table_name_arg
,
const
LEX_CSTRING
*
alias_arg
,
enum
thr_lock_type
lock_type_arg
)
{
bzero
((
char
*
)
this
,
sizeof
(
*
this
));
DBUG_ASSERT
(
!
db_arg
->
str
||
strlen
(
db_arg
->
str
)
==
db_arg
->
length
);
...
...
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