diff options
Diffstat (limited to 'storage/blackhole')
-rw-r--r-- | storage/blackhole/CMakeLists.txt | 7 | ||||
-rw-r--r-- | storage/blackhole/Makefile.am | 52 | ||||
-rw-r--r-- | storage/blackhole/ha_blackhole.cc | 234 | ||||
-rw-r--r-- | storage/blackhole/ha_blackhole.h | 86 | ||||
-rw-r--r-- | storage/blackhole/plug.in | 6 |
5 files changed, 385 insertions, 0 deletions
diff --git a/storage/blackhole/CMakeLists.txt b/storage/blackhole/CMakeLists.txt new file mode 100644 index 00000000000..a90f8e14ca0 --- /dev/null +++ b/storage/blackhole/CMakeLists.txt @@ -0,0 +1,7 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql + ${CMAKE_SOURCE_DIR}/regex + ${CMAKE_SOURCE_DIR}/extra/yassl/include) +ADD_LIBRARY(blackhole ha_blackhole.cc ha_blackhole.h) diff --git a/storage/blackhole/Makefile.am b/storage/blackhole/Makefile.am new file mode 100644 index 00000000000..36a885c4a26 --- /dev/null +++ b/storage/blackhole/Makefile.am @@ -0,0 +1,52 @@ +# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#called from the top level Makefile + +MYSQLDATAdir = $(localstatedir) +MYSQLSHAREdir = $(pkgdatadir) +MYSQLBASEdir= $(prefix) +MYSQLLIBdir= $(pkglibdir) +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \ + -I$(top_srcdir)/regex \ + -I$(top_srcdir)/sql \ + -I$(srcdir) +WRAPLIBS= + +LDADD = + +DEFS = @DEFS@ + +noinst_HEADERS = ha_blackhole.h + +EXTRA_LTLIBRARIES = ha_blackhole.la +pkglib_LTLIBRARIES = @plugin_blackhole_shared_target@ +ha_blackhole_la_LDFLAGS=-module -rpath $(MYSQLLIBdir) +ha_blackhole_la_CXXFLAGS=$(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_blackhole_la_CFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +ha_blackhole_la_SOURCES=ha_blackhole.cc + + +EXTRA_LIBRARIES = libblackhole.a +noinst_LIBRARIES = @plugin_blackhole_static_target@ +libblackhole_a_CXXFLAGS=$(AM_CFLAGS) +libblackhole_a_CFLAGS = $(AM_CFLAGS) +libblackhole_a_SOURCES= ha_blackhole.cc + + +EXTRA_DIST = CMakeLists.txt plug.in +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc new file mode 100644 index 00000000000..64e716584a7 --- /dev/null +++ b/storage/blackhole/ha_blackhole.cc @@ -0,0 +1,234 @@ +/* Copyright (C) 2005 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + +#ifdef USE_PRAGMA_IMPLEMENTATION +#pragma implementation // gcc: Class implementation +#endif + +#include "mysql_priv.h" +#include "ha_blackhole.h" + +/* Static declarations for handlerton */ + +static handler *blackhole_create_handler(handlerton *hton, + TABLE_SHARE *table, + MEM_ROOT *mem_root) +{ + return new (mem_root) ha_blackhole(hton, table); +} + + +/***************************************************************************** +** BLACKHOLE tables +*****************************************************************************/ + +ha_blackhole::ha_blackhole(handlerton *hton, + TABLE_SHARE *table_arg) + :handler(hton, table_arg) +{} + + +static const char *ha_blackhole_exts[] = { + NullS +}; + +const char **ha_blackhole::bas_ext() const +{ + return ha_blackhole_exts; +} + +int ha_blackhole::open(const char *name, int mode, uint test_if_locked) +{ + DBUG_ENTER("ha_blackhole::open"); + thr_lock_init(&thr_lock); + thr_lock_data_init(&thr_lock,&lock,NULL); + DBUG_RETURN(0); +} + +int ha_blackhole::close(void) +{ + DBUG_ENTER("ha_blackhole::close"); + thr_lock_delete(&thr_lock); + DBUG_RETURN(0); +} + +int ha_blackhole::create(const char *name, TABLE *table_arg, + HA_CREATE_INFO *create_info) +{ + DBUG_ENTER("ha_blackhole::create"); + DBUG_RETURN(0); +} + +const char *ha_blackhole::index_type(uint key_number) +{ + DBUG_ENTER("ha_blackhole::index_type"); + DBUG_RETURN((table_share->key_info[key_number].flags & HA_FULLTEXT) ? + "FULLTEXT" : + (table_share->key_info[key_number].flags & HA_SPATIAL) ? + "SPATIAL" : + (table_share->key_info[key_number].algorithm == + HA_KEY_ALG_RTREE) ? "RTREE" : "BTREE"); +} + +int ha_blackhole::write_row(byte * buf) +{ + DBUG_ENTER("ha_blackhole::write_row"); + DBUG_RETURN(0); +} + +int ha_blackhole::rnd_init(bool scan) +{ + DBUG_ENTER("ha_blackhole::rnd_init"); + DBUG_RETURN(0); +} + + +int ha_blackhole::rnd_next(byte *buf) +{ + DBUG_ENTER("ha_blackhole::rnd_next"); + DBUG_RETURN(HA_ERR_END_OF_FILE); +} + + +int ha_blackhole::rnd_pos(byte * buf, byte *pos) +{ + DBUG_ENTER("ha_blackhole::rnd_pos"); + DBUG_ASSERT(0); + DBUG_RETURN(0); +} + + +void ha_blackhole::position(const byte *record) +{ + DBUG_ENTER("ha_blackhole::position"); + DBUG_ASSERT(0); + DBUG_VOID_RETURN; +} + + +int ha_blackhole::info(uint flag) +{ + DBUG_ENTER("ha_blackhole::info"); + + bzero((char*) &stats, sizeof(stats)); + if (flag & HA_STATUS_AUTO) + stats.auto_increment_value= 1; + DBUG_RETURN(0); +} + +int ha_blackhole::external_lock(THD *thd, int lock_type) +{ + DBUG_ENTER("ha_blackhole::external_lock"); + DBUG_RETURN(0); +} + + +uint ha_blackhole::lock_count(void) const +{ + DBUG_ENTER("ha_blackhole::lock_count"); + DBUG_RETURN(0); +} + +THR_LOCK_DATA **ha_blackhole::store_lock(THD *thd, + THR_LOCK_DATA **to, + enum thr_lock_type lock_type) +{ + DBUG_ENTER("ha_blackhole::store_lock"); + DBUG_RETURN(to); +} + + +int ha_blackhole::index_read(byte * buf, const byte * key, + uint key_len, enum ha_rkey_function find_flag) +{ + DBUG_ENTER("ha_blackhole::index_read"); + DBUG_RETURN(0); +} + + +int ha_blackhole::index_read_idx(byte * buf, uint idx, const byte * key, + uint key_len, enum ha_rkey_function find_flag) +{ + DBUG_ENTER("ha_blackhole::index_read_idx"); + DBUG_RETURN(HA_ERR_END_OF_FILE); +} + + +int ha_blackhole::index_read_last(byte * buf, const byte * key, uint key_len) +{ + DBUG_ENTER("ha_blackhole::index_read_last"); + DBUG_RETURN(HA_ERR_END_OF_FILE); +} + + +int ha_blackhole::index_next(byte * buf) +{ + DBUG_ENTER("ha_blackhole::index_next"); + DBUG_RETURN(HA_ERR_END_OF_FILE); +} + + +int ha_blackhole::index_prev(byte * buf) +{ + DBUG_ENTER("ha_blackhole::index_prev"); + DBUG_RETURN(HA_ERR_END_OF_FILE); +} + + +int ha_blackhole::index_first(byte * buf) +{ + DBUG_ENTER("ha_blackhole::index_first"); + DBUG_RETURN(HA_ERR_END_OF_FILE); +} + + +int ha_blackhole::index_last(byte * buf) +{ + DBUG_ENTER("ha_blackhole::index_last"); + DBUG_RETURN(HA_ERR_END_OF_FILE); +} + +static int blackhole_init(void *p) +{ + handlerton *blackhole_hton; + blackhole_hton= (handlerton *)p; + blackhole_hton->state= SHOW_OPTION_YES; + blackhole_hton->db_type= DB_TYPE_BLACKHOLE_DB; + blackhole_hton->create= blackhole_create_handler; + blackhole_hton->flags= HTON_CAN_RECREATE; + return 0; +} + +struct st_mysql_storage_engine blackhole_storage_engine= +{ MYSQL_HANDLERTON_INTERFACE_VERSION }; + +mysql_declare_plugin(blackhole) +{ + MYSQL_STORAGE_ENGINE_PLUGIN, + &blackhole_storage_engine, + "BLACKHOLE", + "MySQL AB", + "/dev/null storage engine (anything you write to it disappears)", + PLUGIN_LICENSE_GPL, + blackhole_init, /* Plugin Init */ + NULL, /* Plugin Deinit */ + 0x0100 /* 1.0 */, + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ +} +mysql_declare_plugin_end; diff --git a/storage/blackhole/ha_blackhole.h b/storage/blackhole/ha_blackhole.h new file mode 100644 index 00000000000..667c18a594b --- /dev/null +++ b/storage/blackhole/ha_blackhole.h @@ -0,0 +1,86 @@ +/* Copyright (C) 2005 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifdef USE_PRAGMA_INTERFACE +#pragma interface /* gcc class implementation */ +#endif + +/* + Class definition for the blackhole storage engine + "Dumbest named feature ever" +*/ +class ha_blackhole: public handler +{ + THR_LOCK_DATA lock; /* MySQL lock */ + THR_LOCK thr_lock; + +public: + ha_blackhole(handlerton *hton, TABLE_SHARE *table_arg); + ~ha_blackhole() + { + } + /* The name that will be used for display purposes */ + const char *table_type() const { return "BLACKHOLE"; } + /* + The name of the index type that will be used for display + don't implement this method unless you really have indexes + */ + const char *index_type(uint key_number); + const char **bas_ext() const; + ulonglong table_flags() const + { + return(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | + HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY | + HA_FILE_BASED | HA_CAN_GEOMETRY | HA_CAN_INSERT_DELAYED); + } + ulong index_flags(uint inx, uint part, bool all_parts) const + { + return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ? + 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | + HA_READ_ORDER | HA_KEYREAD_ONLY); + } + /* The following defines can be increased if necessary */ +#define BLACKHOLE_MAX_KEY 64 /* Max allowed keys */ +#define BLACKHOLE_MAX_KEY_SEG 16 /* Max segments for key */ +#define BLACKHOLE_MAX_KEY_LENGTH 1000 + uint max_supported_keys() const { return BLACKHOLE_MAX_KEY; } + uint max_supported_key_length() const { return BLACKHOLE_MAX_KEY_LENGTH; } + uint max_supported_key_part_length() const { return BLACKHOLE_MAX_KEY_LENGTH; } + int open(const char *name, int mode, uint test_if_locked); + int close(void); + int write_row(byte * buf); + int rnd_init(bool scan); + int rnd_next(byte *buf); + int rnd_pos(byte * buf, byte *pos); + int index_read(byte * buf, const byte * key, + uint key_len, enum ha_rkey_function find_flag); + int index_read_idx(byte * buf, uint idx, const byte * key, + uint key_len, enum ha_rkey_function find_flag); + int index_read_last(byte * buf, const byte * key, uint key_len); + int index_next(byte * buf); + int index_prev(byte * buf); + int index_first(byte * buf); + int index_last(byte * buf); + void position(const byte *record); + int info(uint flag); + int external_lock(THD *thd, int lock_type); + uint lock_count(void) const; + int create(const char *name, TABLE *table_arg, + HA_CREATE_INFO *create_info); + THR_LOCK_DATA **store_lock(THD *thd, + THR_LOCK_DATA **to, + enum thr_lock_type lock_type); +}; diff --git a/storage/blackhole/plug.in b/storage/blackhole/plug.in new file mode 100644 index 00000000000..725db0facba --- /dev/null +++ b/storage/blackhole/plug.in @@ -0,0 +1,6 @@ +MYSQL_STORAGE_ENGINE(blackhole,,[Blackhole Storage Engine], + [Basic Write-only Read-never tables], [max,max-no-ndb]) +MYSQL_PLUGIN_DIRECTORY(blackhole, [storage/blackhole]) +MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.a]) +MYSQL_PLUGIN_DYNAMIC(blackhole, [ha_blackhole.la]) + |