~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.cc

updating to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include "drizzled/global_charset_info.h"
50
50
#include "drizzled/charset.h"
51
51
#include "drizzled/internal/my_sys.h"
52
 
#include "drizzled/db.h"
53
52
 
54
53
#include <drizzled/table_proto.h>
55
54
#include <drizzled/plugin/event_observer.h>
362
361
  return false;
363
362
}
364
363
 
365
 
/**
366
 
  Call this function in order to give the Cursor the possiblity
367
 
  to ask engine if there are any new tables that should be written to disk
368
 
  or any dropped tables that need to be removed from disk
369
 
*/
370
 
int StorageEngine::getTableDefinition(Session& session,
371
 
                                      const identifier::Table &identifier,
372
 
                                      message::table::shared_ptr &table_message,
373
 
                                      bool include_temporary_tables)
374
 
{
375
 
  drizzled::error_t err= static_cast<drizzled::error_t>(ENOENT);
376
 
 
377
 
  if (include_temporary_tables)
378
 
  {
379
 
    Table *table= session.find_temporary_table(identifier);
380
 
    if (table)
381
 
    {
382
 
      table_message.reset(new message::Table(*table->getShare()->getTableMessage()));
383
 
      return EEXIST;
384
 
    }
385
 
  }
386
 
 
387
 
  drizzled::message::table::shared_ptr table_ptr;
388
 
  if ((table_ptr= drizzled::message::Cache::singleton().find(identifier)))
389
 
  {
390
 
    table_message= table_ptr;
391
 
  }
392
 
 
393
 
  message::Table message;
394
 
  EngineVector::iterator iter=
395
 
    std::find_if(vector_of_engines.begin(), vector_of_engines.end(),
396
 
                 StorageEngineGetTableDefinition(session, identifier, message, err));
397
 
 
398
 
  if (iter == vector_of_engines.end())
399
 
  {
400
 
    return ENOENT;
401
 
  }
402
 
  table_message.reset(new message::Table(message));
403
 
 
404
 
 drizzled::message::Cache::singleton().insert(identifier, table_message);
405
 
 
406
 
  return err;
407
 
}
408
 
 
409
364
message::table::shared_ptr StorageEngine::getTableMessage(Session& session,
410
365
                                                          identifier::Table::const_reference identifier,
411
 
                                                          drizzled::error_t &error,
412
366
                                                          bool include_temporary_tables)
413
367
{
 
368
  drizzled::error_t error;
414
369
  error= static_cast<drizzled::error_t>(ENOENT);
415
370
 
416
371
  if (include_temporary_tables)
418
373
    Table *table= session.find_temporary_table(identifier);
419
374
    if (table)
420
375
    {
421
 
      error= EE_OK;
422
376
      return message::table::shared_ptr(new message::Table(*table->getShare()->getTableMessage()));
423
377
    }
424
378
  }
436
390
 
437
391
  if (iter == vector_of_engines.end())
438
392
  {
439
 
    error= static_cast<drizzled::error_t>(ENOENT);
440
393
    return message::table::shared_ptr();
441
394
  }
442
395
  message::table::shared_ptr table_message(new message::Table(message));