mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
WL#3914: Additonal accessors required to compile InnoDB as a plugin storage engine
Add more accessors to MySQL internals in mysql/plugin.h, for storage engine plugins. Add some accessors specific to the InnoDB storage engine, to allow InnoDB to be compiled as a plugin (without MYSQL_SERVER). InnoDB has additional requirements, due to its foreign key support, etc. include/m_string.h: Add structure tag to LEX_STRING definition, so that it can be referred to by forward declarations. Allow struct st_mysql_lex_string to be defined here, or in mysql/plugin.h. include/my_global.h: Define INNODB_COMPATIBILITY_HOOKS unconditionally; it brackets some definitions needed for the InnoDB storage engine plugin which do not belong in our general plugin interface. include/mysql/plugin.h: Additional accessors for MySQL internals: - Full definition of MYSQL_LEX_STRING (identical to LEX_STRING from m_string.h) - Full definition of MYSQL_XID (binary compatible with XID from handler.h) - mysql_tmpfile(), creates a temporary file in mysqld's tmpdir - thd_killed(), to check killed state of connection - thd_alloc() and similar allocation functions - thd_get_xid(), to get XID of connection's transaction - mysql_query_cache_invalidate4, to invalidate a table's query cache entries sql/handler.h: Use MYSQL_XIDDATASIZE definition from mysql/plugin.h, to avoid redundant definitions sql/log.cc: Add definitions for two InnoDB compatibility hooks: - mysql_bin_log_file(), to get log filename - mysql_bin_log_file_pos, to get position in file These are defined only if INNODB_COMPATIBILITY_HOOKS is defined; they are needed by the InnoDB plugin, but aren't part of the general plugin interface. They are declared in ha_innodb.h for InnoDB's use. sql/mysql_priv.h: Expose some server internals when INNODB_COMPATIBILITY_HOOKS is defined, so that InnoDB can be built as a plugin when MYSQL_SERVER is not defined. Move make_lex_string inside THD class. sql/sql_cache.cc: Add definiton of mysql_query_cache_invalidate4(), a part of the plugin API (mysql/plugin.h). sql/sql_class.cc: Add definitions for several accessor functions which form part of the plugin API (mysql/plugin.h): - mysql_tmpfile() - thd_alloc() and friends - thd_make_lex_string() - thd_get_xid() Add definitons for accessor functions which InnoDB requires, but which are not part of the plugin interface: - thd_charset() - thd_query() - thd_slave_thread() - thd_non_transactional_update() - thd_binlog_format() Move definition of make_lex_string() from sql_show.cc into THD class sql/sql_class.h: Remove LEX_STRING_make(), and move make_lex_string() from sql_show.cc inside THD class. sql/sql_parse.cc: Use thd->make_lex_string() instead of thd->LEX_STRING_make() sql/sql_show.cc: Move make_lex_string() inside THD class storage/innobase/handler/ha_innodb.cc: Call thd_make_lex_string() instead of make_lex_string().
This commit is contained in:
@ -24,6 +24,32 @@ class Item;
|
||||
#define MYSQL_THD void*
|
||||
#endif
|
||||
|
||||
#ifndef _m_string_h
|
||||
/* This definition must match the one given in m_string.h */
|
||||
struct st_mysql_lex_string
|
||||
{
|
||||
char *str;
|
||||
unsigned int length;
|
||||
};
|
||||
#endif /* _m_string_h */
|
||||
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
|
||||
|
||||
#define MYSQL_XIDDATASIZE 128
|
||||
/**
|
||||
struct st_mysql_xid is binary compatible with the XID structure as
|
||||
in the X/Open CAE Specification, Distributed Transaction Processing:
|
||||
The XA Specification, X/Open Company Ltd., 1991.
|
||||
http://www.opengroup.org/bookstore/catalog/c193.htm
|
||||
|
||||
@see XID in sql/handler.h
|
||||
*/
|
||||
struct st_mysql_xid {
|
||||
long formatID;
|
||||
long gtrid_length;
|
||||
long bqual_length;
|
||||
char data[MYSQL_XIDDATASIZE]; /* Not \0-terminated */
|
||||
};
|
||||
typedef struct st_mysql_xid MYSQL_XID;
|
||||
|
||||
/*************************************************************************
|
||||
Plugin API. Common for all plugin types.
|
||||
@ -658,6 +684,103 @@ char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length,
|
||||
/* Increments the row counter, see THD::row_count */
|
||||
void thd_inc_row_count(MYSQL_THD thd);
|
||||
|
||||
/**
|
||||
Create a temporary file.
|
||||
|
||||
@details
|
||||
The temporary file is created in a location specified by the mysql
|
||||
server configuration (--tmpdir option). The caller does not need to
|
||||
delete the file, it will be deleted automatically.
|
||||
|
||||
@param prefix prefix for temporary file name
|
||||
@retval -1 error
|
||||
@retval >= 0 a file handle that can be passed to dup or my_close
|
||||
*/
|
||||
int mysql_tmpfile(const char *prefix);
|
||||
|
||||
/**
|
||||
Check the killed state of a connection
|
||||
|
||||
@details
|
||||
In MySQL support for the KILL statement is cooperative. The KILL
|
||||
statement only sets a "killed" flag. This function returns the value
|
||||
of that flag. A thread should check it often, especially inside
|
||||
time-consuming loops, and gracefully abort the operation if it is
|
||||
non-zero.
|
||||
|
||||
@param thd user thread connection handle
|
||||
@retval 0 the connection is active
|
||||
@retval 1 the connection has been killed
|
||||
*/
|
||||
int thd_killed(const MYSQL_THD thd);
|
||||
|
||||
/**
|
||||
Allocate memory in the connection's local memory pool
|
||||
|
||||
@details
|
||||
When properly used in place of @c my_malloc(), this can significantly
|
||||
improve concurrency. Don't use this or related functions to allocate
|
||||
large chunks of memory. Use for temporary storage only. The memory
|
||||
will be freed automatically at the end of the statement; no explicit
|
||||
code is required to prevent memory leaks.
|
||||
|
||||
@see alloc_root()
|
||||
*/
|
||||
void *thd_alloc(MYSQL_THD thd, unsigned int size);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
void *thd_calloc(MYSQL_THD thd, unsigned int size);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
char *thd_strdup(MYSQL_THD thd, const char *str);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size);
|
||||
/**
|
||||
@see thd_alloc()
|
||||
*/
|
||||
void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
|
||||
|
||||
/**
|
||||
Create a LEX_STRING in this connection's local memory pool
|
||||
|
||||
@param thd user thread connection handle
|
||||
@param lex_str pointer to LEX_STRING object to be initialized
|
||||
@param str initializer to be copied into lex_str
|
||||
@param length length of str, in bytes
|
||||
@param allocate_lex_string flag: if TRUE, allocate new LEX_STRING object,
|
||||
instead of using lex_str value
|
||||
@return NULL on failure, or pointer to the LEX_STRING object
|
||||
|
||||
@see thd_alloc()
|
||||
*/
|
||||
MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
|
||||
const char *str, unsigned int size,
|
||||
int allocate_lex_string);
|
||||
|
||||
/**
|
||||
Get the XID for this connection's transaction
|
||||
|
||||
@param thd user thread connection handle
|
||||
@param xid location where identifier is stored
|
||||
*/
|
||||
void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid);
|
||||
|
||||
/**
|
||||
Invalidate the query cache for a given table.
|
||||
|
||||
@param thd user thread connection handle
|
||||
@param key databasename\0tablename\0
|
||||
@param key_length length of key in bytes, including the NUL bytes
|
||||
@param using_trx flag: TRUE if using transactions, FALSE otherwise
|
||||
*/
|
||||
void mysql_query_cache_invalidate4(MYSQL_THD thd,
|
||||
const char *key, unsigned int key_length,
|
||||
int using_trx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user