00001 /* Copyright (C) 2005 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 00018 #ifdef USE_PRAGMA_IMPLEMENTATION 00019 #pragma implementation // gcc: Class implementation 00020 #endif 00021 00022 #include "mysql_priv.h" 00023 #include "ha_blackhole.h" 00024 00025 /* Static declarations for handlerton */ 00026 00027 handlerton blackhole_hton; 00028 static handler *blackhole_create_handler(TABLE_SHARE *table, 00029 MEM_ROOT *mem_root) 00030 { 00031 return new (mem_root) ha_blackhole(table); 00032 } 00033 00034 00035 /***************************************************************************** 00036 ** BLACKHOLE tables 00037 *****************************************************************************/ 00038 00039 ha_blackhole::ha_blackhole(TABLE_SHARE *table_arg) 00040 :handler(&blackhole_hton, table_arg) 00041 {} 00042 00043 00044 static const char *ha_blackhole_exts[] = { 00045 NullS 00046 }; 00047 00048 const char **ha_blackhole::bas_ext() const 00049 { 00050 return ha_blackhole_exts; 00051 } 00052 00053 int ha_blackhole::open(const char *name, int mode, uint test_if_locked) 00054 { 00055 DBUG_ENTER("ha_blackhole::open"); 00056 thr_lock_init(&thr_lock); 00057 thr_lock_data_init(&thr_lock,&lock,NULL); 00058 DBUG_RETURN(0); 00059 } 00060 00061 int ha_blackhole::close(void) 00062 { 00063 DBUG_ENTER("ha_blackhole::close"); 00064 thr_lock_delete(&thr_lock); 00065 DBUG_RETURN(0); 00066 } 00067 00068 int ha_blackhole::create(const char *name, TABLE *table_arg, 00069 HA_CREATE_INFO *create_info) 00070 { 00071 DBUG_ENTER("ha_blackhole::create"); 00072 DBUG_RETURN(0); 00073 } 00074 00075 const char *ha_blackhole::index_type(uint key_number) 00076 { 00077 DBUG_ENTER("ha_blackhole::index_type"); 00078 DBUG_RETURN((table_share->key_info[key_number].flags & HA_FULLTEXT) ? 00079 "FULLTEXT" : 00080 (table_share->key_info[key_number].flags & HA_SPATIAL) ? 00081 "SPATIAL" : 00082 (table_share->key_info[key_number].algorithm == 00083 HA_KEY_ALG_RTREE) ? "RTREE" : "BTREE"); 00084 } 00085 00086 int ha_blackhole::write_row(byte * buf) 00087 { 00088 DBUG_ENTER("ha_blackhole::write_row"); 00089 DBUG_RETURN(0); 00090 } 00091 00092 int ha_blackhole::rnd_init(bool scan) 00093 { 00094 DBUG_ENTER("ha_blackhole::rnd_init"); 00095 DBUG_RETURN(0); 00096 } 00097 00098 00099 int ha_blackhole::rnd_next(byte *buf) 00100 { 00101 DBUG_ENTER("ha_blackhole::rnd_next"); 00102 DBUG_RETURN(HA_ERR_END_OF_FILE); 00103 } 00104 00105 00106 int ha_blackhole::rnd_pos(byte * buf, byte *pos) 00107 { 00108 DBUG_ENTER("ha_blackhole::rnd_pos"); 00109 DBUG_ASSERT(0); 00110 DBUG_RETURN(0); 00111 } 00112 00113 00114 void ha_blackhole::position(const byte *record) 00115 { 00116 DBUG_ENTER("ha_blackhole::position"); 00117 DBUG_ASSERT(0); 00118 DBUG_VOID_RETURN; 00119 } 00120 00121 00122 void ha_blackhole::info(uint flag) 00123 { 00124 DBUG_ENTER("ha_blackhole::info"); 00125 00126 bzero((char*) &stats, sizeof(stats)); 00127 if (flag & HA_STATUS_AUTO) 00128 stats.auto_increment_value= 1; 00129 DBUG_VOID_RETURN; 00130 } 00131 00132 int ha_blackhole::external_lock(THD *thd, int lock_type) 00133 { 00134 DBUG_ENTER("ha_blackhole::external_lock"); 00135 DBUG_RETURN(0); 00136 } 00137 00138 00139 uint ha_blackhole::lock_count(void) const 00140 { 00141 DBUG_ENTER("ha_blackhole::lock_count"); 00142 DBUG_RETURN(0); 00143 } 00144 00145 THR_LOCK_DATA **ha_blackhole::store_lock(THD *thd, 00146 THR_LOCK_DATA **to, 00147 enum thr_lock_type lock_type) 00148 { 00149 DBUG_ENTER("ha_blackhole::store_lock"); 00150 DBUG_RETURN(to); 00151 } 00152 00153 00154 int ha_blackhole::index_read(byte * buf, const byte * key, 00155 uint key_len, enum ha_rkey_function find_flag) 00156 { 00157 DBUG_ENTER("ha_blackhole::index_read"); 00158 DBUG_RETURN(0); 00159 } 00160 00161 00162 int ha_blackhole::index_read_idx(byte * buf, uint idx, const byte * key, 00163 uint key_len, enum ha_rkey_function find_flag) 00164 { 00165 DBUG_ENTER("ha_blackhole::index_read_idx"); 00166 DBUG_RETURN(HA_ERR_END_OF_FILE); 00167 } 00168 00169 00170 int ha_blackhole::index_read_last(byte * buf, const byte * key, uint key_len) 00171 { 00172 DBUG_ENTER("ha_blackhole::index_read_last"); 00173 DBUG_RETURN(HA_ERR_END_OF_FILE); 00174 } 00175 00176 00177 int ha_blackhole::index_next(byte * buf) 00178 { 00179 DBUG_ENTER("ha_blackhole::index_next"); 00180 DBUG_RETURN(HA_ERR_END_OF_FILE); 00181 } 00182 00183 00184 int ha_blackhole::index_prev(byte * buf) 00185 { 00186 DBUG_ENTER("ha_blackhole::index_prev"); 00187 DBUG_RETURN(HA_ERR_END_OF_FILE); 00188 } 00189 00190 00191 int ha_blackhole::index_first(byte * buf) 00192 { 00193 DBUG_ENTER("ha_blackhole::index_first"); 00194 DBUG_RETURN(HA_ERR_END_OF_FILE); 00195 } 00196 00197 00198 int ha_blackhole::index_last(byte * buf) 00199 { 00200 DBUG_ENTER("ha_blackhole::index_last"); 00201 DBUG_RETURN(HA_ERR_END_OF_FILE); 00202 } 00203 00204 static int blackhole_init() 00205 { 00206 blackhole_hton.state= SHOW_OPTION_YES; 00207 blackhole_hton.db_type= DB_TYPE_BLACKHOLE_DB; 00208 blackhole_hton.create= blackhole_create_handler; 00209 blackhole_hton.flags= HTON_CAN_RECREATE; 00210 return 0; 00211 } 00212 00213 struct st_mysql_storage_engine blackhole_storage_engine= 00214 { MYSQL_HANDLERTON_INTERFACE_VERSION, &blackhole_hton }; 00215 00216 mysql_declare_plugin(blackhole) 00217 { 00218 MYSQL_STORAGE_ENGINE_PLUGIN, 00219 &blackhole_storage_engine, 00220 "BLACKHOLE", 00221 "MySQL AB", 00222 "/dev/null storage engine (anything you write to it disappears)", 00223 blackhole_init, /* Plugin Init */ 00224 NULL, /* Plugin Deinit */ 00225 0x0100 /* 1.0 */, 00226 0 00227 } 00228 mysql_declare_plugin_end;
1.4.7

