00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <sys/types.h>
00024 #include <sys/stat.h>
00025 #include <fcntl.h>
00026
00027 #include <drizzled/session.h>
00028 #include <plugin/myisam/myisam.h>
00029 #include <drizzled/plugin/transactional_storage_engine.h>
00030
00031 #include <drizzled/table/instance.h>
00032
00033 #include <drizzled/table.h>
00034
00035 namespace drizzled
00036 {
00037
00038 namespace table
00039 {
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 bool Concurrent::reopen_name_locked_table(TableList* table_list, Session *session)
00065 {
00066 safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
00067
00068 if (session->getKilled())
00069 return true;
00070
00071 identifier::Table identifier(table_list->getSchemaName(), table_list->getTableName());
00072 if (open_unireg_entry(session, table_list->getTableName(), identifier))
00073 {
00074 intern_close_table();
00075 return true;
00076 }
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 getMutableShare()->resetVersion();
00087 in_use = session;
00088
00089 tablenr= session->current_tablenr++;
00090 used_fields= 0;
00091 const_table= 0;
00092 null_row= false;
00093 maybe_null= false;
00094 force_index= false;
00095 status= STATUS_NO_RECORD;
00096
00097 return false;
00098 }
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 int table::Concurrent::open_unireg_entry(Session *session,
00123 const char *alias,
00124 identifier::Table &identifier)
00125 {
00126 int error;
00127 TableShare::shared_ptr share;
00128 uint32_t discover_retry_count= 0;
00129
00130 safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
00131 retry:
00132 if (not (share= table::instance::Shared::make_shared(session, identifier, error)))
00133 {
00134 return 1;
00135 }
00136
00137 while ((error= share->open_table_from_share(session,
00138 identifier,
00139 alias,
00140 (uint32_t) (HA_OPEN_KEYFILE |
00141 HA_OPEN_RNDFILE |
00142 HA_GET_INDEX |
00143 HA_TRY_READ_ONLY),
00144 session->open_options, *this)))
00145 {
00146 if (error == 7)
00147 {
00148 share->resetVersion();
00149 if (discover_retry_count++)
00150 {
00151 table::instance::release(share);
00152 return 1;
00153 }
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 if (share->getTableCount() != 1)
00175 {
00176 table::instance::release(share);
00177 return 1;
00178 }
00179
00180
00181 table::instance::release(share);
00182
00183 if (not session->getKilled())
00184 {
00185 drizzle_reset_errors(session, 1);
00186 session->clear_error();
00187 goto retry;
00188 }
00189
00190 return 1;
00191 }
00192
00193 table::instance::release(share);
00194
00195 return 1;
00196 }
00197
00198 return 0;
00199 }
00200
00201 void table::Concurrent::release(void)
00202 {
00203
00204
00205
00206
00207 if (getShare()->getType() == message::Table::STANDARD)
00208 {
00209 table::instance::release(getMutableShare());
00210 }
00211 else
00212 {
00213 delete _share;
00214 }
00215 _share= NULL;
00216 }
00217
00218 }
00219 }