~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/schema_engine/schema.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:
23
23
 
24
24
#include <assert.h>
25
25
#include <drizzled/plugin/storage_engine.h>
 
26
#include <drizzled/data_home.h>
26
27
#include <boost/unordered_map.hpp>
27
 
#include <boost/thread/shared_mutex.hpp>
 
28
 
 
29
#include <pthread.h>
28
30
 
29
31
extern const drizzled::CHARSET_INFO *default_charset_info;
30
32
 
35
37
class Schema : public drizzled::plugin::StorageEngine
36
38
{
37
39
  bool writeSchemaFile(const drizzled::SchemaIdentifier &schema_identifier, const drizzled::message::Schema &db);
38
 
  bool readSchemaFile(const drizzled::SchemaIdentifier &schema_identifier, drizzled::message::Schema &schema);
 
40
  bool readSchemaFile(const std::string &schema_file_name, drizzled::message::Schema &schema);
39
41
 
40
42
  void prime();
41
43
 
42
 
  typedef boost::unordered_map<std::string, drizzled::message::schema::shared_ptr> SchemaCache;
 
44
  typedef boost::unordered_map<std::string, drizzled::message::Schema> SchemaCache;
43
45
  SchemaCache schema_cache;
44
46
  bool schema_cache_filled;
45
47
 
46
 
  boost::shared_mutex mutex;
 
48
  pthread_rwlock_t schema_lock;
47
49
 
48
50
public:
49
51
  Schema();
51
53
  ~Schema();
52
54
 
53
55
 
54
 
  drizzled::Cursor *create(drizzled::Table &)
 
56
  bool doCanCreateTable(const drizzled::TableIdentifier &identifier);
 
57
 
 
58
  drizzled::Cursor *create(drizzled::TableShare &)
55
59
  {
56
60
    return NULL;
57
61
  }
58
62
 
59
 
  void doGetSchemaIdentifiers(drizzled::SchemaIdentifier::vector &set_of_names);
60
 
  bool doGetSchemaDefinition(const drizzled::SchemaIdentifier&, drizzled::message::schema::shared_ptr &proto);
 
63
  void doGetSchemaIdentifiers(drizzled::SchemaIdentifiers &set_of_names);
 
64
  bool doGetSchemaDefinition(const drizzled::SchemaIdentifier&, drizzled::message::Schema &proto);
61
65
 
62
66
  bool doCreateSchema(const drizzled::message::Schema &schema_message);
63
67
 
74
78
    return ENOENT;
75
79
  }
76
80
 
 
81
 
 
82
  void doGetTableNames(drizzled::CachedDirectory&,
 
83
                       const drizzled::SchemaIdentifier&,
 
84
                       std::set<std::string>&)
 
85
  {
 
86
  }
 
87
 
77
88
  bool doDoesTableExist(drizzled::Session&, const drizzled::TableIdentifier&)
78
89
  {
79
90
    return false;
109
120
  {}
110
121
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
111
122
                             const drizzled::SchemaIdentifier &schema_identifier,
112
 
                             drizzled::TableIdentifier::vector &set_of_identifiers);
 
123
                             drizzled::TableIdentifiers &set_of_identifiers);
113
124
};
114
125
 
115
126
#endif /* PLUGIN_SCHEMA_ENGINE_SCHEMA_H */