~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/eval0proc.h

  • 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:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1998, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/eval0proc.h
21
 
Executes SQL stored procedures and their control structures
22
 
 
23
 
Created 1/20/1998 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#ifndef eval0proc_h
27
 
#define eval0proc_h
28
 
 
29
 
#include "univ.i"
30
 
#include "que0types.h"
31
 
#include "pars0sym.h"
32
 
#include "pars0pars.h"
33
 
 
34
 
/**********************************************************************//**
35
 
Performs an execution step of a procedure node.
36
 
@return query thread to run next or NULL */
37
 
UNIV_INLINE
38
 
que_thr_t*
39
 
proc_step(
40
 
/*======*/
41
 
        que_thr_t*      thr);   /*!< in: query thread */
42
 
/**********************************************************************//**
43
 
Performs an execution step of an if-statement node.
44
 
@return query thread to run next or NULL */
45
 
UNIV_INTERN
46
 
que_thr_t*
47
 
if_step(
48
 
/*====*/
49
 
        que_thr_t*      thr);   /*!< in: query thread */
50
 
/**********************************************************************//**
51
 
Performs an execution step of a while-statement node.
52
 
@return query thread to run next or NULL */
53
 
UNIV_INTERN
54
 
que_thr_t*
55
 
while_step(
56
 
/*=======*/
57
 
        que_thr_t*      thr);   /*!< in: query thread */
58
 
/**********************************************************************//**
59
 
Performs an execution step of a for-loop node.
60
 
@return query thread to run next or NULL */
61
 
UNIV_INTERN
62
 
que_thr_t*
63
 
for_step(
64
 
/*=====*/
65
 
        que_thr_t*      thr);   /*!< in: query thread */
66
 
/**********************************************************************//**
67
 
Performs an execution step of an assignment statement node.
68
 
@return query thread to run next or NULL */
69
 
UNIV_INTERN
70
 
que_thr_t*
71
 
assign_step(
72
 
/*========*/
73
 
        que_thr_t*      thr);   /*!< in: query thread */
74
 
/**********************************************************************//**
75
 
Performs an execution step of a procedure call node.
76
 
@return query thread to run next or NULL */
77
 
UNIV_INLINE
78
 
que_thr_t*
79
 
proc_eval_step(
80
 
/*===========*/
81
 
        que_thr_t*      thr);   /*!< in: query thread */
82
 
/**********************************************************************//**
83
 
Performs an execution step of an exit statement node.
84
 
@return query thread to run next or NULL */
85
 
UNIV_INTERN
86
 
que_thr_t*
87
 
exit_step(
88
 
/*======*/
89
 
        que_thr_t*      thr);   /*!< in: query thread */
90
 
/**********************************************************************//**
91
 
Performs an execution step of a return-statement node.
92
 
@return query thread to run next or NULL */
93
 
UNIV_INTERN
94
 
que_thr_t*
95
 
return_step(
96
 
/*========*/
97
 
        que_thr_t*      thr);   /*!< in: query thread */
98
 
 
99
 
 
100
 
#ifndef UNIV_NONINL
101
 
#include "eval0proc.ic"
102
 
#endif
103
 
 
104
 
#endif