~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.cc

  • Committer: Brian Aker
  • Date: 2011-01-29 23:08:49 UTC
  • mto: This revision was merged to the branch mainline in revision 2128.
  • Revision ID: brian@tangent.org-20110129230849-ga5zr8fq1bavtygz
Merge in changes for catalogs usage of constants for identifier.

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()->getTableProto()));
 
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
    {
376
 
      return message::table::shared_ptr(new message::Table(*table->getShare()->getTableMessage()));
 
420
      error= EE_OK;
 
421
      return message::table::shared_ptr(new message::Table(*table->getShare()->getTableProto()));
377
422
    }
378
423
  }
379
424
 
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) {
933
979
    textno=ER_TABLE_DEF_CHANGED;
934
980
    break;
935
981
  case HA_ERR_NO_SUCH_TABLE:
936
 
    {
937
 
      identifier::Table identifier(table.getShare()->getSchemaName(), table.getShare()->getTableName());
938
 
      my_error(ER_TABLE_UNKNOWN, identifier);
939
 
      return;
940
 
    }
 
982
    my_error(ER_NO_SUCH_TABLE, MYF(0), table.getShare()->getSchemaName(),
 
983
             table.getShare()->getTableName());
 
984
    return;
941
985
  case HA_ERR_RBR_LOGGING_FAILED:
942
986
    textno= ER_BINLOG_ROW_LOGGING_FAILED;
943
987
    break;
1005
1049
  @return
1006
1050
    Returns true if this is a temporary error
1007
1051
*/
1008
 
bool StorageEngine::get_error_message(int , String* ) const
 
1052
bool StorageEngine::get_error_message(int , String* )
1009
1053
{
1010
1054
  return false;
1011
1055
}
1012
1056
 
1013
1057
 
1014
 
void StorageEngine::print_keydup_error(uint32_t key_nr, const char *msg, const Table &table) const
 
1058
void StorageEngine::print_keydup_error(uint32_t key_nr, const char *msg, Table &table)
1015
1059
{
1016
1060
  /* Write the duplicated key in the error message */
1017
1061
  char key[MAX_KEY_LENGTH];