1 | /* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
15 | |
16 | #ifdef USE_PRAGMA_INTERFACE |
17 | #pragma interface /* gcc class implementation */ |
18 | #endif |
19 | |
20 | #include "thr_lock.h" /* THR_LOCK */ |
21 | #include "handler.h" /* handler */ |
22 | #include "table.h" /* TABLE_SHARE */ |
23 | |
24 | /* |
25 | Shared structure for correct LOCK operation |
26 | */ |
27 | struct st_blackhole_share { |
28 | THR_LOCK lock; |
29 | uint use_count; |
30 | uint table_name_length; |
31 | char table_name[1]; |
32 | }; |
33 | |
34 | |
35 | /* |
36 | Class definition for the blackhole storage engine |
37 | "Dumbest named feature ever" |
38 | */ |
39 | class ha_blackhole: public handler |
40 | { |
41 | THR_LOCK_DATA lock; /* MySQL lock */ |
42 | st_blackhole_share *share; |
43 | |
44 | public: |
45 | ha_blackhole(handlerton *hton, TABLE_SHARE *table_arg); |
46 | ~ha_blackhole() |
47 | { |
48 | } |
49 | /* |
50 | The name of the index type that will be used for display |
51 | don't implement this method unless you really have indexes |
52 | */ |
53 | const char *index_type(uint key_number); |
54 | ulonglong table_flags() const |
55 | { |
56 | return(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | |
57 | HA_BINLOG_STMT_CAPABLE | HA_BINLOG_ROW_CAPABLE | |
58 | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY | |
59 | HA_FILE_BASED | HA_CAN_GEOMETRY | HA_CAN_INSERT_DELAYED); |
60 | } |
61 | ulong index_flags(uint inx, uint part, bool all_parts) const |
62 | { |
63 | return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ? |
64 | 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | |
65 | HA_READ_ORDER | HA_KEYREAD_ONLY); |
66 | } |
67 | /* The following defines can be increased if necessary */ |
68 | #define BLACKHOLE_MAX_KEY 64 /* Max allowed keys */ |
69 | #define BLACKHOLE_MAX_KEY_SEG 16 /* Max segments for key */ |
70 | #define BLACKHOLE_MAX_KEY_LENGTH 1000 |
71 | uint max_supported_keys() const { return BLACKHOLE_MAX_KEY; } |
72 | uint max_supported_key_length() const { return BLACKHOLE_MAX_KEY_LENGTH; } |
73 | uint max_supported_key_part_length() const { return BLACKHOLE_MAX_KEY_LENGTH; } |
74 | int open(const char *name, int mode, uint test_if_locked); |
75 | int close(void); |
76 | int truncate(); |
77 | int rnd_init(bool scan); |
78 | int rnd_next(uchar *buf); |
79 | int rnd_pos(uchar * buf, uchar *pos); |
80 | int index_read_map(uchar * buf, const uchar * key, key_part_map keypart_map, |
81 | enum ha_rkey_function find_flag); |
82 | int index_read_idx_map(uchar * buf, uint idx, const uchar * key, |
83 | key_part_map keypart_map, |
84 | enum ha_rkey_function find_flag); |
85 | int index_read_last_map(uchar * buf, const uchar * key, key_part_map keypart_map); |
86 | int index_next(uchar * buf); |
87 | int index_prev(uchar * buf); |
88 | int index_first(uchar * buf); |
89 | int index_last(uchar * buf); |
90 | void position(const uchar *record); |
91 | int info(uint flag); |
92 | int external_lock(THD *thd, int lock_type); |
93 | int create(const char *name, TABLE *table_arg, |
94 | HA_CREATE_INFO *create_info); |
95 | THR_LOCK_DATA **store_lock(THD *thd, |
96 | THR_LOCK_DATA **to, |
97 | enum thr_lock_type lock_type); |
98 | private: |
99 | virtual int write_row(uchar *buf); |
100 | virtual int update_row(const uchar *old_data, const uchar *new_data); |
101 | virtual int delete_row(const uchar *buf); |
102 | }; |
103 | |