Skip to content

Commit 00d29cd

Browse files
author
jimw@mysql.com
committed
Merge mysql.com:/home/jimw/my/mysql-5.0-clean
into mysql.com:/home/jimw/my/mysql-5.1-clean
2 parents 3a9c099 + 90befc0 commit 00d29cd

34 files changed

+1007
-128
lines changed

mysql-test/r/bdb.result

+19
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,25 @@ SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
12891289
id
12901290
4
12911291
DROP TABLE t1;
1292+
create table t1 (a int, key(a)) engine=bdb;
1293+
create table t2 (b int, key(b)) engine=bdb;
1294+
insert into t1 values (1),(1),(2),(3),(4);
1295+
insert into t2 values (1),(5),(6),(7);
1296+
delete from t1 where (a in (select b from t2));
1297+
select count(*) from t1;
1298+
count(*)
1299+
3
1300+
insert into t1 set a=(select b from t2);
1301+
ERROR 21000: Subquery returns more than 1 row
1302+
select count(*) from t1;
1303+
count(*)
1304+
3
1305+
update t1 set a = a + 1 where (a in (select b from t2));
1306+
select count(*) from t1;
1307+
count(*)
1308+
3
1309+
drop table t1, t2;
1310+
End of 4.1 tests
12921311
create temporary table t1 (a int, primary key(a)) engine=bdb;
12931312
select * from t1;
12941313
a

mysql-test/r/func_gconcat.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ show warnings;
163163
Level Code Message
164164
Warning 1260 1 line(s) were cut by GROUP_CONCAT()
165165
set group_concat_max_len = 1024;
166-
select group_concat(sum(a)) from t1 group by grp;
166+
select group_concat(sum(c)) from t1 group by grp;
167167
ERROR HY000: Invalid use of group function
168168
select grp,group_concat(c order by 2) from t1 group by grp;
169169
ERROR 42S22: Unknown column '2' in 'order clause'

mysql-test/r/rpl_trigger.result

+12
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,15 @@ a=b && a=c
122122
1
123123
drop function bug12480;
124124
drop table t1;
125+
create table t1 (i int);
126+
create table t2 (i int);
127+
create trigger tr1 before insert on t1 for each row
128+
begin
129+
insert into t2 values (1);
130+
end|
131+
create database other;
132+
use other;
133+
insert into test.t1 values (1);
134+
use test;
135+
drop table t1,t2;
136+
drop database other;

mysql-test/r/sp.result

+59-23
Original file line numberDiff line numberDiff line change
@@ -4110,33 +4110,33 @@ call bug14376(4711)|
41104110
x
41114111
4711
41124112
drop procedure bug14376|
4113-
drop procedure if exists p1|
4114-
drop table if exists t1|
4115-
create table t1 (a varchar(255))|
4116-
insert into t1 (a) values ("a - table column")|
4117-
create procedure p1(a varchar(255))
4113+
drop procedure if exists bug5967|
4114+
drop table if exists t3|
4115+
create table t3 (a varchar(255))|
4116+
insert into t3 (a) values ("a - table column")|
4117+
create procedure bug5967(a varchar(255))
41184118
begin
41194119
declare i varchar(255);
4120-
declare c cursor for select a from t1;
4120+
declare c cursor for select a from t3;
41214121
select a;
4122-
select a from t1 into i;
4122+
select a from t3 into i;
41234123
select i as 'Parameter takes precedence over table column'; open c;
41244124
fetch c into i;
41254125
close c;
41264126
select i as 'Parameter takes precedence over table column in cursors';
41274127
begin
41284128
declare a varchar(255) default 'a - local variable';
4129-
declare c1 cursor for select a from t1;
4129+
declare c1 cursor for select a from t3;
41304130
select a as 'A local variable takes precedence over parameter';
41314131
open c1;
41324132
fetch c1 into i;
41334133
close c1;
41344134
select i as 'A local variable takes precedence over parameter in cursors';
41354135
begin
41364136
declare a varchar(255) default 'a - local variable in a nested compound statement';
4137-
declare c2 cursor for select a from t1;
4137+
declare c2 cursor for select a from t3;
41384138
select a as 'A local variable in a nested compound statement takes precedence over a local variable in the outer statement';
4139-
select a from t1 into i;
4139+
select a from t3 into i;
41404140
select i as 'A local variable in a nested compound statement takes precedence over table column';
41414141
open c2;
41424142
fetch c2 into i;
@@ -4145,7 +4145,7 @@ select i as 'A local variable in a nested compound statement takes precedence o
41454145
end;
41464146
end;
41474147
end|
4148-
call p1("a - stored procedure parameter")|
4148+
call bug5967("a - stored procedure parameter")|
41494149
a
41504150
a - stored procedure parameter
41514151
Parameter takes precedence over table column
@@ -4162,7 +4162,7 @@ A local variable in a nested compound statement takes precedence over table colu
41624162
a - local variable in a nested compound statement
41634163
A local variable in a nested compound statement takes precedence over table column in cursors
41644164
a - local variable in a nested compound statement
4165-
drop procedure p1|
4165+
drop procedure bug5967|
41664166
drop procedure if exists bug13012|
41674167
create procedure bug13012()
41684168
BEGIN
@@ -4190,17 +4190,17 @@ call bug13012()|
41904190
Table Op Msg_type Msg_text
41914191
test.t1 repair status OK
41924192
test.t2 repair status OK
4193-
test.t3 repair error Table 'test.t3' doesn't exist
4193+
test.t3 repair status OK
41944194
test.v1 repair error 'test.v1' is not BASE TABLE
41954195
Table Op Msg_type Msg_text
41964196
test.t1 optimize status OK
41974197
test.t2 optimize status OK
4198-
test.t3 optimize error Table 'test.t3' doesn't exist
4198+
test.t3 optimize status OK
41994199
test.v1 optimize error 'test.v1' is not BASE TABLE
42004200
Table Op Msg_type Msg_text
42014201
test.t1 analyze status Table is already up to date
42024202
test.t2 analyze status Table is already up to date
4203-
test.t3 analyze error Table 'test.t3' doesn't exist
4203+
test.t3 analyze status Table is already up to date
42044204
test.v1 analyze error 'test.v1' is not BASE TABLE
42054205
Warnings:
42064206
Error 1146 Table 'test.t3' doesn't exist
@@ -4213,17 +4213,17 @@ call bug13012()|
42134213
Table Op Msg_type Msg_text
42144214
test.t1 repair status OK
42154215
test.t2 repair status OK
4216-
test.t3 repair error Table 'test.t3' doesn't exist
4216+
test.t3 repair status OK
42174217
test.v1 repair error 'test.v1' is not BASE TABLE
42184218
Table Op Msg_type Msg_text
42194219
test.t1 optimize status OK
42204220
test.t2 optimize status OK
4221-
test.t3 optimize error Table 'test.t3' doesn't exist
4221+
test.t3 optimize status OK
42224222
test.v1 optimize error 'test.v1' is not BASE TABLE
42234223
Table Op Msg_type Msg_text
42244224
test.t1 analyze status Table is already up to date
42254225
test.t2 analyze status Table is already up to date
4226-
test.t3 analyze error Table 'test.t3' doesn't exist
4226+
test.t3 analyze status Table is already up to date
42274227
test.v1 analyze error 'test.v1' is not BASE TABLE
42284228
Warnings:
42294229
Error 1146 Table 'test.t3' doesn't exist
@@ -4236,17 +4236,17 @@ call bug13012()|
42364236
Table Op Msg_type Msg_text
42374237
test.t1 repair status OK
42384238
test.t2 repair status OK
4239-
test.t3 repair error Table 'test.t3' doesn't exist
4239+
test.t3 repair status OK
42404240
test.v1 repair error 'test.v1' is not BASE TABLE
42414241
Table Op Msg_type Msg_text
42424242
test.t1 optimize status OK
42434243
test.t2 optimize status OK
4244-
test.t3 optimize error Table 'test.t3' doesn't exist
4244+
test.t3 optimize status OK
42454245
test.v1 optimize error 'test.v1' is not BASE TABLE
42464246
Table Op Msg_type Msg_text
42474247
test.t1 analyze status Table is already up to date
42484248
test.t2 analyze status Table is already up to date
4249-
test.t3 analyze error Table 'test.t3' doesn't exist
4249+
test.t3 analyze status Table is already up to date
42504250
test.v1 analyze error 'test.v1' is not BASE TABLE
42514251
Warnings:
42524252
Error 1146 Table 'test.t3' doesn't exist
@@ -4258,8 +4258,17 @@ Error 1347 'test.v1' is not BASE TABLE
42584258
drop procedure bug13012|
42594259
drop view v1;
42604260
select * from t1|
4261-
a
4262-
a - table column
4261+
id data
4262+
aa 0
4263+
aa 1
4264+
aa 2
4265+
aa 3
4266+
aa 4
4267+
aa 5
4268+
aa 6
4269+
aa 7
4270+
aa 8
4271+
aa 9
42634272
drop schema if exists mysqltest1|
42644273
Warnings:
42654274
Note 1008 Can't drop database 'mysqltest1'; database doesn't exist
@@ -4299,4 +4308,31 @@ drop schema if exists mysqltest1|
42994308
drop schema if exists mysqltest2|
43004309
drop schema if exists mysqltest3|
43014310
use test|
4311+
drop table if exists t3|
4312+
drop procedure if exists bug15441|
4313+
create table t3 (id int not null primary key, county varchar(25))|
4314+
insert into t3 (id, county) values (1, 'York')|
4315+
create procedure bug15441(c varchar(25))
4316+
begin
4317+
update t3 set id=2, county=values(c);
4318+
end|
4319+
call bug15441('county')|
4320+
ERROR 42S22: Unknown column 'c' in 'field list'
4321+
drop procedure bug15441|
4322+
create procedure bug15441(county varchar(25))
4323+
begin
4324+
declare c varchar(25) default "hello";
4325+
insert into t3 (id, county) values (1, county)
4326+
on duplicate key update county= values(county);
4327+
select * from t3;
4328+
update t3 set id=2, county=values(id);
4329+
select * from t3;
4330+
end|
4331+
call bug15441('Yale')|
4332+
id county
4333+
1 Yale
4334+
id county
4335+
2 NULL
4336+
drop table t3|
4337+
drop procedure bug15441|
43024338
drop table t1,t2;

