~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/rabbitmq/rabbitmq_handler.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:
29
29
#include <string>
30
30
#include <amqp.h>
31
31
#include <amqp_framing.h>
32
 
#include <netinet/in.h>
33
 
 
34
 
namespace drizzle_plugin
35
 
{
36
32
 
37
33
/**
38
34
 * exception thrown by the rabbitmq handler
39
35
 *
40
36
 */
41
 
class rabbitmq_handler_exception : public std::exception
 
37
class rabbitmq_handler_exception: public std::exception
42
38
{
43
39
private:
44
40
  const char* message;
62
58
  amqp_connection_state_t rabbitmqConnection; 
63
59
  int sockfd; ///< the socket file desc to the rabbitmq server, 
64
60
              ///< need this to be able to close() it.
65
 
  const std::string &hostname;
66
 
  const in_port_t port;
67
 
  const std::string &username;
68
 
  const std::string &password;
69
 
  const std::string &virtualhost;
 
61
  const char* hostname;
 
62
  const int port;
 
63
  const char* username;
 
64
  const char* password;
 
65
  const char* virtualhost;
70
66
public:
71
67
  /**
72
68
   * @brief
84
80
   * @param[in] virtualhost the rabbitmq virtual host.
85
81
   * @throw exception if we cannot connect to rabbitmq server
86
82
   */
87
 
  RabbitMQHandler(const std::string &hostname, 
88
 
                  const in_port_t port, 
89
 
                  const std::string &username, 
90
 
                  const std::string &password, 
91
 
                  const std::string &virtualhost)
92
 
    throw(rabbitmq_handler_exception);
93
 
 
 
83
  RabbitMQHandler(const char* hostname, 
 
84
                  const int port, 
 
85
                  const char* username, 
 
86
                  const char* password, 
 
87
                  const char* virtualhost) throw(rabbitmq_handler_exception);
94
88
  ~RabbitMQHandler();
95
89
 
96
90
  /**
106
100
   * @param[in] routingKey the routing key to use
107
101
   * @throw exception if there is a problem publishing
108
102
   */
109
 
  void publish(void *message, 
110
 
               const int length, 
111
 
               const std::string &exchangeName, 
112
 
               const std::string &routingKey)
113
 
    throw(rabbitmq_handler_exception);
114
 
 
115
 
 
116
 
private:
 
103
  void publish(const uint8_t *message, 
 
104
               const int length, 
 
105
               const char* exchangeName, 
 
106
               const char* routingKey) throw(rabbitmq_handler_exception);
 
107
 
 
108
 
 
109
 private:
117
110
  /**
118
111
   * @brief
119
112
   *   Handles errors produced by librabbitmq
129
122
  void handleAMQPError(amqp_rpc_reply_t x, std::string context) throw(rabbitmq_handler_exception);
130
123
};
131
124
 
132
 
} /* namespace drizzle_plugin */
133
 
 
134
125
#endif /* PLUGIN_RABBITMQ_RABBITMQ_HANDLER_H */