Commit 467cad0b authored by brian@avenger.(none)'s avatar brian@avenger.(none)

First commit of archive example. Archive is a simple storage engine that...

First commit of archive example. Archive is a simple storage engine that handles inserts and selects. 
parent 886ef75c
......@@ -24,6 +24,7 @@ bell@laptop.sanja.is.com.ua
bell@sanja.is.com.ua
bk@admin.bk
bk@mysql.r18.ru
brian@avenger.(none)
brian@brian-akers-computer.local
carsten@tsort.bitbybit.dk
davida@isil.mysql.com
......
......@@ -115,6 +115,9 @@
/* Builds Example DB */
#undef HAVE_EXAMPLE_DB
/* Builds Archive Storage Engine */
#undef HAVE_ARCHIVE_DB
/* fp_except from ieeefp.h */
#undef HAVE_FP_EXCEPT
......
......@@ -1332,6 +1332,36 @@ dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_EXAMPLE SECTION
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_ARCHIVEDB
dnl Sets HAVE_ARCHIVE_DB if --with-archive-storage-engine is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_ARCHIVEDB], [
AC_ARG_WITH([archive-storage-engine],
[
--with-archive-storage-engine
Enable the Archive Storge Engine],
[archivedb="$withval"],
[archivedb=no])
AC_MSG_CHECKING([for archive storage engine])
case "$archivedb" in
yes )
AC_DEFINE(HAVE_ARCHIVE_DB)
AC_MSG_RESULT([yes])
[archivedb=yes]
;;
* )
AC_MSG_RESULT([no])
[archivedb=no]
;;
esac
])
dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_ARCHIVE SECTION
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_NDBCLUSTER
dnl Sets HAVE_NDBCLUSTER_DB if --with-ndbcluster is used
......
......@@ -2619,6 +2619,7 @@ MYSQL_CHECK_ISAM
MYSQL_CHECK_BDB
MYSQL_CHECK_INNODB
MYSQL_CHECK_EXAMPLEDB
MYSQL_CHECK_ARCHIVEDB
MYSQL_CHECK_NDBCLUSTER
# If we have threads generate some library functions and test programs
......
......@@ -58,7 +58,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
log_event.h sql_repl.h slave.h \
stacktrace.h sql_sort.h sql_cache.h set_var.h \
spatial.h gstream.h client_settings.h \
examples/ha_example.h
examples/ha_example.h examples/ha_archive.h
mysqld_SOURCES = sql_lex.cc sql_handler.cc \
item.cc item_sum.cc item_buff.cc item_func.cc \
item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
......@@ -88,7 +88,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
client.c sql_client.cc mini_client_errors.c pack.c\
stacktrace.c repl_failsafe.h repl_failsafe.cc sql_olap.cc\
gstream.cc spatial.cc sql_help.cc protocol_cursor.cc \
examples/ha_example.cc
examples/ha_example.cc examples/ha_archive.cc
gen_lex_hash_SOURCES = gen_lex_hash.cc
gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
......
This diff is collapsed.
/* Copyright (C) 2003 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 */
#include <zlib.h>
/*
Please read ha_archive.cc first. If you are looking for more general
answers on how storage engines work, look at ha_example.cc and
ha_example.h.
*/
typedef struct st_archive_share {
char *table_name;
char data_file_name[FN_REFLEN];
uint table_name_length,use_count;
pthread_mutex_t mutex;
THR_LOCK lock;
gzFile archive_write; /* Archive file we are working with */
bool dirty; /* Flag for if a flush should occur */
} ARCHIVE_SHARE;
/*
Version for file format.
1 - Initial Version
*/
#define ARCHIVE_VERSION 1
class ha_archive: public handler
{
THR_LOCK_DATA lock; /* MySQL lock */
ARCHIVE_SHARE *share; /* Shared lock info */
gzFile archive; /* Archive file we are working with */
z_off_t current_position; /* The position of the row we just read */
byte byte_buffer[IO_SIZE]; /* Initial buffer for our string */
String buffer; /* Buffer used for blob storage */
unsigned int version; /* Used for recording version */
public:
ha_archive(TABLE *table): handler(table)
{
/* Set our original buffer from pre-allocated memory */
buffer.set(byte_buffer, IO_SIZE, system_charset_info);
/* The size of the offset value we will use for position() */
ref_length = sizeof(z_off_t);
}
~ha_archive()
{
}
const char *table_type() const { return "ARCHIVE"; }
const char *index_type(uint inx) { return "NONE"; }
const char **bas_ext() const;
ulong table_flags() const
{
return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT | HA_NO_WRITE_DELAYED |
HA_NO_AUTO_INCREMENT );
}
ulong index_flags(uint inx) const
{
return 0;
}
/*
This is just a default, there is no real limit as far as
archive is concerned.
*/
uint max_record_length() const { return HA_MAX_REC_LENGTH; }
uint max_keys() const { return 0; }
uint max_key_parts() const { return 0; }
uint max_key_length() const { return 0; }
/*
Called in test_quick_select to determine if indexes should be used.
*/
virtual double scan_time() { return (double) (records+deleted) / 20.0+10; }
/* The next method will never be called */
virtual double read_time(ha_rows rows) { return (double) rows / 20.0+1; }
virtual bool fast_key_read() { return 1;}
int open(const char *name, int mode, uint test_if_locked);
int close(void);
int write_row(byte * buf);
int update_row(const byte * old_data, byte * new_data);
int delete_row(const byte * buf);
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_next(byte * buf);
int index_prev(byte * buf);
int index_first(byte * buf);
int index_last(byte * buf);
int rnd_init(bool scan=1);
int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos);
int ha_archive::read_row(byte *buf);
void position(const byte *record);
void info(uint);
int extra(enum ha_extra_function operation);
int reset(void);
int external_lock(THD *thd, int lock_type);
ha_rows records_in_range(int inx, const byte *start_key,uint start_key_len,
enum ha_rkey_function start_search_flag,
const byte *end_key,uint end_key_len,
enum ha_rkey_function end_search_flag);
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type);
};
......@@ -35,6 +35,9 @@
#ifdef HAVE_EXAMPLE_DB
#include "examples/ha_example.h"
#endif
#ifdef HAVE_ARCHIVE_DB
#include "examples/ha_archive.h"
#endif
#ifdef HAVE_INNOBASE_DB
#include "ha_innodb.h"
#else
......@@ -81,6 +84,8 @@ struct show_table_type_st sys_table_types[]=
"Alias for BDB", DB_TYPE_BERKELEY_DB},
{"EXAMPLE",&have_example_db,
"Example storage engine", DB_TYPE_EXAMPLE_DB},
{"ARCHIVE",&have_archive_db,
"Archive storage engine", DB_TYPE_ARCHIVE_DB},
{NullS, NULL, NullS, DB_TYPE_UNKNOWN}
};
......@@ -180,6 +185,10 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
#ifdef HAVE_EXAMPLE_DB
case DB_TYPE_EXAMPLE_DB:
return new ha_example(table);
#endif
#ifdef HAVE_ARCHIVE_DB
case DB_TYPE_ARCHIVE_DB:
return new ha_archive(table);
#endif
case DB_TYPE_HEAP:
return new ha_heap(table);
......
......@@ -146,7 +146,7 @@ enum db_type { DB_TYPE_UNKNOWN=0,DB_TYPE_DIAB_ISAM=1,
DB_TYPE_RMS_ISAM, DB_TYPE_HEAP, DB_TYPE_ISAM,
DB_TYPE_MRG_ISAM, DB_TYPE_MYISAM, DB_TYPE_MRG_MYISAM,
DB_TYPE_BERKELEY_DB, DB_TYPE_INNODB, DB_TYPE_GEMINI,
DB_TYPE_EXAMPLE_DB, DB_TYPE_DEFAULT };
DB_TYPE_EXAMPLE_DB, DB_TYPE_ARCHIVE_DB, DB_TYPE_DEFAULT };
struct show_table_type_st {
const char *type;
......
......@@ -908,7 +908,8 @@ extern struct my_option my_long_options[];
/* optional things, have_* variables */
extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db, have_example_db;
extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db;
extern SHOW_COMP_OPTION have_example_db, have_archive_db;
extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink;
extern SHOW_COMP_OPTION have_query_cache, have_berkeley_db, have_innodb;
extern SHOW_COMP_OPTION have_crypt;
......
......@@ -370,7 +370,7 @@ KEY_CACHE *sql_key_cache;
CHARSET_INFO *system_charset_info, *files_charset_info ;
CHARSET_INFO *national_charset_info, *table_alias_charset;
SHOW_COMP_OPTION have_berkeley_db, have_innodb, have_isam, have_example_db;
SHOW_COMP_OPTION have_berkeley_db, have_innodb, have_isam, have_example_db, have_archive_db;
SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_query_cache;
SHOW_COMP_OPTION have_crypt, have_compress;
......@@ -5126,6 +5126,11 @@ static void mysql_init_variables(void)
#else
have_example_db= SHOW_OPTION_NO;
#endif
#ifdef HAVE_ARCHIVE_DB
have_archive_db= SHOW_OPTION_YES;
#else
have_archive_db= SHOW_OPTION_NO;
#endif
#ifdef USE_RAID
have_raid=SHOW_OPTION_YES;
#else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment