~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.cc

  • Committer: Brian Aker
  • Date: 2011-02-04 09:28:16 UTC
  • mfrom: (2140.1.4 timestamp)
  • mto: This revision was merged to the branch mainline in revision 2144.
  • Revision ID: brian@tangent.org-20110204092816-2s32j9hlh6ztz7ti
Merge in fix for not found table (simplifies the caller as well).

Events are now just being processed on shared tables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
22
#include <fcntl.h>
23
23
#include <unistd.h>
32
32
#include <google/protobuf/io/zero_copy_stream.h>
33
33
#include <google/protobuf/io/zero_copy_stream_impl.h>
34
34
 
35
 
#include <drizzled/cached_directory.h>
 
35
#include "drizzled/cached_directory.h"
36
36
 
37
37
#include <drizzled/definitions.h>
38
38
#include <drizzled/base.h>
43
43
#include <drizzled/gettext.h>
44
44
#include <drizzled/unireg.h>
45
45
#include <drizzled/data_home.h>
46
 
#include <drizzled/errmsg_print.h>
47
 
#include <drizzled/xid.h>
48
 
#include <drizzled/sql_table.h>
49
 
#include <drizzled/global_charset_info.h>
50
 
#include <drizzled/charset.h>
51
 
#include <drizzled/internal/my_sys.h>
 
46
#include "drizzled/errmsg_print.h"
 
47
#include "drizzled/xid.h"
 
48
#include "drizzled/sql_table.h"
 
49
#include "drizzled/global_charset_info.h"
 
50
#include "drizzled/charset.h"
 
51
#include "drizzled/internal/my_sys.h"
 
52
#include "drizzled/db.h"
52
53
 
53
54
#include <drizzled/table_proto.h>
54
55
#include <drizzled/plugin/event_observer.h>
55
 
#include <drizzled/internal_error_handler.h>
56
56
 
57
57
#include <drizzled/table/shell.h>
58
58
 
59
 
#include <drizzled/message/cache.h>
 
59
#include "drizzled/message/cache.h"
60
60
 
61
61
#include <boost/algorithm/string/compare.hpp>
62
62
 
361
361
  return false;
362
362
}
363
363
 
 
364
/**
 
365
  Call this function in order to give the Cursor the possiblity
 
366
  to ask engine if there are any new tables that should be written to disk
 
367
  or any dropped tables that need to be removed from disk
 
368
*/
 
369
int StorageEngine::getTableDefinition(Session& session,
 
370
                                      const identifier::Table &identifier,
 
371
                                      message::table::shared_ptr &table_message,
 
372
                                      bool include_temporary_tables)
 
373
{
 
374
  drizzled::error_t err= static_cast<drizzled::error_t>(ENOENT);
 
375
 
 
376
  if (include_temporary_tables)
 
377
  {
 
378
    Table *table= session.find_temporary_table(identifier);
 
379
    if (table)
 
380
    {
 
381
      table_message.reset(new message::Table(*table->getShare()->getTableMessage()));
 
382
      return EEXIST;
 
383
    }
 
384
  }
 
385
 
 
386
  drizzled::message::table::shared_ptr table_ptr;
 
387
  if ((table_ptr= drizzled::message::Cache::singleton().find(identifier)))
 
388
  {
 
389
    table_message= table_ptr;
 
390
  }
 
391
 
 
392
  message::Table message;
 
393
  EngineVector::iterator iter=
 
394
    std::find_if(vector_of_engines.begin(), vector_of_engines.end(),
 
395
                 StorageEngineGetTableDefinition(session, identifier, message, err));
 
396
 
 
397
  if (iter == vector_of_engines.end())
 
398
  {
 
399
    return ENOENT;
 
400
  }
 
401
  table_message.reset(new message::Table(message));
 
402
 
 
403
 drizzled::message::Cache::singleton().insert(identifier, table_message);
 
404
 
 
405
  return err;
 
406
}
 
407
 
364
408
message::table::shared_ptr StorageEngine::getTableMessage(Session& session,
365
409
                                                          identifier::Table::const_reference identifier,
 
410
                                                          drizzled::error_t &error,
366
411
                                                          bool include_temporary_tables)
367
412
{
368
 
  drizzled::error_t error;
369
413
  error= static_cast<drizzled::error_t>(ENOENT);
370
414
 
371
415
  if (include_temporary_tables)
373
417
    Table *table= session.find_temporary_table(identifier);
374
418
    if (table)
375
419
    {
 
420
      error= EE_OK;
376
421
      return message::table::shared_ptr(new message::Table(*table->getShare()->getTableMessage()));
377
422
    }
378
423
  }
390
435
 
391
436
  if (iter == vector_of_engines.end())
392
437
  {
 
438
    error= static_cast<drizzled::error_t>(ENOENT);
393
439
    return message::table::shared_ptr();
394
440
  }
395
441
  message::table::shared_ptr table_message(new message::Table(message));
801
847
    - table->getShare()->path
802
848
    - table->alias
803
849
*/
804
 
void StorageEngine::print_error(int error, myf errflag, const Table &table) const
 
850
void StorageEngine::print_error(int error, myf errflag, Table &table)
805
851
{
806
852
  drizzled::error_t textno= ER_GET_ERRNO;
807
853
  switch (error) {
1005
1051
  @return
1006
1052
    Returns true if this is a temporary error
1007
1053
*/
1008
 
bool StorageEngine::get_error_message(int , String* ) const
 
1054
bool StorageEngine::get_error_message(int , String* )
1009
1055
{
1010
1056
  return false;
1011
1057
}
1012
1058
 
1013
1059
 
1014
 
void StorageEngine::print_keydup_error(uint32_t key_nr, const char *msg, const Table &table) const
 
1060
void StorageEngine::print_keydup_error(uint32_t key_nr, const char *msg, Table &table)
1015
1061
{
1016
1062
  /* Write the duplicated key in the error message */
1017
1063
  char key[MAX_KEY_LENGTH];