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
96a9d0da
Commit
96a9d0da
authored
Mar 16, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Plain Diff
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-rand-4.1
parents
7df80441
e8a92428
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
3 deletions
+23
-3
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+8
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+8
-0
sql/item_func.cc
sql/item_func.cc
+1
-0
sql/item_func.h
sql/item_func.h
+0
-1
sql/sql_select.cc
sql/sql_select.cc
+6
-2
No files found.
mysql-test/r/subselect.result
View file @
96a9d0da
...
@@ -1630,3 +1630,11 @@ select count(*) from t1 as w1 where w1.val in (select w2.val from t1 as w2 where
...
@@ -1630,3 +1630,11 @@ select count(*) from t1 as w1 where w1.val in (select w2.val from t1 as w2 where
count(*)
count(*)
0
0
drop table if exists t1;
drop table if exists t1;
create table t1 (a int);
insert into t1 values (1);
explain select benchmark(1000, (select a from t1 where a=sha(rand())));
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 UNCACHEABLE SUBQUERY t1 system NULL NULL NULL NULL 1
drop table t1;
mysql-test/t/subselect.test
View file @
96a9d0da
...
@@ -1073,3 +1073,11 @@ create table t1(val varchar(10));
...
@@ -1073,3 +1073,11 @@ create table t1(val varchar(10));
insert
into
t1
values
(
'aaa'
),
(
'bbb'
),(
'eee'
),(
'mmm'
),(
'ppp'
);
insert
into
t1
values
(
'aaa'
),
(
'bbb'
),(
'eee'
),(
'mmm'
),(
'ppp'
);
select
count
(
*
)
from
t1
as
w1
where
w1
.
val
in
(
select
w2
.
val
from
t1
as
w2
where
w2
.
val
like
'm%'
)
and
w1
.
val
in
(
select
w3
.
val
from
t1
as
w3
where
w3
.
val
like
'e%'
);
select
count
(
*
)
from
t1
as
w1
where
w1
.
val
in
(
select
w2
.
val
from
t1
as
w2
where
w2
.
val
like
'm%'
)
and
w1
.
val
in
(
select
w3
.
val
from
t1
as
w3
where
w3
.
val
like
'e%'
);
drop
table
if
exists
t1
;
drop
table
if
exists
t1
;
#
# Static tables & rund() in subqueries
#
create
table
t1
(
a
int
);
insert
into
t1
values
(
1
);
explain
select
benchmark
(
1000
,
(
select
a
from
t1
where
a
=
sha
(
rand
())));
drop
table
t1
;
sql/item_func.cc
View file @
96a9d0da
...
@@ -964,6 +964,7 @@ void Item_func_rand::fix_length_and_dec()
...
@@ -964,6 +964,7 @@ void Item_func_rand::fix_length_and_dec()
{
{
decimals
=
NOT_FIXED_DEC
;
decimals
=
NOT_FIXED_DEC
;
max_length
=
float_length
(
decimals
);
max_length
=
float_length
(
decimals
);
used_tables_cache
|=
RAND_TABLE_BIT
;
if
(
arg_count
)
if
(
arg_count
)
{
// Only use argument once in query
{
// Only use argument once in query
uint32
tmp
=
(
uint32
)
(
args
[
0
]
->
val_int
());
uint32
tmp
=
(
uint32
)
(
args
[
0
]
->
val_int
());
...
...
sql/item_func.h
View file @
96a9d0da
...
@@ -512,7 +512,6 @@ public:
...
@@ -512,7 +512,6 @@ public:
double
val
();
double
val
();
const
char
*
func_name
()
const
{
return
"rand"
;
}
const
char
*
func_name
()
const
{
return
"rand"
;
}
bool
const_item
()
const
{
return
0
;
}
bool
const_item
()
const
{
return
0
;
}
table_map
used_tables
()
const
{
return
RAND_TABLE_BIT
;
}
void
fix_length_and_dec
();
void
fix_length_and_dec
();
};
};
...
...
sql/sql_select.cc
View file @
96a9d0da
...
@@ -584,7 +584,9 @@ JOIN::optimize()
...
@@ -584,7 +584,9 @@ JOIN::optimize()
DBUG_RETURN
(
1
);
// error == -1
DBUG_RETURN
(
1
);
// error == -1
}
}
if
(
const_table_map
!=
found_const_table_map
&&
if
(
const_table_map
!=
found_const_table_map
&&
!
(
select_options
&
SELECT_DESCRIBE
))
!
(
select_options
&
SELECT_DESCRIBE
)
&&
!
((
conds
->
used_tables
()
&
RAND_TABLE_BIT
)
&&
select_lex
->
master_unit
()
!=
&
thd
->
lex
->
unit
))
// not upper level SELECT
{
{
zero_result_cause
=
"no matching row in const table"
;
zero_result_cause
=
"no matching row in const table"
;
DBUG_PRINT
(
"error"
,(
"Error: %s"
,
zero_result_cause
));
DBUG_PRINT
(
"error"
,(
"Error: %s"
,
zero_result_cause
));
...
@@ -3407,7 +3409,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
...
@@ -3407,7 +3409,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
table_map
used_tables
;
table_map
used_tables
;
if
(
join
->
tables
>
1
)
if
(
join
->
tables
>
1
)
cond
->
update_used_tables
();
// Tablenr may have changed
cond
->
update_used_tables
();
// Tablenr may have changed
if
(
join
->
const_tables
==
join
->
tables
)
if
(
join
->
const_tables
==
join
->
tables
&&
join
->
thd
->
lex
->
current_select
->
master_unit
()
==
&
join
->
thd
->
lex
->
unit
)
// not upper level SELECT
join
->
const_table_map
|=
RAND_TABLE_BIT
;
join
->
const_table_map
|=
RAND_TABLE_BIT
;
{
// Check const tables
{
// Check const tables
COND
*
const_cond
=
COND
*
const_cond
=
...
...
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