Loading mysql-test/r/group_by.result +10 −21 Original line number Diff line number Diff line Loading @@ -723,27 +723,6 @@ WHERE hostname LIKE '%aol%' hostname no cache-dtc-af05.proxy.aol.com 1 DROP TABLE t1; create table t1 (c1 char(3), c2 char(3)); create table t2 (c3 char(3), c4 char(3)); insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2'); insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2'); select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 group by c2; c2 aaa aaa Warnings: Warning 1052 Column 'c2' in group statement is ambiguous show warnings; Level Code Message Warning 1052 Column 'c2' in group statement is ambiguous select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 group by t1.c1; c2 aaa show warnings; Level Code Message drop table t1, t2; CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (1,2), (1,3); SELECT a, b FROM t1 GROUP BY 'const'; Loading @@ -762,3 +741,13 @@ SELECT dt DIV 1 AS f, id FROM t1 GROUP BY f; f id 20050501123000 1 DROP TABLE t1; CREATE TABLE t1 (id varchar(20) NOT NULL); INSERT INTO t1 VALUES ('trans1'), ('trans2'); CREATE TABLE t2 (id varchar(20) NOT NULL, err_comment blob NOT NULL); INSERT INTO t2 VALUES ('trans1', 'a problem'); SELECT COUNT(DISTINCT(t1.id)), LEFT(err_comment, 256) AS comment FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY comment; COUNT(DISTINCT(t1.id)) comment 1 NULL 1 a problem DROP TABLE t1, t2; mysql-test/r/view.result +14 −0 Original line number Diff line number Diff line Loading @@ -1726,6 +1726,20 @@ sum(a) drop procedure p1; drop view v1; drop table t1; CREATE TABLE t1(a char(2) primary key, b char(2)); CREATE TABLE t2(a char(2), b char(2), index i(a)); INSERT INTO t1 VALUES ('a','1'), ('b','2'); INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6'); CREATE VIEW v1 AS SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a; SELECT d, c FROM v1 ORDER BY d; d c 5 1 5 2 6 1 6 2 DROP VIEW v1; DROP TABLE t1, t2; create table t1 (s1 int); create view v1 as select sum(distinct s1) from t1; select * from v1; Loading mysql-test/t/group_by.test +15 −24 Original line number Diff line number Diff line Loading @@ -542,30 +542,6 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1 DROP TABLE t1; # # Bug#11211: Ambiguous column reference in GROUP BY. # create table t1 (c1 char(3), c2 char(3)); create table t2 (c3 char(3), c4 char(3)); insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2'); insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2'); # query with ambiguous column reference 'c2' --disable_ps_protocol select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 group by c2; show warnings; --enable_ps_protocol # this query has no ambiguity select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 group by t1.c1; show warnings; drop table t1, t2; # # Test for bug #8614: GROUP BY 'const' with DISTINCT # Loading @@ -589,3 +565,18 @@ INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); SELECT dt DIV 1 AS f, id FROM t1 GROUP BY f; DROP TABLE t1; # # Test for bug #11295: GROUP BY a BLOB column with COUNT(DISTINCT column1) # when the BLOB column takes NULL values # CREATE TABLE t1 (id varchar(20) NOT NULL); INSERT INTO t1 VALUES ('trans1'), ('trans2'); CREATE TABLE t2 (id varchar(20) NOT NULL, err_comment blob NOT NULL); INSERT INTO t2 VALUES ('trans1', 'a problem'); SELECT COUNT(DISTINCT(t1.id)), LEFT(err_comment, 256) AS comment FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY comment; DROP TABLE t1, t2; mysql-test/t/view.test +12 −0 Original line number Diff line number Diff line Loading @@ -1569,6 +1569,18 @@ drop procedure p1; drop view v1; drop table t1; # # Bug#7422 "order by" doesn't work # CREATE TABLE t1(a char(2) primary key, b char(2)); CREATE TABLE t2(a char(2), b char(2), index i(a)); INSERT INTO t1 VALUES ('a','1'), ('b','2'); INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6'); CREATE VIEW v1 AS SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a; SELECT d, c FROM v1 ORDER BY d; DROP VIEW v1; DROP TABLE t1, t2; # # using sum(distinct ) & avg(distinct ) in views (BUG#7015) # Loading sql/filesort.cc +5 −5 Original line number Diff line number Diff line Loading @@ -631,7 +631,7 @@ static void make_sortkey(register SORTPARAM *param, *to++=1; /* All item->str() to use some extra byte for end null.. */ String tmp((char*) to,sort_field->length+4,cs); String *res=item->val_str(&tmp); String *res= item->str_result(&tmp); if (!res) { if (maybe_null) Loading Loading @@ -673,7 +673,7 @@ static void make_sortkey(register SORTPARAM *param, } case INT_RESULT: { longlong value=item->val_int(); longlong value= item->val_int_result(); if (maybe_null) { *to++=1; /* purecov: inspected */ Loading Loading @@ -715,7 +715,7 @@ static void make_sortkey(register SORTPARAM *param, } case DECIMAL_RESULT: { my_decimal dec_buf, *dec_val= item->val_decimal(&dec_buf); my_decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf); if (maybe_null) { if (item->null_value) Loading @@ -733,7 +733,7 @@ static void make_sortkey(register SORTPARAM *param, } case REAL_RESULT: { double value= item->val_real(); double value= item->val_result(); if (maybe_null) { if (item->null_value) Loading Loading
mysql-test/r/group_by.result +10 −21 Original line number Diff line number Diff line Loading @@ -723,27 +723,6 @@ WHERE hostname LIKE '%aol%' hostname no cache-dtc-af05.proxy.aol.com 1 DROP TABLE t1; create table t1 (c1 char(3), c2 char(3)); create table t2 (c3 char(3), c4 char(3)); insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2'); insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2'); select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 group by c2; c2 aaa aaa Warnings: Warning 1052 Column 'c2' in group statement is ambiguous show warnings; Level Code Message Warning 1052 Column 'c2' in group statement is ambiguous select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 group by t1.c1; c2 aaa show warnings; Level Code Message drop table t1, t2; CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (1,2), (1,3); SELECT a, b FROM t1 GROUP BY 'const'; Loading @@ -762,3 +741,13 @@ SELECT dt DIV 1 AS f, id FROM t1 GROUP BY f; f id 20050501123000 1 DROP TABLE t1; CREATE TABLE t1 (id varchar(20) NOT NULL); INSERT INTO t1 VALUES ('trans1'), ('trans2'); CREATE TABLE t2 (id varchar(20) NOT NULL, err_comment blob NOT NULL); INSERT INTO t2 VALUES ('trans1', 'a problem'); SELECT COUNT(DISTINCT(t1.id)), LEFT(err_comment, 256) AS comment FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY comment; COUNT(DISTINCT(t1.id)) comment 1 NULL 1 a problem DROP TABLE t1, t2;
mysql-test/r/view.result +14 −0 Original line number Diff line number Diff line Loading @@ -1726,6 +1726,20 @@ sum(a) drop procedure p1; drop view v1; drop table t1; CREATE TABLE t1(a char(2) primary key, b char(2)); CREATE TABLE t2(a char(2), b char(2), index i(a)); INSERT INTO t1 VALUES ('a','1'), ('b','2'); INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6'); CREATE VIEW v1 AS SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a; SELECT d, c FROM v1 ORDER BY d; d c 5 1 5 2 6 1 6 2 DROP VIEW v1; DROP TABLE t1, t2; create table t1 (s1 int); create view v1 as select sum(distinct s1) from t1; select * from v1; Loading
mysql-test/t/group_by.test +15 −24 Original line number Diff line number Diff line Loading @@ -542,30 +542,6 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1 DROP TABLE t1; # # Bug#11211: Ambiguous column reference in GROUP BY. # create table t1 (c1 char(3), c2 char(3)); create table t2 (c3 char(3), c4 char(3)); insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2'); insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2'); # query with ambiguous column reference 'c2' --disable_ps_protocol select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 group by c2; show warnings; --enable_ps_protocol # this query has no ambiguity select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 group by t1.c1; show warnings; drop table t1, t2; # # Test for bug #8614: GROUP BY 'const' with DISTINCT # Loading @@ -589,3 +565,18 @@ INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); SELECT dt DIV 1 AS f, id FROM t1 GROUP BY f; DROP TABLE t1; # # Test for bug #11295: GROUP BY a BLOB column with COUNT(DISTINCT column1) # when the BLOB column takes NULL values # CREATE TABLE t1 (id varchar(20) NOT NULL); INSERT INTO t1 VALUES ('trans1'), ('trans2'); CREATE TABLE t2 (id varchar(20) NOT NULL, err_comment blob NOT NULL); INSERT INTO t2 VALUES ('trans1', 'a problem'); SELECT COUNT(DISTINCT(t1.id)), LEFT(err_comment, 256) AS comment FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY comment; DROP TABLE t1, t2;
mysql-test/t/view.test +12 −0 Original line number Diff line number Diff line Loading @@ -1569,6 +1569,18 @@ drop procedure p1; drop view v1; drop table t1; # # Bug#7422 "order by" doesn't work # CREATE TABLE t1(a char(2) primary key, b char(2)); CREATE TABLE t2(a char(2), b char(2), index i(a)); INSERT INTO t1 VALUES ('a','1'), ('b','2'); INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6'); CREATE VIEW v1 AS SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a; SELECT d, c FROM v1 ORDER BY d; DROP VIEW v1; DROP TABLE t1, t2; # # using sum(distinct ) & avg(distinct ) in views (BUG#7015) # Loading
sql/filesort.cc +5 −5 Original line number Diff line number Diff line Loading @@ -631,7 +631,7 @@ static void make_sortkey(register SORTPARAM *param, *to++=1; /* All item->str() to use some extra byte for end null.. */ String tmp((char*) to,sort_field->length+4,cs); String *res=item->val_str(&tmp); String *res= item->str_result(&tmp); if (!res) { if (maybe_null) Loading Loading @@ -673,7 +673,7 @@ static void make_sortkey(register SORTPARAM *param, } case INT_RESULT: { longlong value=item->val_int(); longlong value= item->val_int_result(); if (maybe_null) { *to++=1; /* purecov: inspected */ Loading Loading @@ -715,7 +715,7 @@ static void make_sortkey(register SORTPARAM *param, } case DECIMAL_RESULT: { my_decimal dec_buf, *dec_val= item->val_decimal(&dec_buf); my_decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf); if (maybe_null) { if (item->null_value) Loading @@ -733,7 +733,7 @@ static void make_sortkey(register SORTPARAM *param, } case REAL_RESULT: { double value= item->val_real(); double value= item->val_result(); if (maybe_null) { if (item->null_value) Loading