~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/instance/shared.cc

  • Committer: Brian Aker
  • Date: 2011-02-22 23:14:37 UTC
  • mfrom: (2192.1.2 drizzle-staging)
  • Revision ID: brian@tangent.org-20110222231437-s9vawppxyq1s6ldk
Rollup changes in build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <config.h>
22
22
 
23
 
#include <drizzled/table/instance/shared.h>
24
23
#include <drizzled/definition/cache.h>
 
24
#include <drizzled/error.h>
 
25
#include <drizzled/message/schema.h>
25
26
#include <drizzled/plugin/event_observer.h>
 
27
#include <drizzled/table/instance/shared.h>
 
28
#include <drizzled/plugin/storage_engine.h>
26
29
 
27
30
namespace drizzled
28
31
{
41
44
{
42
45
}
43
46
 
 
47
Shared::Shared(const identifier::Table &identifier,
 
48
               message::schema::shared_ptr schema_message) :
 
49
  TableShare(message::Table::STANDARD, identifier, NULL, 0),
 
50
  _schema(schema_message),
 
51
  event_observers(NULL)
 
52
{
 
53
}
 
54
 
44
55
Shared::Shared(const identifier::Table &identifier) :
45
56
  TableShare(identifier, identifier.getKey()),
46
57
  event_observers(NULL)
47
58
{
48
59
}
49
60
 
 
61
bool Shared::is_replicated() const
 
62
{
 
63
  if (_schema)
 
64
  {
 
65
    if (not message::is_replicated(*_schema))
 
66
      return false;
 
67
  }
 
68
 
 
69
  assert(getTableMessage());
 
70
  return message::is_replicated(*getTableMessage());
 
71
}
 
72
 
 
73
 
50
74
Shared::shared_ptr Shared::foundTableShare(Shared::shared_ptr share)
51
75
{
52
76
  /*
102
126
  /* Read table definition from cache */
103
127
  if ((share= definition::Cache::singleton().find(identifier.getKey())))
104
128
    return foundTableShare(share);
105
 
 
106
 
  share.reset(new Shared(message::Table::STANDARD, identifier));
107
129
  
 
130
  drizzled::message::schema::shared_ptr schema_message_ptr= plugin::StorageEngine::getSchemaDefinition(identifier);
 
131
 
 
132
  if (not schema_message_ptr)
 
133
  {
 
134
    drizzled::my_error(ER_SCHEMA_DOES_NOT_EXIST, identifier);
 
135
    return Shared::shared_ptr();
 
136
  }
 
137
 
 
138
  share.reset(new Shared(identifier, schema_message_ptr));
 
139
 
108
140
  if (share->open_table_def(*session, identifier))
109
141
  {
110
142
    in_error= share->error;
118
150
  bool ret= definition::Cache::singleton().insert(identifier.getKey(), share);
119
151
 
120
152
  if (not ret)
 
153
  {
 
154
    drizzled::my_error(ER_UNKNOWN_ERROR);
121
155
    return Shared::shared_ptr();
 
156
  }
122
157
 
123
158
  return share;
124
159
}