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
64cd633f
Commit
64cd633f
authored
Nov 22, 2004
by
dlenev@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/dlenev/src/mysql-4.1-bg6462
parents
3082312f
c37977c8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
6 deletions
+46
-6
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+15
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+19
-0
sql/set_var.cc
sql/set_var.cc
+11
-6
sql/sql_do.cc
sql/sql_do.cc
+1
-0
No files found.
mysql-test/r/subselect.result
View file @
64cd633f
...
@@ -1990,3 +1990,18 @@ ac
...
@@ -1990,3 +1990,18 @@ ac
700
700
NULL
NULL
drop tables t1,t2;
drop tables t1,t2;
create table t1 (a int not null, b int not null, c int, primary key (a,b));
insert into t1 values (1,1,1), (2,2,2), (3,3,3);
set @b:= 0;
explain select sum(a) from t1 where b > @b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 8 NULL 3 Using where; Using index
set @a:= (select sum(a) from t1 where b > @b);
explain select a from t1 where c=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
do @a:= (select sum(a) from t1 where b > @b);
explain select a from t1 where c=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
drop table t1;
mysql-test/t/subselect.test
View file @
64cd633f
...
@@ -1282,3 +1282,22 @@ INSERT INTO `t2` VALUES (6,5,12,7,'a'),(12,0,0,7,'a'),(12,1,0,7,'a'),(12,5,5,7,'
...
@@ -1282,3 +1282,22 @@ INSERT INTO `t2` VALUES (6,5,12,7,'a'),(12,0,0,7,'a'),(12,1,0,7,'a'),(12,5,5,7,'
SELECT
b
.
sc
FROM
(
SELECT
(
SELECT
a
.
access
FROM
t1
a
WHERE
a
.
map
=
op
.
map
AND
a
.
slave
=
op
.
pid
AND
a
.
master
=
1
)
ac
FROM
t2
op
WHERE
op
.
id
=
12
AND
op
.
map
=
0
)
b
;
SELECT
b
.
sc
FROM
(
SELECT
(
SELECT
a
.
access
FROM
t1
a
WHERE
a
.
map
=
op
.
map
AND
a
.
slave
=
op
.
pid
AND
a
.
master
=
1
)
ac
FROM
t2
op
WHERE
op
.
id
=
12
AND
op
.
map
=
0
)
b
;
SELECT
b
.
ac
FROM
(
SELECT
(
SELECT
a
.
access
FROM
t1
a
WHERE
a
.
map
=
op
.
map
AND
a
.
slave
=
op
.
pid
AND
a
.
master
=
1
)
ac
FROM
t2
op
WHERE
op
.
id
=
12
AND
op
.
map
=
0
)
b
;
SELECT
b
.
ac
FROM
(
SELECT
(
SELECT
a
.
access
FROM
t1
a
WHERE
a
.
map
=
op
.
map
AND
a
.
slave
=
op
.
pid
AND
a
.
master
=
1
)
ac
FROM
t2
op
WHERE
op
.
id
=
12
AND
op
.
map
=
0
)
b
;
drop
tables
t1
,
t2
;
drop
tables
t1
,
t2
;
#
# Test for bug #6462. "Same request on same data returns different
# results." a.k.a. "Proper cleanup of subqueries is missing for
# SET and DO statements".
#
create
table
t1
(
a
int
not
null
,
b
int
not
null
,
c
int
,
primary
key
(
a
,
b
));
insert
into
t1
values
(
1
,
1
,
1
),
(
2
,
2
,
2
),
(
3
,
3
,
3
);
set
@
b
:=
0
;
# Let us check that subquery will use covering index
explain
select
sum
(
a
)
from
t1
where
b
>
@
b
;
# This should not crash -debug server due to failing assertion
set
@
a
:=
(
select
sum
(
a
)
from
t1
where
b
>
@
b
);
# And this should not falsely report index usage
explain
select
a
from
t1
where
c
=
2
;
# Same for DO statement
do
@
a
:=
(
select
sum
(
a
)
from
t1
where
b
>
@
b
);
explain
select
a
from
t1
where
c
=
2
;
drop
table
t1
;
sql/set_var.cc
View file @
64cd633f
...
@@ -2733,13 +2733,18 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list)
...
@@ -2733,13 +2733,18 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list)
while
((
var
=
it
++
))
while
((
var
=
it
++
))
{
{
if
((
error
=
var
->
check
(
thd
)))
if
((
error
=
var
->
check
(
thd
)))
DBUG_RETURN
(
error
)
;
goto
err
;
}
}
if
(
thd
->
net
.
report_error
)
if
(
!
thd
->
net
.
report_error
)
DBUG_RETURN
(
1
);
{
it
.
rewind
();
it
.
rewind
();
while
((
var
=
it
++
))
while
((
var
=
it
++
))
error
|=
var
->
update
(
thd
);
// Returns 0, -1 or 1
error
|=
var
->
update
(
thd
);
// Returns 0, -1 or 1
}
else
error
=
1
;
err:
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
...
sql/sql_do.cc
View file @
64cd633f
...
@@ -29,6 +29,7 @@ int mysql_do(THD *thd, List<Item> &values)
...
@@ -29,6 +29,7 @@ int mysql_do(THD *thd, List<Item> &values)
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
while
((
value
=
li
++
))
while
((
value
=
li
++
))
value
->
val_int
();
value
->
val_int
();
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
thd
->
clear_error
();
// DO always is OK
thd
->
clear_error
();
// DO always is OK
send_ok
(
thd
);
send_ok
(
thd
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
...
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