Commit 01bff53c authored by unknown's avatar unknown

All changes are to allow someone to compile the example storage engine and use it.


acconfig.h:
  Default undef for example storage engine.
acinclude.m4:
  Build macro additions for example engine.
configure.in:
  Configure changes for it to be listed in --help
sql/Makefile.am:
  Added in paths to build example.
sql/examples/ha_example.cc:
  Correction in indention and a few minor other corrections. It now lets you create/open/drop example engine.
sql/handler.cc:
  Added definition for the example storage engine. Added case for it to be created.
sql/handler.h:
  Added example storage engine type.
sql/mysql_priv.h:
  Added flag for optional build of example storage engine.
sql/mysqld.cc:
  Pieces to build example storage engine.
parent 83c2292b
......@@ -112,6 +112,9 @@
/* Define if we are using OSF1 DEC threads on 3.2 */
#undef HAVE_DEC_3_2_THREADS
/* Builds Example DB */
#undef HAVE_EXAMPLE_DB
/* fp_except from ieeefp.h */
#undef HAVE_FP_EXCEPT
......
......@@ -1302,6 +1302,36 @@ dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_INNODB SECTION
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_EXAMPLEDB
dnl Sets HAVE_EXAMPLE_DB if --with-example-storage-engine is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_EXAMPLEDB], [
AC_ARG_WITH([example-storage-engine],
[
--with-example-storage-engine
Enable the Example Storge Engine],
[exampledb="$withval"],
[exampledb=no])
AC_MSG_CHECKING([for example storage engine])
case "$exampledb" in
yes )
AC_DEFINE(HAVE_EXAMPLE_DB)
AC_MSG_RESULT([yes])
[exampledb=yes])
;;
* )
AC_MSG_RESULT([no])
[exampledb=no])
;;
esac
])
dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_EXAMPLE SECTION
dnl ---------------------------------------------------------------------------
dnl By default, many hosts won't let programs access large files;
dnl one must use special compiler options to get large-file access to work.
dnl For more details about this brain damage please see:
......
......@@ -2618,6 +2618,7 @@ AC_DEFINE_UNQUOTED(MYSQL_DEFAULT_COLLATION_NAME,"$default_collation")
MYSQL_CHECK_ISAM
MYSQL_CHECK_BDB
MYSQL_CHECK_INNODB
MYSQL_CHECK_EXAMPLEDB
# If we have threads generate some library functions and test programs
sql_server_dirs=
......
......@@ -37,7 +37,7 @@ LDADD = @isam_libs@ \
../mysys/libmysys.a \
../dbug/libdbug.a \
../regex/libregex.a \
../strings/libmystrings.a
../strings/libmystrings.a
mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
@bdb_libs@ @innodb_libs@ @pstack_libs@ \
......@@ -57,7 +57,8 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
lex.h lex_symbol.h sql_acl.h sql_crypt.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
spatial.h gstream.h client_settings.h \
examples/ha_example.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 \
......@@ -86,7 +87,8 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
slave.cc sql_repl.cc sql_union.cc sql_derived.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
gstream.cc spatial.cc sql_help.cc protocol_cursor.cc \
examples/ha_example.cc
gen_lex_hash_SOURCES = gen_lex_hash.cc
gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
......
......@@ -18,11 +18,12 @@
#pragma implementation // gcc: Class implementation
#endif
#include "mysql_priv.h"
#include <mysql_priv.h>
#ifdef HAVE_EXAMPLE_DB
#include "ha_example.h"
/* Variables for example share methods */
extern pthread_mutex_t LOCK_mysql_create_db;
pthread_mutex_t example_mutex;
static HASH example_open_tables;
static int example_init= 0;
......@@ -62,7 +63,8 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
if (!(share=(EXAMPLE_SHARE*) hash_search(&example_open_tables,
(byte*) table_name,
length))){
length)))
{
if (!(share=(EXAMPLE_SHARE *)
my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
&share, sizeof(*share),
......@@ -81,9 +83,6 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
goto error;
thr_lock_init(&share->lock);
pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
if (get_mmap(share, 0) > 0)
goto error2;
}
share->use_count++;
pthread_mutex_unlock(&example_mutex);
......@@ -224,7 +223,7 @@ void ha_example::position(const byte *record)
int ha_example::rnd_pos(byte * buf, byte *pos)
{
DBUG_ENTER("ha_example::rnd_pos");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED));
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED);
}
void ha_example::info(uint flag)
......@@ -271,7 +270,8 @@ THR_LOCK_DATA **ha_example::store_lock(THD *thd,
int ha_example::delete_table(const char *name)
{
DBUG_ENTER("ha_example::delete_table");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED);
/* This is not implemented but we want someone to be able that it works. */
DBUG_RETURN(0);
}
int ha_example::rename_table(const char * from, const char * to)
......@@ -287,12 +287,14 @@ ha_rows ha_example::records_in_range(int inx,
enum ha_rkey_function end_search_flag)
{
DBUG_ENTER("ha_example::records_in_range ");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED);
DBUG_RETURN(records); // HA_ERR_NOT_IMPLEMENTED
}
int ha_example::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info)
{
DBUG_ENTER("ha_example::create");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED);
/* This is not implemented but we want someone to be able that it works. */
DBUG_RETURN(0);
}
#endif /* HAVE_EXAMPLE_DB */
......@@ -32,6 +32,9 @@
#ifdef HAVE_BERKELEY_DB
#include "ha_berkeley.h"
#endif
#ifdef HAVE_EXAMPLE_DB
#include "examples/ha_example.h"
#endif
#ifdef HAVE_INNOBASE_DB
#include "ha_innodb.h"
#else
......@@ -76,6 +79,8 @@ struct show_table_type_st sys_table_types[]=
"Supports transactions and page-level locking", DB_TYPE_BERKELEY_DB},
{"BERKELEYDB",&have_berkeley_db,
"Alias for BDB", DB_TYPE_BERKELEY_DB},
{"EXAMPLE",&have_example_db,
"Example storage engine", DB_TYPE_EXAMPLE_DB},
{NullS, NULL, NullS, DB_TYPE_UNKNOWN}
};
......@@ -171,6 +176,10 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
#ifdef HAVE_INNOBASE_DB
case DB_TYPE_INNODB:
return new ha_innobase(table);
#endif
#ifdef HAVE_EXAMPLE_DB
case DB_TYPE_EXAMPLE_DB:
return new ha_example(table);
#endif
case DB_TYPE_HEAP:
return new ha_heap(table);
......
......@@ -132,7 +132,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_DEFAULT };
DB_TYPE_EXAMPLE_DB, DB_TYPE_DEFAULT };
struct show_table_type_st {
const char *type;
......
......@@ -881,7 +881,7 @@ extern struct my_option my_long_options[];
/* optional things, have_* variables */
extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db;
extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db, have_example_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;
SHOW_COMP_OPTION have_berkeley_db, have_innodb, have_isam, have_example_db;
SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_query_cache;
SHOW_COMP_OPTION have_crypt, have_compress;
......@@ -5121,6 +5121,11 @@ static void mysql_init_variables(void)
#else
have_isam=SHOW_OPTION_NO;
#endif
#ifdef HAVE_EXAMPLE_DB
have_example_db= SHOW_OPTION_YES;
#else
have_example_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