summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--acconfig.h3
-rw-r--r--acinclude.m430
-rw-r--r--configure.in1
-rw-r--r--sql/Makefile.am8
-rw-r--r--sql/examples/ha_example.cc22
-rw-r--r--sql/handler.cc9
-rw-r--r--sql/handler.h2
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/mysqld.cc7
9 files changed, 68 insertions, 16 deletions
diff --git a/acconfig.h b/acconfig.h
index b254b3263fd..fbc26b8f3b5 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -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
diff --git a/acinclude.m4 b/acinclude.m4
index 2eb45b2e8ce..f2387417d9f 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -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:
diff --git a/configure.in b/configure.in
index de546d9c078..8bfee20972b 100644
--- a/configure.in
+++ b/configure.in
@@ -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=
diff --git a/sql/Makefile.am b/sql/Makefile.am
index 4aa6aaaa1ee..bacf3bc58d1 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -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)
diff --git a/sql/examples/ha_example.cc b/sql/examples/ha_example.cc
index 40942ef55d8..e2463761e67 100644
--- a/sql/examples/ha_example.cc
+++ b/sql/examples/ha_example.cc
@@ -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 */
diff --git a/sql/handler.cc b/sql/handler.cc
index ddf2e68db47..58147e7e937 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -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}
};
@@ -172,6 +177,10 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
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);
default: // should never happen
diff --git a/sql/handler.h b/sql/handler.h
index 26fb762a9b5..3fad4d9bd81 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -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;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index a97bd05fed6..fff613b71e0 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -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;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 62ec6bc1027..aed598a1343 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -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