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
1cbf8f74
Commit
1cbf8f74
authored
Mar 11, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed cached constsnt determination (bug #142 related)
parent
fd88f185
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
2 deletions
+52
-2
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+23
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+17
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+12
-2
No files found.
mysql-test/r/subselect.result
View file @
1cbf8f74
...
@@ -1049,3 +1049,26 @@ select t2.Continent, t1.Name, t1.Population from t2 LEFT JOIN t1 ON t2.Code = t1
...
@@ -1049,3 +1049,26 @@ select t2.Continent, t1.Name, t1.Population from t2 LEFT JOIN t1 ON t2.Code = t1
Continent Name Population
Continent Name Population
Oceania Sydney 3276207
Oceania Sydney 3276207
drop table t1, t2;
drop table t1, t2;
CREATE TABLE `t1` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`pseudo` varchar(35) character set latin1 NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `pseudo` (`pseudo`),
) TYPE=MyISAM PACK_KEYS=1 ROW_FORMAT=DYNAMIC;
INSERT INTO t1 (pseudo) VALUES ('test');
SELECT 0 IN (SELECT 1 FROM t1 a);
0 IN (SELECT 1 FROM t1 a)
0
EXPLAIN SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBSELECT NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
INSERT INTO t1 (pseudo) VALUES ('test1');
SELECT 0 IN (SELECT 1 FROM t1 a);
0 IN (SELECT 1 FROM t1 a)
0
EXPLAIN SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBSELECT NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
drop table t1;
mysql-test/t/subselect.test
View file @
1cbf8f74
...
@@ -644,3 +644,20 @@ INSERT INTO t2 VALUES ('AZE','Azerbaijan','Asia','Middle East',86600.00,1991,773
...
@@ -644,3 +644,20 @@ INSERT INTO t2 VALUES ('AZE','Azerbaijan','Asia','Middle East',86600.00,1991,773
select
t2
.
Continent
,
t1
.
Name
,
t1
.
Population
from
t2
LEFT
JOIN
t1
ON
t2
.
Code
=
t1
.
t2
where
t1
.
Population
IN
(
select
max
(
t1
.
Population
)
AS
Population
from
t1
,
t2
where
t1
.
t2
=
t2
.
Code
group
by
Continent
);
select
t2
.
Continent
,
t1
.
Name
,
t1
.
Population
from
t2
LEFT
JOIN
t1
ON
t2
.
Code
=
t1
.
t2
where
t1
.
Population
IN
(
select
max
(
t1
.
Population
)
AS
Population
from
t1
,
t2
where
t1
.
t2
=
t2
.
Code
group
by
Continent
);
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
#
# constants in IN
#
CREATE
TABLE
`t1`
(
`id`
mediumint
(
8
)
unsigned
NOT
NULL
auto_increment
,
`pseudo`
varchar
(
35
)
character
set
latin1
NOT
NULL
default
''
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`pseudo`
(
`pseudo`
),
)
TYPE
=
MyISAM
PACK_KEYS
=
1
ROW_FORMAT
=
DYNAMIC
;
INSERT
INTO
t1
(
pseudo
)
VALUES
(
'test'
);
SELECT
0
IN
(
SELECT
1
FROM
t1
a
);
EXPLAIN
SELECT
0
IN
(
SELECT
1
FROM
t1
a
);
INSERT
INTO
t1
(
pseudo
)
VALUES
(
'test1'
);
SELECT
0
IN
(
SELECT
1
FROM
t1
a
);
EXPLAIN
SELECT
0
IN
(
SELECT
1
FROM
t1
a
);
drop
table
t1
;
sql/item_cmpfunc.cc
View file @
1cbf8f74
...
@@ -298,12 +298,22 @@ bool Item_in_optimizer::fix_fields(THD *thd, struct st_table_list *tables,
...
@@ -298,12 +298,22 @@ bool Item_in_optimizer::fix_fields(THD *thd, struct st_table_list *tables,
return
1
;
return
1
;
cache
->
setup
(
args
[
0
]);
cache
->
setup
(
args
[
0
]);
if
(
cache
->
cols
()
==
1
)
if
(
cache
->
cols
()
==
1
)
{
if
(
args
[
0
]
->
used_tables
())
cache
->
set_used_tables
(
RAND_TABLE_BIT
);
cache
->
set_used_tables
(
RAND_TABLE_BIT
);
else
cache
->
set_used_tables
(
0
);
}
else
else
{
{
uint
n
=
cache
->
cols
();
uint
n
=
cache
->
cols
();
for
(
uint
i
=
0
;
i
<
n
;
i
++
)
for
(
uint
i
=
0
;
i
<
n
;
i
++
)
{
if
(
args
[
0
]
->
el
(
i
)
->
used_tables
())
((
Item_cache
*
)
cache
->
el
(
i
))
->
set_used_tables
(
RAND_TABLE_BIT
);
((
Item_cache
*
)
cache
->
el
(
i
))
->
set_used_tables
(
RAND_TABLE_BIT
);
else
((
Item_cache
*
)
cache
->
el
(
i
))
->
set_used_tables
(
0
);
}
}
}
if
(
args
[
1
]
->
fix_fields
(
thd
,
tables
,
args
))
if
(
args
[
1
]
->
fix_fields
(
thd
,
tables
,
args
))
return
1
;
return
1
;
...
...
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