mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge magare.gmz:/home/kgeorge/mysql/work/B32400-5.0-opt
into magare.gmz:/home/kgeorge/mysql/work/B32400-5.1-opt
This commit is contained in:
@ -434,8 +434,8 @@ execute stmt1 ;
|
|||||||
let $1= 3 ;
|
let $1= 3 ;
|
||||||
while ($1)
|
while ($1)
|
||||||
{
|
{
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
dec $1 ;
|
dec $1 ;
|
||||||
|
@ -783,20 +783,20 @@ a b
|
|||||||
2 two
|
2 two
|
||||||
3 three
|
3 three
|
||||||
4 four
|
4 four
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
|
@ -783,20 +783,20 @@ a b
|
|||||||
2 two
|
2 two
|
||||||
3 three
|
3 three
|
||||||
4 four
|
4 four
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
|
@ -784,20 +784,20 @@ a b
|
|||||||
2 two
|
2 two
|
||||||
3 three
|
3 three
|
||||||
4 four
|
4 four
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
|
@ -826,20 +826,20 @@ a b
|
|||||||
2 two
|
2 two
|
||||||
3 three
|
3 three
|
||||||
4 four
|
4 four
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
@ -3848,20 +3848,20 @@ a b
|
|||||||
2 two
|
2 two
|
||||||
3 three
|
3 three
|
||||||
4 four
|
4 four
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
|
@ -783,20 +783,20 @@ a b
|
|||||||
2 two
|
2 two
|
||||||
3 three
|
3 three
|
||||||
4 four
|
4 four
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
deallocate prepare stmt1 ;
|
deallocate prepare stmt1 ;
|
||||||
prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
|
prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
|
||||||
(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
|
(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
|
||||||
execute stmt1 ;
|
execute stmt1 ;
|
||||||
ccc
|
ccc
|
||||||
1
|
1
|
||||||
|
@ -32,7 +32,9 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
|
|||||||
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
|
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
|
||||||
-- error 1108
|
-- error 1108
|
||||||
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
|
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
|
||||||
|
-- error ER_BAD_FIELD_ERROR
|
||||||
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
|
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
|
||||||
|
-- error ER_BAD_FIELD_ERROR
|
||||||
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
|
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
|
||||||
SELECT (SELECT 1,2,3) = ROW(1,2,3);
|
SELECT (SELECT 1,2,3) = ROW(1,2,3);
|
||||||
SELECT (SELECT 1,2,3) = ROW(1,2,1);
|
SELECT (SELECT 1,2,3) = ROW(1,2,1);
|
||||||
@ -1346,17 +1348,20 @@ drop table t1,t2;
|
|||||||
CREATE TABLE t1 ( a int, b int );
|
CREATE TABLE t1 ( a int, b int );
|
||||||
CREATE TABLE t2 ( c int, d int );
|
CREATE TABLE t2 ( c int, d int );
|
||||||
INSERT INTO t1 VALUES (1,2), (2,3), (3,4);
|
INSERT INTO t1 VALUES (1,2), (2,3), (3,4);
|
||||||
SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
|
SELECT a AS abc, b FROM t1 outr WHERE b =
|
||||||
INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
|
(SELECT MIN(b) FROM t1 WHERE a=outr.a);
|
||||||
|
INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b =
|
||||||
|
(SELECT MIN(b) FROM t1 WHERE a=outr.a);
|
||||||
select * from t2;
|
select * from t2;
|
||||||
CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
|
CREATE TABLE t3 SELECT a AS abc, b FROM t1 outr WHERE b =
|
||||||
|
(SELECT MIN(b) FROM t1 WHERE a=outr.a);
|
||||||
select * from t3;
|
select * from t3;
|
||||||
prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);";
|
prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b = (SELECT MIN(b) FROM t1 WHERE a=outr.a);";
|
||||||
execute stmt1;
|
execute stmt1;
|
||||||
deallocate prepare stmt1;
|
deallocate prepare stmt1;
|
||||||
select * from t2;
|
select * from t2;
|
||||||
drop table t3;
|
drop table t3;
|
||||||
prepare stmt1 from "CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);";
|
prepare stmt1 from "CREATE TABLE t3 SELECT a AS abc, b FROM t1 outr WHERE b = (SELECT MIN(b) FROM t1 WHERE a=outr.a);";
|
||||||
execute stmt1;
|
execute stmt1;
|
||||||
select * from t3;
|
select * from t3;
|
||||||
deallocate prepare stmt1;
|
deallocate prepare stmt1;
|
||||||
@ -1529,7 +1534,9 @@ INSERT INTO t1 VALUES ('ASM','American Samoa','Oceania','Polynesia',199.00,0,680
|
|||||||
INSERT INTO t1 VALUES ('ATF','French Southern territories','Antarctica','Antarctica',7780.00,0,0,NULL,0.00,NULL,'Terres australes françaises','Nonmetropolitan Territory of France','Jacques Chirac',NULL,'TF');
|
INSERT INTO t1 VALUES ('ATF','French Southern territories','Antarctica','Antarctica',7780.00,0,0,NULL,0.00,NULL,'Terres australes françaises','Nonmetropolitan Territory of France','Jacques Chirac',NULL,'TF');
|
||||||
INSERT INTO t1 VALUES ('UMI','United States Minor Outlying Islands','Oceania','Micronesia/Caribbean',16.00,0,0,NULL,0.00,NULL,'United States Minor Outlying Islands','Dependent Territory of the US','George W. Bush',NULL,'UM');
|
INSERT INTO t1 VALUES ('UMI','United States Minor Outlying Islands','Oceania','Micronesia/Caribbean',16.00,0,0,NULL,0.00,NULL,'United States Minor Outlying Islands','Dependent Territory of the US','George W. Bush',NULL,'UM');
|
||||||
/*!40000 ALTER TABLE t1 ENABLE KEYS */;
|
/*!40000 ALTER TABLE t1 ENABLE KEYS */;
|
||||||
SELECT DISTINCT Continent AS c FROM t1 WHERE Code <> SOME ( SELECT Code FROM t1 WHERE Continent = c AND Population < 200);
|
SELECT DISTINCT Continent AS c FROM t1 outr WHERE
|
||||||
|
Code <> SOME ( SELECT Code FROM t1 WHERE Continent = outr.Continent AND
|
||||||
|
Population < 200);
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -3163,6 +3170,37 @@ SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
|
|||||||
|
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #32400: Complex SELECT query returns correct result only on some
|
||||||
|
# occasions
|
||||||
|
#
|
||||||
|
|
||||||
|
CREATE TABLE t1(a INT, b INT);
|
||||||
|
INSERT INTO t1 VALUES (1,1), (1,2), (2,3), (2,4);
|
||||||
|
|
||||||
|
--error ER_BAD_FIELD_ERROR
|
||||||
|
EXPLAIN
|
||||||
|
SELECT a AS out_a, MIN(b) FROM t1
|
||||||
|
WHERE b > (SELECT MIN(b) FROM t1 WHERE a = out_a)
|
||||||
|
GROUP BY a;
|
||||||
|
|
||||||
|
--error ER_BAD_FIELD_ERROR
|
||||||
|
SELECT a AS out_a, MIN(b) FROM t1
|
||||||
|
WHERE b > (SELECT MIN(b) FROM t1 WHERE a = out_a)
|
||||||
|
GROUP BY a;
|
||||||
|
|
||||||
|
EXPLAIN
|
||||||
|
SELECT a AS out_a, MIN(b) FROM t1 t1_outer
|
||||||
|
WHERE b > (SELECT MIN(b) FROM t1 WHERE a = t1_outer.a)
|
||||||
|
GROUP BY a;
|
||||||
|
|
||||||
|
SELECT a AS out_a, MIN(b) FROM t1 t1_outer
|
||||||
|
WHERE b > (SELECT MIN(b) FROM t1 WHERE a = t1_outer.a)
|
||||||
|
GROUP BY a;
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
|
||||||
--echo End of 5.0 tests.
|
--echo End of 5.0 tests.
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -3683,7 +3683,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Search in SELECT and GROUP lists of the outer select. */
|
/* Search in SELECT and GROUP lists of the outer select. */
|
||||||
if (outer_context->resolve_in_select_list)
|
if (place != IN_WHERE && place != IN_ON)
|
||||||
{
|
{
|
||||||
if (!(ref= resolve_ref_in_select_and_group(thd, this, select)))
|
if (!(ref= resolve_ref_in_select_and_group(thd, this, select)))
|
||||||
return -1; /* Some error occurred (e.g. ambiguous names). */
|
return -1; /* Some error occurred (e.g. ambiguous names). */
|
||||||
|
@ -9552,7 +9552,7 @@ static void test_subqueries_ref()
|
|||||||
{
|
{
|
||||||
MYSQL_STMT *stmt;
|
MYSQL_STMT *stmt;
|
||||||
int rc, i;
|
int rc, i;
|
||||||
const char *query= "SELECT a as ccc from t1 where a+1=(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1)";
|
const char *query= "SELECT a as ccc from t1 outr where a+1=(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1)";
|
||||||
|
|
||||||
myheader("test_subqueries_ref");
|
myheader("test_subqueries_ref");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user