~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/archive/archive_test.cc

  • 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:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
 
#include <config.h>
 
16
#include "config.h"
17
17
#include "azio.h"
18
18
#include <string.h>
19
19
#include <assert.h>
22
22
#include <fcntl.h>
23
23
#include <unistd.h>
24
24
#include <cstdlib>
25
 
#include <memory>
26
25
 
27
26
#if TIME_WITH_SYS_TIME
28
27
# include <sys/time.h>
35
34
# endif
36
35
#endif
37
36
 
38
 
#include <boost/scoped_ptr.hpp>
39
 
 
40
37
#define COMMENT_STRING "Your bases"
41
38
#define FRM_STRING "My bases"
42
39
#define TEST_FILENAME "test.az"
114
111
  int error;
115
112
  unsigned int x;
116
113
  int written_rows= 0;
117
 
  boost::scoped_ptr<azio_stream> writer_handle_ap(new azio_stream);
118
 
  boost::scoped_ptr<azio_stream> reader_handle_ap(new azio_stream);
119
 
  azio_stream &writer_handle= *writer_handle_ap.get();
120
 
  azio_stream &reader_handle= *reader_handle_ap.get();
 
114
  azio_stream writer_handle, reader_handle;
121
115
 
122
116
  memcpy(test_string, TEST_STRING_INIT, 1024);
123
117
 
291
285
int size_test(uint64_t length, uint64_t rows_to_test_for,
292
286
              az_method method)
293
287
{
294
 
  boost::scoped_ptr<azio_stream> writer_handle_ap(new azio_stream);
295
 
  boost::scoped_ptr<azio_stream> reader_handle_ap(new azio_stream);
296
 
  azio_stream &writer_handle= *writer_handle_ap.get();
297
 
  azio_stream &reader_handle= *reader_handle_ap.get();
 
288
  azio_stream writer_handle, reader_handle;
298
289
  uint64_t write_length;
299
290
  uint64_t read_length;
300
291
  uint64_t count;