~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/my_sys.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:
49
49
 
50
50
#include <drizzled/dynamic_array.h>
51
51
 
52
 
#ifdef HAVE_SYS_MMAN_H 
53
52
#include <sys/mman.h>
54
 
#endif
55
53
 
56
54
#include "drizzled/qsort_cmp.h"
57
55
 
171
169
 
172
170
extern bool timed_mutexes;
173
171
 
174
 
typedef class wild_file_pack    /* Struct to hold info when selecting files */
 
172
typedef struct wild_file_pack   /* Struct to hold info when selecting files */
175
173
{
176
 
public:
177
174
  uint          wilds;          /* How many wildcards */
178
175
  uint          not_pos;        /* Start of not-theese-files */
179
176
  char *        *wild;          /* Pointer to wildcards */
180
 
 
181
 
  wild_file_pack():
182
 
    wilds(0),
183
 
    not_pos(0),
184
 
    wild(NULL)
185
 
  {}
186
 
 
187
177
} WF_PACK;
188
178
 
189
179
enum cache_type
196
186
  WRITE_NET
197
187
};
198
188
 
199
 
typedef struct record_cache     /* Used when cacheing records */
 
189
typedef struct st_record_cache  /* Used when cacheing records */
200
190
{
201
 
public:
202
191
  int file;
203
192
  int   rc_seek,error,inited;
204
193
  uint  rc_length,read_length,reclength;
209
198
  my_aio_result aio_result;
210
199
#endif
211
200
  enum cache_type type;
212
 
 
213
 
  record_cache():
214
 
    file(0),
215
 
    rc_seek(0),
216
 
    error(0),
217
 
    inited(0),
218
 
    rc_length(0),
219
 
    read_length(0),
220
 
    reclength(0),
221
 
    rc_record_pos(0),
222
 
    end_of_file(0),
223
 
    rc_buff(NULL),
224
 
    rc_buff2(NULL),
225
 
    rc_pos(NULL),
226
 
    rc_end(NULL),
227
 
    rc_request_pos(NULL)
228
 
  {}
229
 
 
230
201
} RECORD_CACHE;
231
202
 
232
203
 
329
300
extern int wild_compare(const char *str,const char *wildstr,
330
301
                        bool str_is_pattern);
331
302
extern WF_PACK *wf_comp(char * str);
332
 
extern int wf_test(wild_file_pack *wf_pack,const char *name);
333
 
extern void wf_end(wild_file_pack *buffer);
 
303
extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
 
304
extern void wf_end(struct wild_file_pack *buffer);
334
305
extern bool array_append_string_unique(const char *str,
335
306
                                          const char **array, size_t size);
336
307
extern void get_date(char * to,int timeflag,time_t use_time);