summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/aria_backup.h7
-rw-r--r--include/assume_aligned.h69
-rw-r--r--include/handler_ername.h1
-rw-r--r--include/hash.h17
-rw-r--r--include/heap.h6
-rw-r--r--include/ilist.h2
-rw-r--r--include/lf.h2
-rw-r--r--include/m_ctype.h617
-rw-r--r--include/m_string.h1
-rw-r--r--include/ma_dyncol.h2
-rw-r--r--include/maria.h325
-rw-r--r--include/my_alarm.h2
-rw-r--r--include/my_alloc.h6
-rw-r--r--include/my_atomic_wrapper.h11
-rw-r--r--include/my_base.h18
-rw-r--r--include/my_bit.h102
-rw-r--r--include/my_bitmap.h49
-rw-r--r--include/my_compare.h2
-rw-r--r--include/my_compiler.h8
-rw-r--r--include/my_cpu.h9
-rw-r--r--include/my_dbug.h11
-rw-r--r--include/my_default.h19
-rw-r--r--include/my_getopt.h8
-rw-r--r--include/my_global.h56
-rw-r--r--include/my_handler_errors.h2
-rw-r--r--include/my_pthread.h109
-rw-r--r--include/my_stack_alloc.h92
-rw-r--r--include/my_stacktrace.h14
-rw-r--r--include/my_sys.h126
-rw-r--r--include/my_valgrind.h20
-rw-r--r--include/myisam.h6
-rw-r--r--include/myisamchk.h25
-rw-r--r--include/myisammrg.h4
-rw-r--r--include/mysql.h11
-rw-r--r--include/mysql/plugin.h40
-rw-r--r--include/mysql/plugin_audit.h.pp197
-rw-r--r--include/mysql/plugin_auth.h.pp195
-rw-r--r--include/mysql/plugin_data_type.h49
-rw-r--r--include/mysql/plugin_data_type.h.pp629
-rw-r--r--include/mysql/plugin_encryption.h.pp193
-rw-r--r--include/mysql/plugin_ftparser.h.pp191
-rw-r--r--include/mysql/plugin_function.h54
-rw-r--r--include/mysql/plugin_function.h.pp638
-rw-r--r--include/mysql/plugin_password_validation.h.pp193
-rw-r--r--include/mysql/psi/mysql_file.h483
-rw-r--r--include/mysql/psi/mysql_idle.h8
-rw-r--r--include/mysql/psi/mysql_mdl.h143
-rw-r--r--include/mysql/psi/mysql_memory.h79
-rw-r--r--include/mysql/psi/mysql_ps.h108
-rw-r--r--include/mysql/psi/mysql_socket.h133
-rw-r--r--include/mysql/psi/mysql_sp.h104
-rw-r--r--include/mysql/psi/mysql_stage.h134
-rw-r--r--include/mysql/psi/mysql_statement.h27
-rw-r--r--include/mysql/psi/mysql_table.h93
-rw-r--r--include/mysql/psi/mysql_thread.h83
-rw-r--r--include/mysql/psi/mysql_transaction.h220
-rw-r--r--include/mysql/psi/psi.h910
-rw-r--r--include/mysql/psi/psi_abi_v0.h2
-rw-r--r--include/mysql/psi/psi_abi_v0.h.pp53
-rw-r--r--include/mysql/psi/psi_abi_v1.h2
-rw-r--r--include/mysql/psi/psi_abi_v1.h.pp286
-rw-r--r--include/mysql/psi/psi_abi_v2.h2
-rw-r--r--include/mysql/psi/psi_abi_v2.h.pp91
-rw-r--r--include/mysql/psi/psi_base.h39
-rw-r--r--include/mysql/psi/psi_memory.h24
-rw-r--r--include/mysql/service_my_crypt.h2
-rw-r--r--include/mysql/service_thd_mdl.h46
-rw-r--r--include/mysql/service_wsrep.h9
-rw-r--r--include/mysql_com.h29
-rw-r--r--include/mysys_err.h6
-rw-r--r--include/pfs_file_provider.h92
-rw-r--r--include/pfs_idle_provider.h48
-rw-r--r--include/pfs_memory_provider.h57
-rw-r--r--include/pfs_metadata_provider.h67
-rw-r--r--include/pfs_socket_provider.h71
-rw-r--r--include/pfs_stage_provider.h52
-rw-r--r--include/pfs_statement_provider.h118
-rw-r--r--include/pfs_table_provider.h83
-rw-r--r--include/pfs_thread_provider.h172
-rw-r--r--include/pfs_transaction_provider.h79
-rw-r--r--include/service_versions.h3
-rw-r--r--include/ssl_compat.h3
-rw-r--r--include/thr_lock.h2
-rw-r--r--include/thr_timer.h2
-rw-r--r--include/thread_pool_priv.h10
-rw-r--r--include/typelib.h5
-rw-r--r--include/violite.h5
87 files changed, 6486 insertions, 1637 deletions
diff --git a/include/aria_backup.h b/include/aria_backup.h
index 1a1c437d0b9..f399f6a6f40 100644
--- a/include/aria_backup.h
+++ b/include/aria_backup.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018 MariaDB corporation
+/* Copyright (C) 2018,2020 MariaDB Corporation 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
@@ -23,10 +23,15 @@ typedef struct st_aria_table_capabilities
ulong bitmap_pages_covered;
uint block_size;
uint keypage_header;
+ enum data_file_type data_file_type;
my_bool checksum;
my_bool transactional;
+ my_bool encrypted;
/* This is true if the table can be copied without any locks */
my_bool online_backup_safe;
+ /* s3 capabilities */
+ ulong s3_block_size;
+ uint8 compression;
} ARIA_TABLE_CAPABILITIES;
int aria_get_capabilities(File kfile, ARIA_TABLE_CAPABILITIES *cap);
diff --git a/include/assume_aligned.h b/include/assume_aligned.h
new file mode 100644
index 00000000000..e1b807c4794
--- /dev/null
+++ b/include/assume_aligned.h
@@ -0,0 +1,69 @@
+/*
+ Copyright (c) 2020, MariaDB Corporation.
+
+ 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-1335 USA */
+
+#pragma once
+
+#include <cassert>
+#include <cstring>
+
+#ifdef _MSC_VER
+template <std::size_t Alignment, class T>
+static inline T my_assume_aligned(T ptr)
+{
+ assert(reinterpret_cast<size_t>(ptr) % Alignment == 0);
+ __assume(reinterpret_cast<size_t>(ptr) % Alignment == 0);
+ return ptr;
+}
+#else
+template <std::size_t Alignment, class T>
+static inline T my_assume_aligned(T ptr)
+{
+ assert(reinterpret_cast<size_t>(ptr) % Alignment == 0);
+ return static_cast<T>(__builtin_assume_aligned(ptr, Alignment));
+}
+#endif
+
+template <std::size_t Alignment>
+inline void *memcpy_aligned(void *dest, const void *src, size_t n)
+{
+ static_assert(Alignment && !(Alignment & (Alignment - 1)), "power of 2");
+
+ return std::memcpy(my_assume_aligned<Alignment>(dest),
+ my_assume_aligned<Alignment>(src), n);
+}
+template <std::size_t Alignment>
+inline void *memmove_aligned(void *dest, const void *src, size_t n)
+{
+ static_assert(Alignment && !(Alignment & (Alignment - 1)), "power of 2");
+
+ return std::memmove(my_assume_aligned<Alignment>(dest),
+ my_assume_aligned<Alignment>(src), n);
+}
+template <std::size_t Alignment>
+inline int memcmp_aligned(const void *s1, const void *s2, size_t n)
+{
+ static_assert(Alignment && !(Alignment & (Alignment - 1)), "power of 2");
+
+ return std::memcmp(my_assume_aligned<Alignment>(s1),
+ my_assume_aligned<Alignment>(s2), n);
+}
+template <std::size_t Alignment>
+inline void *memset_aligned(void *s, int c, size_t n)
+{
+ static_assert(Alignment && !(Alignment & (Alignment - 1)), "power of 2");
+
+ return std::memset(my_assume_aligned<Alignment>(s), c, n);
+}
diff --git a/include/handler_ername.h b/include/handler_ername.h
index fe55062e6fb..c9d09717a14 100644
--- a/include/handler_ername.h
+++ b/include/handler_ername.h
@@ -79,3 +79,4 @@
{ "HA_ERR_ABORTED_BY_USER", HA_ERR_ABORTED_BY_USER, "" },
{ "HA_ERR_DISK_FULL", HA_ERR_DISK_FULL, "" },
{ "HA_ERR_INCOMPATIBLE_DEFINITION", HA_ERR_INCOMPATIBLE_DEFINITION, "" },
+{ "HA_ERR_COMMIT_ERROR", HA_ERR_COMMIT_ERROR, "" },
diff --git a/include/hash.h b/include/hash.h
index fd64bf4c5df..00ffca503fc 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -63,13 +63,12 @@ typedef struct st_hash {
/* A search iterator state */
typedef uint HASH_SEARCH_STATE;
-#define my_hash_init(A,B,C,D,E,F,G,H) my_hash_init2(A,0,B,C,D,E,F,0,G,H)
-my_bool my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
- ulong default_array_elements, size_t key_offset,
- size_t key_length, my_hash_get_key get_key,
- my_hash_function hash_function,
- void (*free_element)(void*),
- uint flags);
+#define my_hash_init(A,B,C,D,E,F,G,H,I) my_hash_init2(A,B,0,C,D,E,F,G,0,H,I)
+my_bool my_hash_init2(PSI_memory_key psi_key, HASH *hash, uint growth_size,
+ CHARSET_INFO *charset, ulong default_array_elements,
+ size_t key_offset, size_t key_length,
+ my_hash_get_key get_key, my_hash_function hash_function,
+ void (*free_element)(void*), uint flags);
void my_hash_free(HASH *tree);
void my_hash_reset(HASH *hash);
uchar *my_hash_element(HASH *hash, size_t idx);
@@ -99,8 +98,8 @@ my_bool my_hash_iterate(HASH *hash, my_hash_walk_action action, void *argument);
#define my_hash_clear(H) bzero((char*) (H), sizeof(*(H)))
#define my_hash_inited(H) ((H)->blength != 0)
-#define my_hash_init_opt(A,B,C,D,E,F,G,H) \
- (!my_hash_inited(A) && my_hash_init(A,B,C,D,E,F,G,H))
+#define my_hash_init_opt(A,B,C,D,E,F,G,H,I) \
+ (!my_hash_inited(B) && my_hash_init(A,B,C,D,E,F,G,H,I))
#ifdef __cplusplus
}
diff --git a/include/heap.h b/include/heap.h
index ca6efa48f1b..f0ac527976c 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -153,7 +153,6 @@ typedef struct st_heap_share
char * name; /* Name of "memory-file" */
time_t create_time;
THR_LOCK lock;
- mysql_mutex_t intern_lock; /* Locking for use with _locking */
my_bool delete_on_close;
my_bool internal; /* Internal temporary table */
LIST open_list;
@@ -240,8 +239,9 @@ extern int heap_disable_indexes(HP_INFO *info);
extern int heap_enable_indexes(HP_INFO *info);
extern int heap_indexes_are_disabled(HP_INFO *info);
extern void heap_update_auto_increment(HP_INFO *info, const uchar *record);
-ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key,
- key_range *max_key);
+ha_rows hp_rb_records_in_range(HP_INFO *info, int inx,
+ const key_range *min_key,
+ const key_range *max_key);
int hp_panic(enum ha_panic_function flag);
int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key,
key_part_map keypart_map, enum ha_rkey_function find_flag);
diff --git a/include/ilist.h b/include/ilist.h
index 6e7219937dd..92812ba8f5d 100644
--- a/include/ilist.h
+++ b/include/ilist.h
@@ -94,7 +94,7 @@ public:
Iterator &operator--() noexcept
{
node_= node_->prev;
- DBUG_ASSERT(node_);
+ DBUG_ASSERT(node_ != nullptr);
return *this;
}
Iterator operator--(int) noexcept
diff --git a/include/lf.h b/include/lf.h
index 88ac644c349..267a66aeeaf 100644
--- a/include/lf.h
+++ b/include/lf.h
@@ -125,7 +125,7 @@ void *lf_alloc_new(LF_PINS *pins);
C_MODE_END
/*
- extendible hash, lf_hash.c
+ extendible hash, lf_hash.cc
*/
#include <hash.h>
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 187c8710929..32cede0baaf 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2020, MariaDB Corporation.
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
@@ -45,6 +46,19 @@ extern "C" {
#define MY_CS_REPLACEMENT_CHARACTER 0xFFFD
+/**
+ Maximum character length of a string produced by wc_to_printable().
+ Note, wc_to_printable() is currently limited to BMP.
+ One non-printable or non-convertable character can produce a string
+ with at most 5 characters: \hhhh.
+ If we ever modify wc_to_printable() to support supplementary characters,
+ e.g. \+hhhhhh, this constant should be changed to 8.
+ Note, maximum octet length of a wc_to_printable() result can be calculated
+ as: (MY_CS_PRINTABLE_CHAR_LENGTH*cs->mbminlen).
+*/
+#define MY_CS_PRINTABLE_CHAR_LENGTH 5
+
+
/*
On i386 we store Unicode->CS conversion tables for
some character sets using Big-endian order,
@@ -212,9 +226,14 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
#define MY_CHARSET_UNDEFINED 0
/* Character repertoire flags */
-#define MY_REPERTOIRE_ASCII 1 /* Pure ASCII U+0000..U+007F */
-#define MY_REPERTOIRE_EXTENDED 2 /* Extended characters: U+0080..U+FFFF */
-#define MY_REPERTOIRE_UNICODE30 3 /* ASCII | EXTENDED: U+0000..U+FFFF */
+typedef enum enum_repertoire_t
+{
+ MY_REPERTOIRE_NONE= 0,
+ MY_REPERTOIRE_ASCII= 1, /* Pure ASCII U+0000..U+007F */
+ MY_REPERTOIRE_EXTENDED= 2, /* Extended characters: U+0080..U+FFFF */
+ MY_REPERTOIRE_UNICODE30= 3 /* ASCII | EXTENDED: U+0000..U+FFFF */
+} my_repertoire_t;
+
/* Flags for strxfrm */
#define MY_STRXFRM_LEVEL1 0x00000001 /* for primary weights */
@@ -578,14 +597,15 @@ struct my_charset_handler_st
- MB3 native code is ((b0 <<16) + (b1 << 8) + b2)
Note, CHARSET_INFO::min_sort_char and CHARSET_INFO::max_sort_char
are defined in native notation and should be written using
- cs->cset->native_to_mb() rather than cs->cset->wc_mb().
+ my_ci_native_to_mb() rather than my_ci_wc_mb().
*/
my_charset_conv_wc_mb native_to_mb;
+ my_charset_conv_wc_mb wc_to_printable;
};
extern MY_CHARSET_HANDLER my_charset_8bit_handler;
extern MY_CHARSET_HANDLER my_charset_ucs2_handler;
-extern MY_CHARSET_HANDLER my_charset_utf8_handler;
+extern MY_CHARSET_HANDLER my_charset_utf8mb3_handler;
/*
@@ -594,6 +614,7 @@ extern MY_CHARSET_HANDLER my_charset_utf8_handler;
*/
#define CHARSET_INFO_DEFINED
+
/* See strings/CHARSET_INFO.txt about information on this structure */
struct charset_info_st
{
@@ -605,7 +626,7 @@ struct charset_info_st
const char *name;
const char *comment;
const char *tailoring;
- const uchar *ctype;
+ const uchar *m_ctype;
const uchar *to_lower;
const uchar *to_upper;
const uchar *sort_order;
@@ -628,15 +649,514 @@ struct charset_info_st
MY_CHARSET_HANDLER *cset;
MY_COLLATION_HANDLER *coll;
-
+
+#ifdef __cplusplus
+ /* Character set routines */
+ bool use_mb() const
+ {
+ return mbmaxlen > 1;
+ }
+
+ size_t numchars(const char *b, const char *e) const
+ {
+ return (cset->numchars)(this, b, e);
+ }
+
+ size_t charpos(const char *b, const char *e, size_t pos) const
+ {
+ return (cset->charpos)(this, b, e, pos);
+ }
+ size_t charpos(const uchar *b, const uchar *e, size_t pos) const
+ {
+ return (cset->charpos)(this, (const char *) b, (const char*) e, pos);
+ }
+
+ size_t lengthsp(const char *str, size_t length) const
+ {
+ return (cset->lengthsp)(this, str, length);
+ }
+
+ size_t numcells(const char *b, const char *e) const
+ {
+ return (cset->numcells)(this, b, e);
+ }
+
+ size_t caseup(const char *src, size_t srclen,
+ char *dst, size_t dstlen) const
+ {
+ return (cset->caseup)(this, src, srclen, dst, dstlen);
+ }
+
+ size_t casedn(const char *src, size_t srclen,
+ char *dst, size_t dstlen) const
+ {
+ return (cset->casedn)(this, src, srclen, dst, dstlen);
+ }
+
+ size_t long10_to_str(char *dst, size_t dstlen,
+ int radix, long int val) const
+ {
+ return (cset->long10_to_str)(this, dst, dstlen, radix, val);
+ }
+
+ size_t (longlong10_to_str)(char *dst, size_t dstlen,
+ int radix, longlong val) const
+ {
+ return (cset->longlong10_to_str)(this, dst, dstlen, radix, val);
+ }
+
+ int mb_wc(my_wc_t *wc, const uchar *b, const uchar *e) const
+ {
+ return (cset->mb_wc)(this, wc, b, e);
+ }
+
+ int wc_mb(my_wc_t wc, uchar *s, uchar *e) const
+ {
+ return (cset->wc_mb)(this, wc, s, e);
+ }
+
+ int native_to_mb(my_wc_t wc, uchar *s, uchar *e) const
+ {
+ return (cset->native_to_mb)(this, wc, s, e);
+ }
+
+ int wc_to_printable(my_wc_t wc, uchar *s, uchar *e) const
+ {
+ return (cset->wc_to_printable)(this, wc, s, e);
+ }
+
+ int ctype(int *to, const uchar *s, const uchar *e) const
+ {
+ return (cset->ctype)(this, to, s, e);
+ }
+
+ void fill(char *to, size_t len, int ch) const
+ {
+ (cset->fill)(this, to, len, ch);
+ }
+
+ long strntol(const char *str, size_t length,
+ int base, char **endptr, int *error) const
+ {
+ return (cset->strntol)(this, str, length, base, endptr, error);
+ }
+
+ ulong strntoul(const char *str, size_t length,
+ int base, char **endptr, int *error) const
+ {
+ return (cset->strntoul)(this, str, length, base, endptr, error);
+ }
+
+ longlong strntoll(const char *str, size_t length,
+ int base, char **endptr, int *error) const
+ {
+ return (cset->strntoll)(this, str, length, base, endptr, error);
+ }
+
+ ulonglong strntoull(const char *str, size_t length,
+ int base, char **endptr, int *error) const
+ {
+ return (cset->strntoull)(this, str, length, base, endptr, error);
+ }
+
+ double strntod(char *str, size_t length,
+ char **endptr, int *error) const
+ {
+ return (cset->strntod)(this, str, length, endptr, error);
+ }
+
+ longlong strtoll10(const char *str, char **endptr, int *error) const
+ {
+ return (cset->strtoll10)(this, str, endptr, error);
+ }
+
+ ulonglong strntoull10rnd(const char *str, size_t length, int unsigned_fl,
+ char **endptr, int *error) const
+ {
+ return (cset->strntoull10rnd)(this, str, length, unsigned_fl, endptr, error);
+ }
+
+ size_t scan(const char *b, const char *e, int seq) const
+ {
+ return (cset->scan)(this, b, e, seq);
+ }
+
+ int charlen(const uchar *str, const uchar *end) const
+ {
+ return (cset->charlen)(this, str, end);
+ }
+ int charlen(const char *str, const char *end) const
+ {
+ return (cset->charlen)(this, (const uchar *) str, (const uchar *) end);
+ }
+
+ uint charlen_fix(const uchar *str, const uchar *end) const
+ {
+ int char_length= (cset->charlen)(this, str, end);
+ DBUG_ASSERT(str < end);
+ return char_length > 0 ? (uint) char_length : (uint) 1U;
+ }
+ uint charlen_fix(const char *str, const char *end) const
+ {
+ return charlen_fix((const uchar *) str, (const uchar *) end);
+ }
+
+ size_t well_formed_char_length(const char *str, const char *end,
+ size_t nchars,
+ MY_STRCOPY_STATUS *status) const
+ {
+ return (cset->well_formed_char_length)(this, str, end, nchars, status);
+ }
+
+ size_t copy_fix(char *dst, size_t dst_length,
+ const char *src, size_t src_length,
+ size_t nchars, MY_STRCOPY_STATUS *status) const
+ {
+ return (cset->copy_fix)(this, dst, dst_length, src, src_length, nchars,
+ status);
+ }
+
+ /* Collation routines */
+ int strnncoll(const uchar *a, size_t alen,
+ const uchar *b, size_t blen, my_bool b_is_prefix= FALSE) const
+ {
+ return (coll->strnncoll)(this, a, alen, b, blen, b_is_prefix);
+ }
+ int strnncoll(const char *a, size_t alen,
+ const char *b, size_t blen, my_bool b_is_prefix= FALSE) const
+ {
+ return (coll->strnncoll)(this,
+ (const uchar *) a, alen,
+ (const uchar *) b, blen, b_is_prefix);
+ }
+
+ int strnncollsp(const uchar *a, size_t alen,
+ const uchar *b, size_t blen) const
+ {
+ return (coll->strnncollsp)(this, a, alen, b, blen);
+ }
+ int strnncollsp(const char *a, size_t alen,
+ const char *b, size_t blen) const
+ {
+ return (coll->strnncollsp)(this, (uchar *) a, alen, (uchar *) b, blen);
+ }
+
+ size_t strnxfrm(char *dst, size_t dstlen, uint nweights,
+ const char *src, size_t srclen, uint flags) const
+ {
+ return (coll->strnxfrm)(this,
+ (uchar *) dst, dstlen, nweights,
+ (const uchar *) src, srclen, flags);
+ }
+ size_t strnxfrm(uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags) const
+ {
+ return (coll->strnxfrm)(this,
+ dst, dstlen, nweights,
+ src, srclen, flags);
+ }
+ size_t strnxfrm(uchar *dst, size_t dstlen,
+ const uchar *src, size_t srclen) const
+ {
+ return (coll->strnxfrm)(this,
+ dst, dstlen, (uint) dstlen,
+ src, srclen, MY_STRXFRM_PAD_WITH_SPACE);
+ }
+
+ size_t strnxfrmlen(size_t length) const
+ {
+ return (coll->strnxfrmlen)(this, length);
+ }
+
+ my_bool like_range(const char *s, size_t s_length,
+ pchar w_prefix, pchar w_one, pchar w_many,
+ size_t res_length,
+ char *min_str, char *max_str,
+ size_t *min_len, size_t *max_len) const
+ {
+ return (coll->like_range)(this, s, s_length,
+ w_prefix, w_one, w_many,
+ res_length, min_str, max_str,
+ min_len, max_len);
+ }
+
+ int wildcmp(const char *str,const char *str_end,
+ const char *wildstr,const char *wildend,
+ int escape,int w_one, int w_many) const
+ {
+ return (coll->wildcmp)(this, str, str_end, wildstr, wildend, escape, w_one, w_many);
+ }
+
+ uint instr(const char *b, size_t b_length,
+ const char *s, size_t s_length,
+ my_match_t *match, uint nmatch) const
+ {
+ return (coll->instr)(this, b, b_length, s, s_length, match, nmatch);
+ }
+
+ void hash_sort(const uchar *key, size_t len, ulong *nr1, ulong *nr2) const
+ {
+ (coll->hash_sort)(this, key, len, nr1, nr2);
+ }
+
+ my_bool propagate(const uchar *str, size_t len) const
+ {
+ return (coll->propagate)(this, str, len);
+ }
+
+#endif /* __cplusplus */
};
+
+
+/* Character set routines */
+
+static inline my_bool
+my_ci_init_charset(struct charset_info_st *ci, MY_CHARSET_LOADER *loader)
+{
+ if (!ci->cset->init)
+ return FALSE;
+ return (ci->cset->init)(ci, loader);
+}
+
+
+static inline my_bool
+my_ci_use_mb(CHARSET_INFO *ci)
+{
+ return ci->mbmaxlen > 1 ? TRUE : FALSE;
+}
+
+static inline size_t
+my_ci_numchars(CHARSET_INFO *cs, const char *b, const char *e)
+{
+ return (cs->cset->numchars)(cs, b, e);
+}
+
+static inline size_t
+my_ci_charpos(CHARSET_INFO *cs, const char *b, const char *e, size_t pos)
+{
+ return (cs->cset->charpos)(cs, b, e, pos);
+}
+
+static inline size_t
+my_ci_lengthsp(CHARSET_INFO *cs, const char *str, size_t length)
+{
+ return (cs->cset->lengthsp)(cs, str, length);
+}
+
+static inline size_t
+my_ci_numcells(CHARSET_INFO *cs, const char *b, const char *e)
+{
+ return (cs->cset->numcells)(cs, b, e);
+}
+
+static inline size_t
+my_ci_caseup(CHARSET_INFO *ci,
+ const char *src, size_t srclen,
+ char *dst, size_t dstlen)
+{
+ return (ci->cset->caseup)(ci, src, srclen, dst, dstlen);
+}
+
+static inline size_t
+my_ci_casedn(CHARSET_INFO *ci,
+ const char *src, size_t srclen,
+ char *dst, size_t dstlen)
+{
+ return (ci->cset->casedn)(ci, src, srclen, dst, dstlen);
+}
+
+static inline size_t
+my_ci_long10_to_str(CHARSET_INFO *cs, char *dst, size_t dstlen,
+ int radix, long int val)
+{
+ return (cs->cset->long10_to_str)(cs, dst, dstlen, radix, val);
+}
+
+static inline size_t
+my_ci_longlong10_to_str(CHARSET_INFO *cs, char *dst, size_t dstlen,
+ int radix, longlong val)
+{
+ return (cs->cset->longlong10_to_str)(cs, dst, dstlen, radix, val);
+}
+
+#define my_ci_mb_wc(s, pwc, b, e) ((s)->cset->mb_wc)(s, pwc, b, e)
+#define my_ci_wc_mb(s, wc, b, e) ((s)->cset->wc_mb)(s, wc, b, e)
+#define my_ci_native_to_mb(s, wc, b, e) ((s)->cset->native_to_mb)(s, wc, b, e)
+#define my_ci_ctype(s, pctype, b, e) ((s)->cset->ctype)(s, pctype, b, e)
+
+static inline void
+my_ci_fill(CHARSET_INFO *cs, char *to, size_t len, int ch)
+{
+ (cs->cset->fill)(cs, to, len, ch);
+}
+
+static inline long
+my_ci_strntol(CHARSET_INFO *cs, const char *str, size_t length,
+ int base, char **endptr, int *error)
+{
+ return (cs->cset->strntol)(cs, str, length, base, endptr, error);
+}
+
+static inline ulong
+my_ci_strntoul(CHARSET_INFO *cs, const char *str, size_t length,
+ int base, char **endptr, int *error)
+{
+ return (cs->cset->strntoul)(cs, str, length, base, endptr, error);
+}
+
+static inline longlong
+my_ci_strntoll(CHARSET_INFO *cs, const char *str, size_t length,
+ int base, char **endptr, int *error)
+{
+ return (cs->cset->strntoll)(cs, str, length, base, endptr, error);
+}
+
+static inline ulonglong
+my_ci_strntoull(CHARSET_INFO *cs, const char *str, size_t length,
+ int base, char **endptr, int *error)
+{
+ return (cs->cset->strntoull)(cs, str, length, base, endptr, error);
+}
+
+static inline double
+my_ci_strntod(CHARSET_INFO *cs, char *str, size_t length,
+ char **endptr, int *error)
+{
+ return (cs->cset->strntod)(cs, str, length, endptr, error);
+}
+
+static inline longlong
+my_ci_strtoll10(CHARSET_INFO *cs, const char *str, char **endptr, int *error)
+{
+ return (cs->cset->strtoll10)(cs, str, endptr, error);
+}
+
+static inline ulonglong
+my_ci_strntoull10rnd(CHARSET_INFO *cs,
+ const char *str, size_t length, int unsigned_fl,
+ char **endptr, int *error)
+{
+ return (cs->cset->strntoull10rnd)(cs, str, length, unsigned_fl, endptr, error);
+}
+
+
+static inline size_t
+my_ci_scan(CHARSET_INFO *cs, const char *b, const char *e, int seq)
+{
+ return (cs->cset->scan)(cs, b, e, seq);
+}
+
+
+/**
+ Return length of the leftmost character in a string.
+ @param cs - character set
+ @param str - the beginning of the string
+ @param end - the string end (the next byte after the string)
+ @return <=0 on errors (EOL, wrong byte sequence)
+ @return 1 on a single byte character
+ @return >1 on a multi-byte character
+
+ Note, inlike my_ismbchar(), 1 is returned for a single byte character.
+*/
+
+static inline int
+my_ci_charlen(CHARSET_INFO *cs, const uchar *str, const uchar *end)
+{
+ return (cs->cset->charlen)(cs, str, end);
+}
+
+
+static inline size_t
+my_ci_well_formed_char_length(CHARSET_INFO *cs,
+ const char *str, const char *end,
+ size_t nchars,
+ MY_STRCOPY_STATUS *status)
+{
+ return (cs->cset->well_formed_char_length)(cs, str, end, nchars, status);
+}
+
+
+static inline size_t
+my_ci_copy_fix(CHARSET_INFO *cs,
+ char *dst, size_t dst_length,
+ const char *src, size_t src_length,
+ size_t nchars, MY_STRCOPY_STATUS *status)
+{
+ return (cs->cset->copy_fix)(cs, dst, dst_length, src, src_length, nchars,
+ status);
+}
+
+
+/* Collation routines */
+
+static inline my_bool
+my_ci_init_collation(struct charset_info_st *ci, MY_CHARSET_LOADER *loader)
+{
+ if (!ci->coll->init)
+ return FALSE;
+ return (ci->coll->init)(ci, loader);
+}
+
+
+static inline int
+my_ci_strnncoll(CHARSET_INFO *ci,
+ const uchar *a, size_t alen,
+ const uchar *b, size_t blen,
+ my_bool b_is_prefix)
+{
+ return (ci->coll->strnncoll)(ci, a, alen, b, blen, b_is_prefix);
+}
+
+static inline int
+my_ci_strnncollsp(CHARSET_INFO *ci,
+ const uchar *a, size_t alen,
+ const uchar *b, size_t blen)
+{
+ return (ci->coll->strnncollsp)(ci, a, alen, b, blen);
+}
+
+
+static inline my_bool
+my_ci_like_range(CHARSET_INFO *ci,
+ const char *s, size_t s_length,
+ pchar w_prefix, pchar w_one, pchar w_many,
+ size_t res_length,
+ char *min_str, char *max_str,
+ size_t *min_len, size_t *max_len)
+{
+ return (ci->coll->like_range)(ci, s, s_length,
+ w_prefix, w_one, w_many,
+ res_length, min_str, max_str,
+ min_len, max_len);
+}
+
+
+static inline uint
+my_ci_instr(CHARSET_INFO *ci,
+ const char *b, size_t b_length,
+ const char *s, size_t s_length,
+ my_match_t *match, uint nmatch)
+{
+ return (ci->coll->instr)(ci, b, b_length, s, s_length, match, nmatch);
+}
+
+
+static inline void
+my_ci_hash_sort(CHARSET_INFO *ci,
+ const uchar *key, size_t len,
+ ulong *nr1, ulong *nr2)
+{
+ (ci->coll->hash_sort)(ci, key, len, nr1, nr2);
+}
+
+
#define ILLEGAL_CHARSET_INFO_NUMBER (~0U)
extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_bin;
extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_latin1;
extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_latin1_nopad;
extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_filename;
-extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8_general_ci;
+extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8mb3_general_ci;
extern struct charset_info_st my_charset_big5_bin;
extern struct charset_info_st my_charset_big5_chinese_ci;
@@ -703,13 +1223,13 @@ extern struct charset_info_st my_charset_utf32_unicode_ci;
extern struct charset_info_st my_charset_utf32_unicode_nopad_ci;
extern struct charset_info_st my_charset_utf32_nopad_bin;
extern struct charset_info_st my_charset_utf32_general_nopad_ci;
-extern struct charset_info_st my_charset_utf8_bin;
-extern struct charset_info_st my_charset_utf8_nopad_bin;
-extern struct charset_info_st my_charset_utf8_general_nopad_ci;
-extern struct charset_info_st my_charset_utf8_general_mysql500_ci;
-extern struct charset_info_st my_charset_utf8_unicode_ci;
-extern struct charset_info_st my_charset_utf8_unicode_nopad_ci;
-extern struct charset_info_st my_charset_utf8mb4_bin;
+extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8mb3_bin;
+extern struct charset_info_st my_charset_utf8mb3_nopad_bin;
+extern struct charset_info_st my_charset_utf8mb3_general_nopad_ci;
+extern struct charset_info_st my_charset_utf8mb3_general_mysql500_ci;
+extern struct charset_info_st my_charset_utf8mb3_unicode_ci;
+extern struct charset_info_st my_charset_utf8mb3_unicode_nopad_ci;
+extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8mb4_bin;
extern struct charset_info_st my_charset_utf8mb4_general_ci;
extern struct charset_info_st my_charset_utf8mb4_nopad_bin;
extern struct charset_info_st my_charset_utf8mb4_general_nopad_ci;
@@ -959,14 +1479,15 @@ my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, size_t len);
typedef struct
{
size_t char_length;
- uint repertoire;
+ my_repertoire_t repertoire;
} MY_STRING_METADATA;
void my_string_metadata_get(MY_STRING_METADATA *metadata,
CHARSET_INFO *cs, const char *str, size_t len);
-uint my_string_repertoire(CHARSET_INFO *cs, const char *str, size_t len);
+my_repertoire_t my_string_repertoire(CHARSET_INFO *cs,
+ const char *str, size_t len);
my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
-uint my_charset_repertoire(CHARSET_INFO *cs);
+my_repertoire_t my_charset_repertoire(CHARSET_INFO *cs);
uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
@@ -1051,17 +1572,17 @@ size_t my_convert_fix(CHARSET_INFO *dstcs, char *dst, size_t dst_length,
#define my_toprint(c) ((c) | 64)
#define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)])
#define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)])
-#define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L))
-#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_U)
-#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_L)
-#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_NMR)
-#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X)
-#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR))
-#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_SPC)
-#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_PNT)
-#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B))
-#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR))
-#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_CTR)
+#define my_isalpha(s, c) (((s)->m_ctype+1)[(uchar) (c)] & (_MY_U | _MY_L))
+#define my_isupper(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_U)
+#define my_islower(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_L)
+#define my_isdigit(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_NMR)
+#define my_isxdigit(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_X)
+#define my_isalnum(s, c) (((s)->m_ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR))
+#define my_isspace(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_SPC)
+#define my_ispunct(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_PNT)
+#define my_isprint(s, c) (((s)->m_ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B))
+#define my_isgraph(s, c) (((s)->m_ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR))
+#define my_iscntrl(s, c) (((s)->m_ctype+1)[(uchar) (c)] & _MY_CTR)
/* Some macros that should be cleaned up a little */
#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_')
@@ -1069,16 +1590,9 @@ size_t my_convert_fix(CHARSET_INFO *dstcs, char *dst, size_t dst_length,
#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT)
#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM)
-#define my_strnxfrm(cs, d, dl, s, sl) \
- ((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE))
#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
-#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
- ((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
-#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m)))
#define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b)))
-#define my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num))
-#define use_mb(s) ((s)->mbmaxlen > 1)
/**
Detect if the leftmost character in a string is a valid multi-byte character
and return its length, or return 0 otherwise.
@@ -1098,31 +1612,12 @@ uint my_ismbchar(CHARSET_INFO *cs, const char *str, const char *end)
/**
- Return length of the leftmost character in a string.
- @param cs - character set
- @param str - the beginning of the string
- @param end - the string end (the next byte after the string)
- @return <=0 on errors (EOL, wrong byte sequence)
- @return 1 on a single byte character
- @return >1 on a multi-byte character
-
- Note, inlike my_ismbchar(), 1 is returned for a single byte character.
-*/
-static inline
-int my_charlen(CHARSET_INFO *cs, const char *str, const char *end)
-{
- return (cs->cset->charlen)(cs, (const uchar *) str,
- (const uchar *) end);
-}
-
-
-/**
Convert broken and incomplete byte sequences to 1 byte.
*/
static inline
-uint my_charlen_fix(CHARSET_INFO *cs, const char *str, const char *end)
+uint my_ci_charlen_fix(CHARSET_INFO *cs, const uchar *str, const uchar *end)
{
- int char_length= my_charlen(cs, str, end);
+ int char_length= my_ci_charlen(cs, str, end);
DBUG_ASSERT(str < end);
return char_length > 0 ? (uint) char_length : (uint) 1U;
}
@@ -1138,7 +1633,7 @@ my_well_formed_length(CHARSET_INFO *cs, const char *b, const char *e,
size_t nchars, int *error)
{
MY_STRCOPY_STATUS status;
- (void) cs->cset->well_formed_char_length(cs, b, e, nchars, &status);
+ (void) my_ci_well_formed_char_length(cs, b, e, nchars, &status);
*error= status.m_well_formed_error_pos == NULL ? 0 : 1;
return (size_t) (status.m_source_end_pos - b);
}
@@ -1146,12 +1641,6 @@ my_well_formed_length(CHARSET_INFO *cs, const char *b, const char *e,
#define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a)))
#define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a)))
-#define my_strntol(s, a, b, c, d, e) ((s)->cset->strntol((s),(a),(b),(c),(d),(e)))
-#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e)))
-#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e)))
-#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e)))
-#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d)))
-
/* XXX: still need to take care of this one */
#ifdef MY_CHARSET_TIS620
diff --git a/include/m_string.h b/include/m_string.h
index 2747a9a7a9f..e4c11d24c0b 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -1,5 +1,6 @@
/*
Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+ Copyright (c) 2019, MariaDB Corporation.
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
diff --git a/include/ma_dyncol.h b/include/ma_dyncol.h
index 4f05b425afd..833a25b937e 100644
--- a/include/ma_dyncol.h
+++ b/include/ma_dyncol.h
@@ -66,7 +66,7 @@ typedef struct st_mysql_lex_string LEX_STRING;
#ifdef HAVE_CHARSET_utf8mb4
#define DYNCOL_UTF (&my_charset_utf8mb4_general_ci)
#else
-#define DYNCOL_UTF (&my_charset_utf8_general_ci)
+#define DYNCOL_UTF (&my_charset_utf8mb3_general_ci)
#endif
/* escape json strings */
diff --git a/include/maria.h b/include/maria.h
index a946363c57b..7fdf95f7ac4 100644
--- a/include/maria.h
+++ b/include/maria.h
@@ -29,146 +29,19 @@
extern "C" {
#endif
-#define MARIA_CANNOT_ROLLBACK
-
-/*
- Limit max keys according to HA_MAX_POSSIBLE_KEY; See myisamchk.h for details
-*/
-
-#if MAX_INDEXES > HA_MAX_POSSIBLE_KEY
-#define MARIA_MAX_KEY HA_MAX_POSSIBLE_KEY /* Max allowed keys */
-#else
-#define MARIA_MAX_KEY MAX_INDEXES /* Max allowed keys */
-#endif
-
-#define MARIA_NAME_IEXT ".MAI"
-#define MARIA_NAME_DEXT ".MAD"
-/* Max extra space to use when sorting keys */
-#define MARIA_MAX_TEMP_LENGTH (2*1024L*1024L*1024L)
-/* Possible values for maria_block_size (must be power of 2) */
-#define MARIA_KEY_BLOCK_LENGTH 8192 /* default key block length */
-#define MARIA_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */
-#define MARIA_MAX_KEY_BLOCK_LENGTH 32768
-/* Minimal page cache when we only want to be able to scan a table */
-#define MARIA_MIN_PAGE_CACHE_SIZE (8192L*16L)
-
-/*
- In the following macros '_keyno_' is 0 .. keys-1.
- If there can be more keys than bits in the key_map, the highest bit
- is for all upper keys. They cannot be switched individually.
- This means that clearing of high keys is ignored, setting one high key
- sets all high keys.
-*/
-#define MARIA_KEYMAP_BITS (8 * SIZEOF_LONG_LONG)
-#define MARIA_KEYMAP_HIGH_MASK (1ULL << (MARIA_KEYMAP_BITS - 1))
-#define maria_get_mask_all_keys_active(_keys_) \
- (((_keys_) < MARIA_KEYMAP_BITS) ? \
- ((1ULL << (_keys_)) - 1ULL) : \
- (~ 0ULL))
-#if MARIA_MAX_KEY > MARIA_KEYMAP_BITS
-#define maria_is_key_active(_keymap_,_keyno_) \
- (((_keyno_) < MARIA_KEYMAP_BITS) ? \
- MY_TEST((_keymap_) & (1ULL << (_keyno_))) : \
- MY_TEST((_keymap_) & MARIA_KEYMAP_HIGH_MASK))
-#define maria_set_key_active(_keymap_,_keyno_) \
- (_keymap_)|= (((_keyno_) < MARIA_KEYMAP_BITS) ? \
- (1ULL << (_keyno_)) : \
- MARIA_KEYMAP_HIGH_MASK)
-#define maria_clear_key_active(_keymap_,_keyno_) \
- (_keymap_)&= (((_keyno_) < MARIA_KEYMAP_BITS) ? \
- (~ (1ULL << (_keyno_))) : \
- (~ (0ULL)) /*ignore*/ )
-#else
-#define maria_is_key_active(_keymap_,_keyno_) \
- MY_TEST((_keymap_) & (1ULL << (_keyno_)))
-#define maria_set_key_active(_keymap_,_keyno_) \
- (_keymap_)|= (1ULL << (_keyno_))
-#define maria_clear_key_active(_keymap_,_keyno_) \
- (_keymap_)&= (~ (1ULL << (_keyno_)))
-#endif
-#define maria_is_any_key_active(_keymap_) \
- MY_TEST((_keymap_))
-#define maria_is_all_keys_active(_keymap_,_keys_) \
- ((_keymap_) == maria_get_mask_all_keys_active(_keys_))
-#define maria_set_all_keys_active(_keymap_,_keys_) \
- (_keymap_)= maria_get_mask_all_keys_active(_keys_)
-#define maria_clear_all_keys_active(_keymap_) \
- (_keymap_)= 0
-#define maria_intersect_keys_active(_to_,_from_) \
- (_to_)&= (_from_)
-#define maria_is_any_intersect_keys_active(_keymap1_,_keys_,_keymap2_) \
- ((_keymap1_) & (_keymap2_) & \
- maria_get_mask_all_keys_active(_keys_))
-#define maria_copy_keys_active(_to_,_maxkeys_,_from_) \
- (_to_)= (maria_get_mask_all_keys_active(_maxkeys_) & \
- (_from_))
-
- /* Param to/from maria_info */
-
-typedef ulonglong MARIA_RECORD_POS;
-
-typedef struct st_maria_info
-{
- ha_rows records; /* Records in database */
- ha_rows deleted; /* Deleted records in database */
- MARIA_RECORD_POS recpos; /* Pos for last used record */
- MARIA_RECORD_POS newrecpos; /* Pos if we write new record */
- MARIA_RECORD_POS dup_key_pos; /* Position to record with dup key */
- my_off_t data_file_length; /* Length of data file */
- my_off_t max_data_file_length, index_file_length;
- my_off_t max_index_file_length, delete_length;
- ulonglong auto_increment;
- ulonglong key_map; /* Which keys are used */
- time_t create_time; /* When table was created */
- time_t check_time;
- time_t update_time;
- ulong record_offset;
- double *rec_per_key; /* for sql optimizing */
- ulong reclength; /* Recordlength */
- ulong mean_reclength; /* Mean recordlength (if packed) */
- char *data_file_name, *index_file_name;
- enum data_file_type data_file_type;
- uint keys; /* Number of keys in use */
- uint options; /* HA_OPTION_... used */
- uint reflength;
- int errkey, /* With key was dupplicated on err */
- sortkey; /* clustered by this key */
- File filenr; /* (uniq) filenr for datafile */
-} MARIA_INFO;
-
-
-typedef struct st_maria_create_info
-{
- const char *index_file_name, *data_file_name; /* If using symlinks */
- ha_rows max_rows;
- ha_rows reloc_rows;
- ulonglong auto_increment;
- ulonglong data_file_length;
- ulonglong key_file_length;
- /* Size of null bitmap at start of row */
- uint null_bytes;
- uint old_options;
- enum data_file_type org_data_file_type;
- uint16 language;
- my_bool with_auto_increment, transactional;
-} MARIA_CREATE_INFO;
+#define MARIA_UNIQUE_HASH_LENGTH 4
+extern my_bool maria_delay_key_write;
+uint maria_max_key_length(void);
+#define maria_max_key_segments() HA_MAX_KEY_SEG
+struct st_maria_bit_buff;
+struct st_maria_page;
+struct st_maria_s_param;
struct st_maria_share;
-struct st_maria_handler; /* For referense */
+typedef struct st_maria_decode_tree MARIA_DECODE_TREE;
typedef struct st_maria_handler MARIA_HA;
-struct st_maria_s_param;
-struct st_maria_keydef;
-struct st_maria_page;
-
-typedef struct st_maria_key /* Internal info about a key */
-{
- uchar *data; /* Data for key */
- struct st_maria_keydef *keyinfo; /* Definition for key */
- uint data_length; /* Length of key data */
- uint ref_length; /* record ref + transid */
- uint32 flag; /* 0 or SEARCH_PART_KEY */
-} MARIA_KEY;
-
+typedef struct st_maria_key MARIA_KEY;
+typedef ulonglong MARIA_RECORD_POS;
typedef struct st_maria_keydef /* Key definition with open & info */
{
@@ -184,6 +57,7 @@ typedef struct st_maria_keydef /* Key definition with open & info */
uint16 keylength; /* Tot length of keyparts (auto) */
uint16 minlength; /* min length of (packed) key (auto) */
uint16 maxlength; /* max length of (packed) key (auto) */
+ uint16 max_store_length; /* Size to store key + overhead */
uint32 write_comp_flag; /* compare flag for write key (auto) */
uint32 version; /* For concurrent read/write */
uint32 ftkey_nr; /* full-text index number */
@@ -210,8 +84,6 @@ typedef struct st_maria_keydef /* Key definition with open & info */
} MARIA_KEYDEF;
-#define MARIA_UNIQUE_HASH_LENGTH 4
-
typedef struct st_maria_unique_def /* Segment definition of unique */
{
uint16 keysegs; /* Number of key-segment */
@@ -220,16 +92,6 @@ typedef struct st_maria_unique_def /* Segment definition of unique */
HA_KEYSEG *seg, *end;
} MARIA_UNIQUEDEF;
-typedef struct st_maria_decode_tree /* Decode huff-table */
-{
- uint16 *table;
- uint quick_table_bits;
- uchar *intervalls;
-} MARIA_DECODE_TREE;
-
-
-struct st_maria_bit_buff;
-
/*
Note that null markers should always be first in a row !
When creating a column, one should only specify:
@@ -261,155 +123,32 @@ typedef struct st_maria_columndef /* column information */
} MARIA_COLUMNDEF;
-extern ulong maria_block_size, maria_checkpoint_frequency;
-extern ulong maria_concurrent_insert;
-extern my_bool maria_flush, maria_single_user, maria_page_checksums;
-extern my_bool maria_delay_key_write;
-extern my_off_t maria_max_temp_length;
-extern ulong maria_bulk_insert_tree_size, maria_data_pointer_size;
-extern MY_TMPDIR *maria_tmpdir;
-extern my_bool maria_encrypt_tables;
-
-/*
- This is used to check if a symlink points into the mysql data home,
- which is normally forbidden as it can be used to get access to
- not privileged data
-*/
-extern int (*maria_test_invalid_symlink)(const char *filename);
-
- /* Prototypes for maria-functions */
+typedef struct st_maria_create_info
+{
+ const char *index_file_name, *data_file_name; /* If using symlinks */
+ ha_rows max_rows;
+ ha_rows reloc_rows;
+ ulonglong auto_increment;
+ ulonglong data_file_length;
+ ulonglong key_file_length;
+ ulong s3_block_size;
+ /* Size of null bitmap at start of row */
+ uint null_bytes;
+ uint old_options;
+ uint compression_algorithm;
+ enum data_file_type org_data_file_type;
+ uint16 language;
+ my_bool with_auto_increment, transactional, encrypted;
+} MARIA_CREATE_INFO;
-extern int maria_init(void);
-extern void maria_end(void);
-extern my_bool maria_upgrade(void);
-extern int maria_close(MARIA_HA *file);
-extern int maria_delete(MARIA_HA *file, const uchar *buff);
-extern MARIA_HA *maria_open(const char *name, int mode,
- uint wait_if_locked);
-extern int maria_panic(enum ha_panic_function function);
-extern int maria_rfirst(MARIA_HA *file, uchar *buf, int inx);
-extern int maria_rkey(MARIA_HA *file, uchar *buf, int inx,
- const uchar *key, key_part_map keypart_map,
- enum ha_rkey_function search_flag);
-extern int maria_rlast(MARIA_HA *file, uchar *buf, int inx);
-extern int maria_rnext(MARIA_HA *file, uchar *buf, int inx);
-extern int maria_rnext_same(MARIA_HA *info, uchar *buf);
-extern int maria_rprev(MARIA_HA *file, uchar *buf, int inx);
-extern int maria_rrnd(MARIA_HA *file, uchar *buf,
- MARIA_RECORD_POS pos);
-extern int maria_scan_init(MARIA_HA *file);
-extern int maria_scan(MARIA_HA *file, uchar *buf);
-extern void maria_scan_end(MARIA_HA *file);
-extern int maria_rsame(MARIA_HA *file, uchar *record, int inx);
-extern int maria_rsame_with_pos(MARIA_HA *file, uchar *record,
- int inx, MARIA_RECORD_POS pos);
-extern int maria_update(MARIA_HA *file, const uchar *old,
- const uchar *new_record);
-extern int maria_write(MARIA_HA *file, const uchar *buff);
-extern MARIA_RECORD_POS maria_position(MARIA_HA *file);
-extern int maria_status(MARIA_HA *info, MARIA_INFO *x, uint flag);
-extern int maria_lock_database(MARIA_HA *file, int lock_type);
extern int maria_create(const char *name, enum data_file_type record_type,
uint keys, MARIA_KEYDEF *keydef,
- uint columns, MARIA_COLUMNDEF *columndef,
- uint uniques, MARIA_UNIQUEDEF *uniquedef,
- MARIA_CREATE_INFO *create_info, uint flags);
-extern int maria_delete_table(const char *name);
-extern int maria_rename(const char *from, const char *to);
-extern int maria_extra(MARIA_HA *file,
- enum ha_extra_function function, void *extra_arg);
-extern int maria_reset(MARIA_HA *file);
-extern ha_rows maria_records_in_range(MARIA_HA *info, int inx,
- key_range *min_key, key_range *max_key);
-extern int maria_is_changed(MARIA_HA *info);
-extern int maria_delete_all_rows(MARIA_HA *info);
-extern uint maria_get_pointer_length(ulonglong file_length, uint def);
-extern int maria_commit(MARIA_HA *info);
-extern int maria_begin(MARIA_HA *info);
-extern void maria_disable_logging(MARIA_HA *info);
-extern void maria_enable_logging(MARIA_HA *info);
-
-#define HA_RECOVER_NONE 0 /* No automatic recover */
-#define HA_RECOVER_DEFAULT 1 /* Automatic recover active */
-#define HA_RECOVER_BACKUP 2 /* Make a backupfile on recover */
-#define HA_RECOVER_FORCE 4 /* Recover even if we loose rows */
-#define HA_RECOVER_QUICK 8 /* Don't check rows in data file */
-
-#define HA_RECOVER_ANY (HA_RECOVER_DEFAULT | HA_RECOVER_BACKUP | HA_RECOVER_FORCE | HA_RECOVER_QUICK)
-
-/* this is used to pass to mysql_mariachk_table */
-
-#define MARIA_CHK_REPAIR 1 /* equivalent to mariachk -r */
-#define MARIA_CHK_VERIFY 2 /* Verify, run repair if failure */
-
-typedef uint maria_bit_type;
-
-typedef struct st_maria_bit_buff
-{ /* Used for packing of record */
- maria_bit_type current_byte;
- uint bits;
- uchar *pos, *end, *blob_pos, *blob_end;
- uint error;
-} MARIA_BIT_BUFF;
-
-/* functions in maria_check */
-void maria_chk_init(HA_CHECK *param);
-void maria_chk_init_for_check(HA_CHECK *param, MARIA_HA *info);
-int maria_chk_status(HA_CHECK *param, MARIA_HA *info);
-int maria_chk_del(HA_CHECK *param, MARIA_HA *info, ulonglong test_flag);
-int maria_chk_size(HA_CHECK *param, MARIA_HA *info);
-int maria_chk_key(HA_CHECK *param, MARIA_HA *info);
-int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info, my_bool extend);
-int maria_repair(HA_CHECK *param, MARIA_HA *info, char * name, my_bool);
-int maria_sort_index(HA_CHECK *param, MARIA_HA *info, char * name);
-int maria_zerofill(HA_CHECK *param, MARIA_HA *info, const char *name);
-int maria_repair_by_sort(HA_CHECK *param, MARIA_HA *info,
- const char *name, my_bool rep_quick);
-int maria_repair_parallel(HA_CHECK *param, MARIA_HA *info,
- const char *name, my_bool rep_quick);
-int maria_change_to_newfile(const char *filename, const char *old_ext,
- const char *new_ext, time_t backup_time,
- myf myflags);
-void maria_lock_memory(HA_CHECK *param);
-int maria_update_state_info(HA_CHECK *param, MARIA_HA *info, uint update);
-void maria_update_key_parts(MARIA_KEYDEF *keyinfo, double *rec_per_key_part,
- ulonglong *unique, ulonglong *notnull,
- ulonglong records);
-int maria_filecopy(HA_CHECK *param, File to, File from, my_off_t start,
- my_off_t length, const char *type);
-int maria_movepoint(MARIA_HA *info, uchar *record, my_off_t oldpos,
- my_off_t newpos, uint prot_key);
-int maria_test_if_almost_full(MARIA_HA *info);
-int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename);
-int maria_disable_indexes(MARIA_HA *info);
-int maria_enable_indexes(MARIA_HA *info);
-int maria_indexes_are_disabled(MARIA_HA *info);
-void maria_disable_indexes_for_rebuild(MARIA_HA *info, ha_rows rows,
- my_bool all_keys);
-my_bool maria_test_if_sort_rep(MARIA_HA *info, ha_rows rows, ulonglong key_map,
- my_bool force);
-
-int maria_init_bulk_insert(MARIA_HA *info, size_t cache_size, ha_rows rows);
-void maria_flush_bulk_insert(MARIA_HA *info, uint inx);
-int maria_end_bulk_insert(MARIA_HA *info, my_bool abort);
-int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves);
-void maria_versioning(MARIA_HA *info, my_bool versioning);
-void maria_ignore_trids(MARIA_HA *info);
-uint maria_max_key_length(void);
-my_bool maria_too_big_key_for_sort(MARIA_KEYDEF *key, ha_rows rows);
-#define maria_max_key_segments() HA_MAX_KEY_SEG
-
-/* fulltext functions */
-FT_INFO *maria_ft_init_search(uint,void *, uint, uchar *, size_t,
- CHARSET_INFO *, uchar *);
-
-/* 'Almost-internal' Maria functions */
-
-void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
- my_bool repair);
-
+ uint columns, MARIA_COLUMNDEF *columndef,
+ uint uniques, MARIA_UNIQUEDEF *uniquedef,
+ MARIA_CREATE_INFO *create_info, uint flags);
#ifdef __cplusplus
}
#endif
#endif
+
diff --git a/include/my_alarm.h b/include/my_alarm.h
index bc0004476ca..df5cb7f51de 100644
--- a/include/my_alarm.h
+++ b/include/my_alarm.h
@@ -31,7 +31,7 @@ extern ulong my_time_to_wait_for_lock;
#include <signal.h>
#ifdef HAVE_SIGHANDLER_T
#define sig_return sighandler_t
-#elif defined(SOLARIS) || defined(__sun) || defined(__APPLE__)
+#elif defined(SOLARIS) || defined(__sun) || defined(__APPLE__) || defined(__FreeBSD__) || defined(_AIX)
typedef void (*sig_return)(int); /* Returns type from signal */
#else
typedef void (*sig_return)(void); /* Returns type from signal */
diff --git a/include/my_alloc.h b/include/my_alloc.h
index 9b0aad26956..181f637c093 100644
--- a/include/my_alloc.h
+++ b/include/my_alloc.h
@@ -20,6 +20,8 @@
#ifndef _my_alloc_h
#define _my_alloc_h
+#include <mysql/psi/psi_memory.h>
+
#define ALLOC_MAX_BLOCK_TO_DROP 4096
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
@@ -43,7 +45,6 @@ typedef struct st_mem_root
/* if block have less memory it will be put in 'used' list */
size_t min_malloc;
size_t block_size; /* initial block size */
- size_t total_alloc;
unsigned int block_num; /* allocated blocks counter */
/*
first free block in queue test counter (if it exceed
@@ -52,7 +53,8 @@ typedef struct st_mem_root
unsigned int first_block_usage;
void (*error_handler)(void);
- const char *name;
+
+ PSI_memory_key m_psi_key;
} MEM_ROOT;
#ifdef __cplusplus
diff --git a/include/my_atomic_wrapper.h b/include/my_atomic_wrapper.h
index c574fba4a8e..c5820b4f5b6 100644
--- a/include/my_atomic_wrapper.h
+++ b/include/my_atomic_wrapper.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2020, MariaDB
+/* Copyright (c) 2020, 2021, MariaDB
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
@@ -41,9 +41,12 @@ public:
Atomic_relaxed(Type val) : m(val) {}
Atomic_relaxed() {}
- operator Type() const { return m.load(std::memory_order_relaxed); }
- Type operator=(const Type val)
- { m.store(val, std::memory_order_relaxed); return val; }
+ Type load(std::memory_order o= std::memory_order_relaxed) const
+ { return m.load(o); }
+ void store(Type i, std::memory_order o= std::memory_order_relaxed)
+ { m.store(i, o); }
+ operator Type() const { return m.load(); }
+ Type operator=(const Type i) { store(i); return i; }
Type operator=(const Atomic_relaxed<Type> &rhs) { return *this= Type{rhs}; }
Type fetch_add(const Type i, std::memory_order o= std::memory_order_relaxed)
{ return m.fetch_add(i, o); }
diff --git a/include/my_base.h b/include/my_base.h
index d045251778f..2a420591873 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -53,7 +53,11 @@
Allow opening even if table is incompatible as this is for ALTER TABLE which
will fix the table structure.
*/
-#define HA_OPEN_FOR_ALTER 4096U
+#define HA_OPEN_FOR_ALTER 8192U
+
+/* Open table for FLUSH */
+#define HA_OPEN_FOR_FLUSH 8192U
+
/* The following is parameter to ha_rkey() how to use key */
@@ -615,7 +619,6 @@ enum data_file_type {
#define EQ_RANGE 32U
#define NULL_RANGE 64U
#define GEOM_FLAG 128U
-#define SKIP_RANGE 256U
typedef struct st_key_range
{
@@ -642,6 +645,17 @@ typedef struct st_key_multi_range
} KEY_MULTI_RANGE;
+/* Store first and last leaf page accessed by records_in_range */
+
+typedef struct st_page_range
+{
+ ulonglong first_page;
+ ulonglong last_page;
+} page_range;
+
+#define UNUSED_PAGE_NO ULONGLONG_MAX
+#define unused_page_range { UNUSED_PAGE_NO, UNUSED_PAGE_NO }
+
/* For number of records */
#ifdef BIG_TABLES
#define rows2double(A) ulonglong2double(A)
diff --git a/include/my_bit.h b/include/my_bit.h
index 7a408bd0535..8ee8b41c8d4 100644
--- a/include/my_bit.h
+++ b/include/my_bit.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2007, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009, 2017, MariaDB Corporation.
+ Copyright (c) 2009, 2020, MariaDB Corporation.
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
@@ -25,16 +25,60 @@ C_MODE_START
extern const uchar _my_bits_reverse_table[256];
+
/*
- Find smallest X in 2^X >= value
- This can be used to divide a number with value by doing a shift instead
-*/
+ my_bit_log2_xxx()
+
+ In the given value, find the highest bit set,
+ which is the smallest X that satisfies the condition: (2^X >= value).
+ Can be used as a reverse operation for (1<<X), to find X.
+
+ Examples:
+ - returns 0 for (1<<0)
+ - returns 1 for (1<<1)
+ - returns 2 for (1<<2)
+ - returns 2 for 3, which has (1<<2) as the highest bit set.
-static inline uint my_bit_log2(ulong value)
+ Note, the behaviour of log2(0) is not defined.
+ Let's return 0 for the input 0, for the code simplicity.
+ See the 000x branch. It covers both (1<<0) and 0.
+*/
+static inline CONSTEXPR uint my_bit_log2_hex_digit(uint8 value)
{
- uint bit;
- for (bit=0 ; value > 1 ; value>>=1, bit++) ;
- return bit;
+ return value & 0x0C ? /*1100*/ (value & 0x08 ? /*1000*/ 3 : /*0100*/ 2) :
+ /*0010*/ (value & 0x02 ? /*0010*/ 1 : /*000x*/ 0);
+}
+static inline CONSTEXPR uint my_bit_log2_uint8(uint8 value)
+{
+ return value & 0xF0 ? my_bit_log2_hex_digit((uint8) (value >> 4)) + 4:
+ my_bit_log2_hex_digit(value);
+}
+static inline CONSTEXPR uint my_bit_log2_uint16(uint16 value)
+{
+ return value & 0xFF00 ? my_bit_log2_uint8((uint8) (value >> 8)) + 8 :
+ my_bit_log2_uint8((uint8) value);
+}
+static inline CONSTEXPR uint my_bit_log2_uint32(uint32 value)
+{
+ return value & 0xFFFF0000UL ?
+ my_bit_log2_uint16((uint16) (value >> 16)) + 16 :
+ my_bit_log2_uint16((uint16) value);
+}
+static inline CONSTEXPR uint my_bit_log2_uint64(ulonglong value)
+{
+ return value & 0xFFFFFFFF00000000ULL ?
+ my_bit_log2_uint32((uint32) (value >> 32)) + 32 :
+ my_bit_log2_uint32((uint32) value);
+}
+static inline CONSTEXPR uint my_bit_log2_size_t(size_t value)
+{
+#ifdef __cplusplus
+ static_assert(sizeof(size_t) <= sizeof(ulonglong),
+ "size_t <= ulonglong is an assumption that needs to be fixed "
+ "for this architecture. Please create an issue on "
+ "https://jira.mariadb.org");
+#endif
+ return my_bit_log2_uint64((ulonglong) value);
}
@@ -128,7 +172,47 @@ static inline uchar last_byte_mask(uint bits)
/* Get the number of used bits-1 (0..7) in the last byte */
unsigned int const used = (bits - 1U) & 7U;
/* Return bitmask for the significant bits */
- return ((2U << used) - 1);
+ return (uchar) ((2U << used) - 1);
+}
+
+#ifdef _MSC_VER
+#include <intrin.h>
+#endif
+
+/*
+ Find the position of the first(least significant) bit set in
+ the argument. Returns 64 if the argument was 0.
+*/
+static inline uint my_find_first_bit(ulonglong n)
+{
+ if(!n)
+ return 64;
+#if defined(__GNUC__)
+ return __builtin_ctzll(n);
+#elif defined(_MSC_VER)
+#if defined(_M_IX86)
+ unsigned long bit;
+ if( _BitScanForward(&bit, (uint)n))
+ return bit;
+ _BitScanForward(&bit, (uint)(n>>32));
+ return bit + 32;
+#else
+ unsigned long bit;
+ _BitScanForward64(&bit, n);
+ return bit;
+#endif
+#else
+ /* Generic case */
+ uint shift= 0;
+ static const uchar last_bit[16] = { 32, 0, 1, 0,
+ 2, 0, 1, 0,
+ 3, 0, 1, 0,
+ 2, 0, 1, 0};
+ uint bit;
+ while ((bit = last_bit[(n >> shift) & 0xF]) == 32)
+ shift+= 4;
+ return shift+bit;
+#endif
}
C_MODE_END
diff --git a/include/my_bitmap.h b/include/my_bitmap.h
index 1b0fbe40d2e..f19254404c1 100644
--- a/include/my_bitmap.h
+++ b/include/my_bitmap.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2001, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009-2011, Monty Program Ab
+ Copyright (c) 2009, 2020, MariaDB Corporation.
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
@@ -89,56 +89,35 @@ extern void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit);
#define no_bytes_in_map(map) (((map)->n_bits + 7)/8)
#define no_words_in_map(map) (((map)->n_bits + 31)/32)
#define bytes_word_aligned(bytes) (4*((bytes + 3)/4))
-#define _bitmap_set_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
- |= (1 << ((BIT) & 7)))
-#define _bitmap_flip_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
- ^= (1 << ((BIT) & 7)))
-#define _bitmap_clear_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
- &= ~ (1 << ((BIT) & 7)))
-#define _bitmap_is_set(MAP, BIT) (uint) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
- & (1 << ((BIT) & 7)))
-/*
- WARNING!
-
- The below symbols are inline functions in DEBUG builds and macros in
- non-DEBUG builds. The latter evaluate their 'bit' argument twice.
-
- NEVER use an increment/decrement operator with the 'bit' argument.
- It would work with DEBUG builds, but fails later in production builds!
-
- FORBIDDEN: bitmap_set_bit($my_bitmap, (field++)->field_index);
-*/
-#ifndef DBUG_OFF
+/* The following functions must be compatible with create_last_word_mask()! */
static inline void
bitmap_set_bit(MY_BITMAP *map,uint bit)
{
- DBUG_ASSERT(bit < (map)->n_bits);
- _bitmap_set_bit(map,bit);
+ uchar *b= (uchar*) map->bitmap + bit / 8;
+ DBUG_ASSERT(bit < map->n_bits);
+ *b= (uchar) (*b | 1U << (bit & 7));
}
static inline void
bitmap_flip_bit(MY_BITMAP *map,uint bit)
{
- DBUG_ASSERT(bit < (map)->n_bits);
- _bitmap_flip_bit(map,bit);
+ uchar *b= (uchar*) map->bitmap + bit / 8;
+ DBUG_ASSERT(bit < map->n_bits);
+ *b= (uchar) (*b ^ 1U << (bit & 7));
}
static inline void
bitmap_clear_bit(MY_BITMAP *map,uint bit)
{
- DBUG_ASSERT(bit < (map)->n_bits);
- _bitmap_clear_bit(map,bit);
+ uchar *b= (uchar*) map->bitmap + bit / 8;
+ DBUG_ASSERT(bit < map->n_bits);
+ *b= (uchar) (*b & ~(1U << (bit & 7)));
}
static inline uint
bitmap_is_set(const MY_BITMAP *map,uint bit)
{
- DBUG_ASSERT(bit < (map)->n_bits);
- return _bitmap_is_set(map,bit);
+ const uchar *b= (const uchar*) map->bitmap + bit / 8;
+ DBUG_ASSERT(bit < map->n_bits);
+ return !!(*b & (1U << (bit & 7)));
}
-#else
-#define bitmap_set_bit(MAP, BIT) _bitmap_set_bit(MAP, BIT)
-#define bitmap_flip_bit(MAP, BIT) _bitmap_flip_bit(MAP, BIT)
-#define bitmap_clear_bit(MAP, BIT) _bitmap_clear_bit(MAP, BIT)
-#define bitmap_is_set(MAP, BIT) _bitmap_is_set(MAP, BIT)
-#endif
static inline my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
{
diff --git a/include/my_compare.h b/include/my_compare.h
index bd5dc418f8c..f936bbe6b0c 100644
--- a/include/my_compare.h
+++ b/include/my_compare.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2011, Oracle and/or its affiliates.
- Copyright (c) 1991, 2020, MariaDB Corporation.
+ Copyright (c) 1991, 2021, MariaDB Corporation.
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
diff --git a/include/my_compiler.h b/include/my_compiler.h
index bee92078767..d35a9104c50 100644
--- a/include/my_compiler.h
+++ b/include/my_compiler.h
@@ -29,6 +29,14 @@
Compiler-dependent internal convenience macros.
*/
+/* C vs C++ */
+#ifdef __cplusplus
+#define CONSTEXPR constexpr
+#else
+#define CONSTEXPR
+#endif /* __cplusplus */
+
+
/* GNU C/C++ */
#if defined __GNUC__
/* Convenience macro to test the minimum required GCC version. */
diff --git a/include/my_cpu.h b/include/my_cpu.h
index 57f2bf814d4..05fa937c98d 100644
--- a/include/my_cpu.h
+++ b/include/my_cpu.h
@@ -55,6 +55,7 @@
#elif defined(_ARCH_PWR8)
#elif defined __GNUC__ && (defined __arm__ || defined __aarch64__)
#else
+# include "my_global.h"
# include "my_atomic.h"
#endif
@@ -83,7 +84,15 @@ static inline void MY_RELAX_CPU(void)
__ppc_get_timebase();
#elif defined __GNUC__ && (defined __arm__ || defined __aarch64__)
/* Mainly, prevent the compiler from optimizing away delay loops */
+#ifdef _aarch64_
+ __asm__ __volatile__ ("isb":::"memory");
+#else
+ /*
+ some older 32 bits processor doesn't support isb but as per
+ arm-v8 reference manual all armv8 processor should support isb.
+ */
__asm__ __volatile__ ("":::"memory");
+#endif
#else
int32 var, oldval = 0;
my_atomic_cas32_strong_explicit(&var, &oldval, 1, MY_MEMORY_ORDER_RELAXED,
diff --git a/include/my_dbug.h b/include/my_dbug.h
index e69ee4f8ed5..92ed2cbdeec 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -52,7 +52,10 @@ extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
extern void _db_return_(struct _db_stack_frame_ *_stack_frame_);
extern int _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_(const char *format,...)
- ATTRIBUTE_FORMAT(printf, 1, 2);
+#ifdef WAITING_FOR_BUGFIX_TO_VSPRINTF
+ ATTRIBUTE_FORMAT(printf, 1, 2)
+#endif
+ ;
extern void _db_dump_(uint _line_,const char *keyword,
const unsigned char *memory, size_t length);
extern void _db_end_(void);
@@ -105,6 +108,8 @@ extern int (*dbug_sanity)(void);
(_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
+#define DBUG_PUSH_EMPTY if (_dbug_on_) { DBUG_PUSH(""); }
+#define DBUG_POP_EMPTY if (_dbug_on_) { DBUG_POP(); }
#define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ ()
#define DBUG_SET(a1) _db_set_ (a1)
@@ -141,7 +146,7 @@ extern int (*dbug_sanity)(void);
#define DBUG_ABORT() (_db_flush_(),\
(void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE),\
(void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR),\
- _exit(3))
+ TerminateProcess(GetCurrentProcess(),3))
#endif
/*
@@ -172,6 +177,8 @@ extern void _db_suicide_(void);
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
#define DBUG_PRINT(keyword,arglist) do { } while(0)
+#define DBUG_PUSH_EMPTY do { } while(0)
+#define DBUG_POP_EMPTY do { } while(0)
#define DBUG_PUSH(a1) do { } while(0)
#define DBUG_SET(a1) do { } while(0)
#define DBUG_SET_INITIAL(a1) do { } while(0)
diff --git a/include/my_default.h b/include/my_default.h
index 865833de34a..0f158bbbe43 100644
--- a/include/my_default.h
+++ b/include/my_default.h
@@ -20,27 +20,16 @@
C_MODE_START
-extern const char *my_defaults_extra_file;
+extern MYSQL_PLUGIN_IMPORT const char *my_defaults_extra_file;
extern const char *my_defaults_group_suffix;
-extern const char *my_defaults_file;
-extern my_bool my_getopt_use_args_separator;
-extern my_bool my_getopt_is_args_separator(const char* arg);
+extern MYSQL_PLUGIN_IMPORT const char *my_defaults_file;
+extern my_bool my_defaults_mark_files;
-/* Define the type of function to be passed to process_default_option_files */
-typedef int (*Process_option_func)(void *ctx, const char *group_name,
- const char *option);
-
-extern int get_defaults_options(int argc, char **argv,
- char **defaults, char **extra_defaults,
- char **group_suffix);
+extern int get_defaults_options(char **argv);
extern int my_load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv, const char ***);
extern int load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv);
-extern int my_search_option_files(const char *conf_file, int *argc,
- char ***argv, uint *args_used,
- Process_option_func func, void *func_ctx,
- const char **default_directories);
extern void free_defaults(char **argv);
extern void my_print_default_files(const char *conf_file);
extern void print_defaults(const char *conf_file, const char **groups);
diff --git a/include/my_getopt.h b/include/my_getopt.h
index f0cefb35b87..ffff706e015 100644
--- a/include/my_getopt.h
+++ b/include/my_getopt.h
@@ -89,7 +89,7 @@ struct my_option
void *app_type; /**< To be used by an application */
};
-typedef my_bool (*my_get_one_option)(int, const struct my_option *, char *);
+typedef my_bool (*my_get_one_option)(const struct my_option *, const char *, const char *);
/**
Used to retrieve a reference to the object (variable) that holds the value
@@ -108,13 +108,14 @@ extern my_bool my_getopt_skip_unknown;
extern my_bool my_getopt_prefix_matching;
extern my_bool my_handle_options_init_variables;
extern my_error_reporter my_getopt_error_reporter;
+extern my_getopt_value my_getopt_get_addr;
extern int handle_options (int *argc, char ***argv,
- const struct my_option *longopts, my_get_one_option);
+ const struct my_option *longopts, my_get_one_option)
+ __attribute__((nonnull));
extern void my_cleanup_options(const struct my_option *options);
extern void my_print_help(const struct my_option *options);
extern void my_print_variables(const struct my_option *options);
-extern void my_getopt_register_get_addr(my_getopt_value);
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
my_bool *fix);
@@ -122,7 +123,6 @@ longlong getopt_ll_limit_value(longlong, const struct my_option *,
my_bool *fix);
double getopt_double_limit_value(double num, const struct my_option *optp,
my_bool *fix);
-my_bool getopt_compare_strings(const char *s, const char *t, uint length);
ulonglong getopt_double2ulonglong(double);
double getopt_ulonglong2double(ulonglong);
diff --git a/include/my_global.h b/include/my_global.h
index b60fa59dfaa..9d9417c957c 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -1,6 +1,6 @@
/*
Copyright (c) 2001, 2013, Oracle and/or its affiliates.
- Copyright (c) 2009, 2019, MariaDB Corporation.
+ Copyright (c) 2009, 2021, MariaDB Corporation.
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
@@ -135,13 +135,6 @@
#endif /* _WIN32*/
-
-/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
-#if defined(_AIX) && defined(_LARGE_FILE_API)
-#undef _LARGE_FILE_API
-#undef __GNUG__
-#endif
-
/*
The macros below are used to allow build of Universal/fat binaries of
MySQL and MySQL applications under darwin.
@@ -159,7 +152,7 @@
# if defined(__i386__) || defined(__ppc__)
# define SIZEOF_CHARP 4
# define SIZEOF_LONG 4
-# elif defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__)
+# elif defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__) || defined(__arm64__)
# define SIZEOF_CHARP 8
# define SIZEOF_LONG 8
# else
@@ -270,22 +263,6 @@ C_MODE_END
#endif
#endif /* !defined(__WIN__) */
-/* Go around some bugs in different OS and compilers */
-#ifdef _AIX /* By soren@t.dk */
-#define _H_STRINGS
-#define _SYS_STREAM_H
-/* #define _AIX32_CURSES */ /* XXX: this breaks AIX 4.3.3 (others?). */
-#define ulonglong2double(A) my_ulonglong2double(A)
-#define my_off_t2double(A) my_ulonglong2double(A)
-C_MODE_START
-inline double my_ulonglong2double(unsigned long long A) { return (double)A; }
-C_MODE_END
-#endif /* _AIX */
-
-#ifdef UNDEF_HAVE_INITGROUPS /* For AIX 4.3 */
-#undef HAVE_INITGROUPS
-#endif
-
/* gcc/egcs issues */
#if defined(__GNUC) && defined(__EXCEPTIONS)
@@ -295,16 +272,6 @@ C_MODE_END
#if defined(_lint) && !defined(lint)
#define lint
#endif
-#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
-#define _LONG_LONG 1 /* For AIX string library */
-#endif
-
-/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
-#if defined(_AIX) && defined(_LARGE_FILE_API)
-#undef _LARGE_FILE_API
-#undef __GNUG__
-#endif
-
#ifndef stdin
#include <stdio.h>
@@ -332,13 +299,6 @@ C_MODE_END
#include <sys/types.h>
#endif
-/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
-#if defined(_AIX) && defined(_LARGE_FILE_API)
-#undef _LARGE_FILE_API
-#undef __GNUG__
-#endif
-
-
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
@@ -796,6 +756,8 @@ inline unsigned long long my_double2ulonglong(double d)
#define LONGLONG_MIN ((long long) 0x8000000000000000LL)
#define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL)
#endif
+/* Max length needed for a buffer to hold a longlong or ulonglong + end \0 */
+#define LONGLONG_BUFFER_SIZE 21
#if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)
/* First check for ANSI C99 definition: */
@@ -1069,8 +1031,8 @@ typedef ulong myf; /* Type of MyFlags in my_funcs */
#ifdef HAVE_CHARSET_utf8mb4
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8mb4"
-#elif defined(HAVE_CHARSET_utf8)
-#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
+#elif defined(HAVE_CHARSET_utf8mb3)
+#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8mb3"
#else
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
#endif
@@ -1195,12 +1157,6 @@ typedef struct { const char *dli_fname, dli_fbase; } Dl_info;
#define HAVE_EXTERNAL_CLIENT
#endif /* EMBEDDED_LIBRARY */
-/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
-#if defined(_AIX) && defined(_LARGE_FILE_API)
-#undef _LARGE_FILE_API
-#undef __GNUG__
-#endif
-
/*
Provide defaults for the CPU cache line size, if it has not been detected by
CMake using getconf
diff --git a/include/my_handler_errors.h b/include/my_handler_errors.h
index 4c3a02dd745..96632629775 100644
--- a/include/my_handler_errors.h
+++ b/include/my_handler_errors.h
@@ -101,7 +101,7 @@ static const char *handler_error_messages[]=
"Operation was interrupted by end user (probably kill command?)",
"Disk full",
/* 190 */
- "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump and restore the table to fix this",
+ "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You may have retry or dump and restore the table to fix this",
"Too many words in a FTS phrase or proximity search",
"Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.",
"Foreign key cascade delete/update exceeds max depth",
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 65498d185c5..1c83e77a41b 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -114,7 +114,7 @@ int pthread_cancel(pthread_t thread);
#define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
#define pthread_key_delete(A) TlsFree(A)
#define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V)))
-#define pthread_setspecific(A,B) (!TlsSetValue((A),(B)))
+#define pthread_setspecific(A,B) (!TlsSetValue((A),(LPVOID)(B)))
#define pthread_getspecific(A) (TlsGetValue(A))
#define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
#define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V))
@@ -311,6 +311,8 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif //!defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
#endif //HAVE_SCHED_YIELD
+size_t my_setstacksize(pthread_attr_t *attr, size_t stacksize);
+
/*
The defines set_timespec and set_timespec_nsec should be used
for calculating an absolute time at which
@@ -350,31 +352,17 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif /* !cmp_timespec */
#ifndef set_timespec_time_nsec
-#define set_timespec_time_nsec(ABSTIME,NSEC) do { \
- ulonglong _now_= (NSEC); \
- (ABSTIME).MY_tv_sec= (_now_ / 1000000000ULL); \
- (ABSTIME).MY_tv_nsec= (_now_ % 1000000000ULL); \
+#define set_timespec_time_nsec(ABSTIME,NSEC) do { \
+ ulonglong _now_= (NSEC); \
+ (ABSTIME).MY_tv_sec= (time_t) (_now_ / 1000000000ULL); \
+ (ABSTIME).MY_tv_nsec= (ulong) (_now_ % 1000000000UL); \
} while(0)
#endif /* !set_timespec_time_nsec */
#ifdef MYSQL_CLIENT
#define _current_thd() NULL
-#elif defined(_WIN32)
-#ifdef __cplusplus
-extern "C"
-#endif
-MYSQL_THD _current_thd_noinline();
-#define _current_thd() _current_thd_noinline()
#else
-/*
- THR_THD is a key which will be used to set/get THD* for a thread,
- using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
-*/
-extern pthread_key(MYSQL_THD, THR_THD);
-static inline MYSQL_THD _current_thd(void)
-{
- return my_pthread_getspecific_ptr(MYSQL_THD,THR_THD);
-}
+MYSQL_THD _current_thd();
#endif
/* safe_mutex adds checking to mutex for easier debugging */
@@ -440,17 +428,16 @@ void safe_mutex_free_deadlock_data(safe_mutex_t *mp);
#define MYF_NO_DEADLOCK_DETECTION 2
#ifdef SAFE_MUTEX
-#define safe_mutex_assert_owner(mp) \
- DBUG_ASSERT((mp)->count > 0 && \
- pthread_equal(pthread_self(), (mp)->thread))
-#define safe_mutex_assert_not_owner(mp) \
- DBUG_ASSERT(! (mp)->count || \
- ! pthread_equal(pthread_self(), (mp)->thread))
+#define safe_mutex_is_owner(mp) ((mp)->count > 0 && \
+ pthread_equal(pthread_self(), (mp)->thread))
+#define safe_mutex_assert_owner(mp) DBUG_ASSERT(safe_mutex_is_owner(mp))
+#define safe_mutex_assert_not_owner(mp) DBUG_ASSERT(!safe_mutex_is_owner(mp))
#define safe_mutex_setflags(mp, F) do { (mp)->create_flags|= (F); } while (0)
#define my_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
#define my_cond_wait(A,B) safe_cond_wait((A), (B), __FILE__, __LINE__)
#else
+#define safe_mutex_is_owner(mp) (1)
#define safe_mutex_assert_owner(mp) do {} while (0)
#define safe_mutex_assert_not_owner(mp) do {} while (0)
#define safe_mutex_setflags(mp, F) do {} while (0)
@@ -580,36 +567,13 @@ extern int rw_pr_destroy(rw_pr_lock_t *);
/**
Implementation of Windows rwlock.
- We use native (slim) rwlocks on Win7 and later, and fallback to portable
- implementation on earlier Windows.
-
- slim rwlock are also available on Vista/WS2008, but we do not use it
- ("trylock" APIs are missing on Vista)
+ We use native (slim) rwlocks on Windows, which requires Win7
+ or later.
*/
-typedef union
+typedef struct _my_rwlock_t
{
- /* Native rwlock (is_srwlock == TRUE) */
- struct
- {
- SRWLOCK srwlock; /* native reader writer lock */
- BOOL have_exclusive_srwlock; /* used for unlock */
- };
-
- /*
- Portable implementation (is_srwlock == FALSE)
- Fields are identical with Unix my_rw_lock_t fields.
- */
- struct
- {
- pthread_mutex_t lock; /* lock for structure */
- pthread_cond_t readers; /* waiting readers */
- pthread_cond_t writers; /* waiting writers */
- int state; /* -1:writer,0:free,>0:readers */
- int waiters; /* number of waiting writers */
-#ifdef SAFE_MUTEX
- pthread_t write_thread;
-#endif
- };
+ SRWLOCK srwlock; /* native reader writer lock */
+ BOOL have_exclusive_srwlock; /* used for unlock */
} my_rw_lock_t;
@@ -705,7 +669,11 @@ extern void my_mutex_end(void);
with the current number of keys and key parts.
*/
#if defined(__SANITIZE_ADDRESS__) || defined(WITH_UBSAN)
+#ifndef DBUG_OFF
+#define DEFAULT_THREAD_STACK (1024*1024L)
+#else
#define DEFAULT_THREAD_STACK (383*1024L) /* 392192 */
+#endif
#else
#define DEFAULT_THREAD_STACK (292*1024L) /* 299008 */
#endif
@@ -718,22 +686,34 @@ extern void my_mutex_end(void);
#define INSTRUMENT_ME 0
+/*
+ Thread specific variables
+
+ Aria key cache is using the following variables for keeping track of
+ state:
+ suspend, next, prev, keycache_link, keycache_file, suspend, lock_type
+
+ MariaDB uses the following to
+ mutex, current_mutex, current_cond, abort
+*/
+
struct st_my_thread_var
{
int thr_errno;
mysql_cond_t suspend;
mysql_mutex_t mutex;
+ struct st_my_thread_var *next,**prev;
mysql_mutex_t * volatile current_mutex;
mysql_cond_t * volatile current_cond;
+ void *keycache_link;
+ void *keycache_file;
+ void *stack_ends_here;
+ safe_mutex_t *mutex_in_use;
pthread_t pthread_self;
my_thread_id id, dbug_id;
int volatile abort;
+ uint lock_type; /* used by conditional release the queue */
my_bool init;
- struct st_my_thread_var *next,**prev;
- void *keycache_link;
- uint lock_type; /* used by conditional release the queue */
- void *stack_ends_here;
- safe_mutex_t *mutex_in_use;
#ifndef DBUG_OFF
void *dbug;
char name[THREAD_NAME_SIZE+1];
@@ -748,18 +728,7 @@ extern my_bool safe_mutex_deadlock_detector;
#define my_thread_var (_my_thread_var())
#define my_errno my_thread_var->thr_errno
int set_mysys_var(struct st_my_thread_var *mysys_var);
-/*
- Keep track of shutdown,signal, and main threads so that my_end() will not
- report errors with them
-*/
-
-/* Which kind of thread library is in use */
-
-#define THD_LIB_OTHER 1
-#define THD_LIB_NPTL 2
-#define THD_LIB_LT 4
-extern uint thd_lib_detected;
/*
thread_safe_xxx functions are for critical statistic or counters.
diff --git a/include/my_stack_alloc.h b/include/my_stack_alloc.h
new file mode 100644
index 00000000000..95e746d6fe7
--- /dev/null
+++ b/include/my_stack_alloc.h
@@ -0,0 +1,92 @@
+/* Copyright 2019 MariaDB corporation 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-1335 USA
+*/
+
+#ifndef _my_stack_alloc_h
+#define _my_stack_alloc_h
+
+/*
+ Do allocation through alloca if there is enough stack available.
+ If not, use my_malloc() instead.
+
+ The idea is that to be able to alloc as much as possible through the
+ stack. To ensure this, we have two different limits, on for big
+ blocks and one for small blocks. This will enable us to continue to
+ do allocation for small blocks even when there is less stack space
+ available.
+ This is for example used by Aria when traversing the b-tree and the code
+ needs to allocate one b-tree page and a few keys for each recursion. Even
+ if there is not space to allocate the b-tree pages on stack we can still
+ continue to allocate the keys.
+*/
+
+/*
+ Default suggested allocations
+*/
+
+/* Allocate big blocks as long as there is this much left */
+#define STACK_ALLOC_BIG_BLOCK 1024*64
+
+/* Allocate small blocks as long as there is this much left */
+#define STACK_ALLOC_SMALL_BLOCK 1024*32
+
+/* Allocate small blocks as long as there is this much left */
+#define STACK_ALLOC_SMALL_BLOCK_SIZE 4096
+
+/*
+ Allocate a block on stack or through malloc.
+ The 'must_be_freed' variable will be set to 1 if malloc was called.
+ 'must_be_freed' must be a variable on the stack!
+*/
+
+#ifdef HAVE_ALLOCA
+#define alloc_on_stack(stack_end, res, must_be_freed, size) \
+do \
+{ \
+ size_t alloc_size= (size); \
+ size_t stack_left= available_stack_size(&alloc_size, (stack_end)); \
+ if (stack_left > alloc_size && \
+ (STACK_ALLOC_BIG_BLOCK < stack_left - alloc_size || \
+ ((STACK_ALLOC_SMALL_BLOCK < stack_left - alloc_size) && \
+ (STACK_ALLOC_SMALL_BLOCK_SIZE <= alloc_size)))) \
+ { \
+ (must_be_freed)= 0; \
+ (res)= alloca(size); \
+ } \
+ else \
+ { \
+ (must_be_freed)= 1; \
+ (res)= my_malloc(PSI_INSTRUMENT_ME, size, MYF(MY_THREAD_SPECIFIC | MY_WME)); \
+ } \
+} while(0)
+#else
+#define alloc_on_stack(stack_end, res, must_be_freed, size) \
+ do { \
+ (must_be_freed)= 1; \
+ (res)= my_malloc(PSI_INSTRUMENT_ME, size, MYF(MY_THREAD_SPECIFIC | MY_WME)); \
+ } while(0)
+#endif /* HAVE_ALLOCA */
+
+
+/*
+ Free memory allocated by stack_alloc
+*/
+
+static inline void stack_alloc_free(void *res, my_bool must_be_freed)
+{
+ if (must_be_freed)
+ my_free(res);
+}
+#endif /* _my_stack_alloc_h */
diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h
index 015fa062752..20b86f45232 100644
--- a/include/my_stacktrace.h
+++ b/include/my_stacktrace.h
@@ -1,5 +1,6 @@
/*
Copyright (c) 2001, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2020, MariaDB Corporation.
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
@@ -45,12 +46,17 @@ void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack,
my_bool silent);
int my_safe_print_str(const char* val, size_t max_len);
void my_write_core(int sig);
-#if BACKTRACE_DEMANGLE
+# if BACKTRACE_DEMANGLE
char *my_demangle(const char *mangled_name, int *status);
-#endif /* BACKTRACE_DEMANGLE */
-#ifdef __WIN__
+# endif /* BACKTRACE_DEMANGLE */
+# ifdef __WIN__
+# define my_setup_stacktrace()
void my_set_exception_pointers(EXCEPTION_POINTERS *ep);
-#endif /* __WIN__ */
+# else
+void my_setup_stacktrace(void);
+# endif /* __WIN__ */
+#else
+# define my_setup_stacktrace()
#endif /* ! (defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)) */
#ifndef _WIN32
diff --git a/include/my_sys.h b/include/my_sys.h
index 437f2d946e6..ad802cfc3ca 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -18,21 +18,13 @@
#define _my_sys_h
#include <m_string.h>
+#include <mysql/psi/mysql_memory.h>
C_MODE_START
-#ifdef HAVE_AIOWAIT
-#include <sys/asynch.h> /* Used by record-cache */
-typedef struct my_aio_result {
- aio_result_t result;
- int pending;
-} my_aio_result;
-#endif
#include <my_valgrind.h>
-
#include <my_pthread.h>
-
#include <m_ctype.h> /* for CHARSET_INFO */
#include <stdarg.h>
#include <typelib.h>
@@ -66,6 +58,7 @@ typedef struct my_aio_result {
#define MY_WME 16U /* Write message on error */
#define MY_WAIT_IF_FULL 32U /* Wait and try again if disk full error */
#define MY_IGNORE_BADFD 32U /* my_sync(): ignore 'bad descriptor' errors */
+#define MY_IGNORE_ENOENT 32U /* my_delete() ignores ENOENT (no such file) */
#define MY_ENCRYPT 64U /* Encrypt IO_CACHE temporary files */
#define MY_TEMPORARY 64U /* create_temp_file(): delete file at once */
#define MY_NOSYMLINKS 512U /* my_open(): don't follow symlinks */
@@ -89,14 +82,12 @@ typedef struct my_aio_result {
#define MY_ZEROFILL 32U /* my_malloc(), fill array with zero */
#define MY_ALLOW_ZERO_PTR 64U /* my_realloc() ; zero ptr -> malloc */
#define MY_FREE_ON_ERROR 128U /* my_realloc() ; Free old ptr on error */
-#define MY_HOLD_ON_ERROR 256U /* my_realloc() ; Return old ptr on error */
#define MY_DONT_OVERWRITE_FILE 2048U /* my_copy: Don't overwrite file */
#define MY_THREADSAFE 2048U /* my_seek(): lock fd mutex */
#define MY_SYNC 4096U /* my_copy(): sync dst file */
#define MY_SYNC_DIR 32768U /* my_create/delete/rename: sync directory */
#define MY_SYNC_FILESIZE 65536U /* my_sync(): safe sync when file is extended */
#define MY_THREAD_SPECIFIC 0x10000U /* my_malloc(): thread specific */
-#define MY_THREAD_MOVE 0x20000U /* realloc(); Memory can move */
/* Tree that should delete things automatically */
#define MY_TREE_WITH_DELETE 0x40000U
@@ -168,24 +159,22 @@ typedef void (*MALLOC_SIZE_CB) (long long size, my_bool is_thread_specific);
extern void set_malloc_size_cb(MALLOC_SIZE_CB func);
/* defines when allocating data */
-extern void *my_malloc(size_t Size,myf MyFlags);
-extern void *my_multi_malloc(myf MyFlags, ...);
-extern void *my_multi_malloc_large(myf MyFlags, ...);
-extern void *my_realloc(void *oldpoint, size_t Size, myf MyFlags);
+extern void *my_malloc(PSI_memory_key key, size_t size, myf MyFlags);
+extern void *my_multi_malloc(PSI_memory_key key, myf MyFlags, ...);
+extern void *my_multi_malloc_large(PSI_memory_key key, myf MyFlags, ...);
+extern void *my_realloc(PSI_memory_key key, void *ptr, size_t size, myf MyFlags);
extern void my_free(void *ptr);
-extern void *my_memdup(const void *from,size_t length,myf MyFlags);
-extern char *my_strdup(const char *from,myf MyFlags);
-extern char *my_strndup(const char *from, size_t length, myf MyFlags);
-
-#ifdef HAVE_LINUX_LARGE_PAGES
-extern uint my_get_large_page_size(void);
-extern uchar * my_large_malloc(size_t size, myf my_flags);
-extern void my_large_free(uchar *ptr);
-#else
-#define my_get_large_page_size() (0)
-#define my_large_malloc(A,B) my_malloc_lock((A),(B))
-#define my_large_free(A) my_free_lock((A))
-#endif /* HAVE_LINUX_LARGE_PAGES */
+extern void *my_memdup(PSI_memory_key key, const void *from,size_t length,myf MyFlags);
+extern char *my_strdup(PSI_memory_key key, const char *from,myf MyFlags);
+extern char *my_strndup(PSI_memory_key key, const char *from, size_t length, myf MyFlags);
+
+int my_init_large_pages(my_bool super_large_pages);
+uchar *my_large_malloc(size_t *size, myf my_flags);
+void my_large_free(void *ptr, size_t size);
+
+#ifdef _WIN32
+extern BOOL my_obtain_privilege(LPCSTR lpPrivilege);
+#endif
void my_init_atomic_write(void);
#ifdef __linux__
@@ -211,11 +200,11 @@ extern my_bool my_may_have_atomic_write;
#define MAX_ALLOCA_SZ 4096
#define my_safe_alloca(size) (((size) <= MAX_ALLOCA_SZ) ? \
my_alloca(size) : \
- my_malloc((size), MYF(MY_THREAD_SPECIFIC|MY_WME)))
+ my_malloc(PSI_NOT_INSTRUMENTED, (size), MYF(MY_THREAD_SPECIFIC|MY_WME)))
#define my_safe_afree(ptr, size) \
do { if ((size) > MAX_ALLOCA_SZ) my_free(ptr); } while(0)
#else
-#define my_alloca(SZ) my_malloc(SZ,MYF(MY_FAE))
+#define my_alloca(SZ) my_malloc(PSI_NOT_INSTRUMENTED, SZ,MYF(MY_FAE))
#define my_afree(PTR) my_free(PTR)
#define my_safe_alloca(size) my_alloca(size)
#define my_safe_afree(ptr, size) my_afree(ptr)
@@ -243,11 +232,6 @@ extern int sf_leaking_memory; /* set to 1 to disable memleak detection */
extern void (*proc_info_hook)(void *, const PSI_stage_info *, PSI_stage_info *,
const char *, const char *, const unsigned int);
-#ifdef HAVE_LINUX_LARGE_PAGES
-extern my_bool my_use_large_pages;
-extern uint my_large_page_size;
-#endif
-
/* charsets */
#define MY_ALL_CHARSETS_SIZE 2048
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *default_charset_info;
@@ -288,7 +272,6 @@ extern my_bool my_disable_async_io,
extern my_bool my_disable_sync, my_disable_copystat_in_redel;
extern char wild_many,wild_one,wild_prefix;
extern const char *charsets_dir;
-extern my_bool timed_mutexes;
enum cache_type
{
@@ -321,10 +304,6 @@ typedef struct st_record_cache /* Used when caching records */
uint rc_length,read_length,reclength;
my_off_t rc_record_pos,end_of_file;
uchar *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
-#ifdef HAVE_AIOWAIT
- int use_async_io;
- my_aio_result aio_result;
-#endif
enum cache_type type;
} RECORD_CACHE;
@@ -355,6 +334,7 @@ typedef struct st_dynamic_array
uint elements,max_element;
uint alloc_increment;
uint size_of_element;
+ PSI_memory_key m_psi_key;
myf malloc_flags;
} DYNAMIC_ARRAY;
@@ -493,15 +473,6 @@ typedef struct st_io_cache /* Used when caching files */
somewhere else
*/
size_t alloced_buffer;
-#ifdef HAVE_AIOWAIT
- /*
- As inidicated by ifdef, this is for async I/O, which is not currently
- used (because it's not reliable on all systems)
- */
- uint inited;
- my_off_t aio_read_pos;
- my_aio_result aio_result;
-#endif
} IO_CACHE;
typedef int (*qsort2_cmp)(const void *, const void *, const void *);
@@ -511,6 +482,8 @@ typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
extern my_error_reporter my_charset_error_reporter;
+extern PSI_file_key key_file_io_cache;
+
/* inline functions for mf_iocache */
extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
@@ -698,16 +671,17 @@ int my_set_user(const char *user, struct passwd *user_info, myf MyFlags);
extern int check_if_legal_filename(const char *path);
extern int check_if_legal_tablename(const char *path);
-#ifdef __WIN__
+#ifdef _WIN32
extern my_bool is_filename_allowed(const char *name, size_t length,
my_bool allow_current_dir);
-#else /* __WIN__ */
+#else /* _WIN32 */
# define is_filename_allowed(name, length, allow_cwd) (TRUE)
-#endif /* __WIN__ */
+#endif /* _WIN32 */
#ifdef _WIN32
/* Windows-only functions (CRT equivalents)*/
extern HANDLE my_get_osfhandle(File fd);
+extern File my_win_handle2File(HANDLE hFile);
extern void my_osmaperr(unsigned long last_error);
#endif
@@ -807,6 +781,10 @@ my_off_t my_get_ptr(uchar *ptr, size_t pack_length);
extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize,
enum cache_type type,my_off_t seek_offset,
my_bool use_async_io, myf cache_myflags);
+extern int init_io_cache_ext(IO_CACHE *info, File file, size_t cachesize,
+ enum cache_type type, my_off_t seek_offset,
+ pbool use_async_io, myf cache_myflags,
+ PSI_file_key file_key);
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
my_off_t seek_offset, my_bool use_async_io,
my_bool clear_cache);
@@ -818,7 +796,6 @@ void end_slave_io_cache(IO_CACHE *cache);
void seek_io_cache(IO_CACHE *cache, my_off_t needed_offset);
extern void remove_io_thread(IO_CACHE *info);
-extern int _my_b_async_read(IO_CACHE *info,uchar *Buffer,size_t Count);
extern int my_b_append(IO_CACHE *info,const uchar *Buffer,size_t Count);
extern int my_b_safe_write(IO_CACHE *info,const uchar *Buffer,size_t Count);
@@ -842,11 +819,12 @@ extern my_bool real_open_cached_file(IO_CACHE *cache);
extern void close_cached_file(IO_CACHE *cache);
File create_temp_file(char *to, const char *dir, const char *pfx,
int mode, myf MyFlags);
-#define my_init_dynamic_array(A,B,C,D,E) init_dynamic_array2(A,B,NULL,C,D,E)
-#define my_init_dynamic_array2(A,B,C,D,E,F) init_dynamic_array2(A,B,C,D,E,F)
-extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size,
- void *init_buffer, uint init_alloc,
- uint alloc_increment, myf my_flags);
+#define my_init_dynamic_array(A,B,C,D,E,F) init_dynamic_array2(A,B,C,NULL,D,E,F)
+#define my_init_dynamic_array2(A,B,C,D,E,F,G) init_dynamic_array2(A,B,C,D,E,F,G)
+extern my_bool init_dynamic_array2(PSI_memory_key psi_key, DYNAMIC_ARRAY *array,
+ uint element_size, void *init_buffer,
+ uint init_alloc, uint alloc_increment,
+ myf my_flags);
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void* element);
extern void *alloc_dynamic(DYNAMIC_ARRAY *array);
extern void *pop_dynamic(DYNAMIC_ARRAY*);
@@ -893,13 +871,13 @@ extern uint32 copy_and_convert_extended(char *to, uint32 to_length,
extern void *my_malloc_lock(size_t length,myf flags);
extern void my_free_lock(void *ptr);
#else
-#define my_malloc_lock(A,B) my_malloc((A),(B))
+#define my_malloc_lock(A,B) my_malloc(PSI_INSTRUMENT_ME, (A),(B))
#define my_free_lock(A) my_free((A))
#endif
#define alloc_root_inited(A) ((A)->min_malloc != 0)
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
-extern void init_alloc_root(MEM_ROOT *mem_root, const char *name,
+extern void init_alloc_root(PSI_memory_key key, MEM_ROOT *mem_root,
size_t block_size, size_t pre_alloc_size,
myf my_flags);
extern void *alloc_root(MEM_ROOT *mem_root, size_t Size);
@@ -927,8 +905,11 @@ extern int my_compress_buffer(uchar *dest, size_t *destLen,
extern int packfrm(const uchar *, size_t, uchar **, size_t *);
extern int unpackfrm(uchar **, size_t *, const uchar *);
-extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem,
- size_t count);
+extern uint32 my_checksum(uint32, const void *, size_t);
+extern uint32 my_crc32c(uint32, const void *, size_t);
+
+extern const char *my_crc32c_implementation();
+
#ifdef DBUG_ASSERT_EXISTS
extern void my_debug_put_break_here(void);
#else
@@ -936,7 +917,6 @@ extern void my_debug_put_break_here(void);
#endif
extern void my_sleep(ulong m_seconds);
-extern ulong crc32(ulong crc, const uchar *buf, uint len);
extern uint my_set_max_open_files(uint files);
void my_free_open_file_info(void);
@@ -958,7 +938,7 @@ extern ulonglong my_interval_timer(void);
extern ulonglong my_getcputime(void);
#define microsecond_interval_timer() (my_interval_timer()/1000)
-#define hrtime_to_time(X) ((X).val/HRTIME_RESOLUTION)
+#define hrtime_to_time(X) ((time_t)((X).val/HRTIME_RESOLUTION))
#define hrtime_from_time(X) ((ulonglong)((X)*HRTIME_RESOLUTION))
#define hrtime_to_double(X) ((X).val/(double)HRTIME_RESOLUTION)
#define hrtime_sec_part(X) ((ulong)((X).val % HRTIME_RESOLUTION))
@@ -981,6 +961,13 @@ static inline my_hrtime_t make_hr_time(my_time_t time, ulong time_sec_part)
#define available_stack_size(CUR,END) (long) ((char*)(END) - (char*)(CUR))
#endif
+#ifndef MAP_SYNC
+#define MAP_SYNC 0x80000
+#endif
+#ifndef MAP_SHARED_VALIDATE
+#define MAP_SHARED_VALIDATE 0x03
+#endif
+
#ifdef HAVE_SYS_MMAN_H
#ifndef MAP_NOSYNC
#define MAP_NOSYNC 0
@@ -1064,14 +1051,18 @@ extern my_bool resolve_collation(const char *cl_name,
CHARSET_INFO **cl);
extern void free_charsets(void);
extern char *get_charsets_dir(char *buf);
-extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
+static inline my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2)
+{
+ return (cs1->csname == cs2->csname);
+}
extern my_bool init_compiled_charsets(myf flags);
extern void add_compiled_collation(struct charset_info_st *cs);
+extern void add_compiled_extra_collation(struct charset_info_st *cs);
extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
char *to, size_t to_length,
const char *from, size_t length);
extern char *get_tty_password(const char *opt_message);
-#ifdef __WIN__
+#ifdef _WIN32
#define BACKSLASH_MBTAIL
/* File system character set */
extern CHARSET_INFO *fs_character_set(void);
@@ -1085,8 +1076,7 @@ extern void thd_increment_bytes_sent(void *thd, size_t length);
extern void thd_increment_bytes_received(void *thd, size_t length);
extern void thd_increment_net_big_packet_count(void *thd, size_t length);
-#ifdef __WIN__
-extern my_bool have_tcpip; /* Is set if tcpip is used */
+#ifdef _WIN32
/* implemented in my_conio.c */
char* my_cgets(char *string, size_t clen, size_t* plen);
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
index 62794a2d70c..dfe2c3db7b3 100644
--- a/include/my_valgrind.h
+++ b/include/my_valgrind.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010, 2020, MariaDB Corporation.
+/* Copyright (C) 2010, 2022, MariaDB Corporation.
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
@@ -27,6 +27,7 @@
#if __has_feature(memory_sanitizer)
# include <sanitizer/msan_interface.h>
# define HAVE_valgrind
+# define HAVE_MEM_CHECK
# define MEM_UNDEFINED(a,len) __msan_allocated_memory(a,len)
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
# define MEM_MAKE_DEFINED(a,len) __msan_unpoison(a,len)
@@ -36,8 +37,14 @@
# define MEM_GET_VBITS(a,b,len) __msan_copy_shadow(b,a,len)
# define MEM_SET_VBITS(a,b,len) __msan_copy_shadow(a,b,len)
# define REDZONE_SIZE 8
+# ifdef __linux__
+# define MSAN_STAT_WORKAROUND(st) MEM_MAKE_DEFINED(st, sizeof(*st))
+# else
+# define MSAN_STAT_WORKAROUND(st) ((void) 0)
+# endif
#elif defined(HAVE_VALGRIND_MEMCHECK_H) && defined(HAVE_valgrind)
# include <valgrind/memcheck.h>
+# define HAVE_MEM_CHECK
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
# define MEM_MAKE_ADDRESSABLE(a,len) MEM_UNDEFINED(a,len)
# define MEM_MAKE_DEFINED(a,len) VALGRIND_MAKE_MEM_DEFINED(a,len)
@@ -47,7 +54,8 @@
# define MEM_GET_VBITS(a,b,len) VALGRIND_GET_VBITS(a,b,len)
# define MEM_SET_VBITS(a,b,len) VALGRIND_SET_VBITS(a,b,len)
# define REDZONE_SIZE 8
-#elif defined(__SANITIZE_ADDRESS__)
+# define MSAN_STAT_WORKAROUND(st) ((void) 0)
+#elif defined(__SANITIZE_ADDRESS__) && (!defined(_MSC_VER) || defined (__clang__))
# include <sanitizer/asan_interface.h>
/* How to do manual poisoning:
https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
@@ -60,6 +68,7 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
# define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0)
+# define MSAN_STAT_WORKAROUND(st) ((void) 0)
# define REDZONE_SIZE 8
#else
# define MEM_UNDEFINED(a,len) ((void) 0)
@@ -71,14 +80,9 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_GET_VBITS(a,b,len) ((void) 0)
# define MEM_SET_VBITS(a,b,len) ((void) 0)
# define REDZONE_SIZE 0
+# define MSAN_STAT_WORKAROUND(st) ((void) 0)
#endif /* __has_feature(memory_sanitizer) */
-#ifdef HAVE_valgrind
-#define IF_VALGRIND(A,B) A
-#else
-#define IF_VALGRIND(A,B) B
-#endif
-
#ifdef TRASH_FREED_MEMORY
/*
_TRASH_FILL() has to call MEM_MAKE_ADDRESSABLE() to cancel any effect of
diff --git a/include/myisam.h b/include/myisam.h
index f2e31bb9f60..0942584e874 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -291,7 +291,9 @@ extern int mi_extra(struct st_myisam_info *file,
void *extra_arg);
extern int mi_reset(struct st_myisam_info *file);
extern ha_rows mi_records_in_range(MI_INFO *info,int inx,
- key_range *min_key, key_range *max_key);
+ const key_range *min_key,
+ const key_range *max_key,
+ page_range *pages);
extern int mi_log(int activate_log);
extern int mi_is_changed(struct st_myisam_info *info);
extern int mi_delete_all_rows(struct st_myisam_info *info);
@@ -309,6 +311,8 @@ extern int mi_make_backup_of_index(struct st_myisam_info *info,
#define MYISAMCHK_VERIFY 2 /* Verify, run repair if failure */
typedef uint mi_bit_type;
+typedef struct st_sort_key_blocks SORT_KEY_BLOCKS;
+typedef struct st_sort_ftbuf SORT_FT_BUF;
typedef struct st_mi_bit_buff
{ /* Used for packing of record */
diff --git a/include/myisamchk.h b/include/myisamchk.h
index 5876d67ca5f..c494c672ec7 100644
--- a/include/myisamchk.h
+++ b/include/myisamchk.h
@@ -20,6 +20,8 @@
#ifndef _myisamchk_h
#define _myisamchk_h
+#include <my_stack_alloc.h>
+
/*
Flags used by xxxxchk.c or/and ha_xxxx.cc that are NOT passed
to xxxcheck.c follows:
@@ -33,15 +35,6 @@
#define O_NEW_DATA 2U
#define O_DATA_LOST 4U
-typedef struct st_sort_key_blocks /* Used when sorting */
-{
- uchar *buff, *end_pos;
- uchar lastkey[HA_MAX_POSSIBLE_KEY_BUFF];
- uint last_length;
- int inited;
-} SORT_KEY_BLOCKS;
-
-
/*
MARIA/MYISAM supports several statistics collection
methods. Currently statistics collection method is not stored in
@@ -77,7 +70,7 @@ typedef struct st_handler_check_param
*/
ulonglong unique_count[HA_MAX_KEY_SEG + 1];
ulonglong notnull_count[HA_MAX_KEY_SEG + 1];
-
+ ulonglong max_allowed_lsn;
my_off_t search_after_block;
my_off_t new_file_pos, key_file_blocks;
my_off_t keydata, totaldata, key_blocks, start_check_pos;
@@ -94,7 +87,7 @@ typedef struct st_handler_check_param
/* Following is used to check if rows are visible */
ulonglong max_trid, max_found_trid;
ulonglong not_visible_rows_found;
- ulonglong sort_buffer_length;
+ ulonglong sort_buffer_length, orig_sort_buffer_length;
ulonglong use_buffers; /* Used as param to getopt() */
size_t read_buffer_length, write_buffer_length, sort_key_blocks;
time_t backup_time; /* To sign backup files */
@@ -103,6 +96,7 @@ typedef struct st_handler_check_param
uint out_flag, error_printed, verbose;
uint opt_sort_key, total_files, max_level;
uint key_cache_block_size, pagecache_block_size;
+ uint skip_lsn_error_count;
int tmpfile_createflag, err_count;
myf myf_rw;
uint16 language;
@@ -111,6 +105,7 @@ typedef struct st_handler_check_param
my_bool retry_repair, force_sort, calc_checksum, static_row_size;
char temp_filename[FN_REFLEN];
IO_CACHE read_cache;
+ void **stack_end_ptr;
enum_handler_stats_method stats_method;
/* For reporting progress */
uint stage, max_stage;
@@ -125,14 +120,6 @@ typedef struct st_handler_check_param
} HA_CHECK;
-typedef struct st_sort_ftbuf
-{
- uchar *buf, *end;
- int count;
- uchar lastkey[HA_MAX_KEY_BUFF];
-} SORT_FT_BUF;
-
-
typedef struct st_buffpek {
my_off_t file_pos; /* Where we are in the sort file */
uchar *base, *key; /* Key pointers */
diff --git a/include/myisammrg.h b/include/myisammrg.h
index 76286000ff5..78e7ac00e8f 100644
--- a/include/myisammrg.h
+++ b/include/myisammrg.h
@@ -116,7 +116,9 @@ extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function,
extern int myrg_reset(MYRG_INFO *info);
extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv);
extern ha_rows myrg_records_in_range(MYRG_INFO *info, int inx,
- key_range *min_key, key_range *max_key);
+ const key_range *min_key,
+ const key_range *max_key,
+ page_range *pages);
extern ha_rows myrg_records(MYRG_INFO *info);
extern ulonglong myrg_position(MYRG_INFO *info);
diff --git a/include/mysql.h b/include/mysql.h
index 114d763e58c..7f2c5e3406c 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -98,6 +98,9 @@ extern char *mysql_unix_port;
#define IS_LONGDATA(t) ((t) >= MYSQL_TYPE_TINY_BLOB && (t) <= MYSQL_TYPE_STRING)
+typedef struct st_mysql_const_lex_string MARIADB_CONST_STRING;
+
+
typedef struct st_mysql_field {
char *name; /* Name of column */
char *org_name; /* Original column name, if an alias */
@@ -412,6 +415,14 @@ MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res);
MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res);
MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res);
+
+
+
+int STDCALL mariadb_field_attr(MARIADB_CONST_STRING *attr,
+ const MYSQL_FIELD *field,
+ enum mariadb_field_attr_t type);
+
+
unsigned int STDCALL mysql_field_count(MYSQL *mysql);
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 0f9f130cb8e..e1cc53564ab 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -23,18 +23,20 @@
unlike other compilers, uses C++ mangling for variables not only
for functions.
*/
-#if defined(_MSC_VER)
- #ifdef __cplusplus
- #define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
+#ifdef MYSQL_DYNAMIC_PLUGIN
+ #ifdef _MSC_VER
+ #define MYSQL_DLLEXPORT _declspec(dllexport)
#else
- #define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
- #endif
-#else /*_MSC_VER */
- #ifdef __cplusplus
- #define MYSQL_PLUGIN_EXPORT extern "C"
- #else
- #define MYSQL_PLUGIN_EXPORT
+ #define MYSQL_DLLEXPORT
#endif
+#else
+ #define MYSQL_DLLEXPORT
+#endif
+
+#ifdef __cplusplus
+ #define MYSQL_PLUGIN_EXPORT extern "C" MYSQL_DLLEXPORT
+#else
+ #define MYSQL_PLUGIN_EXPORT MYSQL_DLLEXPORT
#endif
#ifdef __cplusplus
@@ -88,11 +90,13 @@ typedef struct st_mysql_xid MYSQL_XID;
#define MYSQL_AUDIT_PLUGIN 5
#define MYSQL_REPLICATION_PLUGIN 6
#define MYSQL_AUTHENTICATION_PLUGIN 7
-#define MYSQL_MAX_PLUGIN_TYPE_NUM 10 /* The number of plugin types */
+#define MYSQL_MAX_PLUGIN_TYPE_NUM 12 /* The number of plugin types */
/* MariaDB plugin types */
#define MariaDB_PASSWORD_VALIDATION_PLUGIN 8
#define MariaDB_ENCRYPTION_PLUGIN 9
+#define MariaDB_DATA_TYPE_PLUGIN 10
+#define MariaDB_FUNCTION_PLUGIN 11
/* We use the following strings to define licenses for plugins */
#define PLUGIN_LICENSE_PROPRIETARY 0
@@ -175,7 +179,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
- SHOW_always_last
+ SHOW_SIZE_T, SHOW_always_last
};
/* backward compatibility mapping. */
@@ -311,6 +315,12 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd,
const type def_val; \
} MYSQL_SYSVAR_NAME(name)
+#define DECLARE_MYSQL_SYSVAR_CONST_BASIC(name, type) struct { \
+ MYSQL_PLUGIN_VAR_HEADER; \
+ const type *value; \
+ const type def_val; \
+} MYSQL_SYSVAR_NAME(name)
+
#define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
MYSQL_PLUGIN_VAR_HEADER; \
type *value; type def_val; \
@@ -365,6 +375,11 @@ DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \
PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
#name, comment, check, update, &varname, def}
+#define MYSQL_SYSVAR_CONST_STR(name, varname, opt, comment, check, update, def) \
+DECLARE_MYSQL_SYSVAR_CONST_BASIC(name, char *) = { \
+ PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
+ #name, comment, check, update, &varname, def}
+
#define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \
PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
@@ -647,7 +662,6 @@ int thd_in_lock_tables(const MYSQL_THD thd);
int thd_tablespace_op(const MYSQL_THD thd);
long long thd_test_options(const MYSQL_THD thd, long long test_options);
int thd_sql_command(const MYSQL_THD thd);
-void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
void thd_storage_lock_wait(MYSQL_THD thd, long long value);
int thd_tx_isolation(const MYSQL_THD thd);
int thd_tx_is_read_only(const MYSQL_THD thd);
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp
index c5ae678e82a..07fe16ea92f 100644
--- a/include/mysql/plugin_audit.h.pp
+++ b/include/mysql/plugin_audit.h.pp
@@ -1,5 +1,9 @@
+class THD;
+class Item;
typedef char my_bool;
typedef void * MYSQL_PLUGIN;
+extern "C" {
+extern "C" {
extern struct base64_service_st {
int (*base64_needed_encoded_length_ptr)(int length_of_data);
int (*base64_encode_max_arg_length_ptr)(void);
@@ -16,7 +20,11 @@ int my_base64_decode_max_arg_length();
int my_base64_encode(const void *src, size_t src_len, char *dst);
int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
-extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
+}
+extern "C" {
+extern void (*debug_sync_C_callback_ptr)(THD*, const char *, size_t);
+}
+extern "C" {
struct encryption_service_st {
unsigned int (*encryption_key_get_latest_version_func)(unsigned int key_id);
unsigned int (*encryption_key_get_func)(unsigned int key_id, unsigned int key_version,
@@ -57,6 +65,8 @@ static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
*dlen= d1 + d2;
return res1 ? res1 : res2;
}
+}
+extern "C" {
struct st_encryption_scheme_key {
unsigned int version;
unsigned char key[16];
@@ -93,15 +103,19 @@ int encryption_scheme_decrypt(const unsigned char* src, unsigned int slen,
struct st_encryption_scheme *scheme,
unsigned int key_version, unsigned int i32_1,
unsigned int i32_2, unsigned long long i64);
+}
+extern "C" {
enum thd_kill_levels {
THD_IS_NOT_KILLED=0,
THD_ABORT_SOFTLY=50,
THD_ABORT_ASAP=100,
};
extern struct kill_statement_service_st {
- enum thd_kill_levels (*thd_kill_level_func)(const void*);
+ enum thd_kill_levels (*thd_kill_level_func)(const THD*);
} *thd_kill_statement_service;
-enum thd_kill_levels thd_kill_level(const void*);
+enum thd_kill_levels thd_kill_level(const THD*);
+}
+extern "C" {
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
@@ -123,6 +137,8 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
+}
+extern "C" {
extern struct my_md5_service_st {
void (*my_md5_type)(unsigned char*, const char*, size_t);
void (*my_md5_multi_type)(unsigned char*, ...);
@@ -137,6 +153,8 @@ size_t my_md5_context_size();
void my_md5_init(void *context);
void my_md5_input(void *context, const unsigned char *buf, size_t len);
void my_md5_result(void *context, unsigned char *digest);
+}
+extern "C" {
enum my_aes_mode {
MY_AES_ECB, MY_AES_CBC
};
@@ -166,6 +184,8 @@ int my_aes_crypt(enum my_aes_mode mode, int flags,
int my_random_bytes(unsigned char* buf, int num);
unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
unsigned int my_aes_ctx_size(enum my_aes_mode mode);
+}
+extern "C" {
extern struct my_print_error_service_st {
void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
@@ -174,32 +194,38 @@ extern struct my_print_error_service_st {
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
+}
+extern "C" {
extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
} *my_snprintf_service;
size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
+}
+extern "C" {
extern struct progress_report_service_st {
- void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
- void (*thd_progress_report_func)(void* thd,
+ void (*thd_progress_init_func)(THD* thd, unsigned int max_stage);
+ void (*thd_progress_report_func)(THD* thd,
unsigned long long progress,
unsigned long long max_progress);
- void (*thd_progress_next_stage_func)(void* thd);
- void (*thd_progress_end_func)(void* thd);
- const char *(*set_thd_proc_info_func)(void*, const char *info,
+ void (*thd_progress_next_stage_func)(THD* thd);
+ void (*thd_progress_end_func)(THD* thd);
+ const char *(*set_thd_proc_info_func)(THD*, const char *info,
const char *func,
const char *file,
unsigned int line);
} *progress_report_service;
-void thd_progress_init(void* thd, unsigned int max_stage);
-void thd_progress_report(void* thd,
+void thd_progress_init(THD* thd, unsigned int max_stage);
+void thd_progress_report(THD* thd,
unsigned long long progress,
unsigned long long max_progress);
-void thd_progress_next_stage(void* thd);
-void thd_progress_end(void* thd);
-const char *set_thd_proc_info(void*, const char * info, const char *func,
+void thd_progress_next_stage(THD* thd);
+void thd_progress_end(THD* thd);
+const char *set_thd_proc_info(THD*, const char * info, const char *func,
const char *file, unsigned int line);
+}
+extern "C" {
extern struct my_sha1_service_st {
void (*my_sha1_type)(unsigned char*, const char*, size_t);
void (*my_sha1_multi_type)(unsigned char*, ...);
@@ -214,6 +240,8 @@ size_t my_sha1_context_size();
void my_sha1_init(void *context);
void my_sha1_input(void *context, const unsigned char *buf, size_t len);
void my_sha1_result(void *context, unsigned char *digest);
+}
+extern "C" {
extern struct my_sha2_service_st {
void (*my_sha224_type)(unsigned char*, const char*, size_t);
void (*my_sha224_multi_type)(unsigned char*, ...);
@@ -264,6 +292,8 @@ size_t my_sha512_context_size();
void my_sha512_init(void *context);
void my_sha512_input(void *context, const unsigned char *buf, size_t len);
void my_sha512_result(void *context, unsigned char *digest);
+}
+extern "C" {
struct st_mysql_lex_string
{
char *str;
@@ -277,64 +307,73 @@ struct st_mysql_const_lex_string
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, size_t);
- void *(*thd_calloc_func)(void*, size_t);
- char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, size_t);
- void *(*thd_memdup_func)(void*, const void*, size_t);
- MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
+ void *(*thd_alloc_func)(THD*, size_t);
+ void *(*thd_calloc_func)(THD*, size_t);
+ char *(*thd_strdup_func)(THD*, const char *);
+ char *(*thd_strmake_func)(THD*, const char *, size_t);
+ void *(*thd_memdup_func)(THD*, const void*, size_t);
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(THD*,
MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
-void *thd_alloc(void* thd, size_t size);
-void *thd_calloc(void* thd, size_t size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, size_t size);
-void *thd_memdup(void* thd, const void* str, size_t size);
+void *thd_alloc(THD* thd, size_t size);
+void *thd_calloc(THD* thd, size_t size);
+char *thd_strdup(THD* thd, const char *str);
+char *thd_strmake(THD* thd, const char *str, size_t size);
+void *thd_memdup(THD* thd, const void* str, size_t size);
MYSQL_CONST_LEX_STRING
-*thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
+*thd_make_lex_string(THD* thd, MYSQL_CONST_LEX_STRING *lex_str,
const char *str, size_t size,
int allocate_lex_string);
+}
+extern "C" {
extern struct thd_autoinc_service_st {
- void (*thd_get_autoinc_func)(const void* thd,
+ void (*thd_get_autoinc_func)(const THD* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
-void thd_get_autoinc(const void* thd,
+void thd_get_autoinc(const THD* thd,
unsigned long* off, unsigned long* inc);
+}
+extern "C" {
extern struct thd_error_context_service_st {
- const char *(*thd_get_error_message_func)(const void* thd);
- unsigned int (*thd_get_error_number_func)(const void* thd);
- unsigned long (*thd_get_error_row_func)(const void* thd);
- void (*thd_inc_error_row_func)(void* thd);
- char *(*thd_get_error_context_description_func)(void* thd,
+ const char *(*thd_get_error_message_func)(const THD* thd);
+ unsigned int (*thd_get_error_number_func)(const THD* thd);
+ unsigned long (*thd_get_error_row_func)(const THD* thd);
+ void (*thd_inc_error_row_func)(THD* thd);
+ char *(*thd_get_error_context_description_func)(THD* thd,
char *buffer,
unsigned int length,
unsigned int max_query_length);
} *thd_error_context_service;
-const char *thd_get_error_message(const void* thd);
-unsigned int thd_get_error_number(const void* thd);
-unsigned long thd_get_error_row(const void* thd);
-void thd_inc_error_row(void* thd);
-char *thd_get_error_context_description(void* thd,
+const char *thd_get_error_message(const THD* thd);
+unsigned int thd_get_error_number(const THD* thd);
+unsigned long thd_get_error_row(const THD* thd);
+void thd_inc_error_row(THD* thd);
+char *thd_get_error_context_description(THD* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
+}
+extern "C" {
extern struct thd_rnd_service_st {
- double (*thd_rnd_ptr)(void* thd);
- void (*thd_c_r_p_ptr)(void* thd, char *to, size_t length);
+ double (*thd_rnd_ptr)(THD* thd);
+ void (*thd_c_r_p_ptr)(THD* thd, char *to, size_t length);
} *thd_rnd_service;
-double thd_rnd(void* thd);
-void thd_create_random_password(void* thd, char *to, size_t length);
+double thd_rnd(THD* thd);
+void thd_create_random_password(THD* thd, char *to, size_t length);
+}
+extern "C" {
typedef int MYSQL_THD_KEY_T;
extern struct thd_specifics_service_st {
int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
void (*thd_key_delete_func)(MYSQL_THD_KEY_T *key);
- void *(*thd_getspecific_func)(void* thd, MYSQL_THD_KEY_T key);
- int (*thd_setspecific_func)(void* thd, MYSQL_THD_KEY_T key, void *value);
+ void *(*thd_getspecific_func)(THD* thd, MYSQL_THD_KEY_T key);
+ int (*thd_setspecific_func)(THD* thd, MYSQL_THD_KEY_T key, void *value);
} *thd_specifics_service;
int thd_key_create(MYSQL_THD_KEY_T *key);
void thd_key_delete(MYSQL_THD_KEY_T *key);
-void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key);
-int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value);
+void* thd_getspecific(THD* thd, MYSQL_THD_KEY_T key);
+int thd_setspecific(THD* thd, MYSQL_THD_KEY_T key, void *value);
+}
typedef long my_time_t;
enum enum_mysql_timestamp_type
{
@@ -348,12 +387,15 @@ typedef struct st_mysql_time
my_bool neg;
enum enum_mysql_timestamp_type time_type;
} MYSQL_TIME;
+extern "C" {
extern struct thd_timezone_service_st {
- my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
- void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+ my_time_t (*thd_TIME_to_gmt_sec)(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(THD* thd, MYSQL_TIME *ltime, my_time_t t);
} *thd_timezone_service;
-my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
-void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
+my_time_t thd_TIME_to_gmt_sec(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+}
+extern "C" {
typedef enum _thd_wait_type_e {
THD_WAIT_SLEEP= 1,
THD_WAIT_DISKIO= 2,
@@ -369,11 +411,13 @@ typedef enum _thd_wait_type_e {
THD_WAIT_LAST= 12
} thd_wait_type;
extern struct thd_wait_service_st {
- void (*thd_wait_begin_func)(void*, int);
- void (*thd_wait_end_func)(void*);
+ void (*thd_wait_begin_func)(THD*, int);
+ void (*thd_wait_end_func)(THD*);
} *thd_wait_service;
-void thd_wait_begin(void* thd, int wait_type);
-void thd_wait_end(void* thd);
+void thd_wait_begin(THD* thd, int wait_type);
+void thd_wait_end(THD* thd);
+}
+extern "C" {
enum json_types
{
JSV_BAD_JSON=-1,
@@ -419,6 +463,8 @@ int json_escape_string(const char *str,const char *str_end,
char *json, char *json_end);
int json_unescape_json(const char *json_str, const char *json_end,
char *res, char *res_end);
+}
+}
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -432,7 +478,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
- SHOW_always_last
+ SHOW_SIZE_T, SHOW_always_last
};
enum enum_var_type
{
@@ -444,13 +490,13 @@ struct st_mysql_show_var {
enum enum_mysql_show_type type;
};
struct system_status_var;
-typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
+typedef int (*mysql_show_var_func)(THD*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
struct st_mysql_sys_var;
struct st_mysql_value;
-typedef int (*mysql_var_check_func)(void* thd,
+typedef int (*mysql_var_check_func)(THD* thd,
struct st_mysql_sys_var *var,
void *save, struct st_mysql_value *value);
-typedef void (*mysql_var_update_func)(void* thd,
+typedef void (*mysql_var_update_func)(THD* thd,
struct st_mysql_sys_var *var,
void *var_ptr, const void *save);
struct st_mysql_plugin
@@ -485,6 +531,7 @@ struct st_maria_plugin
const char *version_info;
unsigned int maturity;
};
+extern "C" {
enum enum_ftparser_mode
{
MYSQL_FTPARSER_SIMPLE_MODE= 0,
@@ -531,6 +578,7 @@ struct st_mysql_ftparser
int (*init)(MYSQL_FTPARSER_PARAM *param);
int (*deinit)(MYSQL_FTPARSER_PARAM *param);
};
+}
struct st_mysql_daemon
{
int interface_version;
@@ -555,24 +603,26 @@ struct st_mysql_value
int (*val_int)(struct st_mysql_value *, long long *intbuf);
int (*is_unsigned)(struct st_mysql_value *);
};
-int thd_in_lock_tables(const void* thd);
-int thd_tablespace_op(const void* thd);
-long long thd_test_options(const void* thd, long long test_options);
-int thd_sql_command(const void* thd);
-void **thd_ha_data(const void* thd, const struct handlerton *hton);
-void thd_storage_lock_wait(void* thd, long long value);
-int thd_tx_isolation(const void* thd);
-int thd_tx_is_read_only(const void* thd);
+extern "C" {
+int thd_in_lock_tables(const THD* thd);
+int thd_tablespace_op(const THD* thd);
+long long thd_test_options(const THD* thd, long long test_options);
+int thd_sql_command(const THD* thd);
+void thd_storage_lock_wait(THD* thd, long long value);
+int thd_tx_isolation(const THD* thd);
+int thd_tx_is_read_only(const THD* thd);
int mysql_tmpfile(const char *prefix);
-unsigned long thd_get_thread_id(const void* thd);
-void thd_get_xid(const void* thd, MYSQL_XID *xid);
-void mysql_query_cache_invalidate4(void* thd,
+unsigned long thd_get_thread_id(const THD* thd);
+void thd_get_xid(const THD* thd, MYSQL_XID *xid);
+void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
-void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
-void thd_set_ha_data(void* thd, const struct handlerton *hton,
+void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
+void thd_set_ha_data(THD* thd, const struct handlerton *hton,
const void *ha_data);
-void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
+void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
+}
+extern "C" {
struct mysql_event_general
{
unsigned int event_subclass;
@@ -630,7 +680,8 @@ struct mysql_event_table
struct st_mysql_audit
{
int interface_version;
- void (*release_thd)(void*);
- void (*event_notify)(void*, unsigned int, const void *);
+ void (*release_thd)(THD*);
+ void (*event_notify)(THD*, unsigned int, const void *);
unsigned long class_mask[1];
};
+}
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index 41cb7d075c4..18eebd5e04a 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -1,5 +1,9 @@
+class THD;
+class Item;
typedef char my_bool;
typedef void * MYSQL_PLUGIN;
+extern "C" {
+extern "C" {
extern struct base64_service_st {
int (*base64_needed_encoded_length_ptr)(int length_of_data);
int (*base64_encode_max_arg_length_ptr)(void);
@@ -16,7 +20,11 @@ int my_base64_decode_max_arg_length();
int my_base64_encode(const void *src, size_t src_len, char *dst);
int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
-extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
+}
+extern "C" {
+extern void (*debug_sync_C_callback_ptr)(THD*, const char *, size_t);
+}
+extern "C" {
struct encryption_service_st {
unsigned int (*encryption_key_get_latest_version_func)(unsigned int key_id);
unsigned int (*encryption_key_get_func)(unsigned int key_id, unsigned int key_version,
@@ -57,6 +65,8 @@ static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
*dlen= d1 + d2;
return res1 ? res1 : res2;
}
+}
+extern "C" {
struct st_encryption_scheme_key {
unsigned int version;
unsigned char key[16];
@@ -93,15 +103,19 @@ int encryption_scheme_decrypt(const unsigned char* src, unsigned int slen,
struct st_encryption_scheme *scheme,
unsigned int key_version, unsigned int i32_1,
unsigned int i32_2, unsigned long long i64);
+}
+extern "C" {
enum thd_kill_levels {
THD_IS_NOT_KILLED=0,
THD_ABORT_SOFTLY=50,
THD_ABORT_ASAP=100,
};
extern struct kill_statement_service_st {
- enum thd_kill_levels (*thd_kill_level_func)(const void*);
+ enum thd_kill_levels (*thd_kill_level_func)(const THD*);
} *thd_kill_statement_service;
-enum thd_kill_levels thd_kill_level(const void*);
+enum thd_kill_levels thd_kill_level(const THD*);
+}
+extern "C" {
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
@@ -123,6 +137,8 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
+}
+extern "C" {
extern struct my_md5_service_st {
void (*my_md5_type)(unsigned char*, const char*, size_t);
void (*my_md5_multi_type)(unsigned char*, ...);
@@ -137,6 +153,8 @@ size_t my_md5_context_size();
void my_md5_init(void *context);
void my_md5_input(void *context, const unsigned char *buf, size_t len);
void my_md5_result(void *context, unsigned char *digest);
+}
+extern "C" {
enum my_aes_mode {
MY_AES_ECB, MY_AES_CBC
};
@@ -166,6 +184,8 @@ int my_aes_crypt(enum my_aes_mode mode, int flags,
int my_random_bytes(unsigned char* buf, int num);
unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
unsigned int my_aes_ctx_size(enum my_aes_mode mode);
+}
+extern "C" {
extern struct my_print_error_service_st {
void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
@@ -174,32 +194,38 @@ extern struct my_print_error_service_st {
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
+}
+extern "C" {
extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
} *my_snprintf_service;
size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
+}
+extern "C" {
extern struct progress_report_service_st {
- void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
- void (*thd_progress_report_func)(void* thd,
+ void (*thd_progress_init_func)(THD* thd, unsigned int max_stage);
+ void (*thd_progress_report_func)(THD* thd,
unsigned long long progress,
unsigned long long max_progress);
- void (*thd_progress_next_stage_func)(void* thd);
- void (*thd_progress_end_func)(void* thd);
- const char *(*set_thd_proc_info_func)(void*, const char *info,
+ void (*thd_progress_next_stage_func)(THD* thd);
+ void (*thd_progress_end_func)(THD* thd);
+ const char *(*set_thd_proc_info_func)(THD*, const char *info,
const char *func,
const char *file,
unsigned int line);
} *progress_report_service;
-void thd_progress_init(void* thd, unsigned int max_stage);
-void thd_progress_report(void* thd,
+void thd_progress_init(THD* thd, unsigned int max_stage);
+void thd_progress_report(THD* thd,
unsigned long long progress,
unsigned long long max_progress);
-void thd_progress_next_stage(void* thd);
-void thd_progress_end(void* thd);
-const char *set_thd_proc_info(void*, const char * info, const char *func,
+void thd_progress_next_stage(THD* thd);
+void thd_progress_end(THD* thd);
+const char *set_thd_proc_info(THD*, const char * info, const char *func,
const char *file, unsigned int line);
+}
+extern "C" {
extern struct my_sha1_service_st {
void (*my_sha1_type)(unsigned char*, const char*, size_t);
void (*my_sha1_multi_type)(unsigned char*, ...);
@@ -214,6 +240,8 @@ size_t my_sha1_context_size();
void my_sha1_init(void *context);
void my_sha1_input(void *context, const unsigned char *buf, size_t len);
void my_sha1_result(void *context, unsigned char *digest);
+}
+extern "C" {
extern struct my_sha2_service_st {
void (*my_sha224_type)(unsigned char*, const char*, size_t);
void (*my_sha224_multi_type)(unsigned char*, ...);
@@ -264,6 +292,8 @@ size_t my_sha512_context_size();
void my_sha512_init(void *context);
void my_sha512_input(void *context, const unsigned char *buf, size_t len);
void my_sha512_result(void *context, unsigned char *digest);
+}
+extern "C" {
struct st_mysql_lex_string
{
char *str;
@@ -277,64 +307,73 @@ struct st_mysql_const_lex_string
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, size_t);
- void *(*thd_calloc_func)(void*, size_t);
- char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, size_t);
- void *(*thd_memdup_func)(void*, const void*, size_t);
- MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
+ void *(*thd_alloc_func)(THD*, size_t);
+ void *(*thd_calloc_func)(THD*, size_t);
+ char *(*thd_strdup_func)(THD*, const char *);
+ char *(*thd_strmake_func)(THD*, const char *, size_t);
+ void *(*thd_memdup_func)(THD*, const void*, size_t);
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(THD*,
MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
-void *thd_alloc(void* thd, size_t size);
-void *thd_calloc(void* thd, size_t size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, size_t size);
-void *thd_memdup(void* thd, const void* str, size_t size);
+void *thd_alloc(THD* thd, size_t size);
+void *thd_calloc(THD* thd, size_t size);
+char *thd_strdup(THD* thd, const char *str);
+char *thd_strmake(THD* thd, const char *str, size_t size);
+void *thd_memdup(THD* thd, const void* str, size_t size);
MYSQL_CONST_LEX_STRING
-*thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
+*thd_make_lex_string(THD* thd, MYSQL_CONST_LEX_STRING *lex_str,
const char *str, size_t size,
int allocate_lex_string);
+}
+extern "C" {
extern struct thd_autoinc_service_st {
- void (*thd_get_autoinc_func)(const void* thd,
+ void (*thd_get_autoinc_func)(const THD* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
-void thd_get_autoinc(const void* thd,
+void thd_get_autoinc(const THD* thd,
unsigned long* off, unsigned long* inc);
+}
+extern "C" {
extern struct thd_error_context_service_st {
- const char *(*thd_get_error_message_func)(const void* thd);
- unsigned int (*thd_get_error_number_func)(const void* thd);
- unsigned long (*thd_get_error_row_func)(const void* thd);
- void (*thd_inc_error_row_func)(void* thd);
- char *(*thd_get_error_context_description_func)(void* thd,
+ const char *(*thd_get_error_message_func)(const THD* thd);
+ unsigned int (*thd_get_error_number_func)(const THD* thd);
+ unsigned long (*thd_get_error_row_func)(const THD* thd);
+ void (*thd_inc_error_row_func)(THD* thd);
+ char *(*thd_get_error_context_description_func)(THD* thd,
char *buffer,
unsigned int length,
unsigned int max_query_length);
} *thd_error_context_service;
-const char *thd_get_error_message(const void* thd);
-unsigned int thd_get_error_number(const void* thd);
-unsigned long thd_get_error_row(const void* thd);
-void thd_inc_error_row(void* thd);
-char *thd_get_error_context_description(void* thd,
+const char *thd_get_error_message(const THD* thd);
+unsigned int thd_get_error_number(const THD* thd);
+unsigned long thd_get_error_row(const THD* thd);
+void thd_inc_error_row(THD* thd);
+char *thd_get_error_context_description(THD* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
+}
+extern "C" {
extern struct thd_rnd_service_st {
- double (*thd_rnd_ptr)(void* thd);
- void (*thd_c_r_p_ptr)(void* thd, char *to, size_t length);
+ double (*thd_rnd_ptr)(THD* thd);
+ void (*thd_c_r_p_ptr)(THD* thd, char *to, size_t length);
} *thd_rnd_service;
-double thd_rnd(void* thd);
-void thd_create_random_password(void* thd, char *to, size_t length);
+double thd_rnd(THD* thd);
+void thd_create_random_password(THD* thd, char *to, size_t length);
+}
+extern "C" {
typedef int MYSQL_THD_KEY_T;
extern struct thd_specifics_service_st {
int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
void (*thd_key_delete_func)(MYSQL_THD_KEY_T *key);
- void *(*thd_getspecific_func)(void* thd, MYSQL_THD_KEY_T key);
- int (*thd_setspecific_func)(void* thd, MYSQL_THD_KEY_T key, void *value);
+ void *(*thd_getspecific_func)(THD* thd, MYSQL_THD_KEY_T key);
+ int (*thd_setspecific_func)(THD* thd, MYSQL_THD_KEY_T key, void *value);
} *thd_specifics_service;
int thd_key_create(MYSQL_THD_KEY_T *key);
void thd_key_delete(MYSQL_THD_KEY_T *key);
-void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key);
-int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value);
+void* thd_getspecific(THD* thd, MYSQL_THD_KEY_T key);
+int thd_setspecific(THD* thd, MYSQL_THD_KEY_T key, void *value);
+}
typedef long my_time_t;
enum enum_mysql_timestamp_type
{
@@ -348,12 +387,15 @@ typedef struct st_mysql_time
my_bool neg;
enum enum_mysql_timestamp_type time_type;
} MYSQL_TIME;
+extern "C" {
extern struct thd_timezone_service_st {
- my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
- void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+ my_time_t (*thd_TIME_to_gmt_sec)(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(THD* thd, MYSQL_TIME *ltime, my_time_t t);
} *thd_timezone_service;
-my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
-void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
+my_time_t thd_TIME_to_gmt_sec(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+}
+extern "C" {
typedef enum _thd_wait_type_e {
THD_WAIT_SLEEP= 1,
THD_WAIT_DISKIO= 2,
@@ -369,11 +411,13 @@ typedef enum _thd_wait_type_e {
THD_WAIT_LAST= 12
} thd_wait_type;
extern struct thd_wait_service_st {
- void (*thd_wait_begin_func)(void*, int);
- void (*thd_wait_end_func)(void*);
+ void (*thd_wait_begin_func)(THD*, int);
+ void (*thd_wait_end_func)(THD*);
} *thd_wait_service;
-void thd_wait_begin(void* thd, int wait_type);
-void thd_wait_end(void* thd);
+void thd_wait_begin(THD* thd, int wait_type);
+void thd_wait_end(THD* thd);
+}
+extern "C" {
enum json_types
{
JSV_BAD_JSON=-1,
@@ -419,6 +463,8 @@ int json_escape_string(const char *str,const char *str_end,
char *json, char *json_end);
int json_unescape_json(const char *json_str, const char *json_end,
char *res, char *res_end);
+}
+}
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -432,7 +478,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
- SHOW_always_last
+ SHOW_SIZE_T, SHOW_always_last
};
enum enum_var_type
{
@@ -444,13 +490,13 @@ struct st_mysql_show_var {
enum enum_mysql_show_type type;
};
struct system_status_var;
-typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
+typedef int (*mysql_show_var_func)(THD*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
struct st_mysql_sys_var;
struct st_mysql_value;
-typedef int (*mysql_var_check_func)(void* thd,
+typedef int (*mysql_var_check_func)(THD* thd,
struct st_mysql_sys_var *var,
void *save, struct st_mysql_value *value);
-typedef void (*mysql_var_update_func)(void* thd,
+typedef void (*mysql_var_update_func)(THD* thd,
struct st_mysql_sys_var *var,
void *var_ptr, const void *save);
struct st_mysql_plugin
@@ -485,6 +531,7 @@ struct st_maria_plugin
const char *version_info;
unsigned int maturity;
};
+extern "C" {
enum enum_ftparser_mode
{
MYSQL_FTPARSER_SIMPLE_MODE= 0,
@@ -531,6 +578,7 @@ struct st_mysql_ftparser
int (*init)(MYSQL_FTPARSER_PARAM *param);
int (*deinit)(MYSQL_FTPARSER_PARAM *param);
};
+}
struct st_mysql_daemon
{
int interface_version;
@@ -555,24 +603,25 @@ struct st_mysql_value
int (*val_int)(struct st_mysql_value *, long long *intbuf);
int (*is_unsigned)(struct st_mysql_value *);
};
-int thd_in_lock_tables(const void* thd);
-int thd_tablespace_op(const void* thd);
-long long thd_test_options(const void* thd, long long test_options);
-int thd_sql_command(const void* thd);
-void **thd_ha_data(const void* thd, const struct handlerton *hton);
-void thd_storage_lock_wait(void* thd, long long value);
-int thd_tx_isolation(const void* thd);
-int thd_tx_is_read_only(const void* thd);
+extern "C" {
+int thd_in_lock_tables(const THD* thd);
+int thd_tablespace_op(const THD* thd);
+long long thd_test_options(const THD* thd, long long test_options);
+int thd_sql_command(const THD* thd);
+void thd_storage_lock_wait(THD* thd, long long value);
+int thd_tx_isolation(const THD* thd);
+int thd_tx_is_read_only(const THD* thd);
int mysql_tmpfile(const char *prefix);
-unsigned long thd_get_thread_id(const void* thd);
-void thd_get_xid(const void* thd, MYSQL_XID *xid);
-void mysql_query_cache_invalidate4(void* thd,
+unsigned long thd_get_thread_id(const THD* thd);
+void thd_get_xid(const THD* thd, MYSQL_XID *xid);
+void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
-void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
-void thd_set_ha_data(void* thd, const struct handlerton *hton,
+void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
+void thd_set_ha_data(THD* thd, const struct handlerton *hton,
const void *ha_data);
-void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
+void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
+}
typedef struct st_plugin_vio_info
{
enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET,
@@ -588,6 +637,7 @@ typedef struct st_plugin_vio
int packet_len);
void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
} MYSQL_PLUGIN_VIO;
+extern "C" {
typedef struct st_mysql_server_auth_info
{
const char *user_name;
@@ -599,7 +649,7 @@ typedef struct st_mysql_server_auth_info
int password_used;
const char *host_or_ip;
unsigned int host_or_ip_length;
- void* thd;
+ THD* thd;
} MYSQL_SERVER_AUTH_INFO;
struct st_mysql_auth
{
@@ -611,3 +661,4 @@ struct st_mysql_auth
int (*preprocess_hash)(const char *hash, size_t hash_length,
unsigned char *out, size_t *out_length);
};
+}
diff --git a/include/mysql/plugin_data_type.h b/include/mysql/plugin_data_type.h
new file mode 100644
index 00000000000..77aa9fb27a2
--- /dev/null
+++ b/include/mysql/plugin_data_type.h
@@ -0,0 +1,49 @@
+#ifndef MARIADB_PLUGIN_DATA_TYPE_INCLUDED
+#define MARIADB_PLUGIN_DATA_TYPE_INCLUDED
+/* Copyright (C) 2019, Alexander Barkov and MariaDB
+
+ 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-1335 USA */
+
+/**
+ @file
+
+ Data Type Plugin API.
+
+ This file defines the API for server plugins that manage data types.
+*/
+
+#ifdef __cplusplus
+
+#include <mysql/plugin.h>
+
+/*
+ API for data type plugins. (MariaDB_DATA_TYPE_PLUGIN)
+*/
+#define MariaDB_DATA_TYPE_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
+
+
+struct st_mariadb_data_type
+{
+ int interface_version;
+ class Type_handler *type_handler;
+};
+
+
+/**
+ Data type plugin descriptor
+*/
+
+#endif /* __cplusplus */
+
+#endif /* MARIADB_PLUGIN_DATA_TYPE_INCLUDED */
diff --git a/include/mysql/plugin_data_type.h.pp b/include/mysql/plugin_data_type.h.pp
new file mode 100644
index 00000000000..3db2fdd0251
--- /dev/null
+++ b/include/mysql/plugin_data_type.h.pp
@@ -0,0 +1,629 @@
+class THD;
+class Item;
+typedef char my_bool;
+typedef void * MYSQL_PLUGIN;
+extern "C" {
+extern "C" {
+extern struct base64_service_st {
+ int (*base64_needed_encoded_length_ptr)(int length_of_data);
+ int (*base64_encode_max_arg_length_ptr)(void);
+ int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data);
+ int (*base64_decode_max_arg_length_ptr)();
+ int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst);
+ int (*base64_decode_ptr)(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
+} *base64_service;
+int my_base64_needed_encoded_length(int length_of_data);
+int my_base64_encode_max_arg_length(void);
+int my_base64_needed_decoded_length(int length_of_encoded_data);
+int my_base64_decode_max_arg_length();
+int my_base64_encode(const void *src, size_t src_len, char *dst);
+int my_base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
+}
+extern "C" {
+extern void (*debug_sync_C_callback_ptr)(THD*, const char *, size_t);
+}
+extern "C" {
+struct encryption_service_st {
+ unsigned int (*encryption_key_get_latest_version_func)(unsigned int key_id);
+ unsigned int (*encryption_key_get_func)(unsigned int key_id, unsigned int key_version,
+ unsigned char* buffer, unsigned int* length);
+ unsigned int (*encryption_ctx_size_func)(unsigned int key_id, unsigned int key_version);
+ int (*encryption_ctx_init_func)(void *ctx, const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen,
+ int flags, unsigned int key_id,
+ unsigned int key_version);
+ int (*encryption_ctx_update_func)(void *ctx, const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen);
+ int (*encryption_ctx_finish_func)(void *ctx, unsigned char* dst, unsigned int* dlen);
+ unsigned int (*encryption_encrypted_length_func)(unsigned int slen, unsigned int key_id, unsigned int key_version);
+};
+extern struct encryption_service_st encryption_handler;
+static inline unsigned int encryption_key_id_exists(unsigned int id)
+{
+ return encryption_handler.encryption_key_get_latest_version_func(id) != (~(unsigned int)0);
+}
+static inline unsigned int encryption_key_version_exists(unsigned int id, unsigned int version)
+{
+ unsigned int unused;
+ return encryption_handler.encryption_key_get_func((id),(version),(NULL),(&unused)) != (~(unsigned int)0);
+}
+static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen,
+ int flags, unsigned int key_id, unsigned int key_version)
+{
+ void *ctx= alloca(encryption_handler.encryption_ctx_size_func((key_id),(key_version)));
+ int res1, res2;
+ unsigned int d1, d2;
+ if ((res1= encryption_handler.encryption_ctx_init_func((ctx),(key),(klen),(iv),(ivlen),(flags),(key_id),(key_version))))
+ return res1;
+ res1= encryption_handler.encryption_ctx_update_func((ctx),(src),(slen),(dst),(&d1));
+ res2= encryption_handler.encryption_ctx_finish_func((ctx),(dst + d1),(&d2));
+ *dlen= d1 + d2;
+ return res1 ? res1 : res2;
+}
+}
+extern "C" {
+struct st_encryption_scheme_key {
+ unsigned int version;
+ unsigned char key[16];
+};
+struct st_encryption_scheme {
+ unsigned char iv[16];
+ struct st_encryption_scheme_key key[3];
+ unsigned int keyserver_requests;
+ unsigned int key_id;
+ unsigned int type;
+ void (*locker)(struct st_encryption_scheme *self, int release);
+};
+extern struct encryption_scheme_service_st {
+ int (*encryption_scheme_encrypt_func)
+ (const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+ int (*encryption_scheme_decrypt_func)
+ (const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+} *encryption_scheme_service;
+int encryption_scheme_encrypt(const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+int encryption_scheme_decrypt(const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+}
+extern "C" {
+enum thd_kill_levels {
+ THD_IS_NOT_KILLED=0,
+ THD_ABORT_SOFTLY=50,
+ THD_ABORT_ASAP=100,
+};
+extern struct kill_statement_service_st {
+ enum thd_kill_levels (*thd_kill_level_func)(const THD*);
+} *thd_kill_statement_service;
+enum thd_kill_levels thd_kill_level(const THD*);
+}
+extern "C" {
+typedef struct logger_handle_st LOGGER_HANDLE;
+extern struct logger_service_st {
+ void (*logger_init_mutexes)();
+ LOGGER_HANDLE* (*open)(const char *path,
+ unsigned long long size_limit,
+ unsigned int rotations);
+ int (*close)(LOGGER_HANDLE *log);
+ int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
+ int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...);
+ int (*write)(LOGGER_HANDLE *log, const char *buffer, size_t size);
+ int (*rotate)(LOGGER_HANDLE *log);
+} *logger_service;
+ void logger_init_mutexes();
+ LOGGER_HANDLE *logger_open(const char *path,
+ unsigned long long size_limit,
+ unsigned int rotations);
+ int logger_close(LOGGER_HANDLE *log);
+ int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
+ int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
+ int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
+ int logger_rotate(LOGGER_HANDLE *log);
+}
+extern "C" {
+extern struct my_md5_service_st {
+ void (*my_md5_type)(unsigned char*, const char*, size_t);
+ void (*my_md5_multi_type)(unsigned char*, ...);
+ size_t (*my_md5_context_size_type)();
+ void (*my_md5_init_type)(void *);
+ void (*my_md5_input_type)(void *, const unsigned char *, size_t);
+ void (*my_md5_result_type)(void *, unsigned char *);
+} *my_md5_service;
+void my_md5(unsigned char*, const char*, size_t);
+void my_md5_multi(unsigned char*, ...);
+size_t my_md5_context_size();
+void my_md5_init(void *context);
+void my_md5_input(void *context, const unsigned char *buf, size_t len);
+void my_md5_result(void *context, unsigned char *digest);
+}
+extern "C" {
+enum my_aes_mode {
+ MY_AES_ECB, MY_AES_CBC
+};
+extern struct my_crypt_service_st {
+ int (*my_aes_crypt_init)(void *ctx, enum my_aes_mode mode, int flags,
+ const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen);
+ int (*my_aes_crypt_update)(void *ctx, const unsigned char *src, unsigned int slen,
+ unsigned char *dst, unsigned int *dlen);
+ int (*my_aes_crypt_finish)(void *ctx, unsigned char *dst, unsigned int *dlen);
+ int (*my_aes_crypt)(enum my_aes_mode mode, int flags,
+ const unsigned char *src, unsigned int slen, unsigned char *dst, unsigned int *dlen,
+ const unsigned char *key, unsigned int klen, const unsigned char *iv, unsigned int ivlen);
+ unsigned int (*my_aes_get_size)(enum my_aes_mode mode, unsigned int source_length);
+ unsigned int (*my_aes_ctx_size)(enum my_aes_mode mode);
+ int (*my_random_bytes)(unsigned char* buf, int num);
+} *my_crypt_service;
+int my_aes_crypt_init(void *ctx, enum my_aes_mode mode, int flags,
+ const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen);
+int my_aes_crypt_update(void *ctx, const unsigned char *src, unsigned int slen,
+ unsigned char *dst, unsigned int *dlen);
+int my_aes_crypt_finish(void *ctx, unsigned char *dst, unsigned int *dlen);
+int my_aes_crypt(enum my_aes_mode mode, int flags,
+ const unsigned char *src, unsigned int slen, unsigned char *dst, unsigned int *dlen,
+ const unsigned char *key, unsigned int klen, const unsigned char *iv, unsigned int ivlen);
+int my_random_bytes(unsigned char* buf, int num);
+unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
+unsigned int my_aes_ctx_size(enum my_aes_mode mode);
+}
+extern "C" {
+extern struct my_print_error_service_st {
+ void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
+ void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
+ void (*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
+} *my_print_error_service;
+extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
+extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
+extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
+}
+extern "C" {
+extern struct my_snprintf_service_st {
+ size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
+ size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
+} *my_snprintf_service;
+size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
+size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
+}
+extern "C" {
+extern struct progress_report_service_st {
+ void (*thd_progress_init_func)(THD* thd, unsigned int max_stage);
+ void (*thd_progress_report_func)(THD* thd,
+ unsigned long long progress,
+ unsigned long long max_progress);
+ void (*thd_progress_next_stage_func)(THD* thd);
+ void (*thd_progress_end_func)(THD* thd);
+ const char *(*set_thd_proc_info_func)(THD*, const char *info,
+ const char *func,
+ const char *file,
+ unsigned int line);
+} *progress_report_service;
+void thd_progress_init(THD* thd, unsigned int max_stage);
+void thd_progress_report(THD* thd,
+ unsigned long long progress,
+ unsigned long long max_progress);
+void thd_progress_next_stage(THD* thd);
+void thd_progress_end(THD* thd);
+const char *set_thd_proc_info(THD*, const char * info, const char *func,
+ const char *file, unsigned int line);
+}
+extern "C" {
+extern struct my_sha1_service_st {
+ void (*my_sha1_type)(unsigned char*, const char*, size_t);
+ void (*my_sha1_multi_type)(unsigned char*, ...);
+ size_t (*my_sha1_context_size_type)();
+ void (*my_sha1_init_type)(void *);
+ void (*my_sha1_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha1_result_type)(void *, unsigned char *);
+} *my_sha1_service;
+void my_sha1(unsigned char*, const char*, size_t);
+void my_sha1_multi(unsigned char*, ...);
+size_t my_sha1_context_size();
+void my_sha1_init(void *context);
+void my_sha1_input(void *context, const unsigned char *buf, size_t len);
+void my_sha1_result(void *context, unsigned char *digest);
+}
+extern "C" {
+extern struct my_sha2_service_st {
+ void (*my_sha224_type)(unsigned char*, const char*, size_t);
+ void (*my_sha224_multi_type)(unsigned char*, ...);
+ size_t (*my_sha224_context_size_type)();
+ void (*my_sha224_init_type)(void *);
+ void (*my_sha224_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha224_result_type)(void *, unsigned char *);
+ void (*my_sha256_type)(unsigned char*, const char*, size_t);
+ void (*my_sha256_multi_type)(unsigned char*, ...);
+ size_t (*my_sha256_context_size_type)();
+ void (*my_sha256_init_type)(void *);
+ void (*my_sha256_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha256_result_type)(void *, unsigned char *);
+ void (*my_sha384_type)(unsigned char*, const char*, size_t);
+ void (*my_sha384_multi_type)(unsigned char*, ...);
+ size_t (*my_sha384_context_size_type)();
+ void (*my_sha384_init_type)(void *);
+ void (*my_sha384_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha384_result_type)(void *, unsigned char *);
+ void (*my_sha512_type)(unsigned char*, const char*, size_t);
+ void (*my_sha512_multi_type)(unsigned char*, ...);
+ size_t (*my_sha512_context_size_type)();
+ void (*my_sha512_init_type)(void *);
+ void (*my_sha512_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha512_result_type)(void *, unsigned char *);
+} *my_sha2_service;
+void my_sha224(unsigned char*, const char*, size_t);
+void my_sha224_multi(unsigned char*, ...);
+size_t my_sha224_context_size();
+void my_sha224_init(void *context);
+void my_sha224_input(void *context, const unsigned char *buf, size_t len);
+void my_sha224_result(void *context, unsigned char *digest);
+void my_sha256(unsigned char*, const char*, size_t);
+void my_sha256_multi(unsigned char*, ...);
+size_t my_sha256_context_size();
+void my_sha256_init(void *context);
+void my_sha256_input(void *context, const unsigned char *buf, size_t len);
+void my_sha256_result(void *context, unsigned char *digest);
+void my_sha384(unsigned char*, const char*, size_t);
+void my_sha384_multi(unsigned char*, ...);
+size_t my_sha384_context_size();
+void my_sha384_init(void *context);
+void my_sha384_input(void *context, const unsigned char *buf, size_t len);
+void my_sha384_result(void *context, unsigned char *digest);
+void my_sha512(unsigned char*, const char*, size_t);
+void my_sha512_multi(unsigned char*, ...);
+size_t my_sha512_context_size();
+void my_sha512_init(void *context);
+void my_sha512_input(void *context, const unsigned char *buf, size_t len);
+void my_sha512_result(void *context, unsigned char *digest);
+}
+extern "C" {
+struct st_mysql_lex_string
+{
+ char *str;
+ size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+struct st_mysql_const_lex_string
+{
+ const char *str;
+ size_t length;
+};
+typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
+extern struct thd_alloc_service_st {
+ void *(*thd_alloc_func)(THD*, size_t);
+ void *(*thd_calloc_func)(THD*, size_t);
+ char *(*thd_strdup_func)(THD*, const char *);
+ char *(*thd_strmake_func)(THD*, const char *, size_t);
+ void *(*thd_memdup_func)(THD*, const void*, size_t);
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(THD*,
+ MYSQL_CONST_LEX_STRING *,
+ const char *, size_t, int);
+} *thd_alloc_service;
+void *thd_alloc(THD* thd, size_t size);
+void *thd_calloc(THD* thd, size_t size);
+char *thd_strdup(THD* thd, const char *str);
+char *thd_strmake(THD* thd, const char *str, size_t size);
+void *thd_memdup(THD* thd, const void* str, size_t size);
+MYSQL_CONST_LEX_STRING
+*thd_make_lex_string(THD* thd, MYSQL_CONST_LEX_STRING *lex_str,
+ const char *str, size_t size,
+ int allocate_lex_string);
+}
+extern "C" {
+extern struct thd_autoinc_service_st {
+ void (*thd_get_autoinc_func)(const THD* thd,
+ unsigned long* off, unsigned long* inc);
+} *thd_autoinc_service;
+void thd_get_autoinc(const THD* thd,
+ unsigned long* off, unsigned long* inc);
+}
+extern "C" {
+extern struct thd_error_context_service_st {
+ const char *(*thd_get_error_message_func)(const THD* thd);
+ unsigned int (*thd_get_error_number_func)(const THD* thd);
+ unsigned long (*thd_get_error_row_func)(const THD* thd);
+ void (*thd_inc_error_row_func)(THD* thd);
+ char *(*thd_get_error_context_description_func)(THD* thd,
+ char *buffer,
+ unsigned int length,
+ unsigned int max_query_length);
+} *thd_error_context_service;
+const char *thd_get_error_message(const THD* thd);
+unsigned int thd_get_error_number(const THD* thd);
+unsigned long thd_get_error_row(const THD* thd);
+void thd_inc_error_row(THD* thd);
+char *thd_get_error_context_description(THD* thd,
+ char *buffer, unsigned int length,
+ unsigned int max_query_length);
+}
+extern "C" {
+extern struct thd_rnd_service_st {
+ double (*thd_rnd_ptr)(THD* thd);
+ void (*thd_c_r_p_ptr)(THD* thd, char *to, size_t length);
+} *thd_rnd_service;
+double thd_rnd(THD* thd);
+void thd_create_random_password(THD* thd, char *to, size_t length);
+}
+extern "C" {
+typedef int MYSQL_THD_KEY_T;
+extern struct thd_specifics_service_st {
+ int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
+ void (*thd_key_delete_func)(MYSQL_THD_KEY_T *key);
+ void *(*thd_getspecific_func)(THD* thd, MYSQL_THD_KEY_T key);
+ int (*thd_setspecific_func)(THD* thd, MYSQL_THD_KEY_T key, void *value);
+} *thd_specifics_service;
+int thd_key_create(MYSQL_THD_KEY_T *key);
+void thd_key_delete(MYSQL_THD_KEY_T *key);
+void* thd_getspecific(THD* thd, MYSQL_THD_KEY_T key);
+int thd_setspecific(THD* thd, MYSQL_THD_KEY_T key, void *value);
+}
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
+{
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+typedef struct st_mysql_time
+{
+ unsigned int year, month, day, hour, minute, second;
+ unsigned long second_part;
+ my_bool neg;
+ enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+extern "C" {
+extern struct thd_timezone_service_st {
+ my_time_t (*thd_TIME_to_gmt_sec)(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+} *thd_timezone_service;
+my_time_t thd_TIME_to_gmt_sec(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+}
+extern "C" {
+typedef enum _thd_wait_type_e {
+ THD_WAIT_SLEEP= 1,
+ THD_WAIT_DISKIO= 2,
+ THD_WAIT_ROW_LOCK= 3,
+ THD_WAIT_GLOBAL_LOCK= 4,
+ THD_WAIT_META_DATA_LOCK= 5,
+ THD_WAIT_TABLE_LOCK= 6,
+ THD_WAIT_USER_LOCK= 7,
+ THD_WAIT_BINLOG= 8,
+ THD_WAIT_GROUP_COMMIT= 9,
+ THD_WAIT_SYNC= 10,
+ THD_WAIT_NET= 11,
+ THD_WAIT_LAST= 12
+} thd_wait_type;
+extern struct thd_wait_service_st {
+ void (*thd_wait_begin_func)(THD*, int);
+ void (*thd_wait_end_func)(THD*);
+} *thd_wait_service;
+void thd_wait_begin(THD* thd, int wait_type);
+void thd_wait_end(THD* thd);
+}
+extern "C" {
+enum json_types
+{
+ JSV_BAD_JSON=-1,
+ JSV_NOTHING=0,
+ JSV_OBJECT=1,
+ JSV_ARRAY=2,
+ JSV_STRING=3,
+ JSV_NUMBER=4,
+ JSV_TRUE=5,
+ JSV_FALSE=6,
+ JSV_NULL=7
+};
+extern struct json_service_st {
+ enum json_types (*json_type)(const char *js, const char *js_end,
+ const char **value, int *value_len);
+ enum json_types (*json_get_array_item)(const char *js, const char *js_end,
+ int n_item,
+ const char **value, int *value_len);
+ enum json_types (*json_get_object_key)(const char *js, const char *js_end,
+ const char *key,
+ const char **value, int *value_len);
+ enum json_types (*json_get_object_nkey)(const char *js,const char *js_end,
+ int nkey,
+ const char **keyname, const char **keyname_end,
+ const char **value, int *value_len);
+ int (*json_escape_string)(const char *str,const char *str_end,
+ char *json, char *json_end);
+ int (*json_unescape_json)(const char *json_str, const char *json_end,
+ char *res, char *res_end);
+} *json_service;
+enum json_types json_type(const char *js, const char *js_end,
+ const char **value, int *value_len);
+enum json_types json_get_array_item(const char *js, const char *js_end,
+ int n_item,
+ const char **value, int *value_len);
+enum json_types json_get_object_key(const char *js, const char *js_end,
+ const char *key,
+ const char **value, int *value_len);
+enum json_types json_get_object_nkey(const char *js,const char *js_end, int nkey,
+ const char **keyname, const char **keyname_end,
+ const char **value, int *value_len);
+int json_escape_string(const char *str,const char *str_end,
+ char *json, char *json_end);
+int json_unescape_json(const char *json_str, const char *json_end,
+ char *res, char *res_end);
+}
+}
+struct st_mysql_xid {
+ long formatID;
+ long gtrid_length;
+ long bqual_length;
+ char data[128];
+};
+typedef struct st_mysql_xid MYSQL_XID;
+enum enum_mysql_show_type
+{
+ SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG,
+ SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
+ SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
+ SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
+ SHOW_SIZE_T, SHOW_always_last
+};
+enum enum_var_type
+{
+ SHOW_OPT_DEFAULT= 0, SHOW_OPT_SESSION, SHOW_OPT_GLOBAL
+};
+struct st_mysql_show_var {
+ const char *name;
+ void *value;
+ enum enum_mysql_show_type type;
+};
+struct system_status_var;
+typedef int (*mysql_show_var_func)(THD*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
+struct st_mysql_sys_var;
+struct st_mysql_value;
+typedef int (*mysql_var_check_func)(THD* thd,
+ struct st_mysql_sys_var *var,
+ void *save, struct st_mysql_value *value);
+typedef void (*mysql_var_update_func)(THD* thd,
+ struct st_mysql_sys_var *var,
+ void *var_ptr, const void *save);
+struct st_mysql_plugin
+{
+ int type;
+ void *info;
+ const char *name;
+ const char *author;
+ const char *descr;
+ int license;
+ int (*init)(void *);
+ int (*deinit)(void *);
+ unsigned int version;
+ struct st_mysql_show_var *status_vars;
+ struct st_mysql_sys_var **system_vars;
+ void * __reserved1;
+ unsigned long flags;
+};
+struct st_maria_plugin
+{
+ int type;
+ void *info;
+ const char *name;
+ const char *author;
+ const char *descr;
+ int license;
+ int (*init)(void *);
+ int (*deinit)(void *);
+ unsigned int version;
+ struct st_mysql_show_var *status_vars;
+ struct st_mysql_sys_var **system_vars;
+ const char *version_info;
+ unsigned int maturity;
+};
+extern "C" {
+enum enum_ftparser_mode
+{
+ MYSQL_FTPARSER_SIMPLE_MODE= 0,
+ MYSQL_FTPARSER_WITH_STOPWORDS= 1,
+ MYSQL_FTPARSER_FULL_BOOLEAN_INFO= 2
+};
+enum enum_ft_token_type
+{
+ FT_TOKEN_EOF= 0,
+ FT_TOKEN_WORD= 1,
+ FT_TOKEN_LEFT_PAREN= 2,
+ FT_TOKEN_RIGHT_PAREN= 3,
+ FT_TOKEN_STOPWORD= 4
+};
+typedef struct st_mysql_ftparser_boolean_info
+{
+ enum enum_ft_token_type type;
+ int yesno;
+ int weight_adjust;
+ char wasign;
+ char trunc;
+ char prev;
+ char *quot;
+} MYSQL_FTPARSER_BOOLEAN_INFO;
+typedef struct st_mysql_ftparser_param
+{
+ int (*mysql_parse)(struct st_mysql_ftparser_param *,
+ const char *doc, int doc_len);
+ int (*mysql_add_word)(struct st_mysql_ftparser_param *,
+ const char *word, int word_len,
+ MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info);
+ void *ftparser_state;
+ void *mysql_ftparam;
+ const struct charset_info_st *cs;
+ const char *doc;
+ int length;
+ unsigned int flags;
+ enum enum_ftparser_mode mode;
+} MYSQL_FTPARSER_PARAM;
+struct st_mysql_ftparser
+{
+ int interface_version;
+ int (*parse)(MYSQL_FTPARSER_PARAM *param);
+ int (*init)(MYSQL_FTPARSER_PARAM *param);
+ int (*deinit)(MYSQL_FTPARSER_PARAM *param);
+};
+}
+struct st_mysql_daemon
+{
+ int interface_version;
+};
+struct st_mysql_information_schema
+{
+ int interface_version;
+};
+struct st_mysql_storage_engine
+{
+ int interface_version;
+};
+struct handlerton;
+ struct Mysql_replication {
+ int interface_version;
+ };
+struct st_mysql_value
+{
+ int (*value_type)(struct st_mysql_value *);
+ const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
+ int (*val_real)(struct st_mysql_value *, double *realbuf);
+ int (*val_int)(struct st_mysql_value *, long long *intbuf);
+ int (*is_unsigned)(struct st_mysql_value *);
+};
+extern "C" {
+int thd_in_lock_tables(const THD* thd);
+int thd_tablespace_op(const THD* thd);
+long long thd_test_options(const THD* thd, long long test_options);
+int thd_sql_command(const THD* thd);
+void thd_storage_lock_wait(THD* thd, long long value);
+int thd_tx_isolation(const THD* thd);
+int thd_tx_is_read_only(const THD* thd);
+int mysql_tmpfile(const char *prefix);
+unsigned long thd_get_thread_id(const THD* thd);
+void thd_get_xid(const THD* thd, MYSQL_XID *xid);
+void mysql_query_cache_invalidate4(THD* thd,
+ const char *key, unsigned int key_length,
+ int using_trx);
+void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
+void thd_set_ha_data(THD* thd, const struct handlerton *hton,
+ const void *ha_data);
+void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
+}
+struct st_mariadb_data_type
+{
+ int interface_version;
+ class Type_handler *type_handler;
+};
diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp
index 6597decfbef..ff436bb24c4 100644
--- a/include/mysql/plugin_encryption.h.pp
+++ b/include/mysql/plugin_encryption.h.pp
@@ -1,5 +1,9 @@
+class THD;
+class Item;
typedef char my_bool;
typedef void * MYSQL_PLUGIN;
+extern "C" {
+extern "C" {
extern struct base64_service_st {
int (*base64_needed_encoded_length_ptr)(int length_of_data);
int (*base64_encode_max_arg_length_ptr)(void);
@@ -16,7 +20,11 @@ int my_base64_decode_max_arg_length();
int my_base64_encode(const void *src, size_t src_len, char *dst);
int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
-extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
+}
+extern "C" {
+extern void (*debug_sync_C_callback_ptr)(THD*, const char *, size_t);
+}
+extern "C" {
struct encryption_service_st {
unsigned int (*encryption_key_get_latest_version_func)(unsigned int key_id);
unsigned int (*encryption_key_get_func)(unsigned int key_id, unsigned int key_version,
@@ -57,6 +65,8 @@ static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
*dlen= d1 + d2;
return res1 ? res1 : res2;
}
+}
+extern "C" {
struct st_encryption_scheme_key {
unsigned int version;
unsigned char key[16];
@@ -93,15 +103,19 @@ int encryption_scheme_decrypt(const unsigned char* src, unsigned int slen,
struct st_encryption_scheme *scheme,
unsigned int key_version, unsigned int i32_1,
unsigned int i32_2, unsigned long long i64);
+}
+extern "C" {
enum thd_kill_levels {
THD_IS_NOT_KILLED=0,
THD_ABORT_SOFTLY=50,
THD_ABORT_ASAP=100,
};
extern struct kill_statement_service_st {
- enum thd_kill_levels (*thd_kill_level_func)(const void*);
+ enum thd_kill_levels (*thd_kill_level_func)(const THD*);
} *thd_kill_statement_service;
-enum thd_kill_levels thd_kill_level(const void*);
+enum thd_kill_levels thd_kill_level(const THD*);
+}
+extern "C" {
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
@@ -123,6 +137,8 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
+}
+extern "C" {
extern struct my_md5_service_st {
void (*my_md5_type)(unsigned char*, const char*, size_t);
void (*my_md5_multi_type)(unsigned char*, ...);
@@ -137,6 +153,8 @@ size_t my_md5_context_size();
void my_md5_init(void *context);
void my_md5_input(void *context, const unsigned char *buf, size_t len);
void my_md5_result(void *context, unsigned char *digest);
+}
+extern "C" {
enum my_aes_mode {
MY_AES_ECB, MY_AES_CBC
};
@@ -166,6 +184,8 @@ int my_aes_crypt(enum my_aes_mode mode, int flags,
int my_random_bytes(unsigned char* buf, int num);
unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
unsigned int my_aes_ctx_size(enum my_aes_mode mode);
+}
+extern "C" {
extern struct my_print_error_service_st {
void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
@@ -174,32 +194,38 @@ extern struct my_print_error_service_st {
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
+}
+extern "C" {
extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
} *my_snprintf_service;
size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
+}
+extern "C" {
extern struct progress_report_service_st {
- void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
- void (*thd_progress_report_func)(void* thd,
+ void (*thd_progress_init_func)(THD* thd, unsigned int max_stage);
+ void (*thd_progress_report_func)(THD* thd,
unsigned long long progress,
unsigned long long max_progress);
- void (*thd_progress_next_stage_func)(void* thd);
- void (*thd_progress_end_func)(void* thd);
- const char *(*set_thd_proc_info_func)(void*, const char *info,
+ void (*thd_progress_next_stage_func)(THD* thd);
+ void (*thd_progress_end_func)(THD* thd);
+ const char *(*set_thd_proc_info_func)(THD*, const char *info,
const char *func,
const char *file,
unsigned int line);
} *progress_report_service;
-void thd_progress_init(void* thd, unsigned int max_stage);
-void thd_progress_report(void* thd,
+void thd_progress_init(THD* thd, unsigned int max_stage);
+void thd_progress_report(THD* thd,
unsigned long long progress,
unsigned long long max_progress);
-void thd_progress_next_stage(void* thd);
-void thd_progress_end(void* thd);
-const char *set_thd_proc_info(void*, const char * info, const char *func,
+void thd_progress_next_stage(THD* thd);
+void thd_progress_end(THD* thd);
+const char *set_thd_proc_info(THD*, const char * info, const char *func,
const char *file, unsigned int line);
+}
+extern "C" {
extern struct my_sha1_service_st {
void (*my_sha1_type)(unsigned char*, const char*, size_t);
void (*my_sha1_multi_type)(unsigned char*, ...);
@@ -214,6 +240,8 @@ size_t my_sha1_context_size();
void my_sha1_init(void *context);
void my_sha1_input(void *context, const unsigned char *buf, size_t len);
void my_sha1_result(void *context, unsigned char *digest);
+}
+extern "C" {
extern struct my_sha2_service_st {
void (*my_sha224_type)(unsigned char*, const char*, size_t);
void (*my_sha224_multi_type)(unsigned char*, ...);
@@ -264,6 +292,8 @@ size_t my_sha512_context_size();
void my_sha512_init(void *context);
void my_sha512_input(void *context, const unsigned char *buf, size_t len);
void my_sha512_result(void *context, unsigned char *digest);
+}
+extern "C" {
struct st_mysql_lex_string
{
char *str;
@@ -277,64 +307,73 @@ struct st_mysql_const_lex_string
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, size_t);
- void *(*thd_calloc_func)(void*, size_t);
- char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, size_t);
- void *(*thd_memdup_func)(void*, const void*, size_t);
- MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
+ void *(*thd_alloc_func)(THD*, size_t);
+ void *(*thd_calloc_func)(THD*, size_t);
+ char *(*thd_strdup_func)(THD*, const char *);
+ char *(*thd_strmake_func)(THD*, const char *, size_t);
+ void *(*thd_memdup_func)(THD*, const void*, size_t);
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(THD*,
MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
-void *thd_alloc(void* thd, size_t size);
-void *thd_calloc(void* thd, size_t size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, size_t size);
-void *thd_memdup(void* thd, const void* str, size_t size);
+void *thd_alloc(THD* thd, size_t size);
+void *thd_calloc(THD* thd, size_t size);
+char *thd_strdup(THD* thd, const char *str);
+char *thd_strmake(THD* thd, const char *str, size_t size);
+void *thd_memdup(THD* thd, const void* str, size_t size);
MYSQL_CONST_LEX_STRING
-*thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
+*thd_make_lex_string(THD* thd, MYSQL_CONST_LEX_STRING *lex_str,
const char *str, size_t size,
int allocate_lex_string);
+}
+extern "C" {
extern struct thd_autoinc_service_st {
- void (*thd_get_autoinc_func)(const void* thd,
+ void (*thd_get_autoinc_func)(const THD* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
-void thd_get_autoinc(const void* thd,
+void thd_get_autoinc(const THD* thd,
unsigned long* off, unsigned long* inc);
+}
+extern "C" {
extern struct thd_error_context_service_st {
- const char *(*thd_get_error_message_func)(const void* thd);
- unsigned int (*thd_get_error_number_func)(const void* thd);
- unsigned long (*thd_get_error_row_func)(const void* thd);
- void (*thd_inc_error_row_func)(void* thd);
- char *(*thd_get_error_context_description_func)(void* thd,
+ const char *(*thd_get_error_message_func)(const THD* thd);
+ unsigned int (*thd_get_error_number_func)(const THD* thd);
+ unsigned long (*thd_get_error_row_func)(const THD* thd);
+ void (*thd_inc_error_row_func)(THD* thd);
+ char *(*thd_get_error_context_description_func)(THD* thd,
char *buffer,
unsigned int length,
unsigned int max_query_length);
} *thd_error_context_service;
-const char *thd_get_error_message(const void* thd);
-unsigned int thd_get_error_number(const void* thd);
-unsigned long thd_get_error_row(const void* thd);
-void thd_inc_error_row(void* thd);
-char *thd_get_error_context_description(void* thd,
+const char *thd_get_error_message(const THD* thd);
+unsigned int thd_get_error_number(const THD* thd);
+unsigned long thd_get_error_row(const THD* thd);
+void thd_inc_error_row(THD* thd);
+char *thd_get_error_context_description(THD* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
+}
+extern "C" {
extern struct thd_rnd_service_st {
- double (*thd_rnd_ptr)(void* thd);
- void (*thd_c_r_p_ptr)(void* thd, char *to, size_t length);
+ double (*thd_rnd_ptr)(THD* thd);
+ void (*thd_c_r_p_ptr)(THD* thd, char *to, size_t length);
} *thd_rnd_service;
-double thd_rnd(void* thd);
-void thd_create_random_password(void* thd, char *to, size_t length);
+double thd_rnd(THD* thd);
+void thd_create_random_password(THD* thd, char *to, size_t length);
+}
+extern "C" {
typedef int MYSQL_THD_KEY_T;
extern struct thd_specifics_service_st {
int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
void (*thd_key_delete_func)(MYSQL_THD_KEY_T *key);
- void *(*thd_getspecific_func)(void* thd, MYSQL_THD_KEY_T key);
- int (*thd_setspecific_func)(void* thd, MYSQL_THD_KEY_T key, void *value);
+ void *(*thd_getspecific_func)(THD* thd, MYSQL_THD_KEY_T key);
+ int (*thd_setspecific_func)(THD* thd, MYSQL_THD_KEY_T key, void *value);
} *thd_specifics_service;
int thd_key_create(MYSQL_THD_KEY_T *key);
void thd_key_delete(MYSQL_THD_KEY_T *key);
-void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key);
-int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value);
+void* thd_getspecific(THD* thd, MYSQL_THD_KEY_T key);
+int thd_setspecific(THD* thd, MYSQL_THD_KEY_T key, void *value);
+}
typedef long my_time_t;
enum enum_mysql_timestamp_type
{
@@ -348,12 +387,15 @@ typedef struct st_mysql_time
my_bool neg;
enum enum_mysql_timestamp_type time_type;
} MYSQL_TIME;
+extern "C" {
extern struct thd_timezone_service_st {
- my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
- void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+ my_time_t (*thd_TIME_to_gmt_sec)(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(THD* thd, MYSQL_TIME *ltime, my_time_t t);
} *thd_timezone_service;
-my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
-void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
+my_time_t thd_TIME_to_gmt_sec(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+}
+extern "C" {
typedef enum _thd_wait_type_e {
THD_WAIT_SLEEP= 1,
THD_WAIT_DISKIO= 2,
@@ -369,11 +411,13 @@ typedef enum _thd_wait_type_e {
THD_WAIT_LAST= 12
} thd_wait_type;
extern struct thd_wait_service_st {
- void (*thd_wait_begin_func)(void*, int);
- void (*thd_wait_end_func)(void*);
+ void (*thd_wait_begin_func)(THD*, int);
+ void (*thd_wait_end_func)(THD*);
} *thd_wait_service;
-void thd_wait_begin(void* thd, int wait_type);
-void thd_wait_end(void* thd);
+void thd_wait_begin(THD* thd, int wait_type);
+void thd_wait_end(THD* thd);
+}
+extern "C" {
enum json_types
{
JSV_BAD_JSON=-1,
@@ -419,6 +463,8 @@ int json_escape_string(const char *str,const char *str_end,
char *json, char *json_end);
int json_unescape_json(const char *json_str, const char *json_end,
char *res, char *res_end);
+}
+}
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -432,7 +478,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
- SHOW_always_last
+ SHOW_SIZE_T, SHOW_always_last
};
enum enum_var_type
{
@@ -444,13 +490,13 @@ struct st_mysql_show_var {
enum enum_mysql_show_type type;
};
struct system_status_var;
-typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
+typedef int (*mysql_show_var_func)(THD*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
struct st_mysql_sys_var;
struct st_mysql_value;
-typedef int (*mysql_var_check_func)(void* thd,
+typedef int (*mysql_var_check_func)(THD* thd,
struct st_mysql_sys_var *var,
void *save, struct st_mysql_value *value);
-typedef void (*mysql_var_update_func)(void* thd,
+typedef void (*mysql_var_update_func)(THD* thd,
struct st_mysql_sys_var *var,
void *var_ptr, const void *save);
struct st_mysql_plugin
@@ -485,6 +531,7 @@ struct st_maria_plugin
const char *version_info;
unsigned int maturity;
};
+extern "C" {
enum enum_ftparser_mode
{
MYSQL_FTPARSER_SIMPLE_MODE= 0,
@@ -531,6 +578,7 @@ struct st_mysql_ftparser
int (*init)(MYSQL_FTPARSER_PARAM *param);
int (*deinit)(MYSQL_FTPARSER_PARAM *param);
};
+}
struct st_mysql_daemon
{
int interface_version;
@@ -555,24 +603,26 @@ struct st_mysql_value
int (*val_int)(struct st_mysql_value *, long long *intbuf);
int (*is_unsigned)(struct st_mysql_value *);
};
-int thd_in_lock_tables(const void* thd);
-int thd_tablespace_op(const void* thd);
-long long thd_test_options(const void* thd, long long test_options);
-int thd_sql_command(const void* thd);
-void **thd_ha_data(const void* thd, const struct handlerton *hton);
-void thd_storage_lock_wait(void* thd, long long value);
-int thd_tx_isolation(const void* thd);
-int thd_tx_is_read_only(const void* thd);
+extern "C" {
+int thd_in_lock_tables(const THD* thd);
+int thd_tablespace_op(const THD* thd);
+long long thd_test_options(const THD* thd, long long test_options);
+int thd_sql_command(const THD* thd);
+void thd_storage_lock_wait(THD* thd, long long value);
+int thd_tx_isolation(const THD* thd);
+int thd_tx_is_read_only(const THD* thd);
int mysql_tmpfile(const char *prefix);
-unsigned long thd_get_thread_id(const void* thd);
-void thd_get_xid(const void* thd, MYSQL_XID *xid);
-void mysql_query_cache_invalidate4(void* thd,
+unsigned long thd_get_thread_id(const THD* thd);
+void thd_get_xid(const THD* thd, MYSQL_XID *xid);
+void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
-void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
-void thd_set_ha_data(void* thd, const struct handlerton *hton,
+void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
+void thd_set_ha_data(THD* thd, const struct handlerton *hton,
const void *ha_data);
-void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
+void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
+}
+extern "C" {
struct st_mariadb_encryption
{
int interface_version;
@@ -589,3 +639,4 @@ struct st_mariadb_encryption
int (*crypt_ctx_finish)(void *ctx, unsigned char* dst, unsigned int* dlen);
unsigned int (*encrypted_length)(unsigned int slen, unsigned int key_id, unsigned int key_version);
};
+}
diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp
index bd1cfc7b68b..daefd6b2838 100644
--- a/include/mysql/plugin_ftparser.h.pp
+++ b/include/mysql/plugin_ftparser.h.pp
@@ -1,5 +1,9 @@
+class THD;
+class Item;
typedef char my_bool;
typedef void * MYSQL_PLUGIN;
+extern "C" {
+extern "C" {
extern struct base64_service_st {
int (*base64_needed_encoded_length_ptr)(int length_of_data);
int (*base64_encode_max_arg_length_ptr)(void);
@@ -16,7 +20,11 @@ int my_base64_decode_max_arg_length();
int my_base64_encode(const void *src, size_t src_len, char *dst);
int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
-extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
+}
+extern "C" {
+extern void (*debug_sync_C_callback_ptr)(THD*, const char *, size_t);
+}
+extern "C" {
struct encryption_service_st {
unsigned int (*encryption_key_get_latest_version_func)(unsigned int key_id);
unsigned int (*encryption_key_get_func)(unsigned int key_id, unsigned int key_version,
@@ -57,6 +65,8 @@ static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
*dlen= d1 + d2;
return res1 ? res1 : res2;
}
+}
+extern "C" {
struct st_encryption_scheme_key {
unsigned int version;
unsigned char key[16];
@@ -93,15 +103,19 @@ int encryption_scheme_decrypt(const unsigned char* src, unsigned int slen,
struct st_encryption_scheme *scheme,
unsigned int key_version, unsigned int i32_1,
unsigned int i32_2, unsigned long long i64);
+}
+extern "C" {
enum thd_kill_levels {
THD_IS_NOT_KILLED=0,
THD_ABORT_SOFTLY=50,
THD_ABORT_ASAP=100,
};
extern struct kill_statement_service_st {
- enum thd_kill_levels (*thd_kill_level_func)(const void*);
+ enum thd_kill_levels (*thd_kill_level_func)(const THD*);
} *thd_kill_statement_service;
-enum thd_kill_levels thd_kill_level(const void*);
+enum thd_kill_levels thd_kill_level(const THD*);
+}
+extern "C" {
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
@@ -123,6 +137,8 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
+}
+extern "C" {
extern struct my_md5_service_st {
void (*my_md5_type)(unsigned char*, const char*, size_t);
void (*my_md5_multi_type)(unsigned char*, ...);
@@ -137,6 +153,8 @@ size_t my_md5_context_size();
void my_md5_init(void *context);
void my_md5_input(void *context, const unsigned char *buf, size_t len);
void my_md5_result(void *context, unsigned char *digest);
+}
+extern "C" {
enum my_aes_mode {
MY_AES_ECB, MY_AES_CBC
};
@@ -166,6 +184,8 @@ int my_aes_crypt(enum my_aes_mode mode, int flags,
int my_random_bytes(unsigned char* buf, int num);
unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
unsigned int my_aes_ctx_size(enum my_aes_mode mode);
+}
+extern "C" {
extern struct my_print_error_service_st {
void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
@@ -174,32 +194,38 @@ extern struct my_print_error_service_st {
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
+}
+extern "C" {
extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
} *my_snprintf_service;
size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
+}
+extern "C" {
extern struct progress_report_service_st {
- void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
- void (*thd_progress_report_func)(void* thd,
+ void (*thd_progress_init_func)(THD* thd, unsigned int max_stage);
+ void (*thd_progress_report_func)(THD* thd,
unsigned long long progress,
unsigned long long max_progress);
- void (*thd_progress_next_stage_func)(void* thd);
- void (*thd_progress_end_func)(void* thd);
- const char *(*set_thd_proc_info_func)(void*, const char *info,
+ void (*thd_progress_next_stage_func)(THD* thd);
+ void (*thd_progress_end_func)(THD* thd);
+ const char *(*set_thd_proc_info_func)(THD*, const char *info,
const char *func,
const char *file,
unsigned int line);
} *progress_report_service;
-void thd_progress_init(void* thd, unsigned int max_stage);
-void thd_progress_report(void* thd,
+void thd_progress_init(THD* thd, unsigned int max_stage);
+void thd_progress_report(THD* thd,
unsigned long long progress,
unsigned long long max_progress);
-void thd_progress_next_stage(void* thd);
-void thd_progress_end(void* thd);
-const char *set_thd_proc_info(void*, const char * info, const char *func,
+void thd_progress_next_stage(THD* thd);
+void thd_progress_end(THD* thd);
+const char *set_thd_proc_info(THD*, const char * info, const char *func,
const char *file, unsigned int line);
+}
+extern "C" {
extern struct my_sha1_service_st {
void (*my_sha1_type)(unsigned char*, const char*, size_t);
void (*my_sha1_multi_type)(unsigned char*, ...);
@@ -214,6 +240,8 @@ size_t my_sha1_context_size();
void my_sha1_init(void *context);
void my_sha1_input(void *context, const unsigned char *buf, size_t len);
void my_sha1_result(void *context, unsigned char *digest);
+}
+extern "C" {
extern struct my_sha2_service_st {
void (*my_sha224_type)(unsigned char*, const char*, size_t);
void (*my_sha224_multi_type)(unsigned char*, ...);
@@ -264,6 +292,8 @@ size_t my_sha512_context_size();
void my_sha512_init(void *context);
void my_sha512_input(void *context, const unsigned char *buf, size_t len);
void my_sha512_result(void *context, unsigned char *digest);
+}
+extern "C" {
struct st_mysql_lex_string
{
char *str;
@@ -277,64 +307,73 @@ struct st_mysql_const_lex_string
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, size_t);
- void *(*thd_calloc_func)(void*, size_t);
- char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, size_t);
- void *(*thd_memdup_func)(void*, const void*, size_t);
- MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
+ void *(*thd_alloc_func)(THD*, size_t);
+ void *(*thd_calloc_func)(THD*, size_t);
+ char *(*thd_strdup_func)(THD*, const char *);
+ char *(*thd_strmake_func)(THD*, const char *, size_t);
+ void *(*thd_memdup_func)(THD*, const void*, size_t);
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(THD*,
MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
-void *thd_alloc(void* thd, size_t size);
-void *thd_calloc(void* thd, size_t size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, size_t size);
-void *thd_memdup(void* thd, const void* str, size_t size);
+void *thd_alloc(THD* thd, size_t size);
+void *thd_calloc(THD* thd, size_t size);
+char *thd_strdup(THD* thd, const char *str);
+char *thd_strmake(THD* thd, const char *str, size_t size);
+void *thd_memdup(THD* thd, const void* str, size_t size);
MYSQL_CONST_LEX_STRING
-*thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
+*thd_make_lex_string(THD* thd, MYSQL_CONST_LEX_STRING *lex_str,
const char *str, size_t size,
int allocate_lex_string);
+}
+extern "C" {
extern struct thd_autoinc_service_st {
- void (*thd_get_autoinc_func)(const void* thd,
+ void (*thd_get_autoinc_func)(const THD* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
-void thd_get_autoinc(const void* thd,
+void thd_get_autoinc(const THD* thd,
unsigned long* off, unsigned long* inc);
+}
+extern "C" {
extern struct thd_error_context_service_st {
- const char *(*thd_get_error_message_func)(const void* thd);
- unsigned int (*thd_get_error_number_func)(const void* thd);
- unsigned long (*thd_get_error_row_func)(const void* thd);
- void (*thd_inc_error_row_func)(void* thd);
- char *(*thd_get_error_context_description_func)(void* thd,
+ const char *(*thd_get_error_message_func)(const THD* thd);
+ unsigned int (*thd_get_error_number_func)(const THD* thd);
+ unsigned long (*thd_get_error_row_func)(const THD* thd);
+ void (*thd_inc_error_row_func)(THD* thd);
+ char *(*thd_get_error_context_description_func)(THD* thd,
char *buffer,
unsigned int length,
unsigned int max_query_length);
} *thd_error_context_service;
-const char *thd_get_error_message(const void* thd);
-unsigned int thd_get_error_number(const void* thd);
-unsigned long thd_get_error_row(const void* thd);
-void thd_inc_error_row(void* thd);
-char *thd_get_error_context_description(void* thd,
+const char *thd_get_error_message(const THD* thd);
+unsigned int thd_get_error_number(const THD* thd);
+unsigned long thd_get_error_row(const THD* thd);
+void thd_inc_error_row(THD* thd);
+char *thd_get_error_context_description(THD* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
+}
+extern "C" {
extern struct thd_rnd_service_st {
- double (*thd_rnd_ptr)(void* thd);
- void (*thd_c_r_p_ptr)(void* thd, char *to, size_t length);
+ double (*thd_rnd_ptr)(THD* thd);
+ void (*thd_c_r_p_ptr)(THD* thd, char *to, size_t length);
} *thd_rnd_service;
-double thd_rnd(void* thd);
-void thd_create_random_password(void* thd, char *to, size_t length);
+double thd_rnd(THD* thd);
+void thd_create_random_password(THD* thd, char *to, size_t length);
+}
+extern "C" {
typedef int MYSQL_THD_KEY_T;
extern struct thd_specifics_service_st {
int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
void (*thd_key_delete_func)(MYSQL_THD_KEY_T *key);
- void *(*thd_getspecific_func)(void* thd, MYSQL_THD_KEY_T key);
- int (*thd_setspecific_func)(void* thd, MYSQL_THD_KEY_T key, void *value);
+ void *(*thd_getspecific_func)(THD* thd, MYSQL_THD_KEY_T key);
+ int (*thd_setspecific_func)(THD* thd, MYSQL_THD_KEY_T key, void *value);
} *thd_specifics_service;
int thd_key_create(MYSQL_THD_KEY_T *key);
void thd_key_delete(MYSQL_THD_KEY_T *key);
-void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key);
-int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value);
+void* thd_getspecific(THD* thd, MYSQL_THD_KEY_T key);
+int thd_setspecific(THD* thd, MYSQL_THD_KEY_T key, void *value);
+}
typedef long my_time_t;
enum enum_mysql_timestamp_type
{
@@ -348,12 +387,15 @@ typedef struct st_mysql_time
my_bool neg;
enum enum_mysql_timestamp_type time_type;
} MYSQL_TIME;
+extern "C" {
extern struct thd_timezone_service_st {
- my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
- void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+ my_time_t (*thd_TIME_to_gmt_sec)(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(THD* thd, MYSQL_TIME *ltime, my_time_t t);
} *thd_timezone_service;
-my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
-void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
+my_time_t thd_TIME_to_gmt_sec(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+}
+extern "C" {
typedef enum _thd_wait_type_e {
THD_WAIT_SLEEP= 1,
THD_WAIT_DISKIO= 2,
@@ -369,11 +411,13 @@ typedef enum _thd_wait_type_e {
THD_WAIT_LAST= 12
} thd_wait_type;
extern struct thd_wait_service_st {
- void (*thd_wait_begin_func)(void*, int);
- void (*thd_wait_end_func)(void*);
+ void (*thd_wait_begin_func)(THD*, int);
+ void (*thd_wait_end_func)(THD*);
} *thd_wait_service;
-void thd_wait_begin(void* thd, int wait_type);
-void thd_wait_end(void* thd);
+void thd_wait_begin(THD* thd, int wait_type);
+void thd_wait_end(THD* thd);
+}
+extern "C" {
enum json_types
{
JSV_BAD_JSON=-1,
@@ -419,6 +463,8 @@ int json_escape_string(const char *str,const char *str_end,
char *json, char *json_end);
int json_unescape_json(const char *json_str, const char *json_end,
char *res, char *res_end);
+}
+}
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -432,7 +478,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
- SHOW_always_last
+ SHOW_SIZE_T, SHOW_always_last
};
enum enum_var_type
{
@@ -444,13 +490,13 @@ struct st_mysql_show_var {
enum enum_mysql_show_type type;
};
struct system_status_var;
-typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
+typedef int (*mysql_show_var_func)(THD*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
struct st_mysql_sys_var;
struct st_mysql_value;
-typedef int (*mysql_var_check_func)(void* thd,
+typedef int (*mysql_var_check_func)(THD* thd,
struct st_mysql_sys_var *var,
void *save, struct st_mysql_value *value);
-typedef void (*mysql_var_update_func)(void* thd,
+typedef void (*mysql_var_update_func)(THD* thd,
struct st_mysql_sys_var *var,
void *var_ptr, const void *save);
struct st_mysql_plugin
@@ -509,24 +555,26 @@ struct st_mysql_value
int (*val_int)(struct st_mysql_value *, long long *intbuf);
int (*is_unsigned)(struct st_mysql_value *);
};
-int thd_in_lock_tables(const void* thd);
-int thd_tablespace_op(const void* thd);
-long long thd_test_options(const void* thd, long long test_options);
-int thd_sql_command(const void* thd);
-void **thd_ha_data(const void* thd, const struct handlerton *hton);
-void thd_storage_lock_wait(void* thd, long long value);
-int thd_tx_isolation(const void* thd);
-int thd_tx_is_read_only(const void* thd);
+extern "C" {
+int thd_in_lock_tables(const THD* thd);
+int thd_tablespace_op(const THD* thd);
+long long thd_test_options(const THD* thd, long long test_options);
+int thd_sql_command(const THD* thd);
+void thd_storage_lock_wait(THD* thd, long long value);
+int thd_tx_isolation(const THD* thd);
+int thd_tx_is_read_only(const THD* thd);
int mysql_tmpfile(const char *prefix);
-unsigned long thd_get_thread_id(const void* thd);
-void thd_get_xid(const void* thd, MYSQL_XID *xid);
-void mysql_query_cache_invalidate4(void* thd,
+unsigned long thd_get_thread_id(const THD* thd);
+void thd_get_xid(const THD* thd, MYSQL_XID *xid);
+void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
-void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
-void thd_set_ha_data(void* thd, const struct handlerton *hton,
+void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
+void thd_set_ha_data(THD* thd, const struct handlerton *hton,
const void *ha_data);
-void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
+void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
+}
+extern "C" {
enum enum_ftparser_mode
{
MYSQL_FTPARSER_SIMPLE_MODE= 0,
@@ -573,3 +621,4 @@ struct st_mysql_ftparser
int (*init)(MYSQL_FTPARSER_PARAM *param);
int (*deinit)(MYSQL_FTPARSER_PARAM *param);
};
+}
diff --git a/include/mysql/plugin_function.h b/include/mysql/plugin_function.h
new file mode 100644
index 00000000000..117acd43222
--- /dev/null
+++ b/include/mysql/plugin_function.h
@@ -0,0 +1,54 @@
+#ifndef MARIADB_PLUGIN_FUNCTION_INCLUDED
+#define MARIADB_PLUGIN_FUNCTION_INCLUDED
+/* Copyright (C) 2019, Alexander Barkov and MariaDB
+
+ 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-1335 USA */
+
+/**
+ @file
+
+ Function Plugin API.
+
+ This file defines the API for server plugins that manage functions.
+*/
+
+#ifdef __cplusplus
+
+#include <mysql/plugin.h>
+
+/*
+ API for function plugins. (MariaDB_FUNCTION_PLUGIN)
+*/
+#define MariaDB_FUNCTION_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
+
+
+class Plugin_function
+{
+ int m_interface_version;
+ Create_func *m_builder;
+public:
+ Plugin_function(Create_func *builder)
+ :m_interface_version(MariaDB_FUNCTION_INTERFACE_VERSION),
+ m_builder(builder)
+ { }
+ Create_func *create_func()
+ {
+ return m_builder;
+ }
+};
+
+
+#endif /* __cplusplus */
+
+#endif /* MARIADB_PLUGIN_FUNCTION_INCLUDED */
diff --git a/include/mysql/plugin_function.h.pp b/include/mysql/plugin_function.h.pp
new file mode 100644
index 00000000000..0f915c8413f
--- /dev/null
+++ b/include/mysql/plugin_function.h.pp
@@ -0,0 +1,638 @@
+class THD;
+class Item;
+typedef char my_bool;
+typedef void * MYSQL_PLUGIN;
+extern "C" {
+extern "C" {
+extern struct base64_service_st {
+ int (*base64_needed_encoded_length_ptr)(int length_of_data);
+ int (*base64_encode_max_arg_length_ptr)(void);
+ int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data);
+ int (*base64_decode_max_arg_length_ptr)();
+ int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst);
+ int (*base64_decode_ptr)(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
+} *base64_service;
+int my_base64_needed_encoded_length(int length_of_data);
+int my_base64_encode_max_arg_length(void);
+int my_base64_needed_decoded_length(int length_of_encoded_data);
+int my_base64_decode_max_arg_length();
+int my_base64_encode(const void *src, size_t src_len, char *dst);
+int my_base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
+}
+extern "C" {
+extern void (*debug_sync_C_callback_ptr)(THD*, const char *, size_t);
+}
+extern "C" {
+struct encryption_service_st {
+ unsigned int (*encryption_key_get_latest_version_func)(unsigned int key_id);
+ unsigned int (*encryption_key_get_func)(unsigned int key_id, unsigned int key_version,
+ unsigned char* buffer, unsigned int* length);
+ unsigned int (*encryption_ctx_size_func)(unsigned int key_id, unsigned int key_version);
+ int (*encryption_ctx_init_func)(void *ctx, const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen,
+ int flags, unsigned int key_id,
+ unsigned int key_version);
+ int (*encryption_ctx_update_func)(void *ctx, const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen);
+ int (*encryption_ctx_finish_func)(void *ctx, unsigned char* dst, unsigned int* dlen);
+ unsigned int (*encryption_encrypted_length_func)(unsigned int slen, unsigned int key_id, unsigned int key_version);
+};
+extern struct encryption_service_st encryption_handler;
+static inline unsigned int encryption_key_id_exists(unsigned int id)
+{
+ return encryption_handler.encryption_key_get_latest_version_func(id) != (~(unsigned int)0);
+}
+static inline unsigned int encryption_key_version_exists(unsigned int id, unsigned int version)
+{
+ unsigned int unused;
+ return encryption_handler.encryption_key_get_func((id),(version),(NULL),(&unused)) != (~(unsigned int)0);
+}
+static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen,
+ int flags, unsigned int key_id, unsigned int key_version)
+{
+ void *ctx= alloca(encryption_handler.encryption_ctx_size_func((key_id),(key_version)));
+ int res1, res2;
+ unsigned int d1, d2;
+ if ((res1= encryption_handler.encryption_ctx_init_func((ctx),(key),(klen),(iv),(ivlen),(flags),(key_id),(key_version))))
+ return res1;
+ res1= encryption_handler.encryption_ctx_update_func((ctx),(src),(slen),(dst),(&d1));
+ res2= encryption_handler.encryption_ctx_finish_func((ctx),(dst + d1),(&d2));
+ *dlen= d1 + d2;
+ return res1 ? res1 : res2;
+}
+}
+extern "C" {
+struct st_encryption_scheme_key {
+ unsigned int version;
+ unsigned char key[16];
+};
+struct st_encryption_scheme {
+ unsigned char iv[16];
+ struct st_encryption_scheme_key key[3];
+ unsigned int keyserver_requests;
+ unsigned int key_id;
+ unsigned int type;
+ void (*locker)(struct st_encryption_scheme *self, int release);
+};
+extern struct encryption_scheme_service_st {
+ int (*encryption_scheme_encrypt_func)
+ (const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+ int (*encryption_scheme_decrypt_func)
+ (const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+} *encryption_scheme_service;
+int encryption_scheme_encrypt(const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+int encryption_scheme_decrypt(const unsigned char* src, unsigned int slen,
+ unsigned char* dst, unsigned int* dlen,
+ struct st_encryption_scheme *scheme,
+ unsigned int key_version, unsigned int i32_1,
+ unsigned int i32_2, unsigned long long i64);
+}
+extern "C" {
+enum thd_kill_levels {
+ THD_IS_NOT_KILLED=0,
+ THD_ABORT_SOFTLY=50,
+ THD_ABORT_ASAP=100,
+};
+extern struct kill_statement_service_st {
+ enum thd_kill_levels (*thd_kill_level_func)(const THD*);
+} *thd_kill_statement_service;
+enum thd_kill_levels thd_kill_level(const THD*);
+}
+extern "C" {
+typedef struct logger_handle_st LOGGER_HANDLE;
+extern struct logger_service_st {
+ void (*logger_init_mutexes)();
+ LOGGER_HANDLE* (*open)(const char *path,
+ unsigned long long size_limit,
+ unsigned int rotations);
+ int (*close)(LOGGER_HANDLE *log);
+ int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
+ int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...);
+ int (*write)(LOGGER_HANDLE *log, const char *buffer, size_t size);
+ int (*rotate)(LOGGER_HANDLE *log);
+} *logger_service;
+ void logger_init_mutexes();
+ LOGGER_HANDLE *logger_open(const char *path,
+ unsigned long long size_limit,
+ unsigned int rotations);
+ int logger_close(LOGGER_HANDLE *log);
+ int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
+ int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
+ int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
+ int logger_rotate(LOGGER_HANDLE *log);
+}
+extern "C" {
+extern struct my_md5_service_st {
+ void (*my_md5_type)(unsigned char*, const char*, size_t);
+ void (*my_md5_multi_type)(unsigned char*, ...);
+ size_t (*my_md5_context_size_type)();
+ void (*my_md5_init_type)(void *);
+ void (*my_md5_input_type)(void *, const unsigned char *, size_t);
+ void (*my_md5_result_type)(void *, unsigned char *);
+} *my_md5_service;
+void my_md5(unsigned char*, const char*, size_t);
+void my_md5_multi(unsigned char*, ...);
+size_t my_md5_context_size();
+void my_md5_init(void *context);
+void my_md5_input(void *context, const unsigned char *buf, size_t len);
+void my_md5_result(void *context, unsigned char *digest);
+}
+extern "C" {
+enum my_aes_mode {
+ MY_AES_ECB, MY_AES_CBC
+};
+extern struct my_crypt_service_st {
+ int (*my_aes_crypt_init)(void *ctx, enum my_aes_mode mode, int flags,
+ const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen);
+ int (*my_aes_crypt_update)(void *ctx, const unsigned char *src, unsigned int slen,
+ unsigned char *dst, unsigned int *dlen);
+ int (*my_aes_crypt_finish)(void *ctx, unsigned char *dst, unsigned int *dlen);
+ int (*my_aes_crypt)(enum my_aes_mode mode, int flags,
+ const unsigned char *src, unsigned int slen, unsigned char *dst, unsigned int *dlen,
+ const unsigned char *key, unsigned int klen, const unsigned char *iv, unsigned int ivlen);
+ unsigned int (*my_aes_get_size)(enum my_aes_mode mode, unsigned int source_length);
+ unsigned int (*my_aes_ctx_size)(enum my_aes_mode mode);
+ int (*my_random_bytes)(unsigned char* buf, int num);
+} *my_crypt_service;
+int my_aes_crypt_init(void *ctx, enum my_aes_mode mode, int flags,
+ const unsigned char* key, unsigned int klen,
+ const unsigned char* iv, unsigned int ivlen);
+int my_aes_crypt_update(void *ctx, const unsigned char *src, unsigned int slen,
+ unsigned char *dst, unsigned int *dlen);
+int my_aes_crypt_finish(void *ctx, unsigned char *dst, unsigned int *dlen);
+int my_aes_crypt(enum my_aes_mode mode, int flags,
+ const unsigned char *src, unsigned int slen, unsigned char *dst, unsigned int *dlen,
+ const unsigned char *key, unsigned int klen, const unsigned char *iv, unsigned int ivlen);
+int my_random_bytes(unsigned char* buf, int num);
+unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
+unsigned int my_aes_ctx_size(enum my_aes_mode mode);
+}
+extern "C" {
+extern struct my_print_error_service_st {
+ void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
+ void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
+ void (*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap);
+} *my_print_error_service;
+extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
+extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
+extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
+}
+extern "C" {
+extern struct my_snprintf_service_st {
+ size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
+ size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
+} *my_snprintf_service;
+size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
+size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
+}
+extern "C" {
+extern struct progress_report_service_st {
+ void (*thd_progress_init_func)(THD* thd, unsigned int max_stage);
+ void (*thd_progress_report_func)(THD* thd,
+ unsigned long long progress,
+ unsigned long long max_progress);
+ void (*thd_progress_next_stage_func)(THD* thd);
+ void (*thd_progress_end_func)(THD* thd);
+ const char *(*set_thd_proc_info_func)(THD*, const char *info,
+ const char *func,
+ const char *file,
+ unsigned int line);
+} *progress_report_service;
+void thd_progress_init(THD* thd, unsigned int max_stage);
+void thd_progress_report(THD* thd,
+ unsigned long long progress,
+ unsigned long long max_progress);
+void thd_progress_next_stage(THD* thd);
+void thd_progress_end(THD* thd);
+const char *set_thd_proc_info(THD*, const char * info, const char *func,
+ const char *file, unsigned int line);
+}
+extern "C" {
+extern struct my_sha1_service_st {
+ void (*my_sha1_type)(unsigned char*, const char*, size_t);
+ void (*my_sha1_multi_type)(unsigned char*, ...);
+ size_t (*my_sha1_context_size_type)();
+ void (*my_sha1_init_type)(void *);
+ void (*my_sha1_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha1_result_type)(void *, unsigned char *);
+} *my_sha1_service;
+void my_sha1(unsigned char*, const char*, size_t);
+void my_sha1_multi(unsigned char*, ...);
+size_t my_sha1_context_size();
+void my_sha1_init(void *context);
+void my_sha1_input(void *context, const unsigned char *buf, size_t len);
+void my_sha1_result(void *context, unsigned char *digest);
+}
+extern "C" {
+extern struct my_sha2_service_st {
+ void (*my_sha224_type)(unsigned char*, const char*, size_t);
+ void (*my_sha224_multi_type)(unsigned char*, ...);
+ size_t (*my_sha224_context_size_type)();
+ void (*my_sha224_init_type)(void *);
+ void (*my_sha224_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha224_result_type)(void *, unsigned char *);
+ void (*my_sha256_type)(unsigned char*, const char*, size_t);
+ void (*my_sha256_multi_type)(unsigned char*, ...);
+ size_t (*my_sha256_context_size_type)();
+ void (*my_sha256_init_type)(void *);
+ void (*my_sha256_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha256_result_type)(void *, unsigned char *);
+ void (*my_sha384_type)(unsigned char*, const char*, size_t);
+ void (*my_sha384_multi_type)(unsigned char*, ...);
+ size_t (*my_sha384_context_size_type)();
+ void (*my_sha384_init_type)(void *);
+ void (*my_sha384_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha384_result_type)(void *, unsigned char *);
+ void (*my_sha512_type)(unsigned char*, const char*, size_t);
+ void (*my_sha512_multi_type)(unsigned char*, ...);
+ size_t (*my_sha512_context_size_type)();
+ void (*my_sha512_init_type)(void *);
+ void (*my_sha512_input_type)(void *, const unsigned char *, size_t);
+ void (*my_sha512_result_type)(void *, unsigned char *);
+} *my_sha2_service;
+void my_sha224(unsigned char*, const char*, size_t);
+void my_sha224_multi(unsigned char*, ...);
+size_t my_sha224_context_size();
+void my_sha224_init(void *context);
+void my_sha224_input(void *context, const unsigned char *buf, size_t len);
+void my_sha224_result(void *context, unsigned char *digest);
+void my_sha256(unsigned char*, const char*, size_t);
+void my_sha256_multi(unsigned char*, ...);
+size_t my_sha256_context_size();
+void my_sha256_init(void *context);
+void my_sha256_input(void *context, const unsigned char *buf, size_t len);
+void my_sha256_result(void *context, unsigned char *digest);
+void my_sha384(unsigned char*, const char*, size_t);
+void my_sha384_multi(unsigned char*, ...);
+size_t my_sha384_context_size();
+void my_sha384_init(void *context);
+void my_sha384_input(void *context, const unsigned char *buf, size_t len);
+void my_sha384_result(void *context, unsigned char *digest);
+void my_sha512(unsigned char*, const char*, size_t);
+void my_sha512_multi(unsigned char*, ...);
+size_t my_sha512_context_size();
+void my_sha512_init(void *context);
+void my_sha512_input(void *context, const unsigned char *buf, size_t len);
+void my_sha512_result(void *context, unsigned char *digest);
+}
+extern "C" {
+struct st_mysql_lex_string
+{
+ char *str;
+ size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+struct st_mysql_const_lex_string
+{
+ const char *str;
+ size_t length;
+};
+typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
+extern struct thd_alloc_service_st {
+ void *(*thd_alloc_func)(THD*, size_t);
+ void *(*thd_calloc_func)(THD*, size_t);
+ char *(*thd_strdup_func)(THD*, const char *);
+ char *(*thd_strmake_func)(THD*, const char *, size_t);
+ void *(*thd_memdup_func)(THD*, const void*, size_t);
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(THD*,
+ MYSQL_CONST_LEX_STRING *,
+ const char *, size_t, int);
+} *thd_alloc_service;
+void *thd_alloc(THD* thd, size_t size);
+void *thd_calloc(THD* thd, size_t size);
+char *thd_strdup(THD* thd, const char *str);
+char *thd_strmake(THD* thd, const char *str, size_t size);
+void *thd_memdup(THD* thd, const void* str, size_t size);
+MYSQL_CONST_LEX_STRING
+*thd_make_lex_string(THD* thd, MYSQL_CONST_LEX_STRING *lex_str,
+ const char *str, size_t size,
+ int allocate_lex_string);
+}
+extern "C" {
+extern struct thd_autoinc_service_st {
+ void (*thd_get_autoinc_func)(const THD* thd,
+ unsigned long* off, unsigned long* inc);
+} *thd_autoinc_service;
+void thd_get_autoinc(const THD* thd,
+ unsigned long* off, unsigned long* inc);
+}
+extern "C" {
+extern struct thd_error_context_service_st {
+ const char *(*thd_get_error_message_func)(const THD* thd);
+ unsigned int (*thd_get_error_number_func)(const THD* thd);
+ unsigned long (*thd_get_error_row_func)(const THD* thd);
+ void (*thd_inc_error_row_func)(THD* thd);
+ char *(*thd_get_error_context_description_func)(THD* thd,
+ char *buffer,
+ unsigned int length,
+ unsigned int max_query_length);
+} *thd_error_context_service;
+const char *thd_get_error_message(const THD* thd);
+unsigned int thd_get_error_number(const THD* thd);
+unsigned long thd_get_error_row(const THD* thd);
+void thd_inc_error_row(THD* thd);
+char *thd_get_error_context_description(THD* thd,
+ char *buffer, unsigned int length,
+ unsigned int max_query_length);
+}
+extern "C" {
+extern struct thd_rnd_service_st {
+ double (*thd_rnd_ptr)(THD* thd);
+ void (*thd_c_r_p_ptr)(THD* thd, char *to, size_t length);
+} *thd_rnd_service;
+double thd_rnd(THD* thd);
+void thd_create_random_password(THD* thd, char *to, size_t length);
+}
+extern "C" {
+typedef int MYSQL_THD_KEY_T;
+extern struct thd_specifics_service_st {
+ int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
+ void (*thd_key_delete_func)(MYSQL_THD_KEY_T *key);
+ void *(*thd_getspecific_func)(THD* thd, MYSQL_THD_KEY_T key);
+ int (*thd_setspecific_func)(THD* thd, MYSQL_THD_KEY_T key, void *value);
+} *thd_specifics_service;
+int thd_key_create(MYSQL_THD_KEY_T *key);
+void thd_key_delete(MYSQL_THD_KEY_T *key);
+void* thd_getspecific(THD* thd, MYSQL_THD_KEY_T key);
+int thd_setspecific(THD* thd, MYSQL_THD_KEY_T key, void *value);
+}
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
+{
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
+};
+typedef struct st_mysql_time
+{
+ unsigned int year, month, day, hour, minute, second;
+ unsigned long second_part;
+ my_bool neg;
+ enum enum_mysql_timestamp_type time_type;
+} MYSQL_TIME;
+extern "C" {
+extern struct thd_timezone_service_st {
+ my_time_t (*thd_TIME_to_gmt_sec)(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+} *thd_timezone_service;
+my_time_t thd_TIME_to_gmt_sec(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+}
+extern "C" {
+typedef enum _thd_wait_type_e {
+ THD_WAIT_SLEEP= 1,
+ THD_WAIT_DISKIO= 2,
+ THD_WAIT_ROW_LOCK= 3,
+ THD_WAIT_GLOBAL_LOCK= 4,
+ THD_WAIT_META_DATA_LOCK= 5,
+ THD_WAIT_TABLE_LOCK= 6,
+ THD_WAIT_USER_LOCK= 7,
+ THD_WAIT_BINLOG= 8,
+ THD_WAIT_GROUP_COMMIT= 9,
+ THD_WAIT_SYNC= 10,
+ THD_WAIT_NET= 11,
+ THD_WAIT_LAST= 12
+} thd_wait_type;
+extern struct thd_wait_service_st {
+ void (*thd_wait_begin_func)(THD*, int);
+ void (*thd_wait_end_func)(THD*);
+} *thd_wait_service;
+void thd_wait_begin(THD* thd, int wait_type);
+void thd_wait_end(THD* thd);
+}
+extern "C" {
+enum json_types
+{
+ JSV_BAD_JSON=-1,
+ JSV_NOTHING=0,
+ JSV_OBJECT=1,
+ JSV_ARRAY=2,
+ JSV_STRING=3,
+ JSV_NUMBER=4,
+ JSV_TRUE=5,
+ JSV_FALSE=6,
+ JSV_NULL=7
+};
+extern struct json_service_st {
+ enum json_types (*json_type)(const char *js, const char *js_end,
+ const char **value, int *value_len);
+ enum json_types (*json_get_array_item)(const char *js, const char *js_end,
+ int n_item,
+ const char **value, int *value_len);
+ enum json_types (*json_get_object_key)(const char *js, const char *js_end,
+ const char *key,
+ const char **value, int *value_len);
+ enum json_types (*json_get_object_nkey)(const char *js,const char *js_end,
+ int nkey,
+ const char **keyname, const char **keyname_end,
+ const char **value, int *value_len);
+ int (*json_escape_string)(const char *str,const char *str_end,
+ char *json, char *json_end);
+ int (*json_unescape_json)(const char *json_str, const char *json_end,
+ char *res, char *res_end);
+} *json_service;
+enum json_types json_type(const char *js, const char *js_end,
+ const char **value, int *value_len);
+enum json_types json_get_array_item(const char *js, const char *js_end,
+ int n_item,
+ const char **value, int *value_len);
+enum json_types json_get_object_key(const char *js, const char *js_end,
+ const char *key,
+ const char **value, int *value_len);
+enum json_types json_get_object_nkey(const char *js,const char *js_end, int nkey,
+ const char **keyname, const char **keyname_end,
+ const char **value, int *value_len);
+int json_escape_string(const char *str,const char *str_end,
+ char *json, char *json_end);
+int json_unescape_json(const char *json_str, const char *json_end,
+ char *res, char *res_end);
+}
+}
+struct st_mysql_xid {
+ long formatID;
+ long gtrid_length;
+ long bqual_length;
+ char data[128];
+};
+typedef struct st_mysql_xid MYSQL_XID;
+enum enum_mysql_show_type
+{
+ SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG,
+ SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
+ SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
+ SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
+ SHOW_SIZE_T, SHOW_always_last
+};
+enum enum_var_type
+{
+ SHOW_OPT_DEFAULT= 0, SHOW_OPT_SESSION, SHOW_OPT_GLOBAL
+};
+struct st_mysql_show_var {
+ const char *name;
+ void *value;
+ enum enum_mysql_show_type type;
+};
+struct system_status_var;
+typedef int (*mysql_show_var_func)(THD*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
+struct st_mysql_sys_var;
+struct st_mysql_value;
+typedef int (*mysql_var_check_func)(THD* thd,
+ struct st_mysql_sys_var *var,
+ void *save, struct st_mysql_value *value);
+typedef void (*mysql_var_update_func)(THD* thd,
+ struct st_mysql_sys_var *var,
+ void *var_ptr, const void *save);
+struct st_mysql_plugin
+{
+ int type;
+ void *info;
+ const char *name;
+ const char *author;
+ const char *descr;
+ int license;
+ int (*init)(void *);
+ int (*deinit)(void *);
+ unsigned int version;
+ struct st_mysql_show_var *status_vars;
+ struct st_mysql_sys_var **system_vars;
+ void * __reserved1;
+ unsigned long flags;
+};
+struct st_maria_plugin
+{
+ int type;
+ void *info;
+ const char *name;
+ const char *author;
+ const char *descr;
+ int license;
+ int (*init)(void *);
+ int (*deinit)(void *);
+ unsigned int version;
+ struct st_mysql_show_var *status_vars;
+ struct st_mysql_sys_var **system_vars;
+ const char *version_info;
+ unsigned int maturity;
+};
+extern "C" {
+enum enum_ftparser_mode
+{
+ MYSQL_FTPARSER_SIMPLE_MODE= 0,
+ MYSQL_FTPARSER_WITH_STOPWORDS= 1,
+ MYSQL_FTPARSER_FULL_BOOLEAN_INFO= 2
+};
+enum enum_ft_token_type
+{
+ FT_TOKEN_EOF= 0,
+ FT_TOKEN_WORD= 1,
+ FT_TOKEN_LEFT_PAREN= 2,
+ FT_TOKEN_RIGHT_PAREN= 3,
+ FT_TOKEN_STOPWORD= 4
+};
+typedef struct st_mysql_ftparser_boolean_info
+{
+ enum enum_ft_token_type type;
+ int yesno;
+ int weight_adjust;
+ char wasign;
+ char trunc;
+ char prev;
+ char *quot;
+} MYSQL_FTPARSER_BOOLEAN_INFO;
+typedef struct st_mysql_ftparser_param
+{
+ int (*mysql_parse)(struct st_mysql_ftparser_param *,
+ const char *doc, int doc_len);
+ int (*mysql_add_word)(struct st_mysql_ftparser_param *,
+ const char *word, int word_len,
+ MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info);
+ void *ftparser_state;
+ void *mysql_ftparam;
+ const struct charset_info_st *cs;
+ const char *doc;
+ int length;
+ unsigned int flags;
+ enum enum_ftparser_mode mode;
+} MYSQL_FTPARSER_PARAM;
+struct st_mysql_ftparser
+{
+ int interface_version;
+ int (*parse)(MYSQL_FTPARSER_PARAM *param);
+ int (*init)(MYSQL_FTPARSER_PARAM *param);
+ int (*deinit)(MYSQL_FTPARSER_PARAM *param);
+};
+}
+struct st_mysql_daemon
+{
+ int interface_version;
+};
+struct st_mysql_information_schema
+{
+ int interface_version;
+};
+struct st_mysql_storage_engine
+{
+ int interface_version;
+};
+struct handlerton;
+ struct Mysql_replication {
+ int interface_version;
+ };
+struct st_mysql_value
+{
+ int (*value_type)(struct st_mysql_value *);
+ const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
+ int (*val_real)(struct st_mysql_value *, double *realbuf);
+ int (*val_int)(struct st_mysql_value *, long long *intbuf);
+ int (*is_unsigned)(struct st_mysql_value *);
+};
+extern "C" {
+int thd_in_lock_tables(const THD* thd);
+int thd_tablespace_op(const THD* thd);
+long long thd_test_options(const THD* thd, long long test_options);
+int thd_sql_command(const THD* thd);
+void thd_storage_lock_wait(THD* thd, long long value);
+int thd_tx_isolation(const THD* thd);
+int thd_tx_is_read_only(const THD* thd);
+int mysql_tmpfile(const char *prefix);
+unsigned long thd_get_thread_id(const THD* thd);
+void thd_get_xid(const THD* thd, MYSQL_XID *xid);
+void mysql_query_cache_invalidate4(THD* thd,
+ const char *key, unsigned int key_length,
+ int using_trx);
+void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
+void thd_set_ha_data(THD* thd, const struct handlerton *hton,
+ const void *ha_data);
+void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
+}
+class Plugin_function
+{
+ int m_interface_version;
+ Create_func *m_builder;
+public:
+ Plugin_function(Create_func *builder)
+ :m_interface_version((MYSQL_VERSION_ID << 8)),
+ m_builder(builder)
+ { }
+ Create_func *create_func()
+ {
+ return m_builder;
+ }
+};
diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp
index 2f9d2299c1f..fc8c3848f8c 100644
--- a/include/mysql/plugin_password_validation.h.pp
+++ b/include/mysql/plugin_password_validation.h.pp
@@ -1,5 +1,9 @@
+class THD;
+class Item;
typedef char my_bool;
typedef void * MYSQL_PLUGIN;
+extern "C" {
+extern "C" {
extern struct base64_service_st {
int (*base64_needed_encoded_length_ptr)(int length_of_data);
int (*base64_encode_max_arg_length_ptr)(void);
@@ -16,7 +20,11 @@ int my_base64_decode_max_arg_length();
int my_base64_encode(const void *src, size_t src_len, char *dst);
int my_base64_decode(const char *src, size_t src_len,
void *dst, const char **end_ptr, int flags);
-extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
+}
+extern "C" {
+extern void (*debug_sync_C_callback_ptr)(THD*, const char *, size_t);
+}
+extern "C" {
struct encryption_service_st {
unsigned int (*encryption_key_get_latest_version_func)(unsigned int key_id);
unsigned int (*encryption_key_get_func)(unsigned int key_id, unsigned int key_version,
@@ -57,6 +65,8 @@ static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
*dlen= d1 + d2;
return res1 ? res1 : res2;
}
+}
+extern "C" {
struct st_encryption_scheme_key {
unsigned int version;
unsigned char key[16];
@@ -93,15 +103,19 @@ int encryption_scheme_decrypt(const unsigned char* src, unsigned int slen,
struct st_encryption_scheme *scheme,
unsigned int key_version, unsigned int i32_1,
unsigned int i32_2, unsigned long long i64);
+}
+extern "C" {
enum thd_kill_levels {
THD_IS_NOT_KILLED=0,
THD_ABORT_SOFTLY=50,
THD_ABORT_ASAP=100,
};
extern struct kill_statement_service_st {
- enum thd_kill_levels (*thd_kill_level_func)(const void*);
+ enum thd_kill_levels (*thd_kill_level_func)(const THD*);
} *thd_kill_statement_service;
-enum thd_kill_levels thd_kill_level(const void*);
+enum thd_kill_levels thd_kill_level(const THD*);
+}
+extern "C" {
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
@@ -123,6 +137,8 @@ extern struct logger_service_st {
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
int logger_rotate(LOGGER_HANDLE *log);
+}
+extern "C" {
extern struct my_md5_service_st {
void (*my_md5_type)(unsigned char*, const char*, size_t);
void (*my_md5_multi_type)(unsigned char*, ...);
@@ -137,6 +153,8 @@ size_t my_md5_context_size();
void my_md5_init(void *context);
void my_md5_input(void *context, const unsigned char *buf, size_t len);
void my_md5_result(void *context, unsigned char *digest);
+}
+extern "C" {
enum my_aes_mode {
MY_AES_ECB, MY_AES_CBC
};
@@ -166,6 +184,8 @@ int my_aes_crypt(enum my_aes_mode mode, int flags,
int my_random_bytes(unsigned char* buf, int num);
unsigned int my_aes_get_size(enum my_aes_mode mode, unsigned int source_length);
unsigned int my_aes_ctx_size(enum my_aes_mode mode);
+}
+extern "C" {
extern struct my_print_error_service_st {
void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...);
void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...);
@@ -174,32 +194,38 @@ extern struct my_print_error_service_st {
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
+}
+extern "C" {
extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
} *my_snprintf_service;
size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
+}
+extern "C" {
extern struct progress_report_service_st {
- void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
- void (*thd_progress_report_func)(void* thd,
+ void (*thd_progress_init_func)(THD* thd, unsigned int max_stage);
+ void (*thd_progress_report_func)(THD* thd,
unsigned long long progress,
unsigned long long max_progress);
- void (*thd_progress_next_stage_func)(void* thd);
- void (*thd_progress_end_func)(void* thd);
- const char *(*set_thd_proc_info_func)(void*, const char *info,
+ void (*thd_progress_next_stage_func)(THD* thd);
+ void (*thd_progress_end_func)(THD* thd);
+ const char *(*set_thd_proc_info_func)(THD*, const char *info,
const char *func,
const char *file,
unsigned int line);
} *progress_report_service;
-void thd_progress_init(void* thd, unsigned int max_stage);
-void thd_progress_report(void* thd,
+void thd_progress_init(THD* thd, unsigned int max_stage);
+void thd_progress_report(THD* thd,
unsigned long long progress,
unsigned long long max_progress);
-void thd_progress_next_stage(void* thd);
-void thd_progress_end(void* thd);
-const char *set_thd_proc_info(void*, const char * info, const char *func,
+void thd_progress_next_stage(THD* thd);
+void thd_progress_end(THD* thd);
+const char *set_thd_proc_info(THD*, const char * info, const char *func,
const char *file, unsigned int line);
+}
+extern "C" {
extern struct my_sha1_service_st {
void (*my_sha1_type)(unsigned char*, const char*, size_t);
void (*my_sha1_multi_type)(unsigned char*, ...);
@@ -214,6 +240,8 @@ size_t my_sha1_context_size();
void my_sha1_init(void *context);
void my_sha1_input(void *context, const unsigned char *buf, size_t len);
void my_sha1_result(void *context, unsigned char *digest);
+}
+extern "C" {
extern struct my_sha2_service_st {
void (*my_sha224_type)(unsigned char*, const char*, size_t);
void (*my_sha224_multi_type)(unsigned char*, ...);
@@ -264,6 +292,8 @@ size_t my_sha512_context_size();
void my_sha512_init(void *context);
void my_sha512_input(void *context, const unsigned char *buf, size_t len);
void my_sha512_result(void *context, unsigned char *digest);
+}
+extern "C" {
struct st_mysql_lex_string
{
char *str;
@@ -277,64 +307,73 @@ struct st_mysql_const_lex_string
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, size_t);
- void *(*thd_calloc_func)(void*, size_t);
- char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, size_t);
- void *(*thd_memdup_func)(void*, const void*, size_t);
- MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
+ void *(*thd_alloc_func)(THD*, size_t);
+ void *(*thd_calloc_func)(THD*, size_t);
+ char *(*thd_strdup_func)(THD*, const char *);
+ char *(*thd_strmake_func)(THD*, const char *, size_t);
+ void *(*thd_memdup_func)(THD*, const void*, size_t);
+ MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(THD*,
MYSQL_CONST_LEX_STRING *,
const char *, size_t, int);
} *thd_alloc_service;
-void *thd_alloc(void* thd, size_t size);
-void *thd_calloc(void* thd, size_t size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, size_t size);
-void *thd_memdup(void* thd, const void* str, size_t size);
+void *thd_alloc(THD* thd, size_t size);
+void *thd_calloc(THD* thd, size_t size);
+char *thd_strdup(THD* thd, const char *str);
+char *thd_strmake(THD* thd, const char *str, size_t size);
+void *thd_memdup(THD* thd, const void* str, size_t size);
MYSQL_CONST_LEX_STRING
-*thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
+*thd_make_lex_string(THD* thd, MYSQL_CONST_LEX_STRING *lex_str,
const char *str, size_t size,
int allocate_lex_string);
+}
+extern "C" {
extern struct thd_autoinc_service_st {
- void (*thd_get_autoinc_func)(const void* thd,
+ void (*thd_get_autoinc_func)(const THD* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
-void thd_get_autoinc(const void* thd,
+void thd_get_autoinc(const THD* thd,
unsigned long* off, unsigned long* inc);
+}
+extern "C" {
extern struct thd_error_context_service_st {
- const char *(*thd_get_error_message_func)(const void* thd);
- unsigned int (*thd_get_error_number_func)(const void* thd);
- unsigned long (*thd_get_error_row_func)(const void* thd);
- void (*thd_inc_error_row_func)(void* thd);
- char *(*thd_get_error_context_description_func)(void* thd,
+ const char *(*thd_get_error_message_func)(const THD* thd);
+ unsigned int (*thd_get_error_number_func)(const THD* thd);
+ unsigned long (*thd_get_error_row_func)(const THD* thd);
+ void (*thd_inc_error_row_func)(THD* thd);
+ char *(*thd_get_error_context_description_func)(THD* thd,
char *buffer,
unsigned int length,
unsigned int max_query_length);
} *thd_error_context_service;
-const char *thd_get_error_message(const void* thd);
-unsigned int thd_get_error_number(const void* thd);
-unsigned long thd_get_error_row(const void* thd);
-void thd_inc_error_row(void* thd);
-char *thd_get_error_context_description(void* thd,
+const char *thd_get_error_message(const THD* thd);
+unsigned int thd_get_error_number(const THD* thd);
+unsigned long thd_get_error_row(const THD* thd);
+void thd_inc_error_row(THD* thd);
+char *thd_get_error_context_description(THD* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
+}
+extern "C" {
extern struct thd_rnd_service_st {
- double (*thd_rnd_ptr)(void* thd);
- void (*thd_c_r_p_ptr)(void* thd, char *to, size_t length);
+ double (*thd_rnd_ptr)(THD* thd);
+ void (*thd_c_r_p_ptr)(THD* thd, char *to, size_t length);
} *thd_rnd_service;
-double thd_rnd(void* thd);
-void thd_create_random_password(void* thd, char *to, size_t length);
+double thd_rnd(THD* thd);
+void thd_create_random_password(THD* thd, char *to, size_t length);
+}
+extern "C" {
typedef int MYSQL_THD_KEY_T;
extern struct thd_specifics_service_st {
int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
void (*thd_key_delete_func)(MYSQL_THD_KEY_T *key);
- void *(*thd_getspecific_func)(void* thd, MYSQL_THD_KEY_T key);
- int (*thd_setspecific_func)(void* thd, MYSQL_THD_KEY_T key, void *value);
+ void *(*thd_getspecific_func)(THD* thd, MYSQL_THD_KEY_T key);
+ int (*thd_setspecific_func)(THD* thd, MYSQL_THD_KEY_T key, void *value);
} *thd_specifics_service;
int thd_key_create(MYSQL_THD_KEY_T *key);
void thd_key_delete(MYSQL_THD_KEY_T *key);
-void* thd_getspecific(void* thd, MYSQL_THD_KEY_T key);
-int thd_setspecific(void* thd, MYSQL_THD_KEY_T key, void *value);
+void* thd_getspecific(THD* thd, MYSQL_THD_KEY_T key);
+int thd_setspecific(THD* thd, MYSQL_THD_KEY_T key, void *value);
+}
typedef long my_time_t;
enum enum_mysql_timestamp_type
{
@@ -348,12 +387,15 @@ typedef struct st_mysql_time
my_bool neg;
enum enum_mysql_timestamp_type time_type;
} MYSQL_TIME;
+extern "C" {
extern struct thd_timezone_service_st {
- my_time_t (*thd_TIME_to_gmt_sec)(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
- void (*thd_gmt_sec_to_TIME)(void* thd, MYSQL_TIME *ltime, my_time_t t);
+ my_time_t (*thd_TIME_to_gmt_sec)(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+ void (*thd_gmt_sec_to_TIME)(THD* thd, MYSQL_TIME *ltime, my_time_t t);
} *thd_timezone_service;
-my_time_t thd_TIME_to_gmt_sec(void* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
-void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
+my_time_t thd_TIME_to_gmt_sec(THD* thd, const MYSQL_TIME *ltime, unsigned int *errcode);
+void thd_gmt_sec_to_TIME(THD* thd, MYSQL_TIME *ltime, my_time_t t);
+}
+extern "C" {
typedef enum _thd_wait_type_e {
THD_WAIT_SLEEP= 1,
THD_WAIT_DISKIO= 2,
@@ -369,11 +411,13 @@ typedef enum _thd_wait_type_e {
THD_WAIT_LAST= 12
} thd_wait_type;
extern struct thd_wait_service_st {
- void (*thd_wait_begin_func)(void*, int);
- void (*thd_wait_end_func)(void*);
+ void (*thd_wait_begin_func)(THD*, int);
+ void (*thd_wait_end_func)(THD*);
} *thd_wait_service;
-void thd_wait_begin(void* thd, int wait_type);
-void thd_wait_end(void* thd);
+void thd_wait_begin(THD* thd, int wait_type);
+void thd_wait_end(THD* thd);
+}
+extern "C" {
enum json_types
{
JSV_BAD_JSON=-1,
@@ -419,6 +463,8 @@ int json_escape_string(const char *str,const char *str_end,
char *json, char *json_end);
int json_unescape_json(const char *json_str, const char *json_end,
char *res, char *res_end);
+}
+}
struct st_mysql_xid {
long formatID;
long gtrid_length;
@@ -432,7 +478,7 @@ enum enum_mysql_show_type
SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC,
- SHOW_always_last
+ SHOW_SIZE_T, SHOW_always_last
};
enum enum_var_type
{
@@ -444,13 +490,13 @@ struct st_mysql_show_var {
enum enum_mysql_show_type type;
};
struct system_status_var;
-typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
+typedef int (*mysql_show_var_func)(THD*, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type);
struct st_mysql_sys_var;
struct st_mysql_value;
-typedef int (*mysql_var_check_func)(void* thd,
+typedef int (*mysql_var_check_func)(THD* thd,
struct st_mysql_sys_var *var,
void *save, struct st_mysql_value *value);
-typedef void (*mysql_var_update_func)(void* thd,
+typedef void (*mysql_var_update_func)(THD* thd,
struct st_mysql_sys_var *var,
void *var_ptr, const void *save);
struct st_mysql_plugin
@@ -485,6 +531,7 @@ struct st_maria_plugin
const char *version_info;
unsigned int maturity;
};
+extern "C" {
enum enum_ftparser_mode
{
MYSQL_FTPARSER_SIMPLE_MODE= 0,
@@ -531,6 +578,7 @@ struct st_mysql_ftparser
int (*init)(MYSQL_FTPARSER_PARAM *param);
int (*deinit)(MYSQL_FTPARSER_PARAM *param);
};
+}
struct st_mysql_daemon
{
int interface_version;
@@ -555,27 +603,30 @@ struct st_mysql_value
int (*val_int)(struct st_mysql_value *, long long *intbuf);
int (*is_unsigned)(struct st_mysql_value *);
};
-int thd_in_lock_tables(const void* thd);
-int thd_tablespace_op(const void* thd);
-long long thd_test_options(const void* thd, long long test_options);
-int thd_sql_command(const void* thd);
-void **thd_ha_data(const void* thd, const struct handlerton *hton);
-void thd_storage_lock_wait(void* thd, long long value);
-int thd_tx_isolation(const void* thd);
-int thd_tx_is_read_only(const void* thd);
+extern "C" {
+int thd_in_lock_tables(const THD* thd);
+int thd_tablespace_op(const THD* thd);
+long long thd_test_options(const THD* thd, long long test_options);
+int thd_sql_command(const THD* thd);
+void thd_storage_lock_wait(THD* thd, long long value);
+int thd_tx_isolation(const THD* thd);
+int thd_tx_is_read_only(const THD* thd);
int mysql_tmpfile(const char *prefix);
-unsigned long thd_get_thread_id(const void* thd);
-void thd_get_xid(const void* thd, MYSQL_XID *xid);
-void mysql_query_cache_invalidate4(void* thd,
+unsigned long thd_get_thread_id(const THD* thd);
+void thd_get_xid(const THD* thd, MYSQL_XID *xid);
+void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
-void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
-void thd_set_ha_data(void* thd, const struct handlerton *hton,
+void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
+void thd_set_ha_data(THD* thd, const struct handlerton *hton,
const void *ha_data);
-void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
+void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
+}
+extern "C" {
struct st_mariadb_password_validation
{
int interface_version;
int (*validate_password)(const MYSQL_CONST_LEX_STRING *username,
const MYSQL_CONST_LEX_STRING *password);
};
+}
diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h
index 1d2ec34fc98..9b172cfe9b0 100644
--- a/include/mysql/psi/mysql_file.h
+++ b/include/mysql/psi/mysql_file.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -48,6 +48,10 @@
#include "mysql/psi/psi.h"
+#ifndef PSI_FILE_CALL
+#define PSI_FILE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup File_instrumentation File Instrumentation
@ingroup Instrumentation_interface
@@ -212,7 +216,7 @@
With the instrumentation, mysql_fclose(NULL, ...) will safely return 0,
which is an extension compared to my_fclose and is therefore compliant.
mysql_fclose is on purpose *not* implementing
- @code DBUG_ASSERT(file != NULL) @endcode,
+ @code assert(file != NULL) @endcode,
since doing so could introduce regressions.
*/
#ifdef HAVE_PSI_FILE_INTERFACE
@@ -295,7 +299,7 @@
*/
#ifdef HAVE_PSI_FILE_INTERFACE
#define mysql_file_create_temp(K, T, D, P, M, F) \
- inline_mysql_file_create_temp(K, T, D, P, M, F)
+ inline_mysql_file_create_temp(K, __FILE__, __LINE__, T, D, P, M, F)
#else
#define mysql_file_create_temp(K, T, D, P, M, F) \
inline_mysql_file_create_temp(T, D, P, M, F)
@@ -536,7 +540,7 @@ inline_mysql_file_fgets(
{
char *result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -564,7 +568,7 @@ inline_mysql_file_fgetc(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -592,7 +596,7 @@ inline_mysql_file_fputs(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -622,7 +626,7 @@ inline_mysql_file_fputc(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -650,7 +654,7 @@ inline_mysql_file_fprintf(MYSQL_FILE *file, const char *format, ...)
int result;
va_list args;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -682,7 +686,7 @@ inline_mysql_file_vfprintf(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -710,7 +714,7 @@ inline_mysql_file_fflush(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -744,18 +748,15 @@ inline_mysql_file_fstat(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, filenr, PSI_FILE_FSTAT);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, filenr, PSI_FILE_FSTAT);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_fstat(filenr, stat_area, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_fstat(filenr, stat_area, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
}
#endif
@@ -772,18 +773,15 @@ inline_mysql_file_stat(
{
MY_STAT *result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STAT, path, &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STAT, path, &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- result= my_stat(path, stat_area, flags);
- PSI_FILE_CALL(end_file_open_wait)(locker, result);
- return result;
- }
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ result= my_stat(path, stat_area, flags);
+ PSI_FILE_CALL(end_file_open_wait)(locker, result);
+ return result;
}
#endif
@@ -800,19 +798,16 @@ inline_mysql_file_chsize(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CHSIZE);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CHSIZE);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) newlength, src_file,
- src_line);
- result= my_chsize(file, newlength, filler, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) newlength);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) newlength, src_file,
+ src_line);
+ result= my_chsize(file, newlength, filler, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) newlength);
+ return result;
}
#endif
@@ -828,28 +823,26 @@ inline_mysql_file_fopen(
const char *filename, int flags, myf myFlags)
{
MYSQL_FILE *that;
- that= (MYSQL_FILE*) my_malloc(sizeof(MYSQL_FILE), MYF(MY_WME));
+ that= (MYSQL_FILE*) my_malloc(PSI_NOT_INSTRUMENTED,
+ sizeof(MYSQL_FILE), MYF(MY_WME));
if (likely(that != NULL))
{
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STREAM_OPEN,
+ filename, that);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_STREAM_OPEN,
- filename, that);
- if (likely(locker != NULL))
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ that->m_file= my_fopen(filename, flags, myFlags);
+ that->m_psi= PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file);
+ if (unlikely(that->m_file == NULL))
{
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- that->m_file= my_fopen(filename, flags, myFlags);
- that->m_psi= PSI_FILE_CALL(end_file_open_wait)(locker, that->m_file);
- if (unlikely(that->m_file == NULL))
- {
- my_free(that);
- return NULL;
- }
- return that;
+ my_free(that);
+ return NULL;
}
+ return that;
}
#endif
@@ -875,7 +868,7 @@ inline_mysql_file_fclose(
if (likely(file != NULL))
{
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -907,7 +900,7 @@ inline_mysql_file_fread(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -940,7 +933,7 @@ inline_mysql_file_fwrite(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -973,7 +966,7 @@ inline_mysql_file_fseek(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -1001,7 +994,7 @@ inline_mysql_file_ftell(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ if (psi_likely(file->m_psi))
{
struct PSI_file_locker *locker;
PSI_file_locker_state state;
@@ -1029,19 +1022,16 @@ inline_mysql_file_create(
{
File file;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
+ &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
- &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- file= my_create(filename, create_flags, access_flags, myFlags);
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
- return file;
- }
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ file= my_create(filename, create_flags, access_flags, myFlags);
+ PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
+ return file;
}
#endif
@@ -1052,20 +1042,27 @@ inline_mysql_file_create(
static inline File
inline_mysql_file_create_temp(
#ifdef HAVE_PSI_FILE_INTERFACE
- PSI_file_key key,
+ PSI_file_key key, const char *src_file, uint src_line,
#endif
char *to, const char *dir, const char *pfx, int mode, myf myFlags)
{
File file;
- /*
- TODO: This event is instrumented, but not timed.
- The problem is that the file name is now known
- before the create_temp_file call.
- */
- file= create_temp_file(to, dir, pfx, mode, myFlags);
#ifdef HAVE_PSI_FILE_INTERFACE
- PSI_FILE_CALL(create_file)(key, to, file);
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_CREATE, NULL, &locker);
+ if (psi_likely(locker != NULL))
+ {
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ /* The file name is generated by create_temp_file(). */
+ file= create_temp_file(to, dir, pfx, mode, myFlags);
+ PSI_FILE_CALL(end_temp_file_open_wait_and_bind_to_descriptor)(locker, file, (const char*)to);
+ return file;
+ }
#endif
+
+ file= create_temp_file(to, dir, pfx, mode, myFlags);
return file;
}
@@ -1078,19 +1075,16 @@ inline_mysql_file_open(
{
File file;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_OPEN, filename,
+ &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_OPEN, filename,
- &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- file= my_open(filename, flags, myFlags);
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
- return file;
- }
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ file= my_open(filename, flags, myFlags);
+ PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
+ return file;
}
#endif
@@ -1107,18 +1101,15 @@ inline_mysql_file_close(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CLOSE);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_CLOSE);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_close(file, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- return result;
- }
+ PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
+ result= my_close(file, flags);
+ PSI_FILE_CALL(end_file_close_wait)(locker, result);
+ return result;
}
#endif
@@ -1135,23 +1126,20 @@ inline_mysql_file_read(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_read;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_read;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_read(file, buffer, count, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_read= (result == 0) ? count : 0;
- else
- bytes_read= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_read(file, buffer, count, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_read= (result == 0) ? count : 0;
+ else
+ bytes_read= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
+ return result;
}
#endif
@@ -1168,23 +1156,20 @@ inline_mysql_file_write(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_written;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_written;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_write(file, buffer, count, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_written= (result == 0) ? count : 0;
- else
- bytes_written= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_write(file, buffer, count, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_written= (result == 0) ? count : 0;
+ else
+ bytes_written= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
+ return result;
}
#endif
@@ -1201,23 +1186,20 @@ inline_mysql_file_pread(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_read;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_read;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_READ);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_pread(file, buffer, count, offset, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_read= (result == 0) ? count : 0;
- else
- bytes_read= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_pread(file, buffer, count, offset, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_read= (result == 0) ? count : 0;
+ else
+ bytes_read= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_read);
+ return result;
}
#endif
@@ -1234,23 +1216,20 @@ inline_mysql_file_pwrite(
{
size_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ size_t bytes_written;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- size_t bytes_written;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_WRITE);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
- result= my_pwrite(file, buffer, count, offset, flags);
- if (flags & (MY_NABP | MY_FNABP))
- bytes_written= (result == 0) ? count : 0;
- else
- bytes_written= (result != MY_FILE_ERROR) ? result : 0;
- PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, count, src_file, src_line);
+ result= my_pwrite(file, buffer, count, offset, flags);
+ if (flags & (MY_NABP | MY_FNABP))
+ bytes_written= (result == 0) ? count : 0;
+ else
+ bytes_written= (result != MY_FILE_ERROR) ? result : 0;
+ PSI_FILE_CALL(end_file_wait)(locker, bytes_written);
+ return result;
}
#endif
@@ -1267,18 +1246,15 @@ inline_mysql_file_seek(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_SEEK);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_SEEK);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_seek(file, pos, whence, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_seek(file, pos, whence, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
}
#endif
@@ -1295,18 +1271,15 @@ inline_mysql_file_tell(
{
my_off_t result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_TELL);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, file, PSI_FILE_TELL);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_tell(file, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_tell(file, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
}
#endif
@@ -1323,18 +1296,15 @@ inline_mysql_file_delete(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, name, &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, name, &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_delete(name, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- return result;
- }
+ PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
+ result= my_delete(name, flags);
+ PSI_FILE_CALL(end_file_close_wait)(locker, result);
+ return result;
}
#endif
@@ -1351,18 +1321,16 @@ inline_mysql_file_rename(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_RENAME, from, &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_RENAME, to, &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_rename(from, to, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_rename(from, to, flags);
+ PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result);
+ return result;
}
#endif
@@ -1381,20 +1349,17 @@ inline_mysql_file_create_with_symlink(
{
File file;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
+ &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_CREATE, filename,
- &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
- file= my_create_with_symlink(linkname, filename, create_flags, access_flags,
- flags);
- PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
- return file;
- }
+ PSI_FILE_CALL(start_file_open_wait)(locker, src_file, src_line);
+ file= my_create_with_symlink(linkname, filename, create_flags, access_flags,
+ flags);
+ PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)(locker, file);
+ return file;
}
#endif
@@ -1415,19 +1380,16 @@ inline_mysql_file_delete_with_symlink(
char buf[FN_REFLEN];
char *fullname= fn_format(buf, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, fullname,
+ &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_DELETE, fullname,
- &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_handler_delete_with_symlink(fullname, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- return result;
- }
+ PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
+ result= my_handler_delete_with_symlink(fullname, flags);
+ PSI_FILE_CALL(end_file_close_wait)(locker, result);
+ return result;
}
#endif
@@ -1445,18 +1407,16 @@ inline_mysql_file_rename_with_symlink(
{
int result;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_name_locker)
+ (&state, key, PSI_FILE_RENAME, from, &locker);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)(&state, key, PSI_FILE_RENAME, to, &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_rename_with_symlink(from, to, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_rename_with_symlink(from, to, flags);
+ PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result);
+ return result;
}
#endif
@@ -1473,18 +1433,15 @@ inline_mysql_file_sync(
{
int result= 0;
#ifdef HAVE_PSI_FILE_INTERFACE
- if (psi_likely(pfs_enabled))
+ struct PSI_file_locker *locker;
+ PSI_file_locker_state state;
+ locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, fd, PSI_FILE_SYNC);
+ if (psi_likely(locker != NULL))
{
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_descriptor_locker)(&state, fd, PSI_FILE_SYNC);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
- result= my_sync(fd, flags);
- PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
- return result;
- }
+ PSI_FILE_CALL(start_file_wait)(locker, (size_t) 0, src_file, src_line);
+ result= my_sync(fd, flags);
+ PSI_FILE_CALL(end_file_wait)(locker, (size_t) 0);
+ return result;
}
#endif
diff --git a/include/mysql/psi/mysql_idle.h b/include/mysql/psi/mysql_idle.h
index 1eb19f8f684..1c9927f95b2 100644
--- a/include/mysql/psi/mysql_idle.h
+++ b/include/mysql/psi/mysql_idle.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- Copyright (c) 2017, MariaDB Corporation.
+/* Copyright (c) 2011, 2022, Oracle and/or its affiliates
+ Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -31,6 +31,10 @@
#include "mysql/psi/psi.h"
+#ifndef PSI_IDLE_CALL
+#define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup Idle_instrumentation Idle Instrumentation
@ingroup Instrumentation_interface
diff --git a/include/mysql/psi/mysql_mdl.h b/include/mysql/psi/mysql_mdl.h
new file mode 100644
index 00000000000..483f28f396b
--- /dev/null
+++ b/include/mysql/psi/mysql_mdl.h
@@ -0,0 +1,143 @@
+/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ 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, version 2.0, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef MYSQL_MDL_H
+#define MYSQL_MDL_H
+
+/**
+ @file mysql/psi/mysql_mdl.h
+ Instrumentation helpers for metadata locks.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifdef HAVE_PSI_METADATA_INTERFACE
+
+#ifndef PSI_METADATA_CALL
+#define PSI_METADATA_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#define PSI_CALL_start_metadata_wait(A,B,C,D) PSI_METADATA_CALL(start_metadata_wait)(A,B,C,D)
+#define PSI_CALL_end_metadata_wait(A,B) PSI_METADATA_CALL(end_metadata_wait)(A,B)
+#define PSI_CALL_create_metadata_lock(A,B,C,D,E,F,G) PSI_METADATA_CALL(create_metadata_lock)(A,B,C,D,E,F,G)
+#define PSI_CALL_set_metadata_lock_status(A,B) PSI_METADATA_CALL(set_metadata_lock_status)(A,B)
+#define PSI_CALL_destroy_metadata_lock(A) PSI_METADATA_CALL(destroy_metadata_lock)(A)
+#else
+#define PSI_CALL_start_metadata_wait(A,B,C,D) 0
+#define PSI_CALL_end_metadata_wait(A,B) do { } while(0)
+#define PSI_CALL_create_metadata_lock(A,B,C,D,E,F,G) 0
+#define PSI_CALL_set_metadata_lock_status(A,B) do {} while(0)
+#define PSI_CALL_destroy_metadata_lock(A) do {} while(0)
+#endif
+
+/**
+ @defgroup Thread_instrumentation Metadata Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ @def mysql_mdl_create(K, M, A)
+ Instrumented metadata lock creation.
+ @param I Metadata lock identity
+ @param K Metadata key
+ @param T Metadata lock type
+ @param D Metadata lock duration
+ @param S Metadata lock status
+ @param F request source file
+ @param L request source line
+*/
+
+#ifdef HAVE_PSI_METADATA_INTERFACE
+ #define mysql_mdl_create(I, K, T, D, S, F, L) \
+ inline_mysql_mdl_create(I, K, T, D, S, F, L)
+#else
+ #define mysql_mdl_create(I, K, T, D, S, F, L) NULL
+#endif
+
+#ifdef HAVE_PSI_METADATA_INTERFACE
+ #define mysql_mdl_set_status(L, S) \
+ inline_mysql_mdl_set_status(L, S)
+#else
+ #define mysql_mdl_set_status(L, S) \
+ do {} while (0)
+#endif
+
+
+/**
+ @def mysql_mdl_destroy(M)
+ Instrumented metadata lock destruction.
+ @param M Metadata lock
+*/
+#ifdef HAVE_PSI_METADATA_INTERFACE
+ #define mysql_mdl_destroy(M) \
+ inline_mysql_mdl_destroy(M, __FILE__, __LINE__)
+#else
+ #define mysql_mdl_destroy(M) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_METADATA_INTERFACE
+
+static inline PSI_metadata_lock *
+inline_mysql_mdl_create(void *identity,
+ const MDL_key *mdl_key,
+ enum_mdl_type mdl_type,
+ enum_mdl_duration mdl_duration,
+ MDL_ticket::enum_psi_status mdl_status,
+ const char *src_file, uint src_line)
+{
+ PSI_metadata_lock *result;
+
+ /* static_cast: Fit a round C++ enum peg into a square C int hole ... */
+ result= PSI_METADATA_CALL(create_metadata_lock)
+ (identity,
+ mdl_key,
+ static_cast<opaque_mdl_type> (mdl_type),
+ static_cast<opaque_mdl_duration> (mdl_duration),
+ static_cast<opaque_mdl_status> (mdl_status),
+ src_file, src_line);
+
+ return result;
+}
+
+static inline void inline_mysql_mdl_set_status(
+ PSI_metadata_lock *psi,
+ MDL_ticket::enum_psi_status mdl_status)
+{
+ if (psi != NULL)
+ PSI_METADATA_CALL(set_metadata_lock_status)(psi, mdl_status);
+}
+
+static inline void inline_mysql_mdl_destroy(
+ PSI_metadata_lock *psi,
+ const char *src_file, uint src_line)
+{
+ if (psi != NULL)
+ PSI_METADATA_CALL(destroy_metadata_lock)(psi);
+}
+#endif /* HAVE_PSI_METADATA_INTERFACE */
+
+/** @} (end of group Metadata_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/mysql_memory.h b/include/mysql/psi/mysql_memory.h
new file mode 100644
index 00000000000..06027a655f7
--- /dev/null
+++ b/include/mysql/psi/mysql_memory.h
@@ -0,0 +1,79 @@
+/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ 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, version 2.0, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef MYSQL_MEMORY_H
+#define MYSQL_MEMORY_H
+
+/**
+ @file mysql/psi/mysql_memory.h
+ Instrumentation helpers for memory allocation.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifdef HAVE_PSI_MEMORY_INTERFACE
+#define PSI_CALL_memory_alloc(A1,A2,A3) PSI_MEMORY_CALL(memory_alloc)(A1,A2,A3)
+#define PSI_CALL_memory_free(A1,A2,A3) PSI_MEMORY_CALL(memory_free)(A1,A2,A3)
+#define PSI_CALL_memory_realloc(A1,A2,A3,A4) PSI_MEMORY_CALL(memory_realloc)(A1,A2,A3,A4)
+#define PSI_CALL_register_memory(A1,A2,A3) PSI_MEMORY_CALL(register_memory)(A1,A2,A3)
+#else
+#define PSI_CALL_memory_alloc(A1,A2,A3) 0
+#define PSI_CALL_memory_free(A1,A2,A3) do { } while(0)
+#define PSI_CALL_memory_realloc(A1,A2,A3,A4) 0
+#define PSI_CALL_register_memory(A1,A2,A3) do { } while(0)
+#endif
+
+#ifndef PSI_MEMORY_CALL
+#define PSI_MEMORY_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+/**
+ @defgroup Memory_instrumentation Memory Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+/**
+ @def mysql_memory_register(P1, P2, P3)
+ Memory registration.
+*/
+#define mysql_memory_register(P1, P2, P3) \
+ inline_mysql_memory_register(P1, P2, P3)
+
+static inline void inline_mysql_memory_register(
+#ifdef HAVE_PSI_MEMORY_INTERFACE
+ const char *category,
+ PSI_memory_info *info,
+ int count)
+#else
+ const char *category __attribute__((unused)),
+ void *info __attribute__((unused)),
+ int count __attribute__((unused)))
+#endif
+{
+ PSI_CALL_register_memory(category, info, count);
+}
+
+/** @} (end of group Memory_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/mysql_ps.h b/include/mysql/psi/mysql_ps.h
new file mode 100644
index 00000000000..670555fc55f
--- /dev/null
+++ b/include/mysql/psi/mysql_ps.h
@@ -0,0 +1,108 @@
+/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ 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, version 2.0, 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 */
+
+#ifndef MYSQL_PS_H
+#define MYSQL_PS_H
+
+/**
+ @file mysql/psi/mysql_ps.h
+ Instrumentation helpers for prepared statements.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifndef PSI_PS_CALL
+#define PSI_PS_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifdef HAVE_PSI_PS_INTERFACE
+ #define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH) \
+ inline_mysql_create_prepared_stmt(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH)
+ #define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \
+ inline_mysql_execute_prepared_stmt(LOCKER, PREPARED_STMT)
+ #define MYSQL_DESTROY_PS(PREPARED_STMT) \
+ inline_mysql_destroy_prepared_stmt(PREPARED_STMT)
+ #define MYSQL_REPREPARE_PS(PREPARED_STMT) \
+ inline_mysql_reprepare_prepared_stmt(PREPARED_STMT)
+ #define MYSQL_SET_PS_TEXT(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH) \
+ inline_mysql_set_prepared_stmt_text(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH)
+#else
+ #define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH) \
+ NULL
+ #define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \
+ do {} while (0)
+ #define MYSQL_DESTROY_PS(PREPARED_STMT) \
+ do {} while (0)
+ #define MYSQL_REPREPARE_PS(PREPARED_STMT) \
+ do {} while (0)
+ #define MYSQL_SET_PS_TEXT(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_PS_INTERFACE
+static inline struct PSI_prepared_stmt*
+inline_mysql_create_prepared_stmt(void *identity, uint stmt_id,
+ PSI_statement_locker *locker,
+ const char *stmt_name, size_t stmt_name_length)
+{
+ if (locker == NULL)
+ return NULL;
+ return PSI_PS_CALL(create_prepared_stmt)(identity, stmt_id,
+ locker,
+ stmt_name, stmt_name_length);
+}
+
+static inline void
+inline_mysql_execute_prepared_stmt(PSI_statement_locker *locker,
+ PSI_prepared_stmt* prepared_stmt)
+{
+ if (prepared_stmt != NULL && locker != NULL)
+ PSI_PS_CALL(execute_prepared_stmt)(locker, prepared_stmt);
+}
+
+static inline void
+inline_mysql_destroy_prepared_stmt(PSI_prepared_stmt *prepared_stmt)
+{
+ if (prepared_stmt != NULL)
+ PSI_PS_CALL(destroy_prepared_stmt)(prepared_stmt);
+}
+
+static inline void
+inline_mysql_reprepare_prepared_stmt(PSI_prepared_stmt *prepared_stmt)
+{
+ if (prepared_stmt != NULL)
+ PSI_PS_CALL(reprepare_prepared_stmt)(prepared_stmt);
+}
+
+static inline void
+inline_mysql_set_prepared_stmt_text(PSI_prepared_stmt *prepared_stmt,
+ const char *text,
+ uint text_len)
+{
+ if (prepared_stmt != NULL)
+ {
+ PSI_PS_CALL(set_prepared_stmt_text)(prepared_stmt, text, text_len);
+ }
+}
+#endif
+
+#endif
diff --git a/include/mysql/psi/mysql_socket.h b/include/mysql/psi/mysql_socket.h
index f2f1d5ce519..e32474db1dd 100644
--- a/include/mysql/psi/mysql_socket.h
+++ b/include/mysql/psi/mysql_socket.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
@@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
/* For my_chsize */
#include <my_sys.h>
/* For socket api */
-#ifdef __WIN__
+#ifdef _WIN32
#include <ws2def.h>
#include <winsock2.h>
#include <MSWSock.h>
@@ -47,6 +47,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
#include "mysql/psi/psi.h"
+#ifndef PSI_SOCKET_CALL
+#define PSI_SOCKET_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup Socket_instrumentation Socket Instrumentation
@ingroup Instrumentation_interface
@@ -65,6 +69,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
do {} while (0)
#endif
+/** An instrumented socket. */
struct st_mysql_socket
{
/** The real socket descriptor. */
@@ -107,9 +112,8 @@ mysql_socket_invalid()
/**
Set socket descriptor and address.
@param socket nstrumented socket
- @param fd socket descriptor
@param addr unformatted socket address
- @param adr_len length of socket address
+ @param addr_len length of socket address
*/
static inline void
@@ -134,7 +138,6 @@ mysql_socket_set_address(
/**
Set socket descriptor and address.
@param socket instrumented socket
- @param thread instrumented owning thread
*/
static inline void
mysql_socket_set_thread_owner(
@@ -201,7 +204,6 @@ mysql_socket_setfd(MYSQL_SOCKET *mysql_socket, my_socket fd)
@param STATE locker state
@param SOCKET instrumented socket
@param OP The socket operation to be performed
- @param FLAGS per-socket operation flags.
@param COUNT bytes to be written/read
@sa MYSQL_END_SOCKET_WAIT.
*/
@@ -230,6 +232,13 @@ mysql_socket_setfd(MYSQL_SOCKET *mysql_socket, my_socket fd)
do {} while (0)
#endif
+/**
+ @def MYSQL_SOCKET_SET_STATE
+ Set the state (IDLE, ACTIVE) of an instrumented socket.
+ @param SOCKET the instrumented socket
+ @param STATE the new state
+ @sa PSI_socket_state
+*/
#ifdef HAVE_PSI_SOCKET_INTERFACE
#define MYSQL_SOCKET_SET_STATE(SOCKET, STATE) \
inline_mysql_socket_set_state(SOCKET, STATE)
@@ -325,8 +334,8 @@ inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
Return port number and IP address of the local host
@c mysql_socket_getsockname is a replacement for @c getsockname.
@param FD Instrumented socket descriptor returned by socket()
- @param A Pointer to returned address of local host in sockaddr structure
- @param L Pointer to length of sockaddr structure
+ @param AP Pointer to returned address of local host in @c sockaddr structure
+ @param LP Pointer to length of @c sockaddr structure
*/
#ifdef HAVE_PSI_SOCKET_INTERFACE
#define mysql_socket_getsockname(FD, AP, LP) \
@@ -430,7 +439,7 @@ inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
@param N Maximum bytes to receive
@param FL Control flags
@param AP Pointer to source address in sockaddr_storage structure
- @param L Size of sockaddr_storage structure
+ @param LP Size of sockaddr_storage structure
*/
#ifdef HAVE_PSI_SOCKET_INTERFACE
#define mysql_socket_recvfrom(FD, B, N, FL, AP, LP) \
@@ -477,6 +486,19 @@ inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
#endif
/**
+ @def mysql_sock_set_nonblocking
+ Set socket to non-blocking.
+ @param FD instrumented socket descriptor
+*/
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ #define mysql_sock_set_nonblocking(FD) \
+ inline_mysql_sock_set_nonblocking(__FILE__, __LINE__, FD)
+#else
+ #define mysql_sock_set_nonblocking(FD) \
+ inline_mysql_sock_set_nonblocking(FD)
+#endif
+
+/**
@def mysql_socket_listen(FD, N)
Set socket state to listen for an incoming connection.
@c mysql_socket_listen is a replacement for @c listen.
@@ -972,6 +994,78 @@ inline_mysql_socket_setsockopt
return result;
}
+/** set_socket_nonblock */
+static inline int
+set_socket_nonblock(my_socket fd)
+{
+ int ret= 0;
+#ifdef _WIN32
+ {
+ u_long nonblocking= 1;
+ ret= ioctlsocket(fd, FIONBIO, &nonblocking);
+ }
+#else
+ {
+ int fd_flags;
+ fd_flags= fcntl(fd, F_GETFL, 0);
+ if (fd_flags < 0)
+ return errno;
+#if defined(O_NONBLOCK)
+ fd_flags |= O_NONBLOCK;
+#elif defined(O_NDELAY)
+ fd_flags |= O_NDELAY;
+#elif defined(O_FNDELAY)
+ fd_flags |= O_FNDELAY;
+#else
+#error "No definition of non-blocking flag found."
+#endif /* O_NONBLOCK */
+ if (fcntl(fd, F_SETFL, fd_flags) == -1)
+ ret= errno;
+ }
+#endif /* _WIN32 */
+ return ret;
+}
+
+/** mysql_socket_set_nonblocking */
+
+static inline int
+inline_mysql_sock_set_nonblocking
+(
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET mysql_socket
+)
+{
+ int result= 0;
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+ if (mysql_socket.m_psi)
+ {
+ /* Instrumentation start */
+ PSI_socket_locker *locker;
+ PSI_socket_locker_state state;
+ locker= PSI_SOCKET_CALL(start_socket_wait)
+ (&state, mysql_socket.m_psi, PSI_SOCKET_OPT,
+ (size_t)0, src_file, src_line);
+
+ /* Instrumented code */
+ result= set_socket_nonblock(mysql_socket.fd);
+
+ /* Instrumentation end */
+ if (locker != NULL)
+ PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
+
+ return result;
+ }
+#endif
+
+ /* Non instrumented code */
+ result= set_socket_nonblock(mysql_socket.fd);
+
+ return result;
+}
+
/** mysql_socket_listen */
static inline int
@@ -1024,8 +1118,7 @@ inline_mysql_socket_accept
int flags __attribute__ ((unused));
#endif
- MYSQL_SOCKET socket_accept= MYSQL_INVALID_SOCKET;
- socklen_t addr_length= (addr_len != NULL) ? *addr_len : 0;
+ MYSQL_SOCKET socket_accept;
#ifdef HAVE_PSI_SOCKET_INTERFACE
if (socket_listen.m_psi != NULL)
@@ -1038,10 +1131,9 @@ inline_mysql_socket_accept
/* Instrumented code */
#ifdef HAVE_ACCEPT4
- socket_accept.fd= accept4(socket_listen.fd, addr, &addr_length,
- SOCK_CLOEXEC);
+ socket_accept.fd= accept4(socket_listen.fd, addr, addr_len, SOCK_CLOEXEC);
#else
- socket_accept.fd= accept(socket_listen.fd, addr, &addr_length);
+ socket_accept.fd= accept(socket_listen.fd, addr, addr_len);
#ifdef FD_CLOEXEC
if (socket_accept.fd != INVALID_SOCKET)
{
@@ -1064,10 +1156,9 @@ inline_mysql_socket_accept
{
/* Non instrumented code */
#ifdef HAVE_ACCEPT4
- socket_accept.fd= accept4(socket_listen.fd, addr, &addr_length,
- SOCK_CLOEXEC);
+ socket_accept.fd= accept4(socket_listen.fd, addr, addr_len, SOCK_CLOEXEC);
#else
- socket_accept.fd= accept(socket_listen.fd, addr, &addr_length);
+ socket_accept.fd= accept(socket_listen.fd, addr, addr_len);
#ifdef FD_CLOEXEC
if (socket_accept.fd != INVALID_SOCKET)
{
@@ -1087,7 +1178,7 @@ inline_mysql_socket_accept
{
/* Initialize the instrument with the new socket descriptor and address */
socket_accept.m_psi= PSI_SOCKET_CALL(init_socket)
- (key, (const my_socket*)&socket_accept.fd, addr, addr_length);
+ (key, (const my_socket*)&socket_accept.fd, addr, *addr_len);
}
#endif
@@ -1147,7 +1238,7 @@ inline_mysql_socket_shutdown
{
int result;
-#ifdef __WIN__
+#ifdef _WIN32
static LPFN_DISCONNECTEX DisconnectEx = NULL;
if (DisconnectEx == NULL)
{
@@ -1170,7 +1261,7 @@ inline_mysql_socket_shutdown
(&state, mysql_socket.m_psi, PSI_SOCKET_SHUTDOWN, (size_t)0, src_file, src_line);
/* Instrumented code */
-#ifdef __WIN__
+#ifdef _WIN32
if (DisconnectEx)
result= (DisconnectEx(mysql_socket.fd, (LPOVERLAPPED) NULL,
(DWORD) 0, (DWORD) 0) == TRUE) ? 0 : -1;
@@ -1187,7 +1278,7 @@ inline_mysql_socket_shutdown
#endif
/* Non instrumented code */
-#ifdef __WIN__
+#ifdef _WIN32
if (DisconnectEx)
result= (DisconnectEx(mysql_socket.fd, (LPOVERLAPPED) NULL,
(DWORD) 0, (DWORD) 0) == TRUE) ? 0 : -1;
diff --git a/include/mysql/psi/mysql_sp.h b/include/mysql/psi/mysql_sp.h
new file mode 100644
index 00000000000..1fec59cec91
--- /dev/null
+++ b/include/mysql/psi/mysql_sp.h
@@ -0,0 +1,104 @@
+/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ 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, version 2.0, 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 */
+
+#ifndef MYSQL_SP_H
+#define MYSQL_SP_H
+
+/**
+ @file mysql/psi/mysql_sp.h
+ Instrumentation helpers for stored programs.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifndef PSI_SP_CALL
+#define PSI_SP_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifdef HAVE_PSI_SP_INTERFACE
+ #define MYSQL_START_SP(STATE, SP_SHARE) \
+ inline_mysql_start_sp(STATE, SP_SHARE)
+#else
+ #define MYSQL_START_SP(STATE, SP_SHARE) \
+ NULL
+#endif
+
+
+#ifdef HAVE_PSI_SP_INTERFACE
+ #define MYSQL_END_SP(LOCKER) \
+ inline_mysql_end_sp(LOCKER)
+#else
+ #define MYSQL_END_SP(LOCKER) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_SP_INTERFACE
+ #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
+ inline_mysql_drop_sp(OT, SN, SNL, ON, ONL)
+#else
+ #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_SP_INTERFACE
+ #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
+ inline_mysql_get_sp_share(OT, SN, SNL, ON, ONL)
+#else
+ #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
+ NULL
+#endif
+
+#ifdef HAVE_PSI_SP_INTERFACE
+static inline struct PSI_sp_locker*
+inline_mysql_start_sp(PSI_sp_locker_state *state, PSI_sp_share *sp_share)
+{
+ return PSI_SP_CALL(start_sp)(state, sp_share);
+}
+
+static inline void inline_mysql_end_sp(PSI_sp_locker *locker)
+{
+ if (likely(locker != NULL))
+ PSI_SP_CALL(end_sp)(locker);
+}
+
+static inline void
+inline_mysql_drop_sp(uint sp_type,
+ const char* schema_name, uint shcema_name_length,
+ const char* object_name, uint object_name_length)
+{
+ PSI_SP_CALL(drop_sp)(sp_type,
+ schema_name, shcema_name_length,
+ object_name, object_name_length);
+}
+
+static inline PSI_sp_share*
+inline_mysql_get_sp_share(uint sp_type,
+ const char* schema_name, uint shcema_name_length,
+ const char* object_name, uint object_name_length)
+{
+ return PSI_SP_CALL(get_sp_share)(sp_type,
+ schema_name, shcema_name_length,
+ object_name, object_name_length);
+}
+#endif
+
+#endif
diff --git a/include/mysql/psi/mysql_stage.h b/include/mysql/psi/mysql_stage.h
index 1dbaed6c682..cb579ea4e8c 100644
--- a/include/mysql/psi/mysql_stage.h
+++ b/include/mysql/psi/mysql_stage.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -30,6 +30,10 @@
#include "mysql/psi/psi.h"
+#ifndef PSI_STAGE_CALL
+#define PSI_STAGE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup Stage_instrumentation Stage Instrumentation
@ingroup Instrumentation_interface
@@ -48,12 +52,48 @@
do {} while (0)
#endif
+/**
+ @def MYSQL_SET_STAGE
+ Set the current stage.
+ Use this API when the file and line
+ is passed from the caller.
+ @param K the stage key
+ @param F the source file name
+ @param L the source file line
+ @return the current stage progress
+*/
#ifdef HAVE_PSI_STAGE_INTERFACE
#define MYSQL_SET_STAGE(K, F, L) \
inline_mysql_set_stage(K, F, L)
#else
#define MYSQL_SET_STAGE(K, F, L) \
- do {} while (0)
+ NULL
+#endif
+
+/**
+ @def mysql_set_stage
+ Set the current stage.
+ @param K the stage key
+ @return the current stage progress
+*/
+#ifdef HAVE_PSI_STAGE_INTERFACE
+ #define mysql_set_stage(K) \
+ inline_mysql_set_stage(K, __FILE__, __LINE__)
+#else
+ #define mysql_set_stage(K) \
+ NULL
+#endif
+
+/**
+ @def mysql_end_stage
+ End the last stage
+*/
+#ifdef HAVE_PSI_STAGE_INTERFACE
+ #define mysql_end_stage() \
+ inline_mysql_end_stage()
+#else
+ #define mysql_end_stage() \
+ do {} while (0)
#endif
#ifdef HAVE_PSI_STAGE_INTERFACE
@@ -65,11 +105,97 @@ static inline void inline_mysql_stage_register(
#endif
#ifdef HAVE_PSI_STAGE_INTERFACE
-static inline void
+static inline PSI_stage_progress*
inline_mysql_set_stage(PSI_stage_key key,
const char *src_file, int src_line)
{
- PSI_STAGE_CALL(start_stage)(key, src_file, src_line);
+ return PSI_STAGE_CALL(start_stage)(key, src_file, src_line);
+}
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+static inline void
+inline_mysql_end_stage()
+{
+ PSI_STAGE_CALL(end_stage)();
+}
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+#define mysql_stage_set_work_completed(P1, P2) \
+ inline_mysql_stage_set_work_completed(P1, P2)
+
+#define mysql_stage_get_work_completed(P1) \
+ inline_mysql_stage_get_work_completed(P1)
+#else
+#define mysql_stage_set_work_completed(P1, P2) \
+ do {} while (0)
+
+#define mysql_stage_get_work_completed(P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+#define mysql_stage_inc_work_completed(P1, P2) \
+ inline_mysql_stage_inc_work_completed(P1, P2)
+#else
+#define mysql_stage_inc_work_completed(P1, P2) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+#define mysql_stage_set_work_estimated(P1, P2) \
+ inline_mysql_stage_set_work_estimated(P1, P2)
+
+#define mysql_stage_get_work_estimated(P1) \
+ inline_mysql_stage_get_work_estimated(P1)
+#else
+#define mysql_stage_set_work_estimated(P1, P2) \
+ do {} while (0)
+
+#define mysql_stage_get_work_estimated(P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+static inline void
+inline_mysql_stage_set_work_completed(PSI_stage_progress *progress,
+ ulonglong val)
+{
+ if (progress != NULL)
+ progress->m_work_completed= val;
+}
+
+static inline ulonglong
+inline_mysql_stage_get_work_completed(PSI_stage_progress *progress)
+{
+ return progress->m_work_completed;
+}
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+static inline void
+inline_mysql_stage_inc_work_completed(PSI_stage_progress *progress,
+ ulonglong val)
+{
+ if (progress != NULL)
+ progress->m_work_completed+= val;
+}
+#endif
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+static inline void
+inline_mysql_stage_set_work_estimated(PSI_stage_progress *progress,
+ ulonglong val)
+{
+ if (progress != NULL)
+ progress->m_work_estimated= val;
+}
+
+static inline ulonglong
+inline_mysql_stage_get_work_estimated(PSI_stage_progress *progress)
+{
+ return progress->m_work_estimated;
}
#endif
diff --git a/include/mysql/psi/mysql_statement.h b/include/mysql/psi/mysql_statement.h
index 6d38131ea99..78a4de73869 100644
--- a/include/mysql/psi/mysql_statement.h
+++ b/include/mysql/psi/mysql_statement.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
- Copyright (c) 2017, MariaDB Corporation.
+/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -31,6 +31,17 @@
#include "mysql/psi/psi.h"
+class Diagnostics_area;
+typedef const struct charset_info_st CHARSET_INFO;
+
+#ifndef PSI_STATEMENT_CALL
+#define PSI_STATEMENT_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_DIGEST_CALL
+#define PSI_DIGEST_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup Statement_instrumentation Statement Instrumentation
@ingroup Instrumentation_interface
@@ -66,10 +77,10 @@
#endif
#ifdef HAVE_PSI_STATEMENT_INTERFACE
- #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS) \
- inline_mysql_start_statement(STATE, K, DB, DB_LEN, CS, __FILE__, __LINE__)
+ #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS, SPS) \
+ inline_mysql_start_statement(STATE, K, DB, DB_LEN, CS, SPS, __FILE__, __LINE__)
#else
- #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS) \
+ #define MYSQL_START_STATEMENT(STATE, K, DB, DB_LEN, CS, SPS) \
NULL
#endif
@@ -153,11 +164,13 @@ static inline struct PSI_statement_locker *
inline_mysql_start_statement(PSI_statement_locker_state *state,
PSI_statement_key key,
const char *db, size_t db_len,
- const CHARSET_INFO *charset,
+ CHARSET_INFO *charset,
+ PSI_sp_share *sp_share,
const char *src_file, uint src_line)
{
PSI_statement_locker *locker;
- locker= PSI_STATEMENT_CALL(get_thread_statement_locker)(state, key, charset);
+ locker= PSI_STATEMENT_CALL(get_thread_statement_locker)(state, key, charset,
+ sp_share);
if (psi_likely(locker != NULL))
PSI_STATEMENT_CALL(start_statement)(locker, db, (uint)db_len, src_file, src_line);
return locker;
diff --git a/include/mysql/psi/mysql_table.h b/include/mysql/psi/mysql_table.h
index c1244e38866..03b6e998562 100644
--- a/include/mysql/psi/mysql_table.h
+++ b/include/mysql/psi/mysql_table.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
- Copyright (c) 2017, MariaDB Corporation.
+/* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -31,6 +31,10 @@
#include "mysql/psi/psi.h"
+#ifndef PSI_TABLE_CALL
+#define PSI_TABLE_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
/**
@defgroup Table_instrumentation Table Instrumentation
@ingroup Instrumentation_interface
@@ -39,7 +43,6 @@
#ifdef HAVE_PSI_TABLE_INTERFACE
#define MYSQL_UNBIND_TABLE(handler) (handler)->unbind_psi()
-#define MYSQL_REBIND_TABLE(handler) (handler)->rebind_psi()
#define PSI_CALL_unbind_table PSI_TABLE_CALL(unbind_table)
#define PSI_CALL_rebind_table PSI_TABLE_CALL(rebind_table)
@@ -50,11 +53,10 @@
#define PSI_CALL_drop_table_share PSI_TABLE_CALL(drop_table_share)
#else
#define MYSQL_UNBIND_TABLE(handler) do { } while(0)
-#define MYSQL_REBIND_TABLE(handler) do { } while(0)
#define PSI_CALL_unbind_table(A1) do { } while(0)
#define PSI_CALL_rebind_table(A1,A2,A3) NULL
-#define PSI_CALL_close_table(A1) do { } while(0)
+#define PSI_CALL_close_table(A1,A2) do { } while(0)
#define PSI_CALL_open_table(A1,A2) NULL
#define PSI_CALL_get_table_share(A1,A2) NULL
#define PSI_CALL_release_table_share(A1) do { } while(0)
@@ -82,72 +84,6 @@
#endif
/**
- @def MYSQL_TABLE_IO_WAIT
- Instrumentation helper for table io_waits.
- This instrumentation marks the start of a wait event.
- @param PSI the instrumented table
- @param OP the table operation to be performed
- @param INDEX the table index used if any, or MAY_KEY.
- @param FLAGS per table operation flags.
- @sa MYSQL_END_TABLE_WAIT.
-*/
-#ifdef HAVE_PSI_TABLE_INTERFACE
- #define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
- { \
- if (psi_likely(PSI != NULL)) \
- { \
- PSI_table_locker *locker; \
- PSI_table_locker_state state; \
- locker= PSI_TABLE_CALL(start_table_io_wait) \
- (& state, PSI, OP, INDEX, __FILE__, __LINE__); \
- PAYLOAD \
- if (locker != NULL) \
- PSI_TABLE_CALL(end_table_io_wait)(locker); \
- } \
- else \
- { \
- PAYLOAD \
- } \
- }
-#else
- #define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
- PAYLOAD
-#endif
-
-/**
- @def MYSQL_TABLE_LOCK_WAIT
- Instrumentation helper for table io_waits.
- This instrumentation marks the start of a wait event.
- @param PSI the instrumented table
- @param OP the table operation to be performed
- @param INDEX the table index used if any, or MAY_KEY.
- @param FLAGS per table operation flags.
- @sa MYSQL_END_TABLE_WAIT.
-*/
-#ifdef HAVE_PSI_TABLE_INTERFACE
- #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
- { \
- if (psi_likely(PSI != NULL)) \
- { \
- PSI_table_locker *locker; \
- PSI_table_locker_state state; \
- locker= PSI_TABLE_CALL(start_table_lock_wait) \
- (& state, PSI, OP, FLAGS, __FILE__, __LINE__); \
- PAYLOAD \
- if (locker != NULL) \
- PSI_TABLE_CALL(end_table_lock_wait)(locker); \
- } \
- else \
- { \
- PAYLOAD \
- } \
- }
-#else
- #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
- PAYLOAD
-#endif
-
-/**
@def MYSQL_START_TABLE_LOCK_WAIT
Instrumentation helper for table lock waits.
This instrumentation marks the start of a wait event.
@@ -183,6 +119,14 @@
#endif
#ifdef HAVE_PSI_TABLE_INTERFACE
+ #define MYSQL_UNLOCK_TABLE(T) \
+ inline_mysql_unlock_table(T)
+#else
+ #define MYSQL_UNLOCK_TABLE(T) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TABLE_INTERFACE
/**
Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
@sa MYSQL_END_TABLE_LOCK_WAIT.
@@ -213,6 +157,13 @@ inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
if (psi_likely(locker != NULL))
PSI_TABLE_CALL(end_table_lock_wait)(locker);
}
+
+static inline void
+inline_mysql_unlock_table(struct PSI_table *table)
+{
+ if (table != NULL)
+ PSI_TABLE_CALL(unlock_table)(table);
+}
#endif
/** @} (end of group Table_instrumentation) */
diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h
index eab87402140..9ff3dd382a8 100644
--- a/include/mysql/psi/mysql_thread.h
+++ b/include/mysql/psi/mysql_thread.h
@@ -1,4 +1,5 @@
-/* Copyright (c) 2008, 2013, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -62,6 +63,27 @@
*/
#include "mysql/psi/psi.h"
+#ifdef MYSQL_SERVER
+#ifndef MYSQL_DYNAMIC_PLUGIN
+#include "pfs_thread_provider.h"
+#endif
+#endif
+
+#ifndef PSI_MUTEX_CALL
+#define PSI_MUTEX_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_RWLOCK_CALL
+#define PSI_RWLOCK_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_COND_CALL
+#define PSI_COND_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+#ifndef PSI_THREAD_CALL
+#define PSI_THREAD_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
/**
@defgroup Thread_instrumentation Thread Instrumentation
@@ -75,26 +97,32 @@
#define PSI_CALL_new_thread PSI_THREAD_CALL(new_thread)
#define PSI_CALL_register_thread PSI_THREAD_CALL(register_thread)
#define PSI_CALL_set_thread PSI_THREAD_CALL(set_thread)
+#define PSI_CALL_set_thread_THD PSI_THREAD_CALL(set_thread_THD)
#define PSI_CALL_set_thread_connect_attrs PSI_THREAD_CALL(set_thread_connect_attrs)
#define PSI_CALL_set_thread_db PSI_THREAD_CALL(set_thread_db)
#define PSI_CALL_set_thread_id PSI_THREAD_CALL(set_thread_id)
+#define PSI_CALL_set_thread_os_id PSI_THREAD_CALL(set_thread_os_id)
#define PSI_CALL_set_thread_info PSI_THREAD_CALL(set_thread_info)
#define PSI_CALL_set_thread_start_time PSI_THREAD_CALL(set_thread_start_time)
-#define PSI_CALL_set_thread_user_host PSI_THREAD_CALL(set_thread_user_host)
+#define PSI_CALL_set_thread_account PSI_THREAD_CALL(set_thread_account)
#define PSI_CALL_spawn_thread PSI_THREAD_CALL(spawn_thread)
+#define PSI_CALL_set_connection_type PSI_THREAD_CALL(set_connection_type)
#else
#define PSI_CALL_delete_current_thread() do { } while(0)
#define PSI_CALL_get_thread() NULL
#define PSI_CALL_new_thread(A1,A2,A3) NULL
#define PSI_CALL_register_thread(A1,A2,A3) do { } while(0)
#define PSI_CALL_set_thread(A1) do { } while(0)
+#define PSI_CALL_set_thread_THD(A1,A2) do { } while(0)
#define PSI_CALL_set_thread_connect_attrs(A1,A2,A3) 0
#define PSI_CALL_set_thread_db(A1,A2) do { } while(0)
#define PSI_CALL_set_thread_id(A1,A2) do { } while(0)
+#define PSI_CALL_set_thread_os_id(A1) do { } while(0)
#define PSI_CALL_set_thread_info(A1, A2) do { } while(0)
#define PSI_CALL_set_thread_start_time(A1) do { } while(0)
-#define PSI_CALL_set_thread_user_host(A1, A2, A3, A4) do { } while(0)
+#define PSI_CALL_set_thread_account(A1, A2, A3, A4) do { } while(0)
#define PSI_CALL_spawn_thread(A1, A2, A3, A4, A5) 0
+#define PSI_CALL_set_connection_type(A) do { } while(0)
#endif
@@ -235,6 +263,7 @@ typedef struct st_mysql_cond mysql_cond_t;
*/
#ifndef DISABLE_MYSQL_THREAD_H
+#define mysql_mutex_is_owner(M) safe_mutex_is_owner(&(M)->m_mutex)
/**
@def mysql_mutex_assert_owner(M)
Wrapper, to use safe_mutex_assert_owner with instrumented mutexes.
@@ -256,11 +285,19 @@ typedef struct st_mysql_cond mysql_cond_t;
#define mysql_mutex_setflags(M, F) \
safe_mutex_setflags(&(M)->m_mutex, (F))
-/** Wrappers for instrumented prlock objects. */
-
+/**
+ @def mysql_prlock_assert_write_owner(M)
+ Drop-in replacement
+ for @c rw_pr_lock_assert_write_owner.
+*/
#define mysql_prlock_assert_write_owner(M) \
rw_pr_lock_assert_write_owner(&(M)->m_prlock)
+/**
+ @def mysql_prlock_assert_not_write_owner(M)
+ Drop-in replacement
+ for @c rw_pr_lock_assert_not_write_owner.
+*/
#define mysql_prlock_assert_not_write_owner(M) \
rw_pr_lock_assert_not_write_owner(&(M)->m_prlock)
@@ -538,7 +575,7 @@ typedef struct st_mysql_cond mysql_cond_t;
Instrumented cond_wait.
@c mysql_cond_wait is a drop-in replacement for @c pthread_cond_wait.
*/
-#ifdef HAVE_PSI_COND_INTERFACE
+#if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
#define mysql_cond_wait(C, M) \
inline_mysql_cond_wait(C, M, __FILE__, __LINE__)
#else
@@ -552,7 +589,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_cond_timedwait is a drop-in replacement
for @c pthread_cond_timedwait.
*/
-#ifdef HAVE_PSI_COND_INTERFACE
+#if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
#define mysql_cond_timedwait(C, M, W) \
inline_mysql_cond_timedwait(C, M, W, __FILE__, __LINE__)
#else
@@ -618,6 +655,17 @@ typedef struct st_mysql_cond mysql_cond_t;
#define mysql_thread_set_psi_id(I) do {} while (0)
#endif
+/**
+ @def mysql_thread_set_psi_THD(T)
+ Set the thread sql session for the instrumentation.
+ @param I The thread identifier
+*/
+#ifdef HAVE_PSI_THREAD_INTERFACE
+ #define mysql_thread_set_psi_THD(T) inline_mysql_thread_set_psi_THD(T)
+#else
+ #define mysql_thread_set_psi_THD(T) do {} while (0)
+#endif
+
static inline void inline_mysql_mutex_register(
#ifdef HAVE_PSI_MUTEX_INTERFACE
const char *category,
@@ -1154,7 +1202,7 @@ static inline int inline_mysql_cond_destroy(
static inline int inline_mysql_cond_wait(
mysql_cond_t *that,
mysql_mutex_t *mutex
-#ifdef HAVE_PSI_COND_INTERFACE
+#if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
, const char *src_file, uint src_line
#endif
)
@@ -1191,7 +1239,7 @@ static inline int inline_mysql_cond_timedwait(
mysql_cond_t *that,
mysql_mutex_t *mutex,
const struct timespec *abstime
-#ifdef HAVE_PSI_COND_INTERFACE
+#if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
, const char *src_file, uint src_line
#endif
)
@@ -1281,6 +1329,23 @@ static inline void inline_mysql_thread_set_psi_id(my_thread_id id)
struct PSI_thread *psi= PSI_THREAD_CALL(get_thread)();
PSI_THREAD_CALL(set_thread_id)(psi, id);
}
+
+#ifdef __cplusplus
+class THD;
+static inline void inline_mysql_thread_set_psi_THD(THD *thd)
+{
+ struct PSI_thread *psi= PSI_THREAD_CALL(get_thread)();
+ PSI_THREAD_CALL(set_thread_THD)(psi, thd);
+}
+#endif /* __cplusplus */
+
+static inline void mysql_thread_set_peer_port(uint port __attribute__ ((unused))) {
+#ifdef HAVE_PSI_THREAD_INTERFACE
+ struct PSI_thread *psi = PSI_THREAD_CALL(get_thread)();
+ PSI_THREAD_CALL(set_thread_peer_port)(psi, port);
+#endif
+}
+
#endif
#endif /* DISABLE_MYSQL_THREAD_H */
diff --git a/include/mysql/psi/mysql_transaction.h b/include/mysql/psi/mysql_transaction.h
new file mode 100644
index 00000000000..02f08bfab44
--- /dev/null
+++ b/include/mysql/psi/mysql_transaction.h
@@ -0,0 +1,220 @@
+/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ 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, version 2.0, 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 */
+
+#ifndef MYSQL_TRANSACTION_H
+#define MYSQL_TRANSACTION_H
+
+/**
+ @file mysql/psi/mysql_transaction.h
+ Instrumentation helpers for transactions.
+*/
+
+#include "mysql/psi/psi.h"
+
+#ifndef PSI_TRANSACTION_CALL
+#define PSI_TRANSACTION_CALL(M) PSI_DYNAMIC_CALL(M)
+#endif
+
+/**
+ @defgroup Transaction_instrumentation Transaction Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_START_TRANSACTION(STATE, XID, TRXID, ISO, RO, AC) \
+ inline_mysql_start_transaction(STATE, XID, TRXID, ISO, RO, AC, __FILE__, __LINE__)
+#else
+ #define MYSQL_START_TRANSACTION(STATE, XID, TRXID, ISO, RO, AC) \
+ 0
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_SET_TRANSACTION_GTID(LOCKER, P1, P2) \
+ inline_mysql_set_transaction_gtid(LOCKER, P1, P2)
+#else
+ #define MYSQL_SET_TRANSACTION_GTID(LOCKER, P1, P2) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_SET_TRANSACTION_XID(LOCKER, P1, P2) \
+ inline_mysql_set_transaction_xid(LOCKER, P1, P2)
+#else
+ #define MYSQL_SET_TRANSACTION_XID(LOCKER, P1, P2) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_SET_TRANSACTION_XA_STATE(LOCKER, P1) \
+ inline_mysql_set_transaction_xa_state(LOCKER, P1)
+#else
+ #define MYSQL_SET_TRANSACTION_XA_STATE(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_SET_TRANSACTION_TRXID(LOCKER, P1) \
+ inline_mysql_set_transaction_trxid(LOCKER, P1)
+#else
+ #define MYSQL_SET_TRANSACTION_TRXID(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_INC_TRANSACTION_SAVEPOINTS(LOCKER, P1) \
+ inline_mysql_inc_transaction_savepoints(LOCKER, P1)
+#else
+ #define MYSQL_INC_TRANSACTION_SAVEPOINTS(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_INC_TRANSACTION_ROLLBACK_TO_SAVEPOINT(LOCKER, P1) \
+ inline_mysql_inc_transaction_rollback_to_savepoint(LOCKER, P1)
+#else
+ #define MYSQL_INC_TRANSACTION_ROLLBACK_TO_SAVEPOINT(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_INC_TRANSACTION_RELEASE_SAVEPOINT(LOCKER, P1) \
+ inline_mysql_inc_transaction_release_savepoint(LOCKER, P1)
+#else
+ #define MYSQL_INC_TRANSACTION_RELEASE_SAVEPOINT(LOCKER, P1) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_ROLLBACK_TRANSACTION(LOCKER) \
+ inline_mysql_rollback_transaction(LOCKER)
+#else
+ #define MYSQL_ROLLBACK_TRANSACTION(LOCKER) \
+ do { } while(0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+ #define MYSQL_COMMIT_TRANSACTION(LOCKER) \
+ inline_mysql_commit_transaction(LOCKER)
+#else
+ #define MYSQL_COMMIT_TRANSACTION(LOCKER) \
+ do { } while(0)
+#endif
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+static inline struct PSI_transaction_locker *
+inline_mysql_start_transaction(PSI_transaction_locker_state *state,
+ const void *xid,
+ ulonglong trxid,
+ int isolation_level,
+ my_bool read_only,
+ my_bool autocommit,
+ const char *src_file, int src_line)
+{
+ PSI_transaction_locker *locker;
+ locker= PSI_TRANSACTION_CALL(get_thread_transaction_locker)(state,
+ xid, trxid,
+ isolation_level,
+ read_only,
+ autocommit);
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(start_transaction)(locker, src_file, src_line);
+ return locker;
+}
+
+static inline void
+inline_mysql_set_transaction_gtid(PSI_transaction_locker *locker,
+ const void *sid,
+ const void *gtid_spec)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(set_transaction_gtid)(locker, sid, gtid_spec);
+}
+
+static inline void
+inline_mysql_set_transaction_xid(PSI_transaction_locker *locker,
+ const void *xid,
+ int xa_state)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(set_transaction_xid)(locker, xid, xa_state);
+}
+
+static inline void
+inline_mysql_set_transaction_xa_state(PSI_transaction_locker *locker,
+ int xa_state)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(set_transaction_xa_state)(locker, xa_state);
+}
+
+static inline void
+inline_mysql_set_transaction_trxid(PSI_transaction_locker *locker,
+ const ulonglong *trxid)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(set_transaction_trxid)(locker, trxid);
+}
+
+static inline void
+inline_mysql_inc_transaction_savepoints(PSI_transaction_locker *locker,
+ ulong count)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(inc_transaction_savepoints)(locker, count);
+}
+
+static inline void
+inline_mysql_inc_transaction_rollback_to_savepoint(PSI_transaction_locker *locker,
+ ulong count)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(inc_transaction_rollback_to_savepoint)(locker, count);
+}
+
+static inline void
+inline_mysql_inc_transaction_release_savepoint(PSI_transaction_locker *locker,
+ ulong count)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(inc_transaction_release_savepoint)(locker, count);
+}
+
+static inline void
+inline_mysql_rollback_transaction(struct PSI_transaction_locker *locker)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(end_transaction)(locker, false);
+}
+
+static inline void
+inline_mysql_commit_transaction(struct PSI_transaction_locker *locker)
+{
+ if (likely(locker != NULL))
+ PSI_TRANSACTION_CALL(end_transaction)(locker, true);
+}
+#endif
+
+/** @} (end of group Transaction_instrumentation) */
+
+#endif
+
diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h
index e921233649e..4c3e2c6a9c4 100644
--- a/include/mysql/psi/psi.h
+++ b/include/mysql/psi/psi.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -23,19 +23,6 @@
#ifndef MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
#define MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
-#ifdef EMBEDDED_LIBRARY
-#define DISABLE_PSI_MUTEX
-#define DISABLE_PSI_RWLOCK
-#define DISABLE_PSI_COND
-#define DISABLE_PSI_FILE
-#define DISABLE_PSI_TABLE
-#define DISABLE_PSI_SOCKET
-#define DISABLE_PSI_STAGE
-#define DISABLE_PSI_STATEMENT
-#define DISABLE_PSI_IDLE
-#define DISABLE_PSI_STATEMENT_DIGEST
-#endif /* EMBEDDED_LIBRARY */
-
#ifndef MY_GLOBAL_INCLUDED
/*
Make sure a .c or .cc file contains an include to my_global.h first.
@@ -61,13 +48,58 @@
#define psi_unlikely(A) likely(A)
#endif
+#include "psi_base.h"
+#include "psi_memory.h"
+
+#ifdef _WIN32
+typedef struct thread_attr pthread_attr_t;
+typedef DWORD pthread_t;
+typedef DWORD pthread_key_t;
+#endif
+
+/*
+ MAINTAINER:
+ The following pattern:
+ typedef struct XYZ XYZ;
+ is not needed in C++, but required for C.
+*/
C_MODE_START
+/** @sa MDL_key. */
+struct MDL_key;
+typedef struct MDL_key MDL_key;
+
+/** @sa enum_mdl_type. */
+typedef int opaque_mdl_type;
+
+/** @sa enum_mdl_duration. */
+typedef int opaque_mdl_duration;
+
+/** @sa MDL_wait::enum_wait_status. */
+typedef int opaque_mdl_status;
+
+/** @sa enum_vio_type. */
+typedef int opaque_vio_type;
+
struct TABLE_SHARE;
struct sql_digest_storage;
+#ifdef __cplusplus
+ class THD;
+#else
+ /*
+ Phony declaration when compiling C code.
+ This is ok, because the C code will never have a THD anyway.
+ */
+ struct opaque_THD
+ {
+ int dummy;
+ };
+ typedef struct opaque_THD THD;
+#endif
+
/**
@file mysql/psi/psi.h
Performance schema instrumentation interface.
@@ -134,6 +166,13 @@ struct PSI_socket;
typedef struct PSI_socket PSI_socket;
/**
+ Interface for an instrumented prepared statement.
+ This is an opaque structure.
+*/
+struct PSI_prepared_stmt;
+typedef struct PSI_prepared_stmt PSI_prepared_stmt;
+
+/**
Interface for an instrumented table operation.
This is an opaque structure.
*/
@@ -148,6 +187,13 @@ struct PSI_statement_locker;
typedef struct PSI_statement_locker PSI_statement_locker;
/**
+ Interface for an instrumented transaction.
+ This is an opaque structure.
+*/
+struct PSI_transaction_locker;
+typedef struct PSI_transaction_locker PSI_transaction_locker;
+
+/**
Interface for an instrumented idle operation.
This is an opaque structure.
*/
@@ -161,6 +207,90 @@ typedef struct PSI_idle_locker PSI_idle_locker;
struct PSI_digest_locker;
typedef struct PSI_digest_locker PSI_digest_locker;
+/**
+ Interface for an instrumented stored procedure share.
+ This is an opaque structure.
+*/
+struct PSI_sp_share;
+typedef struct PSI_sp_share PSI_sp_share;
+
+/**
+ Interface for an instrumented stored program.
+ This is an opaque structure.
+*/
+struct PSI_sp_locker;
+typedef struct PSI_sp_locker PSI_sp_locker;
+
+/**
+ Interface for an instrumented metadata lock.
+ This is an opaque structure.
+*/
+struct PSI_metadata_lock;
+typedef struct PSI_metadata_lock PSI_metadata_lock;
+
+/**
+ Interface for an instrumented stage progress.
+ This is a public structure, for efficiency.
+*/
+struct PSI_stage_progress
+{
+ ulonglong m_work_completed;
+ ulonglong m_work_estimated;
+};
+typedef struct PSI_stage_progress PSI_stage_progress;
+
+/** IO operation performed on an instrumented table. */
+enum PSI_table_io_operation
+{
+ /** Row fetch. */
+ PSI_TABLE_FETCH_ROW= 0,
+ /** Row write. */
+ PSI_TABLE_WRITE_ROW= 1,
+ /** Row update. */
+ PSI_TABLE_UPDATE_ROW= 2,
+ /** Row delete. */
+ PSI_TABLE_DELETE_ROW= 3
+};
+typedef enum PSI_table_io_operation PSI_table_io_operation;
+
+/**
+ State data storage for @c start_table_io_wait_v1_t,
+ @c start_table_lock_wait_v1_t.
+ This structure provide temporary storage to a table locker.
+ The content of this structure is considered opaque,
+ the fields are only hints of what an implementation
+ of the psi interface can use.
+ This memory is provided by the instrumented code for performance reasons.
+ @sa start_table_io_wait_v1_t
+ @sa start_table_lock_wait_v1_t
+*/
+struct PSI_table_locker_state
+{
+ /** Internal state. */
+ uint m_flags;
+ /** Current io operation. */
+ enum PSI_table_io_operation m_io_operation;
+ /** Current table handle. */
+ struct PSI_table *m_table;
+ /** Current table share. */
+ struct PSI_table_share *m_table_share;
+ /** Current thread. */
+ struct PSI_thread *m_thread;
+ /** Timer start. */
+ ulonglong m_timer_start;
+ /** Timer function. */
+ ulonglong (*m_timer)(void);
+ /** Internal data. */
+ void *m_wait;
+ /**
+ Implementation specific.
+ For table io, the table io index.
+ For table lock, the lock type.
+ */
+ uint m_index;
+};
+typedef struct PSI_table_locker_state PSI_table_locker_state;
+
/** Entry point for the performance schema interface. */
struct PSI_bootstrap
{
@@ -183,14 +313,84 @@ typedef struct PSI_bootstrap PSI_bootstrap;
#ifdef HAVE_PSI_INTERFACE
+#ifdef DISABLE_ALL_PSI
+
+#ifndef DISABLE_PSI_THREAD
+#define DISABLE_PSI_THREAD
+#endif
+
+#ifndef DISABLE_PSI_MUTEX
+#define DISABLE_PSI_MUTEX
+#endif
+
+#ifndef DISABLE_PSI_RWLOCK
+#define DISABLE_PSI_RWLOCK
+#endif
+
+#ifndef DISABLE_PSI_COND
+#define DISABLE_PSI_COND
+#endif
+
+#ifndef DISABLE_PSI_FILE
+#define DISABLE_PSI_FILE
+#endif
+
+#ifndef DISABLE_PSI_TABLE
+#define DISABLE_PSI_TABLE
+#endif
+
+#ifndef DISABLE_PSI_SOCKET
+#define DISABLE_PSI_SOCKET
+#endif
+
+#ifndef DISABLE_PSI_STAGE
+#define DISABLE_PSI_STAGE
+#endif
+
+#ifndef DISABLE_PSI_STATEMENT
+#define DISABLE_PSI_STATEMENT
+#endif
+
+#ifndef DISABLE_PSI_SP
+#define DISABLE_PSI_SP
+#endif
+
+#ifndef DISABLE_PSI_IDLE
+#define DISABLE_PSI_IDLE
+#endif
+
+#ifndef DISABLE_PSI_STATEMENT_DIGEST
+#define DISABLE_PSI_STATEMENT_DIGEST
+#endif
+
+#ifndef DISABLE_PSI_METADATA
+#define DISABLE_PSI_METADATA
+#endif
+
+#ifndef DISABLE_PSI_MEMORY
+#define DISABLE_PSI_MEMORY
+#endif
+
+#ifndef DISABLE_PSI_TRANSACTION
+#define DISABLE_PSI_TRANSACTION
+#endif
+
+#ifndef DISABLE_PSI_SP
+#define DISABLE_PSI_SP
+#endif
+
+#ifndef DISABLE_PSI_PS
+#define DISABLE_PSI_PS
+#endif
+
+#endif
+
/**
@def DISABLE_PSI_MUTEX
Compiling option to disable the mutex instrumentation.
This option is mostly intended to be used during development,
when doing special builds with only a subset of the performance schema instrumentation,
for code analysis / profiling / performance tuning of a specific instrumentation alone.
- For this reason, DISABLE_PSI_MUTEX is not advertised in the cmake general options.
- To disable mutexes, add -DDISABLE_PSI_MUTEX to CFLAGS.
@sa DISABLE_PSI_RWLOCK
@sa DISABLE_PSI_COND
@sa DISABLE_PSI_FILE
@@ -198,8 +398,13 @@ typedef struct PSI_bootstrap PSI_bootstrap;
@sa DISABLE_PSI_TABLE
@sa DISABLE_PSI_STAGE
@sa DISABLE_PSI_STATEMENT
+ @sa DISABLE_PSI_SP
+ @sa DISABLE_PSI_STATEMENT_DIGEST
@sa DISABLE_PSI_SOCKET
+ @sa DISABLE_PSI_MEMORY
@sa DISABLE_PSI_IDLE
+ @sa DISABLE_PSI_METADATA
+ @sa DISABLE PSI_TRANSACTION
*/
#ifndef DISABLE_PSI_MUTEX
@@ -276,6 +481,26 @@ typedef struct PSI_bootstrap PSI_bootstrap;
#endif
/**
+ @def DISABLE_PSI_SP
+ Compiling option to disable the stored program instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+#ifndef DISABLE_PSI_SP
+#define HAVE_PSI_SP_INTERFACE
+#endif
+
+/**
+ @def DISABLE_PSI_PS
+ Compiling option to disable the prepared statement instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+#ifndef DISABLE_PSI_STATEMENT
+#ifndef DISABLE_PSI_PS
+#define HAVE_PSI_PS_INTERFACE
+#endif
+#endif
+
+/**
@def DISABLE_PSI_STATEMENT_DIGEST
Compiling option to disable the statement digest instrumentation.
*/
@@ -287,6 +512,16 @@ typedef struct PSI_bootstrap PSI_bootstrap;
#endif
/**
+ @def DISABLE_PSI_TRANSACTION
+ Compiling option to disable the transaction instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_TRANSACTION
+#define HAVE_PSI_TRANSACTION_INTERFACE
+#endif
+
+/**
@def DISABLE_PSI_SOCKET
Compiling option to disable the statement instrumentation.
@sa DISABLE_PSI_MUTEX
@@ -297,6 +532,16 @@ typedef struct PSI_bootstrap PSI_bootstrap;
#endif
/**
+ @def DISABLE_PSI_MEMORY
+ Compiling option to disable the memory instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_MEMORY
+#define HAVE_PSI_MEMORY_INTERFACE
+#endif
+
+/**
@def DISABLE_PSI_IDLE
Compiling option to disable the idle instrumentation.
@sa DISABLE_PSI_MUTEX
@@ -307,6 +552,16 @@ typedef struct PSI_bootstrap PSI_bootstrap;
#endif
/**
+ @def DISABLE_PSI_METADATA
+ Compiling option to disable the metadata instrumentation.
+ @sa DISABLE_PSI_MUTEX
+*/
+
+#ifndef DISABLE_PSI_METADATA
+#define HAVE_PSI_METADATA_INTERFACE
+#endif
+
+/**
@def PSI_VERSION_1
Performance Schema Interface number for version 1.
This version is supported.
@@ -368,6 +623,13 @@ typedef struct PSI_file_locker PSI_file_locker;
struct PSI_socket_locker;
typedef struct PSI_socket_locker PSI_socket_locker;
+/**
+ Interface for an instrumented MDL operation.
+ This is an opaque structure.
+*/
+struct PSI_metadata_locker;
+typedef struct PSI_metadata_locker PSI_metadata_locker;
+
/** Operation performed on an instrumented mutex. */
enum PSI_mutex_operation
{
@@ -378,7 +640,12 @@ enum PSI_mutex_operation
};
typedef enum PSI_mutex_operation PSI_mutex_operation;
-/** Operation performed on an instrumented rwlock. */
+/**
+ Operation performed on an instrumented rwlock.
+ For basic READ / WRITE lock,
+ operations are "READ" or "WRITE".
+ For SX-locks, operations are "SHARED", "SHARED-EXCLUSIVE" or "EXCLUSIVE".
+*/
enum PSI_rwlock_operation
{
/** Read lock. */
@@ -388,7 +655,21 @@ enum PSI_rwlock_operation
/** Read lock attempt. */
PSI_RWLOCK_TRYREADLOCK= 2,
/** Write lock attempt. */
- PSI_RWLOCK_TRYWRITELOCK= 3
+ PSI_RWLOCK_TRYWRITELOCK= 3,
+
+ /** Shared lock. */
+ PSI_RWLOCK_SHAREDLOCK= 4,
+ /** Shared Exclusive lock. */
+ PSI_RWLOCK_SHAREDEXCLUSIVELOCK= 5,
+ /** Exclusive lock. */
+ PSI_RWLOCK_EXCLUSIVELOCK= 6,
+ /** Shared lock attempt. */
+ PSI_RWLOCK_TRYSHAREDLOCK= 7,
+ /** Shared Exclusive lock attempt. */
+ PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK= 8,
+ /** Exclusive lock attempt. */
+ PSI_RWLOCK_TRYEXCLUSIVELOCK= 9
+
};
typedef enum PSI_rwlock_operation PSI_rwlock_operation;
@@ -448,20 +729,6 @@ enum PSI_file_operation
};
typedef enum PSI_file_operation PSI_file_operation;
-/** IO operation performed on an instrumented table. */
-enum PSI_table_io_operation
-{
- /** Row fetch. */
- PSI_TABLE_FETCH_ROW= 0,
- /** Row write. */
- PSI_TABLE_WRITE_ROW= 1,
- /** Row update. */
- PSI_TABLE_UPDATE_ROW= 2,
- /** Row delete. */
- PSI_TABLE_DELETE_ROW= 3
-};
-typedef enum PSI_table_io_operation PSI_table_io_operation;
-
/** Lock operation performed on an instrumented table. */
enum PSI_table_lock_operation
{
@@ -518,6 +785,7 @@ enum PSI_socket_operation
};
typedef enum PSI_socket_operation PSI_socket_operation;
+#endif
/**
Instrumented mutex key.
To instrument a mutex, a mutex key must be obtained using @c register_mutex.
@@ -577,44 +845,6 @@ typedef unsigned int PSI_statement_key;
*/
typedef unsigned int PSI_socket_key;
-/**
- @def USE_PSI_1
- Define USE_PSI_1 to use the interface version 1.
-*/
-
-/**
- @def USE_PSI_2
- Define USE_PSI_2 to use the interface version 2.
-*/
-
-/**
- @def HAVE_PSI_1
- Define HAVE_PSI_1 if the interface version 1 needs to be compiled in.
-*/
-
-/**
- @def HAVE_PSI_2
- Define HAVE_PSI_2 if the interface version 2 needs to be compiled in.
-*/
-
-/**
- Global flag.
- This flag indicate that an instrumentation point is a global variable,
- or a singleton.
-*/
-#define PSI_FLAG_GLOBAL (1 << 0)
-
-/**
- Global flag.
- This flag indicate that an instrumentation point is a general placeholder,
- that can mutate into a more specific instrumentation point.
-*/
-#define PSI_FLAG_MUTABLE (1 << 1)
-
-#ifdef USE_PSI_1
-#define HAVE_PSI_1
-#endif
-
#ifdef HAVE_PSI_1
/**
@@ -644,6 +874,7 @@ struct PSI_mutex_info_v1
*/
int m_flags;
};
+typedef struct PSI_mutex_info_v1 PSI_mutex_info_v1;
/**
Rwlock information.
@@ -666,6 +897,7 @@ struct PSI_rwlock_info_v1
*/
int m_flags;
};
+typedef struct PSI_rwlock_info_v1 PSI_rwlock_info_v1;
/**
Condition information.
@@ -688,6 +920,7 @@ struct PSI_cond_info_v1
*/
int m_flags;
};
+typedef struct PSI_cond_info_v1 PSI_cond_info_v1;
/**
Thread instrument information.
@@ -710,6 +943,7 @@ struct PSI_thread_info_v1
*/
int m_flags;
};
+typedef struct PSI_thread_info_v1 PSI_thread_info_v1;
/**
File instrument information.
@@ -732,6 +966,7 @@ struct PSI_file_info_v1
*/
int m_flags;
};
+typedef struct PSI_file_info_v1 PSI_file_info_v1;
/**
Stage instrument information.
@@ -747,6 +982,7 @@ struct PSI_stage_info_v1
/** The flags of the stage instrument to register. */
int m_flags;
};
+typedef struct PSI_stage_info_v1 PSI_stage_info_v1;
/**
Statement instrument information.
@@ -762,6 +998,7 @@ struct PSI_statement_info_v1
/** The flags of the statement instrument to register. */
int m_flags;
};
+typedef struct PSI_statement_info_v1 PSI_statement_info_v1;
/**
Socket instrument information.
@@ -784,6 +1021,7 @@ struct PSI_socket_info_v1
*/
int m_flags;
};
+typedef struct PSI_socket_info_v1 PSI_socket_info_v1;
/**
State data storage for @c start_idle_wait_v1_t.
@@ -807,6 +1045,7 @@ struct PSI_idle_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state_v1;
/**
State data storage for @c start_mutex_wait_v1_t.
@@ -834,6 +1073,7 @@ struct PSI_mutex_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state_v1;
/**
State data storage for @c start_rwlock_rdwait_v1_t, @c start_rwlock_wrwait_v1_t.
@@ -862,6 +1102,7 @@ struct PSI_rwlock_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state_v1;
/**
State data storage for @c start_cond_wait_v1_t.
@@ -891,6 +1132,7 @@ struct PSI_cond_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state_v1;
/**
State data storage for @c get_thread_file_name_locker_v1_t.
@@ -926,28 +1168,23 @@ struct PSI_file_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_file_locker_state_v1 PSI_file_locker_state_v1;
/**
- State data storage for @c start_table_io_wait_v1_t,
- @c start_table_lock_wait_v1_t.
- This structure provide temporary storage to a table locker.
+ State data storage for @c start_metadata_wait_v1_t.
+ This structure provide temporary storage to a metadata locker.
The content of this structure is considered opaque,
the fields are only hints of what an implementation
of the psi interface can use.
This memory is provided by the instrumented code for performance reasons.
- @sa start_table_io_wait_v1_t
- @sa start_table_lock_wait_v1_t
+ @sa start_metadata_wait_v1_t
*/
-struct PSI_table_locker_state_v1
+struct PSI_metadata_locker_state_v1
{
/** Internal state. */
uint m_flags;
- /** Current io operation. */
- enum PSI_table_io_operation m_io_operation;
- /** Current table handle. */
- struct PSI_table *m_table;
- /** Current table share. */
- struct PSI_table_share *m_table_share;
+ /** Current metadata lock. */
+ struct PSI_metadata_lock *m_metadata_lock;
/** Current thread. */
struct PSI_thread *m_thread;
/** Timer start. */
@@ -956,13 +1193,8 @@ struct PSI_table_locker_state_v1
ulonglong (*m_timer)(void);
/** Internal data. */
void *m_wait;
- /**
- Implementation specific.
- For table io, the table io index.
- For table lock, the lock type.
- */
- uint m_index;
};
+typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state_v1;
/* Duplicate of NAME_LEN, to avoid dependency on mysql_com.h */
#define PSI_SCHEMA_NAME_LEN (64 * 3)
@@ -981,6 +1213,8 @@ struct PSI_statement_locker_state_v1
{
/** Discarded flag. */
my_bool m_discarded;
+ /** In prepare flag. */
+ my_bool m_in_prepare;
/** Metric, no index used flag. */
uchar m_no_index_used;
/** Metric, no good index used flag. */
@@ -1033,8 +1267,51 @@ struct PSI_statement_locker_state_v1
uint m_schema_name_length;
/** Statement character set number. */
uint m_cs_number;
+ PSI_sp_share *m_parent_sp_share;
+ PSI_prepared_stmt *m_parent_prepared_stmt;
+};
+typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state_v1;
+
+/**
+ State data storage for @c get_thread_transaction_locker_v1_t,
+ @c get_thread_transaction_locker_v1_t.
+ This structure provide temporary storage to a transaction locker.
+ The content of this structure is considered opaque,
+ the fields are only hints of what an implementation
+ of the psi interface can use.
+ This memory is provided by the instrumented code for performance reasons.
+ @sa get_thread_transaction_locker_v1_t
+*/
+struct PSI_transaction_locker_state_v1
+{
+ /** Internal state. */
+ uint m_flags;
+ /** Instrumentation class. */
+ void *m_class;
+ /** Current thread. */
+ struct PSI_thread *m_thread;
+ /** Timer start. */
+ ulonglong m_timer_start;
+ /** Timer function. */
+ ulonglong (*m_timer)(void);
+ /** Internal data. */
+ void *m_transaction;
+ /** True if read-only transaction, false if read-write. */
+ my_bool m_read_only;
+ /** True if transaction is autocommit. */
+ my_bool m_autocommit;
+ /** Number of statements. */
+ ulong m_statement_count;
+ /** Total number of savepoints. */
+ ulong m_savepoint_count;
+ /** Number of rollback_to_savepoint. */
+ ulong m_rollback_to_savepoint_count;
+ /** Number of release_savepoint. */
+ ulong m_release_savepoint_count;
};
+typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state_v1;
+
/**
State data storage for @c start_socket_wait_v1_t.
This structure provide temporary storage to a socket locker.
@@ -1067,6 +1344,22 @@ struct PSI_socket_locker_state_v1
/** Internal data. */
void *m_wait;
};
+typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state_v1;
+
+struct PSI_sp_locker_state_v1
+{
+ /** Internal state. */
+ uint m_flags;
+ /** Current thread. */
+ struct PSI_thread *m_thread;
+ /** Timer start. */
+ ulonglong m_timer_start;
+ /** Timer function. */
+ ulonglong (*m_timer)(void);
+ /** Stored Procedure share. */
+ PSI_sp_share* m_sp_share;
+};
+typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state_v1;
/* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */
@@ -1263,7 +1556,8 @@ typedef PSI_table* (*rebind_table_v1_t)
Note that the table handle is invalid after this call.
@param table the table handle to close
*/
-typedef void (*close_table_v1_t)(struct PSI_table *table);
+typedef void (*close_table_v1_t)(struct TABLE_SHARE *server_share,
+ struct PSI_table *table);
/**
Create a file instrumentation for a created file.
@@ -1300,6 +1594,14 @@ typedef struct PSI_thread* (*new_thread_v1_t)
(PSI_thread_key key, const void *identity, ulonglong thread_id);
/**
+ Assign a THD to an instrumented thread.
+ @param thread the instrumented thread
+ @param THD the sql layer THD to assign
+*/
+typedef void (*set_thread_THD_v1_t)(struct PSI_thread *thread,
+ THD *thd);
+
+/**
Assign an id to an instrumented thread.
@param thread the instrumented thread
@param id the id to assign
@@ -1308,6 +1610,13 @@ typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
ulonglong id);
/**
+ Assign the current operating system thread id to an instrumented thread.
+ The operating system task id is obtained from @c gettid()
+ @param thread the instrumented thread
+*/
+typedef void (*set_thread_os_id_v1_t)(struct PSI_thread *thread);
+
+/**
Get the instrumentation for the running thread.
For this function to return a result,
the thread instrumentation must have been attached to the
@@ -1330,8 +1639,8 @@ typedef void (*set_thread_user_v1_t)(const char *user, int user_len);
@param host the host name
@param host_len the host name length
*/
-typedef void (*set_thread_user_host_v1_t)(const char *user, int user_len,
- const char *host, int host_len);
+typedef void (*set_thread_account_v1_t)(const char *user, int user_len,
+ const char *host, int host_len);
/**
Assign a current database to the instrumented thread.
@@ -1347,6 +1656,13 @@ typedef void (*set_thread_db_v1_t)(const char* db, int db_len);
typedef void (*set_thread_command_v1_t)(int command);
/**
+ Assign a connection type to the instrumented thread.
+ @param conn_type the connection type
+*/
+typedef void (*set_connection_type_v1_t)(opaque_vio_type conn_type);
+
+
+/**
Assign a start time to the instrumented thread.
@param start_time the thread start time
*/
@@ -1376,6 +1692,15 @@ typedef void (*set_thread_info_v1_t)(const char* info, uint info_len);
*/
typedef void (*set_thread_v1_t)(struct PSI_thread *thread);
+/**
+ Assign the remote (peer) port to the instrumented thread.
+
+ @param thread pointer to the thread instrumentation
+ @param port the remote port
+*/
+typedef void (*set_thread_peer_port_v1_t)(PSI_thread *thread,
+ unsigned int port);
+
/** Delete the current thread instrumentation. */
typedef void (*delete_current_thread_v1_t)(void);
@@ -1446,9 +1771,20 @@ typedef void (*signal_cond_v1_t)
typedef void (*broadcast_cond_v1_t)
(struct PSI_cond *cond);
+/**
+ Record an idle instrumentation wait start event.
+ @param state data storage for the locker
+ @param file the source file name
+ @param line the source line number
+ @return an idle locker, or NULL
+*/
typedef struct PSI_idle_locker* (*start_idle_wait_v1_t)
(struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line);
+/**
+ Record an idle instrumentation wait end event.
+ @param locker a thread locker for the running thread
+*/
typedef void (*end_idle_wait_v1_t)
(struct PSI_idle_locker *locker);
@@ -1540,7 +1876,7 @@ typedef void (*end_cond_wait_v1_t)
@param line the source line number
*/
typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
- (struct PSI_table_locker_state_v1 *state,
+ (struct PSI_table_locker_state *state,
struct PSI_table *table,
enum PSI_table_io_operation op,
uint index,
@@ -1549,8 +1885,11 @@ typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
/**
Record a table instrumentation io wait end event.
@param locker a table locker for the running thread
+ @param numrows the number of rows involved in io
*/
-typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*end_table_io_wait_v1_t)
+ (struct PSI_table_locker *locker,
+ ulonglong numrows);
/**
Record a table instrumentation lock wait start event.
@@ -1559,7 +1898,7 @@ typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
@param line the source line number
*/
typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
- (struct PSI_table_locker_state_v1 *state,
+ (struct PSI_table_locker_state *state,
struct PSI_table *table,
enum PSI_table_lock_operation op,
ulong flags,
@@ -1571,6 +1910,8 @@ typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
*/
typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*unlock_table_v1_t)(struct PSI_table *table);
+
/**
Start a file instrumentation open operation.
@param locker the file locker
@@ -1599,6 +1940,15 @@ typedef void (*end_file_open_wait_and_bind_to_descriptor_v1_t)
(struct PSI_file_locker *locker, File file);
/**
+ End a file instrumentation open operation, for non stream temporary files.
+ @param locker the file locker.
+ @param file the file number assigned by open() or create() for this file.
+ @param filename the file name generated during temporary file creation.
+*/
+typedef void (*end_temp_file_open_wait_and_bind_to_descriptor_v1_t)
+ (struct PSI_file_locker *locker, File file, const char *filename);
+
+/**
Record a file instrumentation start event.
@param locker a file locker for the running thread
@param op file operation to be performed
@@ -1645,14 +1995,28 @@ typedef void (*end_file_close_wait_v1_t)
(struct PSI_file_locker *locker, int rc);
/**
+ Rename a file instrumentation close operation.
+ @param locker the file locker.
+ @param old_name name of the file to be renamed.
+ @param new_name name of the file after rename.
+ @param rc the rename operation return code (0 for success).
+*/
+typedef void (*end_file_rename_wait_v1_t)
+ (struct PSI_file_locker *locker, const char *old_name,
+ const char *new_name, int rc);
+
+/**
Start a new stage, and implicitly end the previous stage.
@param key the key of the new stage
@param src_file the source file name
@param src_line the source line number
+ @return the new stage progress
*/
-typedef void (*start_stage_v1_t)
+typedef PSI_stage_progress* (*start_stage_v1_t)
(PSI_stage_key key, const char *src_file, int src_line);
+typedef PSI_stage_progress* (*get_current_stage_progress_v1_t)(void);
+
/** End the current stage. */
typedef void (*end_stage_v1_t) (void);
@@ -1665,7 +2029,7 @@ typedef void (*end_stage_v1_t) (void);
*/
typedef struct PSI_statement_locker* (*get_thread_statement_locker_v1_t)
(struct PSI_statement_locker_state_v1 *state,
- PSI_statement_key key, const void *charset);
+ PSI_statement_key key, const void *charset, PSI_sp_share *sp_share);
/**
Refine a statement locker to a more specific key.
@@ -1839,6 +2203,102 @@ typedef void (*end_statement_v1_t)
(struct PSI_statement_locker *locker, void *stmt_da);
/**
+ Get a transaction instrumentation locker.
+ @param state data storage for the locker
+ @param xid the xid for this transaction
+ @param trxid the InnoDB transaction id
+ @param iso_level isolation level for this transaction
+ @param read_only true if transaction access mode is read-only
+ @param autocommit true if transaction is autocommit
+ @return a transaction locker, or NULL
+*/
+typedef struct PSI_transaction_locker* (*get_thread_transaction_locker_v1_t)
+ (struct PSI_transaction_locker_state_v1 *state, const void *xid,
+ ulonglong trxid, int isolation_level, my_bool read_only,
+ my_bool autocommit);
+
+/**
+ Start a new transaction event.
+ @param locker the transaction locker for this event
+ @param src_file source file name
+ @param src_line source line number
+*/
+typedef void (*start_transaction_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const char *src_file, uint src_line);
+
+/**
+ Set the transaction xid.
+ @param locker the transaction locker for this event
+ @param xid the id of the XA transaction
+ #param xa_state is the state of the XA transaction
+*/
+typedef void (*set_transaction_xid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const void *xid, int xa_state);
+
+/**
+ Set the state of the XA transaction.
+ @param locker the transaction locker for this event
+ @param xa_state the new state of the xa transaction
+*/
+typedef void (*set_transaction_xa_state_v1_t)
+ (struct PSI_transaction_locker *locker,
+ int xa_state);
+
+/**
+ Set the transaction gtid.
+ @param locker the transaction locker for this event
+ @param sid the source id for the transaction, mapped from sidno
+ @param gtid_spec the gtid specifier for the transaction
+*/
+typedef void (*set_transaction_gtid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const void *sid, const void *gtid_spec);
+
+/**
+ Set the transaction trx_id.
+ @param locker the transaction locker for this event
+ @param trxid the storage engine transaction ID
+*/
+typedef void (*set_transaction_trxid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const ulonglong *trxid);
+
+/**
+ Increment a transaction event savepoint count.
+ @param locker the transaction locker
+ @param count the increment value
+*/
+typedef void (*inc_transaction_savepoints_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+
+/**
+ Increment a transaction event rollback to savepoint count.
+ @param locker the transaction locker
+ @param count the increment value
+*/
+typedef void (*inc_transaction_rollback_to_savepoint_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+
+/**
+ Increment a transaction event release savepoint count.
+ @param locker the transaction locker
+ @param count the increment value
+*/
+typedef void (*inc_transaction_release_savepoint_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+
+/**
+ Commit or rollback the transaction.
+ @param locker the transaction locker for this event
+ @param commit true if transaction was committed, false if rolled back
+*/
+typedef void (*end_transaction_v1_t)
+ (struct PSI_transaction_locker *locker,
+ my_bool commit);
+
+/**
Record a socket instrumentation start event.
@param locker a socket locker for the running thread
@param op socket operation to be performed
@@ -1894,23 +2354,119 @@ typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
/**
+ Get a prepare statement.
+ @param locker a statement locker for the running thread.
+*/
+typedef PSI_prepared_stmt* (*create_prepared_stmt_v1_t)
+ (void *identity, uint stmt_id, PSI_statement_locker *locker,
+ const char *stmt_name, size_t stmt_name_length);
+
+/**
+ destroy a prepare statement.
+ @param prepared_stmt prepared statement.
+*/
+typedef void (*destroy_prepared_stmt_v1_t)
+ (PSI_prepared_stmt *prepared_stmt);
+
+/**
+ repreare a prepare statement.
+ @param prepared_stmt prepared statement.
+*/
+typedef void (*reprepare_prepared_stmt_v1_t)
+ (PSI_prepared_stmt *prepared_stmt);
+
+/**
+ Record a prepare statement instrumentation execute event.
+ @param locker a statement locker for the running thread.
+ @param prepared_stmt prepared statement.
+*/
+typedef void (*execute_prepared_stmt_v1_t)
+ (PSI_statement_locker *locker, PSI_prepared_stmt* prepared_stmt);
+
+/**
+ Set the statement text for a prepared statment event.
+ @param prepared_stmt prepared statement.
+ @param text the prepared statement text
+ @param text_len the prepared statement text length
+*/
+typedef void (*set_prepared_stmt_text_v1_t)(PSI_prepared_stmt *prepared_stmt,
+ const char *text,
+ uint text_len);
+/**
Get a digest locker for the current statement.
@param locker a statement locker for the running thread
*/
typedef struct PSI_digest_locker * (*digest_start_v1_t)
(struct PSI_statement_locker *locker);
+/**
+ Add a token to the current digest instrumentation.
+ @param locker a digest locker for the current statement
+ @param token the lexical token to add
+ @param yylval the lexical token attributes
+*/
typedef void (*digest_end_v1_t)
(struct PSI_digest_locker *locker, const struct sql_digest_storage *digest);
+typedef PSI_sp_locker* (*start_sp_v1_t)
+ (struct PSI_sp_locker_state_v1 *state, struct PSI_sp_share* sp_share);
+
+typedef void (*end_sp_v1_t)
+ (struct PSI_sp_locker *locker);
+
+typedef void (*drop_sp_v1_t)
+ (uint object_type,
+ const char *schema_name, uint schema_name_length,
+ const char *object_name, uint object_name_length);
+
+/**
+ Acquire a sp share instrumentation.
+ @param type of stored program
+ @param schema name of stored program
+ @param name of stored program
+ @return a stored program share instrumentation, or NULL
+*/
+typedef struct PSI_sp_share* (*get_sp_share_v1_t)
+ (uint object_type,
+ const char *schema_name, uint schema_name_length,
+ const char *object_name, uint object_name_length);
+
+/**
+ Release a stored program share.
+ @param info the stored program share to release
+*/
+typedef void (*release_sp_share_v1_t)(struct PSI_sp_share *share);
+
+typedef PSI_metadata_lock* (*create_metadata_lock_v1_t)
+ (void *identity,
+ const MDL_key *key,
+ opaque_mdl_type mdl_type,
+ opaque_mdl_duration mdl_duration,
+ opaque_mdl_status mdl_status,
+ const char *src_file,
+ uint src_line);
+
+typedef void (*set_metadata_lock_status_v1_t)(PSI_metadata_lock *lock,
+ opaque_mdl_status mdl_status);
+
+typedef void (*destroy_metadata_lock_v1_t)(PSI_metadata_lock *lock);
+
+typedef struct PSI_metadata_locker* (*start_metadata_wait_v1_t)
+ (struct PSI_metadata_locker_state_v1 *state,
+ struct PSI_metadata_lock *mdl,
+ const char *src_file, uint src_line);
+
+typedef void (*end_metadata_wait_v1_t)
+ (struct PSI_metadata_locker *locker, int rc);
+
/**
Stores an array of connection attributes
@param buffer char array of length encoded connection attributes
in network format
- @param length legnth of the data in buffer
- @param from_cs charset in which @buffer is encodded
+ @param length length of the data in buffer
+ @param from_cs charset in which @c buffer is encoded
@return state
- @retval non-0 attributes truncated
+ @retval non_0 attributes truncated
@retval 0 stored the attribute
*/
typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length,
@@ -1954,6 +2510,7 @@ struct PSI_v1
init_socket_v1_t init_socket;
/** @sa destroy_socket_v1_t. */
destroy_socket_v1_t destroy_socket;
+
/** @sa get_table_share_v1_t. */
get_table_share_v1_t get_table_share;
/** @sa release_table_share_v1_t. */
@@ -1976,16 +2533,22 @@ struct PSI_v1
new_thread_v1_t new_thread;
/** @sa set_thread_id_v1_t. */
set_thread_id_v1_t set_thread_id;
+ /** @sa set_thread_THD_v1_t. */
+ set_thread_THD_v1_t set_thread_THD;
+ /** @sa set_thread_os_id_v1_t. */
+ set_thread_os_id_v1_t set_thread_os_id;
/** @sa get_thread_v1_t. */
get_thread_v1_t get_thread;
/** @sa set_thread_user_v1_t. */
set_thread_user_v1_t set_thread_user;
- /** @sa set_thread_user_host_v1_t. */
- set_thread_user_host_v1_t set_thread_user_host;
+ /** @sa set_thread_account_v1_t. */
+ set_thread_account_v1_t set_thread_account;
/** @sa set_thread_db_v1_t. */
set_thread_db_v1_t set_thread_db;
/** @sa set_thread_command_v1_t. */
set_thread_command_v1_t set_thread_command;
+ /** @sa set_connection_type_v1_t. */
+ set_connection_type_v1_t set_connection_type;
/** @sa set_thread_start_time_v1_t. */
set_thread_start_time_v1_t set_thread_start_time;
/** @sa set_thread_state_v1_t. */
@@ -2047,6 +2610,9 @@ struct PSI_v1
/** @sa end_file_open_wait_and_bind_to_descriptor_v1_t. */
end_file_open_wait_and_bind_to_descriptor_v1_t
end_file_open_wait_and_bind_to_descriptor;
+ /** @sa end_temp_file_open_wait_and_bind_to_descriptor_v1_t. */
+ end_temp_file_open_wait_and_bind_to_descriptor_v1_t
+ end_temp_file_open_wait_and_bind_to_descriptor;
/** @sa start_file_wait_v1_t. */
start_file_wait_v1_t start_file_wait;
/** @sa end_file_wait_v1_t. */
@@ -2055,8 +2621,12 @@ struct PSI_v1
start_file_close_wait_v1_t start_file_close_wait;
/** @sa end_file_close_wait_v1_t. */
end_file_close_wait_v1_t end_file_close_wait;
+ /** @sa rename_file_close_wait_v1_t. */
+ end_file_rename_wait_v1_t end_file_rename_wait;
/** @sa start_stage_v1_t. */
start_stage_v1_t start_stage;
+ /** @sa get_current_stage_progress_v1_t. */
+ get_current_stage_progress_v1_t get_current_stage_progress;
/** @sa end_stage_v1_t. */
end_stage_v1_t end_stage;
/** @sa get_thread_statement_locker_v1_t. */
@@ -2101,6 +2671,26 @@ struct PSI_v1
set_statement_no_good_index_used_t set_statement_no_good_index_used;
/** @sa end_statement_v1_t. */
end_statement_v1_t end_statement;
+ /** @sa get_thread_transaction_locker_v1_t. */
+ get_thread_transaction_locker_v1_t get_thread_transaction_locker;
+ /** @sa start_transaction_v1_t. */
+ start_transaction_v1_t start_transaction;
+ /** @sa set_transaction_xid_v1_t. */
+ set_transaction_xid_v1_t set_transaction_xid;
+ /** @sa set_transaction_xa_state_v1_t. */
+ set_transaction_xa_state_v1_t set_transaction_xa_state;
+ /** @sa set_transaction_gtid_v1_t. */
+ set_transaction_gtid_v1_t set_transaction_gtid;
+ /** @sa set_transaction_trxid_v1_t. */
+ set_transaction_trxid_v1_t set_transaction_trxid;
+ /** @sa inc_transaction_savepoints_v1_t. */
+ inc_transaction_savepoints_v1_t inc_transaction_savepoints;
+ /** @sa inc_transaction_rollback_to_savepoint_v1_t. */
+ inc_transaction_rollback_to_savepoint_v1_t inc_transaction_rollback_to_savepoint;
+ /** @sa inc_transaction_release_savepoint_v1_t. */
+ inc_transaction_release_savepoint_v1_t inc_transaction_release_savepoint;
+ /** @sa end_transaction_v1_t. */
+ end_transaction_v1_t end_transaction;
/** @sa start_socket_wait_v1_t. */
start_socket_wait_v1_t start_socket_wait;
/** @sa end_socket_wait_v1_t. */
@@ -2111,12 +2701,53 @@ struct PSI_v1
set_socket_info_v1_t set_socket_info;
/** @sa set_socket_thread_owner_v1_t. */
set_socket_thread_owner_v1_t set_socket_thread_owner;
+ /** @sa create_prepared_stmt_v1_t. */
+ create_prepared_stmt_v1_t create_prepared_stmt;
+ /** @sa destroy_prepared_stmt_v1_t. */
+ destroy_prepared_stmt_v1_t destroy_prepared_stmt;
+ /** @sa reprepare_prepared_stmt_v1_t. */
+ reprepare_prepared_stmt_v1_t reprepare_prepared_stmt;
+ /** @sa execute_prepared_stmt_v1_t. */
+ execute_prepared_stmt_v1_t execute_prepared_stmt;
+ /** @sa set_prepared_stmt_text_v1_t. */
+ set_prepared_stmt_text_v1_t set_prepared_stmt_text;
/** @sa digest_start_v1_t. */
digest_start_v1_t digest_start;
/** @sa digest_end_v1_t. */
digest_end_v1_t digest_end;
/** @sa set_thread_connect_attrs_v1_t. */
set_thread_connect_attrs_v1_t set_thread_connect_attrs;
+ /** @sa start_sp_v1_t. */
+ start_sp_v1_t start_sp;
+ /** @sa start_sp_v1_t. */
+ end_sp_v1_t end_sp;
+ /** @sa drop_sp_v1_t. */
+ drop_sp_v1_t drop_sp;
+ /** @sa get_sp_share_v1_t. */
+ get_sp_share_v1_t get_sp_share;
+ /** @sa release_sp_share_v1_t. */
+ release_sp_share_v1_t release_sp_share;
+ /** @sa register_memory_v1_t. */
+ register_memory_v1_t register_memory;
+ /** @sa memory_alloc_v1_t. */
+ memory_alloc_v1_t memory_alloc;
+ /** @sa memory_realloc_v1_t. */
+ memory_realloc_v1_t memory_realloc;
+ /** @sa memory_claim_v1_t. */
+ memory_claim_v1_t memory_claim;
+ /** @sa memory_free_v1_t. */
+ memory_free_v1_t memory_free;
+
+ unlock_table_v1_t unlock_table;
+
+ create_metadata_lock_v1_t create_metadata_lock;
+ set_metadata_lock_status_v1_t set_metadata_lock_status;
+ destroy_metadata_lock_v1_t destroy_metadata_lock;
+
+ start_metadata_wait_v1_t start_metadata_wait;
+ end_metadata_wait_v1_t end_metadata_wait;
+
+ set_thread_peer_port_v1_t set_thread_peer_port;
};
/** @} (end of group Group_PSI_v1) */
@@ -2197,6 +2828,13 @@ struct PSI_statement_info_v2
};
/** Placeholder */
+struct PSI_transaction_info_v2
+{
+ /** Placeholder */
+ int placeholder;
+};
+
+/** Placeholder */
struct PSI_idle_locker_state_v2
{
/** Placeholder */
@@ -2232,14 +2870,14 @@ struct PSI_file_locker_state_v2
};
/** Placeholder */
-struct PSI_table_locker_state_v2
+struct PSI_statement_locker_state_v2
{
/** Placeholder */
int placeholder;
};
/** Placeholder */
-struct PSI_statement_locker_state_v2
+struct PSI_transaction_locker_state_v2
{
/** Placeholder */
int placeholder;
@@ -2252,6 +2890,11 @@ struct PSI_socket_locker_state_v2
int placeholder;
};
+struct PSI_metadata_locker_state_v2
+{
+ int placeholder;
+};
+
/** @} (end of group Group_PSI_v2) */
#endif /* HAVE_PSI_2 */
@@ -2297,15 +2940,18 @@ typedef struct PSI_thread_info_v1 PSI_thread_info;
typedef struct PSI_file_info_v1 PSI_file_info;
typedef struct PSI_stage_info_v1 PSI_stage_info;
typedef struct PSI_statement_info_v1 PSI_statement_info;
+typedef struct PSI_transaction_info_v1 PSI_transaction_info;
typedef struct PSI_socket_info_v1 PSI_socket_info;
typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state;
typedef struct PSI_file_locker_state_v1 PSI_file_locker_state;
-typedef struct PSI_table_locker_state_v1 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state;
+typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state;
typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
+typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state;
+typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state;
#endif
#ifdef USE_PSI_2
@@ -2317,18 +2963,21 @@ typedef struct PSI_thread_info_v2 PSI_thread_info;
typedef struct PSI_file_info_v2 PSI_file_info;
typedef struct PSI_stage_info_v2 PSI_stage_info;
typedef struct PSI_statement_info_v2 PSI_statement_info;
+typedef struct PSI_transaction_info_v2 PSI_transaction_info;
typedef struct PSI_socket_info_v2 PSI_socket_info;
typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state;
typedef struct PSI_file_locker_state_v2 PSI_file_locker_state;
-typedef struct PSI_table_locker_state_v2 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state;
+typedef struct PSI_transaction_locker_state_v2 PSI_transaction_locker_state;
typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
+typedef struct PSI_sp_locker_state_v2 PSI_sp_locker_state;
+typedef struct PSI_metadata_locker_state_v2 PSI_metadata_locker_state;
#endif
-#else /* HAVE_PSI_INTERFACE */
+#ifndef HAVE_PSI_INTERFACE
/**
Dummy structure, used to declare PSI_server when no instrumentation
@@ -2365,10 +3014,13 @@ struct PSI_stage_info_none
with HAVE_PSI_INTERFACE.
*/
typedef struct PSI_stage_info_none PSI_stage_info;
+typedef struct PSI_stage_info_none PSI_statement_info;
+typedef struct PSI_stage_info_none PSI_sp_locker_state;
+typedef struct PSI_stage_info_none PSI_metadata_locker_state;
+typedef struct PSI_stage_info_none PSI_metadata_locker;
#endif /* HAVE_PSI_INTERFACE */
-extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
/*
@@ -2378,50 +3030,6 @@ extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
make a dynamic call using the PSI_server function pointer.
*/
-#ifndef PSI_MUTEX_CALL
-#define PSI_MUTEX_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
-#ifndef PSI_RWLOCK_CALL
-#define PSI_RWLOCK_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
-#ifndef PSI_COND_CALL
-#define PSI_COND_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
-#ifndef PSI_THREAD_CALL
-#define PSI_THREAD_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
-#ifndef PSI_FILE_CALL
-#define PSI_FILE_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
-#ifndef PSI_SOCKET_CALL
-#define PSI_SOCKET_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
-#ifndef PSI_STAGE_CALL
-#define PSI_STAGE_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
-#ifndef PSI_STATEMENT_CALL
-#define PSI_STATEMENT_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
-#ifndef PSI_DIGEST_CALL
-#define PSI_DIGEST_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
-#ifndef PSI_TABLE_CALL
-#define PSI_TABLE_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
-#ifndef PSI_IDLE_CALL
-#define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M)
-#endif
-
#define PSI_DYNAMIC_CALL(M) PSI_server->M
/** @} */
diff --git a/include/mysql/psi/psi_abi_v0.h b/include/mysql/psi/psi_abi_v0.h
index ca4373f847b..df47ae78eb4 100644
--- a/include/mysql/psi/psi_abi_v0.h
+++ b/include/mysql/psi/psi_abi_v0.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/include/mysql/psi/psi_abi_v0.h.pp b/include/mysql/psi/psi_abi_v0.h.pp
index 17d61016a68..47dc72b7ecb 100644
--- a/include/mysql/psi/psi_abi_v0.h.pp
+++ b/include/mysql/psi/psi_abi_v0.h.pp
@@ -1,7 +1,23 @@
#include "mysql/psi/psi.h"
+#include "psi_base.h"
+#include "psi_memory.h"
+#include "psi_base.h"
+struct PSI_thread;
+typedef unsigned int PSI_memory_key;
C_MODE_START
+struct MDL_key;
+typedef struct MDL_key MDL_key;
+typedef int opaque_mdl_type;
+typedef int opaque_mdl_duration;
+typedef int opaque_mdl_status;
+typedef int opaque_vio_type;
struct TABLE_SHARE;
struct sql_digest_storage;
+ struct opaque_THD
+ {
+ int dummy;
+ };
+ typedef struct opaque_THD THD;
struct PSI_mutex;
typedef struct PSI_mutex PSI_mutex;
struct PSI_rwlock;
@@ -18,14 +34,51 @@ struct PSI_file;
typedef struct PSI_file PSI_file;
struct PSI_socket;
typedef struct PSI_socket PSI_socket;
+struct PSI_prepared_stmt;
+typedef struct PSI_prepared_stmt PSI_prepared_stmt;
struct PSI_table_locker;
typedef struct PSI_table_locker PSI_table_locker;
struct PSI_statement_locker;
typedef struct PSI_statement_locker PSI_statement_locker;
+struct PSI_transaction_locker;
+typedef struct PSI_transaction_locker PSI_transaction_locker;
struct PSI_idle_locker;
typedef struct PSI_idle_locker PSI_idle_locker;
struct PSI_digest_locker;
typedef struct PSI_digest_locker PSI_digest_locker;
+struct PSI_sp_share;
+typedef struct PSI_sp_share PSI_sp_share;
+struct PSI_sp_locker;
+typedef struct PSI_sp_locker PSI_sp_locker;
+struct PSI_metadata_lock;
+typedef struct PSI_metadata_lock PSI_metadata_lock;
+struct PSI_stage_progress
+{
+ ulonglong m_work_completed;
+ ulonglong m_work_estimated;
+};
+typedef struct PSI_stage_progress PSI_stage_progress;
+enum PSI_table_io_operation
+{
+ PSI_TABLE_FETCH_ROW= 0,
+ PSI_TABLE_WRITE_ROW= 1,
+ PSI_TABLE_UPDATE_ROW= 2,
+ PSI_TABLE_DELETE_ROW= 3
+};
+typedef enum PSI_table_io_operation PSI_table_io_operation;
+struct PSI_table_locker_state
+{
+ uint m_flags;
+ enum PSI_table_io_operation m_io_operation;
+ struct PSI_table *m_table;
+ struct PSI_table_share *m_table_share;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_wait;
+ uint m_index;
+};
+typedef struct PSI_table_locker_state PSI_table_locker_state;
struct PSI_bootstrap
{
void* (*get_interface)(int version);
diff --git a/include/mysql/psi/psi_abi_v1.h b/include/mysql/psi/psi_abi_v1.h
index 488e832c3ed..61018bdf030 100644
--- a/include/mysql/psi/psi_abi_v1.h
+++ b/include/mysql/psi/psi_abi_v1.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/include/mysql/psi/psi_abi_v1.h.pp b/include/mysql/psi/psi_abi_v1.h.pp
index 576d801b127..2dc27e09ca4 100644
--- a/include/mysql/psi/psi_abi_v1.h.pp
+++ b/include/mysql/psi/psi_abi_v1.h.pp
@@ -1,6 +1,37 @@
+extern "C" {
+}
+extern "C" {
+struct PSI_thread;
+typedef unsigned int PSI_memory_key;
+struct PSI_memory_info_v1
+{
+ PSI_memory_key *m_key;
+ const char *m_name;
+ int m_flags;
+};
+typedef struct PSI_memory_info_v1 PSI_memory_info_v1;
+typedef void (*register_memory_v1_t)
+ (const char *category, struct PSI_memory_info_v1 *info, int count);
+typedef PSI_memory_key (*memory_alloc_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread ** owner);
+typedef PSI_memory_key (*memory_realloc_v1_t)
+ (PSI_memory_key key, size_t old_size, size_t new_size, struct PSI_thread ** owner);
+typedef PSI_memory_key (*memory_claim_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread ** owner);
+typedef void (*memory_free_v1_t)
+ (PSI_memory_key key, size_t size, struct PSI_thread * owner);
+typedef struct PSI_memory_info_v1 PSI_memory_info;
+}
C_MODE_START
+struct MDL_key;
+typedef struct MDL_key MDL_key;
+typedef int opaque_mdl_type;
+typedef int opaque_mdl_duration;
+typedef int opaque_mdl_status;
+typedef int opaque_vio_type;
struct TABLE_SHARE;
struct sql_digest_storage;
+ class THD;
struct PSI_mutex;
typedef struct PSI_mutex PSI_mutex;
struct PSI_rwlock;
@@ -17,14 +48,51 @@ struct PSI_file;
typedef struct PSI_file PSI_file;
struct PSI_socket;
typedef struct PSI_socket PSI_socket;
+struct PSI_prepared_stmt;
+typedef struct PSI_prepared_stmt PSI_prepared_stmt;
struct PSI_table_locker;
typedef struct PSI_table_locker PSI_table_locker;
struct PSI_statement_locker;
typedef struct PSI_statement_locker PSI_statement_locker;
+struct PSI_transaction_locker;
+typedef struct PSI_transaction_locker PSI_transaction_locker;
struct PSI_idle_locker;
typedef struct PSI_idle_locker PSI_idle_locker;
struct PSI_digest_locker;
typedef struct PSI_digest_locker PSI_digest_locker;
+struct PSI_sp_share;
+typedef struct PSI_sp_share PSI_sp_share;
+struct PSI_sp_locker;
+typedef struct PSI_sp_locker PSI_sp_locker;
+struct PSI_metadata_lock;
+typedef struct PSI_metadata_lock PSI_metadata_lock;
+struct PSI_stage_progress
+{
+ ulonglong m_work_completed;
+ ulonglong m_work_estimated;
+};
+typedef struct PSI_stage_progress PSI_stage_progress;
+enum PSI_table_io_operation
+{
+ PSI_TABLE_FETCH_ROW= 0,
+ PSI_TABLE_WRITE_ROW= 1,
+ PSI_TABLE_UPDATE_ROW= 2,
+ PSI_TABLE_DELETE_ROW= 3
+};
+typedef enum PSI_table_io_operation PSI_table_io_operation;
+struct PSI_table_locker_state
+{
+ uint m_flags;
+ enum PSI_table_io_operation m_io_operation;
+ struct PSI_table *m_table;
+ struct PSI_table_share *m_table_share;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_wait;
+ uint m_index;
+};
+typedef struct PSI_table_locker_state PSI_table_locker_state;
struct PSI_bootstrap
{
void* (*get_interface)(int version);
@@ -40,6 +108,8 @@ struct PSI_file_locker;
typedef struct PSI_file_locker PSI_file_locker;
struct PSI_socket_locker;
typedef struct PSI_socket_locker PSI_socket_locker;
+struct PSI_metadata_locker;
+typedef struct PSI_metadata_locker PSI_metadata_locker;
enum PSI_mutex_operation
{
PSI_MUTEX_LOCK= 0,
@@ -51,7 +121,13 @@ enum PSI_rwlock_operation
PSI_RWLOCK_READLOCK= 0,
PSI_RWLOCK_WRITELOCK= 1,
PSI_RWLOCK_TRYREADLOCK= 2,
- PSI_RWLOCK_TRYWRITELOCK= 3
+ PSI_RWLOCK_TRYWRITELOCK= 3,
+ PSI_RWLOCK_SHAREDLOCK= 4,
+ PSI_RWLOCK_SHAREDEXCLUSIVELOCK= 5,
+ PSI_RWLOCK_EXCLUSIVELOCK= 6,
+ PSI_RWLOCK_TRYSHAREDLOCK= 7,
+ PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK= 8,
+ PSI_RWLOCK_TRYEXCLUSIVELOCK= 9
};
typedef enum PSI_rwlock_operation PSI_rwlock_operation;
enum PSI_cond_operation
@@ -81,14 +157,6 @@ enum PSI_file_operation
PSI_FILE_SYNC= 16
};
typedef enum PSI_file_operation PSI_file_operation;
-enum PSI_table_io_operation
-{
- PSI_TABLE_FETCH_ROW= 0,
- PSI_TABLE_WRITE_ROW= 1,
- PSI_TABLE_UPDATE_ROW= 2,
- PSI_TABLE_DELETE_ROW= 3
-};
-typedef enum PSI_table_io_operation PSI_table_io_operation;
enum PSI_table_lock_operation
{
PSI_TABLE_LOCK= 0,
@@ -134,48 +202,56 @@ struct PSI_mutex_info_v1
const char *m_name;
int m_flags;
};
+typedef struct PSI_mutex_info_v1 PSI_mutex_info_v1;
struct PSI_rwlock_info_v1
{
PSI_rwlock_key *m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_rwlock_info_v1 PSI_rwlock_info_v1;
struct PSI_cond_info_v1
{
PSI_cond_key *m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_cond_info_v1 PSI_cond_info_v1;
struct PSI_thread_info_v1
{
PSI_thread_key *m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_thread_info_v1 PSI_thread_info_v1;
struct PSI_file_info_v1
{
PSI_file_key *m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_file_info_v1 PSI_file_info_v1;
struct PSI_stage_info_v1
{
PSI_stage_key m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_stage_info_v1 PSI_stage_info_v1;
struct PSI_statement_info_v1
{
PSI_statement_key m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_statement_info_v1 PSI_statement_info_v1;
struct PSI_socket_info_v1
{
PSI_socket_key *m_key;
const char *m_name;
int m_flags;
};
+typedef struct PSI_socket_info_v1 PSI_socket_info_v1;
struct PSI_idle_locker_state_v1
{
uint m_flags;
@@ -184,6 +260,7 @@ struct PSI_idle_locker_state_v1
ulonglong (*m_timer)(void);
void *m_wait;
};
+typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state_v1;
struct PSI_mutex_locker_state_v1
{
uint m_flags;
@@ -194,6 +271,7 @@ struct PSI_mutex_locker_state_v1
ulonglong (*m_timer)(void);
void *m_wait;
};
+typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state_v1;
struct PSI_rwlock_locker_state_v1
{
uint m_flags;
@@ -204,6 +282,7 @@ struct PSI_rwlock_locker_state_v1
ulonglong (*m_timer)(void);
void *m_wait;
};
+typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state_v1;
struct PSI_cond_locker_state_v1
{
uint m_flags;
@@ -215,6 +294,7 @@ struct PSI_cond_locker_state_v1
ulonglong (*m_timer)(void);
void *m_wait;
};
+typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state_v1;
struct PSI_file_locker_state_v1
{
uint m_flags;
@@ -228,21 +308,21 @@ struct PSI_file_locker_state_v1
ulonglong (*m_timer)(void);
void *m_wait;
};
-struct PSI_table_locker_state_v1
+typedef struct PSI_file_locker_state_v1 PSI_file_locker_state_v1;
+struct PSI_metadata_locker_state_v1
{
uint m_flags;
- enum PSI_table_io_operation m_io_operation;
- struct PSI_table *m_table;
- struct PSI_table_share *m_table_share;
+ struct PSI_metadata_lock *m_metadata_lock;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
void *m_wait;
- uint m_index;
};
+typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state_v1;
struct PSI_statement_locker_state_v1
{
my_bool m_discarded;
+ my_bool m_in_prepare;
uchar m_no_index_used;
uchar m_no_good_index_used;
uint m_flags;
@@ -269,7 +349,26 @@ struct PSI_statement_locker_state_v1
char m_schema_name[(64 * 3)];
uint m_schema_name_length;
uint m_cs_number;
+ PSI_sp_share *m_parent_sp_share;
+ PSI_prepared_stmt *m_parent_prepared_stmt;
+};
+typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state_v1;
+struct PSI_transaction_locker_state_v1
+{
+ uint m_flags;
+ void *m_class;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_transaction;
+ my_bool m_read_only;
+ my_bool m_autocommit;
+ ulong m_statement_count;
+ ulong m_savepoint_count;
+ ulong m_rollback_to_savepoint_count;
+ ulong m_release_savepoint_count;
};
+typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state_v1;
struct PSI_socket_locker_state_v1
{
uint m_flags;
@@ -283,6 +382,16 @@ struct PSI_socket_locker_state_v1
int m_src_line;
void *m_wait;
};
+typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state_v1;
+struct PSI_sp_locker_state_v1
+{
+ uint m_flags;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ PSI_sp_share* m_sp_share;
+};
+typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state_v1;
typedef void (*register_mutex_v1_t)
(const char *category, struct PSI_mutex_info_v1 *info, int count);
typedef void (*register_rwlock_v1_t)
@@ -324,7 +433,8 @@ typedef void (*unbind_table_v1_t)
(struct PSI_table *table);
typedef PSI_table* (*rebind_table_v1_t)
(PSI_table_share *share, const void *identity, PSI_table *table);
-typedef void (*close_table_v1_t)(struct PSI_table *table);
+typedef void (*close_table_v1_t)(struct TABLE_SHARE *server_share,
+ struct PSI_table *table);
typedef void (*create_file_v1_t)(PSI_file_key key, const char *name,
File file);
typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
@@ -333,18 +443,24 @@ typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
void *(*start_routine)(void*), void *arg);
typedef struct PSI_thread* (*new_thread_v1_t)
(PSI_thread_key key, const void *identity, ulonglong thread_id);
+typedef void (*set_thread_THD_v1_t)(struct PSI_thread *thread,
+ THD *thd);
typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
ulonglong id);
+typedef void (*set_thread_os_id_v1_t)(struct PSI_thread *thread);
typedef struct PSI_thread* (*get_thread_v1_t)(void);
typedef void (*set_thread_user_v1_t)(const char *user, int user_len);
-typedef void (*set_thread_user_host_v1_t)(const char *user, int user_len,
- const char *host, int host_len);
+typedef void (*set_thread_account_v1_t)(const char *user, int user_len,
+ const char *host, int host_len);
typedef void (*set_thread_db_v1_t)(const char* db, int db_len);
typedef void (*set_thread_command_v1_t)(int command);
+typedef void (*set_connection_type_v1_t)(opaque_vio_type conn_type);
typedef void (*set_thread_start_time_v1_t)(time_t start_time);
typedef void (*set_thread_state_v1_t)(const char* state);
typedef void (*set_thread_info_v1_t)(const char* info, uint info_len);
typedef void (*set_thread_v1_t)(struct PSI_thread *thread);
+typedef void (*set_thread_peer_port_v1_t)(PSI_thread *thread,
+ unsigned int port);
typedef void (*delete_current_thread_v1_t)(void);
typedef void (*delete_thread_v1_t)(struct PSI_thread *thread);
typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t)
@@ -399,25 +515,30 @@ typedef struct PSI_cond_locker* (*start_cond_wait_v1_t)
typedef void (*end_cond_wait_v1_t)
(struct PSI_cond_locker *locker, int rc);
typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
- (struct PSI_table_locker_state_v1 *state,
+ (struct PSI_table_locker_state *state,
struct PSI_table *table,
enum PSI_table_io_operation op,
uint index,
const char *src_file, uint src_line);
-typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*end_table_io_wait_v1_t)
+ (struct PSI_table_locker *locker,
+ ulonglong numrows);
typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
- (struct PSI_table_locker_state_v1 *state,
+ (struct PSI_table_locker_state *state,
struct PSI_table *table,
enum PSI_table_lock_operation op,
ulong flags,
const char *src_file, uint src_line);
typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
+typedef void (*unlock_table_v1_t)(struct PSI_table *table);
typedef void (*start_file_open_wait_v1_t)
(struct PSI_file_locker *locker, const char *src_file, uint src_line);
typedef struct PSI_file* (*end_file_open_wait_v1_t)
(struct PSI_file_locker *locker, void *result);
typedef void (*end_file_open_wait_and_bind_to_descriptor_v1_t)
(struct PSI_file_locker *locker, File file);
+typedef void (*end_temp_file_open_wait_and_bind_to_descriptor_v1_t)
+ (struct PSI_file_locker *locker, File file, const char *filename);
typedef void (*start_file_wait_v1_t)
(struct PSI_file_locker *locker, size_t count,
const char *src_file, uint src_line);
@@ -427,12 +548,16 @@ typedef void (*start_file_close_wait_v1_t)
(struct PSI_file_locker *locker, const char *src_file, uint src_line);
typedef void (*end_file_close_wait_v1_t)
(struct PSI_file_locker *locker, int rc);
-typedef void (*start_stage_v1_t)
+typedef void (*end_file_rename_wait_v1_t)
+ (struct PSI_file_locker *locker, const char *old_name,
+ const char *new_name, int rc);
+typedef PSI_stage_progress* (*start_stage_v1_t)
(PSI_stage_key key, const char *src_file, int src_line);
+typedef PSI_stage_progress* (*get_current_stage_progress_v1_t)(void);
typedef void (*end_stage_v1_t) (void);
typedef struct PSI_statement_locker* (*get_thread_statement_locker_v1_t)
(struct PSI_statement_locker_state_v1 *state,
- PSI_statement_key key, const void *charset);
+ PSI_statement_key key, const void *charset, PSI_sp_share *sp_share);
typedef struct PSI_statement_locker* (*refine_statement_v1_t)
(struct PSI_statement_locker *locker,
PSI_statement_key key);
@@ -477,6 +602,34 @@ typedef void (*set_statement_no_good_index_used_t)
(struct PSI_statement_locker *locker);
typedef void (*end_statement_v1_t)
(struct PSI_statement_locker *locker, void *stmt_da);
+typedef struct PSI_transaction_locker* (*get_thread_transaction_locker_v1_t)
+ (struct PSI_transaction_locker_state_v1 *state, const void *xid,
+ ulonglong trxid, int isolation_level, my_bool read_only,
+ my_bool autocommit);
+typedef void (*start_transaction_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const char *src_file, uint src_line);
+typedef void (*set_transaction_xid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const void *xid, int xa_state);
+typedef void (*set_transaction_xa_state_v1_t)
+ (struct PSI_transaction_locker *locker,
+ int xa_state);
+typedef void (*set_transaction_gtid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const void *sid, const void *gtid_spec);
+typedef void (*set_transaction_trxid_v1_t)
+ (struct PSI_transaction_locker *locker,
+ const ulonglong *trxid);
+typedef void (*inc_transaction_savepoints_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+typedef void (*inc_transaction_rollback_to_savepoint_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+typedef void (*inc_transaction_release_savepoint_v1_t)
+ (struct PSI_transaction_locker *locker, ulong count);
+typedef void (*end_transaction_v1_t)
+ (struct PSI_transaction_locker *locker,
+ my_bool commit);
typedef struct PSI_socket_locker* (*start_socket_wait_v1_t)
(struct PSI_socket_locker_state_v1 *state,
struct PSI_socket *socket,
@@ -492,10 +645,52 @@ typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
const struct sockaddr *addr,
socklen_t addr_len);
typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
+typedef PSI_prepared_stmt* (*create_prepared_stmt_v1_t)
+ (void *identity, uint stmt_id, PSI_statement_locker *locker,
+ const char *stmt_name, size_t stmt_name_length);
+typedef void (*destroy_prepared_stmt_v1_t)
+ (PSI_prepared_stmt *prepared_stmt);
+typedef void (*reprepare_prepared_stmt_v1_t)
+ (PSI_prepared_stmt *prepared_stmt);
+typedef void (*execute_prepared_stmt_v1_t)
+ (PSI_statement_locker *locker, PSI_prepared_stmt* prepared_stmt);
+typedef void (*set_prepared_stmt_text_v1_t)(PSI_prepared_stmt *prepared_stmt,
+ const char *text,
+ uint text_len);
typedef struct PSI_digest_locker * (*digest_start_v1_t)
(struct PSI_statement_locker *locker);
typedef void (*digest_end_v1_t)
(struct PSI_digest_locker *locker, const struct sql_digest_storage *digest);
+typedef PSI_sp_locker* (*start_sp_v1_t)
+ (struct PSI_sp_locker_state_v1 *state, struct PSI_sp_share* sp_share);
+typedef void (*end_sp_v1_t)
+ (struct PSI_sp_locker *locker);
+typedef void (*drop_sp_v1_t)
+ (uint object_type,
+ const char *schema_name, uint schema_name_length,
+ const char *object_name, uint object_name_length);
+typedef struct PSI_sp_share* (*get_sp_share_v1_t)
+ (uint object_type,
+ const char *schema_name, uint schema_name_length,
+ const char *object_name, uint object_name_length);
+typedef void (*release_sp_share_v1_t)(struct PSI_sp_share *share);
+typedef PSI_metadata_lock* (*create_metadata_lock_v1_t)
+ (void *identity,
+ const MDL_key *key,
+ opaque_mdl_type mdl_type,
+ opaque_mdl_duration mdl_duration,
+ opaque_mdl_status mdl_status,
+ const char *src_file,
+ uint src_line);
+typedef void (*set_metadata_lock_status_v1_t)(PSI_metadata_lock *lock,
+ opaque_mdl_status mdl_status);
+typedef void (*destroy_metadata_lock_v1_t)(PSI_metadata_lock *lock);
+typedef struct PSI_metadata_locker* (*start_metadata_wait_v1_t)
+ (struct PSI_metadata_locker_state_v1 *state,
+ struct PSI_metadata_lock *mdl,
+ const char *src_file, uint src_line);
+typedef void (*end_metadata_wait_v1_t)
+ (struct PSI_metadata_locker *locker, int rc);
typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length,
const void *from_cs);
struct PSI_v1
@@ -527,11 +722,14 @@ struct PSI_v1
spawn_thread_v1_t spawn_thread;
new_thread_v1_t new_thread;
set_thread_id_v1_t set_thread_id;
+ set_thread_THD_v1_t set_thread_THD;
+ set_thread_os_id_v1_t set_thread_os_id;
get_thread_v1_t get_thread;
set_thread_user_v1_t set_thread_user;
- set_thread_user_host_v1_t set_thread_user_host;
+ set_thread_account_v1_t set_thread_account;
set_thread_db_v1_t set_thread_db;
set_thread_command_v1_t set_thread_command;
+ set_connection_type_v1_t set_connection_type;
set_thread_start_time_v1_t set_thread_start_time;
set_thread_state_v1_t set_thread_state;
set_thread_info_v1_t set_thread_info;
@@ -563,11 +761,15 @@ struct PSI_v1
end_file_open_wait_v1_t end_file_open_wait;
end_file_open_wait_and_bind_to_descriptor_v1_t
end_file_open_wait_and_bind_to_descriptor;
+ end_temp_file_open_wait_and_bind_to_descriptor_v1_t
+ end_temp_file_open_wait_and_bind_to_descriptor;
start_file_wait_v1_t start_file_wait;
end_file_wait_v1_t end_file_wait;
start_file_close_wait_v1_t start_file_close_wait;
end_file_close_wait_v1_t end_file_close_wait;
+ end_file_rename_wait_v1_t end_file_rename_wait;
start_stage_v1_t start_stage;
+ get_current_stage_progress_v1_t get_current_stage_progress;
end_stage_v1_t end_stage;
get_thread_statement_locker_v1_t get_thread_statement_locker;
refine_statement_v1_t refine_statement;
@@ -590,14 +792,46 @@ struct PSI_v1
set_statement_no_index_used_t set_statement_no_index_used;
set_statement_no_good_index_used_t set_statement_no_good_index_used;
end_statement_v1_t end_statement;
+ get_thread_transaction_locker_v1_t get_thread_transaction_locker;
+ start_transaction_v1_t start_transaction;
+ set_transaction_xid_v1_t set_transaction_xid;
+ set_transaction_xa_state_v1_t set_transaction_xa_state;
+ set_transaction_gtid_v1_t set_transaction_gtid;
+ set_transaction_trxid_v1_t set_transaction_trxid;
+ inc_transaction_savepoints_v1_t inc_transaction_savepoints;
+ inc_transaction_rollback_to_savepoint_v1_t inc_transaction_rollback_to_savepoint;
+ inc_transaction_release_savepoint_v1_t inc_transaction_release_savepoint;
+ end_transaction_v1_t end_transaction;
start_socket_wait_v1_t start_socket_wait;
end_socket_wait_v1_t end_socket_wait;
set_socket_state_v1_t set_socket_state;
set_socket_info_v1_t set_socket_info;
set_socket_thread_owner_v1_t set_socket_thread_owner;
+ create_prepared_stmt_v1_t create_prepared_stmt;
+ destroy_prepared_stmt_v1_t destroy_prepared_stmt;
+ reprepare_prepared_stmt_v1_t reprepare_prepared_stmt;
+ execute_prepared_stmt_v1_t execute_prepared_stmt;
+ set_prepared_stmt_text_v1_t set_prepared_stmt_text;
digest_start_v1_t digest_start;
digest_end_v1_t digest_end;
set_thread_connect_attrs_v1_t set_thread_connect_attrs;
+ start_sp_v1_t start_sp;
+ end_sp_v1_t end_sp;
+ drop_sp_v1_t drop_sp;
+ get_sp_share_v1_t get_sp_share;
+ release_sp_share_v1_t release_sp_share;
+ register_memory_v1_t register_memory;
+ memory_alloc_v1_t memory_alloc;
+ memory_realloc_v1_t memory_realloc;
+ memory_claim_v1_t memory_claim;
+ memory_free_v1_t memory_free;
+ unlock_table_v1_t unlock_table;
+ create_metadata_lock_v1_t create_metadata_lock;
+ set_metadata_lock_status_v1_t set_metadata_lock_status;
+ destroy_metadata_lock_v1_t destroy_metadata_lock;
+ start_metadata_wait_v1_t start_metadata_wait;
+ end_metadata_wait_v1_t end_metadata_wait;
+ set_thread_peer_port_v1_t set_thread_peer_port;
};
typedef struct PSI_v1 PSI;
typedef struct PSI_mutex_info_v1 PSI_mutex_info;
@@ -607,15 +841,17 @@ typedef struct PSI_thread_info_v1 PSI_thread_info;
typedef struct PSI_file_info_v1 PSI_file_info;
typedef struct PSI_stage_info_v1 PSI_stage_info;
typedef struct PSI_statement_info_v1 PSI_statement_info;
+typedef struct PSI_transaction_info_v1 PSI_transaction_info;
typedef struct PSI_socket_info_v1 PSI_socket_info;
typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state;
typedef struct PSI_file_locker_state_v1 PSI_file_locker_state;
-typedef struct PSI_table_locker_state_v1 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state;
+typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state;
typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
-extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
+typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state;
+typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
C_MODE_END
diff --git a/include/mysql/psi/psi_abi_v2.h b/include/mysql/psi/psi_abi_v2.h
index 67c054848a1..31c9e8fc42f 100644
--- a/include/mysql/psi/psi_abi_v2.h
+++ b/include/mysql/psi/psi_abi_v2.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/include/mysql/psi/psi_abi_v2.h.pp b/include/mysql/psi/psi_abi_v2.h.pp
index adf1af7cfae..a670e53a8b7 100644
--- a/include/mysql/psi/psi_abi_v2.h.pp
+++ b/include/mysql/psi/psi_abi_v2.h.pp
@@ -1,6 +1,24 @@
+extern "C" {
+}
+extern "C" {
+struct PSI_thread;
+typedef unsigned int PSI_memory_key;
+struct PSI_memory_info_v2
+{
+ int placeholder;
+};
+typedef struct PSI_memory_info_v2 PSI_memory_info;
+}
C_MODE_START
+struct MDL_key;
+typedef struct MDL_key MDL_key;
+typedef int opaque_mdl_type;
+typedef int opaque_mdl_duration;
+typedef int opaque_mdl_status;
+typedef int opaque_vio_type;
struct TABLE_SHARE;
struct sql_digest_storage;
+ class THD;
struct PSI_mutex;
typedef struct PSI_mutex PSI_mutex;
struct PSI_rwlock;
@@ -17,14 +35,51 @@ struct PSI_file;
typedef struct PSI_file PSI_file;
struct PSI_socket;
typedef struct PSI_socket PSI_socket;
+struct PSI_prepared_stmt;
+typedef struct PSI_prepared_stmt PSI_prepared_stmt;
struct PSI_table_locker;
typedef struct PSI_table_locker PSI_table_locker;
struct PSI_statement_locker;
typedef struct PSI_statement_locker PSI_statement_locker;
+struct PSI_transaction_locker;
+typedef struct PSI_transaction_locker PSI_transaction_locker;
struct PSI_idle_locker;
typedef struct PSI_idle_locker PSI_idle_locker;
struct PSI_digest_locker;
typedef struct PSI_digest_locker PSI_digest_locker;
+struct PSI_sp_share;
+typedef struct PSI_sp_share PSI_sp_share;
+struct PSI_sp_locker;
+typedef struct PSI_sp_locker PSI_sp_locker;
+struct PSI_metadata_lock;
+typedef struct PSI_metadata_lock PSI_metadata_lock;
+struct PSI_stage_progress
+{
+ ulonglong m_work_completed;
+ ulonglong m_work_estimated;
+};
+typedef struct PSI_stage_progress PSI_stage_progress;
+enum PSI_table_io_operation
+{
+ PSI_TABLE_FETCH_ROW= 0,
+ PSI_TABLE_WRITE_ROW= 1,
+ PSI_TABLE_UPDATE_ROW= 2,
+ PSI_TABLE_DELETE_ROW= 3
+};
+typedef enum PSI_table_io_operation PSI_table_io_operation;
+struct PSI_table_locker_state
+{
+ uint m_flags;
+ enum PSI_table_io_operation m_io_operation;
+ struct PSI_table *m_table;
+ struct PSI_table_share *m_table_share;
+ struct PSI_thread *m_thread;
+ ulonglong m_timer_start;
+ ulonglong (*m_timer)(void);
+ void *m_wait;
+ uint m_index;
+};
+typedef struct PSI_table_locker_state PSI_table_locker_state;
struct PSI_bootstrap
{
void* (*get_interface)(int version);
@@ -40,6 +95,8 @@ struct PSI_file_locker;
typedef struct PSI_file_locker PSI_file_locker;
struct PSI_socket_locker;
typedef struct PSI_socket_locker PSI_socket_locker;
+struct PSI_metadata_locker;
+typedef struct PSI_metadata_locker PSI_metadata_locker;
enum PSI_mutex_operation
{
PSI_MUTEX_LOCK= 0,
@@ -51,7 +108,13 @@ enum PSI_rwlock_operation
PSI_RWLOCK_READLOCK= 0,
PSI_RWLOCK_WRITELOCK= 1,
PSI_RWLOCK_TRYREADLOCK= 2,
- PSI_RWLOCK_TRYWRITELOCK= 3
+ PSI_RWLOCK_TRYWRITELOCK= 3,
+ PSI_RWLOCK_SHAREDLOCK= 4,
+ PSI_RWLOCK_SHAREDEXCLUSIVELOCK= 5,
+ PSI_RWLOCK_EXCLUSIVELOCK= 6,
+ PSI_RWLOCK_TRYSHAREDLOCK= 7,
+ PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK= 8,
+ PSI_RWLOCK_TRYEXCLUSIVELOCK= 9
};
typedef enum PSI_rwlock_operation PSI_rwlock_operation;
enum PSI_cond_operation
@@ -81,14 +144,6 @@ enum PSI_file_operation
PSI_FILE_SYNC= 16
};
typedef enum PSI_file_operation PSI_file_operation;
-enum PSI_table_io_operation
-{
- PSI_TABLE_FETCH_ROW= 0,
- PSI_TABLE_WRITE_ROW= 1,
- PSI_TABLE_UPDATE_ROW= 2,
- PSI_TABLE_DELETE_ROW= 3
-};
-typedef enum PSI_table_io_operation PSI_table_io_operation;
enum PSI_table_lock_operation
{
PSI_TABLE_LOCK= 0,
@@ -160,6 +215,10 @@ struct PSI_statement_info_v2
{
int placeholder;
};
+struct PSI_transaction_info_v2
+{
+ int placeholder;
+};
struct PSI_idle_locker_state_v2
{
int placeholder;
@@ -180,11 +239,11 @@ struct PSI_file_locker_state_v2
{
int placeholder;
};
-struct PSI_table_locker_state_v2
+struct PSI_statement_locker_state_v2
{
int placeholder;
};
-struct PSI_statement_locker_state_v2
+struct PSI_transaction_locker_state_v2
{
int placeholder;
};
@@ -192,6 +251,10 @@ struct PSI_socket_locker_state_v2
{
int placeholder;
};
+struct PSI_metadata_locker_state_v2
+{
+ int placeholder;
+};
typedef struct PSI_v2 PSI;
typedef struct PSI_mutex_info_v2 PSI_mutex_info;
typedef struct PSI_rwlock_info_v2 PSI_rwlock_info;
@@ -200,15 +263,17 @@ typedef struct PSI_thread_info_v2 PSI_thread_info;
typedef struct PSI_file_info_v2 PSI_file_info;
typedef struct PSI_stage_info_v2 PSI_stage_info;
typedef struct PSI_statement_info_v2 PSI_statement_info;
+typedef struct PSI_transaction_info_v2 PSI_transaction_info;
typedef struct PSI_socket_info_v2 PSI_socket_info;
typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state;
typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state;
typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state;
typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state;
typedef struct PSI_file_locker_state_v2 PSI_file_locker_state;
-typedef struct PSI_table_locker_state_v2 PSI_table_locker_state;
typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state;
+typedef struct PSI_transaction_locker_state_v2 PSI_transaction_locker_state;
typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
-extern MYSQL_PLUGIN_IMPORT my_bool pfs_enabled;
+typedef struct PSI_sp_locker_state_v2 PSI_sp_locker_state;
+typedef struct PSI_metadata_locker_state_v2 PSI_metadata_locker_state;
extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
C_MODE_END
diff --git a/include/mysql/psi/psi_base.h b/include/mysql/psi/psi_base.h
index 2bb3061d55c..592aaf58fef 100644
--- a/include/mysql/psi/psi_base.h
+++ b/include/mysql/psi/psi_base.h
@@ -1,13 +1,25 @@
-/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
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.
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ Without limiting anything contained in the foregoing, this file,
+ which is part of C Driver for MySQL (Connector/C), is also subject to the
+ Universal FOSS Exception, version 1.0, a copy of which can be found at
+ http://oss.oracle.com/licenses/universal-foss-exception.
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.
+ GNU General Public License, version 2.0, 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,
@@ -16,6 +28,10 @@
#ifndef MYSQL_PSI_BASE_H
#define MYSQL_PSI_BASE_H
+#ifdef EMBEDDED_LIBRARY
+#define DISABLE_ALL_PSI
+#endif /* EMBEDDED_LIBRARY */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -30,6 +46,7 @@ extern "C" {
*/
#define PSI_INSTRUMENT_ME 0
+#define PSI_INSTRUMENT_MEM ((PSI_memory_key)0)
#define PSI_NOT_INSTRUMENTED 0
@@ -69,6 +86,20 @@ extern "C" {
*/
#define PSI_FLAG_TRANSFER (1 << 5)
+/**
+ Volatility flag.
+ This flag indicate that an instrumented object
+ has a volatility (life cycle) comparable
+ to the volatility of a session.
+*/
+#define PSI_FLAG_VOLATILITY_SESSION (1 << 6)
+
+/**
+ System thread flag.
+ Indicates that the instrumented object exists on a system thread.
+*/
+#define PSI_FLAG_THREAD_SYSTEM (1 << 9)
+
#ifdef HAVE_PSI_INTERFACE
/**
diff --git a/include/mysql/psi/psi_memory.h b/include/mysql/psi/psi_memory.h
index 3c633e6a918..4f5215d1808 100644
--- a/include/mysql/psi/psi_memory.h
+++ b/include/mysql/psi/psi_memory.h
@@ -1,13 +1,25 @@
-/* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
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.
+ it under the terms of the GNU General Public License, version 2.0,
+ as published by the Free Software Foundation.
+
+ This program is also distributed with certain software (including
+ but not limited to OpenSSL) that is licensed under separate terms,
+ as designated in a particular file or component or in included license
+ documentation. The authors of MySQL hereby grant you an additional
+ permission to link the program and your derivative works with the
+ separately licensed software that they have included with MySQL.
+
+ Without limiting anything contained in the foregoing, this file,
+ which is part of C Driver for MySQL (Connector/C), is also subject to the
+ Universal FOSS Exception, version 1.0, a copy of which can be found at
+ http://oss.oracle.com/licenses/universal-foss-exception.
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.
+ GNU General Public License, version 2.0, 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,
@@ -126,6 +138,10 @@ typedef void (*memory_free_v1_t)
/** @} (end of group Group_PSI_v1) */
+#ifdef _AIX
+PSI_memory_key key_memory_log_event;
+#endif
+
#endif /* HAVE_PSI_1 */
#ifdef HAVE_PSI_2
diff --git a/include/mysql/service_my_crypt.h b/include/mysql/service_my_crypt.h
index 2a232117ca1..bb038aaa295 100644
--- a/include/mysql/service_my_crypt.h
+++ b/include/mysql/service_my_crypt.h
@@ -45,7 +45,7 @@ extern "C" {
/* The max key length of all supported algorithms */
#define MY_AES_MAX_KEY_LENGTH 32
-#define MY_AES_CTX_SIZE 656
+#define MY_AES_CTX_SIZE 672
enum my_aes_mode {
MY_AES_ECB, MY_AES_CBC
diff --git a/include/mysql/service_thd_mdl.h b/include/mysql/service_thd_mdl.h
new file mode 100644
index 00000000000..19b0476914e
--- /dev/null
+++ b/include/mysql/service_thd_mdl.h
@@ -0,0 +1,46 @@
+/* Copyright (c) 2019, MariaDB Corporation.
+
+ 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-1335 USA */
+
+#pragma once
+
+/**
+ @file include/mysql/service_thd_mdl.h
+ This service provides functions for plugins and storage engines to access
+ metadata locks.
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+extern struct thd_mdl_service_st {
+ void *(*thd_mdl_context)(MYSQL_THD);
+} *thd_mdl_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+# define thd_mdl_context(_THD) thd_mdl_service->thd_mdl_context(_THD)
+#else
+/**
+ MDL_context accessor
+ @param thd the current session
+ @return pointer to thd->mdl_context
+*/
+void *thd_mdl_context(MYSQL_THD thd);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h
index 1e6aaa1b9b9..42b758c03f3 100644
--- a/include/mysql/service_wsrep.h
+++ b/include/mysql/service_wsrep.h
@@ -83,6 +83,9 @@ extern struct wsrep_service_st {
my_bool (*wsrep_get_debug_func)();
void (*wsrep_commit_ordered_func)(MYSQL_THD thd);
my_bool (*wsrep_thd_is_applying_func)(const MYSQL_THD thd);
+ ulong (*wsrep_OSU_method_get_func)(const MYSQL_THD thd);
+ my_bool (*wsrep_thd_has_ignored_error_func)(const MYSQL_THD thd);
+ void (*wsrep_thd_set_ignored_error_func)(MYSQL_THD thd, my_bool val);
bool (*wsrep_thd_set_wsrep_aborter_func)(MYSQL_THD bf_thd, MYSQL_THD thd);
void (*wsrep_report_bf_lock_wait_func)(const MYSQL_THD thd,
unsigned long long trx_id);
@@ -130,6 +133,9 @@ extern struct wsrep_service_st {
#define wsrep_get_debug() wsrep_service->wsrep_get_debug_func()
#define wsrep_commit_ordered(T) wsrep_service->wsrep_commit_ordered_func(T)
#define wsrep_thd_is_applying(T) wsrep_service->wsrep_thd_is_applying_func(T)
+#define wsrep_OSU_method_get(T) wsrep_service->wsrep_OSU_method_get_func(T)
+#define wsrep_thd_has_ignored_error(T) wsrep_service->wsrep_thd_has_ignored_error_func(T)
+#define wsrep_thd_set_ignored_error(T,V) wsrep_service->wsrep_thd_set_ignored_error_func(T,V)
#define wsrep_thd_set_wsrep_aborter(T) wsrep_service->wsrep_thd_set_wsrep_aborter_func(T1, T2)
#define wsrep_report_bf_lock_wait(T,I) wsrep_service->wsrep_report_bf_lock_wait(T,I)
#define wsrep_thd_set_PA_unsafe(T) wsrep_service->wsrep_thd_set_PA_unsafe_func(T)
@@ -228,6 +234,9 @@ extern "C" my_bool wsrep_get_debug();
extern "C" void wsrep_commit_ordered(MYSQL_THD thd);
extern "C" my_bool wsrep_thd_is_applying(const MYSQL_THD thd);
+extern "C" ulong wsrep_OSU_method_get(const MYSQL_THD thd);
+extern "C" my_bool wsrep_thd_has_ignored_error(const MYSQL_THD thd);
+extern "C" void wsrep_thd_set_ignored_error(MYSQL_THD thd, my_bool val);
extern "C" bool wsrep_thd_set_wsrep_aborter(MYSQL_THD bf_thd, MYSQL_THD victim_thd);
extern "C" void wsrep_report_bf_lock_wait(const THD *thd,
unsigned long long trx_id);
diff --git a/include/mysql_com.h b/include/mysql_com.h
index f63cf0ac5c2..eb2ee7410d8 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -24,9 +24,12 @@
#include "my_decimal_limits.h"
#define HOSTNAME_LENGTH 60
+#define HOSTNAME_LENGTH_STR STRINGIFY_ARG(HOSTNAME_LENGTH)
#define SYSTEM_CHARSET_MBMAXLEN 3
-#define NAME_CHAR_LEN 64U /* Field/table name length */
+#define NAME_CHAR_LEN 64 /* Field/table name length */
#define USERNAME_CHAR_LENGTH 128
+#define USERNAME_CHAR_LENGTH_STR STRINGIFY_ARG(USERNAME_CHAR_LENGTH)
+
#define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
#define DEFINER_CHAR_LENGTH (USERNAME_CHAR_LENGTH + HOSTNAME_LENGTH + 1)
@@ -71,6 +74,7 @@
#define COLUMN_COMMENT_MAXLEN 1024
#define INDEX_COMMENT_MAXLEN 1024
#define TABLE_PARTITION_COMMENT_MAXLEN 1024
+#define DATABASE_COMMENT_MAXLEN 1024
/*
Maximum length of protocol packet.
@@ -205,6 +209,8 @@ enum enum_indicator_type
itself supports it*/
#define LONG_UNIQUE_HASH_FIELD (1<< 30) /* This field will store hash for unique
column */
+#define FIELD_PART_OF_TMP_UNIQUE (1<< 31) /* part of an unique constrain
+ for a tmporary table*/
#define REFRESH_GRANT (1ULL << 0) /* Refresh grant tables */
#define REFRESH_LOG (1ULL << 1) /* Start on new log file */
@@ -295,6 +301,8 @@ enum enum_indicator_type
#define MARIADB_CLIENT_COM_MULTI (1ULL << 33)
/* support of array binding */
#define MARIADB_CLIENT_STMT_BULK_OPERATIONS (1ULL << 34)
+/* support of extended metadata (e.g. type/format information) */
+#define MARIADB_CLIENT_EXTENDED_METADATA (1ULL << 35)
#ifdef HAVE_COMPRESS
#define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
@@ -336,6 +344,7 @@ enum enum_indicator_type
CLIENT_CONNECT_ATTRS |\
MARIADB_CLIENT_COM_MULTI |\
MARIADB_CLIENT_STMT_BULK_OPERATIONS |\
+ MARIADB_CLIENT_EXTENDED_METADATA|\
CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)
/*
@@ -347,6 +356,15 @@ enum enum_indicator_type
& ~CLIENT_COMPRESS) \
& ~CLIENT_SSL_VERIFY_SERVER_CERT)
+enum mariadb_field_attr_t
+{
+ MARIADB_FIELD_ATTR_DATA_TYPE_NAME= 0,
+ MARIADB_FIELD_ATTR_FORMAT_NAME= 1
+};
+
+#define MARIADB_FIELD_ATTR_LAST MARIADB_FIELD_ATTR_FORMAT_NAME
+
+
/**
Is raised when a multi-statement transaction
has been started, either explicitly, by means
@@ -600,6 +618,15 @@ enum enum_session_state_type
SESSION_TRACK_GTIDS,
SESSION_TRACK_TRANSACTION_CHARACTERISTICS, /* Transaction chistics */
SESSION_TRACK_TRANSACTION_STATE, /* Transaction state */
+#ifdef USER_VAR_TRACKING
+ SESSION_TRACK_MYSQL_RESERVED1,
+ SESSION_TRACK_MYSQL_RESERVED2,
+ SESSION_TRACK_MYSQL_RESERVED3,
+ SESSION_TRACK_MYSQL_RESERVED4,
+ SESSION_TRACK_MYSQL_RESERVED5,
+ SESSION_TRACK_MYSQL_RESERVED6,
+ SESSION_TRACK_USER_VARIABLES,
+#endif // USER_VAR_TRACKING
SESSION_TRACK_always_at_the_end /* must be last */
};
diff --git a/include/mysys_err.h b/include/mysys_err.h
index e313d82eedf..e0e97d0284a 100644
--- a/include/mysys_err.h
+++ b/include/mysys_err.h
@@ -69,7 +69,11 @@ extern const char *globerrs[]; /* my_error_messages is here */
#define EE_CANT_SEEK 33
#define EE_CANT_CHMOD 34
#define EE_CANT_COPY_OWNERSHIP 35
-#define EE_ERROR_LAST 35 /* Copy last error nr */
+#define EE_BADMEMORYRELEASE 36
+#define EE_PERM_LOCK_MEMORY 37
+#define EE_MEMCNTL 38
+#define EE_DUPLICATE_CHARSET 39
+#define EE_ERROR_LAST 39 /* Copy last error nr */
/* Add error numbers before EE_ERROR_LAST and change it accordingly. */
diff --git a/include/pfs_file_provider.h b/include/pfs_file_provider.h
new file mode 100644
index 00000000000..3df999894fd
--- /dev/null
+++ b/include/pfs_file_provider.h
@@ -0,0 +1,92 @@
+/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_FILE_PROVIDER_H
+#define PFS_FILE_PROVIDER_H
+
+/**
+ @file include/pfs_file_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_FILE_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_FILE_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_file_v1(const char *category,
+ PSI_file_info_v1 *info,
+ int count);
+
+void pfs_create_file_v1(PSI_file_key key, const char *name, File file);
+
+PSI_file_locker*
+pfs_get_thread_file_name_locker_v1(PSI_file_locker_state *state,
+ PSI_file_key key,
+ PSI_file_operation op,
+ const char *name, const void *identity);
+
+PSI_file_locker*
+pfs_get_thread_file_stream_locker_v1(PSI_file_locker_state *state,
+ PSI_file *file, PSI_file_operation op);
+
+PSI_file_locker*
+pfs_get_thread_file_descriptor_locker_v1(PSI_file_locker_state *state,
+ File file, PSI_file_operation op);
+
+void pfs_start_file_open_wait_v1(PSI_file_locker *locker,
+ const char *src_file,
+ uint src_line);
+
+PSI_file* pfs_end_file_open_wait_v1(PSI_file_locker *locker, void *result);
+
+void pfs_end_file_open_wait_and_bind_to_descriptor_v1
+ (PSI_file_locker *locker, File file);
+
+void pfs_end_temp_file_open_wait_and_bind_to_descriptor_v1
+ (PSI_file_locker *locker, File file, const char *filename);
+
+void pfs_start_file_wait_v1(PSI_file_locker *locker,
+ size_t count,
+ const char *src_file,
+ uint src_line);
+
+void pfs_end_file_wait_v1(PSI_file_locker *locker,
+ size_t byte_count);
+
+void pfs_start_file_close_wait_v1(PSI_file_locker *locker,
+ const char *src_file,
+ uint src_line);
+
+void pfs_end_file_close_wait_v1(PSI_file_locker *locker, int rc);
+
+void pfs_end_file_rename_wait_v1(PSI_file_locker *locker, const char *old_name,
+ const char *new_name, int rc);
+
+C_MODE_END
+
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_FILE_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_idle_provider.h b/include/pfs_idle_provider.h
new file mode 100644
index 00000000000..71d116f7423
--- /dev/null
+++ b/include/pfs_idle_provider.h
@@ -0,0 +1,48 @@
+/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_IDLE_PROVIDER_H
+#define PFS_IDLE_PROVIDER_H
+
+/**
+ @file include/pfs_idle_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_IDLE_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_IDLE_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+PSI_idle_locker*
+pfs_start_idle_wait_v1(PSI_idle_locker_state* state, const char *src_file, uint src_line);
+
+void pfs_end_idle_wait_v1(PSI_idle_locker* locker);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_IDLE_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_memory_provider.h b/include/pfs_memory_provider.h
new file mode 100644
index 00000000000..ea60f9de3be
--- /dev/null
+++ b/include/pfs_memory_provider.h
@@ -0,0 +1,57 @@
+/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_MEMORY_PROVIDER_H
+#define PFS_MEMORY_PROVIDER_H
+
+/**
+ @file include/pfs_memory_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_MEMORY_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_MEMORY_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_memory_v1
+ (const char *category, struct PSI_memory_info_v1 *info, int count);
+
+PSI_memory_key
+pfs_memory_alloc_v1
+ (PSI_memory_key key, size_t size, PSI_thread **owner);
+
+PSI_memory_key
+pfs_memory_realloc_v1
+ (PSI_memory_key key, size_t old_size, size_t new_size, PSI_thread **owner);
+
+void pfs_memory_free_v1
+ (PSI_memory_key key, size_t size, PSI_thread *owner);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_MEMORY_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_metadata_provider.h b/include/pfs_metadata_provider.h
new file mode 100644
index 00000000000..cf3dd0d0dc1
--- /dev/null
+++ b/include/pfs_metadata_provider.h
@@ -0,0 +1,67 @@
+/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_METADATA_PROVIDER_H
+#define PFS_METADATA_PROVIDER_H
+
+/**
+ @file include/pfs_metadata_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_METADATA_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_METADATA_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+PSI_metadata_lock* pfs_create_metadata_lock_v1
+ (void *identity,
+ const MDL_key *key,
+ opaque_mdl_type mdl_type,
+ opaque_mdl_duration mdl_duration,
+ opaque_mdl_status mdl_status,
+ const char *src_file,
+ uint src_line);
+
+void pfs_set_metadata_lock_status_v1
+ (PSI_metadata_lock *lock,
+ opaque_mdl_status mdl_status);
+
+void pfs_destroy_metadata_lock_v1(PSI_metadata_lock *lock);
+
+struct PSI_metadata_locker*
+pfs_start_metadata_wait_v1
+ (struct PSI_metadata_locker_state_v1 *state,
+ struct PSI_metadata_lock *mdl,
+ const char *src_file, uint src_line);
+
+void pfs_end_metadata_wait_v1
+ (struct PSI_metadata_locker *locker, int rc);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_METADATA_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_socket_provider.h b/include/pfs_socket_provider.h
new file mode 100644
index 00000000000..bfafdaafb00
--- /dev/null
+++ b/include/pfs_socket_provider.h
@@ -0,0 +1,71 @@
+/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_SOCKET_PROVIDER_H
+#define PFS_SOCKET_PROVIDER_H
+
+/**
+ @file include/pfs_socket_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_SOCKET_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_SOCKET_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_socket_v1(const char *category,
+ PSI_socket_info_v1 *info,
+ int count);
+
+PSI_socket*
+pfs_init_socket_v1(PSI_socket_key key, const my_socket *fd,
+ const struct sockaddr *addr, socklen_t addr_len);
+
+void pfs_destroy_socket_v1(PSI_socket *socket);
+
+PSI_socket_locker*
+pfs_start_socket_wait_v1(PSI_socket_locker_state *state,
+ PSI_socket *socket,
+ PSI_socket_operation op,
+ size_t count,
+ const char *src_file, uint src_line);
+
+void pfs_end_socket_wait_v1(PSI_socket_locker *locker, size_t byte_count);
+
+void pfs_set_socket_state_v1(PSI_socket *socket, PSI_socket_state state);
+
+void pfs_set_socket_info_v1(PSI_socket *socket,
+ const my_socket *fd,
+ const struct sockaddr *addr,
+ socklen_t addr_len);
+
+void pfs_set_socket_thread_owner_v1(PSI_socket *socket);
+
+C_MODE_END
+
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_SOCKET_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_stage_provider.h b/include/pfs_stage_provider.h
new file mode 100644
index 00000000000..2ad2faab890
--- /dev/null
+++ b/include/pfs_stage_provider.h
@@ -0,0 +1,52 @@
+/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_STAGE_PROVIDER_H
+#define PFS_STAGE_PROVIDER_H
+
+/**
+ @file include/pfs_stage_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_STAGE_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_STAGE_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_stage_v1(const char *category,
+ PSI_stage_info_v1 **info_array,
+ int count);
+
+PSI_stage_progress* pfs_start_stage_v1(PSI_stage_key key, const char *src_file, int src_line);
+PSI_stage_progress* pfs_get_current_stage_progress_v1();
+
+void pfs_end_stage_v1();
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_STAGE_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_statement_provider.h b/include/pfs_statement_provider.h
new file mode 100644
index 00000000000..96870d8400d
--- /dev/null
+++ b/include/pfs_statement_provider.h
@@ -0,0 +1,118 @@
+/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_STATEMENT_PROVIDER_H
+#define PFS_STATEMENT_PROVIDER_H
+
+/**
+ @file include/pfs_statement_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_STATEMENT_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_STATEMENT_CALL(M) pfs_ ## M ## _v1
+#define PSI_DIGEST_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_statement_v1(const char *category,
+ PSI_statement_info_v1 *info,
+ int count);
+
+PSI_statement_locker*
+pfs_get_thread_statement_locker_v1(PSI_statement_locker_state *state,
+ PSI_statement_key key,
+ const void *charset,
+ PSI_sp_share *sp_share);
+
+PSI_statement_locker*
+pfs_refine_statement_v1(PSI_statement_locker *locker,
+ PSI_statement_key key);
+
+void pfs_start_statement_v1(PSI_statement_locker *locker,
+ const char *db, uint db_len,
+ const char *src_file, uint src_line);
+
+void pfs_set_statement_text_v1(PSI_statement_locker *locker,
+ const char *text, uint text_len);
+
+void pfs_set_statement_lock_time_v1(PSI_statement_locker *locker,
+ ulonglong count);
+
+void pfs_set_statement_rows_sent_v1(PSI_statement_locker *locker,
+ ulonglong count);
+
+void pfs_set_statement_rows_examined_v1(PSI_statement_locker *locker,
+ ulonglong count);
+
+void pfs_inc_statement_created_tmp_disk_tables_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_created_tmp_tables_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_select_full_join_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_select_full_range_join_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_select_range_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_select_range_check_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_select_scan_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_sort_merge_passes_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_sort_range_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_sort_rows_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_inc_statement_sort_scan_v1(PSI_statement_locker *locker,
+ ulong count);
+
+void pfs_set_statement_no_index_used_v1(PSI_statement_locker *locker);
+
+void pfs_set_statement_no_good_index_used_v1(PSI_statement_locker *locker);
+
+void pfs_end_statement_v1(PSI_statement_locker *locker, void *stmt_da);
+
+PSI_digest_locker *pfs_digest_start_v1(PSI_statement_locker *locker);
+
+void pfs_digest_end_v1(PSI_digest_locker *locker,
+ const sql_digest_storage *digest);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_STATEMENT_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_table_provider.h b/include/pfs_table_provider.h
new file mode 100644
index 00000000000..0d7ee76274b
--- /dev/null
+++ b/include/pfs_table_provider.h
@@ -0,0 +1,83 @@
+/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_TABLE_PROVIDER_H
+#define PFS_TABLE_PROVIDER_H
+
+/**
+ @file include/pfs_table_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_TABLE_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_TABLE_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+PSI_table_share*
+pfs_get_table_share_v1(my_bool temporary, struct TABLE_SHARE *share);
+
+void pfs_release_table_share_v1(PSI_table_share* share);
+
+void
+pfs_drop_table_share_v1(my_bool temporary,
+ const char *schema_name, int schema_name_length,
+ const char *table_name, int table_name_length);
+
+PSI_table*
+pfs_open_table_v1(PSI_table_share *share, const void *identity);
+
+void pfs_unbind_table_v1(PSI_table *table);
+
+PSI_table *
+pfs_rebind_table_v1(PSI_table_share *share, const void *identity, PSI_table *table);
+
+void pfs_close_table_v1(struct TABLE_SHARE *server_share, PSI_table *table);
+
+PSI_table_locker*
+pfs_start_table_io_wait_v1(PSI_table_locker_state *state,
+ PSI_table *table,
+ PSI_table_io_operation op,
+ uint index,
+ const char *src_file, uint src_line);
+
+PSI_table_locker*
+pfs_start_table_lock_wait_v1(PSI_table_locker_state *state,
+ PSI_table *table,
+ PSI_table_lock_operation op,
+ ulong op_flags,
+ const char *src_file, uint src_line);
+
+void pfs_end_table_io_wait_v1(PSI_table_locker* locker, ulonglong numrows);
+
+void pfs_end_table_lock_wait_v1(PSI_table_locker* locker);
+
+void pfs_unlock_table_v1(PSI_table *table);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_TABLE_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_thread_provider.h b/include/pfs_thread_provider.h
new file mode 100644
index 00000000000..6b5633722f5
--- /dev/null
+++ b/include/pfs_thread_provider.h
@@ -0,0 +1,172 @@
+/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_THREAD_PROVIDER_H
+#define PFS_THREAD_PROVIDER_H
+
+/**
+ @file include/pfs_thread_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_THREAD_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_MUTEX_CALL(M) pfs_ ## M ## _v1
+#define PSI_RWLOCK_CALL(M) pfs_ ## M ## _v1
+#define PSI_COND_CALL(M) pfs_ ## M ## _v1
+#define PSI_THREAD_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+void pfs_register_mutex_v1(const char *category,
+ PSI_mutex_info_v1 *info,
+ int count);
+
+void pfs_register_rwlock_v1(const char *category,
+ PSI_rwlock_info_v1 *info,
+ int count);
+
+void pfs_register_cond_v1(const char *category,
+ PSI_cond_info_v1 *info,
+ int count);
+
+void pfs_register_thread_v1(const char *category,
+ PSI_thread_info_v1 *info,
+ int count);
+
+PSI_mutex*
+pfs_init_mutex_v1(PSI_mutex_key key, void *identity);
+
+void pfs_destroy_mutex_v1(PSI_mutex* mutex);
+
+PSI_rwlock*
+pfs_init_rwlock_v1(PSI_rwlock_key key, void *identity);
+
+void pfs_destroy_rwlock_v1(PSI_rwlock* rwlock);
+
+PSI_cond*
+pfs_init_cond_v1(PSI_cond_key key, void *identity);
+
+void pfs_destroy_cond_v1(PSI_cond* cond);
+
+int pfs_spawn_thread_v1(PSI_thread_key key,
+ pthread_t *thread, const pthread_attr_t *attr,
+ void *(*start_routine)(void*), void *arg);
+
+PSI_thread*
+pfs_new_thread_v1(PSI_thread_key key, const void *identity, ulonglong processlist_id);
+
+void pfs_set_thread_id_v1(PSI_thread *thread, ulonglong processlist_id);
+void pfs_set_thread_THD_v1(PSI_thread *thread, THD *thd);
+void pfs_set_thread_os_id_v1(PSI_thread *thread);
+
+PSI_thread*
+pfs_get_thread_v1(void);
+
+void pfs_set_thread_user_v1(const char *user, int user_len);
+
+void pfs_set_thread_account_v1(const char *user, int user_len,
+ const char *host, int host_len);
+
+void pfs_set_thread_db_v1(const char* db, int db_len);
+
+void pfs_set_thread_command_v1(int command);
+
+void pfs_set_thread_start_time_v1(time_t start_time);
+
+void pfs_set_thread_state_v1(const char* state);
+
+void pfs_set_connection_type_v1(opaque_vio_type conn_type);
+
+void pfs_set_thread_info_v1(const char* info, uint info_len);
+
+void pfs_set_thread_v1(PSI_thread* thread);
+
+void pfs_set_thread_peer_port_v1(PSI_thread *thread, uint port);
+
+void pfs_delete_current_thread_v1(void);
+
+void pfs_delete_thread_v1(PSI_thread *thread);
+
+PSI_mutex_locker*
+pfs_start_mutex_wait_v1(PSI_mutex_locker_state *state,
+ PSI_mutex *mutex, PSI_mutex_operation op,
+ const char *src_file, uint src_line);
+
+PSI_rwlock_locker*
+pfs_start_rwlock_rdwait_v1(PSI_rwlock_locker_state *state,
+ PSI_rwlock *rwlock,
+ PSI_rwlock_operation op,
+ const char *src_file, uint src_line);
+
+PSI_rwlock_locker*
+pfs_start_rwlock_wrwait_v1(PSI_rwlock_locker_state *state,
+ PSI_rwlock *rwlock,
+ PSI_rwlock_operation op,
+ const char *src_file, uint src_line);
+
+PSI_cond_locker*
+pfs_start_cond_wait_v1(PSI_cond_locker_state *state,
+ PSI_cond *cond, PSI_mutex *mutex,
+ PSI_cond_operation op,
+ const char *src_file, uint src_line);
+
+PSI_table_locker*
+pfs_start_table_io_wait_v1(PSI_table_locker_state *state,
+ PSI_table *table,
+ PSI_table_io_operation op,
+ uint index,
+ const char *src_file, uint src_line);
+
+PSI_table_locker*
+pfs_start_table_lock_wait_v1(PSI_table_locker_state *state,
+ PSI_table *table,
+ PSI_table_lock_operation op,
+ ulong op_flags,
+ const char *src_file, uint src_line);
+
+void pfs_unlock_mutex_v1(PSI_mutex *mutex);
+
+void pfs_unlock_rwlock_v1(PSI_rwlock *rwlock);
+
+void pfs_signal_cond_v1(PSI_cond* cond);
+
+void pfs_broadcast_cond_v1(PSI_cond* cond);
+
+void pfs_end_mutex_wait_v1(PSI_mutex_locker* locker, int rc);
+
+void pfs_end_rwlock_rdwait_v1(PSI_rwlock_locker* locker, int rc);
+
+void pfs_end_rwlock_wrwait_v1(PSI_rwlock_locker* locker, int rc);
+
+void pfs_end_cond_wait_v1(PSI_cond_locker* locker, int rc);
+
+int pfs_set_thread_connect_attrs_v1(const char *buffer, uint length,
+ const void *from_cs);
+
+C_MODE_END
+
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_THREAD_INTERFACE */
+
+#endif
+
diff --git a/include/pfs_transaction_provider.h b/include/pfs_transaction_provider.h
new file mode 100644
index 00000000000..fdaad8ae1c6
--- /dev/null
+++ b/include/pfs_transaction_provider.h
@@ -0,0 +1,79 @@
+/* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef PFS_TRANSACTION_PROVIDER_H
+#define PFS_TRANSACTION_PROVIDER_H
+
+/**
+ @file include/pfs_transaction_provider.h
+ Performance schema instrumentation (declarations).
+*/
+
+#ifdef HAVE_PSI_TRANSACTION_INTERFACE
+#ifdef MYSQL_SERVER
+#ifndef EMBEDDED_LIBRARY
+#ifndef MYSQL_DYNAMIC_PLUGIN
+
+#include "mysql/psi/psi.h"
+
+#define PSI_TRANSACTION_CALL(M) pfs_ ## M ## _v1
+
+C_MODE_START
+
+PSI_transaction_locker*
+pfs_get_thread_transaction_locker_v1(PSI_transaction_locker_state *state,
+ const void *xid,
+ ulonglong trxid,
+ int isolation_level,
+ my_bool read_only,
+ my_bool autocommit);
+
+void pfs_start_transaction_v1(PSI_transaction_locker *locker,
+ const char *src_file, uint src_line);
+
+void pfs_set_transaction_xid_v1(PSI_transaction_locker *locker,
+ const void *xid,
+ int xa_state);
+
+void pfs_set_transaction_xa_state_v1(PSI_transaction_locker *locker,
+ int xa_state);
+
+void pfs_set_transaction_gtid_v1(PSI_transaction_locker *locker,
+ const void *sid,
+ const void *gtid_spec);
+
+void pfs_set_transaction_trxid_v1(PSI_transaction_locker *locker,
+ const ulonglong *trxid);
+
+void pfs_inc_transaction_savepoints_v1(PSI_transaction_locker *locker,
+ ulong count);
+
+void pfs_inc_transaction_rollback_to_savepoint_v1(PSI_transaction_locker *locker,
+ ulong count);
+
+void pfs_inc_transaction_release_savepoint_v1(PSI_transaction_locker *locker,
+ ulong count);
+
+void pfs_end_transaction_v1(PSI_transaction_locker *locker, my_bool commit);
+
+C_MODE_END
+
+#endif /* MYSQL_DYNAMIC_PLUGIN */
+#endif /* EMBEDDED_LIBRARY */
+#endif /* MYSQL_SERVER */
+#endif /* HAVE_PSI_TRANSACTION_INTERFACE */
+
+#endif
+
diff --git a/include/service_versions.h b/include/service_versions.h
index fb7e715f858..34e4952c94c 100644
--- a/include/service_versions.h
+++ b/include/service_versions.h
@@ -41,5 +41,6 @@
#define VERSION_thd_specifics 0x0100
#define VERSION_thd_timezone 0x0100
#define VERSION_thd_wait 0x0100
-#define VERSION_wsrep 0x0400
+#define VERSION_wsrep 0x0500
#define VERSION_json 0x0100
+#define VERSION_thd_mdl 0x0100
diff --git a/include/ssl_compat.h b/include/ssl_compat.h
index 8dc1225407e..6db1baab9b5 100644
--- a/include/ssl_compat.h
+++ b/include/ssl_compat.h
@@ -24,7 +24,7 @@
#define SSL_LIBRARY OpenSSL_version(OPENSSL_VERSION)
#define ERR_remove_state(X) ERR_clear_error()
#define EVP_CIPHER_CTX_SIZE 176
-#define EVP_MD_CTX_SIZE 48
+#define EVP_MD_CTX_SIZE 72
#undef EVP_MD_CTX_init
#define EVP_MD_CTX_init(X) do { memset((X), 0, EVP_MD_CTX_SIZE); EVP_MD_CTX_reset(X); } while(0)
#undef EVP_CIPHER_CTX_init
@@ -77,7 +77,6 @@
#define DH_set0_pqg(D,P,Q,G) ((D)->p= (P), (D)->g= (G))
#endif
-#define EVP_CIPHER_CTX_buf_noconst(ctx) ((ctx)->buf)
#define EVP_CIPHER_CTX_encrypting(ctx) ((ctx)->encrypt)
#define EVP_CIPHER_CTX_SIZE sizeof(EVP_CIPHER_CTX)
diff --git a/include/thr_lock.h b/include/thr_lock.h
index 2873d40c58a..1ea24132d90 100644
--- a/include/thr_lock.h
+++ b/include/thr_lock.h
@@ -126,7 +126,7 @@ typedef struct st_thr_lock {
/* write_lock_count is incremented for write locks and reset on read locks */
ulong write_lock_count;
uint read_no_write_count;
- void (*get_status)(void*, my_bool); /* When one gets a lock */
+ my_bool (*get_status)(void*, my_bool);/* Called when one gets a lock */
void (*copy_status)(void*,void*);
void (*update_status)(void*); /* Before release of write */
void (*restore_status)(void*); /* Before release of read */
diff --git a/include/thr_timer.h b/include/thr_timer.h
index 4f0c4f08660..6bca815480b 100644
--- a/include/thr_timer.h
+++ b/include/thr_timer.h
@@ -23,6 +23,7 @@ extern "C" {
typedef struct st_timer {
struct timespec expire_time;
+ ulonglong period;
my_bool expired;
uint index_in_queue;
void (*func)(void*);
@@ -36,6 +37,7 @@ void end_thr_timer();
/* Functions for handling one timer */
void thr_timer_init(thr_timer_t *timer_data, void(*function)(void*),
void *arg);
+void thr_timer_set_period(thr_timer_t* timer_data, ulonglong microseconds);
my_bool thr_timer_settime(thr_timer_t *timer_data, ulonglong microseconds);
void thr_timer_end(thr_timer_t *timer_data);
diff --git a/include/thread_pool_priv.h b/include/thread_pool_priv.h
index 47f281192e9..769c4a7d97d 100644
--- a/include/thread_pool_priv.h
+++ b/include/thread_pool_priv.h
@@ -38,12 +38,6 @@
#include <table.h>
#include <sql_list.h>
-/* Needed to get access to scheduler variables */
-void* thd_get_scheduler_data(THD *thd);
-void thd_set_scheduler_data(THD *thd, void *data);
-PSI_thread* thd_get_psi(THD *thd);
-void thd_set_psi(THD *thd, PSI_thread *psi);
-
/* Interface to THD variables and functions */
void thd_set_killed(THD *thd);
void thd_clear_errors(THD *thd);
@@ -82,8 +76,6 @@ bool do_command(THD *thd);
ensure that the proper MySQL Server logic attached to these events is
executed.
*/
-/* Initialise a new connection handler thread */
-bool init_new_connection_handler_thread();
/* Set up connection thread before use as execution thread */
bool setup_connection_thread_globals(THD *thd);
/* Prepare connection as part of connection set-up */
@@ -94,8 +86,6 @@ void mysql_audit_release(THD *thd);
bool thd_is_connection_alive(THD *thd);
/* Close connection with possible error code */
void close_connection(THD *thd, uint errcode);
-/* Decrement connection counter */
-void dec_connection_count();
/* Destroy THD object */
void delete_thd(THD *thd);
diff --git a/include/typelib.h b/include/typelib.h
index b20724fe05e..dc315dd3bb8 100644
--- a/include/typelib.h
+++ b/include/typelib.h
@@ -27,7 +27,8 @@ typedef struct st_typelib { /* Different types saved here */
unsigned int *type_lengths;
} TYPELIB;
-extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
+extern my_ulonglong find_typeset(const char *x, TYPELIB *typelib,
+ int *error_position);
extern int find_type_with_warning(const char *x, TYPELIB *typelib,
const char *option);
#define FIND_TYPE_BASIC 0
@@ -43,7 +44,7 @@ extern int find_type_with_warning(const char *x, TYPELIB *typelib,
extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags);
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
extern const char *get_type(TYPELIB *typelib,unsigned int nr);
-extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);
+extern TYPELIB *copy_typelib(MEM_ROOT *root, const TYPELIB *from);
extern TYPELIB sql_protocol_typelib;
diff --git a/include/violite.h b/include/violite.h
index f0fc53e4d6e..28e3ca08b0a 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -39,7 +39,10 @@ enum enum_vio_type
{
VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE,
VIO_TYPE_SSL
+ /* see also vio_type_names[] */
};
+#define FIRST_VIO_TYPE VIO_CLOSED
+#define LAST_VIO_TYPE VIO_TYPE_SSL
/**
VIO I/O events.
@@ -187,6 +190,8 @@ void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd);
void vio_end(void);
+const char *vio_type_name(enum enum_vio_type vio_type, size_t *len);
+
#ifdef __cplusplus
}
#endif