summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/audit_null/CMakeLists.txt16
-rw-r--r--plugin/audit_null/Makefile.am32
-rw-r--r--plugin/audit_null/audit_null.c130
-rw-r--r--plugin/audit_null/plug.in4
-rw-r--r--plugin/daemon_example/CMakeLists.txt16
-rw-r--r--plugin/daemon_example/Makefile.am4
-rw-r--r--plugin/fulltext/CMakeLists.txt17
-rw-r--r--plugin/fulltext/Makefile.am1
-rw-r--r--plugin/semisync/CMakeLists.txt28
-rw-r--r--plugin/semisync/Makefile.am4
-rw-r--r--plugin/semisync/semisync_master.cc24
-rw-r--r--plugin/semisync/semisync_master.h15
-rw-r--r--plugin/semisync/semisync_master_plugin.cc36
13 files changed, 290 insertions, 37 deletions
diff --git a/plugin/audit_null/CMakeLists.txt b/plugin/audit_null/CMakeLists.txt
new file mode 100644
index 00000000000..9f32181a163
--- /dev/null
+++ b/plugin/audit_null/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2010 Sun Microsystems, Inc
+#
+# 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; version 2 of the License.
+#
+# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+MYSQL_ADD_PLUGIN(audit_null audit_null.c)
diff --git a/plugin/audit_null/Makefile.am b/plugin/audit_null/Makefile.am
new file mode 100644
index 00000000000..4408c3f7c47
--- /dev/null
+++ b/plugin/audit_null/Makefile.am
@@ -0,0 +1,32 @@
+# Copyright (C) 2007 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; version 2 of the License.
+#
+# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#Makefile.am example for a plugin
+
+pkgplugindir= $(pkglibdir)/plugin
+
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
+EXTRA_LTLIBRARIES= adt_null.la
+pkgplugin_LTLIBRARIES= @plugin_audit_null_shared_target@
+adt_null_la_LDFLAGS= -module -rpath $(pkgplugindir)
+adt_null_la_CPPFLAGS= $(AM_CPPFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+adt_null_la_SOURCES= audit_null.c
+
+EXTRA_LIBRARIES= libadtnull.a
+noinst_LIBRARIES= @plugin_audit_null_static_target@
+libadtnull_a_SOURCES= audit_null.c
+
+EXTRA_DIST= plug.in CMakeLists.txt
diff --git a/plugin/audit_null/audit_null.c b/plugin/audit_null/audit_null.c
new file mode 100644
index 00000000000..52a9df08cf4
--- /dev/null
+++ b/plugin/audit_null/audit_null.c
@@ -0,0 +1,130 @@
+/* Copyright (C) 2006-2007 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; version 2 of the License.
+
+ 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#include <stdio.h>
+#include <mysql/plugin.h>
+#include <mysql/plugin_audit.h>
+
+#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
+#define __attribute__(A)
+#endif
+
+static volatile int number_of_calls; /* for SHOW STATUS, see below */
+
+
+/*
+ Initialize the plugin at server start or plugin installation.
+
+ SYNOPSIS
+ audit_null_plugin_init()
+
+ DESCRIPTION
+ Does nothing.
+
+ RETURN VALUE
+ 0 success
+ 1 failure (cannot happen)
+*/
+
+static int audit_null_plugin_init(void *arg __attribute__((unused)))
+{
+ number_of_calls= 0;
+ return(0);
+}
+
+
+/*
+ Terminate the plugin at server shutdown or plugin deinstallation.
+
+ SYNOPSIS
+ audit_null_plugin_deinit()
+ Does nothing.
+
+ RETURN VALUE
+ 0 success
+ 1 failure (cannot happen)
+
+*/
+
+static int audit_null_plugin_deinit(void *arg __attribute__((unused)))
+{
+ printf("audit_null was invoked %u times\n", number_of_calls);
+ return(0);
+}
+
+
+/*
+ Foo
+
+ SYNOPSIS
+ audit_null_notify()
+ thd connection context
+
+ DESCRIPTION
+*/
+
+static void audit_null_notify(MYSQL_THD thd __attribute__((unused)),
+ const struct mysql_event *event
+ __attribute__((unused)))
+{
+ /* prone to races, oh well */
+ number_of_calls++;
+}
+
+
+/*
+ Plugin type-specific descriptor
+*/
+
+static struct st_mysql_audit audit_null_descriptor=
+{
+ MYSQL_AUDIT_INTERFACE_VERSION, /* interface version */
+ NULL, /* release_thd function */
+ audit_null_notify, /* notify function */
+ { (unsigned long) -1 } /* class mask */
+};
+
+/*
+ Plugin status variables for SHOW STATUS
+*/
+
+static struct st_mysql_show_var simple_status[]=
+{
+ {"audit_null_called", (char *)&number_of_calls, SHOW_INT},
+ {0,0,0}
+};
+
+
+/*
+ Plugin library descriptor
+*/
+
+mysql_declare_plugin(audit_null)
+{
+ MYSQL_AUDIT_PLUGIN, /* type */
+ &audit_null_descriptor, /* descriptor */
+ "NULL_AUDIT", /* name */
+ "MySQL AB", /* author */
+ "Simple NULL Audit", /* description */
+ PLUGIN_LICENSE_GPL,
+ audit_null_plugin_init, /* init function (when loaded) */
+ audit_null_plugin_deinit, /* deinit function (when unloaded) */
+ 0x0001, /* version */
+ simple_status, /* status variables */
+ NULL, /* system variables */
+ NULL
+}
+mysql_declare_plugin_end;
+
diff --git a/plugin/audit_null/plug.in b/plugin/audit_null/plug.in
new file mode 100644
index 00000000000..15b1a48b408
--- /dev/null
+++ b/plugin/audit_null/plug.in
@@ -0,0 +1,4 @@
+MYSQL_PLUGIN(audit_null, [NULL Audit Plug-in],
+ [Simple black-hole Audit example plug-in])
+MYSQL_PLUGIN_DYNAMIC(audit_null, [adt_null.la])
+MYSQL_PLUGIN_STATIC(audit_null, [libadtnull.a])
diff --git a/plugin/daemon_example/CMakeLists.txt b/plugin/daemon_example/CMakeLists.txt
new file mode 100644
index 00000000000..1c21d57b326
--- /dev/null
+++ b/plugin/daemon_example/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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; version 2 of the License.
+#
+# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+MYSQL_ADD_PLUGIN(daemon_example daemon_example.cc MODULE_ONLY)
diff --git a/plugin/daemon_example/Makefile.am b/plugin/daemon_example/Makefile.am
index c5414cd46c7..d1f2555594c 100644
--- a/plugin/daemon_example/Makefile.am
+++ b/plugin/daemon_example/Makefile.am
@@ -26,7 +26,8 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
EXTRA_LTLIBRARIES = libdaemon_example.la
pkgplugin_LTLIBRARIES = @plugin_daemon_example_shared_target@
-libdaemon_example_la_LDFLAGS = -module -rpath $(pkgplugindir)
+libdaemon_example_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices
+
libdaemon_example_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
libdaemon_example_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
libdaemon_example_la_SOURCES = daemon_example.cc
@@ -37,6 +38,7 @@ noinst_LIBRARIES = @plugin_daemon_example_static_target@
libdaemon_example_a_CXXFLAGS = $(AM_CFLAGS)
libdaemon_example_a_CFLAGS = $(AM_CFLAGS)
libdaemon_example_a_SOURCES= daemon_example.cc
+EXTRA_DIST = CMakeLists.txt
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/plugin/fulltext/CMakeLists.txt b/plugin/fulltext/CMakeLists.txt
new file mode 100644
index 00000000000..ea71552a37a
--- /dev/null
+++ b/plugin/fulltext/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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; version 2 of the License.
+#
+# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+MYSQL_ADD_PLUGIN(ftexample plugin_example.c MODULE_ONLY MODULE_OUTPUT_NAME mypluglib)
diff --git a/plugin/fulltext/Makefile.am b/plugin/fulltext/Makefile.am
index 343416072dd..0747e6d0193 100644
--- a/plugin/fulltext/Makefile.am
+++ b/plugin/fulltext/Makefile.am
@@ -22,6 +22,7 @@ pkgplugin_LTLIBRARIES= mypluglib.la
mypluglib_la_SOURCES= plugin_example.c
mypluglib_la_LDFLAGS= -module -rpath $(pkgplugindir)
mypluglib_la_CFLAGS= -DMYSQL_DYNAMIC_PLUGIN
+EXTRA_DIST= CMakeLists.txt
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/plugin/semisync/CMakeLists.txt b/plugin/semisync/CMakeLists.txt
index d42510fab18..2ebd67292f3 100644
--- a/plugin/semisync/CMakeLists.txt
+++ b/plugin/semisync/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 MySQL AB
+# Copyright (C) 2009 Sun Microsystems,Inc
#
# 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
@@ -13,23 +13,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# This is CMakeLists.txt for semi-sync replication plugins
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-# Add common include directories
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+SET(SEMISYNC_MASTER_SOURCES
+ semisync.cc semisync_master.cc semisync_master_plugin.cc
+ semisync.h semisync_master.h)
-SET(SEMISYNC_MASTER_SOURCES semisync.cc semisync_master.cc semisync_master_plugin.cc)
-SET(SEMISYNC_SLAVE_SOURCES semisync.cc semisync_slave.cc semisync_slave_plugin.cc)
+MYSQL_ADD_PLUGIN(semisync_master ${SEMISYNC_MASTER_SOURCES}
+ MODULE_ONLY MODULE_OUTPUT_NAME "semisync_master")
+
+SET(SEMISYNC_SLAVE_SOURCES semisync.cc semisync_slave.cc
+ semisync_slave_plugin.cc semisync.h semisync_slave.h )
+MYSQL_ADD_PLUGIN(semisync_slave ${SEMISYNC_SLAVE_SOURCES}
+ MODULE_ONLY MODULE_OUTPUT_NAME "semisync_slave")
-ADD_DEFINITIONS(-DMYSQL_DYNAMIC_PLUGIN)
-ADD_LIBRARY(semisync_master SHARED ${SEMISYNC_MASTER_SOURCES})
-TARGET_LINK_LIBRARIES(semisync_master mysqld)
-ADD_LIBRARY(semisync_slave SHARED ${SEMISYNC_SLAVE_SOURCES})
-TARGET_LINK_LIBRARIES(semisync_slave mysqld)
-MESSAGE("build SEMISYNC as DLL")
diff --git a/plugin/semisync/Makefile.am b/plugin/semisync/Makefile.am
index 27ff89aae88..0022d600f57 100644
--- a/plugin/semisync/Makefile.am
+++ b/plugin/semisync/Makefile.am
@@ -25,12 +25,12 @@ noinst_HEADERS = semisync.h semisync_master.h semisync_slave.h
pkgplugin_LTLIBRARIES = semisync_master.la semisync_slave.la
-semisync_master_la_LDFLAGS = -module
+semisync_master_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices
semisync_master_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
semisync_master_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
semisync_master_la_SOURCES = semisync.cc semisync_master.cc semisync_master_plugin.cc
-semisync_slave_la_LDFLAGS = -module
+semisync_slave_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices
semisync_slave_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
semisync_slave_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
semisync_slave_la_SOURCES = semisync.cc semisync_slave.cc semisync_slave_plugin.cc
diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc
index 5b06180662e..cdf01854442 100644
--- a/plugin/semisync/semisync_master.cc
+++ b/plugin/semisync/semisync_master.cc
@@ -1,5 +1,5 @@
/* Copyright (C) 2007 Google Inc.
- Copyright (C) 2008 MySQL AB
+ Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc
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
@@ -60,7 +60,7 @@ static unsigned long long timespec_to_usec(const struct timespec *ts)
*
******************************************************************************/
-ActiveTranx::ActiveTranx(pthread_mutex_t *lock,
+ActiveTranx::ActiveTranx(mysql_mutex_t *lock,
unsigned long trace_level)
: Trace(trace_level), allocator_(max_connections),
num_entries_(max_connections << 1), /* Transaction hash table size
@@ -357,8 +357,10 @@ int ReplSemiSyncMaster::initObject()
setTraceLevel(rpl_semi_sync_master_trace_level);
/* Mutex initialization can only be done after MY_INIT(). */
- pthread_mutex_init(&LOCK_binlog_, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_binlog_send_, NULL);
+ mysql_mutex_init(key_ss_mutex_LOCK_binlog_,
+ &LOCK_binlog_, MY_MUTEX_INIT_FAST);
+ mysql_cond_init(key_ss_cond_COND_binlog_send_,
+ &COND_binlog_send_, NULL);
if (rpl_semi_sync_master_enabled)
result = enableMaster();
@@ -433,8 +435,8 @@ ReplSemiSyncMaster::~ReplSemiSyncMaster()
{
if (init_done_)
{
- pthread_mutex_destroy(&LOCK_binlog_);
- pthread_cond_destroy(&COND_binlog_send_);
+ mysql_mutex_destroy(&LOCK_binlog_);
+ mysql_cond_destroy(&COND_binlog_send_);
}
delete active_tranxs_;
@@ -442,17 +444,17 @@ ReplSemiSyncMaster::~ReplSemiSyncMaster()
void ReplSemiSyncMaster::lock()
{
- pthread_mutex_lock(&LOCK_binlog_);
+ mysql_mutex_lock(&LOCK_binlog_);
}
void ReplSemiSyncMaster::unlock()
{
- pthread_mutex_unlock(&LOCK_binlog_);
+ mysql_mutex_unlock(&LOCK_binlog_);
}
void ReplSemiSyncMaster::cond_broadcast()
{
- pthread_cond_broadcast(&COND_binlog_send_);
+ mysql_cond_broadcast(&COND_binlog_send_);
}
int ReplSemiSyncMaster::cond_timewait(struct timespec *wait_time)
@@ -461,8 +463,8 @@ int ReplSemiSyncMaster::cond_timewait(struct timespec *wait_time)
int wait_res;
function_enter(kWho);
- wait_res = pthread_cond_timedwait(&COND_binlog_send_,
- &LOCK_binlog_, wait_time);
+ wait_res= mysql_cond_timedwait(&COND_binlog_send_,
+ &LOCK_binlog_, wait_time);
return function_exit(kWho, wait_res);
}
diff --git a/plugin/semisync/semisync_master.h b/plugin/semisync/semisync_master.h
index 982a7f77a59..e1ad28cd9f6 100644
--- a/plugin/semisync/semisync_master.h
+++ b/plugin/semisync/semisync_master.h
@@ -1,5 +1,6 @@
/* Copyright (C) 2007 Google Inc.
Copyright (C) 2008 MySQL AB
+ Copyright (C) 2009 Sun Microsystems, Inc
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
@@ -20,6 +21,11 @@
#include "semisync.h"
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_ss_mutex_LOCK_binlog_;
+extern PSI_cond_key key_ss_cond_COND_binlog_send_;
+#endif
+
struct TranxNode {
char log_name_[FN_REFLEN];
my_off_t log_pos_;
@@ -280,7 +286,6 @@ private:
}
};
-
/**
This class manages memory for active transaction list.
@@ -300,7 +305,7 @@ private:
TranxNode **trx_htb_; /* A hash table on active transactions. */
int num_entries_; /* maximum hash table entries */
- pthread_mutex_t *lock_; /* mutex lock */
+ mysql_mutex_t *lock_; /* mutex lock */
inline void assert_lock_owner();
@@ -323,7 +328,7 @@ private:
}
public:
- ActiveTranx(pthread_mutex_t *lock, unsigned long trace_level);
+ ActiveTranx(mysql_mutex_t *lock, unsigned long trace_level);
~ActiveTranx();
/* Insert an active transaction node with the specified position.
@@ -372,14 +377,14 @@ class ReplSemiSyncMaster
/* This cond variable is signaled when enough binlog has been sent to slave,
* so that a waiting trx can return the 'ok' to the client for a commit.
*/
- pthread_cond_t COND_binlog_send_;
+ mysql_cond_t COND_binlog_send_;
/* Mutex that protects the following state variables and the active
* transaction list.
* Under no cirumstances we can acquire mysql_bin_log.LOCK_log if we are
* already holding LOCK_binlog_ because it can cause deadlocks.
*/
- pthread_mutex_t LOCK_binlog_;
+ mysql_mutex_t LOCK_binlog_;
/* This is set to true when reply_file_name_ contains meaningful data. */
bool reply_file_name_inited_;
diff --git a/plugin/semisync/semisync_master_plugin.cc b/plugin/semisync/semisync_master_plugin.cc
index efcb7172b28..e371df3edc3 100644
--- a/plugin/semisync/semisync_master_plugin.cc
+++ b/plugin/semisync/semisync_master_plugin.cc
@@ -1,5 +1,5 @@
/* Copyright (C) 2007 Google Inc.
- Copyright (C) 2008 MySQL AB
+ Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc
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
@@ -334,9 +334,43 @@ static SHOW_VAR semi_sync_master_status_vars[]= {
{NULL, NULL, SHOW_LONG},
};
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key key_ss_mutex_LOCK_binlog_;
+
+static PSI_mutex_info all_semisync_mutexes[]=
+{
+ { &key_ss_mutex_LOCK_binlog_, "LOCK_binlog_", 0}
+};
+
+PSI_cond_key key_ss_cond_COND_binlog_send_;
+
+static PSI_cond_info all_semisync_conds[]=
+{
+ { &key_ss_cond_COND_binlog_send_, "COND_binlog_send_", 0}
+};
+
+static void init_semisync_psi_keys(void)
+{
+ const char* category= "semisync";
+ int count;
+
+ if (PSI_server == NULL)
+ return;
+
+ count= array_elements(all_semisync_mutexes);
+ PSI_server->register_mutex(category, all_semisync_mutexes, count);
+
+ count= array_elements(all_semisync_conds);
+ PSI_server->register_cond(category, all_semisync_conds, count);
+}
+#endif /* HAVE_PSI_INTERFACE */
static int semi_sync_master_plugin_init(void *p)
{
+#ifdef HAVE_PSI_INTERFACE
+ init_semisync_psi_keys();
+#endif
+
if (repl_semisync.initObject())
return 1;
if (register_trans_observer(&trans_observer, p))