~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/func_gconcat.test

  • Committer: Stewart Smith
  • Date: 2010-08-12 16:48:46 UTC
  • mto: This revision was merged to the branch mainline in revision 1707.
  • Revision ID: stewart@flamingspork.com-20100812164846-s9bhy47g60bvqs41
bug lp:611379 Equivalent queries with Impossible where return different results

The following two equivalent queries return different results in maria 5.2 and 5.3 (and identical results in mysql 5.5.5) :

SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` ;

SELECT * FROM ( SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` );

MariaDB returns 0 on the second query and NULL on the first, whereas MySQL returns NULL on both. In MariaDB, both EXPLAIN plans agree that "Impossible WHERE noticed after reading const tables"



We have some slightly different output in drizzle:

main.bug_lp611379 [ fail ]
drizzletest: At line 9: query 'explain select * from (select sum(distinct t1.a) from t1,t2 where t1.a=t2.a)
as t' failed: 1048: Column 'sum(distinct t1.a)' cannot be null

but the fix gets us the correct query results, although with slightly different execution plans.



This fix is directly ported from MariaDB.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 
70
70
# Test errors
71
71
 
72
 
--error ER_INVALID_GROUP_FUNC_USE
 
72
--error 1111
73
73
select group_concat(sum(c)) from t1 group by grp;
74
 
--error ER_BAD_FIELD_ERROR
 
74
--error 1054
75
75
select grp,group_concat(c order by 2) from t1 group by grp;
76
76
 
77
77
drop table t1;
104
104
create table t1(id int);
105
105
create table t2(id int);
106
106
insert into t1 values(0),(1);
107
 
select group_concat(t1.id) FROM t1,t2 where t2.id < 2;
 
107
select group_concat(t1.id) FROM t1,t2;
108
108
drop table t1;
109
109
drop table t2;
110
110
 
190
190
CREATE TABLE t2 ( a int );
191
191
INSERT INTO t1 VALUES (1), (2);
192
192
INSERT INTO t2 VALUES (1), (2);
193
 
SELECT GROUP_CONCAT(t1.a*t2.a ORDER BY t2.a) FROM t1, t2 WHERE t1.a < 3 GROUP BY t1.a;
 
193
SELECT GROUP_CONCAT(t1.a*t2.a ORDER BY t2.a) FROM t1, t2 GROUP BY t1.a;
194
194
DROP TABLE t1, t2;
195
195
 
196
196
#
602
602
 FROM
603
603
  t1 AS t1,
604
604
  t1 AS t2
605
 
 WHERE t2.a IS NULL
606
605
 GROUP BY 1
607
606
) AS s1;
608
607
DROP TABLE t1;