1
by brian
clean slate |
1 |
/* Copyright (C) 2005 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
670.2.2
by Monty Taylor
Got rid of the rest of common_includes. Now on to server_includes. |
16 |
#include <drizzled/server_includes.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. |
17 |
#include <drizzled/table.h> |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
18 |
#include <mysys/my_dir.h> |
19 |
#include <drizzled/error.h> |
|
20 |
||
1
by brian
clean slate |
21 |
#include "ha_blackhole.h" |
22 |
||
960.2.41
by Monty Taylor
Made StorageEngine name private. Added constructor param and accessor method. |
23 |
#include <string> |
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
24 |
#include <map> |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
25 |
#include <fstream> |
26 |
#include <drizzled/message/table.pb.h> |
|
27 |
#include <google/protobuf/io/zero_copy_stream.h> |
|
28 |
#include <google/protobuf/io/zero_copy_stream_impl.h> |
|
960.2.41
by Monty Taylor
Made StorageEngine name private. Added constructor param and accessor method. |
29 |
|
30 |
using namespace std; |
|
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
31 |
using namespace google; |
960.2.41
by Monty Taylor
Made StorageEngine name private. Added constructor param and accessor method. |
32 |
|
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
33 |
#define BLACKHOLE_EXT ".blk"
|
1039.3.1
by Stewart Smith
move bas_ext to StorageEngine instead of handler |
34 |
|
35 |
static const char *ha_blackhole_exts[] = { |
|
36 |
NULL
|
|
37 |
};
|
|
38 |
||
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
39 |
class BlackholeEngine : public drizzled::plugin::StorageEngine |
1
by brian
clean slate |
40 |
{
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
41 |
typedef map<string, BlackholeShare*> BlackholeMap; |
42 |
BlackholeMap blackhole_open_tables; |
|
43 |
||
960.2.41
by Monty Taylor
Made StorageEngine name private. Added constructor param and accessor method. |
44 |
public: |
964.1.4
by Monty Taylor
Moved flags into private area. |
45 |
BlackholeEngine(const string &name_arg) |
1233.1.3
by Brian Aker
Move more of the flags up to engine flags. |
46 |
: drizzled::plugin::StorageEngine(name_arg, HTON_FILE_BASED | |
47 |
HTON_NULL_IN_KEY | |
|
48 |
HTON_CAN_INDEX_BLOBS | |
|
1236.1.2
by Brian Aker
Updating blackhole to skip store_lock. I've added a test to make sure that |
49 |
HTON_SKIP_STORE_LOCK | |
1233.1.6
by Brian Aker
Remove table_flags from MyISAM. |
50 |
HTON_AUTO_PART_KEY | |
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
51 |
HTON_HAS_DATA_DICTIONARY), |
52 |
blackhole_open_tables() |
|
1183.1.27
by Brian Aker
Fix issue where there are too many files in data directory. We now only |
53 |
{
|
54 |
table_definition_ext= BLACKHOLE_EXT; |
|
55 |
}
|
|
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
56 |
|
1208.3.2
by brian
Update for Cursor renaming. |
57 |
virtual Cursor *create(TableShare &table, |
960.2.29
by Monty Taylor
Updated blackhole. |
58 |
MEM_ROOT *mem_root) |
59 |
{
|
|
1208.3.2
by brian
Update for Cursor renaming. |
60 |
return new (mem_root) ha_blackhole(*this, table); |
960.2.29
by Monty Taylor
Updated blackhole. |
61 |
}
|
1039.3.1
by Stewart Smith
move bas_ext to StorageEngine instead of handler |
62 |
|
63 |
const char **bas_ext() const { |
|
64 |
return ha_blackhole_exts; |
|
65 |
}
|
|
1039.3.3
by Stewart Smith
Move handler::create to StorageEngine::create_table |
66 |
|
1233.1.6
by Brian Aker
Remove table_flags from MyISAM. |
67 |
int doCreateTable(Session*, |
1222.1.7
by Brian Aker
Remove HA_CREATE_INFO from createTable() |
68 |
const char *, |
69 |
Table&, |
|
70 |
drizzled::message::Table&); |
|
1103.5.2
by Toru Maesaka
Added tests for BLACKHOLE and also code to create and delete a empty file. This is so that the core can track if a table exists or not. This is required for proper implementation of DROP TABLE and otherwise the test suite will reject it |
71 |
|
1233.1.6
by Brian Aker
Remove table_flags from MyISAM. |
72 |
int doDropTable(Session&, const string table_name); |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
73 |
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
74 |
BlackholeShare *findOpenTable(const string table_name); |
75 |
void addOpenTable(const string &table_name, BlackholeShare *); |
|
76 |
void deleteOpenTable(const string &table_name); |
|
77 |
||
1183.1.29
by Brian Aker
Clean up interface so that Truncate sets the propper engine when |
78 |
int doGetTableDefinition(Session& session, |
79 |
const char* path, |
|
1183.5.1
by Brian Aker
Extended definition interface (filename building should now be moved |
80 |
const char *db, |
81 |
const char *table_name, |
|
82 |
const bool is_tmp, |
|
83 |
drizzled::message::Table *table_proto); |
|
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
84 |
|
1183.1.15
by Brian Aker
I_S now provides its own tables via the SE interface |
85 |
void doGetTableNames(CachedDirectory &directory, string&, set<string>& set_of_names) |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
86 |
{
|
87 |
CachedDirectory::Entries entries= directory.getEntries(); |
|
88 |
||
1233.1.9
by Brian Aker
Move max key stuff up to engine. |
89 |
for (CachedDirectory::Entries::iterator entry_iter= entries.begin(); |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
90 |
entry_iter != entries.end(); ++entry_iter) |
91 |
{
|
|
92 |
CachedDirectory::Entry *entry= *entry_iter; |
|
93 |
string *filename= &entry->filename; |
|
94 |
||
95 |
assert(filename->size()); |
|
96 |
||
97 |
const char *ext= strchr(filename->c_str(), '.'); |
|
98 |
||
99 |
if (ext == NULL || my_strcasecmp(system_charset_info, ext, BLACKHOLE_EXT) || |
|
100 |
is_prefix(filename->c_str(), TMP_FILE_PREFIX)) |
|
101 |
{ } |
|
102 |
else
|
|
103 |
{
|
|
104 |
char uname[NAME_LEN + 1]; |
|
105 |
uint32_t file_name_len; |
|
106 |
||
107 |
file_name_len= filename_to_tablename(filename->c_str(), uname, sizeof(uname)); |
|
108 |
// TODO: Remove need for memory copy here
|
|
1233.1.9
by Brian Aker
Move max key stuff up to engine. |
109 |
uname[file_name_len - sizeof(BLACKHOLE_EXT) + 1]= '\0'; // Subtract ending, place NULL |
1183.1.13
by Brian Aker
Fix pass by reference for directory object |
110 |
set_of_names.insert(uname); |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
111 |
}
|
112 |
}
|
|
113 |
}
|
|
1233.1.9
by Brian Aker
Move max key stuff up to engine. |
114 |
|
115 |
/* The following defines can be increased if necessary */
|
|
116 |
uint32_t max_supported_keys() const { return BLACKHOLE_MAX_KEY; } |
|
117 |
uint32_t max_supported_key_length() const { return BLACKHOLE_MAX_KEY_LENGTH; } |
|
118 |
uint32_t max_supported_key_part_length() const { return BLACKHOLE_MAX_KEY_LENGTH; } |
|
1235.1.13
by Brian Aker
Next pass through interface to move index flag bits up to engine. |
119 |
|
120 |
uint32_t index_flags(enum ha_key_alg) const |
|
121 |
{
|
|
122 |
return (HA_READ_NEXT | |
|
123 |
HA_READ_PREV | |
|
124 |
HA_READ_RANGE | |
|
125 |
HA_READ_ORDER | |
|
126 |
HA_KEYREAD_ONLY); |
|
127 |
}
|
|
128 |
||
960.2.29
by Monty Taylor
Updated blackhole. |
129 |
};
|
1
by brian
clean slate |
130 |
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
131 |
|
132 |
BlackholeShare *BlackholeEngine::findOpenTable(const string table_name) |
|
133 |
{
|
|
134 |
BlackholeMap::iterator find_iter= |
|
135 |
blackhole_open_tables.find(table_name); |
|
136 |
||
137 |
if (find_iter != blackhole_open_tables.end()) |
|
138 |
return (*find_iter).second; |
|
139 |
else
|
|
140 |
return NULL; |
|
141 |
}
|
|
142 |
||
143 |
void BlackholeEngine::addOpenTable(const string &table_name, BlackholeShare *share) |
|
144 |
{
|
|
145 |
blackhole_open_tables[table_name]= share; |
|
146 |
}
|
|
147 |
||
148 |
void BlackholeEngine::deleteOpenTable(const string &table_name) |
|
149 |
{
|
|
150 |
blackhole_open_tables.erase(table_name); |
|
151 |
}
|
|
152 |
||
153 |
||
1
by brian
clean slate |
154 |
/* Static declarations for shared structures */
|
155 |
||
156 |
static pthread_mutex_t blackhole_mutex; |
|
157 |
||
158 |
||
159 |
/*****************************************************************************
|
|
160 |
** BLACKHOLE tables
|
|
161 |
*****************************************************************************/
|
|
162 |
||
1208.3.2
by brian
Update for Cursor renaming. |
163 |
ha_blackhole::ha_blackhole(drizzled::plugin::StorageEngine &engine_arg, |
164 |
TableShare &table_arg) |
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
165 |
:Cursor(engine_arg, table_arg), share(NULL) |
1208.3.2
by brian
Update for Cursor renaming. |
166 |
{ } |
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. |
167 |
|
653
by Brian Aker
More solaris bits |
168 |
int ha_blackhole::open(const char *name, int, uint32_t) |
1
by brian
clean slate |
169 |
{
|
170 |
if (!(share= get_share(name))) |
|
51.3.8
by Jay Pipes
Removed DBUG from CSV and Blackhole storage engines |
171 |
return(HA_ERR_OUT_OF_MEM); |
1
by brian
clean slate |
172 |
|
173 |
thr_lock_data_init(&share->lock, &lock, NULL); |
|
51.3.8
by Jay Pipes
Removed DBUG from CSV and Blackhole storage engines |
174 |
return(0); |
1
by brian
clean slate |
175 |
}
|
176 |
||
177 |
int ha_blackhole::close(void) |
|
178 |
{
|
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
179 |
free_share(); |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
180 |
return 0; |
1
by brian
clean slate |
181 |
}
|
182 |
||
1183.1.6
by Brian Aker
Simplify createTable() |
183 |
int BlackholeEngine::doCreateTable(Session*, const char *path, |
1222.1.7
by Brian Aker
Remove HA_CREATE_INFO from createTable() |
184 |
Table&, |
1183.1.18
by Brian Aker
Fixed references to doCreateTable() |
185 |
drizzled::message::Table& proto) |
1
by brian
clean slate |
186 |
{
|
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
187 |
string serialized_proto; |
188 |
string new_path; |
|
189 |
||
190 |
new_path= path; |
|
191 |
new_path+= BLACKHOLE_EXT; |
|
1183.1.19
by Brian Aker
Three cleanups from build test. |
192 |
fstream output(new_path.c_str(), ios::out | ios::binary); |
193 |
||
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
194 |
|
195 |
if (! output) |
|
196 |
return 1; |
|
197 |
||
1183.1.18
by Brian Aker
Fixed references to doCreateTable() |
198 |
if (! proto.SerializeToOstream(&output)) |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
199 |
{
|
200 |
output.close(); |
|
201 |
unlink(new_path.c_str()); |
|
202 |
return 1; |
|
203 |
}
|
|
204 |
||
205 |
return 0; |
|
1103.5.2
by Toru Maesaka
Added tests for BLACKHOLE and also code to create and delete a empty file. This is so that the core can track if a table exists or not. This is required for proper implementation of DROP TABLE and otherwise the test suite will reject it |
206 |
}
|
207 |
||
1183.1.29
by Brian Aker
Clean up interface so that Truncate sets the propper engine when |
208 |
|
209 |
int BlackholeEngine::doDropTable(Session&, const string path) |
|
1103.5.2
by Toru Maesaka
Added tests for BLACKHOLE and also code to create and delete a empty file. This is so that the core can track if a table exists or not. This is required for proper implementation of DROP TABLE and otherwise the test suite will reject it |
210 |
{
|
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
211 |
string new_path(path); |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
212 |
|
213 |
new_path+= BLACKHOLE_EXT; |
|
214 |
||
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
215 |
int error= unlink(new_path.c_str()); |
216 |
||
217 |
if (error != 0) |
|
1103.5.3
by Toru Maesaka
Fix the curly brace in BLACKHOLE to follow the coding standard |
218 |
{
|
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
219 |
error= my_errno= errno; |
1103.5.2
by Toru Maesaka
Added tests for BLACKHOLE and also code to create and delete a empty file. This is so that the core can track if a table exists or not. This is required for proper implementation of DROP TABLE and otherwise the test suite will reject it |
220 |
}
|
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
221 |
|
1213
by Brian Aker
Fixes startup failures when temporary tables were left behind in a crash. |
222 |
return error; |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
223 |
}
|
224 |
||
1183.1.29
by Brian Aker
Clean up interface so that Truncate sets the propper engine when |
225 |
|
226 |
int BlackholeEngine::doGetTableDefinition(Session&, |
|
227 |
const char* path, |
|
1183.5.1
by Brian Aker
Extended definition interface (filename building should now be moved |
228 |
const char *, |
229 |
const char *, |
|
230 |
const bool, |
|
231 |
drizzled::message::Table *table_proto) |
|
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
232 |
{
|
233 |
string new_path; |
|
234 |
||
235 |
new_path= path; |
|
236 |
new_path+= BLACKHOLE_EXT; |
|
237 |
||
238 |
int fd= open(new_path.c_str(), O_RDONLY); |
|
239 |
||
240 |
if (fd == -1) |
|
241 |
{
|
|
1217.1.4
by Brian Aker
Cleanup of return errors from engines (still... a better job could be done). |
242 |
return errno; |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
243 |
}
|
244 |
||
245 |
google::protobuf::io::ZeroCopyInputStream* input= |
|
246 |
new google::protobuf::io::FileInputStream(fd); |
|
247 |
||
248 |
if (! input) |
|
1217.1.4
by Brian Aker
Cleanup of return errors from engines (still... a better job could be done). |
249 |
return HA_ERR_CRASHED_ON_USAGE; |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
250 |
|
251 |
if (table_proto && ! table_proto->ParseFromZeroCopyStream(input)) |
|
252 |
{
|
|
253 |
close(fd); |
|
1183.1.28
by Brian Aker
Memory leak fixed in blackhole |
254 |
delete input; |
1217.1.4
by Brian Aker
Cleanup of return errors from engines (still... a better job could be done). |
255 |
return HA_ERR_CRASHED_ON_USAGE; |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
256 |
}
|
257 |
||
1183.1.28
by Brian Aker
Memory leak fixed in blackhole |
258 |
delete input; |
1183.1.10
by Brian Aker
Update blackhole engine to handle its own dictionary |
259 |
return EEXIST; |
1
by brian
clean slate |
260 |
}
|
261 |
||
653
by Brian Aker
More solaris bits |
262 |
const char *ha_blackhole::index_type(uint32_t) |
1
by brian
clean slate |
263 |
{
|
249
by Brian Aker
Random key cleanup (it is a friday...) |
264 |
return("BTREE"); |
1
by brian
clean slate |
265 |
}
|
266 |
||
653
by Brian Aker
More solaris bits |
267 |
int ha_blackhole::write_row(unsigned char *) |
1
by brian
clean slate |
268 |
{
|
51.3.8
by Jay Pipes
Removed DBUG from CSV and Blackhole storage engines |
269 |
return(table->next_number_field ? update_auto_increment() : 0); |
1
by brian
clean slate |
270 |
}
|
271 |
||
653
by Brian Aker
More solaris bits |
272 |
int ha_blackhole::rnd_init(bool) |
1
by brian
clean slate |
273 |
{
|
51.3.8
by Jay Pipes
Removed DBUG from CSV and Blackhole storage engines |
274 |
return(0); |
1
by brian
clean slate |
275 |
}
|
276 |
||
277 |
||
653
by Brian Aker
More solaris bits |
278 |
int ha_blackhole::rnd_next(unsigned char *) |
1
by brian
clean slate |
279 |
{
|
51.3.8
by Jay Pipes
Removed DBUG from CSV and Blackhole storage engines |
280 |
return(HA_ERR_END_OF_FILE); |
1
by brian
clean slate |
281 |
}
|
282 |
||
283 |
||
653
by Brian Aker
More solaris bits |
284 |
int ha_blackhole::rnd_pos(unsigned char *, unsigned char *) |
1
by brian
clean slate |
285 |
{
|
51.3.8
by Jay Pipes
Removed DBUG from CSV and Blackhole storage engines |
286 |
assert(0); |
287 |
return(0); |
|
1
by brian
clean slate |
288 |
}
|
289 |
||
290 |
||
653
by Brian Aker
More solaris bits |
291 |
void ha_blackhole::position(const unsigned char *) |
1
by brian
clean slate |
292 |
{
|
51.3.8
by Jay Pipes
Removed DBUG from CSV and Blackhole storage engines |
293 |
assert(0); |
294 |
return; |
|
1
by brian
clean slate |
295 |
}
|
296 |
||
297 |
||
482
by Brian Aker
Remove uint. |
298 |
int ha_blackhole::info(uint32_t flag) |
1
by brian
clean slate |
299 |
{
|
212.6.9
by Mats Kindahl
Removing extreneous explicit casts for blackhole storage engine. |
300 |
memset(&stats, 0, sizeof(stats)); |
1
by brian
clean slate |
301 |
if (flag & HA_STATUS_AUTO) |
302 |
stats.auto_increment_value= 1; |
|
51.3.8
by Jay Pipes
Removed DBUG from CSV and Blackhole storage engines |
303 |
return(0); |
1
by brian
clean slate |
304 |
}
|
305 |
||
306 |
||
653
by Brian Aker
More solaris bits |
307 |
int ha_blackhole::index_read_map(unsigned char *, const unsigned char *, |
308 |
key_part_map, enum ha_rkey_function) |
|
309 |
{
|
|
310 |
return(HA_ERR_END_OF_FILE); |
|
311 |
}
|
|
312 |
||
313 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
314 |
int ha_blackhole::index_read_idx_map(unsigned char *, uint32_t, const unsigned char *, |
653
by Brian Aker
More solaris bits |
315 |
key_part_map, enum ha_rkey_function) |
316 |
{
|
|
317 |
return(HA_ERR_END_OF_FILE); |
|
318 |
}
|
|
319 |
||
320 |
||
321 |
int ha_blackhole::index_read_last_map(unsigned char *, const unsigned char *, key_part_map) |
|
322 |
{
|
|
323 |
return(HA_ERR_END_OF_FILE); |
|
324 |
}
|
|
325 |
||
326 |
||
327 |
int ha_blackhole::index_next(unsigned char *) |
|
328 |
{
|
|
329 |
return(HA_ERR_END_OF_FILE); |
|
330 |
}
|
|
331 |
||
332 |
||
333 |
int ha_blackhole::index_prev(unsigned char *) |
|
334 |
{
|
|
335 |
return(HA_ERR_END_OF_FILE); |
|
336 |
}
|
|
337 |
||
338 |
||
339 |
int ha_blackhole::index_first(unsigned char *) |
|
340 |
{
|
|
341 |
return(HA_ERR_END_OF_FILE); |
|
342 |
}
|
|
343 |
||
344 |
||
345 |
int ha_blackhole::index_last(unsigned char *) |
|
1
by brian
clean slate |
346 |
{
|
51.3.8
by Jay Pipes
Removed DBUG from CSV and Blackhole storage engines |
347 |
return(HA_ERR_END_OF_FILE); |
1
by brian
clean slate |
348 |
}
|
349 |
||
350 |
||
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
351 |
BlackholeShare *ha_blackhole::get_share(const char *table_name) |
1
by brian
clean slate |
352 |
{
|
353 |
pthread_mutex_lock(&blackhole_mutex); |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
354 |
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
355 |
BlackholeEngine *a_engine= static_cast<BlackholeEngine *>(engine); |
356 |
share= a_engine->findOpenTable(table_name); |
|
357 |
||
358 |
if (share == NULL) |
|
1
by brian
clean slate |
359 |
{
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
360 |
share= new (nothrow) BlackholeShare(table_name); |
361 |
if (share == NULL) |
|
1
by brian
clean slate |
362 |
{
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
363 |
pthread_mutex_unlock(&blackhole_mutex); |
364 |
return NULL; |
|
1
by brian
clean slate |
365 |
}
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
366 |
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
367 |
a_engine->addOpenTable(share->table_name, share); |
1
by brian
clean slate |
368 |
}
|
369 |
share->use_count++; |
|
370 |
pthread_mutex_unlock(&blackhole_mutex); |
|
371 |
return share; |
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
372 |
|
1
by brian
clean slate |
373 |
}
|
374 |
||
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
375 |
void ha_blackhole::free_share() |
1
by brian
clean slate |
376 |
{
|
377 |
pthread_mutex_lock(&blackhole_mutex); |
|
378 |
if (!--share->use_count) |
|
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
379 |
{
|
380 |
BlackholeEngine *a_engine= static_cast<BlackholeEngine *>(engine); |
|
381 |
a_engine->deleteOpenTable(share->table_name); |
|
382 |
delete share; |
|
383 |
}
|
|
1
by brian
clean slate |
384 |
pthread_mutex_unlock(&blackhole_mutex); |
385 |
}
|
|
386 |
||
1240.2.3
by Monty Taylor
Fixed blackhole crashses on Spare - made Blackhole follow the pattern of CSV and Archive. |
387 |
BlackholeShare::BlackholeShare(const string table_name_arg) |
388 |
: use_count(0), table_name(table_name_arg) |
|
389 |
{
|
|
390 |
thr_lock_init(&lock); |
|
391 |
}
|
|
392 |
||
393 |
BlackholeShare::~BlackholeShare() |
|
394 |
{
|
|
395 |
thr_lock_delete(&lock); |
|
396 |
}
|
|
397 |
||
1
by brian
clean slate |
398 |
|
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
399 |
static drizzled::plugin::StorageEngine *blackhole_engine= NULL; |
971.1.51
by Monty Taylor
New-style plugin registration now works. |
400 |
|
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
401 |
static int blackhole_init(drizzled::plugin::Registry ®istry) |
1
by brian
clean slate |
402 |
{
|
971.1.51
by Monty Taylor
New-style plugin registration now works. |
403 |
|
1192.5.9
by Monty Taylor
Made blackhole dynamic |
404 |
blackhole_engine= new BlackholeEngine("BLACKHOLE"); |
1130.1.8
by Monty Taylor
Added polymorphic add/remove methods around slot add/remove methods. |
405 |
registry.add(blackhole_engine); |
971.1.51
by Monty Taylor
New-style plugin registration now works. |
406 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
407 |
pthread_mutex_init(&blackhole_mutex, MY_MUTEX_INIT_FAST); |
1
by brian
clean slate |
408 |
|
409 |
return 0; |
|
410 |
}
|
|
411 |
||
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
412 |
static int blackhole_fini(drizzled::plugin::Registry ®istry) |
1
by brian
clean slate |
413 |
{
|
1130.1.8
by Monty Taylor
Added polymorphic add/remove methods around slot add/remove methods. |
414 |
registry.remove(blackhole_engine); |
960.2.29
by Monty Taylor
Updated blackhole. |
415 |
delete blackhole_engine; |
416 |
||
1
by brian
clean slate |
417 |
pthread_mutex_destroy(&blackhole_mutex); |
418 |
||
419 |
return 0; |
|
420 |
}
|
|
421 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
422 |
DRIZZLE_DECLARE_PLUGIN
|
1
by brian
clean slate |
423 |
{
|
424 |
"BLACKHOLE", |
|
177.4.3
by mark
ripped out more plugin ABI and API version checking, and plugin versions are now strings |
425 |
"1.0", |
1
by brian
clean slate |
426 |
"MySQL AB", |
427 |
"/dev/null storage engine (anything you write to it disappears)", |
|
428 |
PLUGIN_LICENSE_GPL, |
|
1103.5.1
by Toru Maesaka
Updated Blackhole to work with the current SE interface |
429 |
blackhole_init, /* Plugin Init */ |
430 |
blackhole_fini, /* Plugin Deinit */ |
|
431 |
NULL, /* status variables */ |
|
432 |
NULL, /* system variables */ |
|
433 |
NULL /* config options */ |
|
1
by brian
clean slate |
434 |
}
|
1228.1.5
by Monty Taylor
Merged in some naming things. |
435 |
DRIZZLE_DECLARE_PLUGIN_END; |