~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/drizzle_client.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
 
 * Drizzle Client & Protocol Library
3
 
 *
4
 
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
5
 
 * All rights reserved.
6
 
 *
7
 
 * Redistribution and use in source and binary forms, with or without
8
 
 * modification, are permitted provided that the following conditions are
9
 
 * met:
10
 
 *
11
 
 *     * Redistributions of source code must retain the above copyright
12
 
 * notice, this list of conditions and the following disclaimer.
13
 
 *
14
 
 *     * Redistributions in binary form must reproduce the above
15
 
 * copyright notice, this list of conditions and the following disclaimer
16
 
 * in the documentation and/or other materials provided with the
17
 
 * distribution.
18
 
 *
19
 
 *     * The names of its contributors may not be used to endorse or
20
 
 * promote products derived from this software without specific prior
21
 
 * written permission.
22
 
 *
23
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
 
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
 
 *
35
 
 */
36
 
 
37
 
 
38
 
/**
39
 
 * @file
40
 
 * @brief Drizzle Declarations for Clients
41
 
 */
42
 
 
43
 
#ifndef __DRIZZLE_CLIENT_H
44
 
#define __DRIZZLE_CLIENT_H
45
 
 
46
 
#include <libdrizzle/drizzle.h>
47
 
#include <libdrizzle/conn_client.h>
48
 
#include <libdrizzle/handshake_client.h>
49
 
#include <libdrizzle/command_client.h>
50
 
#include <libdrizzle/query.h>
51
 
#include <libdrizzle/result_client.h>
52
 
#include <libdrizzle/column_client.h>
53
 
#include <libdrizzle/row_client.h>
54
 
#include <libdrizzle/field_client.h>
55
 
 
56
 
#ifdef __cplusplus
57
 
extern "C" {
58
 
#endif
59
 
 
60
 
/**
61
 
 * @defgroup drizzle_client_interface Drizzle Client Interface
62
 
 */
63
 
 
64
 
/**
65
 
 * @addtogroup drizzle_client Drizzle Declarations for Clients
66
 
 * @ingroup drizzle_client_interface
67
 
 * @{
68
 
 */
69
 
 
70
 
/**
71
 
 * Add TCP (IPv4 or IPv6) connection with common arguments.
72
 
 *
73
 
 * @param[in] drizzle Drizzle structure previously initialized with
74
 
 *  drizzle_create() or drizzle_clone().
75
 
 * @param[in] con Caller allocated structure, or NULL to allocate one.
76
 
 * @param[in] host Host to connect to. This may be a hostname to resolve, an
77
 
 *  IPv4 address, or an IPv6 address. This is passed directly to getaddrinfo().
78
 
 * @param[in] port Remote port to connect to.
79
 
 * @param[in] user User to use while establishing the connection.
80
 
 * @param[in] password Password to use while establishing the connection.
81
 
 * @param[in] db Initial database to connect to.
82
 
 * @param[in] options Drizzle connection options to add.
83
 
 * @return Same return as drizzle_con_create().
84
 
 */
85
 
DRIZZLE_API
86
 
drizzle_con_st *drizzle_con_add_tcp(drizzle_st *drizzle, drizzle_con_st *con,
87
 
                                    const char *host, in_port_t port,
88
 
                                    const char *user, const char *password,
89
 
                                    const char *db,
90
 
                                    drizzle_con_options_t options);
91
 
 
92
 
/**
93
 
 * Add unix domain socket connection with common arguments.
94
 
 *
95
 
 * @param[in] drizzle Drizzle structure previously initialized with
96
 
 *  drizzle_create() or drizzle_clone().
97
 
 * @param[in] con Caller allocated structure, or NULL to allocate one.
98
 
 * @param[in] uds Path to unix domain socket to use for connection.
99
 
 * @param[in] user User to use while establishing the connection.
100
 
 * @param[in] password Password to use while establishing the connection.
101
 
 * @param[in] db Initial database to connect to.
102
 
 * @param[in] options Drizzle connection options to add.
103
 
 * @return Same return as drizzle_con_create().
104
 
 */
105
 
DRIZZLE_API
106
 
drizzle_con_st *drizzle_con_add_uds(drizzle_st *drizzle, drizzle_con_st *con,
107
 
                                    const char *uds, const char *user,
108
 
                                    const char *password, const char *db,
109
 
                                    drizzle_con_options_t options);
110
 
 
111
 
/** @} */
112
 
 
113
 
#ifdef  __cplusplus
114
 
}
115
 
#endif
116
 
 
117
 
#endif /* __DRIZZLE_CLIENT_H */