575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
19 |
||
1241.9.36
by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h. |
20 |
#include "config.h" |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
21 |
|
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
22 |
#include <fcntl.h> |
23 |
#include <unistd.h> |
|
24 |
||
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
25 |
#include <string> |
26 |
#include <vector> |
|
1183.1.5
by Brian Aker
Reworked getTableNames() interface. Way simpler, less mallocs.... |
27 |
#include <set> |
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
28 |
#include <fstream> |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
29 |
#include <algorithm> |
30 |
#include <functional> |
|
31 |
||
32 |
#include <google/protobuf/io/zero_copy_stream.h> |
|
33 |
#include <google/protobuf/io/zero_copy_stream_impl.h> |
|
34 |
||
1241.9.44
by Monty Taylor
Made magic with cached_directory. |
35 |
#include "drizzled/cached_directory.h" |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
36 |
|
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
37 |
#include <drizzled/definitions.h> |
38 |
#include <drizzled/base.h> |
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
39 |
#include <drizzled/cursor.h> |
960.2.23
by Monty Taylor
Moved handlerton to plugin/storage_engine.h. |
40 |
#include <drizzled/plugin/storage_engine.h> |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
41 |
#include <drizzled/session.h> |
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
42 |
#include <drizzled/error.h> |
43 |
#include <drizzled/gettext.h> |
|
971.1.37
by Monty Taylor
Another one bites the dust. |
44 |
#include <drizzled/unireg.h> |
971.1.38
by Monty Taylor
Moved delete table. |
45 |
#include <drizzled/data_home.h> |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
46 |
#include "drizzled/errmsg_print.h" |
47 |
#include "drizzled/xid.h" |
|
1241.9.23
by Monty Taylor
Removed sql_table.h from server_includes.h. |
48 |
#include "drizzled/sql_table.h" |
1241.9.28
by Monty Taylor
Removed global_charset_info.h from server_includes.h |
49 |
#include "drizzled/global_charset_info.h" |
1273.20.3
by Brian Aker
Fixing charset return. |
50 |
#include "drizzled/charset.h" |
1241.9.64
by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal. |
51 |
#include "drizzled/internal/my_sys.h" |
1273.13.9
by Brian Aker
Updating test cases + added Drizzle specific schema_names and schema_info. |
52 |
#include "drizzled/db.h" |
1241.9.28
by Monty Taylor
Removed global_charset_info.h from server_includes.h |
53 |
|
1095.3.3
by Stewart Smith
move drizzle_proto_exists and drizzle_read_table_proto out of unireg.h and into table_proto.h |
54 |
#include <drizzled/table_proto.h> |
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
55 |
#include <drizzled/plugin/event_observer.h> |
1095.3.3
by Stewart Smith
move drizzle_proto_exists and drizzle_read_table_proto out of unireg.h and into table_proto.h |
56 |
|
1859.2.9
by Brian Aker
We add a "shell" table type, used only during field creation. |
57 |
#include <drizzled/table/shell.h> |
58 |
||
1910.2.14
by Brian Aker
Check simple cache performance hit. |
59 |
#include "drizzled/message/cache.h" |
60 |
||
1685.2.10
by Brian Aker
Optimize the string comparison a bit. |
61 |
#include <boost/algorithm/string/compare.hpp> |
62 |
||
1217.1.3
by Brian Aker
Remove NameMap from Storage Engine. Modified the cleanup code to just do a |
63 |
static bool shutdown_has_begun= false; // Once we put in the container for the vector/etc for engines this will go away. |
64 |
||
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
65 |
namespace drizzled |
66 |
{
|
|
67 |
||
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
68 |
namespace plugin |
69 |
{
|
|
1217.1.3
by Brian Aker
Remove NameMap from Storage Engine. Modified the cleanup code to just do a |
70 |
|
71 |
static EngineVector vector_of_engines; |
|
1273.19.30
by Brian Aker
Performance patch... we now only cycle through engines that actually have |
72 |
static EngineVector vector_of_schema_engines; |
1217.1.3
by Brian Aker
Remove NameMap from Storage Engine. Modified the cleanup code to just do a |
73 |
|
1685.2.10
by Brian Aker
Optimize the string comparison a bit. |
74 |
const std::string DEFAULT_STRING("default"); |
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
75 |
const std::string UNKNOWN_STRING("UNKNOWN"); |
76 |
const std::string DEFAULT_DEFINITION_FILE_EXT(".dfe"); |
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
77 |
|
1183.1.27
by Brian Aker
Fix issue where there are too many files in data directory. We now only |
78 |
static std::set<std::string> set_of_table_definition_ext; |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
79 |
|
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
80 |
EngineVector &StorageEngine::getSchemaEngines() |
81 |
{
|
|
82 |
return vector_of_schema_engines; |
|
83 |
}
|
|
84 |
||
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
85 |
StorageEngine::StorageEngine(const std::string name_arg, |
86 |
const std::bitset<HTON_BIT_SIZE> &flags_arg) : |
|
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
87 |
Plugin(name_arg, "StorageEngine"), |
88 |
MonitoredInTransaction(), /* This gives the storage engine a "slot" or ID */ |
|
89 |
flags(flags_arg) |
|
964.1.6
by Monty Taylor
Moved savepoint stuff to protected virtual methods, moved the offset to private, and moved the logic about adding the offset to the passed-in pointer and adding the offset to the global offset inside of the class. |
90 |
{
|
91 |
}
|
|
92 |
||
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
93 |
StorageEngine::~StorageEngine() |
964.1.6
by Monty Taylor
Moved savepoint stuff to protected virtual methods, moved the offset to private, and moved the logic about adding the offset to the passed-in pointer and adding the offset to the global offset inside of the class. |
94 |
{
|
95 |
}
|
|
96 |
||
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
97 |
void StorageEngine::setTransactionReadWrite(Session& session) |
1039.3.8
by Stewart Smith
Re-introduce marking transaction as read-write for engine on create_table: |
98 |
{
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
99 |
TransactionContext &statement_ctx= session.transaction.stmt; |
100 |
statement_ctx.markModifiedNonTransData(); |
|
1039.3.8
by Stewart Smith
Re-introduce marking transaction as read-write for engine on create_table: |
101 |
}
|
102 |
||
1389
by Brian Aker
Large reord in ALTER TABLE for RENAME. |
103 |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
104 |
int StorageEngine::renameTable(Session &session, const identifier::Table &from, const identifier::Table &to) |
1039.3.5
by Stewart Smith
move handler::rename_table to StorageEngine |
105 |
{
|
1502.5.2
by Barry.Leslie at PrimeBase
Changes made to drizzle source when building in the events plugin. |
106 |
int error; |
1389
by Brian Aker
Large reord in ALTER TABLE for RENAME. |
107 |
setTransactionReadWrite(session); |
108 |
||
1502.5.8
by Barry.Leslie at PrimeBase
- Changed names to match the drizzle naming convention. |
109 |
if (unlikely(plugin::EventObserver::beforeRenameTable(session, from, to))) |
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
110 |
{
|
111 |
error= ER_EVENT_OBSERVER_PLUGIN; |
|
112 |
}
|
|
1502.5.2
by Barry.Leslie at PrimeBase
Changes made to drizzle source when building in the events plugin. |
113 |
else
|
114 |
{
|
|
115 |
error = doRenameTable(session, from, to); |
|
1502.5.8
by Barry.Leslie at PrimeBase
- Changed names to match the drizzle naming convention. |
116 |
if (unlikely(plugin::EventObserver::afterRenameTable(session, from, to, error))) |
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
117 |
{
|
118 |
error= ER_EVENT_OBSERVER_PLUGIN; |
|
119 |
}
|
|
1502.5.2
by Barry.Leslie at PrimeBase
Changes made to drizzle source when building in the events plugin. |
120 |
}
|
121 |
||
122 |
return error; |
|
1039.3.5
by Stewart Smith
move handler::rename_table to StorageEngine |
123 |
}
|
124 |
||
1039.3.2
by Stewart Smith
move delete_table out of handler and up into StorageEngine where it belongs. |
125 |
/**
|
126 |
Delete all files with extension from bas_ext().
|
|
127 |
||
128 |
@param name Base name of table
|
|
129 |
||
130 |
@note
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
131 |
We assume that the Cursor may return more extensions than
|
1039.3.2
by Stewart Smith
move delete_table out of handler and up into StorageEngine where it belongs. |
132 |
was actually used for the file.
|
133 |
||
134 |
@retval
|
|
135 |
0 If we successfully deleted at least one file from base_ext and
|
|
136 |
didn't get any other errors than ENOENT
|
|
137 |
@retval
|
|
138 |
!0 Error
|
|
139 |
*/
|
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
140 |
int StorageEngine::doDropTable(Session&, const identifier::Table &identifier) |
1358.1.3
by Brian Aker
doDropTable() now only uses identifier. |
141 |
|
1039.3.2
by Stewart Smith
move delete_table out of handler and up into StorageEngine where it belongs. |
142 |
{
|
143 |
int error= 0; |
|
144 |
int enoent_or_zero= ENOENT; // Error if no file was deleted |
|
145 |
char buff[FN_REFLEN]; |
|
146 |
||
1183.1.21
by Brian Aker
Fixed temp engines to no longer write out DFE. I have two designs right now |
147 |
for (const char **ext= bas_ext(); *ext ; ext++) |
1039.3.2
by Stewart Smith
move delete_table out of handler and up into StorageEngine where it belongs. |
148 |
{
|
1358.1.9
by Brian Aker
Update for std::string |
149 |
internal::fn_format(buff, identifier.getPath().c_str(), "", *ext, |
150 |
MY_UNPACK_FILENAME|MY_APPEND_EXT); |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
151 |
if (internal::my_delete_with_symlink(buff, MYF(0))) |
1039.3.2
by Stewart Smith
move delete_table out of handler and up into StorageEngine where it belongs. |
152 |
{
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
153 |
if ((error= errno) != ENOENT) |
1373
by Brian Aker
Simple style cleanup. |
154 |
break; |
1039.3.2
by Stewart Smith
move delete_table out of handler and up into StorageEngine where it belongs. |
155 |
}
|
156 |
else
|
|
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
157 |
{
|
1039.3.2
by Stewart Smith
move delete_table out of handler and up into StorageEngine where it belongs. |
158 |
enoent_or_zero= 0; // No error for ENOENT |
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
159 |
}
|
160 |
||
1039.3.2
by Stewart Smith
move delete_table out of handler and up into StorageEngine where it belongs. |
161 |
error= enoent_or_zero; |
162 |
}
|
|
163 |
return error; |
|
164 |
}
|
|
971.1.38
by Monty Taylor
Moved delete table. |
165 |
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
166 |
bool StorageEngine::addPlugin(StorageEngine *engine) |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
167 |
{
|
1217.1.3
by Brian Aker
Remove NameMap from Storage Engine. Modified the cleanup code to just do a |
168 |
|
1183.1.5
by Brian Aker
Reworked getTableNames() interface. Way simpler, less mallocs.... |
169 |
vector_of_engines.push_back(engine); |
170 |
||
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
171 |
if (engine->getTableDefinitionFileExtension().length()) |
1183.1.27
by Brian Aker
Fix issue where there are too many files in data directory. We now only |
172 |
{
|
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
173 |
assert(engine->getTableDefinitionFileExtension().length() == DEFAULT_DEFINITION_FILE_EXT.length()); |
174 |
set_of_table_definition_ext.insert(engine->getTableDefinitionFileExtension()); |
|
1183.1.27
by Brian Aker
Fix issue where there are too many files in data directory. We now only |
175 |
}
|
176 |
||
1273.19.30
by Brian Aker
Performance patch... we now only cycle through engines that actually have |
177 |
if (engine->check_flag(HTON_BIT_SCHEMA_DICTIONARY)) |
178 |
vector_of_schema_engines.push_back(engine); |
|
179 |
||
1130.1.19
by Monty Taylor
Added error reporting to plugin registration. |
180 |
return false; |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
181 |
}
|
182 |
||
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
183 |
void StorageEngine::removePlugin(StorageEngine *) |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
184 |
{
|
1217.1.3
by Brian Aker
Remove NameMap from Storage Engine. Modified the cleanup code to just do a |
185 |
if (shutdown_has_begun == false) |
186 |
{
|
|
187 |
vector_of_engines.clear(); |
|
1273.19.30
by Brian Aker
Performance patch... we now only cycle through engines that actually have |
188 |
vector_of_schema_engines.clear(); |
1217.1.3
by Brian Aker
Remove NameMap from Storage Engine. Modified the cleanup code to just do a |
189 |
|
190 |
shutdown_has_begun= true; |
|
191 |
}
|
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
192 |
}
|
193 |
||
1228.3.2
by Monty Taylor
Removed engine_map - just use vector_of_engines. |
194 |
class FindEngineByName |
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
195 |
: public std::unary_function<StorageEngine *, bool> |
1228.3.2
by Monty Taylor
Removed engine_map - just use vector_of_engines. |
196 |
{
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
197 |
const std::string &predicate; |
1384
by Brian Aker
Merge |
198 |
|
1228.3.2
by Monty Taylor
Removed engine_map - just use vector_of_engines. |
199 |
public: |
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
200 |
explicit FindEngineByName(const std::string &target_arg) : |
1685.2.10
by Brian Aker
Optimize the string comparison a bit. |
201 |
predicate(target_arg) |
1384
by Brian Aker
Merge |
202 |
{
|
203 |
}
|
|
1685.2.10
by Brian Aker
Optimize the string comparison a bit. |
204 |
|
1228.3.2
by Monty Taylor
Removed engine_map - just use vector_of_engines. |
205 |
result_type operator() (argument_type engine) |
206 |
{
|
|
1685.2.10
by Brian Aker
Optimize the string comparison a bit. |
207 |
return boost::iequals(engine->getName(), predicate); |
1228.3.2
by Monty Taylor
Removed engine_map - just use vector_of_engines. |
208 |
}
|
209 |
};
|
|
210 |
||
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
211 |
StorageEngine *StorageEngine::findByName(const std::string &predicate) |
1183.1.29
by Brian Aker
Clean up interface so that Truncate sets the propper engine when |
212 |
{
|
1966.2.14
by Brian Aker
Merge in some additional std namespace finds. |
213 |
EngineVector::iterator iter= std::find_if(vector_of_engines.begin(), |
214 |
vector_of_engines.end(), |
|
215 |
FindEngineByName(predicate)); |
|
1228.3.2
by Monty Taylor
Removed engine_map - just use vector_of_engines. |
216 |
if (iter != vector_of_engines.end()) |
1217.1.3
by Brian Aker
Remove NameMap from Storage Engine. Modified the cleanup code to just do a |
217 |
{
|
1228.3.2
by Monty Taylor
Removed engine_map - just use vector_of_engines. |
218 |
StorageEngine *engine= *iter; |
1217.1.3
by Brian Aker
Remove NameMap from Storage Engine. Modified the cleanup code to just do a |
219 |
if (engine->is_user_selectable()) |
220 |
return engine; |
|
221 |
}
|
|
1183.1.29
by Brian Aker
Clean up interface so that Truncate sets the propper engine when |
222 |
|
223 |
return NULL; |
|
224 |
}
|
|
225 |
||
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
226 |
StorageEngine *StorageEngine::findByName(Session& session, const std::string &predicate) |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
227 |
{
|
1685.2.10
by Brian Aker
Optimize the string comparison a bit. |
228 |
if (boost::iequals(predicate, DEFAULT_STRING)) |
1183.1.29
by Brian Aker
Clean up interface so that Truncate sets the propper engine when |
229 |
return session.getDefaultStorageEngine(); |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
230 |
|
1966.2.14
by Brian Aker
Merge in some additional std namespace finds. |
231 |
EngineVector::iterator iter= std::find_if(vector_of_engines.begin(), |
232 |
vector_of_engines.end(), |
|
233 |
FindEngineByName(predicate)); |
|
1228.3.2
by Monty Taylor
Removed engine_map - just use vector_of_engines. |
234 |
if (iter != vector_of_engines.end()) |
1217.1.3
by Brian Aker
Remove NameMap from Storage Engine. Modified the cleanup code to just do a |
235 |
{
|
1228.3.2
by Monty Taylor
Removed engine_map - just use vector_of_engines. |
236 |
StorageEngine *engine= *iter; |
1217.1.3
by Brian Aker
Remove NameMap from Storage Engine. Modified the cleanup code to just do a |
237 |
if (engine->is_user_selectable()) |
238 |
return engine; |
|
239 |
}
|
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
240 |
|
241 |
return NULL; |
|
242 |
}
|
|
243 |
||
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
244 |
class StorageEngineCloseConnection : public std::unary_function<StorageEngine *, void> |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
245 |
{
|
246 |
Session *session; |
|
247 |
public: |
|
248 |
StorageEngineCloseConnection(Session *session_arg) : session(session_arg) {} |
|
249 |
/*
|
|
250 |
there's no need to rollback here as all transactions must
|
|
251 |
be rolled back already
|
|
252 |
*/
|
|
253 |
inline result_type operator() (argument_type engine) |
|
254 |
{
|
|
1273.1.20
by Jay Pipes
Remove StorageEngine::start_consitent_snapshot() and StorageEngine::enable(), disable() and is_enabled(). Unused. |
255 |
if (*session->getEngineData(engine)) |
1240.9.6
by Monty Taylor
Removed some casts- also removed a few c-interface functions and made them actual methods on session. Also made the ha_data private. (fancy that) |
256 |
engine->close_connection(session); |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
257 |
}
|
258 |
};
|
|
259 |
||
260 |
/**
|
|
261 |
@note
|
|
262 |
don't bother to rollback here, it's done already
|
|
263 |
*/
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
264 |
void StorageEngine::closeConnection(Session* session) |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
265 |
{
|
1966.2.14
by Brian Aker
Merge in some additional std namespace finds. |
266 |
std::for_each(vector_of_engines.begin(), vector_of_engines.end(), |
267 |
StorageEngineCloseConnection(session)); |
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
268 |
}
|
269 |
||
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
270 |
bool StorageEngine::flushLogs(StorageEngine *engine) |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
271 |
{
|
272 |
if (engine == NULL) |
|
273 |
{
|
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
274 |
if (std::find_if(vector_of_engines.begin(), vector_of_engines.end(), |
275 |
std::mem_fun(&StorageEngine::flush_logs)) |
|
1309.1.3
by Brian Aker
Cache for Schema. |
276 |
!= vector_of_engines.begin()) |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
277 |
return true; |
278 |
}
|
|
279 |
else
|
|
280 |
{
|
|
1273.1.20
by Jay Pipes
Remove StorageEngine::start_consitent_snapshot() and StorageEngine::enable(), disable() and is_enabled(). Unused. |
281 |
if (engine->flush_logs()) |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
282 |
return true; |
283 |
}
|
|
284 |
return false; |
|
285 |
}
|
|
286 |
||
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
287 |
class StorageEngineGetTableDefinition: public std::unary_function<StorageEngine *,bool> |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
288 |
{
|
1183.1.29
by Brian Aker
Clean up interface so that Truncate sets the propper engine when |
289 |
Session& session; |
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
290 |
const identifier::Table &identifier; |
1354.1.1
by Brian Aker
Modify ptr to reference. |
291 |
message::Table &table_message; |
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
292 |
drizzled::error_t &err; |
1183.5.1
by Brian Aker
Extended definition interface (filename building should now be moved |
293 |
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
294 |
public: |
1200
by Brian Aker
Clean up some mispellings |
295 |
StorageEngineGetTableDefinition(Session& session_arg, |
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
296 |
const identifier::Table &identifier_arg, |
1354.1.1
by Brian Aker
Modify ptr to reference. |
297 |
message::Table &table_message_arg, |
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
298 |
drizzled::error_t &err_arg) : |
1183.1.29
by Brian Aker
Clean up interface so that Truncate sets the propper engine when |
299 |
session(session_arg), |
1358.1.2
by Brian Aker
Long pass through the system to use more of TableIdentifiers. |
300 |
identifier(identifier_arg), |
1320.1.1
by Brian Aker
Light cleanup for references. |
301 |
table_message(table_message_arg), |
1183.5.1
by Brian Aker
Extended definition interface (filename building should now be moved |
302 |
err(err_arg) {} |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
303 |
|
304 |
result_type operator() (argument_type engine) |
|
305 |
{
|
|
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
306 |
int ret= engine->doGetTableDefinition(session, identifier, table_message); |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
307 |
|
308 |
if (ret != ENOENT) |
|
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
309 |
err= static_cast<drizzled::error_t>(ret); |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
310 |
|
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
311 |
return err == static_cast<drizzled::error_t>(EEXIST) or err != static_cast<drizzled::error_t>(ENOENT); |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
312 |
}
|
313 |
};
|
|
314 |
||
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
315 |
class StorageEngineDoesTableExist: public std::unary_function<StorageEngine *, bool> |
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
316 |
{
|
317 |
Session& session; |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
318 |
const identifier::Table &identifier; |
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
319 |
|
320 |
public: |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
321 |
StorageEngineDoesTableExist(Session& session_arg, const identifier::Table &identifier_arg) : |
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
322 |
session(session_arg), |
323 |
identifier(identifier_arg) |
|
324 |
{ } |
|
325 |
||
326 |
result_type operator() (argument_type engine) |
|
327 |
{
|
|
328 |
return engine->doDoesTableExist(session, identifier); |
|
329 |
}
|
|
330 |
};
|
|
331 |
||
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
332 |
/**
|
1273.19.11
by Brian Aker
This restores temporary tables back to being viewable via show/select. |
333 |
Utility method which hides some of the details of getTableDefinition()
|
334 |
*/
|
|
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
335 |
bool plugin::StorageEngine::doesTableExist(Session &session, |
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
336 |
const identifier::Table &identifier, |
1273.19.11
by Brian Aker
This restores temporary tables back to being viewable via show/select. |
337 |
bool include_temporary_tables) |
338 |
{
|
|
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
339 |
if (include_temporary_tables) |
340 |
{
|
|
341 |
if (session.doDoesTableExist(identifier)) |
|
342 |
return true; |
|
343 |
}
|
|
344 |
||
345 |
EngineVector::iterator iter= |
|
1966.2.14
by Brian Aker
Merge in some additional std namespace finds. |
346 |
std::find_if(vector_of_engines.begin(), vector_of_engines.end(), |
347 |
StorageEngineDoesTableExist(session, identifier)); |
|
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
348 |
|
1414
by Brian Aker
Remove dead type. |
349 |
if (iter == vector_of_engines.end()) |
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
350 |
{
|
351 |
return false; |
|
352 |
}
|
|
353 |
||
354 |
return true; |
|
355 |
}
|
|
356 |
||
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
357 |
bool plugin::StorageEngine::doDoesTableExist(Session&, const drizzled::identifier::Table&) |
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
358 |
{
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
359 |
std::cerr << " Engine was called for doDoesTableExist() and does not implement it: " << this->getName() << "\n"; |
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
360 |
assert(0); |
361 |
return false; |
|
1273.19.11
by Brian Aker
This restores temporary tables back to being viewable via show/select. |
362 |
}
|
363 |
||
364 |
/**
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
365 |
Call this function in order to give the Cursor the possiblity
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
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 |
*/
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
369 |
int StorageEngine::getTableDefinition(Session& session, |
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
370 |
const identifier::Table &identifier, |
1938.4.2
by Brian Aker
Fix style issue around table for message (though this is imperfect,...) |
371 |
message::table::shared_ptr &table_message, |
1309.2.3
by Brian Aker
Update the code so use a faster index lookup method. |
372 |
bool include_temporary_tables) |
1223.4.17
by Brian Aker
Added a form of getTableDefinition() that uses TableIdentifiers |
373 |
{
|
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
374 |
drizzled::error_t err= static_cast<drizzled::error_t>(ENOENT); |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
375 |
|
1273.19.11
by Brian Aker
This restores temporary tables back to being viewable via show/select. |
376 |
if (include_temporary_tables) |
377 |
{
|
|
1910.2.11
by Brian Aker
Have the SE go through the Session API for tables to directly find the table |
378 |
Table *table= session.find_temporary_table(identifier); |
379 |
if (table) |
|
380 |
{
|
|
2134.1.6
by Brian Aker
Merge in encapsulation of the table message from the main class. |
381 |
table_message.reset(new message::Table(*table->getShare()->getTableMessage())); |
1273.19.11
by Brian Aker
This restores temporary tables back to being viewable via show/select. |
382 |
return EEXIST; |
1910.2.11
by Brian Aker
Have the SE go through the Session API for tables to directly find the table |
383 |
}
|
1273.19.11
by Brian Aker
This restores temporary tables back to being viewable via show/select. |
384 |
}
|
385 |
||
1938.4.2
by Brian Aker
Fix style issue around table for message (though this is imperfect,...) |
386 |
drizzled::message::table::shared_ptr table_ptr; |
1910.2.14
by Brian Aker
Check simple cache performance hit. |
387 |
if ((table_ptr= drizzled::message::Cache::singleton().find(identifier))) |
388 |
{
|
|
1910.2.15
by Brian Aker
Update so that we use shared_ptr from the cache throughout more of the |
389 |
table_message= table_ptr; |
1910.2.14
by Brian Aker
Check simple cache performance hit. |
390 |
}
|
391 |
||
1910.2.15
by Brian Aker
Update so that we use shared_ptr from the cache throughout more of the |
392 |
message::Table message; |
1273.19.30
by Brian Aker
Performance patch... we now only cycle through engines that actually have |
393 |
EngineVector::iterator iter= |
1966.2.14
by Brian Aker
Merge in some additional std namespace finds. |
394 |
std::find_if(vector_of_engines.begin(), vector_of_engines.end(), |
395 |
StorageEngineGetTableDefinition(session, identifier, message, err)); |
|
1183.1.16
by Brian Aker
Switch to using vector over Registry |
396 |
|
397 |
if (iter == vector_of_engines.end()) |
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
398 |
{
|
1309.1.1
by Brian Aker
This removes the special case read of proto from SE interface, down to |
399 |
return ENOENT; |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
400 |
}
|
1910.2.15
by Brian Aker
Update so that we use shared_ptr from the cache throughout more of the |
401 |
table_message.reset(new message::Table(message)); |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
402 |
|
1910.2.14
by Brian Aker
Check simple cache performance hit. |
403 |
drizzled::message::Cache::singleton().insert(identifier, table_message); |
404 |
||
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
405 |
return err; |
406 |
}
|
|
407 |
||
2068.7.8
by Brian Aker
Merge in changes for table message API. |
408 |
message::table::shared_ptr StorageEngine::getTableMessage(Session& session, |
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
409 |
identifier::Table::const_reference identifier, |
2068.7.8
by Brian Aker
Merge in changes for table message API. |
410 |
drizzled::error_t &error, |
411 |
bool include_temporary_tables) |
|
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
412 |
{
|
413 |
error= static_cast<drizzled::error_t>(ENOENT); |
|
414 |
||
415 |
if (include_temporary_tables) |
|
416 |
{
|
|
417 |
Table *table= session.find_temporary_table(identifier); |
|
418 |
if (table) |
|
419 |
{
|
|
420 |
error= EE_OK; |
|
2134.1.6
by Brian Aker
Merge in encapsulation of the table message from the main class. |
421 |
return message::table::shared_ptr(new message::Table(*table->getShare()->getTableMessage())); |
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
422 |
}
|
423 |
}
|
|
424 |
||
425 |
drizzled::message::table::shared_ptr table_ptr; |
|
426 |
if ((table_ptr= drizzled::message::Cache::singleton().find(identifier))) |
|
427 |
{
|
|
2068.7.8
by Brian Aker
Merge in changes for table message API. |
428 |
(void)table_ptr; |
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
429 |
}
|
430 |
||
431 |
message::Table message; |
|
432 |
EngineVector::iterator iter= |
|
433 |
std::find_if(vector_of_engines.begin(), vector_of_engines.end(), |
|
434 |
StorageEngineGetTableDefinition(session, identifier, message, error)); |
|
435 |
||
436 |
if (iter == vector_of_engines.end()) |
|
437 |
{
|
|
438 |
error= static_cast<drizzled::error_t>(ENOENT); |
|
2068.7.8
by Brian Aker
Merge in changes for table message API. |
439 |
return message::table::shared_ptr(); |
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
440 |
}
|
2068.7.8
by Brian Aker
Merge in changes for table message API. |
441 |
message::table::shared_ptr table_message(new message::Table(message)); |
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
442 |
|
443 |
drizzled::message::Cache::singleton().insert(identifier, table_message); |
|
444 |
||
2068.7.8
by Brian Aker
Merge in changes for table message API. |
445 |
return table_message; |
2068.7.7
by Brian Aker
Add additional getTableMessage() method which will have a good return type. |
446 |
}
|
447 |
||
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
448 |
/**
|
449 |
An interceptor to hijack the text of the error message without
|
|
450 |
setting an error in the thread. We need the text to present it
|
|
451 |
in the form of a warning to the user.
|
|
452 |
*/
|
|
453 |
||
454 |
class Ha_delete_table_error_handler: public Internal_error_handler |
|
455 |
{
|
|
456 |
public: |
|
457 |
Ha_delete_table_error_handler() : Internal_error_handler() {} |
|
2087.3.1
by Brian Aker
Entire convert over to time_t. |
458 |
virtual bool handle_error(drizzled::error_t sql_errno, |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
459 |
const char *message, |
460 |
DRIZZLE_ERROR::enum_warning_level level, |
|
461 |
Session *session); |
|
462 |
char buff[DRIZZLE_ERRMSG_SIZE]; |
|
463 |
};
|
|
464 |
||
465 |
||
466 |
bool
|
|
467 |
Ha_delete_table_error_handler:: |
|
2087.3.1
by Brian Aker
Entire convert over to time_t. |
468 |
handle_error(drizzled::error_t , |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
469 |
const char *message, |
470 |
DRIZZLE_ERROR::enum_warning_level , |
|
471 |
Session *) |
|
472 |
{
|
|
473 |
/* Grab the error message */
|
|
474 |
strncpy(buff, message, sizeof(buff)-1); |
|
475 |
return true; |
|
476 |
}
|
|
477 |
||
2068.7.1
by Brian Aker
First pass through error correction in SE interface for drop table. |
478 |
class DropTableByIdentifier: public std::unary_function<EngineVector::value_type, bool> |
479 |
{
|
|
480 |
Session::reference session; |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
481 |
identifier::Table::const_reference identifier; |
2068.7.1
by Brian Aker
First pass through error correction in SE interface for drop table. |
482 |
drizzled::error_t &error; |
483 |
||
484 |
public: |
|
485 |
||
486 |
DropTableByIdentifier(Session::reference session_arg, |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
487 |
identifier::Table::const_reference identifier_arg, |
2068.7.1
by Brian Aker
First pass through error correction in SE interface for drop table. |
488 |
drizzled::error_t &error_arg) : |
489 |
session(session_arg), |
|
490 |
identifier(identifier_arg), |
|
491 |
error(error_arg) |
|
492 |
{ } |
|
493 |
||
494 |
result_type operator() (argument_type engine) |
|
495 |
{
|
|
496 |
if (not engine->doDoesTableExist(session, identifier)) |
|
497 |
return false; |
|
498 |
||
499 |
int local_error= engine->doDropTable(session, identifier); |
|
500 |
||
501 |
||
502 |
if (not local_error) |
|
503 |
return true; |
|
504 |
||
505 |
switch (local_error) |
|
506 |
{
|
|
507 |
case HA_ERR_NO_SUCH_TABLE: |
|
508 |
case ENOENT: |
|
509 |
error= static_cast<drizzled::error_t>(HA_ERR_NO_SUCH_TABLE); |
|
510 |
return false; |
|
511 |
||
512 |
default: |
|
513 |
error= static_cast<drizzled::error_t>(local_error); |
|
514 |
return true; |
|
515 |
}
|
|
516 |
}
|
|
517 |
};
|
|
518 |
||
519 |
||
520 |
bool StorageEngine::dropTable(Session::reference session, |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
521 |
identifier::Table::const_reference identifier, |
2068.7.1
by Brian Aker
First pass through error correction in SE interface for drop table. |
522 |
drizzled::error_t &error) |
523 |
{
|
|
524 |
error= EE_OK; |
|
525 |
||
526 |
EngineVector::const_iterator iter= std::find_if(vector_of_engines.begin(), vector_of_engines.end(), |
|
527 |
DropTableByIdentifier(session, identifier, error)); |
|
528 |
||
529 |
if (error) |
|
530 |
{
|
|
531 |
return false; |
|
532 |
}
|
|
533 |
else if (iter == vector_of_engines.end()) |
|
534 |
{
|
|
535 |
error= ER_BAD_TABLE_ERROR; |
|
536 |
return false; |
|
537 |
}
|
|
538 |
||
539 |
drizzled::message::Cache::singleton().erase(identifier); |
|
540 |
||
541 |
return true; |
|
542 |
}
|
|
543 |
||
544 |
bool StorageEngine::dropTable(Session& session, |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
545 |
const identifier::Table &identifier) |
2068.7.1
by Brian Aker
First pass through error correction in SE interface for drop table. |
546 |
{
|
547 |
drizzled::error_t error; |
|
548 |
||
549 |
if (not dropTable(session, identifier, error)) |
|
550 |
{
|
|
551 |
return false; |
|
552 |
}
|
|
553 |
||
554 |
return true; |
|
555 |
}
|
|
556 |
||
557 |
bool StorageEngine::dropTable(Session::reference session, |
|
558 |
StorageEngine &engine, |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
559 |
identifier::Table::const_reference identifier, |
2068.7.1
by Brian Aker
First pass through error correction in SE interface for drop table. |
560 |
drizzled::error_t &error) |
561 |
{
|
|
562 |
error= EE_OK; |
|
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
563 |
engine.setTransactionReadWrite(session); |
2068.7.2
by Brian Aker
Add assert to make sure we only use this method on temp tables. |
564 |
|
565 |
assert(identifier.isTmp()); |
|
1502.5.2
by Barry.Leslie at PrimeBase
Changes made to drizzle source when building in the events plugin. |
566 |
|
1502.5.8
by Barry.Leslie at PrimeBase
- Changed names to match the drizzle naming convention. |
567 |
if (unlikely(plugin::EventObserver::beforeDropTable(session, identifier))) |
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
568 |
{
|
569 |
error= ER_EVENT_OBSERVER_PLUGIN; |
|
570 |
}
|
|
571 |
else
|
|
572 |
{
|
|
2068.7.1
by Brian Aker
First pass through error correction in SE interface for drop table. |
573 |
error= static_cast<drizzled::error_t>(engine.doDropTable(session, identifier)); |
574 |
||
1502.5.8
by Barry.Leslie at PrimeBase
- Changed names to match the drizzle naming convention. |
575 |
if (unlikely(plugin::EventObserver::afterDropTable(session, identifier, error))) |
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
576 |
{
|
577 |
error= ER_EVENT_OBSERVER_PLUGIN; |
|
578 |
}
|
|
579 |
}
|
|
580 |
||
1910.2.14
by Brian Aker
Check simple cache performance hit. |
581 |
drizzled::message::Cache::singleton().erase(identifier); |
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
582 |
|
2068.7.1
by Brian Aker
First pass through error correction in SE interface for drop table. |
583 |
if (error) |
584 |
{
|
|
585 |
return false; |
|
586 |
}
|
|
587 |
||
588 |
return true; |
|
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
589 |
}
|
590 |
||
1412
by Brian Aker
Innodb is now in the house (aka... it handls its own DFE). |
591 |
|
971.1.38
by Monty Taylor
Moved delete table. |
592 |
/**
|
593 |
Initiates table-file and calls appropriate database-creator.
|
|
594 |
||
595 |
@retval
|
|
596 |
0 ok
|
|
597 |
@retval
|
|
598 |
1 error
|
|
599 |
*/
|
|
2068.7.6
by Brian Aker
Fix interface for create table such that it issues error and returns state |
600 |
bool StorageEngine::createTable(Session &session, |
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
601 |
const identifier::Table &identifier, |
2068.7.6
by Brian Aker
Fix interface for create table such that it issues error and returns state |
602 |
message::Table& table_message) |
971.1.38
by Monty Taylor
Moved delete table. |
603 |
{
|
2068.7.6
by Brian Aker
Fix interface for create table such that it issues error and returns state |
604 |
drizzled::error_t error= EE_OK; |
605 |
||
1608.2.4
by Brian Aker
Update for having share declared type. |
606 |
TableShare share(identifier); |
1859.2.11
by Brian Aker
Merge in so that shell requires a share to construct. |
607 |
table::Shell table(share); |
1130.3.16
by Monty Taylor
Moved the last three methods from plugin/storage_engine.cc to be static methods on StorageEngine. |
608 |
message::Table tmp_proto; |
971.1.38
by Monty Taylor
Moved delete table. |
609 |
|
1626.3.2
by Brian Aker
Cleanup table_share to pass in identifier. |
610 |
if (share.parse_table_proto(session, table_message) || share.open_table_from_share(&session, identifier, "", 0, 0, table)) |
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
611 |
{
|
612 |
// @note Error occured, we should probably do a little more here.
|
|
2068.7.6
by Brian Aker
Fix interface for create table such that it issues error and returns state |
613 |
// ER_CORRUPT_TABLE_DEFINITION,ER_CORRUPT_TABLE_DEFINITION_ENUM
|
614 |
||
615 |
my_error(ER_CORRUPT_TABLE_DEFINITION_UNKNOWN, identifier); |
|
616 |
||
617 |
return false; |
|
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
618 |
}
|
619 |
else
|
|
620 |
{
|
|
621 |
/* Check for legal operations against the Engine using the proto (if used) */
|
|
622 |
if (table_message.type() == message::Table::TEMPORARY && |
|
623 |
share.storage_engine->check_flag(HTON_BIT_TEMPORARY_NOT_SUPPORTED) == true) |
|
624 |
{
|
|
625 |
error= HA_ERR_UNSUPPORTED; |
|
626 |
}
|
|
627 |
else if (table_message.type() != message::Table::TEMPORARY && |
|
628 |
share.storage_engine->check_flag(HTON_BIT_TEMPORARY_ONLY) == true) |
|
629 |
{
|
|
630 |
error= HA_ERR_UNSUPPORTED; |
|
631 |
}
|
|
632 |
else
|
|
633 |
{
|
|
1412
by Brian Aker
Innodb is now in the house (aka... it handls its own DFE). |
634 |
share.storage_engine->setTransactionReadWrite(session); |
635 |
||
2068.7.6
by Brian Aker
Fix interface for create table such that it issues error and returns state |
636 |
error= static_cast<drizzled::error_t>(share.storage_engine->doCreateTable(session, |
637 |
table, |
|
638 |
identifier, |
|
639 |
table_message)); |
|
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
640 |
}
|
641 |
||
2068.7.1
by Brian Aker
First pass through error correction in SE interface for drop table. |
642 |
if (error == ER_TABLE_PERMISSION_DENIED) |
643 |
{
|
|
644 |
my_error(ER_TABLE_PERMISSION_DENIED, identifier); |
|
645 |
}
|
|
646 |
else if (error) |
|
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
647 |
{
|
1954.2.1
by Brian Aker
getSQLPath() modified to take a string so that we can const the table |
648 |
std::string path; |
649 |
identifier.getSQLPath(path); |
|
650 |
my_error(ER_CANT_CREATE_TABLE, MYF(ME_BELL+ME_WAITTANG), path.c_str(), error); |
|
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
651 |
}
|
652 |
||
1672.3.2
by Brian Aker
Tiny little cleanup around Table. |
653 |
table.delete_table(); |
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
654 |
}
|
655 |
||
2068.7.6
by Brian Aker
Fix interface for create table such that it issues error and returns state |
656 |
return(error == EE_OK); |
971.1.38
by Monty Taylor
Moved delete table. |
657 |
}
|
658 |
||
1869.1.4
by Brian Aker
TableShare is no longer in the house (i.e. we no longer directly have a copy |
659 |
Cursor *StorageEngine::getCursor(Table &arg) |
1183.1.1
by Brian Aker
Rework interface pieces on SE (sort of... dumb ones...) |
660 |
{
|
1869.1.4
by Brian Aker
TableShare is no longer in the house (i.e. we no longer directly have a copy |
661 |
return create(arg); |
1183.1.1
by Brian Aker
Rework interface pieces on SE (sort of... dumb ones...) |
662 |
}
|
1160.1.1
by Brian Aker
Refactor SE createTable back to engine class. |
663 |
|
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
664 |
class AddTableIdentifier : |
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
665 |
public std::unary_function<StorageEngine *, void> |
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
666 |
{
|
667 |
CachedDirectory &directory; |
|
2087.4.1
by Brian Aker
Merge in schema identifier. |
668 |
const identifier::Schema &identifier; |
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
669 |
identifier::Table::vector &set_of_identifiers; |
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
670 |
|
671 |
public: |
|
672 |
||
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
673 |
AddTableIdentifier(CachedDirectory &directory_arg, const identifier::Schema &identifier_arg, identifier::Table::vector &of_names) : |
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
674 |
directory(directory_arg), |
675 |
identifier(identifier_arg), |
|
676 |
set_of_identifiers(of_names) |
|
677 |
{
|
|
678 |
}
|
|
679 |
||
680 |
result_type operator() (argument_type engine) |
|
681 |
{
|
|
682 |
engine->doGetTableIdentifiers(directory, identifier, set_of_identifiers); |
|
683 |
}
|
|
684 |
};
|
|
685 |
||
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
686 |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
687 |
void StorageEngine::getIdentifiers(Session &session, const identifier::Schema &schema_identifier, identifier::Table::vector &set_of_identifiers) |
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
688 |
{
|
689 |
CachedDirectory directory(schema_identifier.getPath(), set_of_table_definition_ext); |
|
690 |
||
691 |
if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER) |
|
692 |
{ } |
|
693 |
else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER) |
|
694 |
{ } |
|
695 |
else
|
|
696 |
{
|
|
697 |
if (directory.fail()) |
|
698 |
{
|
|
699 |
errno= directory.getError(); |
|
700 |
if (errno == ENOENT) |
|
1954.2.1
by Brian Aker
getSQLPath() modified to take a string so that we can const the table |
701 |
{
|
702 |
std::string path; |
|
703 |
schema_identifier.getSQLPath(path); |
|
704 |
my_error(ER_BAD_DB_ERROR, MYF(ME_BELL+ME_WAITTANG), path.c_str()); |
|
705 |
}
|
|
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
706 |
else
|
1954.2.1
by Brian Aker
getSQLPath() modified to take a string so that we can const the table |
707 |
{
|
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
708 |
my_error(ER_CANT_READ_DIR, MYF(ME_BELL+ME_WAITTANG), directory.getPath(), errno); |
1954.2.1
by Brian Aker
getSQLPath() modified to take a string so that we can const the table |
709 |
}
|
710 |
||
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
711 |
return; |
712 |
}
|
|
713 |
}
|
|
714 |
||
1966.2.14
by Brian Aker
Merge in some additional std namespace finds. |
715 |
std::for_each(vector_of_engines.begin(), vector_of_engines.end(), |
716 |
AddTableIdentifier(directory, schema_identifier, set_of_identifiers)); |
|
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
717 |
|
718 |
session.doGetTableIdentifiers(directory, schema_identifier, set_of_identifiers); |
|
719 |
}
|
|
720 |
||
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
721 |
class DropTable: public std::unary_function<identifier::Table&, bool> |
1510.3.2
by mordred
Fix error found by cppcheck - modifying a container invalidates its iterators, |
722 |
{
|
723 |
Session &session; |
|
724 |
StorageEngine *engine; |
|
725 |
||
726 |
public: |
|
727 |
||
728 |
DropTable(Session &session_arg, StorageEngine *engine_arg) : |
|
729 |
session(session_arg), |
|
730 |
engine(engine_arg) |
|
731 |
{ } |
|
732 |
||
733 |
result_type operator() (argument_type identifier) |
|
734 |
{
|
|
735 |
return engine->doDropTable(session, identifier) == 0; |
|
736 |
}
|
|
737 |
};
|
|
738 |
||
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
739 |
/* This will later be converted to identifier::Tables */
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
740 |
class DropTables: public std::unary_function<StorageEngine *, void> |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
741 |
{
|
742 |
Session &session; |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
743 |
identifier::Table::vector &table_identifiers; |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
744 |
|
745 |
public: |
|
746 |
||
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
747 |
DropTables(Session &session_arg, identifier::Table::vector &table_identifiers_arg) : |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
748 |
session(session_arg), |
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
749 |
table_identifiers(table_identifiers_arg) |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
750 |
{ } |
751 |
||
752 |
result_type operator() (argument_type engine) |
|
753 |
{
|
|
1510.3.2
by mordred
Fix error found by cppcheck - modifying a container invalidates its iterators, |
754 |
// True returning from DropTable means the table has been successfully
|
755 |
// deleted, so it should be removed from the list of tables to drop
|
|
1966.2.15
by Brian Aker
Did a grep for _if( |
756 |
table_identifiers.erase(std::remove_if(table_identifiers.begin(), |
757 |
table_identifiers.end(), |
|
758 |
DropTable(session, engine)), |
|
1510.3.2
by mordred
Fix error found by cppcheck - modifying a container invalidates its iterators, |
759 |
table_identifiers.end()); |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
760 |
}
|
761 |
};
|
|
762 |
||
763 |
/*
|
|
764 |
This only works for engines which use file based DFE.
|
|
765 |
||
766 |
Note-> Unlike MySQL, we do not, on purpose, delete files that do not match any engines.
|
|
767 |
*/
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
768 |
void StorageEngine::removeLostTemporaryTables(Session &session, const char *directory) |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
769 |
{
|
770 |
CachedDirectory dir(directory, set_of_table_definition_ext); |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
771 |
identifier::Table::vector table_identifiers; |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
772 |
|
773 |
if (dir.fail()) |
|
774 |
{
|
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
775 |
errno= dir.getError(); |
776 |
my_error(ER_CANT_READ_DIR, MYF(0), directory, errno); |
|
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
777 |
|
778 |
return; |
|
779 |
}
|
|
780 |
||
781 |
CachedDirectory::Entries files= dir.getEntries(); |
|
782 |
||
783 |
for (CachedDirectory::Entries::iterator fileIter= files.begin(); |
|
784 |
fileIter != files.end(); fileIter++) |
|
785 |
{
|
|
786 |
size_t length; |
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
787 |
std::string path; |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
788 |
CachedDirectory::Entry *entry= *fileIter; |
789 |
||
790 |
/* We remove the file extension. */
|
|
791 |
length= entry->filename.length(); |
|
792 |
entry->filename.resize(length - DEFAULT_DEFINITION_FILE_EXT.length()); |
|
793 |
||
794 |
path+= directory; |
|
795 |
path+= FN_LIBCHAR; |
|
796 |
path+= entry->filename; |
|
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
797 |
message::Table definition; |
798 |
if (StorageEngine::readTableFile(path, definition)) |
|
799 |
{
|
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
800 |
identifier::Table identifier(definition.schema(), definition.name(), path); |
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
801 |
table_identifiers.push_back(identifier); |
802 |
}
|
|
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
803 |
}
|
804 |
||
1966.2.14
by Brian Aker
Merge in some additional std namespace finds. |
805 |
std::for_each(vector_of_engines.begin(), vector_of_engines.end(), |
806 |
DropTables(session, table_identifiers)); |
|
807 |
||
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
808 |
/*
|
809 |
Now we just clean up anything that might left over.
|
|
810 |
||
811 |
We rescan because some of what might have been there should
|
|
812 |
now be all nice and cleaned up.
|
|
813 |
*/
|
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
814 |
std::set<std::string> all_exts= set_of_table_definition_ext; |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
815 |
|
1273.19.30
by Brian Aker
Performance patch... we now only cycle through engines that actually have |
816 |
for (EngineVector::iterator iter= vector_of_engines.begin(); |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
817 |
iter != vector_of_engines.end() ; iter++) |
818 |
{
|
|
819 |
for (const char **ext= (*iter)->bas_ext(); *ext ; ext++) |
|
820 |
all_exts.insert(*ext); |
|
821 |
}
|
|
822 |
||
823 |
CachedDirectory rescan(directory, all_exts); |
|
824 |
||
825 |
files= rescan.getEntries(); |
|
826 |
for (CachedDirectory::Entries::iterator fileIter= files.begin(); |
|
827 |
fileIter != files.end(); fileIter++) |
|
828 |
{
|
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
829 |
std::string path; |
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
830 |
CachedDirectory::Entry *entry= *fileIter; |
831 |
||
832 |
path+= directory; |
|
833 |
path+= FN_LIBCHAR; |
|
834 |
path+= entry->filename; |
|
835 |
||
836 |
unlink(path.c_str()); |
|
837 |
}
|
|
838 |
}
|
|
839 |
||
1160.1.1
by Brian Aker
Refactor SE createTable back to engine class. |
840 |
|
1216.1.1
by Brian Aker
Move print_error up to Engine. |
841 |
/**
|
842 |
Print error that we got from Cursor function.
|
|
843 |
||
844 |
@note
|
|
845 |
In case of delete table it's only safe to use the following parts of
|
|
846 |
the 'table' structure:
|
|
1532.1.15
by Brian Aker
Partial encapsulation of TableShare from Table. |
847 |
- table->getShare()->path
|
1216.1.1
by Brian Aker
Move print_error up to Engine. |
848 |
- table->alias
|
849 |
*/
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
850 |
void StorageEngine::print_error(int error, myf errflag, Table &table) |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
851 |
{
|
2054.1.2
by Brian Aker
Rename of the Loooongggggg error type over to simply drizzled::error_t |
852 |
drizzled::error_t textno= ER_GET_ERRNO; |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
853 |
switch (error) { |
854 |
case EACCES: |
|
855 |
textno=ER_OPEN_AS_READONLY; |
|
856 |
break; |
|
857 |
case EAGAIN: |
|
858 |
textno=ER_FILE_USED; |
|
859 |
break; |
|
860 |
case ENOENT: |
|
861 |
textno=ER_FILE_NOT_FOUND; |
|
862 |
break; |
|
863 |
case HA_ERR_KEY_NOT_FOUND: |
|
864 |
case HA_ERR_NO_ACTIVE_RECORD: |
|
865 |
case HA_ERR_END_OF_FILE: |
|
866 |
textno=ER_KEY_NOT_FOUND; |
|
867 |
break; |
|
868 |
case HA_ERR_WRONG_MRG_TABLE_DEF: |
|
869 |
textno=ER_WRONG_MRG_TABLE; |
|
870 |
break; |
|
871 |
case HA_ERR_FOUND_DUPP_KEY: |
|
872 |
{
|
|
2068.7.5
by Brian Aker
Remove dead call to print error that didn't use a table reference. |
873 |
uint32_t key_nr= table.get_dup_key(error); |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
874 |
if ((int) key_nr >= 0) |
875 |
{
|
|
876 |
const char *err_msg= ER(ER_DUP_ENTRY_WITH_KEY_NAME); |
|
877 |
||
2068.7.5
by Brian Aker
Remove dead call to print error that didn't use a table reference. |
878 |
print_keydup_error(key_nr, err_msg, table); |
1578.6.5
by Brian Aker
Remove error message for less effective one, but remove current_session(). |
879 |
|
1216.1.1
by Brian Aker
Move print_error up to Engine. |
880 |
return; |
881 |
}
|
|
882 |
textno=ER_DUP_KEY; |
|
883 |
break; |
|
884 |
}
|
|
885 |
case HA_ERR_FOREIGN_DUPLICATE_KEY: |
|
886 |
{
|
|
2068.7.5
by Brian Aker
Remove dead call to print error that didn't use a table reference. |
887 |
uint32_t key_nr= table.get_dup_key(error); |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
888 |
if ((int) key_nr >= 0) |
889 |
{
|
|
890 |
uint32_t max_length; |
|
891 |
||
892 |
/* Write the key in the error message */
|
|
893 |
char key[MAX_KEY_LENGTH]; |
|
894 |
String str(key,sizeof(key),system_charset_info); |
|
895 |
||
896 |
/* Table is opened and defined at this point */
|
|
2068.7.5
by Brian Aker
Remove dead call to print error that didn't use a table reference. |
897 |
key_unpack(&str, &table,(uint32_t) key_nr); |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
898 |
max_length= (DRIZZLE_ERRMSG_SIZE- |
899 |
(uint32_t) strlen(ER(ER_FOREIGN_DUPLICATE_KEY))); |
|
900 |
if (str.length() >= max_length) |
|
901 |
{
|
|
902 |
str.length(max_length-4); |
|
903 |
str.append(STRING_WITH_LEN("...")); |
|
904 |
}
|
|
2068.7.5
by Brian Aker
Remove dead call to print error that didn't use a table reference. |
905 |
my_error(ER_FOREIGN_DUPLICATE_KEY, MYF(0), table.getShare()->getTableName(), |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
906 |
str.c_ptr(), key_nr+1); |
907 |
return; |
|
908 |
}
|
|
909 |
textno= ER_DUP_KEY; |
|
910 |
break; |
|
911 |
}
|
|
912 |
case HA_ERR_FOUND_DUPP_UNIQUE: |
|
913 |
textno=ER_DUP_UNIQUE; |
|
914 |
break; |
|
915 |
case HA_ERR_RECORD_CHANGED: |
|
916 |
textno=ER_CHECKREAD; |
|
917 |
break; |
|
918 |
case HA_ERR_CRASHED: |
|
919 |
textno=ER_NOT_KEYFILE; |
|
920 |
break; |
|
921 |
case HA_ERR_WRONG_IN_RECORD: |
|
922 |
textno= ER_CRASHED_ON_USAGE; |
|
923 |
break; |
|
924 |
case HA_ERR_CRASHED_ON_USAGE: |
|
925 |
textno=ER_CRASHED_ON_USAGE; |
|
926 |
break; |
|
927 |
case HA_ERR_NOT_A_TABLE: |
|
2054.1.2
by Brian Aker
Rename of the Loooongggggg error type over to simply drizzled::error_t |
928 |
textno= static_cast<drizzled::error_t>(error); |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
929 |
break; |
930 |
case HA_ERR_CRASHED_ON_REPAIR: |
|
931 |
textno=ER_CRASHED_ON_REPAIR; |
|
932 |
break; |
|
933 |
case HA_ERR_OUT_OF_MEM: |
|
934 |
textno=ER_OUT_OF_RESOURCES; |
|
935 |
break; |
|
936 |
case HA_ERR_WRONG_COMMAND: |
|
937 |
textno=ER_ILLEGAL_HA; |
|
938 |
break; |
|
939 |
case HA_ERR_OLD_FILE: |
|
940 |
textno=ER_OLD_KEYFILE; |
|
941 |
break; |
|
942 |
case HA_ERR_UNSUPPORTED: |
|
943 |
textno=ER_UNSUPPORTED_EXTENSION; |
|
944 |
break; |
|
945 |
case HA_ERR_RECORD_FILE_FULL: |
|
946 |
case HA_ERR_INDEX_FILE_FULL: |
|
947 |
textno=ER_RECORD_FILE_FULL; |
|
948 |
break; |
|
949 |
case HA_ERR_LOCK_WAIT_TIMEOUT: |
|
950 |
textno=ER_LOCK_WAIT_TIMEOUT; |
|
951 |
break; |
|
952 |
case HA_ERR_LOCK_TABLE_FULL: |
|
953 |
textno=ER_LOCK_TABLE_FULL; |
|
954 |
break; |
|
955 |
case HA_ERR_LOCK_DEADLOCK: |
|
956 |
textno=ER_LOCK_DEADLOCK; |
|
957 |
break; |
|
958 |
case HA_ERR_READ_ONLY_TRANSACTION: |
|
959 |
textno=ER_READ_ONLY_TRANSACTION; |
|
960 |
break; |
|
961 |
case HA_ERR_CANNOT_ADD_FOREIGN: |
|
962 |
textno=ER_CANNOT_ADD_FOREIGN; |
|
963 |
break; |
|
964 |
case HA_ERR_ROW_IS_REFERENCED: |
|
965 |
{
|
|
966 |
String str; |
|
967 |
get_error_message(error, &str); |
|
968 |
my_error(ER_ROW_IS_REFERENCED_2, MYF(0), str.c_ptr_safe()); |
|
969 |
return; |
|
970 |
}
|
|
971 |
case HA_ERR_NO_REFERENCED_ROW: |
|
972 |
{
|
|
973 |
String str; |
|
974 |
get_error_message(error, &str); |
|
975 |
my_error(ER_NO_REFERENCED_ROW_2, MYF(0), str.c_ptr_safe()); |
|
976 |
return; |
|
977 |
}
|
|
978 |
case HA_ERR_TABLE_DEF_CHANGED: |
|
979 |
textno=ER_TABLE_DEF_CHANGED; |
|
980 |
break; |
|
981 |
case HA_ERR_NO_SUCH_TABLE: |
|
2140.1.3
by Brian Aker
Merge in error message fix for just one type of error for unknown table. |
982 |
{
|
983 |
identifier::Table identifier(table.getShare()->getSchemaName(), table.getShare()->getTableName()); |
|
984 |
my_error(ER_TABLE_UNKNOWN, identifier); |
|
985 |
return; |
|
986 |
}
|
|
1216.1.1
by Brian Aker
Move print_error up to Engine. |
987 |
case HA_ERR_RBR_LOGGING_FAILED: |
988 |
textno= ER_BINLOG_ROW_LOGGING_FAILED; |
|
989 |
break; |
|
990 |
case HA_ERR_DROP_INDEX_FK: |
|
991 |
{
|
|
992 |
const char *ptr= "???"; |
|
2068.7.5
by Brian Aker
Remove dead call to print error that didn't use a table reference. |
993 |
uint32_t key_nr= table.get_dup_key(error); |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
994 |
if ((int) key_nr >= 0) |
2068.7.5
by Brian Aker
Remove dead call to print error that didn't use a table reference. |
995 |
ptr= table.key_info[key_nr].name; |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
996 |
my_error(ER_DROP_INDEX_FK, MYF(0), ptr); |
997 |
return; |
|
998 |
}
|
|
999 |
case HA_ERR_TABLE_NEEDS_UPGRADE: |
|
1000 |
textno=ER_TABLE_NEEDS_UPGRADE; |
|
1001 |
break; |
|
1002 |
case HA_ERR_TABLE_READONLY: |
|
1003 |
textno= ER_OPEN_AS_READONLY; |
|
1004 |
break; |
|
1005 |
case HA_ERR_AUTOINC_READ_FAILED: |
|
1006 |
textno= ER_AUTOINC_READ_FAILED; |
|
1007 |
break; |
|
1008 |
case HA_ERR_AUTOINC_ERANGE: |
|
1009 |
textno= ER_WARN_DATA_OUT_OF_RANGE; |
|
1010 |
break; |
|
1011 |
case HA_ERR_LOCK_OR_ACTIVE_TRANSACTION: |
|
1012 |
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, |
|
1013 |
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); |
|
1014 |
return; |
|
1015 |
default: |
|
1016 |
{
|
|
1017 |
/*
|
|
1018 |
The error was "unknown" to this function.
|
|
1019 |
Ask Cursor if it has got a message for this error
|
|
1020 |
*/
|
|
1021 |
bool temporary= false; |
|
1022 |
String str; |
|
1023 |
temporary= get_error_message(error, &str); |
|
1024 |
if (!str.is_empty()) |
|
1025 |
{
|
|
1026 |
const char* engine_name= getName().c_str(); |
|
1027 |
if (temporary) |
|
1028 |
my_error(ER_GET_TEMPORARY_ERRMSG, MYF(0), error, str.ptr(), |
|
1029 |
engine_name); |
|
1030 |
else
|
|
1031 |
my_error(ER_GET_ERRMSG, MYF(0), error, str.ptr(), engine_name); |
|
1032 |
}
|
|
1033 |
else
|
|
1034 |
{
|
|
1035 |
my_error(ER_GET_ERRNO,errflag,error); |
|
1036 |
}
|
|
1037 |
return; |
|
1038 |
}
|
|
1039 |
}
|
|
2068.7.5
by Brian Aker
Remove dead call to print error that didn't use a table reference. |
1040 |
|
1041 |
my_error(textno, errflag, table.getShare()->getTableName(), error); |
|
1216.1.1
by Brian Aker
Move print_error up to Engine. |
1042 |
}
|
1043 |
||
1044 |
||
1045 |
/**
|
|
1046 |
Return an error message specific to this Cursor.
|
|
1047 |
||
1048 |
@param error error code previously returned by Cursor
|
|
1049 |
@param buf pointer to String where to add error message
|
|
1050 |
||
1051 |
@return
|
|
1052 |
Returns true if this is a temporary error
|
|
1053 |
*/
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
1054 |
bool StorageEngine::get_error_message(int , String* ) |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
1055 |
{
|
1056 |
return false; |
|
1057 |
}
|
|
1058 |
||
1059 |
||
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
1060 |
void StorageEngine::print_keydup_error(uint32_t key_nr, const char *msg, Table &table) |
1216.1.1
by Brian Aker
Move print_error up to Engine. |
1061 |
{
|
1062 |
/* Write the duplicated key in the error message */
|
|
1063 |
char key[MAX_KEY_LENGTH]; |
|
1064 |
String str(key,sizeof(key),system_charset_info); |
|
1065 |
||
1066 |
if (key_nr == MAX_KEY) |
|
1067 |
{
|
|
1068 |
/* Key is unknown */
|
|
1069 |
str.copy("", 0, system_charset_info); |
|
1070 |
my_printf_error(ER_DUP_ENTRY, msg, MYF(0), str.c_ptr(), "*UNKNOWN*"); |
|
1071 |
}
|
|
1072 |
else
|
|
1073 |
{
|
|
1074 |
/* Table is opened and defined at this point */
|
|
1075 |
key_unpack(&str, &table, (uint32_t) key_nr); |
|
1076 |
uint32_t max_length=DRIZZLE_ERRMSG_SIZE-(uint32_t) strlen(msg); |
|
1077 |
if (str.length() >= max_length) |
|
1078 |
{
|
|
1079 |
str.length(max_length-4); |
|
1080 |
str.append(STRING_WITH_LEN("...")); |
|
1081 |
}
|
|
1082 |
my_printf_error(ER_DUP_ENTRY, msg, |
|
1083 |
MYF(0), str.c_ptr(), table.key_info[key_nr].name); |
|
1084 |
}
|
|
1085 |
}
|
|
1086 |
||
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1087 |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
1088 |
int StorageEngine::deleteDefinitionFromPath(const identifier::Table &identifier) |
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1089 |
{
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
1090 |
std::string path(identifier.getPath()); |
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1091 |
|
1092 |
path.append(DEFAULT_DEFINITION_FILE_EXT); |
|
1093 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1094 |
return internal::my_delete(path.c_str(), MYF(0)); |
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1095 |
}
|
1096 |
||
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
1097 |
int StorageEngine::renameDefinitionFromPath(const identifier::Table &dest, const identifier::Table &src) |
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1098 |
{
|
1395.1.18
by Brian Aker
Small update. |
1099 |
message::Table table_message; |
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
1100 |
std::string src_path(src.getPath()); |
1101 |
std::string dest_path(dest.getPath()); |
|
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1102 |
|
1103 |
src_path.append(DEFAULT_DEFINITION_FILE_EXT); |
|
1104 |
dest_path.append(DEFAULT_DEFINITION_FILE_EXT); |
|
1105 |
||
1395.1.18
by Brian Aker
Small update. |
1106 |
bool was_read= StorageEngine::readTableFile(src_path.c_str(), table_message); |
1107 |
||
1108 |
if (not was_read) |
|
1109 |
{
|
|
1110 |
return ENOENT; |
|
1111 |
}
|
|
1395.1.1
by Brian Aker
Fixes for alter table to make sure that the proto on disk is valid. |
1112 |
|
1113 |
dest.copyToTableMessage(table_message); |
|
1114 |
||
1395.1.18
by Brian Aker
Small update. |
1115 |
int error= StorageEngine::writeDefinitionFromPath(dest, table_message); |
1116 |
||
1117 |
if (not error) |
|
1395.1.1
by Brian Aker
Fixes for alter table to make sure that the proto on disk is valid. |
1118 |
{
|
1395.1.18
by Brian Aker
Small update. |
1119 |
if (unlink(src_path.c_str())) |
1120 |
perror(src_path.c_str()); |
|
1395.1.1
by Brian Aker
Fixes for alter table to make sure that the proto on disk is valid. |
1121 |
}
|
1122 |
||
1395.1.18
by Brian Aker
Small update. |
1123 |
return error; |
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1124 |
}
|
1125 |
||
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
1126 |
int StorageEngine::writeDefinitionFromPath(const identifier::Table &identifier, message::Table &table_message) |
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1127 |
{
|
1395.1.18
by Brian Aker
Small update. |
1128 |
char definition_file_tmp[FN_REFLEN]; |
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
1129 |
std::string file_name(identifier.getPath()); |
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1130 |
|
1131 |
file_name.append(DEFAULT_DEFINITION_FILE_EXT); |
|
1132 |
||
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
1133 |
snprintf(definition_file_tmp, sizeof(definition_file_tmp), "%sXXXXXX", file_name.c_str()); |
1395.1.18
by Brian Aker
Small update. |
1134 |
|
1135 |
int fd= mkstemp(definition_file_tmp); |
|
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1136 |
|
1137 |
if (fd == -1) |
|
1395.1.1
by Brian Aker
Fixes for alter table to make sure that the proto on disk is valid. |
1138 |
{
|
1395.1.18
by Brian Aker
Small update. |
1139 |
perror(definition_file_tmp); |
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1140 |
return errno; |
1395.1.1
by Brian Aker
Fixes for alter table to make sure that the proto on disk is valid. |
1141 |
}
|
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1142 |
|
1143 |
google::protobuf::io::ZeroCopyOutputStream* output= |
|
1144 |
new google::protobuf::io::FileOutputStream(fd); |
|
1145 |
||
1608.1.2
by Brian Aker
Merge enum test |
1146 |
bool success; |
1147 |
||
1966.3.1
by Monty Taylor
Use std::exception instead of catch(...) |
1148 |
try
|
1149 |
{
|
|
1608.1.2
by Brian Aker
Merge enum test |
1150 |
success= table_message.SerializeToZeroCopyStream(output); |
1151 |
}
|
|
1152 |
catch (...) |
|
1153 |
{
|
|
1154 |
success= false; |
|
1155 |
}
|
|
1156 |
||
1157 |
if (not success) |
|
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1158 |
{
|
2017.2.1
by Brian Aker
Cleanup error messages around bad table definitions. |
1159 |
std::string error_message; |
1160 |
identifier.getSQLPath(error_message); |
|
1161 |
||
1395.1.18
by Brian Aker
Small update. |
1162 |
my_error(ER_CORRUPT_TABLE_DEFINITION, MYF(0), |
2017.2.1
by Brian Aker
Cleanup error messages around bad table definitions. |
1163 |
error_message.c_str(), |
1395.1.18
by Brian Aker
Small update. |
1164 |
table_message.InitializationErrorString().c_str()); |
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1165 |
delete output; |
1395.1.18
by Brian Aker
Small update. |
1166 |
|
1167 |
if (close(fd) == -1) |
|
1168 |
perror(definition_file_tmp); |
|
1169 |
||
1170 |
if (unlink(definition_file_tmp) == -1) |
|
1171 |
perror(definition_file_tmp); |
|
1172 |
||
1173 |
return ER_CORRUPT_TABLE_DEFINITION; |
|
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1174 |
}
|
1175 |
||
1176 |
delete output; |
|
1395.1.18
by Brian Aker
Small update. |
1177 |
|
1178 |
if (close(fd) == -1) |
|
1179 |
{
|
|
1180 |
int error= errno; |
|
1181 |
perror(definition_file_tmp); |
|
1182 |
||
1183 |
if (unlink(definition_file_tmp)) |
|
1184 |
perror(definition_file_tmp); |
|
1185 |
||
1186 |
return error; |
|
1187 |
}
|
|
1188 |
||
1189 |
if (rename(definition_file_tmp, file_name.c_str()) == -1) |
|
1190 |
{
|
|
1191 |
int error= errno; |
|
1192 |
perror(definition_file_tmp); |
|
1193 |
||
1194 |
if (unlink(definition_file_tmp)) |
|
1195 |
perror(definition_file_tmp); |
|
1196 |
||
1197 |
return error; |
|
1198 |
}
|
|
1395.1.1
by Brian Aker
Fixes for alter table to make sure that the proto on disk is valid. |
1199 |
|
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1200 |
return 0; |
1201 |
}
|
|
1202 |
||
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
1203 |
class CanCreateTable: public std::unary_function<StorageEngine *, bool> |
1320.1.8
by Brian Aker
Temporary fix for allowing engines to say "don't do this". |
1204 |
{
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
1205 |
const identifier::Table &identifier; |
1320.1.8
by Brian Aker
Temporary fix for allowing engines to say "don't do this". |
1206 |
|
1207 |
public: |
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
1208 |
CanCreateTable(const identifier::Table &identifier_arg) : |
1320.1.8
by Brian Aker
Temporary fix for allowing engines to say "don't do this". |
1209 |
identifier(identifier_arg) |
1210 |
{ } |
|
1211 |
||
1212 |
result_type operator() (argument_type engine) |
|
1213 |
{
|
|
1214 |
return not engine->doCanCreateTable(identifier); |
|
1215 |
}
|
|
1216 |
};
|
|
1217 |
||
1218 |
||
1219 |
/**
|
|
1220 |
@note on success table can be created.
|
|
1221 |
*/
|
|
2087.4.2
by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers. |
1222 |
bool StorageEngine::canCreateTable(const identifier::Table &identifier) |
1320.1.8
by Brian Aker
Temporary fix for allowing engines to say "don't do this". |
1223 |
{
|
1224 |
EngineVector::iterator iter= |
|
1966.2.14
by Brian Aker
Merge in some additional std namespace finds. |
1225 |
std::find_if(vector_of_engines.begin(), vector_of_engines.end(), |
1226 |
CanCreateTable(identifier)); |
|
1320.1.8
by Brian Aker
Temporary fix for allowing engines to say "don't do this". |
1227 |
|
1228 |
if (iter == vector_of_engines.end()) |
|
1229 |
{
|
|
1230 |
return true; |
|
1231 |
}
|
|
1232 |
||
1233 |
return false; |
|
1234 |
}
|
|
1235 |
||
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
1236 |
bool StorageEngine::readTableFile(const std::string &path, message::Table &table_message) |
1237 |
{
|
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
1238 |
std::fstream input(path.c_str(), std::ios::in | std::ios::binary); |
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
1239 |
|
1240 |
if (input.good()) |
|
1241 |
{
|
|
1608.1.2
by Brian Aker
Merge enum test |
1242 |
try { |
1243 |
if (table_message.ParseFromIstream(&input)) |
|
1244 |
{
|
|
1245 |
return true; |
|
1246 |
}
|
|
1247 |
}
|
|
1248 |
catch (...) |
|
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
1249 |
{
|
1608.1.2
by Brian Aker
Merge enum test |
1250 |
my_error(ER_CORRUPT_TABLE_DEFINITION, MYF(0), |
2017.2.1
by Brian Aker
Cleanup error messages around bad table definitions. |
1251 |
table_message.name().empty() ? path.c_str() : table_message.name().c_str(), |
1608.1.2
by Brian Aker
Merge enum test |
1252 |
table_message.InitializationErrorString().empty() ? "": table_message.InitializationErrorString().c_str()); |
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
1253 |
}
|
1254 |
}
|
|
1255 |
else
|
|
1256 |
{
|
|
1257 |
perror(path.c_str()); |
|
1258 |
}
|
|
1259 |
||
1260 |
return false; |
|
1261 |
}
|
|
1262 |
||
2029.1.2
by Brian Aker
Merge in refactor of LIKE up to its own calling pointer in the parser. |
1263 |
std::ostream& operator<<(std::ostream& output, const StorageEngine &engine) |
1264 |
{
|
|
1265 |
output << "StorageEngine:("; |
|
1266 |
output << engine.getName(); |
|
1267 |
output << ")"; |
|
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
1268 |
|
2029.1.2
by Brian Aker
Merge in refactor of LIKE up to its own calling pointer in the parser. |
1269 |
return output; |
1270 |
}
|
|
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
1271 |
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
1272 |
} /* namespace plugin */ |
1160.1.1
by Brian Aker
Refactor SE createTable back to engine class. |
1273 |
} /* namespace drizzled */ |