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
e4cd7e98
Commit
e4cd7e98
authored
Jun 12, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/autopush/B28992-5.0-opt
parents
e43380e8
030bb02b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
24 deletions
+53
-24
mysql-test/r/trigger.result
mysql-test/r/trigger.result
+9
-6
mysql-test/t/trigger.test
mysql-test/t/trigger.test
+16
-5
sql/item_func.cc
sql/item_func.cc
+28
-13
No files found.
mysql-test/r/trigger.result
View file @
e4cd7e98
...
...
@@ -1454,19 +1454,22 @@ CREATE TABLE t2 (id INTEGER);
INSERT INTO t2 VALUES (1),(2);
CREATE TRIGGER t1_test AFTER INSERT ON t1 FOR EACH ROW
INSERT INTO t2 VALUES (new.id);
SELECT GET_LOCK('B26162',20);
GET_LOCK('B26162',20)
SELECT GET_LOCK('B26162',
1
20);
GET_LOCK('B26162',
1
20)
1
SELECT 'rl_acquirer', GET_LOCK('B26162',
5
), id FROM t2 WHERE id = 1;
SELECT 'rl_acquirer', GET_LOCK('B26162',
120
), id FROM t2 WHERE id = 1;
SET SESSION LOW_PRIORITY_UPDATES=1;
SET GLOBAL LOW_PRIORITY_UPDATES=1;
INSERT INTO t1 VALUES (5);
SELECT 'rl_contender', id FROM t2 WHERE id > 1;
SELECT RELEASE_LOCK('B26162');
RELEASE_LOCK('B26162')
0
rl_acquirer GET_LOCK('B26162',5) id
rl_acquirer 0 1
1
rl_acquirer GET_LOCK('B26162',120) id
rl_acquirer 1 1
SELECT RELEASE_LOCK('B26162');
RELEASE_LOCK('B26162')
1
rl_contender id
rl_contender 2
DROP TRIGGER t1_test;
...
...
mysql-test/t/trigger.test
View file @
e4cd7e98
...
...
@@ -1763,6 +1763,9 @@ select * from t1;
select
*
from
t3
;
drop
table
t1
,
t2
,
t3
;
disconnect
addconroot1
;
disconnect
addconroot2
;
disconnect
addconwithoutdb
;
#
# Bug #26162: Trigger DML ignores low_priority_updates setting
#
...
...
@@ -1776,19 +1779,23 @@ INSERT INTO t2 VALUES (1),(2);
CREATE
TRIGGER
t1_test
AFTER
INSERT
ON
t1
FOR
EACH
ROW
INSERT
INTO
t2
VALUES
(
new
.
id
);
CONNECT
(
rl_holder
,
localhost
,
root
,,);
CONNECT
(
rl_acquirer
,
localhost
,
root
,,);
CONNECT
(
wl_acquirer
,
localhost
,
root
,,);
CONNECT
(
rl_contender
,
localhost
,
root
,,);
SELECT
GET_LOCK
(
'B26162'
,
20
);
CONNECTION
rl_holder
;
SELECT
GET_LOCK
(
'B26162'
,
120
);
CONNECTION
rl_acquirer
;
--
send
SELECT
'rl_acquirer'
,
GET_LOCK
(
'B26162'
,
5
),
id
FROM
t2
WHERE
id
=
1
;
SELECT
'rl_acquirer'
,
GET_LOCK
(
'B26162'
,
120
),
id
FROM
t2
WHERE
id
=
1
;
CONNECTION
wl_acquirer
;
SET
SESSION
LOW_PRIORITY_UPDATES
=
1
;
SET
GLOBAL
LOW_PRIORITY_UPDATES
=
1
;
#need to wait for rl_acquirer to lock on the B26162 lock
sleep
2
;
--
send
INSERT
INTO
t1
VALUES
(
5
);
...
...
@@ -1798,13 +1805,16 @@ CONNECTION rl_contender;
--
send
SELECT
'rl_contender'
,
id
FROM
t2
WHERE
id
>
1
;
CONNECTION
default
;
CONNECTION
rl_holder
;
#need to wait for wl_acquirer and rl_contender to lock on t2
sleep
2
;
SELECT
RELEASE_LOCK
(
'B26162'
);
CONNECTION
wl_acquirer
;
--
reap
CONNECTION
rl_acquirer
;
--
reap
SELECT
RELEASE_LOCK
(
'B26162'
);
CONNECTION
wl_acquirer
;
--
reap
CONNECTION
rl_contender
;
--
reap
...
...
@@ -1812,6 +1822,7 @@ CONNECTION default;
DISCONNECT
rl_acquirer
;
DISCONNECT
wl_acquirer
;
DISCONNECT
rl_contender
;
DISCONNECT
rl_holder
;
DROP
TRIGGER
t1_test
;
DROP
TABLE
t1
,
t2
;
...
...
sql/item_func.cc
View file @
e4cd7e98
...
...
@@ -3449,6 +3449,7 @@ longlong Item_func_get_lock::val_int()
THD
*
thd
=
current_thd
;
User_level_lock
*
ull
;
int
error
;
DBUG_ENTER
(
"Item_func_get_lock::val_int"
);
/*
In slave thread no need to get locks, everything is serialized. Anyway
...
...
@@ -3458,7 +3459,7 @@ longlong Item_func_get_lock::val_int()
it's not guaranteed to be same as on master.
*/
if
(
thd
->
slave_thread
)
return
1
;
DBUG_RETURN
(
1
)
;
pthread_mutex_lock
(
&
LOCK_user_locks
);
...
...
@@ -3466,8 +3467,10 @@ longlong Item_func_get_lock::val_int()
{
pthread_mutex_unlock
(
&
LOCK_user_locks
);
null_value
=
1
;
return
0
;
DBUG_RETURN
(
0
)
;
}
DBUG_PRINT
(
"info"
,
(
"lock %.*s, thd=%ld"
,
res
->
length
(),
res
->
ptr
(),
(
long
)
thd
->
real_id
));
null_value
=
0
;
if
(
thd
->
ull
)
...
...
@@ -3486,14 +3489,17 @@ longlong Item_func_get_lock::val_int()
delete
ull
;
pthread_mutex_unlock
(
&
LOCK_user_locks
);
null_value
=
1
;
// Probably out of memory
return
0
;
DBUG_RETURN
(
0
)
;
}
ull
->
thread
=
thd
->
real_id
;
ull
->
thread_id
=
thd
->
thread_id
;
thd
->
ull
=
ull
;
pthread_mutex_unlock
(
&
LOCK_user_locks
);
return
1
;
// Got new lock
DBUG_PRINT
(
"info"
,
(
"made new lock"
));
DBUG_RETURN
(
1
);
// Got new lock
}
ull
->
count
++
;
DBUG_PRINT
(
"info"
,
(
"ull->count=%d"
,
ull
->
count
));
/*
Structure is now initialized. Try to get the lock.
...
...
@@ -3507,9 +3513,13 @@ longlong Item_func_get_lock::val_int()
error
=
0
;
while
(
ull
->
locked
&&
!
thd
->
killed
)
{
DBUG_PRINT
(
"info"
,
(
"waiting on lock"
));
error
=
pthread_cond_timedwait
(
&
ull
->
cond
,
&
LOCK_user_locks
,
&
abstime
);
if
(
error
==
ETIMEDOUT
||
error
==
ETIME
)
{
DBUG_PRINT
(
"info"
,
(
"lock wait timeout"
));
break
;
}
error
=
0
;
}
...
...
@@ -3533,6 +3543,7 @@ longlong Item_func_get_lock::val_int()
ull
->
thread_id
=
thd
->
thread_id
;
thd
->
ull
=
ull
;
error
=
0
;
DBUG_PRINT
(
"info"
,
(
"got the lock"
));
}
pthread_mutex_unlock
(
&
LOCK_user_locks
);
...
...
@@ -3542,7 +3553,7 @@ longlong Item_func_get_lock::val_int()
thd
->
mysys_var
->
current_cond
=
0
;
pthread_mutex_unlock
(
&
thd
->
mysys_var
->
mutex
);
return
!
error
?
1
:
0
;
DBUG_RETURN
(
!
error
?
1
:
0
)
;
}
...
...
@@ -3560,11 +3571,14 @@ longlong Item_func_release_lock::val_int()
String
*
res
=
args
[
0
]
->
val_str
(
&
value
);
User_level_lock
*
ull
;
longlong
result
;
THD
*
thd
=
current_thd
;
DBUG_ENTER
(
"Item_func_release_lock::val_int"
);
if
(
!
res
||
!
res
->
length
())
{
null_value
=
1
;
return
0
;
DBUG_RETURN
(
0
)
;
}
DBUG_PRINT
(
"info"
,
(
"lock %.*s"
,
res
->
length
(),
res
->
ptr
()));
null_value
=
0
;
result
=
0
;
...
...
@@ -3577,19 +3591,20 @@ longlong Item_func_release_lock::val_int()
}
else
{
#ifdef EMBEDDED_LIBRARY
if
(
ull
->
locked
&&
pthread_equal
(
current_thd
->
real_id
,
ull
->
thread
))
#else
if
(
ull
->
locked
&&
pthread_equal
(
pthread_self
(),
ull
->
thread
))
#endif
DBUG_PRINT
(
"info"
,
(
"ull->locked=%d ull->thread=%ld thd=%ld"
,
(
int
)
ull
->
locked
,
(
long
)
ull
->
thread
,
(
long
)
thd
->
real_id
));
if
(
ull
->
locked
&&
pthread_equal
(
thd
->
real_id
,
ull
->
thread
))
{
DBUG_PRINT
(
"info"
,
(
"release lock"
));
result
=
1
;
// Release is ok
item_user_lock_release
(
ull
);
current_
thd
->
ull
=
0
;
thd
->
ull
=
0
;
}
}
pthread_mutex_unlock
(
&
LOCK_user_locks
);
return
result
;
DBUG_RETURN
(
result
)
;
}
...
...
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