~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/conclusions.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
 
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2010 Vijay Samuel
5
 
 *  Copyright (C) 2008 MySQL
6
 
 *
7
 
 *  This program is free software; you can redistribute it and/or modify
8
 
 *  it under the terms of the GNU General Public License as published by
9
 
 *  the Free Software Foundation; either version 2 of the License, or
10
 
 *  (at your option) any later version.
11
 
 *
12
 
 *  This program is distributed in the hope that it will be useful,
13
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 *  GNU General Public License for more details.
16
 
 *
17
 
 *  You should have received a copy of the GNU General Public License
18
 
 *  along with this program; if not, write to the Free Software
19
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
 
 */
21
 
#ifndef CLIENT_CONCLUSIONS_H
22
 
#define CLIENT_CONCLUSIONS_H
23
 
 
24
 
#include "client_priv.h"
25
 
#include <string>
26
 
#include <iostream>
27
 
 
28
 
class Conclusions 
29
 
{
30
 
 
31
 
public:
32
 
  Conclusions(char *in_engine,
33
 
              long int in_avg_timing,
34
 
              long int in_max_timing,
35
 
              long int in_min_timing,
36
 
              uint32_t in_users,
37
 
              uint32_t in_real_users,
38
 
              uint64_t in_avg_rows,
39
 
              long int in_sum_of_time,
40
 
              long int in_std_dev,
41
 
              long int in_create_avg_timing,
42
 
              long int in_create_max_timing,
43
 
              long int in_create_min_timing,
44
 
              uint64_t in_create_count,
45
 
              uint64_t in_max_rows,
46
 
              uint64_t in_min_rows) :
47
 
    engine(in_engine),
48
 
    avg_timing(in_avg_timing),
49
 
    max_timing(in_max_timing),
50
 
    min_timing(in_min_timing),
51
 
    users(in_users),
52
 
    real_users(in_real_users),
53
 
    avg_rows(in_avg_rows),
54
 
    sum_of_time(in_sum_of_time),
55
 
    std_dev(in_std_dev),
56
 
    create_avg_timing(in_create_avg_timing),
57
 
    create_max_timing(in_create_max_timing),
58
 
    create_min_timing(in_create_min_timing),
59
 
    create_count(in_create_count),
60
 
    max_rows(in_max_rows),
61
 
    min_rows(in_min_rows)
62
 
  { }
63
 
 
64
 
  Conclusions() :
65
 
    engine(NULL),
66
 
    avg_timing(0),
67
 
    max_timing(0),
68
 
    min_timing(0),
69
 
    users(0),
70
 
    real_users(0),
71
 
    avg_rows(0),
72
 
    sum_of_time(0),
73
 
    std_dev(0),
74
 
    create_avg_timing(0),
75
 
    create_max_timing(0),
76
 
    create_min_timing(0),
77
 
    create_count(0),
78
 
    max_rows(0),
79
 
    min_rows(0)
80
 
  { }
81
 
 
82
 
  char *getEngine() const
83
 
  {
84
 
    return engine;
85
 
  }
86
 
  
87
 
  long int getAvgTiming() const
88
 
  {
89
 
    return avg_timing;
90
 
  }
91
 
 
92
 
  long int getMaxTiming() const
93
 
  {
94
 
    return max_timing;
95
 
  }
96
 
 
97
 
  long int getMinTiming() const
98
 
  {
99
 
    return min_timing;
100
 
  }
101
 
 
102
 
  uint32_t getUsers() const
103
 
  {
104
 
    return users;
105
 
  }
106
 
 
107
 
  uint32_t getRealUsers() const
108
 
  {
109
 
    return real_users;
110
 
  }
111
 
 
112
 
  uint64_t getAvgRows() const
113
 
  {
114
 
    return avg_rows;
115
 
  }   
116
 
 
117
 
  long int getSumOfTime() const
118
 
  {
119
 
    return sum_of_time;
120
 
  }
121
 
 
122
 
  long int getStdDev() const
123
 
  {
124
 
    return std_dev;
125
 
  }
126
 
 
127
 
  long int getCreateAvgTiming() const
128
 
  {
129
 
    return create_avg_timing;
130
 
  }
131
 
 
132
 
  long int getCreateMaxTiming() const
133
 
  {
134
 
    return create_max_timing;
135
 
  }
136
 
 
137
 
  long int getCreateMinTiming() const
138
 
  {
139
 
    return create_min_timing;
140
 
  }
141
 
   
142
 
  uint64_t getCreateCount() const
143
 
  {
144
 
    return create_count;
145
 
  }
146
 
 
147
 
  uint64_t getMinRows() const
148
 
  {
149
 
    return min_rows;
150
 
  }
151
 
 
152
 
  uint64_t getMaxRows() const
153
 
  {
154
 
    return max_rows;
155
 
  }
156
 
 
157
 
  void setEngine(char *in_engine) 
158
 
  {
159
 
    engine= in_engine;
160
 
  }
161
 
  
162
 
  void setAvgTiming(long int in_avg_timing) 
163
 
  {
164
 
    avg_timing= in_avg_timing;
165
 
  }
166
 
 
167
 
  void setMaxTiming(long int in_max_timing) 
168
 
  {
169
 
    max_timing= in_max_timing;
170
 
  }
171
 
 
172
 
  void setMinTiming(long int in_min_timing) 
173
 
  {
174
 
    min_timing= in_min_timing;
175
 
  }
176
 
 
177
 
  void setUsers(uint32_t in_users) 
178
 
  {
179
 
    users= in_users;
180
 
  }
181
 
 
182
 
  void setRealUsers(uint32_t in_real_users) 
183
 
  {
184
 
    real_users= in_real_users;
185
 
  }
186
 
 
187
 
  void setAvgRows(uint64_t in_avg_rows) 
188
 
  {
189
 
    avg_rows= in_avg_rows;
190
 
  }   
191
 
 
192
 
  void setSumOfTime(long int in_sum_of_time) 
193
 
  {
194
 
    sum_of_time= in_sum_of_time;
195
 
  }
196
 
 
197
 
  void setStdDev(long int in_std_dev) 
198
 
  {
199
 
    std_dev= in_std_dev;
200
 
  }
201
 
 
202
 
  void setCreateAvgTiming(long int in_create_avg_timing) 
203
 
  {
204
 
    create_avg_timing= in_create_avg_timing;
205
 
  }
206
 
 
207
 
  void setCreateMaxTiming(long int in_create_max_timing) 
208
 
  {
209
 
    create_max_timing= in_create_max_timing;
210
 
  }
211
 
 
212
 
  void setCreateMinTiming(long int in_create_min_timing) 
213
 
  {
214
 
    create_min_timing= in_create_min_timing;
215
 
  }
216
 
   
217
 
  void setCreateCount(uint64_t in_create_count) 
218
 
  {
219
 
    create_count= in_create_count;
220
 
  }
221
 
 
222
 
  void setMinRows(uint64_t in_min_rows) 
223
 
  {
224
 
    min_rows= in_min_rows;
225
 
  }
226
 
 
227
 
  void setMaxRows(uint64_t in_max_rows) 
228
 
  {
229
 
    max_rows= in_max_rows;
230
 
  }
231
 
 
232
 
private:
233
 
  char *engine;
234
 
  long int avg_timing;
235
 
  long int max_timing;
236
 
  long int min_timing;
237
 
  uint32_t users;
238
 
  uint32_t real_users;
239
 
  uint64_t avg_rows;
240
 
  long int sum_of_time;
241
 
  long int std_dev;
242
 
  /* These are just for create time stats */
243
 
  long int create_avg_timing;
244
 
  long int create_max_timing;
245
 
  long int create_min_timing;
246
 
  uint64_t create_count;
247
 
  /* The following are not used yet */
248
 
  uint64_t max_rows;
249
 
  uint64_t min_rows;
250
 
};
251
 
 
252
 
#endif /* CLIENT_CONCLUSIONS_H */