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
384efc44
Commit
384efc44
authored
Apr 18, 2005
by
jan@hundin.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug: deadlock without any locking, simple select and update (Bug #7975).
Backported from 5.0.3.
parent
39f412d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
22 deletions
+38
-22
innobase/row/row0ins.c
innobase/row/row0ins.c
+23
-18
sql/ha_innodb.cc
sql/ha_innodb.cc
+15
-4
No files found.
innobase/row/row0ins.c
View file @
384efc44
...
@@ -51,14 +51,19 @@ innobase_invalidate_query_cache(
...
@@ -51,14 +51,19 @@ innobase_invalidate_query_cache(
chars count */
chars count */
/**********************************************************************
/**********************************************************************
This function returns true if SQL-query in the current thread
This function returns true if
1) SQL-query in the current thread
is either REPLACE or LOAD DATA INFILE REPLACE.
is either REPLACE or LOAD DATA INFILE REPLACE.
2) SQL-query in the current thread
is INSERT ON DUPLICATE KEY UPDATE.
NOTE that /mysql/innobase/row/row0ins.c must contain the
NOTE that /mysql/innobase/row/row0ins.c must contain the
prototype for this function ! */
prototype for this function ! */
ibool
ibool
innobase_query_is_replace
(
void
);
innobase_query_is_update
(
void
);
/*===========================*/
/*************************************************************************
/*************************************************************************
Creates an insert node struct. */
Creates an insert node struct. */
...
@@ -1562,12 +1567,12 @@ row_ins_scan_sec_index_for_duplicate(
...
@@ -1562,12 +1567,12 @@ row_ins_scan_sec_index_for_duplicate(
trx
=
thr_get_trx
(
thr
);
trx
=
thr_get_trx
(
thr
);
ut_ad
(
trx
);
ut_ad
(
trx
);
if
(
innobase_query_is_
replac
e
())
{
if
(
innobase_query_is_
updat
e
())
{
/*
The manual defines the REPLACE semantics that it
/*
If the SQL-query will update or replace
is either an INSERT or DELETE(s) for duplicate key
duplicate key we will take X-lock for
+ INSERT. Therefore, we should take X-lock for
duplicates ( REPLACE, LOAD DATAFILE REPLACE,
duplicates
*/
INSERT ON DUPLICATE KEY UPDATE).
*/
err
=
row_ins_set_exclusive_rec_lock
(
err
=
row_ins_set_exclusive_rec_lock
(
LOCK_ORDINARY
,
rec
,
index
,
thr
);
LOCK_ORDINARY
,
rec
,
index
,
thr
);
...
@@ -1675,12 +1680,12 @@ row_ins_duplicate_error_in_clust(
...
@@ -1675,12 +1680,12 @@ row_ins_duplicate_error_in_clust(
sure that in roll-forward we get the same duplicate
sure that in roll-forward we get the same duplicate
errors as in original execution */
errors as in original execution */
if
(
innobase_query_is_
replac
e
())
{
if
(
innobase_query_is_
updat
e
())
{
/*
The manual defines the REPLACE semantics
/*
If the SQL-query will update or replace
that it is either an INSERT or DELETE(s)
duplicate key we will take X-lock for
for duplicate key + INSERT. Therefore, we
duplicates ( REPLACE, LOAD DATAFILE REPLACE,
should take X-lock for duplicates
*/
INSERT ON DUPLICATE KEY UPDATE).
*/
err
=
row_ins_set_exclusive_rec_lock
(
err
=
row_ins_set_exclusive_rec_lock
(
LOCK_REC_NOT_GAP
,
rec
,
cursor
->
index
,
LOCK_REC_NOT_GAP
,
rec
,
cursor
->
index
,
...
@@ -1713,12 +1718,12 @@ row_ins_duplicate_error_in_clust(
...
@@ -1713,12 +1718,12 @@ row_ins_duplicate_error_in_clust(
if
(
rec
!=
page_get_supremum_rec
(
page
))
{
if
(
rec
!=
page_get_supremum_rec
(
page
))
{
/* The manual defines the REPLACE semantics that it
if
(
innobase_query_is_update
())
{
is either an INSERT or DELETE(s) for duplicate key
+ INSERT. Therefore, we should take X-lock for
duplicates. */
if
(
innobase_query_is_replace
())
{
/* If the SQL-query will update or replace
duplicate key we will take X-lock for
duplicates ( REPLACE, LOAD DATAFILE REPLACE,
INSERT ON DUPLICATE KEY UPDATE). */
err
=
row_ins_set_exclusive_rec_lock
(
err
=
row_ins_set_exclusive_rec_lock
(
LOCK_REC_NOT_GAP
,
LOCK_REC_NOT_GAP
,
...
...
sql/ha_innodb.cc
View file @
384efc44
...
@@ -5653,13 +5653,19 @@ innobase_get_at_most_n_mbchars(
...
@@ -5653,13 +5653,19 @@ innobase_get_at_most_n_mbchars(
extern
"C"
{
extern
"C"
{
/**********************************************************************
/**********************************************************************
This function returns true if SQL-query in the current thread
This function returns true if
1) SQL-query in the current thread
is either REPLACE or LOAD DATA INFILE REPLACE.
is either REPLACE or LOAD DATA INFILE REPLACE.
2) SQL-query in the current thread
is INSERT ON DUPLICATE KEY UPDATE.
NOTE that /mysql/innobase/row/row0ins.c must contain the
NOTE that /mysql/innobase/row/row0ins.c must contain the
prototype for this function ! */
prototype for this function ! */
ibool
ibool
innobase_query_is_
replac
e
(
void
)
innobase_query_is_
updat
e
(
void
)
/*===========================*/
/*===========================*/
{
{
THD
*
thd
;
THD
*
thd
;
...
@@ -5671,9 +5677,14 @@ innobase_query_is_replace(void)
...
@@ -5671,9 +5677,14 @@ innobase_query_is_replace(void)
(
thd
->
lex
->
sql_command
==
SQLCOM_LOAD
&&
(
thd
->
lex
->
sql_command
==
SQLCOM_LOAD
&&
thd
->
lex
->
duplicates
==
DUP_REPLACE
))
{
thd
->
lex
->
duplicates
==
DUP_REPLACE
))
{
return
true
;
return
true
;
}
else
{
return
false
;
}
}
if
(
thd
->
lex
->
sql_command
==
SQLCOM_INSERT
&&
thd
->
lex
->
duplicates
==
DUP_UPDATE
)
{
return
true
;
}
return
false
;
}
}
}
}
...
...
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