~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.h

  • Committer: Prafulla Tekawade
  • Date: 2010-07-18 03:36:32 UTC
  • mto: (1662.1.4 rollup)
  • mto: This revision was merged to the branch mainline in revision 1664.
  • Revision ID: prafulla_t@users.sourceforge.net-20100718033632-p7q6qtgliqbhe38p
Fix for Bug 592444

There were two problems:
o. In greedy_search optimizer method, best_extension_by_limited search
   maintains join embedding(nestedness) of tables added so far, so that 
   correct(valid)  join order is selected
   These are requirements from nested outer join executioner.
   The problem was, embedding_map was not correctly updated when a table 
   is added to optimal plan outside best_extension_by_limited search, 
   by greedy_search method. We need to update join->cur_embedding_map
   correctly here so that execution plan for other tables get
   generated.
   Invoked checked_interleaving_with_nj from greedy_search on the
   best_table selected. Fixed its prototype to take only one JoinTab
   This is same as mysql 5.1 source tree.
o. The other problem was, join->cur_embedding_map was not restored correctly
   when a table is added to the optimal plan to reflect the current embedding 
   map. 
   Taken good documented method restore_prev_nj_state which restores 
   cur_embedding_map from mysql 5.1 source tree and modified it for drizzled 
   code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <drizzled/definitions.h>
25
25
#include <drizzled/plugin.h>
26
26
#include <drizzled/handler_structs.h>
27
 
#include <drizzled/message.h>
28
 
#include <drizzled/message/cache.h>
 
27
#include <drizzled/message/schema.pb.h>
 
28
#include <drizzled/message/table.pb.h>
29
29
#include "drizzled/plugin/plugin.h"
30
30
#include "drizzled/sql_string.h"
31
 
#include "drizzled/identifier.h"
 
31
#include "drizzled/schema_identifier.h"
 
32
#include "drizzled/table_identifier.h"
32
33
#include "drizzled/cached_directory.h"
33
34
#include "drizzled/plugin/monitored_in_transaction.h"
34
35
 
 
36
#include <drizzled/unordered_map.h>
 
37
 
35
38
#include <bitset>
36
39
#include <string>
37
40
#include <vector>
117
120
namespace plugin
118
121
{
119
122
 
 
123
typedef unordered_map<std::string, StorageEngine *> EngineMap;
120
124
typedef std::vector<StorageEngine *> EngineVector;
121
125
 
122
126
typedef std::set<std::string> TableNameList;
252
256
  {
253
257
    return 0;
254
258
  }
255
 
  virtual Cursor *create(Table &)= 0;
 
259
  virtual Cursor *create(TableShare &, memory::Root *)= 0;
256
260
  /* args: path */
257
261
  virtual bool flush_logs() { return false; }
258
262
  virtual bool show_status(Session *, stat_print_fn *, enum ha_stat_type)
286
290
 
287
291
  int renameTable(Session &session, const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to);
288
292
 
 
293
  // @todo move these to protected
 
294
  virtual void doGetTableNames(CachedDirectory &directory,
 
295
                               const drizzled::SchemaIdentifier &schema_identifier,
 
296
                               TableNameList &set_of_names)= 0;
 
297
 
289
298
  virtual void doGetTableIdentifiers(CachedDirectory &directory,
290
299
                                     const drizzled::SchemaIdentifier &schema_identifier,
291
 
                                     TableIdentifier::vector &set_of_identifiers)= 0;
 
300
                                     TableIdentifiers &set_of_identifiers)= 0;
292
301
 
293
302
  virtual int doDropTable(Session &session,
294
303
                          const drizzled::TableIdentifier &identifier)= 0;
299
308
 
300
309
  static int getTableDefinition(Session& session,
301
310
                                const drizzled::TableIdentifier &identifier,
302
 
                                message::table::shared_ptr &table_proto,
 
311
                                message::Table &table_proto,
303
312
                                bool include_temporary_tables= true);
304
313
  static bool doesTableExist(Session &session,
305
314
                             const drizzled::TableIdentifier &identifier,
318
327
  static int dropTable(Session& session,
319
328
                       StorageEngine &engine,
320
329
                       const drizzled::TableIdentifier &identifier);
321
 
  static void getIdentifiers(Session &session,
322
 
                             const SchemaIdentifier &schema_identifier,
323
 
                             TableIdentifier::vector &set_of_identifiers);
 
330
  static void getTableNames(Session &session, const drizzled::SchemaIdentifier& schema_identifier, TableNameList &set_of_names);
 
331
  static void getTableIdentifiers(Session &session, const SchemaIdentifier &schema_identifier, TableIdentifiers &set_of_identifiers);
324
332
 
325
333
  // Check to see if any SE objects to creation.
326
334
  static bool canCreateTable(const drizzled::TableIdentifier &identifier);
328
336
  { (void)identifier;  return true; }
329
337
 
330
338
  // @note All schema methods defined here
331
 
  static void getIdentifiers(Session &session, SchemaIdentifier::vector &schemas);
332
 
  static bool getSchemaDefinition(const drizzled::TableIdentifier &identifier, message::schema::shared_ptr &proto);
333
 
  static bool getSchemaDefinition(const drizzled::SchemaIdentifier &identifier, message::schema::shared_ptr &proto);
 
339
  static void getSchemaIdentifiers(Session &session, SchemaIdentifiers &schemas);
 
340
  static bool getSchemaDefinition(const drizzled::TableIdentifier &identifier, message::Schema &proto);
 
341
  static bool getSchemaDefinition(const drizzled::SchemaIdentifier &identifier, message::Schema &proto);
334
342
  static bool doesSchemaExist(const drizzled::SchemaIdentifier &identifier);
335
343
  static const CHARSET_INFO *getSchemaCollation(const drizzled::SchemaIdentifier &identifier);
336
344
  static bool createSchema(const drizzled::message::Schema &schema_message);
338
346
  static bool alterSchema(const drizzled::message::Schema &schema_message);
339
347
 
340
348
  // @note make private/protected
341
 
  virtual void doGetSchemaIdentifiers(SchemaIdentifier::vector&)
 
349
  virtual void doGetSchemaIdentifiers(SchemaIdentifiers&)
342
350
  { }
343
351
 
344
 
  virtual bool doGetSchemaDefinition(const drizzled::SchemaIdentifier&, drizzled::message::schema::shared_ptr&)
 
352
  virtual bool doGetSchemaDefinition(const drizzled::SchemaIdentifier&, drizzled::message::Schema&)
345
353
  { 
346
354
    return false; 
347
355
  }
366
374
 
367
375
  static void removeLostTemporaryTables(Session &session, const char *directory);
368
376
 
369
 
  Cursor *getCursor(Table &share);
 
377
  Cursor *getCursor(TableShare &share, memory::Root *alloc);
370
378
 
371
379
  uint32_t max_record_length() const
372
380
  { return std::min((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }