~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/func_test.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
# Bug#23411: The "%" (MOD) operator is not documented; MOD-ing zero returns strange result
70
70
# Manual: "Division by zero produces a NULL result"
71
71
#
72
 
--error ER_DIVISION_BY_ZERO
73
72
select (12%0) <=> null      as '1';
74
 
--error ER_DIVISION_BY_ZERO
75
73
select (12%0) is null       as '1';
76
 
--error ER_DIVISION_BY_ZERO
77
74
select 12%0                 as 'NULL';
78
75
select 12%2                 as '0';
79
76
select 12%NULL              as 'NULL';
83
80
select 0 % null             as 'NULL';
84
81
select null % null          as 'NULL';
85
82
 
86
 
--error ER_DIVISION_BY_ZERO
87
83
select (12 mod 0) <=> null  as '1';
88
 
--error ER_DIVISION_BY_ZERO
89
84
select (12 mod 0) is null   as '1';
90
 
--error ER_DIVISION_BY_ZERO
91
85
select 12 mod 0             as 'NULL';
92
86
select 12 mod 2             as '0';
93
87
select 12 mod null          as 'NULL';
96
90
select 0 mod null           as 'NULL';
97
91
select null mod null        as 'NULL';
98
92
 
99
 
--error ER_DIVISION_BY_ZERO
100
93
select mod(12.0, 0)         as 'NULL';
101
 
--error ER_DIVISION_BY_ZERO
102
94
select mod(12, 0.0)         as 'NULL';
103
95
select mod(12, NULL)        as 'NULL';
104
96
select mod(12.0, NULL)      as 'NULL';