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
e756a511
Commit
e756a511
authored
Dec 10, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed unlocking tables during subquery execution (BUG#2048)
parent
4734f452
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
8 deletions
+52
-8
mysql-test/r/subselect_innodb.result
mysql-test/r/subselect_innodb.result
+20
-0
mysql-test/t/subselect_innodb.test
mysql-test/t/subselect_innodb.test
+23
-1
sql/item_subselect.cc
sql/item_subselect.cc
+3
-2
sql/sql_derived.cc
sql/sql_derived.cc
+1
-1
sql/sql_lex.h
sql/sql_lex.h
+1
-1
sql/sql_union.cc
sql/sql_union.cc
+4
-3
No files found.
mysql-test/r/subselect_innodb.result
View file @
e756a511
...
...
@@ -63,3 +63,23 @@ processor_id (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.proces
2 1
3 1
drop table t1,t2,t3;
CREATE TABLE t1 (
id int(11) NOT NULL default '0',
b int(11) default NULL,
c char(3) default NULL,
PRIMARY KEY (id),
KEY t2i1 (b)
) TYPE=innodb DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL');
CREATE TABLE t2 (
id int(11) NOT NULL default '0',
b int(11) default NULL,
c char(3) default NULL,
PRIMARY KEY (id),
KEY t2i (b)
) TYPE=innodb DEFAULT CHARSET=latin1;
INSERT INTO t2 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL');
select (select max(id) from t2 where b=1 group by b) as x,b from t1 where b=1;
x b
2 1
drop table t1,t2;
mysql-test/t/subselect_innodb.test
View file @
e756a511
...
...
@@ -68,3 +68,25 @@ INSERT INTO t3 VALUES (1,1),(2,2),(3,3);
INSERT
INTO
t2
VALUES
(
1
,
1
),(
2
,
2
),(
3
,
3
);
SELECT
distinct
p1
.
processor_id
,
(
SELECT
y
.
yod_id
FROM
t1
p2
,
t2
y
WHERE
p2
.
processor_id
=
p1
.
processor_id
and
p2
.
processor_id
=
y
.
processor_id
)
FROM
t1
p1
;
drop
table
t1
,
t2
,
t3
;
#
# innodb locking
#
CREATE
TABLE
t1
(
id
int
(
11
)
NOT
NULL
default
'0'
,
b
int
(
11
)
default
NULL
,
c
char
(
3
)
default
NULL
,
PRIMARY
KEY
(
id
),
KEY
t2i1
(
b
)
)
TYPE
=
innodb
DEFAULT
CHARSET
=
latin1
;
INSERT
INTO
t1
VALUES
(
0
,
0
,
'GPL'
),(
1
,
0
,
'GPL'
),(
2
,
1
,
'GPL'
),(
3
,
2
,
'GPL'
);
CREATE
TABLE
t2
(
id
int
(
11
)
NOT
NULL
default
'0'
,
b
int
(
11
)
default
NULL
,
c
char
(
3
)
default
NULL
,
PRIMARY
KEY
(
id
),
KEY
t2i
(
b
)
)
TYPE
=
innodb
DEFAULT
CHARSET
=
latin1
;
INSERT
INTO
t2
VALUES
(
0
,
0
,
'GPL'
),(
1
,
0
,
'GPL'
),(
2
,
1
,
'GPL'
),(
3
,
2
,
'GPL'
);
select
(
select
max
(
id
)
from
t2
where
b
=
1
group
by
b
)
as
x
,
b
from
t1
where
b
=
1
;
drop
table
t1
,
t2
;
sql/item_subselect.cc
View file @
e756a511
...
...
@@ -906,7 +906,8 @@ int subselect_single_select_engine::prepare()
{
if
(
prepared
)
return
0
;
join
=
new
JOIN
(
thd
,
select_lex
->
item_list
,
select_lex
->
options
,
result
);
join
=
new
JOIN
(
thd
,
select_lex
->
item_list
,
select_lex
->
options
|
SELECT_NO_UNLOCK
,
result
);
if
(
!
join
||
!
result
)
{
thd
->
fatal_error
();
//out of memory
...
...
@@ -933,7 +934,7 @@ int subselect_single_select_engine::prepare()
int
subselect_union_engine
::
prepare
()
{
return
unit
->
prepare
(
thd
,
result
);
return
unit
->
prepare
(
thd
,
result
,
SELECT_NO_UNLOCK
);
}
int
subselect_uniquesubquery_engine
::
prepare
()
...
...
sql/sql_derived.cc
View file @
e756a511
...
...
@@ -114,7 +114,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
DBUG_RETURN
(
1
);
// out of memory
// st_select_lex_unit::prepare correctly work for single select
if
((
res
=
unit
->
prepare
(
thd
,
derived_result
)))
if
((
res
=
unit
->
prepare
(
thd
,
derived_result
,
0
)))
goto
exit
;
/*
...
...
sql/sql_lex.h
View file @
e756a511
...
...
@@ -351,7 +351,7 @@ public:
void
exclude_tree
();
/* UNION methods */
int
prepare
(
THD
*
thd
,
select_result
*
result
);
int
prepare
(
THD
*
thd
,
select_result
*
result
,
ulong
additional_options
);
int
exec
();
int
cleanup
();
...
...
sql/sql_union.cc
View file @
e756a511
...
...
@@ -29,7 +29,7 @@ int mysql_union(THD *thd, LEX *lex, select_result *result,
{
DBUG_ENTER
(
"mysql_union"
);
int
res
=
0
;
if
(
!
(
res
=
unit
->
prepare
(
thd
,
result
)))
if
(
!
(
res
=
unit
->
prepare
(
thd
,
result
,
SELECT_NO_UNLOCK
)))
res
=
unit
->
exec
();
res
|=
unit
->
cleanup
();
DBUG_RETURN
(
res
);
...
...
@@ -106,7 +106,8 @@ bool select_union::flush()
}
int
st_select_lex_unit
::
prepare
(
THD
*
thd_arg
,
select_result
*
sel_result
)
int
st_select_lex_unit
::
prepare
(
THD
*
thd_arg
,
select_result
*
sel_result
,
ulong
additional_options
)
{
SELECT_LEX
*
lex_select_save
=
thd_arg
->
lex
.
current_select
;
SELECT_LEX
*
sl
,
*
first_select
;
...
...
@@ -146,7 +147,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result)
for
(;
sl
;
sl
=
sl
->
next_select
())
{
JOIN
*
join
=
new
JOIN
(
thd_arg
,
sl
->
item_list
,
sl
->
options
|
thd_arg
->
options
|
SELECT_NO_UNLOCK
,
sl
->
options
|
thd_arg
->
options
|
additional_options
,
tmp_result
);
thd_arg
->
lex
.
current_select
=
sl
;
offset_limit_cnt
=
sl
->
offset_limit
;
...
...
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