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
6e1dac8f
Commit
6e1dac8f
authored
Feb 23, 2012
by
Michael Widenius
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge
parents
567d871f
d395d251
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
182 additions
and
125 deletions
+182
-125
BUILD/SETUP.sh
BUILD/SETUP.sh
+1
-1
mysql-test/mysql-test-run.pl
mysql-test/mysql-test-run.pl
+2
-1
mysql-test/r/lock_multi.result
mysql-test/r/lock_multi.result
+1
-0
mysql-test/t/lock_multi.test
mysql-test/t/lock_multi.test
+1
-0
mysys/thr_lock.c
mysys/thr_lock.c
+30
-11
scripts/make_binary_distribution.sh
scripts/make_binary_distribution.sh
+5
-1
scripts/mysql_config.sh
scripts/mysql_config.sh
+1
-1
sql/lock.cc
sql/lock.cc
+132
-100
sql/mysql_priv.h
sql/mysql_priv.h
+3
-3
sql/sql_base.cc
sql/sql_base.cc
+5
-6
sql/sql_handler.cc
sql/sql_handler.cc
+1
-1
No files found.
BUILD/SETUP.sh
View file @
6e1dac8f
...
@@ -178,7 +178,7 @@ base_configs="--prefix=$prefix --enable-assembler "
...
@@ -178,7 +178,7 @@ base_configs="--prefix=$prefix --enable-assembler "
base_configs
=
"
$base_configs
--with-extra-charsets=complex "
base_configs
=
"
$base_configs
--with-extra-charsets=complex "
base_configs
=
"
$base_configs
--enable-thread-safe-client "
base_configs
=
"
$base_configs
--enable-thread-safe-client "
base_configs
=
"
$base_configs
--with-big-tables"
base_configs
=
"
$base_configs
--with-big-tables"
base_configs
=
"
$base_configs
--with-plugin-aria --with-aria-tmp-tables
--without-plugin-innodb_plugin
"
base_configs
=
"
$base_configs
--with-plugin-aria --with-aria-tmp-tables"
# Compile our client programs with static libraries to allow them to be moved
# Compile our client programs with static libraries to allow them to be moved
base_configs
=
"
$base_configs
--with-mysqld-ldflags=-static --with-client-ldflags=-static"
base_configs
=
"
$base_configs
--with-mysqld-ldflags=-static --with-client-ldflags=-static"
...
...
mysql-test/mysql-test-run.pl
View file @
6e1dac8f
...
@@ -2518,7 +2518,8 @@ sub setup_vardir() {
...
@@ -2518,7 +2518,8 @@ sub setup_vardir() {
else
else
{
{
# hm, what paths work for debs and for rpms ?
# hm, what paths work for debs and for rpms ?
for
(
<
$bindir
/lib/m
ysql
/plugin/
*.
so
>
,
for
(
<
$bindir
/lib64/m
ysql
/plugin/
*.
so
>
,
<
$bindir
/lib/m
ysql
/plugin/
*.
so
>
,
<
$bindir
/lib/plugin
/*.
dll
>
)
<
$bindir
/lib/plugin
/*.
dll
>
)
{
{
my
$pname
=
basename
(
$_
);
my
$pname
=
basename
(
$_
);
...
...
mysql-test/r/lock_multi.result
View file @
6e1dac8f
drop table if exists t1,t2;
drop table if exists t1,t2;
drop DATABASE if exists mysqltest_1;
create table t1(n int);
create table t1(n int);
insert into t1 values (1);
insert into t1 values (1);
lock tables t1 write;
lock tables t1 write;
...
...
mysql-test/t/lock_multi.test
View file @
6e1dac8f
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
--
disable_warnings
--
disable_warnings
drop
table
if
exists
t1
,
t2
;
drop
table
if
exists
t1
,
t2
;
drop
DATABASE
if
exists
mysqltest_1
;
--
enable_warnings
--
enable_warnings
# Test to see if select will get the lock ahead of low priority update
# Test to see if select will get the lock ahead of low priority update
...
...
mysys/thr_lock.c
View file @
6e1dac8f
...
@@ -168,7 +168,8 @@ thr_lock_owner_equal(THR_LOCK_OWNER *rhs, THR_LOCK_OWNER *lhs)
...
@@ -168,7 +168,8 @@ thr_lock_owner_equal(THR_LOCK_OWNER *rhs, THR_LOCK_OWNER *lhs)
static
uint
found_errors
=
0
;
static
uint
found_errors
=
0
;
static
int
check_lock
(
struct
st_lock_list
*
list
,
const
char
*
lock_type
,
static
int
check_lock
(
struct
st_lock_list
*
list
,
const
char
*
lock_type
,
const
char
*
where
,
my_bool
same_owner
,
my_bool
no_cond
)
const
char
*
where
,
my_bool
same_owner
,
my_bool
no_cond
,
my_bool
read_lock
)
{
{
THR_LOCK_DATA
*
data
,
**
prev
;
THR_LOCK_DATA
*
data
,
**
prev
;
uint
count
=
0
;
uint
count
=
0
;
...
@@ -181,6 +182,23 @@ static int check_lock(struct st_lock_list *list, const char* lock_type,
...
@@ -181,6 +182,23 @@ static int check_lock(struct st_lock_list *list, const char* lock_type,
for
(
data
=
list
->
data
;
data
&&
count
++
<
MAX_LOCKS
;
data
=
data
->
next
)
for
(
data
=
list
->
data
;
data
&&
count
++
<
MAX_LOCKS
;
data
=
data
->
next
)
{
{
if
(
data
->
type
==
TL_UNLOCK
)
{
fprintf
(
stderr
,
"Warning: Found unlocked lock at %s: %s
\n
"
,
lock_type
,
where
);
return
1
;
}
if
((
read_lock
&&
data
->
type
>
TL_READ_NO_INSERT
)
||
(
!
read_lock
&&
data
->
type
<=
TL_READ_NO_INSERT
))
{
fprintf
(
stderr
,
"Warning: Found %s lock in %s queue at %s: %s
\n
"
,
read_lock
?
"write"
:
"read"
,
read_lock
?
"read"
:
"write"
,
lock_type
,
where
);
return
1
;
}
if
(
data
->
type
!=
last_lock_type
)
if
(
data
->
type
!=
last_lock_type
)
last_lock_type
=
TL_IGNORE
;
last_lock_type
=
TL_IGNORE
;
if
(
data
->
prev
!=
prev
)
if
(
data
->
prev
!=
prev
)
...
@@ -237,11 +255,14 @@ static void check_locks(THR_LOCK *lock, const char *where,
...
@@ -237,11 +255,14 @@ static void check_locks(THR_LOCK *lock, const char *where,
if
(
found_errors
<
MAX_FOUND_ERRORS
)
if
(
found_errors
<
MAX_FOUND_ERRORS
)
{
{
if
(
check_lock
(
&
lock
->
write
,
"write"
,
where
,
1
,
1
)
|
if
(
check_lock
(
&
lock
->
write
,
"write"
,
where
,
1
,
1
,
0
)
|
check_lock
(
&
lock
->
write_wait
,
"write_wait"
,
where
,
0
,
0
)
|
check_lock
(
&
lock
->
write_wait
,
"write_wait"
,
where
,
0
,
0
,
0
)
|
check_lock
(
&
lock
->
read
,
"read"
,
where
,
0
,
1
)
|
check_lock
(
&
lock
->
read
,
"read"
,
where
,
0
,
1
,
1
)
|
check_lock
(
&
lock
->
read_wait
,
"read_wait"
,
where
,
0
,
0
))
check_lock
(
&
lock
->
read_wait
,
"read_wait"
,
where
,
0
,
0
,
1
))
{
DBUG_ASSERT
(
my_assert_on_error
==
0
);
found_errors
++
;
found_errors
++
;
}
if
(
found_errors
<
MAX_FOUND_ERRORS
)
if
(
found_errors
<
MAX_FOUND_ERRORS
)
{
{
...
@@ -592,18 +613,17 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
...
@@ -592,18 +613,17 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
static
enum
enum_thr_lock_result
static
enum
enum_thr_lock_result
thr_lock
(
THR_LOCK_DATA
*
data
,
THR_LOCK_OWNER
*
owner
,
thr_lock
(
THR_LOCK_DATA
*
data
,
THR_LOCK_OWNER
*
owner
)
enum
thr_lock_type
lock_type
)
{
{
THR_LOCK
*
lock
=
data
->
lock
;
THR_LOCK
*
lock
=
data
->
lock
;
enum
enum_thr_lock_result
result
=
THR_LOCK_SUCCESS
;
enum
enum_thr_lock_result
result
=
THR_LOCK_SUCCESS
;
struct
st_lock_list
*
wait_queue
;
struct
st_lock_list
*
wait_queue
;
THR_LOCK_DATA
*
lock_owner
;
THR_LOCK_DATA
*
lock_owner
;
enum
thr_lock_type
lock_type
=
data
->
type
;
DBUG_ENTER
(
"thr_lock"
);
DBUG_ENTER
(
"thr_lock"
);
data
->
next
=
0
;
data
->
next
=
0
;
data
->
cond
=
0
;
/* safety */
data
->
cond
=
0
;
/* safety */
data
->
type
=
lock_type
;
data
->
owner
=
owner
;
/* Must be reset ! */
data
->
owner
=
owner
;
/* Must be reset ! */
data
->
priority
&=
~
THR_LOCK_LATE_PRIV
;
data
->
priority
&=
~
THR_LOCK_LATE_PRIV
;
VOID
(
pthread_mutex_lock
(
&
lock
->
mutex
));
VOID
(
pthread_mutex_lock
(
&
lock
->
mutex
));
...
@@ -912,9 +932,7 @@ void thr_unlock(THR_LOCK_DATA *data, uint unlock_flags)
...
@@ -912,9 +932,7 @@ void thr_unlock(THR_LOCK_DATA *data, uint unlock_flags)
if
(
lock_type
==
TL_READ_NO_INSERT
)
if
(
lock_type
==
TL_READ_NO_INSERT
)
lock
->
read_no_write_count
--
;
lock
->
read_no_write_count
--
;
data
->
type
=
TL_UNLOCK
;
/* Mark unlocked */
data
->
type
=
TL_UNLOCK
;
/* Mark unlocked */
check_locks
(
lock
,
"after releasing lock"
,
lock_type
,
1
);
wake_up_waiters
(
lock
);
wake_up_waiters
(
lock
);
check_locks
(
lock
,
"end of thr_unlock"
,
lock_type
,
1
);
pthread_mutex_unlock
(
&
lock
->
mutex
);
pthread_mutex_unlock
(
&
lock
->
mutex
);
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
@@ -934,6 +952,7 @@ static void wake_up_waiters(THR_LOCK *lock)
...
@@ -934,6 +952,7 @@ static void wake_up_waiters(THR_LOCK *lock)
enum
thr_lock_type
lock_type
;
enum
thr_lock_type
lock_type
;
DBUG_ENTER
(
"wake_up_waiters"
);
DBUG_ENTER
(
"wake_up_waiters"
);
check_locks
(
lock
,
"before waking up waiters"
,
TL_UNLOCK
,
1
);
if
(
!
lock
->
write
.
data
)
/* If no active write locks */
if
(
!
lock
->
write
.
data
)
/* If no active write locks */
{
{
data
=
lock
->
write_wait
.
data
;
data
=
lock
->
write_wait
.
data
;
...
@@ -1087,7 +1106,7 @@ thr_multi_lock(THR_LOCK_DATA **data, uint count, THR_LOCK_OWNER *owner)
...
@@ -1087,7 +1106,7 @@ thr_multi_lock(THR_LOCK_DATA **data, uint count, THR_LOCK_OWNER *owner)
/* lock everything */
/* lock everything */
for
(
pos
=
data
,
end
=
data
+
count
;
pos
<
end
;
pos
++
)
for
(
pos
=
data
,
end
=
data
+
count
;
pos
<
end
;
pos
++
)
{
{
enum
enum_thr_lock_result
result
=
thr_lock
(
*
pos
,
owner
,
(
*
pos
)
->
type
);
enum
enum_thr_lock_result
result
=
thr_lock
(
*
pos
,
owner
);
if
(
result
!=
THR_LOCK_SUCCESS
)
if
(
result
!=
THR_LOCK_SUCCESS
)
{
/* Aborted */
{
/* Aborted */
thr_multi_unlock
(
data
,(
uint
)
(
pos
-
data
),
0
);
thr_multi_unlock
(
data
,(
uint
)
(
pos
-
data
),
0
);
...
...
scripts/make_binary_distribution.sh
View file @
6e1dac8f
...
@@ -285,7 +285,8 @@ if [ x"$BASE_SYSTEM" != x"netware" ] ; then
...
@@ -285,7 +285,8 @@ if [ x"$BASE_SYSTEM" != x"netware" ] ; then
pkgplugindir
=
@pkgplugindir@
\
pkgplugindir
=
@pkgplugindir@
\
pkgsuppdir
=
@pkgsuppdir@
\
pkgsuppdir
=
@pkgsuppdir@
\
mandir
=
@mandir@
\
mandir
=
@mandir@
\
infodir
=
@infodir@
infodir
=
@infodir@
\
libexecdir
=
@prefix@/libexec
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Rename top directory, and set DEST to the new directory
# Rename top directory, and set DEST to the new directory
...
@@ -301,7 +302,10 @@ if [ x"$BASE_SYSTEM" != x"netware" ] ; then
...
@@ -301,7 +302,10 @@ if [ x"$BASE_SYSTEM" != x"netware" ] ; then
if
[
-z
"
$gcclib
"
]
;
then
if
[
-z
"
$gcclib
"
]
;
then
echo
"Warning: Compiler doesn't tell libgcc.a!"
echo
"Warning: Compiler doesn't tell libgcc.a!"
elif
[
-f
"
$gcclib
"
]
;
then
elif
[
-f
"
$gcclib
"
]
;
then
{
mkdir
-p
$DEST
/lib
$CP
$gcclib
$DEST
/lib/libmygcc.a
$CP
$gcclib
$DEST
/lib/libmygcc.a
}
else
else
echo
"Warning: Compiler result '
$gcclib
' not found / no file!"
echo
"Warning: Compiler result '
$gcclib
' not found / no file!"
fi
fi
...
...
scripts/mysql_config.sh
View file @
6e1dac8f
...
@@ -86,7 +86,7 @@ bindir='@bindir@'
...
@@ -86,7 +86,7 @@ bindir='@bindir@'
# If installed, search for the compiled in directory first (might be "lib64")
# If installed, search for the compiled in directory first (might be "lib64")
pkglibdir
=
'@pkglibdir@'
pkglibdir
=
'@pkglibdir@'
pkglibdir_rel
=
`
echo
$pkglibdir
|
sed
-e
"s;^
$basedir
/;;"
`
pkglibdir_rel
=
`
echo
$pkglibdir
|
sed
-e
"s;^
$basedir
/;;"
`
fix_path pkglibdir
$pkglibdir_rel
lib/mysql lib
fix_path pkglibdir
$pkglibdir_rel
lib
64/mysql lib64 lib
/mysql lib
plugindir
=
'@pkgplugindir@'
plugindir
=
'@pkgplugindir@'
...
...
sql/lock.cc
View file @
6e1dac8f
...
@@ -195,31 +195,33 @@ int mysql_lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags)
...
@@ -195,31 +195,33 @@ int mysql_lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags)
MYSQL_LOCK
*
mysql_lock_tables
(
THD
*
thd
,
TABLE
**
tables
,
uint
count
,
MYSQL_LOCK
*
mysql_lock_tables
(
THD
*
thd
,
TABLE
**
tables
,
uint
count
,
uint
flags
,
bool
*
need_reopen
)
uint
flags
,
bool
*
need_reopen
)
{
{
TABLE
*
write_lock_used
;
MYSQL_LOCK
*
sql_lock
;
MYSQL_LOCK
*
sql_lock
;
TABLE
*
write_lock_used
;
int
rc
;
DBUG_ENTER
(
"mysql_lock_tables(tables)"
);
DBUG_ENTER
(
"mysql_lock_tables(tables)"
);
*
need_reopen
=
FALSE
;
*
need_reopen
=
FALSE
;
if
(
mysql_lock_tables_check
(
thd
,
tables
,
count
,
flags
))
DBUG_RETURN
(
NULL
);
if
(
!
(
sql_lock
=
get_lock_data
(
thd
,
tables
,
count
,
GET_LOCK_STORE_LOCKS
,
if
(
mysql_lock_tables_check
(
thd
,
tables
,
count
,
flags
))
&
write_lock_used
))
||
DBUG_RETURN
(
NULL
);
!
sql_lock
->
table_count
)
DBUG_RETURN
(
sql_lock
);
if
(
mysql_lock_tables
(
thd
,
sql_lock
,
write_lock_used
!=
0
,
flags
,
for
(;;)
need_reopen
))
{
{
/* Clear the lock type of all lock data to avoid reusage. */
if
(
!
(
sql_lock
=
get_lock_data
(
thd
,
tables
,
count
,
GET_LOCK_STORE_LOCKS
,
reset_lock_data
(
sql_lock
,
1
);
&
write_lock_used
))
||
!
sql_lock
->
table_count
)
break
;
rc
=
mysql_lock_tables
(
thd
,
sql_lock
,
write_lock_used
!=
0
,
flags
,
need_reopen
);
if
(
!
rc
)
break
;
// Got lock
my_free
(
sql_lock
,
MYF
(
0
));
my_free
(
sql_lock
,
MYF
(
0
));
sql_lock
=
0
;
if
(
rc
>
0
)
DBUG_RETURN
(
0
);
// Failed
}
}
DBUG_RETURN
(
sql_lock
);
DBUG_RETURN
(
sql_lock
);
}
}
/**
/**
Lock a table based on a MYSQL_LOCK structure.
Lock a table based on a MYSQL_LOCK structure.
...
@@ -232,120 +234,150 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
...
@@ -232,120 +234,150 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
@param need_reopen Out parameter, TRUE if some tables were altered
@param need_reopen Out parameter, TRUE if some tables were altered
or deleted and should be reopened by caller.
or deleted and should be reopened by caller.
@return 0 ok
@return 0 ok
@return 1 error
@return 1 fatal error
@return -1 retry
*/
*/
bool
mysql_lock_tables
(
THD
*
thd
,
MYSQL_LOCK
*
sql_lock
,
int
mysql_lock_tables
(
THD
*
thd
,
MYSQL_LOCK
*
sql_lock
,
bool
write_lock_used
,
bool
write_lock_used
,
uint
flags
,
bool
*
need_reopen
)
uint
flags
,
bool
*
need_reopen
)
{
{
int
res
=
0
;
int
rc
;
int
rc
;
bool
error
=
1
;
DBUG_ENTER
(
"mysql_lock_tables(sql_lock)"
);
DBUG_ENTER
(
"mysql_lock_tables(sql_lock)"
);
*
need_reopen
=
FALSE
;
*
need_reopen
=
FALSE
;
for
(;;)
if
(
write_lock_used
&&
!
(
flags
&
MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK
))
{
{
if
(
write_lock_used
&&
!
(
flags
&
MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK
)
)
if
(
global_read_lock
)
{
{
if
(
global_read_lock
)
/*
Someone has issued LOCK ALL TABLES FOR READ and we want a write lock
Wait until the lock is gone
*/
if
(
wait_if_global_read_lock
(
thd
,
1
,
1
))
{
{
/*
/* Clear the lock type of all lock data to avoid reusage. */
Someone has issued LOCK ALL TABLES FOR READ and we want a write lock
reset_lock_data
(
sql_lock
,
1
);
Wait until the lock is gone
DBUG_RETURN
(
1
);
// Fatal error
*/
if
(
wait_if_global_read_lock
(
thd
,
1
,
1
))
break
;
if
(
thd
->
version
!=
refresh_version
)
goto
retry
;
}
}
if
(
thd
->
version
!=
refresh_version
)
if
(
opt_readonly
&&
!
(
thd
->
security_ctx
->
master_access
&
SUPER_ACL
)
&&
!
thd
->
slave_thread
)
{
{
/*
/* Clear the lock type of all lock data to avoid reusage. */
Someone has issued SET GLOBAL READ_ONLY=1 and we want a write lock.
reset_lock_data
(
sql_lock
,
1
);
We do not wait for READ_ONLY=0, and fail.
goto
retry
;
*/
my_error
(
ER_OPTION_PREVENTS_STATEMENT
,
MYF
(
0
),
"--read-only"
);
break
;
}
}
}
}
thd_proc_info
(
thd
,
"System lock"
);
if
(
opt_readonly
&&
if
(
lock_external
(
thd
,
sql_lock
->
table
,
sql_lock
->
table_count
))
!
(
thd
->
security_ctx
->
master_access
&
SUPER_ACL
)
&&
break
;
!
thd
->
slave_thread
)
thd_proc_info
(
thd
,
"Table lock"
);
/* Copy the lock data array. thr_multi_lock() reorders its contens. */
memcpy
(
sql_lock
->
locks
+
sql_lock
->
lock_count
,
sql_lock
->
locks
,
sql_lock
->
lock_count
*
sizeof
(
*
sql_lock
->
locks
));
/* Lock on the copied half of the lock data array. */
rc
=
thr_lock_errno_to_mysql
[(
int
)
thr_multi_lock
(
sql_lock
->
locks
+
sql_lock
->
lock_count
,
sql_lock
->
lock_count
,
thd
->
lock_id
)];
if
(
rc
)
/* Locking failed */
{
{
/*
Someone has issued SET GLOBAL READ_ONLY=1 and we want a write lock.
We do not wait for READ_ONLY=0, and fail.
*/
my_error
(
ER_OPTION_PREVENTS_STATEMENT
,
MYF
(
0
),
"--read-only"
);
reset_lock_data
(
sql_lock
,
1
);
DBUG_RETURN
(
1
);
// Fatal error
}
}
thd_proc_info
(
thd
,
"System lock"
);
if
(
lock_external
(
thd
,
sql_lock
->
table
,
sql_lock
->
table_count
))
{
/* Clear the lock type of all lock data to avoid reusage. */
res
=
1
;
// Fatal error
goto
end
;
}
thd_proc_info
(
thd
,
"Table lock"
);
DBUG_PRINT
(
"info"
,
(
"thd->proc_info %s"
,
thd
->
proc_info
));
/* Copy the lock data array. thr_multi_lock() reorders its contens. */
memcpy
(
sql_lock
->
locks
+
sql_lock
->
lock_count
,
sql_lock
->
locks
,
sql_lock
->
lock_count
*
sizeof
(
*
sql_lock
->
locks
));
/* Lock on the copied half of the lock data array. */
rc
=
thr_lock_errno_to_mysql
[(
int
)
thr_multi_lock
(
sql_lock
->
locks
+
sql_lock
->
lock_count
,
sql_lock
->
lock_count
,
thd
->
lock_id
)];
if
(
rc
)
// Locking failed
{
if
(
sql_lock
->
table_count
)
VOID
(
unlock_external
(
thd
,
sql_lock
->
table
,
sql_lock
->
table_count
));
VOID
(
unlock_external
(
thd
,
sql_lock
->
table
,
sql_lock
->
table_count
));
if
(
rc
>
1
)
{
/*
/* a timeout or a deadlock */
reset_lock_data is required here. If thr_multi_lock fails it
my_error
(
rc
,
MYF
(
0
));
resets lock type for tables, which were locked before (and
break
;
including) one that caused error. Lock type for other tables
}
preserved.
/* We where aborted and should try again from upper level*/
*/
thd
->
some_tables_deleted
=
1
;
reset_lock_data
(
sql_lock
,
0
);
if
(
rc
>
1
)
{
my_error
(
rc
,
MYF
(
0
));
DBUG_RETURN
(
1
);
}
}
else
DBUG_ASSERT
(
rc
==
1
);
// Timeout
thd
->
some_tables_deleted
=
1
;
// Reopen tables
sql_lock
->
lock_count
=
0
;
// Locks are already freed
/* Retry */
}
else
{
/*
Lock worked. Now check that nothing happend while we where waiting
to get the lock that would require us to free it.
*/
if
(
!
thd
->
some_tables_deleted
||
(
flags
&
MYSQL_LOCK_IGNORE_FLUSH
))
{
res
=
0
;
goto
end
;
/* Lock was not aborted. Return to upper level */
}
if
(
!
thd
->
open_tables
&&
!
(
flags
&
MYSQL_LOCK_NOT_TEMPORARY
))
{
{
/*
/*
Lock worked. Now check that nothing happend while we where waiting
Only using temporary tables, no need to unlock.
to get the lock that would require us to free it.
We need the flag as open_tables is not enough to distingush if
*/
we are only using temporary tables for tables used trough
error
=
0
;
the HANDLER interface.
if
(
!
thd
->
some_tables_deleted
||
(
flags
&
MYSQL_LOCK_IGNORE_FLUSH
))
{
/*
Table was not signaled for deletion or we don't care if it was.
Return with table as locked.
*/
break
;
}
else
if
(
!
thd
->
open_tables
&&
!
(
flags
&
MYSQL_LOCK_NOT_TEMPORARY
))
{
/*
Only using temporary tables, no need to unlock.
We need the flag as open_tables is not enough to distingush if
we are only using temporary tables for tables used trough
the HANDLER interface.
We reset some_tables_deleted as it doesn't make sense to have this
We reset some_tables_deleted as it doesn't make sense to have this
one when we are only using temporary tables.
one when we are only using temporary tables.
*/
*/
thd
->
some_tables_deleted
=
0
;
thd
->
some_tables_deleted
=
0
;
break
;
goto
end
;
}
/* some table was altered or deleted. reopen tables marked deleted */
error
=
1
;
mysql_unlock_tables
(
thd
,
sql_lock
,
0
);
}
}
/* Free lock and retry */
}
/* some table was altered or deleted. reopen tables marked deleted */
mysql_unlock_tables
(
thd
,
sql_lock
,
0
);
retry:
retry:
if
(
flags
&
MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN
)
res
=
-
1
;
// Retry
{
if
(
flags
&
MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN
)
*
need_reopen
=
TRUE
;
{
break
;
*
need_reopen
=
TRUE
;
// Upper level will retry
}
DBUG_RETURN
(
1
);
// Fatal error
if
(
wait_for_tables
(
thd
))
break
;
// Couldn't open tables
reset_lock_data
(
sql_lock
,
0
);
// Set org locks and retry
}
}
if
(
wait_for_tables
(
thd
))
res
=
1
;
// Couldn't open tables
end:
thd_proc_info
(
thd
,
0
);
thd_proc_info
(
thd
,
0
);
if
(
thd
->
killed
)
{
thd
->
send_kill_message
();
if
(
res
==
0
)
mysql_unlock_tables
(
thd
,
sql_lock
,
0
);
else
reset_lock_data
(
sql_lock
,
1
);
res
=
1
;
// Fatal
}
thd
->
set_time_after_lock
();
thd
->
set_time_after_lock
();
DBUG_RETURN
(
error
);
DBUG_RETURN
(
res
);
}
}
...
...
sql/mysql_priv.h
View file @
6e1dac8f
...
@@ -2347,9 +2347,9 @@ extern struct st_VioSSLFd * ssl_acceptor_fd;
...
@@ -2347,9 +2347,9 @@ extern struct st_VioSSLFd * ssl_acceptor_fd;
MYSQL_LOCK
*
mysql_lock_tables
(
THD
*
thd
,
TABLE
**
table
,
uint
count
,
MYSQL_LOCK
*
mysql_lock_tables
(
THD
*
thd
,
TABLE
**
table
,
uint
count
,
uint
flags
,
bool
*
need_reopen
);
uint
flags
,
bool
*
need_reopen
);
bool
mysql_lock_tables
(
THD
*
thd
,
MYSQL_LOCK
*
sql_lock
,
int
mysql_lock_tables
(
THD
*
thd
,
MYSQL_LOCK
*
sql_lock
,
bool
write_lock_used
,
bool
write_lock_used
,
uint
flags
,
bool
*
need_reopen
);
uint
flags
,
bool
*
need_reopen
);
/* mysql_lock_tables() and open_table() flags bits */
/* mysql_lock_tables() and open_table() flags bits */
#define MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK 0x0001
#define MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK 0x0001
...
...
sql/sql_base.cc
View file @
6e1dac8f
...
@@ -9606,13 +9606,12 @@ open_performance_schema_table(THD *thd, TABLE_LIST *one_table,
...
@@ -9606,13 +9606,12 @@ open_performance_schema_table(THD *thd, TABLE_LIST *one_table,
else
else
{
{
/*
/*
If error in mysql_lock_tables(), open_ltable doesn't close the
This can happen during a thd->kill or while we are trying to log
table. Thread kill during mysql_lock_tables() is such error. But
data for a stored procedure/trigger and someone causes the table
open tables cannot be accepted when restoring the open tables
to be flushed (for example by creating a new trigger for the
state.
table)
*/
*/
if
(
thd
->
killed
)
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
thd
->
restore_backup_open_tables_state
(
backup
);
thd
->
restore_backup_open_tables_state
(
backup
);
}
}
...
...
sql/sql_handler.cc
View file @
6e1dac8f
...
@@ -676,7 +676,7 @@ retry:
...
@@ -676,7 +676,7 @@ retry:
/* save open_tables state */
/* save open_tables state */
if
(
handler
->
lock
->
lock_count
>
0
)
if
(
handler
->
lock
->
lock_count
>
0
)
{
{
bool
lock_error
;
int
lock_error
;
handler
->
lock
->
locks
[
0
]
->
type
=
handler
->
lock
->
locks
[
0
]
->
org_type
;
handler
->
lock
->
locks
[
0
]
->
type
=
handler
->
lock
->
locks
[
0
]
->
org_type
;
lock_error
=
mysql_lock_tables
(
thd
,
handler
->
lock
,
0
,
lock_error
=
mysql_lock_tables
(
thd
,
handler
->
lock
,
0
,
...
...
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