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
Show 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;
@@innodb_table_locks
0
1
drop table if exists t1;
set @@innodb_table_locks=1;
create table t1 (id integer, x integer) engine=INNODB;
insert into t1 values(0, 0);
...
...
@@ -25,24 +25,32 @@ id x
commit;
drop table t1;
set @@innodb_table_locks=0;
create table t1 (id integer, x integer) engine=INNODB;
insert into t1 values(0, 0);
set autocommit=0
;
create table t1 (id integer
primary key
, x integer) engine=INNODB;
insert into t1 values(0, 0)
,(1,1),(2,2)
;
commit
;
SELECT * from t1 where id = 0 FOR UPDATE;
id x
0 0
set autocommit=0;
set @@innodb_table_locks=0;
lock table t1 write;
update t1 set x=1
where id = 0
;
select * from t1
;
update t1 set x=1
0 where id = 2
;
SELECT * from t1 where id = 2
;
id x
0 1
2 2
UPDATE t1 set x=3 where id = 2;
commit;
update t1 set x=2 where id = 0;
SELECT * from t1;
id x
0 0
1 1
2 3
commit;
unlock tables;
commit;
select * from t1;
id x
0 2
commit;
0 0
1 1
2 10
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
connect
(
con1
,
localhost
,
root
,,);
connect
(
con2
,
localhost
,
root
,,);
drop
table
if
exists
t1
;
#
# Check and select innodb lock type
#
...
...
@@ -14,6 +10,14 @@ select @@innodb_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
;
connection
con1
;
...
...
@@ -48,37 +52,44 @@ commit;
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
;
create
table
t1
(
id
integer
,
x
integer
)
engine
=
INNODB
;
insert
into
t1
values
(
0
,
0
);
set
autocommit
=
0
;
create
table
t1
(
id
integer
primary
key
,
x
integer
)
engine
=
INNODB
;
insert
into
t1
values
(
0
,
0
)
,(
1
,
1
),(
2
,
2
)
;
commit
;
SELECT
*
from
t1
where
id
=
0
FOR
UPDATE
;
connection
con2
;
set
autocommit
=
0
;
set
@@
innodb_table_locks
=
0
;
# The following statement should hang because con1 is locking the page
--
send
# The following statement should work becase innodb doesn't check table locks
lock
table
t1
write
;
--
sleep
2
;
connection
con1
;
update
t1
set
x
=
1
where
id
=
0
;
select
*
from
t1
;
commit
;
# This will be locked by MySQL
--
send
update
t1
set
x
=
10
where
id
=
2
;
--
sleep
2
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
;
unlock
tables
;
connection
con1
;
select
*
from
t1
;
reap
;
commit
;
select
*
from
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)
!
lock
->
write_wait
.
data
&&
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 */
data
->
prev
=
lock
->
write
.
last
;
lock
->
write
.
last
=
&
data
->
next
;
...
...
@@ -568,6 +574,8 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
}
else
{
DBUG_PRINT
(
"info"
,
(
"write_wait.data: 0x%lx"
,
(
ulong
)
lock
->
write_wait
.
data
));
if
(
!
lock
->
write_wait
.
data
)
{
/* no scheduled write locks */
if
(
lock_type
==
TL_WRITE_CONCURRENT_INSERT
&&
...
...
sql/mysqld.cc
View file @
b32ffec8
...
...
@@ -3704,7 +3704,7 @@ struct my_option my_long_options[] =
"If Innodb should enforce LOCK TABLE"
,
(
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 */
{
"help"
,
'?'
,
"Display this help and exit"
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
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,
DBUG_RETURN
(
0
);
}
table
->
query_id
=
thd
->
query_id
;
DBUG_PRINT
(
"info"
,(
"Using temporary table"
));
goto
reset
;
}
}
...
...
@@ -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
;
DBUG_PRINT
(
"info"
,(
"Using locked table"
));
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