~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/concurrent.cc

  • Committer: David Shrewsbury
  • Date: 2010-11-15 15:29:16 UTC
  • mto: (1932.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1933.
  • Revision ID: shrewsbury.dave@gmail.com-20101115152916-cowsgsfm3sibys30
Move transaction_reader from drizzled/message to transaction_log plugin; also pulled transaction_reader file operations out into separate class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "plugin/myisam/myisam.h"
29
29
#include "drizzled/plugin/transactional_storage_engine.h"
30
30
 
31
 
#include <drizzled/table/instance.h>
32
 
 
33
31
#include "drizzled/table.h"
34
32
 
35
33
namespace drizzled
54
52
  pointer.
55
53
 
56
54
  NOTE
57
 
  This function assumes that its caller already acquired table::Cache::singleton().mutex() mutex.
 
55
  This function assumes that its caller already acquired LOCK_open mutex.
58
56
 
59
57
  RETURN VALUE
60
58
  false - Success
63
61
 
64
62
bool Concurrent::reopen_name_locked_table(TableList* table_list, Session *session)
65
63
{
66
 
  safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
 
64
  safe_mutex_assert_owner(LOCK_open.native_handle());
67
65
 
68
66
  if (session->getKilled())
69
67
    return true;
70
68
 
71
 
  identifier::Table identifier(table_list->getSchemaName(), table_list->getTableName());
 
69
  TableIdentifier identifier(table_list->getSchemaName(), table_list->getTableName());
72
70
  if (open_unireg_entry(session, table_list->getTableName(), identifier))
73
71
  {
74
72
    intern_close_table();
112
110
 
113
111
  NOTES
114
112
  Extra argument for open is taken from session->open_options
115
 
  One must have a lock on table::Cache::singleton().mutex() when calling this function
 
113
  One must have a lock on LOCK_open when calling this function
116
114
 
117
115
  RETURN
118
116
  0     ok
121
119
 
122
120
int table::Concurrent::open_unireg_entry(Session *session,
123
121
                                         const char *alias,
124
 
                                         identifier::Table &identifier)
 
122
                                         TableIdentifier &identifier)
125
123
{
126
124
  int error;
127
 
  TableShare::shared_ptr share;
 
125
  TableSharePtr share;
128
126
  uint32_t discover_retry_count= 0;
129
127
 
130
 
  safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
 
128
  safe_mutex_assert_owner(LOCK_open.native_handle());
131
129
retry:
132
 
  if (not (share= table::instance::Shared::make_shared(session,
133
 
                                                       identifier,
134
 
                                                       error)))
 
130
  if (not (share= TableShare::getShareCreate(session,
 
131
                                             identifier,
 
132
                                             error)))
135
133
  {
136
134
    return 1;
137
135
  }
150
148
      share->resetVersion();                        // Mark share as old
151
149
      if (discover_retry_count++)               // Retry once
152
150
      {
153
 
        table::instance::release(share);
 
151
        TableShare::release(share);
154
152
        return 1;
155
153
      }
156
154
 
175
173
      */
176
174
      if (share->getTableCount() != 1)
177
175
      {
178
 
        table::instance::release(share);
 
176
        TableShare::release(share);
179
177
        return 1;
180
178
      }
181
 
 
182
179
      /* Free share and wait until it's released by all threads */
183
 
      table::instance::release(share);
 
180
      TableShare::release(share);
184
181
 
185
182
      if (not session->getKilled())
186
183
      {
188
185
        session->clear_error();                 // Clear error message
189
186
        goto retry;
190
187
      }
191
 
 
192
188
      return 1;
193
189
    }
194
190
 
195
 
    table::instance::release(share);
 
191
    TableShare::release(share);
196
192
 
197
193
    return 1;
198
194
  }
208
204
  // delete if this happens.
209
205
  if (getShare()->getType() == message::Table::STANDARD)
210
206
  {
211
 
    table::instance::release(getMutableShare());
 
207
    TableShare::release(getMutableShare());
212
208
  }
213
209
  else
214
210
  {