mysql-test/r/subselect.result

+143
Original file line numberDiff line numberDiff line change
@@ -2988,3 +2988,146 @@ max(fld)
29882988
1
29892989
drop table t1;
29902990
purge master logs before (select adddate(current_timestamp(), interval -4 day));
2991+
CREATE TABLE t1 (a int, b int);
2992+
CREATE TABLE t2 (c int, d int);
2993+
CREATE TABLE t3 (e int);
2994+
INSERT INTO t1 VALUES
2995+
(1,10), (2,10), (1,20), (2,20), (3,20), (2,30), (4,40);
2996+
INSERT INTO t2 VALUES
2997+
(2,10), (2,20), (4,10), (5,10), (3,20), (2,40);
2998+
INSERT INTO t3 VALUES (10), (30), (10), (20) ;
2999+
SELECT a, MAX(b), MIN(b) FROM t1 GROUP BY a;
3000+
a MAX(b) MIN(b)
3001+
1 20 10
3002+
2 30 10
3003+
3 20 20
3004+
4 40 40
3005+
SELECT * FROM t2;
3006+
c d
3007+
2 10
3008+
2 20
3009+
4 10
3010+
5 10
3011+
3 20
3012+
2 40
3013+
SELECT * FROM t3;
3014+
e
3015+
10
3016+
30
3017+
10
3018+
20
3019+
SELECT a FROM t1 GROUP BY a
3020+
HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20);
3021+
a
3022+
2
3023+
4
3024+
SELECT a FROM t1 GROUP BY a
3025+
HAVING a IN (SELECT c FROM t2 WHERE MAX(b)<d);
3026+
a
3027+
2
3028+
SELECT a FROM t1 GROUP BY a
3029+
HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>d);
3030+
a
3031+
2
3032+
4
3033+
SELECT a FROM t1 GROUP BY a
3034+
HAVING a IN (SELECT c FROM t2
3035+
WHERE d >= SOME(SELECT e FROM t3 WHERE MAX(b)=e));
3036+
a
3037+
2
3038+
3
3039+
SELECT a FROM t1 GROUP BY a
3040+
HAVING a IN (SELECT c FROM t2
3041+
WHERE EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e <= d));
3042+
a
3043+
2
3044+
3
3045+
SELECT a FROM t1 GROUP BY a
3046+
HAVING a IN (SELECT c FROM t2
3047+
WHERE d > SOME(SELECT e FROM t3 WHERE MAX(b)=e));
3048+
a
3049+
2
3050+
SELECT a FROM t1 GROUP BY a
3051+
HAVING a IN (SELECT c FROM t2
3052+
WHERE EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e < d));
3053+
a
3054+
2
3055+
SELECT a FROM t1 GROUP BY a
3056+
HAVING a IN (SELECT c FROM t2
3057+
WHERE MIN(b) < d AND
3058+
EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e <= d));
3059+
a
3060+
2
3061+
SELECT a, SUM(a) FROM t1 GROUP BY a;
3062+
a SUM(a)
3063+
1 2
3064+
2 6
3065+
3 3
3066+
4 4
3067+
SELECT a FROM t1
3068+
WHERE EXISTS(SELECT c FROM t2 GROUP BY c HAVING SUM(a) = c) GROUP BY a;
3069+
a
3070+
3
3071+
4
3072+
SELECT a FROM t1 GROUP BY a
3073+
HAVING EXISTS(SELECT c FROM t2 GROUP BY c HAVING SUM(a) = c);
3074+
a
3075+
1
3076+
3
3077+
4
3078+
SELECT a FROM t1
3079+
WHERE a < 3 AND
3080+
EXISTS(SELECT c FROM t2 GROUP BY c HAVING SUM(a) != c) GROUP BY a;
3081+
a
3082+
1
3083+
2
3084+
SELECT a FROM t1
3085+
WHERE a < 3 AND
3086+
EXISTS(SELECT c FROM t2 GROUP BY c HAVING SUM(a) != c);
3087+
a
3088+
1
3089+
2
3090+
1
3091+
2
3092+
2
3093+
SELECT t1.a FROM t1 GROUP BY t1.a
3094+
HAVING t1.a < ALL(SELECT t2.c FROM t2 GROUP BY t2.c
3095+
HAVING EXISTS(SELECT t3.e FROM t3 GROUP BY t3.e
3096+
HAVING SUM(t1.a+t2.c) < t3.e/4));
3097+
a
3098+
1
3099+
2
3100+
SELECT t1.a FROM t1 GROUP BY t1.a
3101+
HAVING t1.a > ALL(SELECT t2.c FROM t2
3102+
WHERE EXISTS(SELECT t3.e FROM t3 GROUP BY t3.e
3103+
HAVING SUM(t1.a+t2.c) < t3.e/4));
3104+
a
3105+
4
3106+
SELECT t1.a FROM t1 GROUP BY t1.a
3107+
HAVING t1.a > ALL(SELECT t2.c FROM t2
3108+
WHERE EXISTS(SELECT t3.e FROM t3
3109+
WHERE SUM(t1.a+t2.c) < t3.e/4));
3110+
ERROR HY000: Invalid use of group function
3111+
SELECT t1.a from t1 GROUP BY t1.a HAVING AVG(SUM(t1.b)) > 20;
3112+
ERROR HY000: Invalid use of group function
3113+
SELECT t1.a FROM t1 GROUP BY t1.a
3114+
HAVING t1.a IN (SELECT t2.c FROM t2 GROUP BY t2.c
3115+
HAVING AVG(t2.c+SUM(t1.b)) > 20);
3116+
a
3117+
2
3118+
3
3119+
4
3120+
SELECT t1.a FROM t1 GROUP BY t1.a
3121+
HAVING t1.a IN (SELECT t2.c FROM t2 GROUP BY t2.c
3122+
HAVING AVG(SUM(t1.b)) > 20);
3123+
a
3124+
2
3125+
4
3126+
SELECT t1.a, SUM(b) AS sum FROM t1 GROUP BY t1.a
3127+
HAVING t1.a IN (SELECT t2.c FROM t2 GROUP BY t2.c
3128+
HAVING t2.c+sum > 20);
3129+
a sum
3130+
2 60
3131+
3 20
3132+
4 40
3133+
DROP TABLE t1,t2,t3;

0 commit comments

Comments
 (0)