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
6fb8a4e9
Commit
6fb8a4e9
authored
Nov 25, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/usr/local/home/marty/MySQL/mysql-4.1
parents
e1af5e5d
44662d2c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
mysql-test/r/select.result
mysql-test/r/select.result
+8
-0
mysql-test/t/select.test
mysql-test/t/select.test
+11
-0
sql/item.cc
sql/item.cc
+12
-3
No files found.
mysql-test/r/select.result
View file @
6fb8a4e9
...
@@ -2706,3 +2706,11 @@ select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1;
...
@@ -2706,3 +2706,11 @@ select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1;
count(f2) >0
count(f2) >0
1
1
drop table t1,t2;
drop table t1,t2;
create table t1 (f1 int,f2 int);
insert into t1 values(1,1);
create table t2 (f3 int, f4 int, primary key(f3,f4));
insert into t2 values(1,1);
select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2));
f1 f2
1 1
drop table t1,t2;
mysql-test/t/select.test
View file @
6fb8a4e9
...
@@ -2237,4 +2237,15 @@ insert into t1 values (1,1);
...
@@ -2237,4 +2237,15 @@ insert into t1 values (1,1);
insert
into
t2
values
(
1
,
1
),(
1
,
2
);
insert
into
t2
values
(
1
,
1
),(
1
,
2
);
select
distinct
count
(
f2
)
>
0
from
t1
left
join
t2
on
f1
=
f3
group
by
f1
;
select
distinct
count
(
f2
)
>
0
from
t1
left
join
t2
on
f1
=
f3
group
by
f1
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
#
# Bug #14482 Server crash when subselecting from the same table
#
create
table
t1
(
f1
int
,
f2
int
);
insert
into
t1
values
(
1
,
1
);
create
table
t2
(
f3
int
,
f4
int
,
primary
key
(
f3
,
f4
));
insert
into
t2
values
(
1
,
1
);
select
*
from
t1
where
f1
in
(
select
f3
from
t2
where
(
f3
,
f4
)
=
(
select
f3
,
f4
from
t2
));
drop
table
t1
,
t2
;
# End of 4.1 tests
# End of 4.1 tests
sql/item.cc
View file @
6fb8a4e9
...
@@ -2863,7 +2863,7 @@ Item_result item_cmp_type(Item_result a,Item_result b)
...
@@ -2863,7 +2863,7 @@ Item_result item_cmp_type(Item_result a,Item_result b)
void
resolve_const_item
(
THD
*
thd
,
Item
**
ref
,
Item
*
comp_item
)
void
resolve_const_item
(
THD
*
thd
,
Item
**
ref
,
Item
*
comp_item
)
{
{
Item
*
item
=
*
ref
;
Item
*
item
=
*
ref
;
Item
*
new_item
;
Item
*
new_item
=
NULL
;
if
(
item
->
basic_const_item
())
if
(
item
->
basic_const_item
())
return
;
// Can't be better
return
;
// Can't be better
Item_result
res_type
=
item_cmp_type
(
comp_item
->
result_type
(),
Item_result
res_type
=
item_cmp_type
(
comp_item
->
result_type
(),
...
@@ -2892,8 +2892,17 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
...
@@ -2892,8 +2892,17 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
new_item
=
(
null_value
?
(
Item
*
)
new
Item_null
(
name
)
:
new_item
=
(
null_value
?
(
Item
*
)
new
Item_null
(
name
)
:
(
Item
*
)
new
Item_int
(
name
,
result
,
length
));
(
Item
*
)
new
Item_int
(
name
,
result
,
length
));
}
}
else
if
(
res_type
==
ROW_RESULT
)
else
if
(
res_type
==
ROW_RESULT
&&
item
->
type
()
==
Item
::
ROW_ITEM
&&
comp_item
->
type
()
==
Item
::
ROW_ITEM
)
{
{
/*
Substitute constants only in Item_rows. Don't affect other Items
with ROW_RESULT (eg Item_singlerow_subselect).
For such Items more optimal is to detect if it is constant and replace
it with Item_row. This would optimize queries like this:
SELECT * FROM t1 WHERE (a,b) = (SELECT a,b FROM t2 LIMIT 1);
*/
Item_row
*
item_row
=
(
Item_row
*
)
item
;
Item_row
*
item_row
=
(
Item_row
*
)
item
;
Item_row
*
comp_item_row
=
(
Item_row
*
)
comp_item
;
Item_row
*
comp_item_row
=
(
Item_row
*
)
comp_item
;
uint
col
;
uint
col
;
...
@@ -2910,7 +2919,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
...
@@ -2910,7 +2919,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
while
(
col
--
>
0
)
while
(
col
--
>
0
)
resolve_const_item
(
thd
,
item_row
->
addr
(
col
),
comp_item_row
->
el
(
col
));
resolve_const_item
(
thd
,
item_row
->
addr
(
col
),
comp_item_row
->
el
(
col
));
}
}
else
else
if
(
res_type
==
REAL_RESULT
)
{
// It must REAL_RESULT
{
// It must REAL_RESULT
double
result
=
item
->
val
();
double
result
=
item
->
val
();
uint
length
=
item
->
max_length
,
decimals
=
item
->
decimals
;
uint
length
=
item
->
max_length
,
decimals
=
item
->
decimals
;
...
...
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