2012-08-09 17:22:00 +02:00
|
|
|
/* Copyright (c) 2005, 2012, Oracle and/or its affiliates.
|
|
|
|
Copyright (c) 2009, 2012, Monty Program Ab
|
2005-11-05 12:20:35 +01:00
|
|
|
|
|
|
|
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
|
2006-12-27 02:23:51 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2005-11-05 12:20:35 +01:00
|
|
|
|
|
|
|
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
|
2011-06-30 17:46:53 +02:00
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
2005-11-05 12:20:35 +01:00
|
|
|
|
|
|
|
#ifndef _sql_plugin_h
|
|
|
|
#define _sql_plugin_h
|
|
|
|
|
2010-12-21 13:00:26 +01:00
|
|
|
#include <my_global.h>
|
|
|
|
|
2010-03-31 16:05:33 +02:00
|
|
|
/*
|
|
|
|
the following #define adds server-only members to enum_mysql_show_type,
|
|
|
|
that is defined in plugin.h
|
|
|
|
*/
|
|
|
|
#define SHOW_always_last SHOW_KEY_CACHE_LONG, \
|
2010-11-25 18:17:28 +01:00
|
|
|
SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, \
|
2010-03-31 16:05:33 +02:00
|
|
|
SHOW_HAVE, SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, \
|
|
|
|
SHOW_LONG_NOFLUSH, SHOW_LONGLONG_STATUS, SHOW_LEX_STRING
|
|
|
|
#include <mysql/plugin.h>
|
|
|
|
#undef SHOW_always_last
|
|
|
|
|
|
|
|
#include "m_string.h" /* LEX_STRING */
|
|
|
|
#include "my_alloc.h" /* MEM_ROOT */
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
class sys_var;
|
2009-12-22 10:35:56 +01:00
|
|
|
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
|
2010-09-27 14:55:09 +02:00
|
|
|
enum enum_plugin_load_option { PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE,
|
|
|
|
PLUGIN_FORCE_PLUS_PERMANENT };
|
|
|
|
extern const char *global_plugin_typelib_names[];
|
2009-12-22 10:35:56 +01:00
|
|
|
|
|
|
|
#include <my_sys.h>
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2009-09-26 06:49:49 +02:00
|
|
|
#ifdef DBUG_OFF
|
|
|
|
#define plugin_ref_to_int(A) A
|
|
|
|
#define plugin_int_to_ref(A) A
|
|
|
|
#else
|
|
|
|
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
|
|
|
|
#define plugin_int_to_ref(A) &(A)
|
|
|
|
#endif
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
the following flags are valid for plugin_init()
|
|
|
|
*/
|
|
|
|
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
|
|
|
|
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
|
|
|
|
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
|
|
|
|
|
|
|
|
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
|
|
|
|
|
2006-01-07 14:41:57 +01:00
|
|
|
typedef enum enum_mysql_show_type SHOW_TYPE;
|
|
|
|
typedef struct st_mysql_show_var SHOW_VAR;
|
2005-11-05 12:20:35 +01:00
|
|
|
|
|
|
|
#define MYSQL_ANY_PLUGIN -1
|
|
|
|
|
2006-09-06 10:22:59 +02:00
|
|
|
/*
|
|
|
|
different values of st_plugin_int::state
|
|
|
|
though they look like a bitmap, plugin may only
|
|
|
|
be in one of those eigenstates, not in a superposition of them :)
|
|
|
|
It's a bitmap, because it makes it easier to test
|
|
|
|
"whether the state is one of those..."
|
|
|
|
*/
|
|
|
|
#define PLUGIN_IS_FREED 1
|
|
|
|
#define PLUGIN_IS_DELETED 2
|
|
|
|
#define PLUGIN_IS_UNINITIALIZED 4
|
|
|
|
#define PLUGIN_IS_READY 8
|
2007-03-02 17:43:45 +01:00
|
|
|
#define PLUGIN_IS_DYING 16
|
2008-12-17 16:45:34 +01:00
|
|
|
#define PLUGIN_IS_DISABLED 32
|
2005-11-05 12:20:35 +01:00
|
|
|
|
|
|
|
/* A handle for the dynamic library containing a plugin or plugins. */
|
|
|
|
|
|
|
|
struct st_plugin_dl
|
|
|
|
{
|
|
|
|
LEX_STRING dl;
|
|
|
|
void *handle;
|
2010-04-01 16:34:51 +02:00
|
|
|
struct st_maria_plugin *plugins;
|
|
|
|
int mysqlversion;
|
|
|
|
int mariaversion;
|
2010-03-12 20:05:21 +01:00
|
|
|
bool allocated;
|
2005-11-05 12:20:35 +01:00
|
|
|
uint ref_count; /* number of plugins loaded from the library */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* A handle of a plugin */
|
|
|
|
|
|
|
|
struct st_plugin_int
|
|
|
|
{
|
|
|
|
LEX_STRING name;
|
2010-04-01 16:34:51 +02:00
|
|
|
struct st_maria_plugin *plugin;
|
2005-11-05 12:20:35 +01:00
|
|
|
struct st_plugin_dl *plugin_dl;
|
2006-09-06 10:22:59 +02:00
|
|
|
uint state;
|
2006-05-31 18:07:32 +02:00
|
|
|
uint ref_count; /* number of threads using the plugin */
|
2012-04-18 04:00:08 +02:00
|
|
|
uint locks_total; /* how many times the plugin was locked */
|
2006-05-31 18:07:32 +02:00
|
|
|
void *data; /* plugin type specific, e.g. handlerton */
|
2007-03-02 17:43:45 +01:00
|
|
|
MEM_ROOT mem_root; /* memory for dynamic plugin structures */
|
|
|
|
sys_var *system_vars; /* server variables for this plugin */
|
2010-09-27 14:55:09 +02:00
|
|
|
enum enum_plugin_load_option load_option; /* OFF, ON, FORCE, F+PERMANENT */
|
2005-11-05 12:20:35 +01:00
|
|
|
};
|
|
|
|
|
2007-03-23 18:14:46 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
See intern_plugin_lock() for the explanation for the
|
|
|
|
conditionally defined plugin_ref type
|
|
|
|
*/
|
2007-03-02 17:43:45 +01:00
|
|
|
#ifdef DBUG_OFF
|
|
|
|
typedef struct st_plugin_int *plugin_ref;
|
2010-03-08 14:57:32 +01:00
|
|
|
#define plugin_ref_to_int(A) A
|
|
|
|
#define plugin_int_to_ref(A) A
|
2007-03-02 17:43:45 +01:00
|
|
|
#define plugin_decl(pi) ((pi)->plugin)
|
|
|
|
#define plugin_dlib(pi) ((pi)->plugin_dl)
|
|
|
|
#define plugin_data(pi,cast) ((cast)((pi)->data))
|
|
|
|
#define plugin_name(pi) (&((pi)->name))
|
|
|
|
#define plugin_state(pi) ((pi)->state)
|
2010-09-27 14:55:09 +02:00
|
|
|
#define plugin_load_option(pi) ((pi)->load_option)
|
2007-03-23 18:14:46 +01:00
|
|
|
#define plugin_equals(p1,p2) ((p1) == (p2))
|
2007-03-02 17:43:45 +01:00
|
|
|
#else
|
|
|
|
typedef struct st_plugin_int **plugin_ref;
|
2010-03-08 14:57:32 +01:00
|
|
|
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
|
|
|
|
#define plugin_int_to_ref(A) &(A)
|
2007-03-02 17:43:45 +01:00
|
|
|
#define plugin_decl(pi) ((pi)[0]->plugin)
|
|
|
|
#define plugin_dlib(pi) ((pi)[0]->plugin_dl)
|
|
|
|
#define plugin_data(pi,cast) ((cast)((pi)[0]->data))
|
|
|
|
#define plugin_name(pi) (&((pi)[0]->name))
|
|
|
|
#define plugin_state(pi) ((pi)[0]->state)
|
2010-09-27 14:55:09 +02:00
|
|
|
#define plugin_load_option(pi) ((pi)[0]->load_option)
|
2007-03-23 18:14:46 +01:00
|
|
|
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
|
2007-03-02 17:43:45 +01:00
|
|
|
#endif
|
|
|
|
|
handlerton cleanup:
duplicate fields removed, st_mysql_storage_engine added to support
run-time handlerton initialization (no compiler warnings), handler API
is now tied to MySQL version, handlerton->plugin mapping added
(slot-based), dummy default_hton removed, plugin-type-specific
initialization generalized, built-in plugins are now initialized too,
--default-storage-engine no longer needs a list of storage engines
in handle_options().
mysql-test-run.pl bugfixes
include/mysql/plugin.h:
added st_mysql_storage_engine
made handlerton tied to MySQL version
mysql-test/mysql-test-run.pl:
bugfixes (umask, --no-defaults)
mysql-test/r/ndb_dd_basic.result:
update error message
mysql-test/t/partition_mgm_err2.test:
fix typo
sql/ha_berkeley.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_berkeley.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_federated.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_heap.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_innodb.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_innodb.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_myisam.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_myisammrg.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster_binlog.cc:
no 'name' in the handlerton anymore
sql/ha_partition.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/handler.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
handlerton->plugin mapping
sql/handler.h:
handlerton cleanup: remove duplicate fields
sql/log.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/mysql_priv.h:
handler.h needs plugin.h
sql/mysqld.cc:
Convert --default-storage-engine to a handlerton* when
all storage engines are initialized and not in getopt
sql/set_var.cc:
no name in the handlerton anymore
sql/sql_parse.cc:
no default_hton anymore
sql/sql_partition.cc:
no name in the handlerton anymore
sql/sql_plugin.cc:
generalize plugin type-specific initialization.
initialize built-in plugins too
sql/sql_plugin.h:
generalize plugin type-specific initialization.
sql/sql_show.cc:
st_mysql_storage_engine structure
no name in the handlerton anymore
sql/sql_table.cc:
no name in the handlerton anymore
no default_hton anymore
sql/sql_tablespace.cc:
no name in the handlerton anymore
no default_hton anymore
sql/sql_yacc.yy:
no default_hton anymore
issue "unknown storage engine" warning where it is discovered
storage/archive/ha_archive.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/archive/ha_archive.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/blackhole/ha_blackhole.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/csv/ha_tina.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/example/ha_example.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
2006-05-28 14:51:01 +02:00
|
|
|
typedef int (*plugin_type_init)(struct st_plugin_int *);
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
extern char *opt_plugin_load;
|
2005-11-05 12:20:35 +01:00
|
|
|
extern char *opt_plugin_dir_ptr;
|
|
|
|
extern char opt_plugin_dir[FN_REFLEN];
|
2006-06-12 15:50:11 +02:00
|
|
|
extern const LEX_STRING plugin_type_names[];
|
2011-04-25 17:22:25 +02:00
|
|
|
extern ulong plugin_maturity;
|
2010-06-16 19:01:22 +02:00
|
|
|
extern TYPELIB plugin_maturity_values;
|
|
|
|
extern const char *plugin_maturity_names[];
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
extern int plugin_init(int *argc, char **argv, int init_flags);
|
2006-08-29 20:58:12 +02:00
|
|
|
extern void plugin_shutdown(void);
|
2009-12-22 10:35:56 +01:00
|
|
|
void add_plugin_options(DYNAMIC_ARRAY *options, MEM_ROOT *mem_root);
|
2007-03-02 17:43:45 +01:00
|
|
|
extern bool plugin_is_ready(const LEX_STRING *name, int type);
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
2010-07-08 23:20:08 +02:00
|
|
|
#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C)
|
|
|
|
#define my_plugin_lock(A,B) plugin_lock(A,B)
|
2011-04-25 17:22:25 +02:00
|
|
|
extern plugin_ref plugin_lock(THD *thd, plugin_ref ptr);
|
2007-03-02 17:43:45 +01:00
|
|
|
extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name,
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
2010-07-08 23:20:08 +02:00
|
|
|
int type);
|
2007-03-02 17:43:45 +01:00
|
|
|
extern void plugin_unlock(THD *thd, plugin_ref plugin);
|
|
|
|
extern void plugin_unlock_list(THD *thd, plugin_ref *list, uint count);
|
|
|
|
extern bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
|
|
|
|
const LEX_STRING *dl);
|
2012-03-05 21:48:06 +01:00
|
|
|
extern bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
|
|
|
|
const LEX_STRING *dl);
|
2007-03-02 17:43:45 +01:00
|
|
|
extern bool plugin_register_builtin(struct st_mysql_plugin *plugin);
|
2007-04-02 20:38:58 +02:00
|
|
|
extern void plugin_thdvar_init(THD *thd);
|
2007-03-02 17:43:45 +01:00
|
|
|
extern void plugin_thdvar_cleanup(THD *thd);
|
2012-06-29 13:36:01 +02:00
|
|
|
extern SHOW_COMP_OPTION plugin_status(const char *name, size_t len, int type);
|
2010-12-01 13:54:50 +01:00
|
|
|
extern bool check_valid_path(const char *path, size_t length);
|
2005-12-21 19:18:40 +01:00
|
|
|
|
2006-01-07 14:41:57 +01:00
|
|
|
typedef my_bool (plugin_foreach_func)(THD *thd,
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_ref plugin,
|
2005-12-21 19:18:40 +01:00
|
|
|
void *arg);
|
2006-09-06 10:22:59 +02:00
|
|
|
#define plugin_foreach(A,B,C,D) plugin_foreach_with_mask(A,B,C,PLUGIN_IS_READY,D)
|
2007-03-02 17:43:45 +01:00
|
|
|
extern bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
|
|
|
|
int type, uint state_mask, void *arg);
|
2005-11-05 12:20:35 +01:00
|
|
|
#endif
|