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
b32ffec8
Commit
b32ffec8
authored
Oct 20, 2004
by
monty@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test case for innodb-lock
parent
9f8d47d8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
32 deletions
+62
-32
mysql-test/r/innodb-lock.result
mysql-test/r/innodb-lock.result
+19
-11
mysql-test/t/innodb-lock-master.opt
mysql-test/t/innodb-lock-master.opt
+1
-0
mysql-test/t/innodb-lock.test
mysql-test/t/innodb-lock.test
+29
-18
mysys/thr_lock.c
mysys/thr_lock.c
+10
-2
sql/mysqld.cc
sql/mysqld.cc
+1
-1
sql/sql_base.cc
sql/sql_base.cc
+2
-0
No files found.
mysql-test/r/innodb-lock.result
View file @
b32ffec8
drop table if exists t1;
select @@innodb_table_locks;
select @@innodb_table_locks;
@@innodb_table_locks
@@innodb_table_locks
0
1
drop table if exists t1;
set @@innodb_table_locks=1;
set @@innodb_table_locks=1;
create table t1 (id integer, x integer) engine=INNODB;
create table t1 (id integer, x integer) engine=INNODB;
insert into t1 values(0, 0);
insert into t1 values(0, 0);
...
@@ -25,24 +25,32 @@ id x
...
@@ -25,24 +25,32 @@ id x
commit;
commit;
drop table t1;
drop table t1;
set @@innodb_table_locks=0;
set @@innodb_table_locks=0;
create table t1 (id integer, x integer) engine=INNODB;
create table t1 (id integer
primary key
, x integer) engine=INNODB;
insert into t1 values(0, 0);
insert into t1 values(0, 0)
,(1,1),(2,2)
;
set autocommit=0
;
commit
;
SELECT * from t1 where id = 0 FOR UPDATE;
SELECT * from t1 where id = 0 FOR UPDATE;
id x
id x
0 0
0 0
set autocommit=0;
set autocommit=0;
set @@innodb_table_locks=0;
lock table t1 write;
lock table t1 write;
update t1 set x=1
where id = 0
;
update t1 set x=1
0 where id = 2
;
select * from t1
;
SELECT * from t1 where id = 2
;
id x
id x
0 1
2 2
UPDATE t1 set x=3 where id = 2;
commit;
commit;
update t1 set x=2 where id = 0;
SELECT * from t1;
id x
0 0
1 1
2 3
commit;
commit;
unlock tables;
unlock tables;
commit;
select * from t1;
select * from t1;
id x
id x
0 2
0 0
commit;
1 1
2 10
drop table t1;
drop table t1;
mysql-test/t/innodb-lock-master.opt
0 → 100644
View file @
b32ffec8
--innodb-table-lock=1
mysql-test/t/innodb-lock.test
View file @
b32ffec8
--
source
include
/
have_innodb
.
inc
--
source
include
/
have_innodb
.
inc
connect
(
con1
,
localhost
,
root
,,);
connect
(
con2
,
localhost
,
root
,,);
drop
table
if
exists
t1
;
#
#
# Check and select innodb lock type
# Check and select innodb lock type
#
#
...
@@ -14,6 +10,14 @@ select @@innodb_table_locks;
...
@@ -14,6 +10,14 @@ select @@innodb_table_locks;
# Testing of explicit table locks with enforced table locks
# Testing of explicit table locks with enforced table locks
#
#
connect
(
con1
,
localhost
,
root
,,);
connect
(
con2
,
localhost
,
root
,,);
drop
table
if
exists
t1
;
#
# Testing of explicit table locks with enforced table locks
#
set
@@
innodb_table_locks
=
1
;
set
@@
innodb_table_locks
=
1
;
connection
con1
;
connection
con1
;
...
@@ -48,37 +52,44 @@ commit;
...
@@ -48,37 +52,44 @@ commit;
drop
table
t1
;
drop
table
t1
;
#
#
# Try with old lock method (where LOCK TABLE is ignored)
# Try with old lock method (where LOCK TABLE is ignored
by InnoDB
)
#
#
set
@@
innodb_table_locks
=
0
;
set
@@
innodb_table_locks
=
0
;
create
table
t1
(
id
integer
,
x
integer
)
engine
=
INNODB
;
create
table
t1
(
id
integer
primary
key
,
x
integer
)
engine
=
INNODB
;
insert
into
t1
values
(
0
,
0
);
insert
into
t1
values
(
0
,
0
)
,(
1
,
1
),(
2
,
2
)
;
set
autocommit
=
0
;
commit
;
SELECT
*
from
t1
where
id
=
0
FOR
UPDATE
;
SELECT
*
from
t1
where
id
=
0
FOR
UPDATE
;
connection
con2
;
connection
con2
;
set
autocommit
=
0
;
set
autocommit
=
0
;
set
@@
innodb_table_locks
=
0
;
# The following statement should hang because con1 is locking the page
# The following statement should work becase innodb doesn't check table locks
--
send
lock
table
t1
write
;
lock
table
t1
write
;
--
sleep
2
;
connection
con1
;
connection
con1
;
update
t1
set
x
=
1
where
id
=
0
;
select
*
from
t1
;
# This will be locked by MySQL
commit
;
--
send
update
t1
set
x
=
10
where
id
=
2
;
--
sleep
2
connection
con2
;
connection
con2
;
reap
;
update
t1
set
x
=
2
where
id
=
0
;
# Note that we will get a deadlock if we try to select any rows marked
# for update by con1 !
SELECT
*
from
t1
where
id
=
2
;
UPDATE
t1
set
x
=
3
where
id
=
2
;
commit
;
SELECT
*
from
t1
;
commit
;
commit
;
unlock
tables
;
unlock
tables
;
connection
con1
;
connection
con1
;
select
*
from
t1
;
reap
;
commit
;
commit
;
select
*
from
t1
;
drop
table
t1
;
drop
table
t1
;
mysys/thr_lock.c
View file @
b32ffec8
...
@@ -552,8 +552,14 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
...
@@ -552,8 +552,14 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
!
lock
->
write_wait
.
data
&&
!
lock
->
write_wait
.
data
&&
lock
->
write
.
data
->
type
==
TL_WRITE_ALLOW_WRITE
))
lock
->
write
.
data
->
type
==
TL_WRITE_ALLOW_WRITE
))
{
{
/* We have already got a write lock or all locks are
/*
TL_WRITE_ALLOW_WRITE */
We have already got a write lock or all locks are
TL_WRITE_ALLOW_WRITE
*/
DBUG_PRINT
(
"info"
,
(
"write_wait.data: 0x%lx old_type: %d"
,
(
ulong
)
lock
->
write_wait
.
data
,
lock
->
write
.
data
->
type
));
(
*
lock
->
write
.
last
)
=
data
;
/* Add to running fifo */
(
*
lock
->
write
.
last
)
=
data
;
/* Add to running fifo */
data
->
prev
=
lock
->
write
.
last
;
data
->
prev
=
lock
->
write
.
last
;
lock
->
write
.
last
=
&
data
->
next
;
lock
->
write
.
last
=
&
data
->
next
;
...
@@ -568,6 +574,8 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
...
@@ -568,6 +574,8 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
}
}
else
else
{
{
DBUG_PRINT
(
"info"
,
(
"write_wait.data: 0x%lx"
,
(
ulong
)
lock
->
write_wait
.
data
));
if
(
!
lock
->
write_wait
.
data
)
if
(
!
lock
->
write_wait
.
data
)
{
/* no scheduled write locks */
{
/* no scheduled write locks */
if
(
lock_type
==
TL_WRITE_CONCURRENT_INSERT
&&
if
(
lock_type
==
TL_WRITE_CONCURRENT_INSERT
&&
...
...
sql/mysqld.cc
View file @
b32ffec8
...
@@ -3704,7 +3704,7 @@ struct my_option my_long_options[] =
...
@@ -3704,7 +3704,7 @@ struct my_option my_long_options[] =
"If Innodb should enforce LOCK TABLE"
,
"If Innodb should enforce LOCK TABLE"
,
(
gptr
*
)
&
global_system_variables
.
innodb_table_locks
,
(
gptr
*
)
&
global_system_variables
.
innodb_table_locks
,
(
gptr
*
)
&
global_system_variables
.
innodb_table_locks
,
(
gptr
*
)
&
global_system_variables
.
innodb_table_locks
,
0
,
GET_BOOL
,
OPT_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
0
,
GET_BOOL
,
OPT_ARG
,
1
,
0
,
0
,
0
,
0
,
0
},
#endif
/* End HAVE_INNOBASE_DB */
#endif
/* End HAVE_INNOBASE_DB */
{
"help"
,
'?'
,
"Display this help and exit"
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
{
"help"
,
'?'
,
"Display this help and exit"
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
0
,
0
,
0
,
0
,
0
},
...
...
sql/sql_base.cc
View file @
b32ffec8
...
@@ -826,6 +826,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
...
@@ -826,6 +826,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
table
->
query_id
=
thd
->
query_id
;
table
->
query_id
=
thd
->
query_id
;
DBUG_PRINT
(
"info"
,(
"Using temporary table"
));
goto
reset
;
goto
reset
;
}
}
}
}
...
@@ -840,6 +841,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
...
@@ -840,6 +841,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
table
->
query_id
!=
thd
->
query_id
)
table
->
query_id
!=
thd
->
query_id
)
{
{
table
->
query_id
=
thd
->
query_id
;
table
->
query_id
=
thd
->
query_id
;
DBUG_PRINT
(
"info"
,(
"Using locked table"
));
goto
reset
;
goto
reset
;
}
}
}
}
...
...
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