~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSConfig.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
 
/* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
 
1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
2
2
 *
3
3
 * PrimeBase Media Stream for MySQL
4
4
 *
14
14
 *
15
15
 * You should have received a copy of the GNU General Public License
16
16
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
 *
19
19
 * Original author: Paul McCullagh (H&G2JCtL)
20
20
 * Continued development: Barry Leslie
36
36
// in other headers. So the only safe thing I can think of is to include it in all source code
37
37
// files.
38
38
#ifdef DRIZZLED
39
 
#include <config.h>
 
39
#include "config.h"
40
40
#include <drizzled/common.h>
41
41
#else
42
42
#include "my_global.h"
43
43
#include "mysql_priv.h"
44
44
#endif
45
45
 
46
 
#else  // defined(MYSQL_SERVER) ||  defined(DRIZZLED)
 
46
/* Note: mysql_priv.h messes with new, which caused a crash. */
 
47
#ifdef new
 
48
#undef new
 
49
#endif
47
50
 
48
 
#if defined(WIN32) ||  defined(WIN64) 
49
 
#include "win_config.h"
50
51
#else
51
 
#include <config.h>
52
 
#endif
53
 
 
54
 
#endif // defined(MYSQL_SERVER) ||  defined(DRIZZLED)
55
 
 
 
52
#include "config.h"
 
53
#endif  //defined(MYSQL_SERVER) ||  defined(DRIZZLED)
 
54
 
 
55
#include <sys/types.h>
 
56
#include <inttypes.h>
 
57
#include <unistd.h>
56
58
 
57
59
/*
58
60
 * This enables everything that GNU can do. The macro is actually
62
64
#define _GNU_SOURCE
63
65
#endif
64
66
 
65
 
/*
66
 
 * Make sure we use the thread safe version of the library.
67
 
 */
68
 
#ifndef _THREAD_SAFE // Seems to be defined by some Drizzle header
69
 
#define _THREAD_SAFE
70
 
#endif
71
 
 
72
 
/*
73
 
 * This causes things to be defined like stuff in inttypes.h
74
 
 * which is used in printf()
75
 
 */
76
 
#ifndef __STDC_FORMAT_MACROS
77
 
#define __STDC_FORMAT_MACROS
 
67
#ifndef NODEBUG
 
68
#ifdef DEBUG
 
69
#ifndef DBUG_OFF
 
70
#ifndef DEBUG
 
71
#define DEBUG
 
72
#endif
 
73
#endif
 
74
#endif
78
75
#endif
79
76
 
80
77
/*
81
78
 * What operating system are we on?
82
79
 */
83
 
#ifdef __APPLE__
 
80
#ifdef __darwin__
84
81
#define OS_MACINTOSH
85
82
#endif
86
83
 
87
 
#if defined(MSDOS) || defined(__WIN__) || defined(_WIN64) || defined(WIN32)
 
84
#if defined(MSDOS) || defined(__WIN__) || defined(_WIN64)
88
85
#define OS_WINDOWS
89
86
#endif
90
87
 
91
 
#ifdef __FreeBSD__
92
 
#define OS_FREEBSD
93
 
#endif
94
 
 
95
 
#ifdef __NetBSD__
96
 
#define OS_NETBSD
97
 
#endif
98
 
 
99
88
#ifdef __sun
100
89
#define OS_SOLARIS
101
90
#endif
102
91
 
103
 
#if defined(_DEBUG) || defined(DBUG_ON)
104
 
#if !defined(NODEBUG) && !defined(DBUG_OFF) && !defined(DEBUG)
 
92
 
 
93
#ifdef OS_WINDOWS
 
94
#ifdef _DEBUG
 
95
#ifndef NODEBUG
 
96
#ifndef DBUG_OFF
 
97
#ifndef DEBUG
105
98
#define DEBUG
106
99
#endif
107
100
#endif
 
101
#endif
 
102
#endif
 
103
#endif
108
104
 
109
105
#endif